Code

Fixed logging for open groupware account
[gosa.git] / plugins / admin / acl / class_divListACL.inc
1 <?php
3 class divListACL extends MultiSelectWindow
4 {
6   /* Current base */
7   var $selectedBase       = "";
8   var $departments        = array();
10   /* Regex */
11   var $Regex              = "*";
13   /* CheckBoxes */
15   /* Subsearch checkbox */
16   var $SubSearch              = false;
18   var $parent             ;
19   var $ui                 ;
20   var $action_col_size;
21   
23   function divListACL ($config,$parent)
24   {
25     MultiSelectWindow::MultiSelectWindow($config, "ACLs", "acl");
26     
27     $this->parent       = $parent;
28     $this->ui           = get_userinfo();
30     /* Set list strings */
31     $this->SetTitle(_("List of acl"));
32     $this->SetSummary(_("List of acls"));
34     /* Result page will look like a headpage */
35     $this->SetHeadpageMode();
36     $this->SetInformation(_("This menu allows you to edit and delete selected acls."));
38     $this->EnableAplhabet   (true);
39   
40     /* Disable buttonsm */
41     $this->EnableCloseButton(false);
42     $this->EnableSaveButton (false);
44     /* Dynamic action col */
45     $this->action_col_size = 120;
47     /* set Page header */
48     $this->AddHeader(array("string"=>"&nbsp;",          "attach"=>"style='width:20px;'"));
49     $this->AddHeader(array("string"=>_("Summary")));
50     $this->AddHeader(array("string"=>_("Actions"),      "attach" => "style='width:".$this->action_col_size."px;border-right:0px;text-align:right;'"));
52     /* Set dynamically filter checkboxes */
53     $this->set_filter_objectclasses();   
54  
55     /* Add SubSearch checkbox */
56     $this->AddCheckBox("SubSearch",  _("Select to search within subtrees"), _("Ignore subtrees"), false);
59     /*                  Name                 ,Text                              ,Default  , Connect with alphabet  */
60     $this->AddRegex   ("Regex",     _("Display acls matching"),"*" , true);
61   }
64   function GenHeader()
65   {
66      /* Prepare departments,
67        which are shown in the listbox on top of the listbox
68      */
69     $options= "";
70     $Copy_Paste = "";
72     /* Get all departments within this subtree */
73     $ui= get_userinfo();
74     $first = "";
75     $found = FALSE;
76     $base = $this->config->current['BASE'];
78     /* Add base */
79     $deps[] = array("dn"=>$this->config->current['BASE']);
80     $deps= array_merge($deps,get_list("(&(|(ou=*)(description=*))(objectClass=gosaDepartment))", $this->module, $base,
81                     array("ou", "description"), GL_SIZELIMIT | GL_SUBSEARCH));
83     /* Load possible departments */
84     $ui     = get_userinfo();
85     $tdeps  = $ui->get_module_departments("acl");
86     $ids    = $this->config->idepartments;
87     foreach($deps as $dep){
88       if(isset($ids[$dep['dn']]) && in_array_ics($dep['dn'], $tdeps)){
90         /* Keep first base dn in mind, we could need this
91          *  info if no valid base was found
92          */
93         if(empty($first)) {
94           $first = $dep['dn'];
95         }
96   
97         $value = $ids[$dep['dn']];
98         if ($this->selectedBase == $dep['dn']){
99           $found = TRUE;
100           $options.= "<option selected='selected' value='".$dep['dn']."'>$value</option>";
101         } else {
102           $options.= "<option value='".$dep['dn']."'>$value</option>";
103         }
104       }
105     }
107     /* The currently used base is not visible with your acl setup.
108      * Set base to first useable base.
109      */
110     if(!$found){
111       $this->selectedBase = $first;
112     }
114     /* Allow copy & paste for roles */ 
115     $acl_all  = $ui->has_complete_category_acls($this->selectedBase,"acl");
116     $acl      = $ui->get_permissions($this->selectedBase,"acl/acl");
118     /* Add default header */
119     $listhead = MultiSelectWindow::get_default_header();
121     /* Get copy & paste icon */
122     $Copy_Paste ="";
123     if(preg_match("/(c.*w|w.*c)/",$acl_all) &&  $this->parent->CopyPasteHandler){
124       $Copy_Paste = $this->parent->CopyPasteHandler->generatePasteIcon();
125       $addsep = true;
126     }
128     /* Add snapshot icons */
129     if(preg_match("/(c.*w|w.*c)/",$acl_all)){
130       $listhead .= $this->get_snapshot_header($this->selectedBase);
131       $add_sep = true;
132     }
134     if(preg_match("/c/",$ui->get_permissions($this->selectedBase,"acl/acl"))){
135       $add_sep = true;
136       $listhead .= "<input class='center' type='image' align='middle' src='images/list_new_acl_role.png'
137         name='new_acl_role'     alt='"._("New acl role")."' title='"._("New acl role")."'>&nbsp;";
138     }
140     $listhead .= $Copy_Paste. 
141       _("Base")."&nbsp;<select name='CurrentMainBase' onChange='mainform.submit()' class='center'>$options</select>".
142       " <input class='center' type='image' src='images/list_submit.png' align='middle' 
143       title='"._("Submit department")."' name='submit_department' alt='".  _("Submit")."'>&nbsp;".
144       "</div>";
146     $this->SetListHeader($listhead);
147   }
149   /* so some basic settings */
150   function execute()
151   {
152     $this->ClearElementsList();
153     $this->GenHeader();
154   }
156   function setEntries($list)
157   {
159     foreach($list as $key => $acl_entry){
161       /* Get copy & paste icon */
162       $acl        = $this->ui->get_permissions($acl_entry['dn'],"acl/acl");
163       $acl_all    = $this->ui->has_complete_category_acls($acl_entry['dn'],"acl");
164       $action     = "";
166       if(in_array("gosaRole",$acl_entry['objectClass'])){
168         /* Role handling */
169         $editlink       = "<a href='?plug=".$_GET['plug']."&amp;id=%s&amp;act=list_edit_role'>%s</a>";
170         $list_left_icon = "<img src='images/select_acl_role.png' alt='"._("Role")."'>";
171         $cn = htmlentities(utf8_decode($acl_entry['cn'][0])) ;
173         if(isset($acl_entry['description'][0])){
174           $cn .= "&nbsp;[".$acl_entry['description'][0]."]";
175         }
177         /* Add copy & paste handler */
178         if(($this->parent->CopyPasteHandler) && preg_match("/(c.*w|w.*c)/",$acl_all)){
179           $action.= "<input class='center' type='image'
180             src='images/editcut.png' alt='"._("cut")."' name='cut_%KEY%' title='"._("Cut this entry")."'>&nbsp;";
181           $action.= "<input class='center' type='image'
182             src='images/editcopy.png' alt='"._("copy")."' name='copy_%KEY%' title='"._("Copy this entry")."'>&nbsp;";
183         }
185         /* Add actions depending on acls */
186         if(preg_match("/r/", $acl)){
187           $action.= "<input class='center' type='image' src='images/edit.png' alt='"._("edit")."'     
188             name='list_acl_role_edit_%KEY%' title='"._("Edit acl role")."'>";
189         }
191         /* Add snapshot functionality */
192         if(preg_match("/(c.*w|w.*c)/", $acl_all)){
193           $action.= $this->GetSnapShotActions($acl_entry['dn']);
194         }
196         if(preg_match("/d/", $acl)){
197           $action.= "<input class='center' type='image' src='images/edittrash.png' alt='"._("delete")."' 
198             name='list_acl_role_del_%KEY%' title='"._("Delete acl role")."'>";
199         }
200       }else{
202         /* Acl handling */
203         $editlink       = "<a href='?plug=".$_GET['plug']."&amp;id=%s&amp;act=list_edit_entry'>%s</a>";
204         $list_left_icon = "<img src='images/select_acl.png' alt='"._("Acl")."'>";
205         $cn = htmlentities(utf8_decode($acl_entry['dn'])); 
207         /* Add actions depending on acls */
208         if(preg_match("/r/", $acl)){
209           $action.= "<input class='center' type='image' src='images/edit.png' alt='"._("edit")."'     
210             name='list_acl_edit_%KEY%' title='"._("Edit acl")."'>";
211         }
212         if(preg_match("/d/", $acl)){
213           $action.= "<input class='center' type='image' src='images/edittrash.png' alt='"._("delete")."' 
214             name='list_acl_del_%KEY%' title='"._("Delete acl")."'>";
215         }
216       }
218       $field1 = array("string" => $list_left_icon, "attach"=> "style='text-align:center;width:20px;'");
219       $field2 = array("string" => sprintf($editlink,$key,$cn)."&nbsp;","attach" => "");
220       $field3 = array("string" => preg_replace("/%KEY%/",$key,$action), "attach"=> "style='text-align:right;width:".$this->action_col_size."px;border-right:0px;'");
221       $this->AddElement(array($field1,$field2,$field3));
222     }
223   }
225   function Save()
226   {
227     MultiSelectWindow :: Save();  
228   }
230   function save_object()
231   {
232     /* Save automatic created POSTs like regex, checkboxes */
233     MultiSelectWindow::save_object();   
234   }
237   /* Add some additional checkboxes to the filter part, this should be generated dynamically. */
238   function set_filter_objectclasses()
239   { 
240   }
241   
242   /* Return objectClass names used in filter part */  
243   function get_filter_objectclasses()
244   {
245     return(array("gosaAccount","gosaDepartment"));
246   }
248   
249   /* Return plugin informations for acl handling */
250   function plInfo()
251   {
252     return (array(
253           "plShortName"   => _("ACL")."&nbsp;&amp;&nbsp;"._("ACL roles"),
254           "plDescription" => _("ACL")."&nbsp;&amp;&nbsp;"._("ACL roles")."&nbsp;-&nbsp;("._("Access control list").")",
255           "plSelfModify"  => FALSE,
256           "plDepends"     => array(),
257           "plPriority"    => 0,
258           "plSection"     => array("administration"),
259           "plCategory"    => array("acl" => array("description"  => _("ACL")."&nbsp;&amp;&nbsp;"._("ACL roles"),
260                                                           "objectClass"  => array("gosaAcl","gosaRole"))),
261           "plProvidedAcls"=> array(
262             "cn"          => _("Role name"),
263             "description" => _("Role description"))
265           ));
266   }
271 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
272 ?>