Code

Updated read-only handling
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Mon, 1 Dec 2008 09:30:27 +0000 (09:30 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Mon, 1 Dec 2008 09:30:27 +0000 (09:30 +0000)
-Added read-only to user management

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

gosa-core/ihtml/themes/default/islocked.tpl
gosa-core/include/class_plugin.inc
gosa-core/include/class_tabs.inc
gosa-core/include/functions.inc
gosa-core/plugins/admin/users/class_userManagement.inc

index 2845fa2ea66af08349d66cec82529114ddc86969..75de1c40e464e272042d68d9a8c84b15e1bf2589 100644 (file)
 
 <p class="plugbottom">
   <input type="submit" name="delete_lock" value="{$action}">
+       {if $allow_readonly}
   &nbsp;
   <input type="submit" name="open_readonly" value="{t}Read only{/t}">
+       {/if}
   &nbsp;
   <input type="submit" name="cancel_lock" value="{t}Cancel{/t}">
 </p>
index 7d3a6dd4e8d0de40cc6ee65193835bc383619c5d..f834f454ac70c79219cd82a9a1920fca61ffc6dd 100644 (file)
@@ -150,8 +150,14 @@ class plugin
       return;
     }
 
+    /* Check if this entry was opened in read only mode */
     if(isset($_POST['open_readonly'])){
-      $this->read_only = TRUE;
+      if(session::is_set("LOCK_CACHE")){
+        $cache = &session::get("LOCK_CACHE");
+        if(isset($cache['READ_ONLY'][$this->dn])){
+          $this->read_only = TRUE;
+        }
+      }
     }
 
     /* Save current dn as acl_base */
index 38567747c6439b9c4128f76d60b30e297116e3f4..b4e72f9e0725a588da414843763ec1b85a35b34e 100644 (file)
@@ -37,6 +37,8 @@ class tabs
   var $acl_category; 
   var $multiple_support_active = FALSE;
 
+  var $read_only = FALSE; // Used when the entry is opened as "readonly" due to locks.
+
   function tabs(&$config, $data, $dn, $acl_category= "")
   {
     /* Save dn */
@@ -68,6 +70,7 @@ class tabs
         $this->by_object[$tab['CLASS']]= new $tab['CLASS']($this->config, $this->dn, $baseobject);
       }
 
+      $this->read_only |= $this->by_object[$tab['CLASS']]->read_only;
       $this->by_object[$tab['CLASS']]->parent= &$this;
       $this->by_object[$tab['CLASS']]->set_acl_category($this->acl_category);
 
index 66c22e9ae7b3f27585e6c72bee67a3d80619d788..e022dcd4e2c42a6102aaed4add8e867e31203242 100644 (file)
@@ -608,15 +608,12 @@ function add_lock($object, $user)
   $cache = &session::get("LOCK_CACHE");
   if(isset($_POST['open_readonly'])){
     $cache['READ_ONLY'][$object] = TRUE;
-    echo "ADDED : {$user}:{$object}<br>";
     return;
   }
   if(isset($cache['READ_ONLY'][$object])){
-    echo "Removed lock entry $object <br>";
     unset($cache['READ_ONLY'][$object]);
   }
 
-
   if(is_array($object)){
     foreach($object as $obj){
       add_lock($obj,$user);
@@ -680,15 +677,14 @@ function del_lock ($object)
   if(session::is_set("LOCK_CACHE")){
     $cache = &session::get("LOCK_CACHE");
     if(isset($cache['READ_ONLY'][$object])){
-      if(isset($_POST['delete_lock'])){
-        unset($cache['READ_ONLY'][$object]);
-      }else{
-        echo "Skipped: $object <br>";
-        return;
-      }
+      unset($cache['READ_ONLY'][$object]);
+      //echo "Remove ".$object."<b> Skipped!</b>";
+      return;
     }
   }
 
+  //echo "Remove ".$object."<b> Done!</b>";
+
   /* Check for existance and remove the entry */
   $ldap= $config->get_ldap_link();
   $ldap->cd ($config->get_cfg_value("config"));
@@ -1289,7 +1285,7 @@ function get_uid_regexp()
 }
 
 
-function gen_locked_message($user, $dn)
+function gen_locked_message($user, $dn, $allow_readonly = FALSE)
 {
   global $plug, $config;
 
@@ -1326,7 +1322,7 @@ function gen_locked_message($user, $dn)
 
   /* Prepare and show template */
   $smarty= get_smarty();
-  
+  $smarty->assign("allow_readonly",$allow_readonly);
   if(is_array($dn)){
     $msg = "<pre>";
     foreach($dn as $sub_dn){
index 945f60ebd1ef8bba055d45eac173d675bbf5cd11..1171849cc1d3a269292e117d3f5e5937dcfd27da 100644 (file)
@@ -396,7 +396,7 @@ class userManagement extends plugin
       /* Check locking, save current plugin in 'back_plugin', so
          the dialog knows where to return. */
       if (($user= get_lock($this->dn)) != ""){
-        return(gen_locked_message ($user, $this->dn));
+        return(gen_locked_message ($user, $this->dn,TRUE));
       }
 
       /* Lock the current entry, so everyone will get the
@@ -931,15 +931,21 @@ class userManagement extends plugin
         }
 
         if(!is_object($dia) && $dia != TRUE){
-          $display.= "<p style=\"text-align:right\">\n";
-          $display.= "<input type=submit name=\"edit_finish\" style=\"width:80px\" value=\"".msgPool::okButton()."\">\n";
-          $display.= "&nbsp;\n";
-          if ($this->dn != "new"){
-            $display.= "<input type=submit name=\"edit_apply\" value=\"".msgPool::applyButton()."\">\n";
+          if(($this->usertab instanceOf tabs || $this->usertab instanceOf plugin) && $this->usertab->read_only == TRUE){
+            $display.= "<p style=\"text-align:right\">
+                          <input type=submit name=\"edit_cancel\" value=\"".msgPool::cancelButton()."\">
+                        </p>";
+          }else{
+            $display.= "<p style=\"text-align:right\">\n";
+            $display.= "<input type=submit name=\"edit_finish\" style=\"width:80px\" value=\"".msgPool::okButton()."\">\n";
             $display.= "&nbsp;\n";
+            if ($this->dn != "new"){
+              $display.= "<input type=submit name=\"edit_apply\" value=\"".msgPool::applyButton()."\">\n";
+              $display.= "&nbsp;\n";
+            }
+            $display.= "<input type=submit name=\"edit_cancel\" value=\"".msgPool::cancelButton()."\">\n";
+            $display.= "</p>";
           }
-          $display.= "<input type=submit name=\"edit_cancel\" value=\"".msgPool::cancelButton()."\">\n";
-          $display.= "</p>";
         }
       return ($display);
     }
@@ -1080,8 +1086,7 @@ class userManagement extends plugin
     /* Remove user lock if a DN is marked as "currently edited" */
     if (isset($this->usertab->dn)){
       del_lock ($this->usertab->dn);
-    }
-    if(isset($this->dn) && !empty($this->dn) && $this->dn != "new"){
+    }elseif(isset($this->dn) && !empty($this->dn) && $this->dn != "new"){
       del_lock($this->dn);
     }
     if(isset($this->dns) && is_array($this->dns) && count($this->dns)){