Code

Fixed a set of typos
[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     /* set Page header */
48     $this->AddHeader(array("string"=>"&nbsp;","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:80px;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")."'>&nbsp;".
94       " <input type='image' class='center' src='images/list_back.png' title='"._("Go up one department")."' alt='"._("Up")."' name='dep_back'>&nbsp;".
95       " <input type='image' class='center' src='images/list_home.png' title='"._("Go to users department")."' alt='"._("Home")."' name='dep_home'>&nbsp;".
96       " <input class='center' type='image' src='images/list_reload.png' align='middle' title='"._("Reload list")."' name='submit_department' alt='".        _("Submit")."'>&nbsp;".
97       " <img class='center' src='images/list_seperator.png' alt='' height='16' width='1'>&nbsp;".
98       " <input type='image' class='center' src='images/list_new_group.png' title='"._("Create new group")."' alt='"._("New")."' name='group_new'>&nbsp;".
99       $Copy_Paste.
100       " <img class='center' src='images/list_seperator.png' alt='' height='16' width='1'>&nbsp;".
101       _("Base")."&nbsp;<select name='CurrentMainBase' onChange='mainform.submit()' class='center'>$options</select>".
102        " <input type='image' class='center' src='images/list_submit.png' title='"._("Submit department")."' name='submit_department' alt='"._("Submit").
103 "'>&nbsp;".
104       "</div>";
106     $this->SetListHeader($listhead);
107   }
109   function execute()
110   {
111     $this->ClearElementsList();
112     $this->GenHeader();
113   }
115   function setEntries($groups)
116   {
117     // Defining Links
118     $linkopen = "<a href='?plug=".$_GET['plug']."&amp;act=dep_open&amp;dep_id=%s'>%s</a>";
120     // image Buttons
121     $editlink = "<a href='?plug=".$_GET['plug']."&amp;id=%s&amp;act=edit_entry'>%s</a>";
122     $userimg  = "<img class='center' src='images/select_groups.png' alt='User'    title='%s'>";
124     /* Assign extension images */
125     $posiximg = "<input type='image' class='center' src='images/select_groups.png'
126                  name='group_group_edit_%KEY%' alt='P'  title='"._("Posix")  ."'>";
127     $mailimg  = "<input type='image' class='center' src='images/mailto.png'
128                  name='mailgroup_group_edit_%KEY%' alt='M'  title='"._("Mail")   ."'>";
129     $sambaimg = "<input type='image'  class='center' src='images/select_winstation.png'
130                  name='group_group_edit_%KEY%' alt='S'  title='"._("Samba")  ."'>";
131     $applimg  = "<input type='image'  class='center' src='images/select_application.png'
132                  name='appgroup_group_edit_%KEY%' alt='A'  title='"._("Application")."'>";
133     $phoneimg = "<input type='image'  class='center' src='images/select_phone.png'
134                  name='group_group_edit_%KEY%' alt='Ph' title='"._("Phone")  ."'>";
135     $envimg   = "<input type='image'  class='center' src='images/smallenv.png'
136                  name='environment_group_edit_%KEY%' alt='E' title='"._("Environment")  ."'>";
138     // Space
139     $empty    = "<img class='center' src='images/empty.png' style='width:16px;height:16px;' alt=''>";
141     /* Create action icons - copy & paste icons */
142     $actions = "";
143     if($this->parent->CopyPasteHandler){
144       $actions.= "<input class='center' type='image'
145         src='images/editcut.png' alt='"._("cut")."' name='cut_%KEY%' title='"._("Cut this entry")."'>&nbsp;";
146       $actions.= "<input class='center' type='image'
147         src='images/editcopy.png' alt='"._("copy")."' name='copy_%KEY%' title='"._("Copy this entry")."'>&nbsp;";
148     }
149     $actions.= "<input class='center' type='image'
150       src='images/edit.png' alt='"._("edit")."' name='group_edit_%KEY%' title='"._("Edit this entry")."'>";
151     $actions.= "<input class='center' type='image'
152       src='images/edittrash.png' alt='"._("delete")."' name='group_del_%KEY%' title='"._("Delete this entry")."'>";
155     // User and Template  Images
156     $editlink = "<a href='?plug=".$_GET['plug']."&amp;id=%s&amp;act=edit_entry'>%s</a>";
158     // Test Every Entry and generate divlist Array
159     foreach($groups as $key => $val){
161       $posix=$mail=$samba=$appl=$phone=$enviro=$empty;
163       if(isset($val['objectClass'])){
164         if(in_array("posixGroup",           $val['objectClass']))   $posix = $posiximg;
165         if(in_array("gosaMailAccount",      $val['objectClass']))   $mail  = $mailimg;
166         if(in_array("sambaGroupMapping",    $val['objectClass']))   $samba = $sambaimg;
167         if(in_array("gosaApplicationGroup", $val['objectClass']))   $appl  = $applimg;
168         if(in_array("goFonPickupGroup",     $val['objectClass']))   $phone = $phoneimg;
169         if(in_array("gotoEnvironment",      $val['objectClass']))   $enviro= $envimg;
170       }
172       $title = "title='dn:&nbsp;".@LDAP::fix($val['dn'])."'";
174       if(!isset($val['description'][0])){
175         $desc = "";
176       }else{
177         $desc = " - [ ".$val['description'][0]." ]";
178       }
180       /* FAIrelease tag from groupApplications */
181       if(isset($val['FAIrelease'][0])){
182         $desc .= " (".$val['FAIrelease'][0].")";
183       }
185       $field1 = array("string" => sprintf($userimg,$val['dn']), "attach" => "style='text-align:center;width:20px;'");
186       $field2 = array("string" => sprintf($editlink,$key,($val['cn']['0'].$desc)), "attach" => "style='' ".$title);
187       $field3 = array("string" => preg_replace("/%KEY%/", $key, $posix."&nbsp;".$enviro."&nbsp;".$mail."&nbsp;".$samba."&nbsp;".$appl."&nbsp;".$phone),     "attach" => "style='width:136px;'");
188       $field4 = array("string" => preg_replace("/%KEY%/", $key, $actions), "attach" => "style='width:80px;border-right:0px;text-align:right;'");
190       $this->AddElement(array($field1,$field2,$field3,$field4));
191     }
192   }
194   function Save()
195   {
196     MultiSelectWindow :: Save();  
197   }
199   function save_object()
200   {
201     /* Save automatic created POSTs like regex, checkboxes */
202     MultiSelectWindow::save_object();   
203   }
205 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
206 ?>