Code

Updated plugin deactivation
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Wed, 26 May 2010 08:40:21 +0000 (08:40 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Wed, 26 May 2010 08:40:21 +0000 (08:40 +0000)
-Deactivate Icon Menu entries too.
-Do not allow to instantiate tabs while base plugin is not available

git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@18746 594d385d-05f5-0310-b6e9-bd551577e9d8

gosa-core/include/class_management.inc
gosa-core/include/class_pluglist.inc
gosa-core/plugins/personal/generic/class_user.inc
gosa-core/plugins/personal/myaccount/main.inc

index 837688dc568a9d1ec7fd65e6a998384eb2aa5445..77f07307f1bedaf0e9687a9a1f86570de83adbc5 100644 (file)
@@ -625,11 +625,21 @@ class management
     if(empty($tabClass) || empty($tabType)){
       // No tab type defined
     }else{
-      if (isset($this->config->data['TABS'][$tabType])) {
-        $this->tabObject= new $tabClass($this->config,$this->config->data['TABS'][$tabType], $this->dn, $aclCategory);
-        $this->tabObject->set_acl_base($this->headpage->getBase());
-        $this->tabObject->parent = &$this;
-        @DEBUG (DEBUG_TRACE, __LINE__, __FUNCTION__, __FILE__,$this->dn,"Create new entry initiated!");
+
+        if (isset($this->config->data['TABS'][$tabType])) {
+
+            // Check if the base plugin is available - it is mostly responsible for object creation and removal.
+            $first  = $this->config->data['TABS'][$tabType][0];
+            if(!class_available($first['CLASS'])){
+                msg_dialog::display(_("Internal error"),
+                        sprintf(_("Cannot instantiate tabbed-plugin, the base plugin (%s) is not available!"), $first['CLASS']),
+                        ERROR_DIALOG);
+            }else{
+                $this->tabObject= new $tabClass($this->config,$this->config->data['TABS'][$tabType], $this->dn, $aclCategory);
+                $this->tabObject->set_acl_base($this->headpage->getBase());
+                $this->tabObject->parent = &$this;
+                @DEBUG (DEBUG_TRACE, __LINE__, __FUNCTION__, __FILE__,$this->dn,"Create new entry initiated!");
+            }
       } else {
         msg_dialog::display(_("Error"), sprintf(_("No tab definition for %s found in configuration file: cannot create plugin instance!"), bold($tabType)), ERROR_DIALOG);
       }
index 3bf9caa74ca2b79abf2746b4fd7f761847c85282..83fd3c6ef082e454b149d451119391de8f821736 100644 (file)
@@ -186,7 +186,7 @@ class pluglist
         }
       }
 
-        $disabledPlugins = $this->config->configRegistry->getDisabledPlugins();
+      $disabledPlugins = $this->config->configRegistry->getDisabledPlugins();
 
       $cfg= $this->config->data['MENU'];
       $menu = "\n      <div class='navigation'>";
@@ -258,9 +258,10 @@ class pluglist
   function show_iconmenu()
   {
     $add_hr =FALSE;
-    $this->iconmenu = "";
     if ($this->iconmenu == ""){
 
+      $disabledPlugins = $this->config->configRegistry->getDisabledPlugins();
+
       $cfg= $this->config->data['MENU'];
       foreach ($cfg as $headline => $plug){
         $col= 0;
@@ -277,6 +278,9 @@ class pluglist
           // Get Plugin info
           list($index, $title, $desc, $icon) = $this->getPlugData($info['CLASS']);
 
+          // The Plugin has been deactivated for some reason, perhabs a missing ldap schema.
+          if(isset($disabledPlugins[$info['CLASS']])) continue;
+
           // Add a seperating row
           if (($col % 4) == 0){ 
             $this->iconmenu .= "\n        <div class='clear'></div>";
@@ -307,6 +311,8 @@ class pluglist
   {
     if(empty($this->pathMenu)){
 
+      $disabledPlugins = $this->config->configRegistry->getDisabledPlugins();
+
       // Now load the path menu and try to register the plugins in the pluglist
       //  if this fails for some reason, then remove the plugin from the menu.
       if(isset($this->config->data['PATHMENU'])){
@@ -331,6 +337,10 @@ class pluglist
         $rcfg = array_reverse($cfg);
         foreach($rcfg as $id => $plug){
           list($index, $title, $desc, $icon) = $this->getPlugData($plug['CLASS']);
+
+          // The Plugin has been deactivated for some reason, perhabs a missing ldap schema.
+          if(isset($disabledPlugins[$plug['CLASS']])) continue;
+
           $this->pathMenu.= "\n            <li class='right left-border' onClick='openPlugin({$index})'>{$title}</li>";
         }
       }
index 4b3ff88a067bb1a544f4ac9d678446ea05be7c31..12effd8a2875b5242232519e5b88396e7324447b 100644 (file)
@@ -1692,7 +1692,7 @@ class user extends plugin
                 'gosaAccount' => '>=2.7',
                 'gosaUserTemplate' => '>=2.7'
                 ),
-            'onFailureDisablePlugin' => array(get_class(),'userManagement')
+            'onFailureDisablePlugin' => array(get_class(),'userManagement', 'user')
             ),
 
         "plProperties" => array(
index 7c1c86bb7de3c7969f02046c76cc6d38ab6f5c15..a69c6ddb9ef6a0e2ef857d324b4d743e53afe8e2 100644 (file)
@@ -27,132 +27,145 @@ $lock_msg="";
 if ($remove_lock || isset($_POST['edit_cancel']) || isset($_POST['password_cancel'])){
   del_lock($ui->dn);
   if(session::is_set('MyAccountTabs') && session::is_set('edit')){
-    session::un_set('MyAccountTabs');
+      session::un_set('MyAccountTabs');
   }
 }
 
 /* Reset requested? */
 if (isset($_POST['edit_cancel']) || $cleanup){
-  session::un_set ('edit');
-  session::un_set ('MyAccountTabs');
+    session::un_set ('edit');
+    session::un_set ('MyAccountTabs');
 }
 
 /* Remove this plugin from session
  */
 if (! $cleanup ){
 
-  /* Create MyAccountTabs object on demand */
-  if (!session::is_set('MyAccountTabs') || (isset($_GET['reset']) && $_GET['reset'] == 1)){
-    $MyAccountTabs= new MyAccountTabs($config,$config->data['TABS']['MYACCOUNTTABS'], $ui->dn, "users", true, true); 
-    $MyAccountTabs->setReadOnly(TRUE);
-    session::set('MyAccountTabs',$MyAccountTabs);
-  }
-  $MyAccountTabs = session::get('MyAccountTabs');
-  
-  /* Enter edit mode? */
-  if ((isset($_POST['edit'])) && (!session::is_set('edit'))){
-    
-    /* Check locking */
-    if (($username= get_lock($ui->dn)) != ""){
-      session::set('back_plugin',$plug);
-      session::set('LOCK_VARS_TO_USE',array("/^edit$/","/^plug$/"));
-      $lock_msg =  gen_locked_message ($username, array($ui->dn));
-
-    }else{
-
-      /* Lock the current entry */
-      add_lock ($ui->dn, $ui->dn);
-      session::set('edit',TRUE);
-      $MyAccountTabs->setReadOnly(FALSE);
-    }
-  }
+    /* Create MyAccountTabs object on demand */
+    if (!session::is_set('MyAccountTabs') || (isset($_GET['reset']) && $_GET['reset'] == 1)){
 
-  $info= "";
-  if (isset($_POST['edit_finish'])){
-    $message= $MyAccountTabs->check ();
-    if (count ($message) == 0){
-      $MyAccountTabs->save ();
-      del_lock ($ui->dn);
-      session::un_set ('edit');
-      $MyAccountTabs->setReadOnly(TRUE);
-      if(isset($MyAccountTabs->by_object['user']) && $MyAccountTabs->by_object['user']->password_change_needed()){
-        $MyAccountTabs->password_change_needed = TRUE;
-      }else{
-        session::un_set ('MyAccountTabs');
-      }
-    } else {
-      msg_dialog::displayChecks($message);
+        // Check if the base plugin is available - it is mostly responsible for object creation and removal.
+        $first  = $config->data['TABS']['MYACCOUNTTABS'][0];
+        if(!class_available($first['CLASS'])){
+            msg_dialog::display(_("Internal error"),
+                    sprintf(_("Cannot instantiate tabbed-plugin, the base plugin (%s) is not available!"), $first['CLASS']),
+                    ERROR_DIALOG);
+        }else{
+
+            $MyAccountTabs= new MyAccountTabs($config,$config->data['TABS']['MYACCOUNTTABS'], $ui->dn, "users", true, true); 
+            $MyAccountTabs->setReadOnly(TRUE);
+            session::set('MyAccountTabs',$MyAccountTabs);
+        }
     }
-  }
 
+    if(session::is_set('MyAccountTabs')){
+        $MyAccountTabs = session::get('MyAccountTabs');
 
-  if (isset($_POST['password_finish']) && $MyAccountTabs->password_change_needed){
-    $user = $MyAccountTabs->by_object['user'];
+        /* Enter edit mode? */
+        if ((isset($_POST['edit'])) && (!session::is_set('edit'))){
 
-    if ($user->acl_is_writeable("userPassword") || $user->acl_is_createable()){
-      $message= array();
-      if ($_POST['new_password'] != $_POST['repeated_password']){
-        $message[]= _("The passwords you've entered as 'New password' and 'Repeated new password' do not match.");
-      } else {
-        if ($_POST['new_password'] == ""){
-          $message[]= msgPool::required(_("New password"));
+            /* Check locking */
+            if (($username= get_lock($ui->dn)) != ""){
+                session::set('back_plugin',$plug);
+                session::set('LOCK_VARS_TO_USE',array("/^edit$/","/^plug$/"));
+                $lock_msg =  gen_locked_message ($username, array($ui->dn));
+
+            }else{
+
+                /* Lock the current entry */
+                add_lock ($ui->dn, $ui->dn);
+                session::set('edit',TRUE);
+                $MyAccountTabs->setReadOnly(FALSE);
+            }
         }
-      }
-
-      if (count($message) != 0){
-        msg_dialog::displayChecks($message);
-        $display.= $smarty->fetch(get_template_path('password.tpl', TRUE));
-        return ($display);
-      }
-      change_password ($user->dn, $_POST['new_password'], 0, $user->pw_storage);
-      $MyAccountTabs= new MyAccountTabs($config,$config->data['TABS']['MYACCOUNTTABS'], $ui->dn, "users", true, true);
-      $MyAccountTabs->setReadOnly(TRUE);
-      session::set('MyAccountTabs',$MyAccountTabs);
-      new log("modify","users/password","",array(),"Password has been changed");
-    } else {
-      msg_dialog::display(_("Error"), _("You have no permission to set your password!"), ERROR_DIALOG);
-    }
 
-    del_lock ($ui->dn);
-    session::un_set ('user');
-  }
+        $info= "";
+        if (isset($_POST['edit_finish'])){
+            $message= $MyAccountTabs->check ();
+            if (count ($message) == 0){
+                $MyAccountTabs->save ();
+                del_lock ($ui->dn);
+                session::un_set ('edit');
+                $MyAccountTabs->setReadOnly(TRUE);
+                if(isset($MyAccountTabs->by_object['user']) && $MyAccountTabs->by_object['user']->password_change_needed()){
+                    $MyAccountTabs->password_change_needed = TRUE;
+                }else{
+                    session::un_set ('MyAccountTabs');
+                }
+            } else {
+                msg_dialog::displayChecks($message);
+            }
+        }
 
-  if($MyAccountTabs->password_change_needed){
-    $display.= $smarty->fetch(get_template_path('password.tpl', TRUE));
-  }
 
-  /* Execute formular */
-  if(!$MyAccountTabs->password_change_needed){
-    pathNavigator::registerPlugin(_("My account"));
-    if($lock_msg){
-      $display = $lock_msg;
-    }else{
-      $display.= $MyAccountTabs->execute ();
-    }
-  }
+        if (isset($_POST['password_finish']) && $MyAccountTabs->password_change_needed){
+            $user = $MyAccountTabs->by_object['user'];
+
+            if ($user->acl_is_writeable("userPassword") || $user->acl_is_createable()){
+                $message= array();
+                if ($_POST['new_password'] != $_POST['repeated_password']){
+                    $message[]= _("The passwords you've entered as 'New password' and 'Repeated new password' do not match.");
+                } else {
+                    if ($_POST['new_password'] == ""){
+                        $message[]= msgPool::required(_("New password"));
+                    }
+                }
+
+                if (count($message) != 0){
+                    msg_dialog::displayChecks($message);
+                    $display.= $smarty->fetch(get_template_path('password.tpl', TRUE));
+                    return ($display);
+                }
+                change_password ($user->dn, $_POST['new_password'], 0, $user->pw_storage);
+                $MyAccountTabs= new MyAccountTabs($config,$config->data['TABS']['MYACCOUNTTABS'], $ui->dn, "users", true, true);
+                $MyAccountTabs->setReadOnly(TRUE);
+                session::set('MyAccountTabs',$MyAccountTabs);
+                new log("modify","users/password","",array(),"Password has been changed");
+            } else {
+                msg_dialog::display(_("Error"), _("You have no permission to set your password!"), ERROR_DIALOG);
+            }
+
+            del_lock ($ui->dn);
+            session::un_set ('user');
+        }
 
-  /* Store changes  in session */
-  if (session::is_set('edit')){
-    session::set('MyAccountTabs',$MyAccountTabs);
-  }
+        if($MyAccountTabs->password_change_needed){
+            $display.= $smarty->fetch(get_template_path('password.tpl', TRUE));
+        }
 
-  /* Show page footer depending on the mode */
-  if (!$MyAccountTabs->is_modal_dialog() && empty($lock_msg) && !$MyAccountTabs->password_change_needed){
+        /* Execute formular */
+        if(!$MyAccountTabs->password_change_needed){
+            pathNavigator::registerPlugin(_("My account"));
+            if($lock_msg){
+                $display = $lock_msg;
+            }else{
+                $display.= $MyAccountTabs->execute ();
+            }
+        }
 
-    $display.= "<div class='plugin-actions'>";
+        /* Store changes  in session */
+        if (session::is_set('edit')){
+            session::set('MyAccountTabs',$MyAccountTabs);
+        }
 
-    /* Are we in edit mode? */
-    if (session::is_set('edit')){
-      $display.= "<button class='button' type='submit' name='edit_finish'>".msgPool::okButton()."</button>\n";
-      $display.= "<button class='button' type='submit' name='edit_cancel'>".msgPool::cancelButton()."</button>\n";
-    } else {
-      if(preg_match("/r/",$ui->get_category_permissions($ui->dn,"users"))){
-        $display.= "<button class='button' type='submit' name='edit'>".msgPool::editButton()."</button>\n";
-      }
-      $display.= "<input type='hidden' name='ignore'>\n";
+        /* Show page footer depending on the mode */
+        if (!$MyAccountTabs->is_modal_dialog() && empty($lock_msg) && !$MyAccountTabs->password_change_needed){
+
+            $display.= "<div class='plugin-actions'>";
+
+            /* Are we in edit mode? */
+            if (session::is_set('edit')){
+                $display.= "<button class='button' type='submit' name='edit_finish'>".msgPool::okButton()."</button>\n";
+                $display.= "<button class='button' type='submit' name='edit_cancel'>".msgPool::cancelButton()."</button>\n";
+            } else {
+                if(preg_match("/r/",$ui->get_category_permissions($ui->dn,"users"))){
+                    $display.= "<button class='button' type='submit' name='edit'>".msgPool::editButton()."</button>\n";
+                }
+                $display.= "<input type='hidden' name='ignore'>\n";
+            }
+            $display.= "</div>\n";
+        }
     }
-    $display.= "</div>\n";
-  }
 }
 
 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: