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!
31 // Tab definition
32 protected $tabClass = "mimetabs";
33 protected $tabType = "MIMETABS";
34 protected $aclCategory = "mimetypes";
35 protected $aclPlugin = "mimetype";
36 protected $objectName = "mimetype";
38 function __construct($config,$ui)
39 {
40 $this->config = $config;
41 $this->ui = $ui;
43 if($this->IsReleaseManagementActivated()){
44 $this->mime_release = get_ou('mimetypeRDN').$this->config->current['BASE'];
45 $filter_xml = "mimetype-filter-release.xml";
46 $list_xml = "mimetype-list-release.xml";
47 $this->storagePoints= array();
48 }else{
49 $filter_xml = "mimetype-filter.xml";
50 $list_xml = "mimetype-list.xml";
51 $this->storagePoints= array(get_ou("mimetypeRDN"));
52 }
54 # // Build filter
55 # if (session::global_is_set(get_class($this)."_filter")){
56 # $filter= session::global_get(get_class($this)."_filter");
57 # } else {
58 $filter = new filter(get_template_path($filter_xml, true));
59 $filter->setObjectStorage($this->storagePoints);
60 # }
61 $this->setFilter($filter);
63 // Build headpage
64 $headpage = new listing(get_template_path($list_xml, true));
65 $headpage->setFilter($filter);
67 // Add copy&paste and snapshot handler.
68 if ($this->config->boolValueIsTrue("main", "copyPaste")){
69 $this->cpHandler = new CopyPasteHandler($this->config);
70 }
71 if($this->config->get_cfg_value("enableSnapshots") == "true"){
72 $this->snapHandler = new SnapshotHandler($this->config);
73 }
74 parent::__construct($config, $ui, "mimetypes", $headpage);
75 }
77 function renderList()
78 {
79 $filter = $this->getFilter();
80 $headpage = $this->getHeadpage();
81 if($this->IsReleaseManagementActivated()){
82 $filter->setComboBoxOptions("RELEASE",$this->getReleaseList());
84 if(isset($_POST['RELEASE'])){
85 $this->mime_release = get_post('RELEASE');
86 }
87 $headpage->setBase($this->mime_release);
88 }
90 $headpage->update();
91 $display = $headpage->render();
92 return($this->getHeader().$display);
93 }
95 function getReleaseList($base = "", $prefix ="")
96 {
97 $list = array();
98 if(empty($base)){
99 $base = get_ou('mimetypeRDN').$this->config->current['BASE'];
100 $list[$base] = "/";
101 }
103 $ldap = $this->config->get_ldap_link();
104 $ldap->ls("(objectClass=FAIbranch)",$base,array("ou","FAIstate"));
105 while($release = $ldap->fetch()){
106 $list[$release['dn']] = $prefix.$release['ou'][0];
107 $list = array_merge($list,$this->getReleaseList($release['dn'],$prefix." "));
108 }
109 return($list);
110 }
113 function IsReleaseManagementActivated()
114 {
115 /* Check if we should enable the release selection */
116 $tmp = $this->config->search("faiManagement", "CLASS",array('menu','tabs'));
117 if(!empty($tmp)){
118 return(true);
119 }
120 return(false);
121 }
123 }
124 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
125 ?>