Code

Printer ACLs (Not finished)
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Mon, 18 Sep 2006 04:03:09 +0000 (04:03 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Mon, 18 Sep 2006 04:03:09 +0000 (04:03 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@4698 594d385d-05f5-0310-b6e9-bd551577e9d8

plugins/admin/systems/class_printGeneric.inc
plugins/admin/systems/printer.tpl

index db8e40b1fe225aba6c6a6b9bd58b5405e1e77005..947c778201c42105379d63306ffede234ee70b77 100644 (file)
@@ -49,7 +49,7 @@ class printgeneric extends plugin
                               "gotoUserAdminPrinter","gotoGroupAdminPrinter","gotoUserPrinter","gotoGroupPrinter");
   var $objectclasses  = array("top", "gotoPrinter");
 
-  function printgeneric ($config, $dn= NULL,$parent = NULL)
+  function printgeneric ($config, $dn,$parent)
   {
     $this->config = $config;
     $this->dn = $dn; 
@@ -263,6 +263,21 @@ class printgeneric extends plugin
     }
 
     $smarty= get_smarty();
+
+    /* Assign acls */
+    $tmp = $this->plInfo();
+    foreach($tmp['plProvidedAcls'] as $name => $translation){
+      $smarty->assign($name."ACL", $this->getacl($name));
+    }
+
+    /* Create base acls */
+    $baseACL = $this->getacl("base");
+    if(!$this->acl_is_moveable()) {
+      $baseACL = preg_replace("/w/","",$baseACL);
+    }
+    $smarty->assign("baseACL",          $baseACL);
+
+
     $display="";
 
     /* Tell smarty if this is a standalone object or a terminal / WS depending printer */
@@ -350,12 +365,9 @@ class printgeneric extends plugin
 
     /* Assign attributes */
     foreach ($this->attributes as $attr){
-      $smarty->assign($attr."ACL", chkacl($this->acl, $attr));
       $smarty->assign("$attr", $this->$attr);
     }
 
-    $smarty->assign("baseACL", chkacl($this->acl,"base"));
-
     if(isset($_POST['AddUser'])){
       $this->dialog = new selectUserToPrinterDialog($this->config, NULL,"AddUser");
     }
@@ -499,7 +511,7 @@ class printgeneric extends plugin
       }else{
         $smarty->assign("desc"    ,sprintf(_("This printer belongs to workstation %s. You can't rename this printer."),"<b>".$this->cn."</b>"));
       }
-      $smarty->assign("cnACL"    ," disabled ");
+      $smarty->assign("cnACL"    , $this->getacl("cn",true));
     }else{
       $smarty->assign("desc"    ,"");
     }
@@ -572,9 +584,23 @@ class printgeneric 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'];
+    if(isset($_POST['base'])){
+      $this->set_acl_base('dummy,'.$_POST['base']);
+      if($this->acl_is_moveable()){
+
+        if(isset($this->config->idepartments[$_POST['base']])){
+          $this->base = $_POST['base'];
+          if ($_POST['base'] != $this->base){
+            $this->is_modified= TRUE;
+          }
+        }
+      }else{
+
+        print_red(sprintf(_("You are not allowed to move this object to '%s'."),LDAP::fix($_POST['base'])));
+        $this->set_acl_base('dummy,'.$this->base);
+      }
     }
   }
 
@@ -606,10 +632,7 @@ class printgeneric extends plugin
     }
 
     if($this->BelongsTo == "Printer"){
-      $ui= get_userinfo();
-      $acl= get_permissions ($dn, $ui->subtreeACL);
-      $acl= get_module_permission($acl, "printer", $this->dn);
-      if (chkacl($acl, "create") != ""){
+      if($this->acl_is_createable()){
         $message[]= _("You have no permissions to create a printer on this 'Base'.");
       }
     }
@@ -808,7 +831,8 @@ class printgeneric extends plugin
           "plCategory"    => array("printer" => array("description"  => _("Printer"),
                                                     "objectClass"  => "gotoPrinter")),
           "plProvidedAcls"=> array(
-            "cn"                => _("Name"), 
+            "cn"                => _("Name"),
+             
             "description"       => _("Description"), 
             "l"                 => _("Location"), 
             "labeledURI"        => _("LabeledURL"), 
index 9b20e927858224fa1e1ff90a7b4f8a4d13cd6d04..2639e9b4de5a328fadc1bd9a764f2bfecce8d469 100644 (file)
@@ -1,59 +1,78 @@
-
 <table summary="" width="100%">
      <tr>
-               <td style="vertical-align:top; width:50%; border-right:1px solid #B0B0B0">
+ <tr>
+  <td style="vertical-align:top; width:50%; border-right:1px solid #B0B0B0">
 {if $StandAlone }
-                       <h2>{t}General{/t}</h2>
-                       <table summary="">
-                        <tr>
-                         <td><LABEL for="cn" >{t}Printer name{/t}</LABEL>{$must}</td>
-                         <td><input name="cn" id="cn" size=20 maxlength=60 value="{$cn}" {$cnACL}></td>
-                        </tr>
-                        <tr>
-                         <td><LABEL for="description">{t}Description{/t}</LABEL></td>
-                         <td><input id="description" name="description" size=25 maxlength=80 value="{$description}"></td>
-                        </tr>
-                        <tr>
-                                 <td colspan=2>&nbsp;</td>
-                        </tr>
-                        <tr>
-                         <td><LABEL for="base">{t}Base{/t}</LABEL>{$must}</td>
-                         <td>
-                          <select size="1" name="base" title="{t}Choose subtree to place terminal in{/t}" {$baseACL}>
-                               {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>
-                         </tr>
-                       </table>
-               </td>
-               <td>
+   <h2>{t}General{/t}</h2>
+   <table summary="">
+    <tr>
+     <td><LABEL for="cn" >{t}Printer name{/t}</LABEL>{$must}</td>
+     <td>
+{render acl=$cnACL}
+      <input name="cn" id="cn" size=20 maxlength=60 value="{$cn}">
+{/render}
+     </td>
+    </tr>
+    <tr>
+     <td><LABEL for="description">{t}Description{/t}</LABEL></td>
+     <td>
+{render acl=$descriptionACL}
+      <input id="description" name="description" size=25 maxlength=80 value="{$description}">
+{/render}
+     </td>
+    </tr>
+    <tr>
+      <td colspan=2>&nbsp;</td>
+    </tr>
+    <tr>
+     <td><LABEL for="base">{t}Base{/t}</LABEL>{$must}</td>
+     <td>
+{render acl=$baseACL}
+      <select id="base" size="1" name="base" title="{t}Choose subtree to place user in{/t}" onchange="document.mainform.submit()">
+       {html_options options=$bases selected=$base_select}
+      </select>
+{/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>
+  <td>
 {/if}
-                       <h2>{t}Details{/t}</h2>
-                       <table summary="">
-                               <tr>
-                                       <td><LABEL for="l">{t}Printer location{/t}</LABEL></td>
-                                       <td><input id="l" name="l" size=25 maxlength=80 value="{$l}"></td>
-                               </tr>
-                               <tr>
-                                       <td><LABEL for="labeledURI">{t}Printer URL{/t}</LABEL>{$must}</td>
-                                       <td><input id="labeledURI" name="labeledURI" size=25 maxlength=80 value="{$labeledURI}"></td>
-                               </tr>
-                       </table>
-                       <table summary="">
-                               <tr>    
-                                       <td>
-                                               <br>
-                                               {t}Driver{/t}: <i>{$driverInfo}</i>&nbsp;
-                                                       <input type="submit" name="EditDriver" value="{t}Edit{/t}">
-                                                       <input type="submit" name="RemoveDriver" value="{t}Remove{/t}">
-                                       </td>
-                               </tr>
-                       </table>
+   <h2>{t}Details{/t}</h2>
+   <table summary="">
+     <tr>
+       <td><LABEL for="l">{t}Printer location{/t}</LABEL></td>
+       <td>
+{render acl=$lACL}
+        <input id="l" name="l" size=25 maxlength=80 value="{$l}">
+{/render}
+       </td>
+     </tr>
+     <tr>
+       <td><LABEL for="labeledURI">{t}Printer URL{/t}</LABEL>{$must}</td>
+       <td>
+{render acl=$labeledURIACL}
+        <input id="labeledURI" name="labeledURI" size=25 maxlength=80 value="{$labeledURI}">
+{/render}
+       </td>
+     </tr>
+   </table>
+   <table summary="">
+    <tr> 
+     <td>
+      <br>
+      {t}Driver{/t}: <i>{$driverInfo}</i>&nbsp;
+{render acl=$gotoPrinterPPDACL mode=read_active}
+       <input type="submit" name="EditDriver" value="{t}Edit{/t}">
+{/render}
+{render acl=$gotoPrinterPPDACL}
+       <input type="submit" name="RemoveDriver" value="{t}Remove{/t}">
+{/render}
+     </td>
+    </tr>
+   </table>
   </td>
  </tr>
 </table>
 
 <h2><img class="center" alt="" align="middle" src="images/closedlock.png"> {t}Permissions{/t}</h2>
 <table summary="" width="100%">
-       <tr>
-               <td style="border-right:1px solid #B0B0B0; width:50%">
-                       <table style="width:100%" summary=''>
-                               <tr>
-                                       <td>
-                                               {t}Users which are allowed to use this printer{/t}<br>
-                                               <select size="1" name="UserMember[]" title="{t}Users{/t}" style="width:100%;height:120px;"  multiple>
-                                               {html_options options=$UserMembers values=$UserMemberKeys}
-                                               </select><br>
-                                                       <input type="submit" value="{t}Add user{/t}"  name="AddUser">
-                                                       <input type="submit" value="{t}Add group{/t}" name="AddGroup">
-                                                       <input type="submit" value="{t}Delete{/t}" name="DelUser">
-                                       </td>
-                               </tr>
-                       </table>        
-       
-               </td>
-               <td>
-                       <table style="width:100%" summary=''>
-                               <tr>
-                                       <td>
-                                               {t}Users which are allowed to administrate this printer{/t}<br>
-                                               <select size="1" name="AdminMember[]" title="{t}Admins{/t}" style="width:100%;height:120px;"  multiple>
-                                               {html_options options=$AdminMembers values=$AdminMemberKeys}
-                                               </select><br>
-                                                       <input type="submit" value="{t}Add user{/t}"  name="AddAdminUser">
-                                                       <input type="submit" value="{t}Add group{/t}" name="AddAdminGroup">
-                                                       <input type="submit" value="{t}Delete{/t}" name="DelAdmin">
-               
-                                       </td>
-                               </tr>
-                       </table>
-                       
-               </td>
-       </tr>
+ <tr>
+  <td style="border-right:1px solid #B0B0B0; width:50%">
+   <table style="width:100%" summary=''>
+    <tr>
+     <td>
+      {t}Users which are allowed to use this printer{/t}<br>
+{render acl=$gotoUserPrinterACL}
+      <select size="1" name="UserMember[]" title="{t}Users{/t}" style="width:100%;height:120px;"  multiple>
+       {html_options options=$UserMembers values=$UserMemberKeys}
+      </select><br>
+{/render}
+{render acl=$gotoUserPrinterACL}
+      <input type="submit" value="{t}Add user{/t}"  name="AddUser">
+{/render}
+{render acl=$gotoUserPrinterACL}
+      <input type="submit" value="{t}Add group{/t}" name="AddGroup">
+{/render}
+{render acl=$gotoUserPrinterACL}
+      <input type="submit" value="{t}Delete{/t}" name="DelUser">
+{/render}
+     </td>
+    </tr>
+   </table> 
+  </td>
+  <td>
+   <table style="width:100%" summary=''>
+    <tr>
+     <td>
+      {t}Users which are allowed to administrate this printer{/t}<br>
+{render acl=$gotoUserPrinterACL}
+           <select size="1" name="AdminMember[]" title="{t}Admins{/t}" style="width:100%;height:120px;"  multiple>
+                    {html_options options=$AdminMembers values=$AdminMemberKeys}
+                   </select><br>
+{/render}
+{render acl=$gotoUserPrinterACL}
+       <input type="submit" value="{t}Add user{/t}"  name="AddAdminUser">
+{/render}
+{render acl=$gotoUserPrinterACL}
+       <input type="submit" value="{t}Add group{/t}" name="AddAdminGroup">
+{/render}
+{render acl=$gotoUserPrinterACL}
+       <input type="submit" value="{t}Delete{/t}" name="DelAdmin">
+{/render}
+  
+     </td>
+    </tr>
+   </table>
+   
+  </td>
+ </tr>
 </table>