1 <?php
3 class divListOGroup extends MultiSelectWindow
4 {
6 /* Current base */
7 var $selectedBase = "";
8 var $departments = array();
10 /* Regex */
11 var $Regex = "*";
13 /* CheckBoxes, to change default values modify $this->AddCheckBox */
14 var $UserGroups ;
15 var $GroupGroups ;
16 var $ApplicationGroups ;
17 var $DepartmentGroups ;
18 var $ServerGroups ;
19 var $WorkstationGroups ;
20 var $TerminalGroups ;
21 var $PrinterGroups ;
22 var $PhoneGroups ;
25 /* Subsearch checkbox */
26 var $SubSearch ;
27 var $parent ;
28 var $ui ;
30 function divListOGroup ($config,$parent)
31 {
32 MultiSelectWindow::MultiSelectWindow($config, "OGroups", "ogroups");
34 $this->parent = $parent;
35 $this->ui = get_userinfo();
37 /* Set list strings */
38 $this->SetTitle(_("List of object groups"));
39 $this->SetSummary(_("List of object groups"));
40 $this->EnableAplhabet(true);
42 /* Result page will look like a headpage */
43 $this->SetHeadpageMode();
44 $this->SetInformation(_("This menu allows you to add, edit or remove selected groups. You may want to use the range selector on top of the group listbox, when working with a large number of groups."));
46 /* Disable buttonsm */
47 $this->EnableCloseButton(false);
48 $this->EnableSaveButton (false);
50 /* Dynamic action col, depending on snapshot icons */
51 $action_col_size = 70;
52 if($this->parent->snapshotEnabled()){
53 $action_col_size += 38;
54 }
56 /* set Page header */
57 $this->AddHeader(array("string" => " ", "attach" => "style='text-align:center;width:20px;'"));
58 $this->AddHeader(array("string" => _("Name of object groups")." / "._("Departments"), "attach" => "style=''"));
59 $this->AddHeader(array("string" => _("Properties"), "attach" => "style='width:136px;'"));
60 $this->AddHeader(array("string" => _("Actions"), "attach" => "style='width:".$action_col_size."px;border-right:0px;text-align:right;'"));
62 /* Text ,Value ,Name ,Is selected */
63 $this->AddCheckBox("UserGroups" , _("Select to see groups containing users") , _("Show groups containing users"), true);
64 $this->AddCheckBox("GroupGroups" , _("Select to see groups containing groups") , _("Show groups containing groups"), true);
65 $this->AddCheckBox("ApplicationGroups", _("Select to see groups containing applications"), _("Show groups containing applications"), true);
66 $this->AddCheckBox("DepartmentGroups" , _("Select to see groups containing departments") , _("Show groups containing departments"), true);
67 $this->AddCheckBox("ServerGroups" , _("Select to see groups containing servers") , _("Show groups containing servers"), true);
68 $this->AddCheckBox("WorkstationGroups", _("Select to see groups containing workstations"), _("Show groups containing workstations"), true);
69 $this->AddCheckBox("TerminalGroups" , _("Select to see groups containing terminals") , _("Show groups containing terminals"), true);
70 $this->AddCheckBox("PrinterGroups" , _("Select to see groups containing printer") , _("Show groups containing printer"), true);
71 $this->AddCheckBox("PhoneGroups" , _("Select to see groups containing phones") , _("Show groups containing phones"), true);
73 /* Add SubSearch checkbox */
74 $this->AddCheckBox(SEPERATOR);
75 $this->AddCheckBox("SubSearch", _("Select to search within subtrees"), _("Ignore subtrees"), false);
77 /* Name ,Text ,Default , Connect with alphabet */
78 $this->AddRegex ("Regex", _("Regular expression for matching group names"), "*" , true);
79 }
82 function GenHeader()
83 {
84 /* Prepare departments,
85 which are shown in the listbox on top of the listbox
86 */
87 $options= "";
89 /* Get all departments within this subtree */
90 $base = $this->config->current['BASE'];
91 $deps= get_list("(&(|(ou=*)(description=*))(objectClass=gosaDepartment))", $this->module, $base,
92 array("ou", "description"), GL_SIZELIMIT | GL_SUBSEARCH);
94 /* Load possible departments */
95 $ui= get_userinfo();
96 $tdeps= $ui->get_module_departments("ogroups");
98 $ids = $this->config->idepartments;
100 foreach($deps as $dep){
101 if(isset($ids[$dep['dn']]) && in_array_ics($dep['dn'], $tdeps)){
103 $value = $ids[$dep['dn']];
104 if ($this->selectedBase == $dep['dn']){
105 $options.= "<option selected='selected' value='".$dep['dn']."'>$value</option>";
106 } else {
107 $options.= "<option value='".$dep['dn']."'>$value</option>";
108 }
109 }
110 }
112 /* Add a seperator after displaying c&p and snapshot icons ? */
113 $add_sep = false;
115 /* Get copy & paste icon */
116 $acls = $ui->get_permissions($this->selectedBase,"ogroups/ogroup");
117 $acl_all= $ui->has_complete_category_acls($this->selectedBase,"ogroups");
118 $Copy_Paste ="";
119 if(preg_match("/(c.*w|w.*c)/",$acl_all) && $this->parent->CopyPasteHandler){
120 $Copy_Paste = $this->parent->CopyPasteHandler->generatePasteIcon();
121 $add_sep = true;
122 }
124 /* Add default header */
125 $listhead = MultiSelectWindow::get_default_header();
127 /* Add snapshot restore icons */
128 if(preg_match("/(c.*w|w.*c)/",$acl_all)){
129 $listhead .= $this->get_snapshot_header($this->selectedBase);
130 $add_sep = true;
131 }
133 /* Create new ogroup icon */
134 if(preg_match("/c/",$acls)) {
135 $listhead .=" <input class='center' type='image' align='middle' src='images/list_new_ogroup.png'
136 title='"._("Create new object group")."' alt='"._("new")."' name='group_new'>";
137 $add_sep = true;
138 }
140 /* Add copy & paste icon */
141 $listhead .= $Copy_Paste;
143 /* Should we add a seperator here ? */
144 if($add_sep){
145 $listhead .=" <img class='center' src='images/list_seperator.png' align='middle' alt='' height='16' width='1'> ";
146 }
148 /* Add department selector */
149 $listhead .= _("Base")." <select name='CurrentMainBase' onChange='mainform.submit()' class='center'>$options</select>".
150 " <input class='center' type='image' src='images/list_submit.png' align='middle'
151 title='"._("Submit department")."' name='submit_department' alt='"._("Submit")."'> ".
152 "</div>";
154 $this->SetListHeader($listhead);
155 }
157 function execute()
158 {
159 $this->ClearElementsList();
160 $this->GenHeader();
161 }
163 function setEntries($list)
164 {
165 /* Add Copy & Paste buttons if copy&paste is enabled
166 */
167 // Defining Links
168 $linkopen = "<a href='?plug=".$_GET['plug']."&act=dep_open&dep_id=%s'>%s</a>";
169 $editlink = "<a href='?plug=".$_GET['plug']."&id=%s&act=edit_entry'>%s</a>";
170 $userimg = "<img class='center' src='images/select_groups.png' alt='User' title='%s'>";
171 $mailimg = "<img class='center' src='images/mailto.png' alt='M' title='"._("Mail") ."'>";
172 $empty = "<img class='center' src='images/empty.png' style='width:16px;height:16px;' alt=''>";
174 /* Dynamic action col, depending on snapshot icons */
175 $action_col_size = 70;
176 if($this->parent->snapshotEnabled()){
177 $action_col_size += 38;
178 }
180 $ui = get_userinfo();
182 // Assigning ogroups
183 foreach($list as $key => $val){
185 /* Create action icons */
186 $actions= "";
187 $acl_all= $ui->has_complete_category_acls($val['dn'],"ogroups");
188 if(($this->parent->CopyPasteHandler) && preg_match("/(c.*w|w.*c)/",$acl_all)){
189 $actions.= "<input class='center' type='image'
190 src='images/editcut.png' alt='"._("cut")."' name='cut_%KEY%' title='"._("Cut this entry")."'> ";
191 $actions.= "<input class='center' type='image'
192 src='images/editcopy.png' alt='"._("copy")."' name='copy_%KEY%' title='"._("Copy this entry")."'> ";
193 }
195 $actions.= "<input class='center' type='image'
196 src='images/edit.png' alt='"._("edit")."' name='group_edit_%KEY%' title='"._("Edit this entry")."'>";
198 if(preg_match("/(c.*w|w.*c)/", $acl_all)){
199 $actions.= $this->GetSnapShotActions($val['dn']);
200 }
202 if(preg_match("/d/",$ui->get_permissions($val['dn'],"ogroups/ogroup"))) {
203 $actions.= "<input class='center' type='image'
204 src='images/edittrash.png' alt='"._("delete")."' name='group_del_%KEY%' title='"._("Delete this entry")."'>";
205 }else{
206 $actions.= "<img class='center' src='images/empty.png' alt=' '
207 title='"._("You are not allowed to remove this entry.")."'>";
208 }
211 if(isset($val['mail'])){
212 $mail = $mailimg;
213 }else{
214 $mail = $empty;
215 }
216 $title = "title='".preg_replace('/ /', ' ', @LDAP::fix($val['dn']))."'";
217 if(!isset($val['description'][0])){
218 $desc = "";
219 }else{
220 $desc = " - [ ".$val['description'][0]." ]";
221 }
222 $field1 = array("string" => "<img src='images/list_ogroup.png' alt='"._("Object group")."' ".$title.">", "attach" => "style='text-align:center;width: 20px;'");
223 $field2 = array("string" => sprintf($editlink,$key,($val['cn']['0'].$desc)), "attach" => "style='' ".$title);
224 $field3 = array("string" => preg_replace("/%KEY/", $key, $this->parent->convert_list($val))." ".$mail, "attach" => "style='width:136px;'");
225 $field4 = array("string" => preg_replace("/%KEY%/", $key, $actions), "attach" => "style='width:".$action_col_size."px;border-right:0px;text-align:right;'");
227 $this->AddElement(array($field1,$field2,$field3,$field4));
228 }
229 }
231 function Save()
232 {
233 MultiSelectWindow :: Save();
234 }
236 function save_object()
237 {
238 /* Save automatic created POSTs like regex, checkboxes */
239 MultiSelectWindow::save_object();
240 }
241 }
242 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
243 ?>