Code

Updated sudo
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Tue, 8 Apr 2008 07:21:21 +0000 (07:21 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Tue, 8 Apr 2008 07:21:21 +0000 (07:21 +0000)
-Allow to create a default entry

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

gosa-plugins/sudo/admin/sudo/class_divListSudo.inc
gosa-plugins/sudo/admin/sudo/class_sudoGeneric.inc
gosa-plugins/sudo/admin/sudo/class_sudoManagement.inc
gosa-plugins/sudo/admin/sudo/generic.tpl
gosa-plugins/sudo/admin/sudo/tabs_sudo.inc

index fa135f12031adc3c1ba9abfbccf85aeac2c23a2c..d0de10f6fd079ad15d44337566d5746c5e623003 100644 (file)
@@ -107,6 +107,7 @@ class divListSudo extends MultiSelectWindow
     /* Append create options */
     if(preg_match("/c/",$acl)) {
       $s.= "...|<input class='center' type='image' src='images/list_new_sudo.png' alt=''>&nbsp;"._("Role")."|new_role|\n";
+      $s.= "...|<input class='center' type='image' src='images/list_new_sudo.png' alt=''>&nbsp;"._("Default")."|new_default|\n";
     }
 
     /* Append multiple remove */
index 7af22e569453f9572b2cfd7d5dc95c457bb8c2de..ffccd2576e83f8bb7c777795d3b4b87fdabeeafb 100644 (file)
@@ -35,9 +35,10 @@ class sudo extends plugin
   var $sudoHost   = array("ALL");
   var $sudoRunAs  = array("ALL");
 
-  var $accessTo       = array();
-  var $trustModel     = "";
-  var $show_ws_dialog = FALSE;
+  var $accessTo         = array();
+  var $trustModel       = "";
+  var $show_ws_dialog   = FALSE;
+  var $was_trust_account= FALSE;
 
   var $objectclasses = array("top","sudoRole");
   var $attributes    = array("cn","description","sudoUser","sudoCommand","sudoHost","sudoRunAs","accessTo","trustModel");
@@ -411,6 +412,10 @@ class sudo extends plugin
   function save_object()
   {
     plugin::save_object();
+    
+    if($this->is_default){
+      $this->cn = "default";
+    }  
 
     if(is_object($this->dialog)){
       $this->dialog->save_object();
@@ -510,6 +515,11 @@ class sudo extends plugin
       $message[] = msgPool::required(_("Name"));
     }
 
+    /* Check if name is reserved */
+    if(!$this->is_default && preg_match("/^default$/i",$this->cn)){
+      $message[] = msgPool::reserved(_("Name"));
+    }
+
     /* Check name */
     if(!preg_match("/^[a-z]*$/i",$this->cn)){
       $message[] = msgPool::invalid(_("Name"),$this->cn,"/[a-z]/i");
@@ -593,6 +603,13 @@ class sudo extends plugin
   }
 
 
+  public function set_default($state)
+  {
+    $this->is_default = TRUE;
+    $this->cn = "default";
+  }
+
+
   /*! \brief  Add ACL object
       @return Returns the ACL object.
    */
index 47fd657a70b349c030866375670d5c6183d0d860..9571c7ed0ecfeeab59c4e3c098d0fc5140899f20 100644 (file)
@@ -87,7 +87,7 @@ class sudoManagement extends plugin
       } 
     }
 
-    if(isset($_POST['menu_action']) && in_array($_POST['menu_action'],array("new_role","del_role"))){
+    if(isset($_POST['menu_action']) && in_array($_POST['menu_action'],array("new_role","del_role","new_default"))){
       $s_action = $_POST['menu_action'];
     }
 
@@ -99,7 +99,7 @@ class sudoManagement extends plugin
      ********************/
 
     /* New sudo? */
-    if ($s_action=="new_role"){
+    if ($s_action=="new_role" || $s_action == "new_default"){
 
       /* Check create permissions */
       $acl = $this->ui->get_permissions($this->base,"sudo/sudo");
@@ -114,6 +114,11 @@ class sudoManagement extends plugin
 
         /* Set up the sudo ACL's for this 'dn' */
         $this->sudotabs->set_acl_base($this->base);
+
+        /* This entry will become the default entry */
+        if($s_action == "new_default"){
+          $this->sudotabs->set_default(TRUE);
+        }
       }
     }
 
index d437576122d7120c5a5b7c827921cd824f80e7a0..7fda69f487874e3db6f2b2fb2a83045a5e81bd6b 100644 (file)
@@ -7,9 +7,7 @@
    {t}Name{/t}
   </td>
   <td>
-   {render acl=$cnACL}
-   <input type="text" name="cn" value="{$cn}">
-   {/render}
+   <input type="text" name="dummy" value="{$cn}" disabled>
   </td>
  </tr>
  <tr>
index 0e0c1267c6e8a7e16497419ad3bacc44b3e80d15..666fb4c71f06f24ab0fccb1057a22c0890b70764 100644 (file)
@@ -28,6 +28,13 @@ class sudotabs extends tabs
     $this->addSpecialTabs();
   }
 
+  function set_default($state)
+  {
+    if(isset($this->by_object['sudo'])){
+      $this->by_object['sudo']->set_default($state);
+    }
+  }
+
   function save($ignore_account= FALSE)
   {
     $baseobject= $this->by_object['sudo'];