Code

Backports from trunk
[gosa.git] / gosa-plugins / systems / admin / systems / class_systemManagement.inc
index b14b2de3ef7e8adafa5ddd45920637b8850b12da..3c2b052f4ce518de9f461479be2f42f2c36d4f7c 100644 (file)
@@ -119,6 +119,7 @@ class systemManagement extends management
         $this->registerAction("systemTypeChosen","systemTypeChosen");
         $this->registerAction("handleActivationQueue","handleActivationQueue");
 
+        $this->registerAction("new_device",           "newEntry");
         $this->registerAction("new_goServer",         "newEntry");
         $this->registerAction("new_gotoWorkstation",  "newEntry");
         $this->registerAction("new_gotoTerminal",     "newEntry");
@@ -164,7 +165,7 @@ class systemManagement extends management
             $entry = $headpage->getEntry($dn);
             $ui       = get_userinfo();
             $smarty = get_smarty();
-            if(in_array("FAKE_OC_PWD_changeAble", $entry['objectClass'])){
+            if(in_array_strict("FAKE_OC_PWD_changeAble", $entry['objectClass'])){
                 $acl = $tDefs[$type]['aclCategory'].'/'.$tDefs[$type]['aclClass'];
                 $tabacl   = $ui->get_permissions($dn,$acl,"userPassword");
                 if(preg_match("/w/",$tabacl)){
@@ -267,7 +268,7 @@ class systemManagement extends management
         $ui       = get_userinfo();
         $smarty = get_smarty();
 
-        if(!in_array('FAKE_OC_PWD_changeAble', $entry['objectClass'])){
+        if(!in_array_strict('FAKE_OC_PWD_changeAble', $entry['objectClass'])){
             trigger_error("Tried to change pwd, for invalid object!");
         }elseif (get_post('new_password') != get_post('repeated_password')){
             msg_dialog::display(_("Error"), 
@@ -291,7 +292,7 @@ class systemManagement extends management
 
                     /* Remove password attribute
                      */
-                    if(in_array("simpleSecurityObject",$old_attrs['objectClass'])){
+                    if(in_array_strict("simpleSecurityObject",$old_attrs['objectClass'])){
                         $attrs['objectClass'] = array();
                         for($i = 0 ; $i < $old_attrs['objectClass']['count'] ; $i ++){
                             if(!preg_match("/simpleSecurityObject/i",$old_attrs['objectClass'][$i])){
@@ -304,7 +305,7 @@ class systemManagement extends management
 
                     /* Add/modify password attribute
                      */
-                    if(!in_array("simpleSecurityObject",$old_attrs['objectClass'])){
+                    if(!in_array_strict("simpleSecurityObject",$old_attrs['objectClass'])){
                         $attrs['objectClass'] = array();
                         for($i = 0 ; $i < $old_attrs['objectClass']['count'] ; $i ++){
                             $attrs['objectClass'][] = $old_attrs['objectClass'][$i];
@@ -489,13 +490,13 @@ class systemManagement extends management
             /* Skip installation or update trigerred events,
              *  if this entry is currently processing.
              */
-            if($triggered && in_array($event,array("DaemonEvent_reinstall","DaemonEvent_update"))){
+            if($triggered && in_array_strict($event,array("DaemonEvent_reinstall","DaemonEvent_update"))){
                 foreach($mac as $key => $mac_address){
                     foreach($o_queue->get_entries_by_mac(array($mac_address)) as $entry){
                         $entry['STATUS'] = strtoupper($entry['STATUS']);
                         if($entry['STATUS'] == "PROCESSING" &&
                                 isset($events['QUEUED'][$entry['HEADERTAG']]) &&
-                                in_array($events['QUEUED'][$entry['HEADERTAG']],array("DaemonEvent_reinstall","DaemonEvent_update"))){
+                                in_array_strict($events['QUEUED'][$entry['HEADERTAG']],array("DaemonEvent_reinstall","DaemonEvent_update"))){
                             unset($mac[$key]);
 
                             new log("security","systems/".get_class($this),"",array(),"Skip adding 'DaemonEvent::".$type."' for mac '".$mac_address."', there is already a job in progress.");
@@ -660,7 +661,7 @@ class systemManagement extends management
                     // Delete the object
                     $this->dn = $dn;
                     if($info['tabClass'] == "phonetabs"){
-                        $this->tabObject= new $tabtype($this->config, $this->config->data['TABS'][$tabobj], $dn,$type);
+                        $this->tabObject= new $info['tabClass']($this->config, $this->config->data['TABS'][$info['tabDesc']], $dn,$type);
                         $this->tabObject->set_acl_base($dn);
                         $this->tabObject->by_object['phoneGeneric']->remove_from_parent ();
                     }else{
@@ -700,6 +701,12 @@ class systemManagement extends management
             $headpage = $this->getHeadpage();
             $dn = $target[0];
             $type =$headpage->getType($dn);
+
+            if(!isset($tInfo[$type])){
+                msg_dialog::display(_("Information"),sprintf(_("The object-type '%s' cannot be managed with your setup of GOsa, please install the required  plugins!"), $type), ERROR_DIALOG);
+                return;
+            }
+
             $tData = $tInfo[$type];
 
             if($type == "FAKE_OC_ArpNewDevice"){
@@ -1074,7 +1081,7 @@ class systemManagement extends management
                 $ocs = $attrs['objectClass'];
                 unset($ocs['count']);
                 $new_attrs = array();
-                if(!in_array("FAIobject",$ocs)){
+                if(!in_array_strict("FAIobject",$ocs)){
                     $ocs[] = "FAIobject";
                     $new_attrs['objectClass'] = $ocs;
                 }
@@ -1272,6 +1279,15 @@ class systemManagement extends management
     public function getObjectDefinitions()
     {
         $tabs = array(
+                "device" => array(
+                    "ou"          => get_ou('Device','GOsaDeviceRDN'),
+                    "plugClass"   => "Device",
+                    "tabClass"    => "DeviceTab",
+                    "tabDesc"     => "NEWDEVICETABS",
+                    "aclClass"    => "Device",
+                    "sendEvents"  => FALSE,
+                    "aclCategory" => "Device"),
+
                 "FAKE_OC_OpsiHost" => array(
                     "ou"          => "",
                     "plugClass"   => "opsiGeneric",
@@ -1372,11 +1388,21 @@ class systemManagement extends management
 
         $tabs['FAKE_OC_ArpNewDevice'] = &$tabs['FAKE_OC_NewDevice'];
 
+
+        // Remove those types, we cannot handle at the moment due to lack of 
+        //  installed GOsa-plugins.
+        foreach($tabs as $name => $tab){
+
+            if(!class_available($tab['plugClass'])) {
+                unset($tabs[$name]);
+            }
+        }
+
         return($tabs);
     }
 
 
-    static function filterSystemDescription($row,$dn,$pid,$state,$description=array())
+    static function filterSystemDescription($row,$dn,$pid,$state = '',$description=array())
     {
         $dn= LDAP::fix(func_get_arg(1));
         $desc = isset($description[0])?set_post($description[0]):"";
@@ -1473,7 +1499,7 @@ class systemManagement extends management
                             "name"          => "systemRDN",
                             "type"          => "rdn",
                             "default"       => "ou=systems,",
-                            "description"   => _("The 'systemRDN' statement defines the location where new systems will be created. The default is 'ou=systems,'."),
+                            "description"   => _("RDN for system storage."),
                             "check"         => "gosaProperty::isRdn",
                             "migrate"       => "migrate_systemRDN",
                             "group"         => "plugin",