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 ;
23 function divListACL ($config,$parent)
24 {
25 MultiSelectWindow::MultiSelectWindow($config, "ACLs", "acls");
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, depending on snapshot icons */
45 $action_col_size = 80;
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:".$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(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= "";
71 foreach ($this->config->idepartments as $key => $value){
72 if ($this->selectedBase == $key){
73 $options.= "<option selected='selected' value='$key'>$value</option>";
74 } else {
75 $options.= "<option value='$key'>$value</option>";
76 }
77 }
79 /* Create header with selected base */
80 $listhead = "<div style='background:#F0F0F9;padding:5px;'>".
81 " <input class='center' type='image' src='images/list_root.png' align='middle'
82 title='"._("Go to root department")."' name='dep_root' alt='"._("Root")."'> ".
83 " <input class='center' type='image' align='middle' src='images/list_back.png'
84 title='"._("Go up one department")."' alt='"._("Up")."' name='dep_back'> ".
85 " <input class='center' type='image' align='middle' src='images/list_home.png'
86 title='"._("Go to users department")."' alt='"._("Home")."' name='dep_home'> ".
87 " <input class='center' type='image' src='images/list_reload.png' align='middle'
88 title='"._("Reload list")."' name='submit_department' alt='". _("Submit")."'> ".
89 " <img class='center' src='images/list_seperator.png' align='middle' alt='' height='16' width='1'> ";
90 $listhead .= $this->get_snapshot_header($this->selectedBase);
91 $listhead .=
92 _("Base")." <select name='CurrentMainBase' onChange='mainform.submit()' class='center'>$options</select>".
93 " <input class='center' type='image' src='images/list_submit.png' align='middle'
94 title='"._("Submit department")."' name='submit_department' alt='". _("Submit")."'> ".
95 "</div>";
97 $this->SetListHeader($listhead);
98 }
100 /* so some basic settings */
101 function execute()
102 {
103 $this->ClearElementsList();
104 $this->GenHeader();
105 }
107 function setEntries($list)
108 {
109 $list_left_icon = "<img src='images/select_acl.png' alt='"._("Acl")."'>";
110 $editlink = "<a href='?plug=".$_GET['plug']."&id=%s&act=edit_entry'>%s</a>";
112 foreach($list as $key => $acl_entry){
114 $skip = true;
115 foreach($this->get_filter_objectclasses() as $oc){
116 if(in_array($oc,$acl_entry['objectClass']) && $this->$oc){
117 $skip = false;
118 }
119 }
121 if(!$skip){
122 $action = "<input class='center' type='image' src='images/edit.png' alt='"._("edit")."'
123 name='acl_edit_%KEY%' title='"._("Edit system")."'>";
124 $action.= $this->GetSnapShotActions($acl_entry['dn']);
125 $action.= "<input class='center' type='image' src='images/edittrash.png' alt='"._("delete")."'
126 name='acl_del_%KEY%' title='"._("Delete system")."'>";
128 $field1 = array("string" => $list_left_icon, "attach"=> "style='text-align:center;width:20px;'");
129 $field2 = array("string" => sprintf($editlink,$key,htmlentities(utf8_decode($acl_entry['dn'])))." ","attach" => "");
130 $field3 = array("string" => preg_replace("/%KEY%/",$key,$action), "attach"=> "style='text-align:center;width:80px;border-right:0px;'");
131 $this->AddElement(array($field1,$field2,$field3));
132 }
133 }
134 }
136 function Save()
137 {
138 MultiSelectWindow :: Save();
139 }
141 function save_object()
142 {
143 /* Save automatic created POSTs like regex, checkboxes */
144 MultiSelectWindow::save_object();
145 }
148 /* Add some additional checkboxes to the filter part, this should be generated dynamically. */
149 function set_filter_objectclasses()
150 {
151 #FIXME This should be created dynamically
152 $this->gosaAccount = true;
153 $this->AddCheckBox("gosaAccount", _("Select to display users"), _("Display user") , true);
154 $this->gosaDepartment = true;
155 $this->AddCheckBox("gosaDepartment", _("Select to display departments"), _("Display departments"), true);
156 }
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 ?>