Code

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