Code

e1656f2d1c5d45c734e1ad6d3aaee160ba6752b1
[gosa.git] / plugins / admin / ogroups / class_divListOGroup.inc
1 <?php
3 class divListOGroup extends MultiSelectWindow
4 {
6   /* Current base */
7   var $selectedBase       = "";
8   var $departments        = array();
10   /* Regex */
11   var $Regex              = "*";
13   /* CheckBoxes, to change default values modify $this->AddCheckBox */
14   var $UserGroups         ;
15   var $GroupGroups        ;
16   var $ApplicationGroups  ;
17   var $DepartmentGroups   ; 
18   var $ServerGroups       ;
19   var $WorkstationGroups  ;
20   var $TerminalGroups     ;
21   var $PrinterGroups      ;
22   var $PhoneGroups        ;
23   
25   /* Subsearch checkbox */
26   var $SubSearch          ;
27   var $parent             ;
28   var $ui                 ;
30   function divListOGroup ($config,$parent)
31   {
32     MultiSelectWindow::MultiSelectWindow($config,"OGroups");
33     
34     $this->parent       = $parent;
35     $this->ui           = get_userinfo();
37     /* Set list strings */
38     $this->SetTitle(_("List of object groups"));
39     $this->SetSummary(_("List of object groups"));
40     $this->EnableAplhabet(true);
42     /* Result page will look like a headpage */
43     $this->SetHeadpageMode();
44     $this->SetInformation(_("This menu allows you to add, edit or remove selected groups. ".
45                             "You may want to use the range selector on top of the group listbox, when working with  a large number of groups."));
46   
47     /* Disable buttonsm */
48     $this->EnableCloseButton(false);
49     $this->EnableSaveButton (false);
51     /* set Page header */
52     $this->AddHeader(array("string" => "&nbsp;", "attach" => "style='text-align:center;width:20px;'"));
53     $this->AddHeader(array("string" => _("Name of object groups")." / "._("Departments"), "attach" => "style=''"));
54     $this->AddHeader(array("string" => _("Properties"), "attach" => "style='width:136px;'"));
55     $this->AddHeader(array("string" => _("Actions"), "attach" => "style='width:107px;border-right:0px;text-align:right;'"));
57     /*                  Text        ,Value    ,Name         ,Is selected */
58     $this->AddCheckBox("UserGroups" ,       _("") , _("Show groups containing users"), true);
59     $this->AddCheckBox("GroupGroups" ,      _("") , _("Show groups containing groups"), true);
60     $this->AddCheckBox("ApplicationGroups", _("") , _("Show groups containing applications"), true);
61     $this->AddCheckBox("DepartmentGroups" , _("") , _("Show groups containing departments"), true);
62     $this->AddCheckBox("ServerGroups" ,     _("") , _("Show groups containing servers"), true);
63     $this->AddCheckBox("WorkstationGroups", _("") , _("Show groups containing workstations"), true);
64     $this->AddCheckBox("TerminalGroups" ,   _("") , _("Show groups containing terminals"), true);
65     $this->AddCheckBox("PrinterGroups" ,    _("") , _("Show groups containing printer"), true);
66     $this->AddCheckBox("PhoneGroups" ,      _("") , _("Show groups containing phones"), true);
68     /* Add SubSearch checkbox */    
69     $this->AddCheckBox(SEPERATOR);
70     $this->AddCheckBox("SubSearch",  _("Select to search within subtrees"), _("Ignore subtrees"), false);
72     /*                  Name                 ,Text                              ,Default  , Connect with alphabet  */
73     $this->AddRegex   ("Regex",     _("Regular expression for matching group names"), "*" , true);
74   }
77   function GenHeader()
78   {
79     /* Prepare departments,
80        which are shown in the listbox on top of the listbox
81      */
82     $options= "";
83     foreach ($this->config->idepartments as $key => $value){
84       if ($this->selectedBase == $key){
85         $options.= "<option selected='selected' value='$key'>$value</option>";
86       } else {
87         $options.= "<option value='$key'>$value</option>";
88       }
89     }
91     if($this->parent->CopyPasteHandler){
92       $Copy_Paste = $this->parent->CopyPasteHandler->generatePasteIcon();
93     }else{
94       $Copy_Paste ="";
95     }
97     // Managment
98     $listhead = "<div style='background:#F0F0F9;padding:5px;'>".
99       " <input class='center' type='image' src='images/list_root.png' align='middle' 
100           title='"._("Go to root department")."' name='dep_root' alt='"._("Root")."'>&nbsp;".
101       " <input class='center' type='image' align='middle' src='images/list_back.png' 
102           title='"._("Go up one department")."' alt='"._("Up")."' name='dep_back'>&nbsp;".
103       " <input class='center' type='image' align='middle' src='images/list_home.png' 
104           title='"._("Go to users department")."' alt='"._("Home")."' name='dep_home'>&nbsp;".
105        " <input class='center' type='image' src='images/list_reload.png' align='middle' 
106           title='"._("Reload list")."' name='submit_department' alt='"._("Submit")."'>&nbsp;".
107       " <img class='center' src='images/list_seperator.png' align='middle' alt='' height='16' width='1'>&nbsp;".
108       " <input class='center' type='image' align='middle' src='images/list_new_ogroup.png' 
109           title='"._("Create new object group")."' alt='"._("new")."' name='group_new'>".
110       $Copy_Paste.
111       " <img class='center' src='images/list_seperator.png' align='middle' alt='' height='16' width='1'>&nbsp;".
112       _("Base")."&nbsp;<select name='CurrentMainBase' onChange='mainform.submit()' class='center'>$options</select>".
113       " <input class='center' type='image' src='images/list_submit.png' align='middle' 
114           title='"._("Submit department")."' name='submit_department' alt='"._("Submit")."'>&nbsp;".
115       "</div>";
116   
117     $this->SetListHeader($listhead);
118   }
120   function execute()
121   {
122     $this->ClearElementsList();
123     $this->GenHeader();
124   }
126   function setEntries($list)
127   {
128     /* Add Copy & Paste buttons if copy&paste is enabled
129      */
130     /* Create action icons */
131     $actions = "";
132     if($this->parent->CopyPasteHandler){
133       $actions.= "<input class='center' type='image'
134         src='images/editcut.png' alt='"._("cut")."' name='cut_%KEY%' title='"._("Cut this entry")."'>&nbsp;";
135       $actions.= "<input class='center' type='image'
136         src='images/editcopy.png' alt='"._("copy")."' name='copy_%KEY%' title='"._("Copy this entry")."'>&nbsp;";
137     }
138     $actions.= "<input class='center' type='image'
139       src='images/edit.png' alt='"._("edit")."' name='group_edit_%KEY%' title='"._("Edit this entry")."'>";
140     $actions.= "<input class='center' type='image'
141       src='images/edittrash.png' alt='"._("delete")."' name='group_del_%KEY%' title='"._("Delete this entry")."'>";
143     // Defining Links
144     $linkopen = "<a href='?plug=".$_GET['plug']."&amp;act=dep_open&amp;dep_id=%s'>%s</a>";
145     $editlink = "<a href='?plug=".$_GET['plug']."&amp;id=%s&amp;act=edit_entry'>%s</a>";
146     $userimg  = "<img class='center' src='images/select_groups.png' alt='User'    title='%s'>";
147     $mailimg  = "<img class='center' src='images/mailto.png'             alt='M'  title='"._("Mail")   ."'>";
148     $empty    = "<img class='center' src='images/empty.png' style='width:16px;height:16px;' alt=''>";
150     // Assigning ogroups
151     foreach($list as $key => $val){
153       if(isset($val['mail'])){
154         $mail = $mailimg;
155       }else{
156         $mail = $empty;
157       }
158       $title = "title='dn:&nbsp;".@LDAP::fix($val['dn'])."'";
159       if(!isset($val['description'][0])){
160         $desc = "";
161       }else{
162         $desc = " - [ ".$val['description'][0]." ]";
163       }
164       $field1 = array("string" => "<img src='images/list_ogroup.png' alt='"._("Object group")."' ".$title.">", "attach" => "style='text-align:center;width: 20px;'");
165       $field2 = array("string" => sprintf($editlink,$key,($val['cn']['0'].$desc)), "attach" => "style='' ".$title);
166       $field3 = array("string" => preg_replace("/%KEY/", $key, $this->parent->convert_list($val))."&nbsp;".$mail, "attach" => "style='width:136px;'");
167       $field4 = array("string" => preg_replace("/%KEY%/", $key, $actions), "attach" => "style='width:107px;border-right:0px;text-align:right;'");
169       $this->AddElement(array($field1,$field2,$field3,$field4));
170     }
171   }
173   function Save()
174   {
175     MultiSelectWindow :: Save();  
176   }
178   function save_object()
179   {
180     /* Save automatic created POSTs like regex, checkboxes */
181     MultiSelectWindow::save_object();   
182   }
184 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
185 ?>