1 <?php
4 /*! \brief Displays opsi product properties.
5 */
6 class opsiProperties extends plugin
7 {
8 private $product;
9 private $cfg;
10 private $hostId;
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 $smarty = get_smarty();
35 $smarty->assign("cfg",$this->cfg);
36 $smarty->assign("cfg_count",count($this->cfg));
37 return($smarty->fetch(get_template_path("properties.tpl",TRUE,dirname(__FILE__))));
38 }
41 /*! \brief Save the posted property updates
42 */
43 public function save_object()
44 {
45 foreach($this->cfg as $name => $value){
46 if(isset($_POST['value_'.$name])){
47 $this->cfg[$name]['DEFAULT'] = validate(get_post('value_'.$name));
48 }
49 }
50 }
53 /*! \brief Sets the current config array.
54 */
55 public function set_cfg($cfg)
56 {
57 $this->cfg = $cfg;
58 }
61 /*! \brief Returns the current product config
62 @return Array.
63 */
64 public function get_cfg()
65 {
66 return($this->cfg);
67 }
70 /*! \brief Returns the ID of the product.
71 @param String Product ID
72 */
73 public function get_product()
74 {
75 return($this->product);
76 }
79 /*! \brief Sets the current product ID,
80 The name is only used to remember the currently edited product.
81 */
82 public function set_product($name)
83 {
84 $this->product = $name;
85 }
88 /*! \brief Retuns the hostId.
89 */
90 public function get_hostId()
91 {
92 return($this->hostId);
93 }
94 }
95 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
96 ?>