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 plugin::execute();
35 $ui =get_userinfo();
36 $acl = $ui->get_permissions($this->config->current['BASE'],"opsi/opsiProperties","");
37 $smarty = get_smarty();
38 $smarty->assign("ACL",$acl);
39 $smarty->assign("cfg",$this->cfg);
40 $smarty->assign("cfg_count",count($this->cfg));
41 return($smarty->fetch(get_template_path("properties.tpl",TRUE,dirname(__FILE__))));
42 }
45 /*! \brief Save the posted property updates
46 */
47 public function save_object()
48 {
49 $ui =get_userinfo();
50 $acl = $ui->get_permissions($this->config->current['BASE'],"opsi/opsiProperties","");
51 if(preg_match("/w/",$acl)){
52 foreach($this->cfg as $name => $value){
53 if(isset($_POST['value_'.$name])){
54 $this->cfg[$name]['CURRENT'] = validate(get_post('value_'.$name));
55 }
56 }
57 }
58 }
61 /*! \brief Sets the current config array.
62 */
63 public function set_cfg($cfg)
64 {
65 $this->cfg = $cfg;
66 }
69 /*! \brief Returns the current product config
70 @return Array.
71 */
72 public function get_cfg()
73 {
74 return($this->cfg);
75 }
78 /*! \brief Returns the ID of the product.
79 @param String Product ID
80 */
81 public function get_product()
82 {
83 return($this->product);
84 }
87 /*! \brief Sets the current product ID,
88 The name is only used to remember the currently edited product.
89 */
90 public function set_product($name)
91 {
92 $this->product = $name;
93 }
96 /*! \brief Retuns the hostId.
97 */
98 public function get_hostId()
99 {
100 return($this->hostId);
101 }
104 /* Return plugin informations for acl handling */
105 static function plInfo()
106 {
107 return (array(
108 "plShortName" => _("Products"),
109 "plDescription" => _("Product properties"),
110 "plSelfModify" => FALSE,
111 "plDepends" => array(),
112 "plPriority" => 10,
113 "plSection" => array("administration"),
114 "plCategory" => array("opsi"),
115 "plProvidedAcls"=> array(
116 )
117 ));
118 }
119 }
120 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
121 ?>