Code

Updated parent handling for connectivity extensions
[gosa.git] / gosa-plugins / connectivity / personal / connectivity / class_connectivity.inc
index c5ca2aa8c51138b0b89178b0a658218a0d43ba23..f1be45aa0e325c7886cf5f4ce8e2664b1b3cca2f 100644 (file)
@@ -13,7 +13,8 @@ class connectivity extends plugin
 {
   /* Definitions */
   var $plHeadline= "Connectivity";
-  var $plDescription= "This does something";
+  var $plDescription= "Manage connectivity user settings";
+  var $plIcon = "plugins/connectivity/images/plugin.png";
 
   /* attribute list for save action */
   var $attributes= array();
@@ -29,6 +30,7 @@ class connectivity extends plugin
   function connectivity (&$config, $dn= NULL,$parent =NULL)
   {
     /* Preseed permissions */
+    $this->initTime = microtime(TRUE);
     $this->dn= $dn;
     $ui= get_userinfo();
 
@@ -36,9 +38,10 @@ class connectivity extends plugin
   
     /* Load accounts */
     foreach ($config->data['TABS']['CONNECTIVITY'] as $plug){
-      if (!plugin_available($plug['CLASS'])) {
+      if (!class_available($plug['CLASS']) || !plugin_available($plug['CLASS'])) {
        continue;
       }
+
       $name= $plug['CLASS'];
       $this->plugin_name[]= $name;
       $this->plugin[$name]= new $name($config, $dn,$parent);
@@ -49,6 +52,11 @@ class connectivity extends plugin
       $this->plugin[$name]-> set_acl_category("users");
       $this->plugin[$name]-> set_acl_base($this->dn);
     }
+
+    // Create statistic table entry
+    stats::log('plugin', $class = get_class($this), $category = array($this->acl_category),  $action = 'open',
+            $amount = 1, $duration = (microtime(TRUE) - $this->initTime));
+
   }
 
   function execute()
@@ -71,14 +79,13 @@ class connectivity extends plugin
         }
       }
       if (!$enabled){
-        $display= "<img alt=\"\" src=\"images/stop.png\" align=\"middle\">&nbsp;<b>".
-          _("This account has no connectivity extensions.")."</b>";
+        $display= "<img alt=\"\" src=\"images/small-error.png\" align=\"middle\">&nbsp;<b>".
+          msgPool::noValidExtension()."</b>";
         $display.= back_to_main();
         return ($display);
       }
     }
 
-    /* Remove checkboxes in single edit mode */
     if ($this->parent !== NULL){
       foreach ($this->plugin_name as $name){
         $this->plugin[$name]->parent= $this->parent;
@@ -88,12 +95,10 @@ class connectivity extends plugin
     /* Execude  objects */
     $is_first= true;
 
-    $ReadOnly = (!isset($this->parent) || !$this->parent) && !session::is_set('edit');
-
     foreach ($this->plugin_name as $name){
-      $this->plugin[$name]->ReadOnly = $ReadOnly;
+      $this->plugin[$name]->read_only = &$this->read_only;
       if (!$is_first){
-        $display.= '<p class="seperator">&nbsp;</p>';
+        $display.= '<hr>';
       } else {
         $is_first= false;
       }
@@ -149,6 +154,13 @@ class connectivity extends plugin
   /* Save to LDAP */
   function save()
   {
+    // Append parent to sub-plugins.
+    if ($this->parent !== NULL){
+      foreach ($this->plugin_name as $name){
+        $this->plugin[$name]->parent= $this->parent;
+      }
+    }
+
     /* Save objects */
     foreach ($this->plugin_name as $name){
       $this->plugin[$name]->dn= $this->dn;
@@ -163,6 +175,13 @@ class connectivity extends plugin
 
   function remove_from_parent()
   {
+    // Append parent to sub-plugins.
+    if ($this->parent !== NULL){
+      foreach ($this->plugin_name as $name){
+        $this->plugin[$name]->parent= $this->parent;
+      }
+    }
+
     /* Remove objects */
     foreach ($this->plugin_name as $name){
       $this->plugin[$name]->dn= $this->dn;
@@ -170,12 +189,12 @@ class connectivity extends plugin
     }
   }
 
-  function adapt_from_template($dn)
+  function adapt_from_template($dn, $skip= array())
   {
     /* Adapt objects */
     foreach ($this->plugin_name as $name){
       $this->plugin[$name]->dn= $this->dn;
-      $this->plugin[$name]->adapt_from_template($dn);
+      $this->plugin[$name]->adapt_from_template($dn, $skip);
     }
   }
 
@@ -259,6 +278,27 @@ class connectivity extends plugin
       $this->plugin[$name]->set_multi_edit_values($plugin->get_multi_edit_values());
     }
   }
+
+
+  /* Return plugin informations for acl handling */
+  static function plInfo()
+  {
+    return (array(
+          "plShortName"     => _("Connectivity"),
+          "plDepends"       => array("user"),
+          "plPriority"      => 20,                                 // Position in tabs
+          "plSection"     => array("personal" => _("My account")),
+          "plCategory"    => array("users"),
+          "plOptions"       => array(),
+
+          "plDescription"       => _("Connectivity add-on"),
+          "plSelfModify"        => TRUE,
+
+          "plProvidedAcls"  => array()
+          ));
+  }
+
+
 }
 
 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: