Code

Updated management
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Tue, 27 Oct 2009 12:19:16 +0000 (12:19 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Tue, 27 Oct 2009 12:19:16 +0000 (12:19 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@14652 594d385d-05f5-0310-b6e9-bd551577e9d8

gosa-core/include/class_management.inc
gosa-core/plugins/admin/users/class_userManagement.inc
gosa-core/plugins/admin/users/user-list.xml

index 00629634d68a977af09248dff77c905c308f6a18..5d6ea8ed4b28919f62c97d083f6fec479d5cd235 100644 (file)
@@ -34,11 +34,18 @@ class management
   protected $dn = "";
   protected $dns = array();
 
+  protected $last_dn = "";
+  protected $last_dns = array();
+
   protected $tabClass = "";
   protected $tabType = "";
   protected $aclCategory = "";
   protected $objectName = "";
   protected $tabObject = null;
+  protected $dialogObject = null;
+
+  protected $last_tabObject = null;
+  protected $last_dialogObject = null;
 
   protected $displayApplyBtn = "";
   protected $cpHandler = null;
@@ -357,6 +364,11 @@ class management
   
   protected function closeDialogs()
   {
+    $this->last_dn = $this->dn;
+    $this->last_dns = $this->dns;
+    $this->last_tabObject = $this->tabObject;
+    $this->last_dialogObject = $this->dialogObject;
+
     $this->dn = "";
     $this->dns = array();
     $this->tabObject = null;
index d27045db6de1115392671ada830b8673a581bcf1..b15d6bfcffb4cadd570dca0f93461f1a1901f538 100644 (file)
@@ -32,6 +32,8 @@ class userManagement extends management
   var $got_uid = "";
   var $edit_uid = "";
 
+  var $pwd_change_queue = array();
+
   // Tab definition 
   protected $tabClass = "usertabs";
   protected $tabType = "USERTABS";
@@ -87,6 +89,10 @@ class userManagement extends management
     $this->registerAction("templatize", "templatizeUsers");
     $this->registerAction("templatizeContinue", "templatizeContinue");
 
+    $this->registerAction("password", "changePassword");
+    $this->registerAction("passwordQueue", "handlePasswordQueue");
+    $this->registerAction("passwordCancel", "closeDialogs");
+
     $this->registerAction("sendMessage", "sendMessage");
     $this->registerAction("saveEventDialog", "saveEventDialog");
     $this->registerAction("abortEventDialog", "closeDialogs");
@@ -101,10 +107,22 @@ class userManagement extends management
     if(isset($_POST['templatize_continue'])) $action['action'] = "templatizeContinue";
     if(isset($_POST['save_event_dialog'])) $action['action'] = "saveEventDialog";
     if(isset($_POST['abort_event_dialog'])) $action['action'] = "abortEventDialog";
+    if(isset($_POST['password_cancel'])){
+      $action['action'] = "passwordCancel";
+    }elseif((count($this->pwd_change_queue) || isset($_POST['password_finish']))){
+      $action['action'] = "passwordQueue";
+    }
     return($action);
   }
 
 
+  function closeDialogs()
+  {
+    management::closeDialogs();
+    $this->pwd_change_queue = array();
+  }
+    
+
   /*! \brief  Sends a message to a set of users using gosa-si events.
    */ 
   function sendMessage($action="",$target=array(),$all=array())
@@ -162,6 +180,100 @@ class userManagement extends management
   }
 
 
+  /*! \brief  Queues a set of users for password changes
+   */ 
+  function changePassword($action="",$target=array(),$all=array())
+  {
+    $this->dn ="";
+    $this->pwd_change_queue = $target;
+
+    // Check permisions
+    $disallowed = array();
+    foreach($this->pwd_change_queue as $key => $dn){
+      if(!preg_match("/w/",$this->ui->get_permissions($dn,$this->aclCategory."/password"))){
+        unset($this->pwd_change_queue[$key]);
+        $disallowed[] = $dn; 
+      }
+    }
+    if(count($disallowed)){
+      msg_dialog::display(_("Permission"),msgPool::permModify($disallowed),INFO_DIALOG);
+    }
+
+    // Now display change dialog.
+    return($this->handlePasswordQueue()); 
+  }
+
+
+  function handlePasswordQueue()
+  {
+    // Get next entry from queue.
+    if(empty($this->dn) && count($this->pwd_change_queue)){
+      $this->dn = array_pop($this->pwd_change_queue);
+      set_object_info($this->dn);
+      $smarty = get_smarty();
+      return ($smarty->fetch(get_template_path('password.tpl', TRUE)));
+    }
+
+    // Check permissions
+    $dn  = $this->dn;
+    $acl = $this->ui->get_permissions($dn, "users/password");
+    $cacl= $this->ui->get_permissions($dn, "users/user");
+    if (preg_match('/w/', $acl) || preg_match('/c/', $cacl)){
+      $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"));
+        }
+      }
+
+      // Display errors
+      if (count($message) != 0){
+        msg_dialog::displayChecks($message);
+        $smarty = get_smarty();
+        return($smarty->fetch(get_template_path('password.tpl', TRUE)));
+      }
+
+      // Change cassword 
+      if(!change_password ($this->dn, $_POST['new_password'])){
+        return($smarty->fetch(get_template_path('password.tpl', TRUE)));
+      }
+      if ($this->config->get_cfg_value("passwordHook") != ""){
+        exec($this->config->get_cfg_value("passwordHook")." ".$username." ".$_POST['new_password'], $resarr);
+      }
+      new log("modify","users/".get_class($this),$this->dn,array(),"Password has been changed");
+      $this->dn ="";
+      
+    } else {
+      msg_dialog::display(_("Password change"),
+          _("You have no permission to change this users password!"),
+          WARNING_DIALOG);
+    }
+
+    // Cleanup
+    if(!count($this->pwd_change_queue)){
+      $this->remove_lock();
+      $this->closeDialogs();
+    }else{
+      return($this->handlePasswordQueue());
+    }
+  }
+
+
+  /*! \brief  Save user modifications. 
+   *          Whenever we save a 'new' user, request a password change for him.
+   */ 
+  function saveChanges()
+  {
+    management::saveChanges();
+    if($this->last_dn == "new"){
+      $this->pwd_change_queue[] = $this->last_tabObject->dn;
+      return($this->handlePasswordQueue());
+    }
+  }
+
+
   /*! \brief  Intiates user creation. 
    *          If we've user templates, then the user will be asked to use to use one. 
    *          -> See 'templateContinue' for further handling.
index 3552af42c0638263d5da841f14bc9bb60be5cc1a..88ae7826fece5d203870a4535d192b2bff170f57 100644 (file)
       <label>Remove</label>
     </action>
 
+    <action>
+      <name>password</name>
+      <type>entry</type>
+      <image>plugins/users/images/list_password.png</image>
+      <label>Change password</label>
+    </action>
+
     <action>
       <type>separator</type>
     </action>
     <action>
       <name>sendMessage</name>
       <type>entry</type>
+      <depends>goto</depends>
       <image>plugins/goto/images/notify.png</image>
       <label>Send message</label>
     </action>