1 <?php
3 class divListGroup extends MultiSelectWindow
4 {
6 /* Current base */
7 var $selectedBase = "";
8 var $departments = array();
10 /* Regex */
11 var $Regex = "*";
12 var $UserRegex = "*";
14 /* CheckBoxes, to change default values modify $this->AddCheckBox */
15 var $ShowPrimaryGroups;
16 var $ShowSambaGroups;
17 var $ShowApplicationGroups;
18 var $ShowMailGroups;
19 var $ShowFunctionalGroups;
21 /* Subsearch checkbox */
22 var $SubSearch = false;
24 var $parent ;
25 var $ui ;
27 function divListGroup ($config,$parent)
28 {
29 MultiSelectWindow::MultiSelectWindow($config,"Groups");
31 $this->parent = $parent;
32 $this->ui = get_userinfo();
34 /* Set list strings */
35 $this->SetTitle(_("List of groups"));
36 $this->SetSummary(_("List of groups"));
37 $this->EnableAplhabet (true);
39 /* Result page will look like a headpage */
40 $this->SetHeadpageMode();
41 $this->SetInformation(_("This menu allows you to add, edit and 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."));
43 /* Disable buttonsm */
44 $this->EnableCloseButton(false);
45 $this->EnableSaveButton (false);
47 /* set Page header */
48 $this->AddHeader(array("string"=>" ","attach"=>"style='width:20px;'"));
49 $this->AddHeader(array("string"=>_("Groupname / Department")));
50 $this->AddHeader(array("string"=>_("Properties"),"attach"=>"style='width:136px;'"));
51 $this->AddHeader(array("string"=>_("Actions"),"attach"=>"style='width:110px;border-right:0px;'"));
53 /* Text ,Value ,Name ,Is selected */
54 $this->AddCheckBox("ShowPrimaryGroups", _("Select to see groups that are primary groups of users"), _("Show primary groups"), true);
55 $this->AddCheckBox("ShowSambaGroups", _("Select to see groups that have samba groups mappings"), _("Show samba groups"), true);
56 $this->AddCheckBox("ShowApplicationGroups", _("Select to see groups that have applications configured"), _("Show application groups"),true);
57 $this->AddCheckBox("ShowMailGroups", _("Select to see groups that have mail settings"), _("Show mail groups"), true);
58 $this->AddCheckBox("ShowFunctionalGroups", _("Select to see normal groups that have only functional aspects"), _("Show functional groups"), true);
59 $this->AddCheckBox(SEPERATOR);
61 /* Add SubSearch checkbox */
62 $this->AddCheckBox("SubSearch", _("Select to search within subtrees"), _("Ignore subtrees"), false);
64 /* Name ,Text ,Default , Connect with alphabet */
65 $this->AddRegex ("Regex", _("Regular expression for matching group names"), "*" , true);
66 $this->AddRegex ("UserRegex", _("User name of which groups are shown"), "*" , false, "images/search_user.png");
67 }
70 function GenHeader()
71 {
72 /* Prepare departments,
73 which are shown in the listbox on top of the listbox
74 */
75 $options= "";
76 foreach ($this->config->idepartments as $key => $value){
77 if ($this->selectedBase == $key){
78 $options.= "<option selected='selected' value='$key'>$value</option>";
79 } else {
80 $options.= "<option value='$key'>$value</option>";
81 }
82 }
84 if($this->parent->CopyPasteHandler){
85 $Copy_Paste = $this->parent->CopyPasteHandler->generatePasteIcon();
86 }else{
87 $Copy_Paste ="";
88 }
90 // Managment
91 $listhead = "
92 <div style='background:#F0F0F9;padding:5px;'>".
93 " <input type='image' class='center' src='images/list_root.png' title='"._("Go to root department")."' name='dep_root' alt='"._("Root")."'> ".
94 " <input type='image' class='center' src='images/list_back.png' title='"._("Go up one department")."' alt='"._("Up")."' name='dep_back'> ".
95 " <input type='image' class='center' src='images/list_home.png' title='"._("Go to users department")."' alt='"._("Home")."' name='dep_home'> ".
96 " <input class='center' type='image' src='images/list_reload.png' align='middle' title='"._("Reload list")."' name='submit_department' alt='". _("Submit")."'> ".
97 " <img class='center' src='images/list_seperator.png' alt='' height='16' width='1'> ";
100 if($this->parent->snapshotEnabled()){
101 $listhead .= " <input class='center' type='image' align='middle' src='images/restore.png'
102 title='"._("Restore snapshopts of already deleted objects")."' alt='"._("Restore")."' name='RestoreDeletedSnapShot'>".
103 " <img class='center' src='images/list_seperator.png' align='middle' alt='' height='16' width='1'> ";
104 }
106 $listhead.=" <input type='image' class='center' src='images/list_new_group.png' title='"._("Create new group")."' alt='"._("New")."' name='group_new'> ".
107 $Copy_Paste.
108 " <img class='center' src='images/list_seperator.png' alt='' height='16' width='1'> ".
109 _("Base")." <select name='CurrentMainBase' onChange='mainform.submit()' class='center'>$options</select>".
110 " <input type='image' class='center' src='images/list_submit.png' title='"._("Submit department")."' name='submit_department' alt='"._("Submit").
111 "'> ".
112 "</div>";
114 $this->SetListHeader($listhead);
115 }
117 function execute()
118 {
119 $this->ClearElementsList();
120 $this->GenHeader();
121 }
123 function setEntries($groups)
124 {
125 // Defining Links
126 $linkopen = "<a href='?plug=".$_GET['plug']."&act=dep_open&dep_id=%s'>%s</a>";
128 // image Buttons
129 $editlink = "<a href='?plug=".$_GET['plug']."&id=%s&act=edit_entry'>%s</a>";
130 $userimg = "<img class='center' src='images/select_groups.png' alt='User' title='%s'>";
132 /* Assign extension images */
133 $posiximg = "<input type='image' class='center' src='images/select_groups.png'
134 name='group_group_edit_%KEY%' alt='P' title='"._("Posix") ."'>";
135 $mailimg = "<input type='image' class='center' src='images/mailto.png'
136 name='mailgroup_group_edit_%KEY%' alt='M' title='"._("Mail") ."'>";
137 $sambaimg = "<input type='image' class='center' src='images/select_winstation.png'
138 name='group_group_edit_%KEY%' alt='S' title='"._("Samba") ."'>";
139 $applimg = "<input type='image' class='center' src='images/select_application.png'
140 name='appgroup_group_edit_%KEY%' alt='A' title='"._("Application")."'>";
141 $phoneimg = "<input type='image' class='center' src='images/select_phone.png'
142 name='group_group_edit_%KEY%' alt='Ph' title='"._("Phone") ."'>";
143 $envimg = "<input type='image' class='center' src='images/smallenv.png'
144 name='environment_group_edit_%KEY%' alt='E' title='"._("Environment") ."'>";
146 // Space
147 $empty = "<img class='center' src='images/empty.png' style='width:16px;height:16px;' alt=''>";
150 // User and Template Images
151 $editlink = "<a href='?plug=".$_GET['plug']."&id=%s&act=edit_entry'>%s</a>";
153 // Test Every Entry and generate divlist Array
154 foreach($groups as $key => $val){
156 /* Create action icons - copy & paste icons */
157 $actions = $this->GetSnapShotActions($val['dn']);
158 if($this->parent->CopyPasteHandler){
159 $actions.= "<input class='center' type='image'
160 src='images/editcut.png' alt='"._("cut")."' name='cut_%KEY%' title='"._("Cut this entry")."'> ";
161 $actions.= "<input class='center' type='image'
162 src='images/editcopy.png' alt='"._("copy")."' name='copy_%KEY%' title='"._("Copy this entry")."'> ";
163 }
164 $actions.= "<input class='center' type='image'
165 src='images/edit.png' alt='"._("edit")."' name='group_edit_%KEY%' title='"._("Edit this entry")."'>";
166 $actions.= "<input class='center' type='image'
167 src='images/edittrash.png' alt='"._("delete")."' name='group_del_%KEY%' title='"._("Delete this entry")."'>";
170 $posix=$mail=$samba=$appl=$phone=$enviro=$empty;
172 if(isset($val['objectClass'])){
173 if(in_array("posixGroup", $val['objectClass'])) $posix = $posiximg;
174 if(in_array("gosaMailAccount", $val['objectClass'])) $mail = $mailimg;
175 if(in_array("sambaGroupMapping", $val['objectClass'])) $samba = $sambaimg;
176 if(in_array("gosaApplicationGroup", $val['objectClass'])) $appl = $applimg;
177 if(in_array("goFonPickupGroup", $val['objectClass'])) $phone = $phoneimg;
178 if(in_array("gotoEnvironment", $val['objectClass'])) $enviro= $envimg;
179 }
181 $title = "title='".preg_replace('/ /', ' ', @LDAP::fix($val['dn']))."'";
183 if(!isset($val['description'][0])){
184 $desc = "";
185 }else{
186 $desc = " - [ ".$val['description'][0]." ]";
187 }
189 /* FAIrelease tag from groupApplications */
190 if(isset($val['FAIrelease'][0])){
191 $desc .= " (".$val['FAIrelease'][0].")";
192 }
194 $field1 = array("string" => sprintf($userimg,$val['dn']), "attach" => "style='text-align:center;width:20px;'");
195 $field2 = array("string" => sprintf($editlink,$key,($val['cn']['0'].$desc)), "attach" => "style='' ".$title);
196 $field3 = array("string" => preg_replace("/%KEY%/", $key, $posix." ".$enviro." ".$mail." ".$samba." ".$appl." ".$phone), "attach" => "style='width:136px;'");
197 $field4 = array("string" => preg_replace("/%KEY%/", $key, $actions), "attach" => "style='width:110px;border-right:0px;text-align:right;'");
199 $this->AddElement(array($field1,$field2,$field3,$field4));
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 }
213 }
214 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
215 ?>