Code

Some mimetype acl fixes.
[gosa.git] / plugins / admin / users / class_userManagement.inc
index 027473faf4f6fa98d50aa09f20ed4db96d2ad8f2..c0042797a60a184c1b8ec58f9e99d9cff82d85f2 100644 (file)
@@ -51,8 +51,6 @@ class userManagement extends plugin
     /* Creat dialog object */
     $this->DivListUsers = new divListUsers($this->config,$this);
 
-    /* LOCK MESSAGE Vars */
-    $_SESSION['LOCK_VARS_TO_USE'] = array("/^act$/","/^id$/","/^user_edit_/","/^user_del_/");
   }
 
 
@@ -61,6 +59,9 @@ class userManagement extends plugin
     /* Call parent execute */
     plugin::execute();
 
+    /* LOCK MESSAGE Vars */
+    $_SESSION['LOCK_VARS_TO_USE'] = array("/^act$/","/^id$/","/^user_edit_/","/^user_del_/");
+
     $smarty       = get_smarty();                 // Smarty instance
     $s_action     = "";                           // Contains the action to be taken
     $s_entry      = "";                           // The value for s_action
@@ -103,6 +104,10 @@ class userManagement extends plugin
       $s_tab= "user";
     }
 
+    if(!search_config($this->config->data['TABS'], $s_tab , "CLASS")){
+      $s_tab = "user";
+    }
+
     /* Display the copy & paste dialog, if it is currently open */
     $ret = $this->copyPasteHandling($s_action,$s_entry);
     if($ret){
@@ -201,11 +206,10 @@ class userManagement extends plugin
     if (isset($_POST['password_finish'])){
 
       /* For security reasons, check if user is allowed to set password again */
-      $dn  = $this->usertab->dn;
+      $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)){
 
         /* Check input and feed errors into 'message' */
@@ -397,6 +401,7 @@ class userManagement extends plugin
 
           /* In case of new users, ask for a password, skip this for templates */
           if (($set_pass || $this->usertab->password_change_needed()) && !$this->is_template){
+            $this->dn = $this->usertab->dn;
             return($smarty->fetch(get_template_path('password.tpl', TRUE)));
           }
 
@@ -798,6 +803,9 @@ class userManagement extends plugin
 
         /* Use the last dn to search for it's ID in the newly generated list. */
         $dn= $this->CopyPasteHandler->lastdn;
+
+        /* Get new user list */
+        $this->reload();
         foreach($this->list as $id => $entry){
           if($entry['dn'] == $dn){
             $s_entry= $id;
@@ -817,14 +825,19 @@ class userManagement extends plugin
       if($s_action == "copy"){
         $this->CopyPasteHandler->Clear();
         $dn= $this->list[trim($s_entry)]['dn'];
-        $obj    = new usertabs($this->config, $this->config->data['TABS']['USERTABS'], $dn);
-        $obj->set_acl_base($dn);
-        $obj->set_acl_category("users");
-        $objNew = new usertabs($this->config, $this->config->data['TABS']['USERTABS'], "new");
-        $objNew->set_acl_base($dn);
-        $objNew->set_acl_category("users");
-
-        $this->CopyPasteHandler->Copy($obj,$objNew);
+
+        /* Check acl */
+        $acl_all  = $ui->has_complete_category_acls($this->selectedBase,"users") ;
+        if(preg_match("/(c.*w|w.*c)/",$acl_all)){
+          $obj    = new usertabs($this->config, $this->config->data['TABS']['USERTABS'], $dn);
+          $obj->set_acl_base($dn);
+          $objNew = new usertabs($this->config, $this->config->data['TABS']['USERTABS'], "new");
+          $objNew->set_acl_base($dn);
+
+          $this->CopyPasteHandler->Copy($obj,$objNew);
+        }else{
+          print_red("You are not allowed to copy this entry.");
+        }
       }
 
       /* Cut selected object. 
@@ -832,10 +845,16 @@ class userManagement extends plugin
       if($s_action == "cut"){
         $this->CopyPasteHandler->Clear();
         $dn= $this->list[trim($s_entry)]['dn'];
-        $obj= new usertabs($this->config, $this->config->data['TABS']['USERTABS'], $dn);
-        $obj->set_acl_base($dn);
-        $obj->set_acl_category("users");
-        $this->CopyPasteHandler->Cut($obj);
+
+        /* Check acl */
+        $acl_all  = $ui->has_complete_category_acls($this->selectedBase,"users") ;
+        if(preg_match("/(c.*w|w.*c)/",$acl_all)){
+          $obj= new usertabs($this->config, $this->config->data['TABS']['USERTABS'], $dn);
+          $obj->set_acl_base($dn);
+          $this->CopyPasteHandler->Cut($obj);
+        }else{
+          print_red("You are not allowed to cut this entry.");
+        }
       }
     }
   }