Code

fixed macro plugin image.
[gosa.git] / gosa-plugins / gofon / gofon / conference / class_divListConferences.inc
1 <?php
3 class divListConference extends MultiSelectWindow
4 {
6   /* Current base */
7   var $selectedBase       = "";
8   var $departments        = array();
10   /* Regex */
11   var $Regex              = "*";
13   /* checkboxes */
14   var $ShowSendBocklists      ;
15   var $ShowReceiveMacros  ;
17   /* Subsearch checkbox */
18   var $SubSearch;
20   var $parent             ;
21   var $ui                 ;
23   function divListConference (&$config,$parent)
24   {
25     MultiSelectWindow::MultiSelectWindow($config,"Conferences", "gofonconference");
26     
27     $this->parent       = $parent;
28     $this->ui           = get_userinfo();
30     /* Set list strings */
31     $this->SetTitle(_("List of conference rooms"));
32     $this->SetSummary(_("List of conference rooms"));
34     /* Result page will look like a headpage */
35     $this->SetHeadpageMode();
37     $this->EnableAplhabet(true);
38   
39     /* Disable buttonsm */
40     $this->EnableCloseButton(false);
41     $this->EnableSaveButton (false);
43     /* Dynamic action col, depending on snapshot icons */
44     $action_col_size = 100;
45     if($this->parent->snapshotEnabled()){
46       $action_col_size += 20;
47     }
49     /* Toggle all selected / deselected */
50     $chk = "<input type='checkbox' id='select_all' name='select_all' title='"._("Select all")."'
51       onClick='toggle_all_(\"^item_selected_[0-9]*$\",\"select_all\");' >";
53     /* set Page header */
54     $this->AddHeader(array("string"=> $chk,          "attach"=>"style='width:20px;'"));
55     $this->AddHeader(array("string" => "&nbsp;", "attach" => "style='text-align:center;width:20px;'"));
56     $this->AddHeader(array("string" =>_("Name")." - "._("Number"), "attach" => "style=''"));
57     $this->AddHeader(array("string" => _("Owner"), "attach" => "style='width:200px;'"));
58     $this->AddHeader(array("string" => _("PIN"), "attach" => "style='width:50px;'"));
59     $this->AddHeader(array("string" =>_("Actions"), "attach" => "style='width:".$action_col_size."px;border-right:0px;text-align:right;'"));
61     /* Add Checkboxes / SubSearch checkbox */
62     $this->AddCheckBox("SubSearch",  msgPool::selectToView("","subsearch"), msgPool::selectToView("","subsearch_small"), false);
64     /*                  Name                 ,Text                              ,Default  , Connect with alphabet  */
65     $this->AddRegex   ("Regex",      _("Regular expression for matching conference names"),"*" , true);
66   }
69   function GenHeader()
70   {
71     /* Get all departments within this subtree */
72     $base = $this->config->current['BASE'];
73     $options  = $this->create_department_list($this->module);
75     /* Get acls */
76     $acls     = $this->ui->get_permissions($this->selectedBase,"gofonconference/conference");
77     $acl_all  = $this->ui->has_complete_category_acls($this->selectedBase,"gofonconference") ;
79     /* Add default header */
80     $listhead = MultiSelectWindow::get_default_header();
82     /* Add the rest (base select ....)*/
83     $listhead .= _("Base")."&nbsp;<select name='CurrentMainBase' onChange='mainform.submit()' class='center'>$options</select>".
84       " <input class='center' type='image' src='images/lists/submit.png' align='middle' 
85       title='"._("Submit department")."' name='submit_department' alt='".  _("Submit").     "'>&nbsp;";
87     /* Create Layers menu */
88     $s  = ".|"._("Actions")."|\n";
90     /* Append create options */
91     if(preg_match("/(c.*w|w.*c)/",$acl_all)){
92       $s .= "..|<img src='images/lists/new.png' alt='' border='0' class='center'>".
93         "&nbsp;"._("Create")."|\n";
94       $s.= "...|<input class='center' type='image' src='plugins/gofon/images/list_new_conference.png' alt=''>".
95         "&nbsp;"._("Conference")."|conference_new|\n";
96       $s.= "..|---|\n";
97     }
99     /* Multiple options */
100     $s.= "..|<img src='images/lists/trash.png' alt='' border='0' class='center'>".
101       "&nbsp;"._("Remove")."|"."remove_multiple|\n";
103     /* Add Copy & Paste header */
104     $s .= $this->parent->get_copypaste_header($this->selectedBase,$this->module);
106     $s .= $this->parent->get_snapshot_header($this->selectedBase,$this->module);
108     $this->SetDropDownHeaderMenu($s);
109     $this->SetListHeader($listhead);
110   }
112   function execute()
113   {
114     $this->ClearElementsList();
115     $this->GenHeader();
116   }
118   function setEntries($list)
119   {
120     $userimg  = "<img class='center' src='plugins/gofon/images/select_conference.png' alt='User' title='%s'>";
121     $editlink = "<a href='?plug=".$_GET['plug']."&amp;id=%s&amp;act=edit_entry'>%s</a>";
123     /* Dynamic action col, depending on snapshot icons */
124     $action_col_size = 100;
125     if($this->parent->snapshotEnabled()){
126       $action_col_size += 20;
127     }
129     $ui = get_userinfo();
131     /* Insert conferneces*/
132     foreach($list as $conferencekey => $conference ){
134       $acl      = $this->ui->get_permissions($conference['dn'],"gofonconference/conference");
135       $acl_all  = $this->ui->has_complete_category_acls($conference['dn'],"gofonconference");
137       /* You will need at least read access for the 
138           current conference informations to display it */  
139       if(!preg_match("/r/",$acl)){
140         continue;
141       }
143       $actions ="";
145       /* Add copy & cut functionality */
146       $actions.= $this->parent->get_copypaste_action($conference['dn'],"gofonconference","conference");
148       /* Add edit icon - This is allowed when we have at least read access. */
149       $actions.= "<input class='center' type='image' src='images/lists/edit.png'     
150                     alt='"._("edit")."'    name='conference_edit_%KEY%' title='"._("Edit this entry")."'>";
152       /* Add snapshot icon */
153       $actions.= $this->parent->get_snapshot_action($conference['dn'],$this->module);
155       /* Create delete link - Only if we are allowed to delete this entry */
156       if(preg_match("/d/",$acl)){
157         $actions.= "<input class='center' type='image' src='images/lists/trash.png' 
158           alt='"._("delete")."'   name='conference_del_%KEY%'  title='"._("Delete this entry")."'>";
159       }
161       /* Display PIN icon, only if we are the owner of the given conference */
162       $owner = $this->parent->ui->dn==$conference['goFonConferenceOwner'][0];
163       $p_acl = $this->ui->get_permissions($conference['dn'],"gofonconference/conference","goFonPIN");
164       if((isset($conference['goFonPIN'][0])) && $owner && preg_match("/r/",$p_acl)){
165         $pin = "<img class='center' src='plugins/gofon/images/pin.png' title='PIN : ".$conference['goFonPIN'][0]."' alt='PIN'>";
166       }else{
167         $pin = "&nbsp;";
168       }
170       /* Display numer of the conference if we are allowed to view it */
171       $n_acl = $this->ui->get_permissions($conference['dn'],"gofonconference/conference","telephoneNumber");
172       if(isset($conference['telephoneNumber'][0]) && preg_match("/r/",$n_acl)){
173         $number = " - ".$conference['telephoneNumber'][0];
174       }else{
175         $number = "&nbsp; - ?";
176       }
178       /* Get conference owner name */
179       $ldap= $this->parent->config->get_ldap_link();
180       $ldap->cat($conference['goFonConferenceOwner'][0], array('cn'));
181       $data = $ldap->fetch();
182       if(isset($data['cn'][0])){
183         $cn = $data['cn'][0];
184       }else{
185         $cn = _("Unknown"); 
186       }  
188       /* Create title */
189       $title = " title='".preg_replace("/ /","&nbsp;",@LDAP::fix($data['dn']))."' ";
191       /* Cutted objects should be displayed in light grey */
192       $display = $conference['cn'][0].$number;
193       if($this->parent->CopyPasteHandler){
194         foreach($this->parent->CopyPasteHandler->queue as $queue_key => $queue_data){
195           if($queue_data['dn'] == $conference['dn']) {
196             $display = "<font color='#999999'>".$display."</font>";
197             break;
198           }
199         }
200       }
202       /* Create each field */
203       $field0 = array("string" => "<input type='checkbox' id='item_selected_".$conferencekey."' name='item_selected_".$conferencekey."'>" ,
204           "attach" => "style='width:20px;'");
205       $a_field1 = array("string"=>sprintf($userimg,_("Conference")), "attach" => $title." style='text-align:center;width:20px;'");
206       $a_field2 = array("string"=>sprintf($editlink,$conferencekey,$display), "attach" => $title." style=''");
207       $a_field3 = array("string"=> $cn , "attach" =>  $title." style='width:200px;'");
208       $a_field4 = array("string"=> $pin, "attach" =>  $title." style='width:50px;'");
209       $a_field5 = array("string"=> preg_replace("/%KEY%/",$conferencekey,$actions), 
210                         "attach"=> $title."style='width:".$action_col_size."px;border-right:0px;text-align:right;'");
212       $this->AddElement(array($field0,$a_field1,$a_field2,$a_field3,$a_field4,$a_field5));
213     }
215     /* Create summary string for list footer */
216     $num_deps=0;
217     if(!$this->SubSearch){
218       $num_deps = count($this->Added_Departments);
219     }
220     $num_objs = count($list);
222     $num_obj_str = sprintf(_("Number of listed '%s'"),_("conferences"));
223     $num_dep_str = sprintf(_("Number of listed '%s'"),_("departments"));
225     $str = "<img class='center' src='plguins/gofon/images/select_conference.png'
226               title='".$num_obj_str."' alt='".$num_obj_str."'>&nbsp;".$num_objs."&nbsp;&nbsp;&nbsp;&nbsp;";
227     $str.= "<img class='center' src='images/lists/folder.png'
228               title='".$num_dep_str."' alt='".$num_dep_str."'>&nbsp;".$num_deps."&nbsp;&nbsp;&nbsp;&nbsp;";
230     $this->set_List_Bottom_Info($str);
231   }
233   function Save()
234   {
235     MultiSelectWindow :: Save();  
236   }
238   function save_object()
239   {
240     /* Save automatic created POSTs like regex, checkboxes */
241     MultiSelectWindow :: save_object();   
242   }
244 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
245 ?>