Code

Updated template
[gosa.git] / gosa-plugins / goto / admin / mimetypes / class_mimetypeManagement.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_mimetypeManagement.inc 14766 2009-11-05 14:30:35Z hickert $$
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 mimetypeManagement extends management
24 {
25   var $plHeadline     = "Mime types";
26   var $plDescription  = "Manage mime types";
27   var $plIcon  = "plugins/goto/images/mimetypes.png";
29   var $mime_release = ""; // The currently selected release while in release management mode!
30   var $mime_base = ""; // The currently selected release while in release management mode!
32   // Tab definition 
33   protected $tabClass = "mimetabs";
34   protected $tabType = "MIMETABS";
35   protected $aclCategory = "mimetypes";
36   protected $aclPlugin   = "mimetype";
37   protected $objectName   = "mimetype";
39   var $releaseSelector = NULL;
41   function __construct($config,$ui)
42   {
43     $this->config = $config;
44     $this->ui = $ui;
45     $this->mime_base = get_ou('mimetypeRDN').$this->config->current['BASE'];
46     $this->mime_release = get_ou('mimetypeRDN').$this->config->current['BASE'];
48     if($this->IsReleaseManagementActivated()){
49       $filter_xml = "mimetype-filter-release.xml";
50       $list_xml   = "mimetype-list-release.xml";
51       $this->storagePoints= array("");
52       $releases = faiManagement::getReleaseStates($this->config,$this->mime_base);
53       $this->releaseSelector = new releaseSelector($releases, $this->mime_release, $this->mime_release);
54     }else{
55       $filter_xml = "mimetype-filter.xml";
56       $list_xml = "mimetype-list.xml";
57       $this->storagePoints= array(get_ou("mimetypeRDN"));
58     }
60     // Build filter
61     if (0 && session::global_is_set(get_class($this)."_filter")){
62       $filter= session::global_get(get_class($this)."_filter");
63     } else {
64       $filter = new filter(get_template_path($filter_xml, true));
65       $filter->setObjectStorage($this->storagePoints);
66     }
67     $this->setFilter($filter);
69     // Build headpage
70     $headpage = new listing(get_template_path($list_xml, true));
71     $headpage->setFilter($filter);
73     // Add copy&paste and snapshot handler.
74     if ($this->config->boolValueIsTrue("main", "copyPaste")){
75       $this->cpHandler = new CopyPasteHandler($this->config);
76     }
77     if($this->config->get_cfg_value("enableSnapshots") == "true"){
78       $this->snapHandler = new SnapshotHandler($this->config);
79     }
80     parent::__construct($config, $ui, "mimetypes", $headpage);
81   }
83  
84   /*! \brief   Overridden render method of class mangement.
85    *            this allows us to add a release selection box.
86    */
87   function renderList()
88   {
89     $smarty = get_smarty();
90     $filter = $this->getFilter();
91     $headpage = $this->getHeadpage();
93     // Display release selector
94     if($this->IsReleaseManagementActivated()){
95       $this->releaseSelector->update();
96       $this->mime_release = $this->releaseSelector->getBase();
97       $headpage->setBase($this->mime_release);
98       $smarty->assign("RELEASE", $this->releaseSelector->render());
99     }
101     $headpage->update();
102     $display = $headpage->render();
103     return($this->getHeader().$display);
104   }
105  
107   /*! \brief  This method opens an existing object or a list of existing objects to be edited.
108    *
109    *
110    *  @param  String  'action'  The name of the action which was the used as trigger.
111    *  @param  Array   'target'  A list of object dns, which should be affected by this method.
112    *  @param  Array   'all'     A combination of both 'action' and 'target'.
113    */
114   function editEntry($action="",$target=array(),$all=array(), $altTabClass ="", $altTabType = "", $altAclCategory="")
115   {
116     management::editEntry($action,$target,$all,$altTabClass,$altTabType,$altAclCategory);
117     if($this->tabObject){
118       if(isset($this->tabObject->by_object['mimetype']->attrs['FAIstate'][0])){
119         $state = $this->tabObject->by_object['mimetype']->attrs['FAIstate'][0];
120         $this->tabObject->setReadOnly(preg_match("/freeze/i", $state));
121       }
122     }
123   }
125   
126   /*! \brief   Someone wants to remove some object(s)
127    *            ask for a confirmation now.
128    */
129   function removeEntryRequested($action="",$target=array(),$all=array(),
130       $altTabClass ="", $altTabType = "",             $altAclCategory="")
131   {
132     // Close dialogs and remove locks for currently handled dns
133     $this->cancelEdit();
135     // Do not allow to remove objects with state freeezed
136     $errors = $disallowed = array();
137     $headpage = $this->getHeadpage();
138     foreach($target as $dn){
140       $obj = $headpage->getEntry($dn);
141       $acl  = $this->ui->get_permissions($obj['dn'],"mimetypes/mimetype");
142       if(!preg_match("/d/",$acl)){
143         $disallowed[] = $obj['dn'];
144       }elseif(isset($obj['FAIstate']) && preg_match('/freeze/i', $obj['FAIstate'][0])){
145         $errors[] = $obj['dn'];
146       }else{
147         $this->dns[] = $obj['dn'];
148       }
149     }
150     if(count($errors)){
151       msg_dialog::display(_("Branch locked"),
152           sprintf(_("The following entries are locked, you can't remove them %s."),
153             msgPool::buildList($errors)),INFO_DIALOG);
154     }
155     if(count($disallowed)){
156       msg_dialog::display(_("Permission error"), msgPool::permDelete($disallowed), ERROR_DIALOG);
157     }
158     return(management::removeEntryRequested($action, $this->dns));
159   }
162   function IsReleaseManagementActivated()
163   {
164     /* Check if we should enable the release selection */
165     $tmp = $this->config->search("faiManagement", "CLASS",array('menu','tabs'));
166     if(!empty($tmp)){
167       return(true);
168     }
169     return(false);
170   }
172
173 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
174 ?>