Code

Enabled license listing
[gosa.git] / gosa-plugins / opsi / admin / opsiLicenses / class_licenseGeneric.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_opsiLicenses.inc 13520 2009-03-09 14:54:13Z 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 */
24 class licenseGeneric extends plugin 
25 {
27   var $si = NULL;
29   function __construct(&$config,$dn, $license)
30   {
31     $this->config = $config;
32     $this->dn = $this->orig_dn = $dn;
33     $this->si = new opsiLicenceHandler($this->config);
35     // Extract pool name out of the fake dn.
36     $this->init();
37   }
39   
40   function init()
41   {
42     // Load local Boot Products 
43     $res = $this->si->get_local_products();
44     if($this->si->is_error()){
45       $this->init_successfull = FALSE;
46       return(FALSE);
47     }
48   }
51   function execute()
52   {
53     // Handle initialization failures.
54     if(isset($_POST['retry_init'])) $this->init();
55     if(!$this->init_successfull){
56       $smarty = get_smarty();
57       $smarty->assign("init_successfull", $this->init_successfull);
58       return($smarty->fetch(get_template_path('licenseGeneric.tpl',TRUE,dirname(__FILE__))));
59     }
61     $smarty = get_smarty();
63     // Assign ACls 
64     $plInfo = $this->plInfo();
65     foreach($plInfo['plProvidedAcls'] as $name => $desc){
66       $smarty->assign("{$name}ACL",$this->getacl($name));
67     }
68     foreach($this->attributes as $attr){
69       $smarty->assign($attr,$this->$attr);
70     }
72     $smarty->assign("init_successfull", $this->init_successfull);
73     $smarty->assign("initially_was_account", $this->initially_was_account);
74     return($smarty->fetch(get_template_path('licenseGeneric.tpl',TRUE,dirname(__FILE__))));
75   }
77  
78   /* Save HTML inputs
79    */
80   function save_object()
81   {
82     if(isset($_POST['opsiLicensesPosted'])){
83       plugin::save_object();  
84     }
85   }  
88   /* Check user input and return a list of 'invalid input' messages.
89    */
90   function check()
91   {
92     $message = plugin::check();
93     return($message);
94   }
95   
97  
98   /* Removes the object from the opsi database
99    */ 
100   function remove_from_parent()
101   {
102   echo "missing remove.";
103 #   $this->si->deletePool($this->orig_cn);
104 #   if($this->si->is_error()){
105 #     msg_dialog::display(_("Error"),msgPool::siError($this->si->get_error()),ERROR_DIALOG);
106 #   }else{
108 #     // Trigger remove signal
109 #     $this->handle_post_events("remove");
110 #   }
112 #   new log("remove","users/".get_class($this),$this->dn,array_keys($this->attrs),$this->si->get_error());
113   }
116   /* Saves object modifications
117    */  
118   function save()
119   {
121     echo "missing save";
122 #   plugin::save();
124 #   // Send modify/add events
125 #   $mode = "modify";
126 #   if($this->orig_dn == "new"){
127 #     $mode = "add";
128 #   }
130 #   $this->si->createPool($this->cn, $this->description,$this->productIds,$this->softwareIds);#
131 #   if($this->si->is_error()){
132 #     msg_dialog::display(_("Error"),msgPool::siError($this->si->get_error()),ERROR_DIALOG);
133 #   }else{
134 #     $this->handle_post_events($mode);
135 #   }
137 #   // Log action
138 #   if($mode == "modify"){
139 #     new log("modify","users/".get_class($this),$this->dn,array_keys($this->attrs),$this->si->get_error());
140 #   }else{
141 #     new log("create","users/".get_class($this),$this->dn,array_keys($this->attrs),$this->si->get_error());
142 #   }
144 #   return 0;
145   }
146  
147   static function plInfo()
148   {
149     return (array(
150           "plShortName"   => _("Generic"),
151           "plDescription" => _("License generic"),
152           "plSelfModify"  => FALSE,
153           "plDepends"     => array(),
154           "plPriority"    => 1,
155           "plSection"     => array("administration"),
156           "plCategory"    => array("opsi"),
157           "plProvidedAcls"=> array(
158             "cn"                => _("Name"),
159             "description" => _("Description"))
160           ));
161   }
165 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
166 ?>