Code

Updated css und div framework.
[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 = 110;
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     $base = $this->config->current['BASE'];
74     $deps= get_list("(&(|(ou=*)(description=*))(objectClass=gosaDepartment))", "acl", $base,
75                     array("ou", "description"), GL_SIZELIMIT | GL_SUBSEARCH);
77     /* Load possible departments */
78     $ui     = get_userinfo();
79     $tdeps  = $ui->get_module_departments("acl");
80     $ids    = $this->config->idepartments;
81     foreach($deps as $dep){
82       if(isset($ids[$dep['dn']]) && in_array_ics($dep['dn'], $tdeps)){
83         $value = $ids[$dep['dn']];
84         if ($this->selectedBase == $dep['dn']){
85           $options.= "<option selected='selected' value='".$dep['dn']."'>$value</option>";
86         } else {
87           $options.= "<option value='".$dep['dn']."'>$value</option>";
88         }
89       }
90     }
92     /* Allow copy & paste for roles */ 
93     $acl_all  = $ui->has_complete_category_acls($this->selectedBase,"acl");
94     $acl      = $ui->get_permissions($this->selectedBase,"acl/acl");
96     /* Add default header */
97     $listhead = MultiSelectWindow::get_default_header();
99     /* Get copy & paste icon */
100     $Copy_Paste ="";
101     if(preg_match("/(c.*w|w.*c)/",$acl_all) &&  $this->parent->CopyPasteHandler){
102       $Copy_Paste = $this->parent->CopyPasteHandler->generatePasteIcon();
103       $addsep = true;
104     }
106     /* Add snapshot icons */
107     if(preg_match("/(c.*w|w.*c)/",$acl_all)){
108       $listhead .= $this->get_snapshot_header($this->selectedBase);
109       $add_sep = true;
110     }
112     if(preg_match("/c/",$ui->get_permissions($this->selectedBase,"acl/acl"))){
113       $add_sep = true;
114       $listhead .= "<input class='center' type='image' align='middle' src='images/list_new_acl_role.png'
115         name='new_acl_role'     alt='"._("New acl role")."' title='"._("New acl role")."'>&nbsp;";
116     }
118     $listhead .= $Copy_Paste. 
119       _("Base")."&nbsp;<select name='CurrentMainBase' onChange='mainform.submit()' class='center'>$options</select>".
120       " <input class='center' type='image' src='images/list_submit.png' align='middle' 
121       title='"._("Submit department")."' name='submit_department' alt='".  _("Submit")."'>&nbsp;".
122       "</div>";
124     $this->SetListHeader($listhead);
125   }
127   /* so some basic settings */
128   function execute()
129   {
130     $this->ClearElementsList();
131     $this->GenHeader();
132   }
134   function setEntries($list)
135   {
137     foreach($list as $key => $acl_entry){
139       /* Get copy & paste icon */
140       $acl        = $this->ui->get_permissions($acl_entry['dn'],"acl/acl");
141       $acl_all    = $this->ui->has_complete_category_acls($acl_entry['dn'],"acl");
142       $action     = "";
144       if(in_array("gosaRole",$acl_entry['objectClass'])){
146         /* Role handling */
147         $editlink       = "<a href='?plug=".$_GET['plug']."&amp;id=%s&amp;act=list_edit_role'>%s</a>";
148         $list_left_icon = "<img src='images/select_acl_role.png' alt='"._("Role")."'>";
149         $cn = htmlentities(utf8_decode($acl_entry['cn'][0])) ;
151         if(isset($acl_entry['description'][0])){
152           $cn .= "&nbsp;[".$acl_entry['description'][0]."]";
153         }
155         /* Add copy & paste handler */
156         if(($this->parent->CopyPasteHandler) && preg_match("/(c.*w|w.*c)/",$acl_all)){
157           $action.= "<input class='center' type='image'
158             src='images/editcut.png' alt='"._("cut")."' name='cut_%KEY%' title='"._("Cut this entry")."'>&nbsp;";
159           $action.= "<input class='center' type='image'
160             src='images/editcopy.png' alt='"._("copy")."' name='copy_%KEY%' title='"._("Copy this entry")."'>&nbsp;";
161         }
163         /* Add actions depending on acls */
164         if(preg_match("/r/", $acl)){
165           $action.= "<input class='center' type='image' src='images/edit.png' alt='"._("edit")."'     
166             name='list_acl_role_edit_%KEY%' title='"._("Edit acl role")."'>";
167         }
169         /* Add snapshot functionality */
170         if(preg_match("/(c.*w|w.*c)/", $acl_all)){
171           $action.= $this->GetSnapShotActions($acl_entry['dn']);
172         }
174         if(preg_match("/d/", $acl)){
175           $action.= "<input class='center' type='image' src='images/edittrash.png' alt='"._("delete")."' 
176             name='list_acl_role_del_%KEY%' title='"._("Delete acl role")."'>";
177         }
178       }else{
180         /* Acl handling */
181         $editlink       = "<a href='?plug=".$_GET['plug']."&amp;id=%s&amp;act=list_edit_entry'>%s</a>";
182         $list_left_icon = "<img src='images/select_acl.png' alt='"._("Acl")."'>";
183         $cn = htmlentities(utf8_decode($acl_entry['dn'])); 
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_edit_%KEY%' title='"._("Edit acl")."'>";
189         }
190         if(preg_match("/d/", $acl)){
191           $action.= "<input class='center' type='image' src='images/edittrash.png' alt='"._("delete")."' 
192             name='list_acl_del_%KEY%' title='"._("Delete acl")."'>";
193         }
194       }
196       $field1 = array("string" => $list_left_icon, "attach"=> "style='text-align:center;width:20px;'");
197       $field2 = array("string" => sprintf($editlink,$key,$cn)."&nbsp;","attach" => "");
198       $field3 = array("string" => preg_replace("/%KEY%/",$key,$action), "attach"=> "style='text-align:right;width:".$this->action_col_size."px;border-right:0px;'");
199       $this->AddElement(array($field1,$field2,$field3));
200     }
201   }
203   function Save()
204   {
205     MultiSelectWindow :: Save();  
206   }
208   function save_object()
209   {
210     /* Save automatic created POSTs like regex, checkboxes */
211     MultiSelectWindow::save_object();   
212   }
215   /* Add some additional checkboxes to the filter part, this should be generated dynamically. */
216   function set_filter_objectclasses()
217   { 
218   }
219   
220   /* Return objectClass names used in filter part */  
221   function get_filter_objectclasses()
222   {
223     return(array("gosaAccount","gosaDepartment"));
224   }
226   
227   /* Return plugin informations for acl handling */
228   function plInfo()
229   {
230     return (array(
231           "plShortName"   => _("ACL")."&nbsp;&amp;&nbsp;"._("ACL roles"),
232           "plDescription" => _("ACL")."&nbsp;&amp;&nbsp;"._("ACL roles")."&nbsp;-&nbsp;("._("Access control list").")",
233           "plSelfModify"  => FALSE,
234           "plDepends"     => array(),
235           "plPriority"    => 0,
236           "plSection"     => array("administration"),
237           "plCategory"    => array("acl" => array("description"  => _("ACL")."&nbsp;&amp;&nbsp;"._("ACL roles"),
238                                                           "objectClass"  => array("gosaAcl","gosaRole"))),
239           "plProvidedAcls"=> array(
240             "cn"          => _("Role name"),
241             "description" => _("Role description"))
243           ));
244   }
249 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
250 ?>