Code

Some additional acl handling for aclManagement
[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", "acls");
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 = 45;
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(SEPERATOR);
57     $this->AddCheckBox("SubSearch",  _("Select to search within subtrees"), _("Ignore subtrees"), false);
60     /*                  Name                 ,Text                              ,Default  , Connect with alphabet  */
61     $this->AddRegex   ("Regex",     _("Display acls matching"),"Not implemented yet" , true);
62   }
65   function GenHeader()
66   {
67      /* Prepare departments,
68        which are shown in the listbox on top of the listbox
69      */
70     $options= "";
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     /* Get copy & paste icon */
93     $acl      = $ui->get_permissions($this->selectedBase,"acl/aclManagement");
95     /* Create header with selected base */
96     $listhead = "<div style='background:#F0F0F9;padding:5px;'>".
97       " <input class='center' type='image' src='images/list_root.png' align='middle' 
98       title='"._("Go to root department")."' name='dep_root' alt='"._("Root")."'>&nbsp;".
99       " <input class='center' type='image' align='middle' src='images/list_back.png' 
100       title='"._("Go up one department")."' alt='"._("Up")."'                name='dep_back'>&nbsp;".
101       " <input class='center' type='image' align='middle' src='images/list_home.png' 
102       title='"._("Go to users department")."' alt='"._("Home")."'            name='dep_home'>&nbsp;".
103       " <input class='center' type='image' src='images/list_reload.png' align='middle' 
104       title='"._("Reload list")."' name='submit_department' alt='".        _("Submit")."'>&nbsp;".
105       " <img   class='center' src='images/list_seperator.png' align='middle' alt='' height='16' width='1'>&nbsp;";
106     $listhead .=  
107       _("Base")."&nbsp;<select name='CurrentMainBase' onChange='mainform.submit()' class='center'>$options</select>".
108       " <input class='center' type='image' src='images/list_submit.png' align='middle' 
109       title='"._("Submit department")."' name='submit_department' alt='".  _("Submit")."'>&nbsp;".
110       "</div>";
112     $this->SetListHeader($listhead);
113   }
115   /* so some basic settings */
116   function execute()
117   {
118     $this->ClearElementsList();
119     $this->GenHeader();
120   }
122   function setEntries($list)
123   {
124     $list_left_icon = "<img src='images/select_acl.png' alt='"._("Acl")."'>";
125     $editlink       = "<a href='?plug=".$_GET['plug']."&amp;id=%s&amp;act=list_edit_entry'>%s</a>";
127     foreach($list as $key => $acl_entry){
129       /* Get copy & paste icon */
130       $acl      = $this->ui->get_permissions($acl_entry['dn'],"acl/aclManagement");
132       $action = "";
134       /* Add actions depending on acls */
135       if(preg_match("/r/", $acl)){
136         $action.= "<input class='center' type='image' src='images/edit.png' alt='"._("edit")."'     
137           name='list_acl_edit_%KEY%' title='"._("Edit system")."'>";
138       }
139       if(preg_match("/d/", $acl)){
140         $action.= "<input class='center' type='image' src='images/edittrash.png' alt='"._("delete")."' 
141           name='list_acl_del_%KEY%' title='"._("Delete system")."'>";
142       }
144       $field1 = array("string" => $list_left_icon, "attach"=> "style='text-align:center;width:20px;'");
145       $field2 = array("string" => sprintf($editlink,$key,htmlentities(utf8_decode($acl_entry['dn'])))."&nbsp;","attach" => "");
146       $field3 = array("string" => preg_replace("/%KEY%/",$key,$action), "attach"=> "style='text-align:center;width:".$this->action_col_size."px;border-right:0px;'");
147       $this->AddElement(array($field1,$field2,$field3));
148     }
149   }
151   function Save()
152   {
153     MultiSelectWindow :: Save();  
154   }
156   function save_object()
157   {
158     /* Save automatic created POSTs like regex, checkboxes */
159     MultiSelectWindow::save_object();   
160   }
163   /* Add some additional checkboxes to the filter part, this should be generated dynamically. */
164   function set_filter_objectclasses()
165   { 
166     #FIXME This should be created dynamically 
167     $this->gosaAccount = true;
168     $this->AddCheckBox("gosaAccount",     _("Select to display users"),       _("Display user")       , true);
169     $this->gosaDepartment = true;
170     $this->AddCheckBox("gosaDepartment",  _("Select to display departments"), _("Display departments"), true);
171   }
173   
174   /* Return objectClass names used in filter part */  
175   function get_filter_objectclasses()
176   {
177     return(array("gosaAccount","gosaDepartment"));
178   }
181 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
182 ?>