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;
23 function divListACL ($config,$parent)
24 {
25 MultiSelectWindow::MultiSelectWindow($config, "ACLs", "acl");
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);
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"=>" ", "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();
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= "";
71 /* Get all departments within this subtree */
72 $base = $this->config->current['BASE'];
73 $deps= get_list("(&(|(ou=*)(description=*))(objectClass=gosaDepartment))", "acl", $base,
74 array("ou", "description"), GL_SIZELIMIT | GL_SUBSEARCH);
76 /* Load possible departments */
77 $ui = get_userinfo();
78 $tdeps = $ui->get_module_departments("acl");
79 $ids = $this->config->idepartments;
80 foreach($deps as $dep){
81 if(isset($ids[$dep['dn']]) && in_array_ics($dep['dn'], $tdeps)){
82 $value = $ids[$dep['dn']];
83 if ($this->selectedBase == $dep['dn']){
84 $options.= "<option selected='selected' value='".$dep['dn']."'>$value</option>";
85 } else {
86 $options.= "<option value='".$dep['dn']."'>$value</option>";
87 }
88 }
89 }
91 /* Get copy & paste icon */
92 $acl = $ui->get_permissions($this->selectedBase,"acl/aclManagement");
95 /* Add default header */
96 $listhead = MultiSelectWindow::get_default_header();
97 $listhead .=
98 _("Base")." <select name='CurrentMainBase' onChange='mainform.submit()' class='center'>$options</select>".
99 " <input class='center' type='image' src='images/list_submit.png' align='middle'
100 title='"._("Submit department")."' name='submit_department' alt='". _("Submit")."'> ".
101 "</div>";
103 $this->SetListHeader($listhead);
104 }
106 /* so some basic settings */
107 function execute()
108 {
109 $this->ClearElementsList();
110 $this->GenHeader();
111 }
113 function setEntries($list)
114 {
115 $list_left_icon = "<img src='images/select_acl.png' alt='"._("Acl")."'>";
116 $editlink = "<a href='?plug=".$_GET['plug']."&id=%s&act=list_edit_entry'>%s</a>";
118 foreach($list as $key => $acl_entry){
120 /* Get copy & paste icon */
121 $acl = $this->ui->get_permissions($acl_entry['dn'],"acl/aclManagement");
123 $action = "";
125 /* Add actions depending on acls */
126 if(preg_match("/r/", $acl)){
127 $action.= "<input class='center' type='image' src='images/edit.png' alt='"._("edit")."'
128 name='list_acl_edit_%KEY%' title='"._("Edit system")."'>";
129 }
130 if(preg_match("/d/", $acl)){
131 $action.= "<input class='center' type='image' src='images/edittrash.png' alt='"._("delete")."'
132 name='list_acl_del_%KEY%' title='"._("Delete system")."'>";
133 }
135 $field1 = array("string" => $list_left_icon, "attach"=> "style='text-align:center;width:20px;'");
136 $field2 = array("string" => sprintf($editlink,$key,htmlentities(utf8_decode($acl_entry['dn'])))." ","attach" => "");
137 $field3 = array("string" => preg_replace("/%KEY%/",$key,$action), "attach"=> "style='text-align:center;width:".$this->action_col_size."px;border-right:0px;'");
138 $this->AddElement(array($field1,$field2,$field3));
139 }
140 }
142 function Save()
143 {
144 MultiSelectWindow :: Save();
145 }
147 function save_object()
148 {
149 /* Save automatic created POSTs like regex, checkboxes */
150 MultiSelectWindow::save_object();
151 }
154 /* Add some additional checkboxes to the filter part, this should be generated dynamically. */
155 function set_filter_objectclasses()
156 {
157 }
159 /* Return objectClass names used in filter part */
160 function get_filter_objectclasses()
161 {
162 return(array("gosaAccount","gosaDepartment"));
163 }
165 }
166 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
167 ?>