Code

e3bf0ca57f3d4a32e58751e5dcd0ac4d27ce47b8
[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 = 70;
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 copy & paste icon */
109     if(preg_match("/w/",$ui->get_permissions($this->selectedBase,"groups/group")) &&  $this->parent->CopyPasteHandler){
110       $Copy_Paste = $this->parent->CopyPasteHandler->generatePasteIcon();
111     }else{
112       $Copy_Paste ="";
113     }
115     // Managment
116     $listhead = "
117       <div style='background:#F0F0F9;padding:5px;'>".
118       " <input type='image' class='center' src='images/list_root.png' title='"._("Go to root department")."' name='dep_root' alt='"._("Root")."'>&nbsp;".
119       " <input type='image' class='center' src='images/list_back.png' title='"._("Go up one department")."' alt='"._("Up")."' name='dep_back'>&nbsp;".
120       " <input type='image' class='center' src='images/list_home.png' title='"._("Go to users department")."' alt='"._("Home")."' name='dep_home'>&nbsp;".
121       " <input class='center' type='image' src='images/list_reload.png' align='middle' title='"._("Reload list")."' name='submit_department' alt='".        _("Submit")."'>&nbsp;".
122       " <img class='center' src='images/list_seperator.png' alt='' height='16' width='1'>&nbsp;";
123     $listhead .= $this->get_snapshot_header($this->selectedBase);
125     $acls  = $ui->get_permissions($this->selectedBase,"groups/group");
126     if(preg_match("/c/",$acls)) {
127       $listhead.=" <input type='image' class='center' src='images/list_new_group.png' 
128         title='"._("Create new group")."' alt='"._("New")."' name='group_new'>&nbsp;";
129     }
131     $listhead.=      $Copy_Paste.
132       " <img class='center' src='images/list_seperator.png' alt='' height='16' width='1'>&nbsp;".
133       _("Base")."&nbsp;<select name='CurrentMainBase' onChange='mainform.submit()' class='center'>$options</select>".
134       " <input type='image' class='center' src='images/list_submit.png' title='"._("Submit department")."' name='submit_department' alt='"._("Submit").
135       "'>&nbsp;".
136       "</div>";
138     $this->SetListHeader($listhead);
139   }
141   function execute()
142   {
143     $this->ClearElementsList();
144     $this->GenHeader();
145   }
147   function setEntries($groups)
148   {
149     // Defining Links
150     $linkopen = "<a href='?plug=".$_GET['plug']."&amp;act=dep_open&amp;dep_id=%s'>%s</a>";
152     // image Buttons
153     $editlink = "<a href='?plug=".$_GET['plug']."&amp;id=%s&amp;act=edit_entry'>%s</a>";
154     $userimg  = "<img class='center' src='images/select_groups.png' alt='User'    title='%s'>";
156     /* Dynamic action col, depending on snapshot icons */
157     $action_col_size = 70;
158     if($this->parent->snapshotEnabled()){
159       $action_col_size += 38;
160     }
162     /* Assign extension images */
163     $posiximg = "<input type='image' class='center' src='images/select_groups.png'
164                  name='group_group_edit_%KEY%' alt='P'  title='"._("Posix")  ."'>";
165     $mailimg  = "<input type='image' class='center' src='images/mailto.png'
166                  name='mailgroup_group_edit_%KEY%' alt='M'  title='"._("Mail")   ."'>";
167     $sambaimg = "<input type='image'  class='center' src='images/select_winstation.png'
168                  name='group_group_edit_%KEY%' alt='S'  title='"._("Samba")  ."'>";
169     $applimg  = "<input type='image'  class='center' src='images/select_application.png'
170                  name='appgroup_group_edit_%KEY%' alt='A'  title='"._("Application")."'>";
171     $phoneimg = "<input type='image'  class='center' src='images/select_phone.png'
172                  name='group_group_edit_%KEY%' alt='Ph' title='"._("Phone")  ."'>";
173     $envimg   = "<input type='image'  class='center' src='images/smallenv.png'
174                  name='environment_group_edit_%KEY%' alt='E' title='"._("Environment")  ."'>";
176     // Space
177     $empty    = "<img class='center' src='images/empty.png' style='width:16px;height:16px;' alt=''>";
179     // User and Template  Images
180     $editlink = "<a href='?plug=".$_GET['plug']."&amp;id=%s&amp;act=edit_entry'>%s</a>";
182     $ui = get_userinfo();
184     // Test Every Entry and generate divlist Array
185     foreach($groups as $key => $val){
186     
187       /* Create action icons - copy & paste icons */
188       $actions= "";
189       if(($this->parent->CopyPasteHandler) && preg_match("/w/",$ui->get_category_permissions($val['dn'],"group"))){
190         $actions.= "<input class='center' type='image'
191           src='images/editcut.png' alt='"._("cut")."' name='cut_%KEY%' title='"._("Cut this entry")."'>&nbsp;";
192         $actions.= "<input class='center' type='image'
193           src='images/editcopy.png' alt='"._("copy")."' name='copy_%KEY%' title='"._("Copy this entry")."'>&nbsp;";
194       }
196       if(preg_match("/r/",$ui->get_category_permissions($val['dn'],"groups"))){
197         $actions.= "<input class='center' type='image'
198           src='images/edit.png' alt='"._("edit")."' name='group_edit_%KEY%' title='"._("Edit this entry")."'>";
199       }
201       $actions.= $this->GetSnapShotActions($val['dn']);
203       if(preg_match("/d/",$ui->get_permissions($val['dn'],"groups/group"))){
204         $actions.= "<input class='center' type='image'
205           src='images/edittrash.png' alt='"._("delete")."' name='group_del_%KEY%' title='"._("Delete this entry")."'>";
206       }
209       $posix=$mail=$samba=$appl=$phone=$enviro=$empty;
211       if(isset($val['objectClass'])){
212         if(in_array("posixGroup",           $val['objectClass']))   $posix = $posiximg;
213         if(in_array("gosaMailAccount",      $val['objectClass']))   $mail  = $mailimg;
214         if(in_array("sambaGroupMapping",    $val['objectClass']))   $samba = $sambaimg;
215         if(in_array("gosaApplicationGroup", $val['objectClass']))   $appl  = $applimg;
216         if(in_array("goFonPickupGroup",     $val['objectClass']))   $phone = $phoneimg;
217         if(in_array("gotoEnvironment",      $val['objectClass']))   $enviro= $envimg;
218       }
220       $title = "title='".preg_replace('/ /', '&nbsp;', @LDAP::fix($val['dn']))."'";
222       if(!isset($val['description'][0])){
223         $desc = "";
224       }else{
225         $desc = " - [ ".$val['description'][0]." ]";
226       }
228       /* FAIrelease tag from groupApplications */
229       if(isset($val['FAIrelease'][0])){
230         $desc .= " (".$val['FAIrelease'][0].")";
231       }
233       $field1 = array("string" => sprintf($userimg,$val['dn']), "attach" => "style='text-align:center;width:20px;'");
234       $field2 = array("string" => sprintf($editlink,$key,($val['cn']['0'].$desc)), "attach" => "style='' ".$title);
235       $field3 = array("string" => preg_replace("/%KEY%/", $key, $posix."&nbsp;".$enviro."&nbsp;".$mail."&nbsp;".$samba."&nbsp;".$appl."&nbsp;".$phone),     "attach" => "style='width:136px;'");
236       $field4 = array("string" => preg_replace("/%KEY%/", $key, $actions), "attach" => "style='width:".$action_col_size."px;border-right:0px;text-align:right;'");
238       $this->AddElement(array($field1,$field2,$field3,$field4));
239     }
240   }
242   function Save()
243   {
244     MultiSelectWindow :: Save();  
245   }
247   function save_object()
248   {
249     /* Save automatic created POSTs like regex, checkboxes */
250     MultiSelectWindow::save_object();   
251   }
253 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
254 ?>