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 */
15 var $ShowPrimaryGroups = true;
16 var $ShowSambaGroups = true;
17 var $ShowApplicationGroups = true;
18 var $ShowMailGroups = true;
19 var $ShowFunctionalGroups = true;
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. ".
42 "You may want to use the range selector on top of the group listbox, when working with a large number of groups."));
44 /* Disable buttonsm */
45 $this->EnableCloseButton(false);
46 $this->EnableSaveButton (false);
48 /* set Page header */
49 $this->AddHeader(array("string"=>" ","attach"=>"style='width:20px;'"));
50 $this->AddHeader(array("string"=>_("Groupname / Department")));
51 $this->AddHeader(array("string"=>_("Properties"),"attach"=>"style='width:136px;'"));
52 $this->AddHeader(array("string"=>_("Actions"),"attach"=>"style='width:80px;border-right:0px;'"));
54 /* Text ,Value ,Name ,Is selected */
55 $this->AddCheckBox("ShowPrimaryGroups", _("Select to see groups that are primary groups of users"), _("Show primary groups"), true);
56 $this->AddCheckBox("ShowSambaGroups", _("Select to see groups that have samba groups mappings"), _("Show samba groups"), true);
57 $this->AddCheckBox("ShowApplicationGroups", _("Select to see groups that have applications configured"), _("Show application groups"),true);
58 $this->AddCheckBox("ShowMailGroups", _("Select to see groups that have mail settings"), _("Show mail groups"), true);
59 $this->AddCheckBox("ShowFunctionalGroups", _("Select to see normal groups that have only functional aspects"), _("Show functional groups"), true);
60 $this->AddCheckBox(SEPERATOR);
62 /* Add SubSearch checkbox */
63 $this->AddCheckBox("SubSearch", _("Select to search within subtrees"), _("Ignore subtrees"), false);
65 /* Name ,Text ,Default , Connect with alphabet */
66 $this->AddRegex ("Regex", _("Regular expression for matching group names"), "*" , true);
67 $this->AddRegex ("UserRegex", _("User name of which groups are shown"), "*" , false, "images/search_user.png");
68 }
71 function GenHeader()
72 {
73 /* Prepare departments,
74 which are shown in the listbox on top of the listbox
75 */
76 $options= "";
77 foreach ($this->config->idepartments as $key => $value){
78 if ($this->selectedBase == $key){
79 $options.= "<option selected='selected' value='$key'>$value</option>";
80 } else {
81 $options.= "<option value='$key'>$value</option>";
82 }
83 }
85 if($this->parent->CopyPasteHandler){
86 $Copy_Paste = $this->parent->CopyPasteHandler->generatePasteIcon();
87 }else{
88 $Copy_Paste ="";
89 }
91 // Managment
92 $listhead = "
93 <div style='background:#F0F0F9;padding:5px;'>".
94 " <input type='image' class='center' src='images/list_root.png' title='"._("Go to root department")."' name='dep_root' alt='"._("Root")."'> ".
95 " <input type='image' class='center' src='images/list_back.png' title='"._("Go up one department")."' alt='"._("Up")."' name='dep_back'> ".
96 " <input type='image' class='center' src='images/list_home.png' title='"._("Go to users department")."' alt='"._("Home")."' name='dep_home'> ".
97 " <input class='center' type='image' src='images/list_reload.png' align='middle' title='"._("Reload list")."' name='submit_department' alt='". _("Submit")."'> ".
98 " <img class='center' src='images/list_seperator.png' alt='' height='16' width='1'> ".
99 " <input type='image' class='center' src='images/list_new_group.png' title='"._("Create new group")."' alt='"._("New")."' name='group_new'> ".
100 $Copy_Paste.
101 " <img class='center' src='images/list_seperator.png' alt='' height='16' width='1'> ".
102 _("Base")." <select name='CurrentMainBase' onChange='mainform.submit()' class='center'>$options</select>".
103 " <input type='image' class='center' src='images/list_submit.png' title='"._("Submit department")."' name='submit_department' alt='"._("Submit").
104 "'> ".
105 "</div>";
107 $this->SetListHeader($listhead);
108 }
110 function execute()
111 {
112 $this->ClearElementsList();
113 $this->GenHeader();
114 }
116 function setEntries($groups)
117 {
118 // Defining Links
119 $linkopen = "<a href='?plug=".$_GET['plug']."&act=dep_open&dep_id=%s'>%s</a>";
121 // image Buttons
122 $editlink = "<a href='?plug=".$_GET['plug']."&id=%s&act=edit_entry'>%s</a>";
123 $userimg = "<img class='center' src='images/select_groups.png' alt='User' title='%s'>";
125 /* Assign extension images */
126 $posiximg = "<input type='image' class='center' src='images/select_groups.png'
127 name='group_group_edit_%KEY%' alt='P' title='"._("Posix") ."'>";
128 $mailimg = "<input type='image' class='center' src='images/mailto.png'
129 name='mailgroup_group_edit_%KEY%' alt='M' title='"._("Mail") ."'>";
130 $sambaimg = "<input type='image' class='center' src='images/select_winstation.png'
131 name='group_group_edit_%KEY%' alt='S' title='"._("Samba") ."'>";
132 $applimg = "<input type='image' class='center' src='images/select_application.png'
133 name='appgroup_group_edit_%KEY%' alt='A' title='"._("Application")."'>";
134 $phoneimg = "<input type='image' class='center' src='images/select_phone.png'
135 name='group_group_edit_%KEY%' alt='Ph' title='"._("Phone") ."'>";
136 $envimg = "<input type='image' class='center' src='images/smallenv.png'
137 name='environment_group_edit_%KEY%' alt='E' title='"._("Environment") ."'>";
139 // Space
140 $empty = "<img class='center' src='images/empty.png' style='width:16px;height:16px;' alt=''>";
142 /* Create action icons - copy & paste icons */
143 $actions = "";
144 if($this->parent->CopyPasteHandler){
145 $actions.= "<input class='center' type='image'
146 src='images/editcut.png' alt='"._("cut")."' name='cut_%KEY%' title='"._("Cut this entry")."'> ";
147 $actions.= "<input class='center' type='image'
148 src='images/editcopy.png' alt='"._("copy")."' name='copy_%KEY%' title='"._("Copy this entry")."'> ";
149 }
150 $actions.= "<input class='center' type='image'
151 src='images/edit.png' alt='"._("edit")."' name='group_edit_%KEY%' title='"._("Edit this entry")."'>";
152 $actions.= "<input class='center' type='image'
153 src='images/edittrash.png' alt='"._("delete")."' name='group_del_%KEY%' title='"._("Delete this entry")."'>";
156 // User and Template Images
157 $editlink = "<a href='?plug=".$_GET['plug']."&id=%s&act=edit_entry'>%s</a>";
159 // Test Every Entry and generate divlist Array
160 foreach($groups as $key => $val){
162 $posix=$mail=$samba=$appl=$phone=$enviro=$empty;
164 if(isset($val['objectClass'])){
165 if(in_array("posixGroup", $val['objectClass'])) $posix = $posiximg;
166 if(in_array("gosaMailAccount", $val['objectClass'])) $mail = $mailimg;
167 if(in_array("sambaGroupMapping", $val['objectClass'])) $samba = $sambaimg;
168 if(in_array("gosaApplicationGroup", $val['objectClass'])) $appl = $applimg;
169 if(in_array("goFonPickupGroup", $val['objectClass'])) $phone = $phoneimg;
170 if(in_array("gotoEnvironment", $val['objectClass'])) $enviro= $envimg;
171 }
173 $title = "title='dn: ".@LDAP::fix($val['dn'])."'";
175 if(!isset($val['description'][0])){
176 $desc = "";
177 }else{
178 $desc = " - [ ".$val['description'][0]." ]";
179 }
181 /* FAIrelease tag from groupApplications */
182 if(isset($val['FAIrelease'][0])){
183 $desc .= " (".$val['FAIrelease'][0].")";
184 }
186 $field1 = array("string" => sprintf($userimg,$val['dn']), "attach" => "style='text-align:center;width:20px;'");
187 $field2 = array("string" => sprintf($editlink,$key,($val['cn']['0'].$desc)), "attach" => "style='' ".$title);
188 $field3 = array("string" => preg_replace("/%KEY%/", $key, $posix." ".$enviro." ".$mail." ".$samba." ".$appl." ".$phone), "attach" => "style='width:136px;'");
189 $field4 = array("string" => preg_replace("/%KEY%/", $key, $actions), "attach" => "style='width:80px;border-right:0px;text-align:right;'");
191 $this->AddElement(array($field1,$field2,$field3,$field4));
192 }
193 }
195 function Save()
196 {
197 MultiSelectWindow :: Save();
198 }
200 function save_object()
201 {
202 /* Save automatic created POSTs like regex, checkboxes */
203 MultiSelectWindow::save_object();
204 }
205 }
206 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
207 ?>