Code

Some changes
[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     foreach($this->attributes as $attrs){
45       $smarty->assign($attrs,stripslashes($this->$attrs));
46     }
48     for($i =1 ; $i <= 100 ; $i++){
49       $Object_FAIprioritys[$i]=$i;
50     }
51     $smarty->assign("Object_FAIprioritys",$Object_FAIprioritys);
52     $display.= $smarty->fetch(get_template_path('faiVariableEntry.tpl', TRUE));
53     return($display);
54   }
56   /* Save data to object */
57   function save_object()
58   {
59     if(isset($_POST['SubObjectFormSubmitted'])){
60       foreach($this->attributes as $attrs){
61         if(isset($_POST[$attrs])){
62           $this->$attrs = $_POST[$attrs];
63         }else{
64           $this->$attrs = "";
65         }
66       }
67     }
68   }
70   /* Check supplied data */
71   function check()
72   {
73     $message= array();
74     
75     if(empty($this->Object_FAIvariableContent)) {
76       $message[]=_("Please specify a value for the attribute 'content'."); 
77     }
78    
79     if(empty($this->Object_cn)){
80       $message[] = _("Please enter a name.");
81     }
83     if(preg_match("/[^0-9a-z]/i",$this->Object_cn)){
84       $message[] = _("Please enter a valid name. Only a-Z 0-9 are allowed.");
85     }
86  
87     return ($message);
88   }
89  
90   function save()
91   {
92     $tmp=array();
93     foreach($this->attributes as $attrs){ 
94       $attr = preg_replace("/^Object_/","",$attrs);
95       $tmp[$attr] = $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->Object_status;  
105     return($tmp);
106   }
108 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
109 ?>