Code

Added acls to terminals
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Thu, 28 Sep 2006 11:01:13 +0000 (11:01 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Thu, 28 Sep 2006 11:01:13 +0000 (11:01 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@4814 594d385d-05f5-0310-b6e9-bd551577e9d8

plugins/admin/systems/class_terminalGeneric.inc
plugins/admin/systems/class_terminalService.inc
plugins/admin/systems/class_terminalStartup.inc
plugins/admin/systems/tabs_terminal.inc
plugins/admin/systems/terminal.tpl

index 69a5872fd5e2b2ab5a6222322f157d5f4e920c20..de00c606e1187ca758c4f3cbe90280349165db9b 100644 (file)
@@ -119,6 +119,18 @@ class termgeneric extends plugin
     $this->orig_dn= $this->dn;
   }
 
+  function set_acl_base($base)
+  {
+    plugin::set_acl_base($base);
+    $this->netConfigDNS->set_acl_base($base);
+  }
+
+  function set_acl_category($cat)
+  {
+    plugin::set_acl_category($cat);
+    $this->netConfigDNS->set_acl_category($cat);
+  }
+
   function execute()
   {
     /* Call parent execute */
@@ -129,7 +141,7 @@ class termgeneric extends plugin
       $this->is_account= !$this->is_account;
     }
 
-    if (isset($_POST['action'])){
+    if (isset($_POST['action']) && $this->acl_is_writeable("FAIstate")){
 
       /* Set FAIstate */
       $ldap = $this->config->get_ldap_link();
@@ -202,7 +214,7 @@ class termgeneric extends plugin
     /* Base select dialog */
     $once = true;
     foreach($_POST as $name => $value){
-      if(preg_match("/^chooseBase/",$name) && $once){
+      if(preg_match("/^chooseBase/",$name) && $once && $this->acl_is_moveable()){
         $once = false;
         $this->dialog = new baseSelectDialog($this->config,$this);
         $this->dialog->setCurrentBase($this->base);
@@ -232,12 +244,12 @@ class termgeneric extends plugin
     }
 
     /* Add new ntp Server to our list */
-    if((isset($_POST['addNtpServer'])) && (isset($_POST['gotoNtpServers']))){
+    if((isset($_POST['addNtpServer'])) && (isset($_POST['gotoNtpServers'])) && $this->acl_is_writeable("gotoNtpServer")){
       $this->gotoNtpServer[$_POST['gotoNtpServers']] = $_POST['gotoNtpServers'];
     }
 
     /* Delete selected NtpServer for list of used servers  */
-    if((isset($_POST['delNtpServer'])) && (isset($_POST['gotoNtpServerSelected']))){
+    if((isset($_POST['delNtpServer'])) && (isset($_POST['gotoNtpServerSelected'])) && $this->acl_is_writeable("gotoNtpServer")){
       foreach($_POST['gotoNtpServerSelected'] as $name){
         unset($this->gotoNtpServer[$name]);
       } 
@@ -245,6 +257,12 @@ class termgeneric extends plugin
 
     /* Fill templating stuff */
     $smarty= get_smarty();
+    
+    $tmp = $this->plInfo();
+    foreach($tmp['plProvidedAcls'] as $name => $translation){
+      $smarty->assign($name."ACL",$this->getacl($name));
+    }
+
     $smarty->assign("cn", $this->cn);
     $smarty->assign("staticAddress", "");
 
@@ -294,40 +312,37 @@ class termgeneric extends plugin
     $smarty->assign("ntpservers",     $tmp);
 
     /* Variables */
-    foreach(array("base", "gotoMode", "gotoTerminalPath", "gotoSwapServer",
-          "gotoSyslogServer", "gotoNtpServer") as $val){
-
+    foreach(array("base", "gotoMode", "gotoTerminalPath", "gotoSwapServer","gotoSyslogServer", "gotoNtpServer") as $val){
       $smarty->assign($val."_select", $this->$val);
-      $smarty->assign($val."ACL", chkacl($this->acl, $val));
     }
 
     /* Show main page */
     $smarty->assign("netconfig", $this->netConfigDNS->execute());
-    $smarty->assign("actionACL", chkacl($this->acl, 'action'));
     return($smarty->fetch (get_template_path('terminal.tpl', TRUE)));
   }
 
   function remove_from_parent()
   {
-    
-    $ldap= $this->config->get_ldap_link();
-    $ldap->cd($this->dn);
-    $ldap->cat($this->dn, array('dn'));
-    if($ldap->count()){
-      $this->netConfigDNS->remove_from_parent();
-      $ldap->rmDir($this->dn);
-      show_ldap_error($ldap->get_error(), sprintf(_("Removing of object system terminal/generic with dn '%s' failed."),$this->dn));
-
-      /* Optionally execute a command after we're done */
-      $this->handle_post_events("remove", array("macAddress" => $this->netConfigDNS->macAddress));
-
-      /* Delete references to object groups */
-      $ldap->cd ($this->config->current['BASE']);
-      $ldap->search ("(&(objectClass=gosaGroupOfNames)(member=".$this->dn."))", array("cn"));
-      while ($ldap->fetch()){
-        $og= new ogroup($this->config, $ldap->getDN());
-        unset($og->member[$this->dn]);
-        $og->save ();
+    if($this->acl_is_removeable()){   
+      $ldap= $this->config->get_ldap_link();
+      $ldap->cd($this->dn);
+      $ldap->cat($this->dn, array('dn'));
+      if($ldap->count()){
+        $this->netConfigDNS->remove_from_parent();
+        $ldap->rmDir($this->dn);
+        show_ldap_error($ldap->get_error(), sprintf(_("Removing of object system terminal/generic with dn '%s' failed."),$this->dn));
+
+        /* Optionally execute a command after we're done */
+        $this->handle_post_events("remove", array("macAddress" => $this->netConfigDNS->macAddress));
+
+        /* Delete references to object groups */
+        $ldap->cd ($this->config->current['BASE']);
+        $ldap->search ("(&(objectClass=gosaGroupOfNames)(member=".$this->dn."))", array("cn"));
+        while ($ldap->fetch()){
+          $og= new ogroup($this->config, $ldap->getDN());
+          unset($og->member[$this->dn]);
+          $og->save ();
+        }
       }
     }
   }
@@ -338,10 +353,6 @@ class termgeneric extends plugin
   {
     plugin::save_object();
     $this->netConfigDNS->save_object();
-    /* Save base, since this is no LDAP attribute */
-    if (isset($_POST['base']) && chkacl($this->acl, "create") == ""){
-      $this->base= $_POST['base'];
-    }
 
     /* Save terminal path to parent since it is used by termstartup, too */
     $this->parent->by_object['termstartup']->gotoTerminalPath=
@@ -368,13 +379,11 @@ class termgeneric extends plugin
     $this->dn= "cn=".$this->cn."ou=terminals,ou=systems,".$this->base;
 
     $ui= get_userinfo();
-    $acl= get_permissions ($this->dn, $ui->subtreeACL);
-    $acl= get_module_permission($acl, "group", $this->dn);
-    if (chkacl($acl, "create") != ""){
+    if ($this->dn == "new" && !$this->acl_is_createable()){
       $message[]= _("You have no permissions to create a terminal on this 'Base'.");
     }
 
-    if ($this->cn == "" && chkacl ($this->acl, "cn") == ""){
+    if ($this->cn == ""){
       $message[]= _("The required field 'Terminal name' is not set.");
     }
 
@@ -488,7 +497,7 @@ class termgeneric extends plugin
           "plDescription" => _("Terminal generic"),
           "plSelfModify"  => FALSE,
           "plDepends"     => array(),
-          "plPriority"    => 0,
+          "plPriority"    => 1,
           "plSection"     => array("administration"),
           "plCategory"    => array("terminal" => array( "description"  => _("Terminal"),
                                                         "objectClass"  => "gotoTerminal")),
index 7ffe10bce62b4bc5a08b6b1e693473e8f357a3dd..cc4b868caa87d25a37fc2d82d06a74d63e322c5a 100644 (file)
@@ -426,7 +426,7 @@ class termservice extends plugin
           "plDescription" => _("Terminal service"),
           "plSelfModify"  => FALSE,
           "plDepends"     => array(),
-          "plPriority"    => 0,
+          "plPriority"    => 3,
           "plSection"     => array("administration"),
           "plCategory"    => array("terminal"),
 
index 3fce2c28eb823e94cb807751173986d660039fbe..3ec5c115c0001098933f0df8dbd1b733921cea3d 100644 (file)
@@ -442,7 +442,7 @@ class termstartup extends plugin
           "plDescription" => _("Terminal startup"),
           "plSelfModify"  => FALSE,
           "plDepends"     => array(),
-          "plPriority"    => 0,
+          "plPriority"    => 5,
           "plSection"     => array("administration"),
           "plCategory"    => array("terminal"),
 
index 7614608df23260c774ddd2ec788bb64b1b486e51..78bf16d45ab793cf7259b9f5d0c3c32e0042b397 100644 (file)
@@ -9,16 +9,21 @@ class termtabs extends tabs
     $this->dn= $dn;
     $this->config= $config;
 
+    $baseobject= NULL;
+
     foreach ($data as $tab){
-      if($tab['CLASS'] == "printgeneric"){
-        $this->by_name[$tab['CLASS']]= $tab['NAME'];
-        $this->by_object[$tab['CLASS']]= new $tab['CLASS']($this->config, $this->dn, $category);
-        $this->by_object[$tab['CLASS']]->parent= &$this;
-      }else{
-        $this->by_name[$tab['CLASS']]= $tab['NAME'];
-        $this->by_object[$tab['CLASS']]= new $tab['CLASS']($this->config, $this->dn, $category);
-        $this->by_object[$tab['CLASS']]->parent= &$this;
+      $this->by_name[$tab['CLASS']]= $tab['NAME'];
+
+      if ($baseobject == NULL){
+        $baseobject= new $tab['CLASS']($this->config, $this->dn,NULL,$this);
+        $this->by_object[$tab['CLASS']]= $baseobject;
+      } else {
+        $this->by_object[$tab['CLASS']]= new $tab['CLASS']($this->config, $this->dn, $baseobject,$this);
       }
+
+      $this->by_object[$tab['CLASS']]->parent= &$this;
+      $this->by_object[$tab['CLASS']]->set_acl_category($category);
+
       /* Initialize current */
       if ($this->current == ""){
         $this->current= $tab['CLASS'];
index 152c9dc19ccc922f74e61ea71d0784ddfda0a288..794a27ed84ac857820a9db8b2492dd26f607bb4a 100644 (file)
@@ -9,22 +9,25 @@
      {else}
      <td><LABEL for="cn">{t}Terminal name{/t}</LABEL>{$must}</td>
      <td>
+{render acl=$cnACL}
       <input name="cn" id="cn" size=18 maxlength=60 value="{$cn}">
+{/render}
      </td>
      {/if}
     </tr>
     <tr>
      <td><LABEL for="base">{t}Base{/t}</LABEL>{$must}</td>
      <td>
-      <select size="1" id="base" name="base" title="{t}Choose subtree to place terminal in{/t}" {$baseACL}>
+
+{render acl=$baseACL}
+      <select id="base" size="1" name="base" title="{t}Choose subtree to place group in{/t}">
        {html_options options=$bases selected=$base_select}
       </select>
-        {if $baseACL == ""}
-            <input type="image" name="chooseBase" src="images/folder.png" class="center" title="{t}Select a base{/t}">
-        {else}
-            <img src="images/folder_gray.png" class="center" title="{t}Select a base{/t}">
-        {/if}
-               </td>
+{/render}
+{render acl=$baseACL disable_picture='images/folder_gray.png'}
+        <input type="image" name="chooseBase" src="images/folder.png" class="center" title="{t}Select a base{/t}">
+{/render}
+     </td>
     </tr>
    </table>
   </td>
     <tr>
      <td><LABEL for="gotoMode">{t}Mode{/t}</LABEL></td>
      <td>
-      <select id="gotoMode" name="gotoMode" title="{t}Select terminal mode{/t}" {$gotoModeACL}>
+{render acl=$gotoModeACL}
+      <select id="gotoMode" name="gotoMode" title="{t}Select terminal mode{/t}">
        {html_options options=$modes selected=$gotoMode_select}
       </select>
+{/render}
      </td>
     </tr>
     <tr>
      <td><LABEL for="gotoSyslogServer">{t}Syslog server{/t}</LABEL></td>
      <td>
-      <select name="gotoSyslogServer" id="gotoSyslogServer" title="{t}Choose server to use for logging{/t}" {$gotoSyslogServerACL}>
+{render acl=$gotoSyslogServerACL}
+      <select name="gotoSyslogServer" id="gotoSyslogServer" title="{t}Choose server to use for logging{/t}">
        {html_options options=$syslogservers selected=$gotoSyslogServer_select}
       </select>
+{/render}
      </td>
     </tr>
        </table>
     <tr>
      <td><LABEL for="gotoTerminalPath">{t}Root server{/t}</LABEL></td>
      <td>
-      <select name="gotoTerminalPath" id="gotoTerminalPath" title="{t}Select NFS root filesystem to use{/t}" {$gotoTerminalPathACL}>
+{render acl=$gotoTerminalPathACL}
+      <select name="gotoTerminalPath" id="gotoTerminalPath" title="{t}Select NFS root filesystem to use{/t}">
        {html_options options=$nfsservers selected=$gotoTerminalPath_select}
       </select>
+{/render}
      </td>
     </tr>
     <tr>
      <td><LABEL for="gotoSwapServer">{t}Swap server{/t}</LABEL></td>
      <td>
-      <select name="gotoSwapServer" id="gotoSwapServer" title="{t}Choose NFS filesystem to place swap files on{/t}" {$gotoSwapServerACL}>
+{render acl=$gotoSwapServerACL}
+      <select name="gotoSwapServer" id="gotoSwapServer" title="{t}Choose NFS filesystem to place swap files on{/t}">
        {html_options options=$nfsservers selected=$gotoSwapServer_select}
       </select>
+{/render}
      </td>
     </tr>
    </table>
@@ -77,6 +88,7 @@
        <table width="100%">
     <tr>
         <td colspan="2">
+{render acl=$gotoNtpServerACL}
                <input type="checkbox" value="1" name="inheritTimeServer"
                        {if $inheritTimeServer } checked {/if} 
                        onClick="javascript:
                                        changeState('gotoNtpServers');
                                        changeState('addNtpServer');
                                        changeState('delNtpServer');">{t}Inherit time server attributes{/t}
+{/render}
         </td>
        </tr>
        <tr>
      <td colspan="2" style='padding-left:14px;padding-top:5px;'><LABEL for="gotoNtpServerSelected">{t}NTP server{/t}</LABEL><br>
+{render acl=$gotoNtpServerACL}
       <select name="gotoNtpServerSelected[]" id="gotoNtpServerSelected" multiple size=5 style="width:100%;"
-                       title="{t}Choose server to use for synchronizing time{/t}" {$gotoNtpServerACL} {if $inheritTimeServer} disabled {/if}>
+                       title="{t}Choose server to use for synchronizing time{/t}" {if $inheritTimeServer} disabled {/if}>
        {html_options options=$gotoNtpServer_select}
       </select>
+{/render}
         <br>
-      <select name="gotoNtpServers" id="gotoNtpServers" {$gotoNtpServerACL} {if $inheritTimeServer} disabled {/if} >
+{render acl=$gotoNtpServerACL}
+      <select name="gotoNtpServers" id="gotoNtpServers" {if $inheritTimeServer} disabled {/if} >
        {html_options values=$ntpservers output=$ntpservers }
       </select>
+{/render}
+{render acl=$gotoNtpServerACL}
                <input type="submit" name="addNtpServer" value="{t}Add{/t}"             id="addNtpServer" {$gotoNtpServerACL}
                 {if $inheritTimeServer} disabled {/if}>
+{/render}
+{render acl=$gotoNtpServerACL}
                <input type="submit" name="delNtpServer" value="{t}Delete{/t}"  id="delNtpServer" {$gotoNtpServerACL}
                 {if $inheritTimeServer} disabled {/if}>
+{/render}
      </td>
     </tr>
    </table>
 <table summary="">
  <tr>
   <td>
-   <select size="1" name="saction" {$actionACL} title="{t}Select action to execute for this terminal{/t}">
+{render acl=$gotoNtpServerACL}
+   <select size="1" name="saction" title="{t}Select action to execute for this terminal{/t}">
     <option disabled>&nbsp;</option>
     {html_options options=$actions}
    </select>
+{/render}
   </td>
   <td>
+{render acl=$gotoNtpServerACL}
    <input type=submit name="action" value="{t}Execute{/t}">
+{/render}
   </td>
  </tr>
 </table>