Code

Merged icons for save/restore
[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");
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= "";
82     foreach ($this->config->idepartments as $key => $value){
83       if ($this->selectedBase == $key){
84         $options.= "<option selected='selected' value='$key'>$value</option>";
85       } else {
86         $options.= "<option value='$key'>$value</option>";
87       }
88     }
90     if($this->parent->CopyPasteHandler){
91       $Copy_Paste = $this->parent->CopyPasteHandler->generatePasteIcon();
92     }else{
93       $Copy_Paste ="";
94     }
96     // Managment
97     $listhead = "
98       <div style='background:#F0F0F9;padding:5px;'>".
99       " <input type='image' class='center' src='images/list_root.png' title='"._("Go to root department")."' name='dep_root' alt='"._("Root")."'>&nbsp;".
100       " <input type='image' class='center' src='images/list_back.png' title='"._("Go up one department")."' alt='"._("Up")."' name='dep_back'>&nbsp;".
101       " <input type='image' class='center' src='images/list_home.png' title='"._("Go to users department")."' alt='"._("Home")."' name='dep_home'>&nbsp;".
102       " <input class='center' type='image' src='images/list_reload.png' align='middle' title='"._("Reload list")."' name='submit_department' alt='".        _("Submit")."'>&nbsp;".
103       " <img class='center' src='images/list_seperator.png' alt='' height='16' width='1'>&nbsp;";
106     if($this->parent->snapshotEnabled()){
107       $listhead .= "  <input class='center' type='image' align='middle' src='images/restore.png'
108         title='"._("Restore snapshopts of already deleted objects")."' alt='"._("Restore")."' name='RestoreDeletedSnapShot'>".
109         " <img class='center' src='images/list_seperator.png' align='middle' alt='' height='16' width='1'>&nbsp;";
110     }
112     $listhead.=" <input type='image' class='center' src='images/list_new_group.png' title='"._("Create new group")."' alt='"._("New")."' name='group_new'>&nbsp;".
113       $Copy_Paste.
114       " <img class='center' src='images/list_seperator.png' alt='' height='16' width='1'>&nbsp;".
115       _("Base")."&nbsp;<select name='CurrentMainBase' onChange='mainform.submit()' class='center'>$options</select>".
116       " <input type='image' class='center' src='images/list_submit.png' title='"._("Submit department")."' name='submit_department' alt='"._("Submit").
117       "'>&nbsp;".
118       "</div>";
120     $this->SetListHeader($listhead);
121   }
123   function execute()
124   {
125     $this->ClearElementsList();
126     $this->GenHeader();
127   }
129   function setEntries($groups)
130   {
131     // Defining Links
132     $linkopen = "<a href='?plug=".$_GET['plug']."&amp;act=dep_open&amp;dep_id=%s'>%s</a>";
134     // image Buttons
135     $editlink = "<a href='?plug=".$_GET['plug']."&amp;id=%s&amp;act=edit_entry'>%s</a>";
136     $userimg  = "<img class='center' src='images/select_groups.png' alt='User'    title='%s'>";
138     /* Dynamic action col, depending on snapshot icons */
139     $action_col_size = 70;
140     if($this->parent->snapshotEnabled()){
141       $action_col_size += 38;
142     }
144     /* Assign extension images */
145     $posiximg = "<input type='image' class='center' src='images/select_groups.png'
146                  name='group_group_edit_%KEY%' alt='P'  title='"._("Posix")  ."'>";
147     $mailimg  = "<input type='image' class='center' src='images/mailto.png'
148                  name='mailgroup_group_edit_%KEY%' alt='M'  title='"._("Mail")   ."'>";
149     $sambaimg = "<input type='image'  class='center' src='images/select_winstation.png'
150                  name='group_group_edit_%KEY%' alt='S'  title='"._("Samba")  ."'>";
151     $applimg  = "<input type='image'  class='center' src='images/select_application.png'
152                  name='appgroup_group_edit_%KEY%' alt='A'  title='"._("Application")."'>";
153     $phoneimg = "<input type='image'  class='center' src='images/select_phone.png'
154                  name='group_group_edit_%KEY%' alt='Ph' title='"._("Phone")  ."'>";
155     $envimg   = "<input type='image'  class='center' src='images/smallenv.png'
156                  name='environment_group_edit_%KEY%' alt='E' title='"._("Environment")  ."'>";
158     // Space
159     $empty    = "<img class='center' src='images/empty.png' style='width:16px;height:16px;' alt=''>";
161     // User and Template  Images
162     $editlink = "<a href='?plug=".$_GET['plug']."&amp;id=%s&amp;act=edit_entry'>%s</a>";
164     // Test Every Entry and generate divlist Array
165     foreach($groups as $key => $val){
166     
167       /* Create action icons - copy & paste icons */
168       $actions= "";
169       if($this->parent->CopyPasteHandler){
170         $actions.= "<input class='center' type='image'
171           src='images/editcut.png' alt='"._("cut")."' name='cut_%KEY%' title='"._("Cut this entry")."'>&nbsp;";
172         $actions.= "<input class='center' type='image'
173           src='images/editcopy.png' alt='"._("copy")."' name='copy_%KEY%' title='"._("Copy this entry")."'>&nbsp;";
174       }
175       $actions.= "<input class='center' type='image'
176         src='images/edit.png' alt='"._("edit")."' name='group_edit_%KEY%' title='"._("Edit this entry")."'>";
177       $actions.= $this->GetSnapShotActions($val['dn']);
178       $actions.= "<input class='center' type='image'
179         src='images/edittrash.png' alt='"._("delete")."' name='group_del_%KEY%' title='"._("Delete this entry")."'>";
182       $posix=$mail=$samba=$appl=$phone=$enviro=$empty;
184       if(isset($val['objectClass'])){
185         if(in_array("posixGroup",           $val['objectClass']))   $posix = $posiximg;
186         if(in_array("gosaMailAccount",      $val['objectClass']))   $mail  = $mailimg;
187         if(in_array("sambaGroupMapping",    $val['objectClass']))   $samba = $sambaimg;
188         if(in_array("gosaApplicationGroup", $val['objectClass']))   $appl  = $applimg;
189         if(in_array("goFonPickupGroup",     $val['objectClass']))   $phone = $phoneimg;
190         if(in_array("gotoEnvironment",      $val['objectClass']))   $enviro= $envimg;
191       }
193       $title = "title='".preg_replace('/ /', '&nbsp;', @LDAP::fix($val['dn']))."'";
195       if(!isset($val['description'][0])){
196         $desc = "";
197       }else{
198         $desc = " - [ ".$val['description'][0]." ]";
199       }
201       /* FAIrelease tag from groupApplications */
202       if(isset($val['FAIrelease'][0])){
203         $desc .= " (".$val['FAIrelease'][0].")";
204       }
206       $field1 = array("string" => sprintf($userimg,$val['dn']), "attach" => "style='text-align:center;width:20px;'");
207       $field2 = array("string" => sprintf($editlink,$key,($val['cn']['0'].$desc)), "attach" => "style='' ".$title);
208       $field3 = array("string" => preg_replace("/%KEY%/", $key, $posix."&nbsp;".$enviro."&nbsp;".$mail."&nbsp;".$samba."&nbsp;".$appl."&nbsp;".$phone),     "attach" => "style='width:136px;'");
209       $field4 = array("string" => preg_replace("/%KEY%/", $key, $actions), "attach" => "style='width:".$action_col_size."px;border-right:0px;text-align:right;'");
211       $this->AddElement(array($field1,$field2,$field3,$field4));
212     }
213   }
215   function Save()
216   {
217     MultiSelectWindow :: Save();  
218   }
220   function save_object()
221   {
222     /* Save automatic created POSTs like regex, checkboxes */
223     MultiSelectWindow::save_object();   
224   }
226 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
227 ?>