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 $str = utf8_encode("üöä");
76 if(empty($this->Object_FAIvariableContent)) {
77 $message[]=_("Please specify a value for the attribute 'content'.");
78 }
80 if(empty($this->Object_description)){
81 $message[] = _("Please enter a description.");
82 }
84 if(preg_match("/[^a-z0-9".$str."\.,;:\-_\? ]/i",$this->Object_description)){
85 $message[] = _("Invalid character in description. Please enter a valid description.");
86 }
88 if(empty($this->Object_cn)){
89 $message[] = _("Please enter a name.");
90 }
92 if(preg_match("/[^0-9a-z]/i",$this->Object_cn)){
93 $message[] = _("Please enter a valid name. Only a-Z 0-9 are allowed.");
94 }
96 return ($message);
97 }
99 function save()
100 {
101 $tmp=array();
102 foreach($this->attributes as $attrs){
103 $attr = preg_replace("/^Object_/","",$attrs);
104 $tmp[$attr] = $this->$attrs;
105 }
107 if(($this->orig_cn)&&($tmp['cn']!=$this->orig_cn)){
108 $tmp['remove']['from'] = $this->orig_cn;
109 $tmp['remove']['to'] = $tmp['cn'];
110 }
112 $tmp['dn'] = $this->dn;
113 $tmp['status'] = $this->Object_status;
114 return($tmp);
115 }
116 }
117 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
118 ?>