Code

Only show date selector while dates are writeable
[gosa.git] / gosa-plugins / opsi / admin / opsiLicenses / class_divListLicenses.inc
1 <?php
2 /*
3  * This code is part of GOsa (http://www.gosa-project.org)
4  * Copyright (C) 2003-2008 GONICUS GmbH
5  *
6  * ID: $$Id: class_divListLicense.inc 12852 2008-10-31 16:19:40Z cajus $$
7  *
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; either version 2 of the License, or
11  * (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program; if not, write to the Free Software
20  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
21  */
23 class divListLicense extends MultiSelectWindow
24 {
26   // Current base 
27   var $selectedBase       = "";
28   var $departments        = array();
30   // Regex 
31   var $Regex              = "*";
33   // Subsearch checkbox 
34   var $SubSearch          ;
35   var $parent             ;
36   var $ui                 ;
38   function divListLicense (&$config,$parent)
39   {
40     MultiSelectWindow::MultiSelectWindow($config, "opsi", "licenseGeneric");
41     
42     $this->parent       = $parent;
43     $this->ui           = get_userinfo();
45     // Dynamic action col, depending on snapshot icons 
46     $action_col_size = 90;
47     if($this->parent->snapshotEnabled()){
48       $action_col_size += 38;
49     }
51     // Set list strings 
52     $this->SetTitle(_("List of license pools"));
53     $this->SetSummary(_("List of license pools"));
54     $this->EnableAplhabet(true);
56     // Result page will look like a headpage 
57     $this->SetHeadpageMode();
58   
59     // Disable buttonsm 
60     $this->EnableCloseButton(false);
61     $this->EnableSaveButton (false);
63     // Add checkbox: Toggle all selected / deselected 
64     $chk = "<input type='checkbox' id='select_all' name='select_all' title='"._("Select all")."'
65                onClick='toggle_all_(\"^item_selected_[0-9]*$\",\"select_all\");' >";
67     // Set Page col headers 
68     $this->AddHeader(array("string" => $chk,"attach"=>"style='width:20px;'"));
69     $this->AddHeader(array("string" => "&nbsp;", "attach" => "style='text-align:center;width:20px;'"));
70     $this->AddHeader(array("string" => _("License pools"), "attach" => "style=''"));
71     $this->AddHeader(array("string" => _("Actions"), 
72           "attach" => "style='width:".$action_col_size."px;border-right:0px;text-align:right;'"));
74     // Add regex user input field
75     $this->AddRegex   ("Regex", _("Regular expression for matching license pools"), "*" , true);
76   }
79   function GenHeader()
80   {
81     /* Get all departments within this subtree */
82     $ui= get_userinfo();
83     $first = "";
84     $found = FALSE;
85     $base = $this->config->current['BASE'];
86     $options  = $this->create_department_list($this->module);
88     /* Get copy & paste icon */
89     $acls  = $ui->get_permissions($this->selectedBase,"opsi/licenseGeneric");
90     $acl_all= $ui->has_complete_category_acls($this->selectedBase,"opsi");
92     /* Add default header */
93     $listhead = MultiSelectWindow::get_default_header(false);
94   
95     /* Create Layers menu */
96     $s  = ".|"._("Actions")."|\n";
98     /* Append create options */
99     if(preg_match("/c/",$acls)) {
100       $s .= "..|<img src='images/lists/new.png' alt='' border='0' class='center'>".
101         "&nbsp;"._("Create")."|\n";
102       $s.= "...|<input class='center' type='image' src='plugins/opsiLicenses/images/new.png' alt=''>".
103         "&nbsp;"._("License")."|license_new|\n";
104     }
106     /* Multiple options */
107     $s.= "..|---|\n";
108     $s.= "..|<img src='images/lists/trash.png' alt='' border='0' class='center'>".
109       "&nbsp;"._("Remove")."|"."remove_multiple_licenses|\n";
111     $this->SetDropDownHeaderMenu($s);
112     $this->SetListHeader($listhead);
113   }
116   function execute()
117   {
118     $this->ClearElementsList();
119     $this->GenHeader();
120   }
122   function setEntries($list)
123   {
124     // Defining Links
125     $editlink = "<a href='?plug=".$_GET['plug']."&amp;id=%s&amp;act=edit_entry'>%s</a>";
127     // Dynamic action col, depending on snapshot icons 
128     $action_col_size = 90;
129     if($this->parent->snapshotEnabled()){
130       $action_col_size += 38;
131     }
132   
133     $ui = get_userinfo();
135     // Assigning licenses
136     foreach($list as $key => $val){
137      
138       // Get object permissions
139       $acl    = $ui->get_permissions($val['dn'],"opsi/licenseGeneric");
140       $acl_all= $ui->has_complete_category_acls($val['dn'],"opsi");
142       // Create edit and remove icon buttons
143       $actions = "<input class='center' type='image'
144         src='images/lists/edit.png' alt='"._("edit")."' 
145         name='license_edit_%KEY%' title='"._("Edit this entry")."'>";
146       if(preg_match("/d/",$acl)){
147         $actions.= "<input class='center' type='image'
148           src='images/lists/trash.png' alt='"._("delete")."' 
149           name='license_del_%KEY%' title='"._("Delete this entry")."'>";
150       }else{
151         $actions.= "<img class='center' src='images/empty.png' alt='&nbsp;'
152           title='".msgPool::permDelete()."'>";
153       }
156       // Append license descriptio, if available
157       $title = "title='".preg_replace('/ /', '&nbsp;', LDAP::fix($val['dn']))."'";
158       if(!isset($val['description'][0])){
159         $desc = "";
160       }else{
161         $desc = " - [ ".$val['description'][0]." ]";
162       }
163       $display = $val['cn'][0].$desc;
165       // Append the entry to the divlist
166       $field0 = array("string" => "<input type='checkbox' id='item_selected_".$key."' 
167           name='item_selected_".$key."'>" ,
168           "attach" => "style='width:20px;'");
169       $field1 = array("string" => "<img src='plugins/opsi/images/license.png' 
170           alt='"._("License")."' ".$title.">", 
171           "attach" => "style='text-align:center;width: 20px;'");
172       $field2 = array("string" => sprintf($editlink,$key,$display), 
173           "attach" => "style='' ".$title);
174       $field4 = array("string" => preg_replace("/%KEY%/", $key, $actions), 
175           "attach" => "style='width:".$action_col_size."px;border-right:0px;text-align:right;'");
177       $this->AddElement(array($field0,$field1,$field2,$field4));
178     }
179    
180     // Create the list summary 
181     $num_deps=0;
182     if(!$this->SubSearch){
183       $num_deps = count($this->Added_Departments);
184     }
185     $num_objs = count($list);
186     $num_obj_str = _("Number of listed license pools");
187     $str = "<img class='center' src='plugins/opsi/images/license.png'
188               title='".$num_obj_str."' alt='".$num_obj_str."'>&nbsp;".$num_objs."&nbsp;&nbsp;&nbsp;&nbsp;";
189     $this->set_List_Bottom_Info($str);
190   }
192 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
193 ?>