Code

Updated css und div framework.
[gosa.git] / plugins / admin / groups / class_divListGroup.inc
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", "groups");
30     
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."));
42   
43     /* Disable buttonsm */
44     $this->EnableCloseButton(false);
45     $this->EnableSaveButton (false);
47     /* Dynamic action col, depending on snapshot icons */
48     $action_col_size = 80;
49     if($this->parent->snapshotEnabled()){
50       $action_col_size += 38;
51     }
53     /* set Page header */
54     $this->AddHeader(array("string"=>"&nbsp;","attach"=>"style='width:20px;'"));
55     $this->AddHeader(array("string"=>_("Groupname / Department")));
56     $this->AddHeader(array("string"=>_("Properties"),"attach"=>"style='width:136px;'"));
57     $this->AddHeader(array("string"=>_("Actions"),"attach"=>"style='width:".$action_col_size."px;border-right:0px;'"));
59     /*                  Text        ,Value    ,Name         ,Is selected */
60     $this->AddCheckBox("ShowPrimaryGroups",     _("Select to see groups that are primary groups of users"),          _("Show primary groups"),      true);
61     $this->AddCheckBox("ShowSambaGroups",       _("Select to see groups that have samba groups mappings"),          _("Show samba groups"),      true);
62     $this->AddCheckBox("ShowApplicationGroups", _("Select to see groups that have applications configured"),        _("Show application groups"),true);
63     $this->AddCheckBox("ShowMailGroups",        _("Select to see groups that have mail settings"),                  _("Show mail groups"),       true);
64     $this->AddCheckBox("ShowFunctionalGroups",  _("Select to see normal groups that have only functional aspects"), _("Show functional groups"), true);
65     $this->AddCheckBox(SEPERATOR);
67     /* Add SubSearch checkbox */    
68     $this->AddCheckBox("SubSearch",  _("Select to search within subtrees"), _("Ignore subtrees"), false);
70     /*                  Name                 ,Text                              ,Default  , Connect with alphabet  */
71     $this->AddRegex   ("Regex",     _("Regular expression for matching group names"), "*" , true);
72     $this->AddRegex   ("UserRegex", _("User name of which groups are shown"),         "*" , false, "images/search_user.png");
73   }
76   function GenHeader()
77   {
78     /* Prepare departments,
79        which are shown in the listbox on top of the listbox
80      */
81     $options= "";
84     
85     /* Get all departments within this subtree */
86     $base = $this->config->current['BASE'];
87     $deps= get_list("(&(|(ou=*)(description=*))(objectClass=gosaDepartment))", $this->module, $base,
88                     array("ou", "description"), GL_SIZELIMIT | GL_SUBSEARCH);
90     /* Load possible departments */
91     $ui= get_userinfo();
92     $tdeps= $ui->get_module_departments("groups");
94     $ids = $this->config->idepartments;
96     foreach($deps as $dep){
97       if(isset($ids[$dep['dn']]) && in_array_ics($dep['dn'], $tdeps)){
99         $value = $ids[$dep['dn']];
100         if ($this->selectedBase == $dep['dn']){
101           $options.= "<option selected='selected' value='".$dep['dn']."'>$value</option>";
102         } else {
103           $options.= "<option value='".$dep['dn']."'>$value</option>";
104         }
105       }
106     }
108     /* Get acls */
109     $acls   = $ui->get_permissions($this->selectedBase,"groups/group");
110     $acl_all= $ui->has_complete_category_acls($this->selectedBase,"groups");
112     /* If this is true add a seperator after added c&p and snapshot icons to header */
113     $addsep = false;
115     /* Get copy & paste icon */
116     $Copy_Paste ="";
117     if(preg_match("/(c.*w|w.*c)/",$acl_all) &&  $this->parent->CopyPasteHandler){
118       $Copy_Paste = $this->parent->CopyPasteHandler->generatePasteIcon();
119       $addsep = true;
120     }
122     /* Add default header */
123     $listhead = MultiSelectWindow::get_default_header();
124     
125     /* Add snapshot restore icon and force a following seperator */
126     if(preg_match("/(c.*w|w.*c)/",$acl_all)){
127       $listhead .= $this->get_snapshot_header($this->selectedBase);
128       $addsep = true;
129     }
131     /* Add Create group icon */
132     if(preg_match("/c/",$acls)) {
133       $listhead.=" <input type='image' class='center' src='images/list_new_group.png' 
134         title='"._("Create new group")."' alt='"._("New")."' name='group_new'>&nbsp;";
135       $addsep = true;
136     }
138     /* Assign copy & paste icons */
139     $listhead.=      $Copy_Paste;
140     
141     /* Append an additional seperator */
142     if($addsep){
143       $listhead.=" <img class='center' src='images/list_seperator.png' alt='' height='16' width='1'>&nbsp;";
144     }
145     
146     /* Add department selection */
147     $listhead .= _("Base")."&nbsp;<select name='CurrentMainBase' onChange='mainform.submit()' class='center'>$options</select>".
148       " <input type='image' class='center' src='images/list_submit.png' title='"._("Submit department")."' name='submit_department' alt='"._("Submit").
149       "'>&nbsp;".
150       "</div>";
152     $this->SetListHeader($listhead);
153   }
155   function execute()
156   {
157     $this->ClearElementsList();
158     $this->GenHeader();
159   }
161   function setEntries($groups)
162   {
163     // Defining Links
164     $linkopen = "<a href='?plug=".$_GET['plug']."&amp;act=dep_open&amp;dep_id=%s'>%s</a>";
166     // image Buttons
167     $editlink = "<a href='?plug=".$_GET['plug']."&amp;id=%s&amp;act=edit_entry'>%s</a>";
168     $userimg  = "<img class='center' src='images/select_groups.png' alt='User'    title='%s'>";
170     /* Dynamic action col, depending on snapshot icons */
171     $action_col_size = 80;
172     if($this->parent->snapshotEnabled()){
173       $action_col_size += 38;
174     }
176     /* Assign extension images */
177     $posiximg = "<input type='image' class='center' src='images/select_groups.png'
178                  name='group_group_edit_%KEY%' alt='P'  title='"._("Posix")  ."'>";
179     $mailimg  = "<input type='image' class='center' src='images/mailto.png'
180                  name='mailgroup_group_edit_%KEY%' alt='M'  title='"._("Mail")   ."'>";
181     $sambaimg = "<input type='image'  class='center' src='images/select_winstation.png'
182                  name='group_group_edit_%KEY%' alt='S'  title='"._("Samba")  ."'>";
183     $applimg  = "<input type='image'  class='center' src='images/select_application.png'
184                  name='appgroup_group_edit_%KEY%' alt='A'  title='"._("Application")."'>";
185     $phoneimg = "<input type='image'  class='center' src='images/select_phone.png'
186                  name='group_group_edit_%KEY%' alt='Ph' title='"._("Phone")  ."'>";
187     $envimg   = "<input type='image'  class='center' src='images/smallenv.png'
188                  name='environment_group_edit_%KEY%' alt='E' title='"._("Environment")  ."'>";
190     // Space
191     $empty    = "<img class='center' src='images/empty.png' style='width:16px;height:16px;' alt=''>";
193     // User and Template  Images
194     $editlink = "<a href='?plug=".$_GET['plug']."&amp;id=%s&amp;act=edit_entry'>%s</a>";
196     $ui = get_userinfo();
198     // Test Every Entry and generate divlist Array
199     foreach($groups as $key => $val){
200     
201       /* Create action icons - copy & paste icons */
202       $acl = $ui->get_permissions($val['dn'],"groups/group");
203       $acl_all= $ui->has_complete_category_acls($val['dn'],"groups");
205       $actions= "";
206       if(($this->parent->CopyPasteHandler) && preg_match("/(c.*w|w.*c)/",$acl_all)){
207         $actions.= "<input class='center' type='image'
208           src='images/editcut.png' alt='"._("cut")."' name='cut_%KEY%' title='"._("Cut this entry")."'>&nbsp;";
209         $actions.= "<input class='center' type='image'
210           src='images/editcopy.png' alt='"._("copy")."' name='copy_%KEY%' title='"._("Copy this entry")."'>&nbsp;";
211       }
213       /* Add edit icon */
214       $actions.= "<input class='center' type='image'
215         src='images/edit.png' alt='"._("edit")."' name='group_edit_%KEY%' title='"._("Edit this entry")."'>";
217       /* Add snapshot functionality */
218       if(preg_match("/(c.*w|w.*c)/", $acl_all)){
219         $actions.= $this->GetSnapShotActions($val['dn']);
220       }
222       if(preg_match("/d/",$acl)){
223         $actions.= "<input class='center' type='image'
224           src='images/edittrash.png' alt='"._("delete")."' name='group_del_%KEY%' title='"._("Delete this entry")."'>";
225       }
228       $posix=$mail=$samba=$appl=$phone=$enviro=$empty;
230       if(isset($val['objectClass'])){
231         if(in_array("posixGroup",           $val['objectClass']))   $posix = $posiximg;
232         if(in_array("gosaMailAccount",      $val['objectClass']))   $mail  = $mailimg;
233         if(in_array("sambaGroupMapping",    $val['objectClass']))   $samba = $sambaimg;
234         if(in_array("gosaApplicationGroup", $val['objectClass']))   $appl  = $applimg;
235         if(in_array("goFonPickupGroup",     $val['objectClass']))   $phone = $phoneimg;
236         if(in_array("gotoEnvironment",      $val['objectClass']))   $enviro= $envimg;
237       }
239       $title = "title='".preg_replace('/ /', '&nbsp;', @LDAP::fix($val['dn']))."'";
241       if(!isset($val['description'][0])){
242         $desc = "";
243       }else{
244         $desc = " - [ ".$val['description'][0]." ]";
245       }
247       /* FAIrelease tag from groupApplications */
248       if(isset($val['FAIrelease'][0])){
249         $desc .= " (".$val['FAIrelease'][0].")";
250       }
252       $field1 = array("string" => sprintf($userimg,$val['dn']), "attach" => "style='text-align:center;width:20px;'");
253       $field2 = array("string" => sprintf($editlink,$key,($val['cn']['0'].$desc)), "attach" => "style='' ".$title);
254       $field3 = array("string" => preg_replace("/%KEY%/", $key, $posix."&nbsp;".$enviro."&nbsp;".$mail."&nbsp;".$samba."&nbsp;".$appl."&nbsp;".$phone),     "attach" => "style='width:136px;'");
255       $field4 = array("string" => preg_replace("/%KEY%/", $key, $actions), "attach" => "style='width:".$action_col_size."px;border-right:0px;text-align:right;'");
257       $this->AddElement(array($field1,$field2,$field3,$field4));
258     }
259   }
261   function Save()
262   {
263     MultiSelectWindow :: Save();  
264   }
266   function save_object()
267   {
268     /* Save automatic created POSTs like regex, checkboxes */
269     MultiSelectWindow::save_object();   
270   }
272 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
273 ?>