1 <?php
4 /*! \brief Displays opsi product properties.
5 */
6 class opsiProperties extends plugin
7 {
8 private $product;
9 private $cfg;
10 private $hostId;
11 public $config;
13 /*! \brief Initializes the class.
14 @param Object The gosa configuration object
15 @param String The product name.
16 @param Array The product config (e.g. aray('attr' => 'value'))
17 @param String The host id if necessary
18 */
19 public function __construct($config,$product,$cfg = array() ,$hostId = "")
20 {
21 $this->config = $config;
22 $this->product = $product;
23 $this->cfg = $cfg;
24 $this->hostId = $hostId;
25 }
28 /*! \brief Display html dialog which allows to
29 configure the properties
30 @return String HTML content
31 */
32 public function execute()
33 {
34 $ui =get_userinfo();
35 $acl = $ui->get_permissions($this->config->current['BASE'],"opsi/opsiProperties","");
36 $smarty = get_smarty();
37 $smarty->assign("ACL",$acl);
38 $smarty->assign("cfg",$this->cfg);
39 $smarty->assign("cfg_count",count($this->cfg));
40 return($smarty->fetch(get_template_path("properties.tpl",TRUE,dirname(__FILE__))));
41 }
44 /*! \brief Save the posted property updates
45 */
46 public function save_object()
47 {
48 $ui =get_userinfo();
49 $acl = $ui->get_permissions($this->config->current['BASE'],"opsi/opsiProperties","");
50 if(preg_match("/w/",$acl)){
51 foreach($this->cfg as $name => $value){
52 if(isset($_POST['value_'.$name])){
53 $this->cfg[$name]['DEFAULT'] = validate(get_post('value_'.$name));
54 }
55 }
56 }
57 }
60 /*! \brief Sets the current config array.
61 */
62 public function set_cfg($cfg)
63 {
64 $this->cfg = $cfg;
65 }
68 /*! \brief Returns the current product config
69 @return Array.
70 */
71 public function get_cfg()
72 {
73 return($this->cfg);
74 }
77 /*! \brief Returns the ID of the product.
78 @param String Product ID
79 */
80 public function get_product()
81 {
82 return($this->product);
83 }
86 /*! \brief Sets the current product ID,
87 The name is only used to remember the currently edited product.
88 */
89 public function set_product($name)
90 {
91 $this->product = $name;
92 }
95 /*! \brief Retuns the hostId.
96 */
97 public function get_hostId()
98 {
99 return($this->hostId);
100 }
103 /* Return plugin informations for acl handling */
104 static function plInfo()
105 {
106 return (array(
107 "plShortName" => _("Products"),
108 "plDescription" => _("Product properties"),
109 "plSelfModify" => FALSE,
110 "plDepends" => array(),
111 "plPriority" => 10,
112 "plSection" => array("administration"),
113 "plCategory" => array("opsi"),
114 "plProvidedAcls"=> array(
115 )
116 ));
117 }
118 }
119 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
120 ?>