Code

fixed macro plugin image.
[gosa.git] / gosa-plugins / gofon / gofon / macro / class_divListMacros.inc
1 <?php
3 class divListMacro 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 divListMacro (&$config,$parent)
24   {
25     MultiSelectWindow::MultiSelectWindow($config,"Macros", "gofonmacro");
26     
27     $this->parent       = $parent;
28     $this->ui           = get_userinfo();
30     /* Set list strings */
31     $this->SetTitle(_("List of macros"));
32     $this->SetSummary(_("List of macros"));
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")." / "._("Department"), "attach" => "style=''"));
57     $this->AddHeader(array("string" => _("Visible"), "attach" => "style='width:50px;'"));
58     $this->AddHeader(array("string" => _("Actions"), "attach" => "style='width:".$action_col_size."px;border-right:0px;text-align:right;'" ));
60     /* Add Checkboxes / SubSearch checkbox */
61     $this->AddCheckBox("SubSearch",  msgPool::selectToView("","subsearch"), msgPool::selectToView("","subsearch_small"), false);
63     /*                  Name                 ,Text                              ,Default  , Connect with alphabet  */
64     $this->AddRegex   ("Regex",     _("Regular expression for matching macro names"),"*" , true);
65   }
67   function GenHeader()
68   {
69     /* Get all departments within this subtree */
70     $base = $this->config->current['BASE'];
71     $options  = $this->create_department_list($this->module);
73     $ui =get_userinfo();
74     $acl    = $ui->get_permissions($this->selectedBase,"gofonmacro/macro");
75     $acl_all= $ui->has_complete_category_acls($this->selectedBase,"gofonmacro");
77     /* Add default header */
78     $listhead = MultiSelectWindow::get_default_header();
79     $listhead .= _("Base")."&nbsp;<select name='CurrentMainBase' onChange='mainform.submit()' class='center'>$options</select>".
80       " <input class='center' type='image' src='images/lists/submit.png' align='middle' 
81       title='"._("Submit department")."' name='submit_department' alt='"._("Submit")."'>&nbsp;";
82     
83     /* Create Layers menu */
84     $s  = ".|"._("Actions")."|\n";
86     /* Append create options */
87     if(preg_match("/c/",$acl)){
88       $s .= "..|<img src='images/lists/new.png' alt='' border='0' class='center'>".
89         "&nbsp;"._("Create")."|\n";
90       $s.= "...|<input class='center' type='image' src='plugins/gofon/images/list_new_macro.png' alt=''>".
91         "&nbsp;"._("Macro")."|goFonMacro_new|\n";
92       $s.= "..|---|\n";
93     }
95     /* Multiple options */
96     $s.= "..|<img src='images/lists/trash.png' alt='' border='0' class='center'>".
97       "&nbsp;"._("Remove")."|"."remove_multiple|\n";
100     /* Add Copy & Paste header */
101     $s .= $this->parent->get_copypaste_header($this->selectedBase,$this->module);
103     /* Add snapshot icons */
104     $s .= $this->parent->get_snapshot_header($this->selectedBase,$this->module);
106     $this->SetDropDownHeaderMenu($s);
107     $this->SetListHeader($listhead);
108   }
110   function execute()
111   {
112     $this->ClearElementsList();
113     $this->GenHeader();
114   }
116   function setEntries($list)
117   {
118   
119     $empty      = "<img class='center' src='images/nothing.png' style='width:16px;height:16px;' alt=''>";
120     $macroimg   = "<img class='center' src='plugins/gofon/images/list_macro.png' alt='"._("Macro")."' title='%s'>";
121     $visible    = "<img class='center' src='images/true.png' alt='"._("yes")."' title='"._("visible")."'>";
122     $invisible  = "<img class='center' src='images/false.png' alt='"._("no")."'title='"._("invisible")."'>";
123     $editlink   = "<a href='?plug=".$_GET['plug']."&amp;id=%s&amp;act=edit_entry'>%s</a>";
125     /* Dynamic action col, depending on snapshot icons */
126     $action_col_size = 100;
127     if($this->parent->snapshotEnabled()){
128       $action_col_size += 20;
129     }
131     $ui = get_userinfo();
133     foreach($list as $key => $val){
134        
135       $acl    = $ui->get_permissions($val['dn'],"gofonmacro/macro");
136       $acl_all= $ui->has_complete_category_acls($val['dn'],"gofonmacro");
138       $action = "";
139       if(!preg_match("/r/",$acl)){
140         continue;
141       }
143       /* Add copy & cut functionality */
144       $action.= $this->parent->get_copypaste_action($val['dn'],"gofonmacro","macro");
145   
146       $action.= "<input class='center' type='image' src='images/lists/edit.png' alt='"._("edit")."'     
147         name='goFonMacro_edit_%KEY%' title='"._("Edit macro")."'>";
149       /* Add snapshot icon */
150       $action.= $this->parent->get_snapshot_action($val['dn'],$this->module);      
152       if(preg_match("/d/",$acl)){
153         $action.= "<input class='center' type='image' src='images/lists/trash.png' alt='"._("delete")."'   
154           name='goFonMacro_del_%KEY%' title='"._("Delete macro")."'>";
155       }
157       if(isset($val['goFonMacroVisible']['0'])&&($val['goFonMacroVisible']['0'] == "1")){
158         $pic1 = $visible;
159       }else{
160         $pic1 = $invisible;
161       }
163       $display= $val["displayName"][0]."&nbsp;(".$val["cn"][0].")";
164       if(isset($val['description'][0])){
166         $desc = $val['description'][0];
167         if(strlen($desc) > 55){
168           $desc = substr($desc,0,52)."...";
169         }
171         $display .= "&nbsp;[".$desc."]";
172       }
174       /* Cutted objects should be displayed in light grey */
175       if($this->parent->CopyPasteHandler){
176         foreach($this->parent->CopyPasteHandler->queue as $queue_key => $queue_data){
177           if($queue_data['dn'] == $val['dn']) {
178             $display = "<font color='#999999'>".$display."</font>";
179             break;
180           }
181         }
182       }
184       /* Create each field */
185       $field0 = array("string" => "<input type='checkbox' id='item_selected_".$key."' name='item_selected_".$key."'>" ,
186                       "attach" => "style='width:20px;'");
187       $field1 = array("string" => sprintf($macroimg,$val['dn']), "attach" => "style='text-align:center;width:20px;'");
188       $field2 = array("string" => sprintf($editlink,$key,$display), "attach" => "style='' title='".preg_replace('/ /', '&nbsp;', @LDAP::fix($val['dn']))."'");
189       $field3 = array("string" => $pic1, "attach" => "style='width:50px;'");
190       $field4 = array("string" => preg_replace("/%KEY%/", "$key", $action), "attach" => "style='width:".$action_col_size."px;border-right:0px;text-align:right;'");
192       $this->AddElement(array($field0,$field1,$field2,$field3,$field4));
193     }
195     /* Create summary string for list footer */
196     $num_deps=0;
197     if(!$this->SubSearch){
198       $num_deps = count($this->Added_Departments);
199     }
200     $num_objs = count($list);
202     $num_obj_str = sprintf(_("Number of listed %s"),_("macros"));
203     $num_dep_str = sprintf(_("Number of listed %s"),_("departments"));
205     $str = "<img class='center' src='plugins/gofon/images/select_macro.png'
206               title='".$num_obj_str."' alt='".$num_obj_str."'>&nbsp;".$num_objs."&nbsp;&nbsp;&nbsp;&nbsp;";
207     $str.= "<img class='center' src='images/lists/folder.png'
208               title='".$num_dep_str."' alt='".$num_dep_str."'>&nbsp;".$num_deps."&nbsp;&nbsp;&nbsp;&nbsp;";
210     $this->set_List_Bottom_Info($str);
211   }
213   function Save()
214   {
215     MultiSelectWindow :: Save();  
216   }
218   function save_object()
219   {
220     /* Save automatic created POSTs like regex, checkboxes */
221     MultiSelectWindow :: save_object();   
222   }
224 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
225 ?>