Code

Fixed missing images problem in group headpage
[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     /* Fill templating stuff */
41     $smarty     = get_smarty();
42     $display = "";
44      /* Magic quotes GPC, escapes every ' " \, to solve some security risks
45      * If we post the escaped strings they will be escaped again
46      */
47     foreach($this->attributes as $attrs){
48       if(get_magic_quotes_gpc()){
49         $smarty->assign($attrs,htmlentities (stripslashes($this->$attrs)));
50       }else{
51         $smarty->assign($attrs,htmlentities (($this->$attrs)));
52       }
53     }
55     $display.= $smarty->fetch(get_template_path('faiVariableEntry.tpl', TRUE));
56     return($display);
57   }
59   /* Save data to object */
60   function save_object()
61   {
62     if(isset($_POST['SubObjectFormSubmitted'])){
63       foreach($this->attributes as $attrs){
64         if(isset($_POST[$attrs])){
65           $this->$attrs = $_POST[$attrs];
66         }else{
67           $this->$attrs = "";
68         }
69       }
70     }
71   }
73   /* Check supplied data */
74   function check()
75   {
76     $message= array();
77     
78     if(empty($this->FAIvariableContent)) {
79       $message[]=_("Please specify a value for the attribute 'content'."); 
80     }
81    
82     if(empty($this->cn)){
83       $message[] = _("Please enter a name.");
84     }
86     return ($message);
87   }
88  
89   function save()
90   {
91     $tmp=array();
92     foreach($this->attributes as $attrs){ 
93       $tmp[$attrs] = stripslashes( $this->$attrs);
94     }
96     if(($this->orig_cn)&&($tmp['cn']!=$this->orig_cn)){
97       $tmp['remove']['from']  = $this->orig_cn;
98       $tmp['remove']['to']    = $tmp['cn'];
99     }
100   
101     $tmp['dn']      = $this->dn;  
102     $tmp['status']  = $this->status;  
103     return($tmp);
104   }
106 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
107 ?>