Code

git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@1522 594d385d-05f5-0310...
[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("Object_cn","Object_description","Object_FAIvariableContent");
13   var $objectclasses= array();
15   var $orig_cn              = "";
16   var $Object_dn            = "";
17   var $Object_cn            = "";
18   var $Object_FAIvariableContent   = "";
19   var $Object_description   = "";
20   var $Object_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 = "Object_".$name;
30         $this->$oname=$value;
31       }
32     }else{
33       $this->Object_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,stripslashes($this->$attrs));
50       }else{
51         $smarty->assign($attrs,($this->$attrs));
52       }
53     }
55     for($i =1 ; $i <= 100 ; $i++){
56       $Object_FAIprioritys[$i]=$i;
57     }
58     $smarty->assign("Object_FAIprioritys",$Object_FAIprioritys);
59     $display.= $smarty->fetch(get_template_path('faiVariableEntry.tpl', TRUE));
60     return($display);
61   }
63   /* Save data to object */
64   function save_object()
65   {
66     if(isset($_POST['SubObjectFormSubmitted'])){
67       foreach($this->attributes as $attrs){
68         if(isset($_POST[$attrs])){
69           $this->$attrs = $_POST[$attrs];
70         }else{
71           $this->$attrs = "";
72         }
73       }
74     }
75   }
77   /* Check supplied data */
78   function check()
79   {
80     $message= array();
81     
82     if(empty($this->Object_FAIvariableContent)) {
83       $message[]=_("Please specify a value for the attribute 'content'."); 
84     }
85    
86     if(empty($this->Object_cn)){
87       $message[] = _("Please enter a name.");
88     }
90     if(preg_match("/[^0-9a-z]/i",$this->Object_cn)){
91       $message[] = _("Please enter a valid name. Only a-Z 0-9 are allowed.");
92     }
93  
94     return ($message);
95   }
96  
97   function save()
98   {
99     $tmp=array();
100     foreach($this->attributes as $attrs){ 
101       $attr = preg_replace("/^Object_/","",$attrs);
102       $tmp[$attr] = $this->$attrs;
103     }
105     if(($this->orig_cn)&&($tmp['cn']!=$this->orig_cn)){
106       $tmp['remove']['from']  = $this->orig_cn;
107       $tmp['remove']['to']    = $tmp['cn'];
108     }
109   
110     $tmp['dn']      = $this->dn;  
111     $tmp['status']  = $this->Object_status;  
112     return($tmp);
113   }
115 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
116 ?>