Code

Hide tabs frames
[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. You may want to use the range selector on top of the group listbox, when working with  a large number of groups."));
45   
46     /* Disable buttonsm */
47     $this->EnableCloseButton(false);
48     $this->EnableSaveButton (false);
50     /* set Page header */
51     $this->AddHeader(array("string" => "&nbsp;", "attach" => "style='text-align:center;width:20px;'"));
52     $this->AddHeader(array("string" => _("Name of object groups")." / "._("Departments"), "attach" => "style=''"));
53     $this->AddHeader(array("string" => _("Properties"), "attach" => "style='width:136px;'"));
54     $this->AddHeader(array("string" => _("Actions"), "attach" => "style='width:107px;border-right:0px;text-align:right;'"));
56     /*                  Text        ,Value    ,Name         ,Is selected */
57     $this->AddCheckBox("UserGroups" ,       _("Select to see groups containing users")       , _("Show groups containing users"), true);
58     $this->AddCheckBox("GroupGroups" ,      _("Select to see groups containing groups")      , _("Show groups containing groups"), true);
59     $this->AddCheckBox("ApplicationGroups", _("Select to see groups containing applications"), _("Show groups containing applications"), true);
60     $this->AddCheckBox("DepartmentGroups" , _("Select to see groups containing departments") , _("Show groups containing departments"), true);
61     $this->AddCheckBox("ServerGroups" ,     _("Select to see groups containing servers")     , _("Show groups containing servers"), true);
62     $this->AddCheckBox("WorkstationGroups", _("Select to see groups containing workstations"), _("Show groups containing workstations"), true);
63     $this->AddCheckBox("TerminalGroups" ,   _("Select to see groups containing terminals")   , _("Show groups containing terminals"), true);
64     $this->AddCheckBox("PrinterGroups" ,    _("Select to see groups containing printer")     , _("Show groups containing printer"), true);
65     $this->AddCheckBox("PhoneGroups" ,      _("Select to see groups containing phones")      , _("Show groups containing phones"), true);
67     /* Add SubSearch checkbox */    
68     $this->AddCheckBox(SEPERATOR);
69     $this->AddCheckBox("SubSearch",  _("Select to search within subtrees"), _("Search in subtrees"), false);
71     /*                  Name                 ,Text                              ,Default  , Connect with alphabet  */
72     $this->AddRegex   ("Regex",     _("Regular expression for matching group names"), "*" , true);
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     /* Add default header */
97     $listhead = MultiSelectWindow::get_default_header();
98     $listhead.=  " <input class='center' type='image' align='middle' src='images/list_new_ogroup.png' 
99           title='"._("Create new object group")."' alt='"._("new")."' name='group_new'>".
100       $Copy_Paste.
101       " <img class='center' src='images/list_seperator.png' align='middle' alt='' height='16' width='1'>&nbsp;".
102       _("Base")."&nbsp;<select name='CurrentMainBase' onChange='mainform.submit()' class='center'>$options</select>".
103       " <input class='center' type='image' src='images/list_submit.png' align='middle' 
104           title='"._("Submit department")."' name='submit_department' alt='"._("Submit")."'>&nbsp;".
105       "</div>";
106   
107     $this->SetListHeader($listhead);
108   }
110   function execute()
111   {
112     $this->ClearElementsList();
113     $this->GenHeader();
114   }
116   function setEntries($list)
117   {
118     /* Add Copy & Paste buttons if copy&paste is enabled
119      */
120     // Defining Links
121     $linkopen = "<a href='?plug=".$_GET['plug']."&amp;act=dep_open&amp;dep_id=%s'>%s</a>";
122     $editlink = "<a href='?plug=".$_GET['plug']."&amp;id=%s&amp;act=edit_entry'>%s</a>";
123     $userimg  = "<img class='center' src='images/select_groups.png' alt='User'    title='%s'>";
124     $mailimg  = "<img class='center' src='images/mailto.png'             alt='M'  title='"._("Mail")   ."'>";
125     $empty    = "<img class='center' src='images/empty.png' style='width:16px;height:16px;' alt=''>";
127     // Assigning ogroups
128     foreach($list as $key => $val){
130       $acl= get_permissions ($val['dn'], $this->ui->subtreeACL);
131       $acl= get_module_permission($acl, "ogroup", $val['dn']);
132   
133       /* Create action icons */
134       $actions = "";
135       if($this->parent->CopyPasteHandler && $acl == "#all#"){
136         $actions.= "<input class='center' type='image'
137           src='images/editcut.png' alt='"._("cut")."' name='cut_%KEY%' title='"._("Cut this entry")."'>&nbsp;";
138         $actions.= "<input class='center' type='image'
139           src='images/editcopy.png' alt='"._("copy")."' name='copy_%KEY%' title='"._("Copy this entry")."'>&nbsp;";
140       }
141       $actions.= "<input class='center' type='image'
142         src='images/edit.png' alt='"._("edit")."' name='group_edit_%KEY%' title='"._("Edit this entry")."'>";
144       if(chkacl($acl,"delete") == ""){
145         $actions.= "<input class='center' type='image'
146           src='images/edittrash.png' alt='"._("delete")."' name='group_del_%KEY%' title='"._("Delete this entry")."'>";
147       }
149       if(isset($val['mail'])){
150         $mail = $mailimg;
151       }else{
152         $mail = $empty;
153       }
154       $title = "title='".preg_replace('/ /', '&nbsp;', @LDAP::fix($val['dn']))."'";
155       if(!isset($val['description'][0])){
156         $desc = "";
157       }else{
158         $desc = " - [ ".$val['description'][0]." ]";
159       }
161       /* Cutted objects should be displayed in light grey */
162       $display = $val['cn'][0].$desc;
163       if(isset($this->parent->CopyPasteHandler) && $this->parent->CopyPasteHandler->cutCurrent && $val['dn'] == $this->parent->CopyPasteHandler->objectdn){
164         $display = "<font color='#999999'>".$display."</font>";
165       }
167       $field1 = array("string" => "<img src='images/list_ogroup.png' alt='"._("Object group")."' ".$title.">", "attach" => "style='text-align:center;width: 20px;'");
168       $field2 = array("string" => sprintf($editlink,$key,$display), "attach" => "style='' ".$title);
169       $field3 = array("string" => preg_replace("/%KEY/", $key, $this->parent->convert_list($val))."&nbsp;".$mail, "attach" => "style='width:136px;'");
170       $field4 = array("string" => preg_replace("/%KEY%/", $key, $actions), "attach" => "style='width:107px;border-right:0px;text-align:right;'");
172       $this->AddElement(array($field1,$field2,$field3,$field4));
173     }
174    
175  
176     /* Create summary string for list footer */
177     $num_deps=0;
178     if(!$this->SubSearch){
179       $num_deps = count($this->Added_Departments);
180     }
181     $num_objs = count($list);
183     $num_obj_str = _("Number of listed object groups");
184     $num_dep_str = _("Number of listed departments");
186     $str = "<img class='center' src='images/select_ogroup.png'
187               title='".$num_obj_str."' alt='".$num_obj_str."'>&nbsp;".$num_objs."&nbsp;&nbsp;&nbsp;&nbsp;";
188     $str.= "<img class='center' src='images/folder.png'
189               title='".$num_dep_str."' alt='".$num_dep_str."'>&nbsp;".$num_deps."&nbsp;&nbsp;&nbsp;&nbsp;";
191     $this->set_List_Bottom_Info($str);
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 ?>