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";
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();
75 if(empty($this->Object_FAIvariableContent)) {
76 $message[]=_("Please specify a value for the attribute 'content'.");
77 }
79 if(empty($this->Object_description)){
80 $message[] = _("Please enter a description.");
81 }
83 if(empty($this->Object_cn)){
84 $message[] = _("Please enter a name.");
85 }
87 if(preg_match("/[^0-9a-z]/i",$this->Object_cn)){
88 $message[] = _("Please enter a valid name. Only a-Z 0-9 are allowed.");
89 }
91 return ($message);
92 }
94 function save()
95 {
96 $tmp=array();
97 foreach($this->attributes as $attrs){
98 $attr = preg_replace("/^Object_/","",$attrs);
99 $tmp[$attr] = $this->$attrs;
100 }
102 if(($this->orig_cn)&&($tmp['cn']!=$this->orig_cn)){
103 $tmp['remove']['from'] = $this->orig_cn;
104 $tmp['remove']['to'] = $tmp['cn'];
105 }
107 $tmp['dn'] = $this->dn;
108 $tmp['status'] = $this->Object_status;
109 return($tmp);
110 }
111 }
112 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
113 ?>