Code

Added execute methods
[gosa.git] / plugins / admin / fai / class_faiVariableEntry.inc
1 <?php
3 class faiVariableEntry extends plugin
4 {
5   /* CLI vars */
6   var $cli_summary= "Manage server basic objects";
7   var $cli_description= "Some longer text\nfor help";
8   var $cli_parameters= array("eins" => "Eins ist toll", "zwei" => "Zwei ist noch besser");
10   /* attribute list for save action */
11   var $ignore_account= TRUE;
12   var $attributes   = array("cn","description","FAIvariableContent");
13   var $objectclasses= array();
15   var $orig_cn              = "";
16   var $dn            = "";
17   var $cn            = "";
18   var $FAIvariableContent   = "";
19   var $description   = "";
20   var $status        = "new";
21   
22   function faiVariableEntry ($config, $dn= NULL,$object=false)
23   {
24     plugin::plugin ($config, $dn);
25     if($dn != "new"){
26       $this->orig_cn= $object['cn'];
27       $this->dn=$object['dn'];
28       foreach($object as $name=>$value){
29         $oname = $name;
30         $this->$oname=addslashes($value);
31       }
32     }else{
33       $this->status = "new";
34       $this->orig_cn       = false;
35     }
36   }
38   function execute()
39   {
40         /* Call parent execute */
41         plugin::execute();
42     /* Fill templating stuff */
43     $smarty     = get_smarty();
44     $display = "";
46      /* Magic quotes GPC, escapes every ' " \, to solve some security risks
47      * If we post the escaped strings they will be escaped again
48      */
49     foreach($this->attributes as $attrs){
50       if(get_magic_quotes_gpc()){
51         $smarty->assign($attrs,htmlentities (stripslashes($this->$attrs)));
52       }else{
53         $smarty->assign($attrs,htmlentities (($this->$attrs)));
54       }
55     }
57     $display.= $smarty->fetch(get_template_path('faiVariableEntry.tpl', TRUE));
58     return($display);
59   }
61   /* Save data to object */
62   function save_object()
63   {
64     if(isset($_POST['SubObjectFormSubmitted'])){
65       foreach($this->attributes as $attrs){
66         if(isset($_POST[$attrs])){
67           $this->$attrs = $_POST[$attrs];
68         }else{
69           $this->$attrs = "";
70         }
71       }
72     }
73   }
75   /* Check supplied data */
76   function check()
77   {
78     $message= array();
79     
80     if(empty($this->FAIvariableContent)) {
81       $message[]=_("Please specify a value for the attribute 'content'."); 
82     }
83    
84     if(empty($this->cn)){
85       $message[] = _("Please enter a name.");
86     }
88     return ($message);
89   }
90  
91   function save()
92   {
93     $tmp=array();
94     foreach($this->attributes as $attrs){ 
95       $tmp[$attrs] = stripslashes( $this->$attrs);
96     }
98     if(($this->orig_cn)&&($tmp['cn']!=$this->orig_cn)){
99       $tmp['remove']['from']  = $this->orig_cn;
100       $tmp['remove']['to']    = $tmp['cn'];
101     }
102   
103     $tmp['dn']      = $this->dn;  
104     $tmp['status']  = $this->status;  
105     return($tmp);
106   }
108 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
109 ?>