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";
22 var $FAIstate = "";
24 function faiVariableEntry ($config, $dn= NULL,$object=false)
25 {
26 plugin::plugin ($config, $dn);
27 if($dn != "new"){
28 $this->orig_cn= $object['cn'];
29 $this->dn=$object['dn'];
30 foreach($object as $name=>$value){
31 $oname = $name;
32 $this->$oname=addslashes($value);
33 }
35 if(isset($this->attrs['FAIstate'][0])){
36 $this->FAIstate = $this->attrs['FAIstate'][0];
37 }
39 }else{
40 $this->status = "new";
41 $this->orig_cn = false;
42 }
43 }
45 function execute()
46 {
47 /* Call parent execute */
48 plugin::execute();
50 /* Fill templating stuff */
51 $smarty = get_smarty();
52 $display = "";
54 /* Magic quotes GPC, escapes every ' " \, to solve some security risks
55 * If we post the escaped strings they will be escaped again
56 */
57 foreach($this->attributes as $attrs){
58 if(get_magic_quotes_gpc()){
59 $smarty->assign($attrs,htmlentities (stripslashes(utf8_decode($this->$attrs))));
60 }else{
61 $smarty->assign($attrs,htmlentities (utf8_decode($this->$attrs)));
62 }
63 }
65 foreach($this->attributes as $attr){
66 if(($this->FAIstate == "freeze") || (chkacl($this->acl,$attr)!= "")){
67 $smarty->assign($attr."ACL"," disabled ");
68 }else{
69 $smarty->assign($attr."ACL"," ");
70 }
71 }
73 $display.= $smarty->fetch(get_template_path('faiVariableEntry.tpl', TRUE));
74 return($display);
75 }
77 /* Save data to object */
78 function save_object()
79 {
80 if((isset($_POST['SubObjectFormSubmitted'])) && ($this->FAIstate != "freeze")){
81 foreach($this->attributes as $attrs){
82 if(isset($_POST[$attrs])){
83 $this->$attrs = $_POST[$attrs];
84 }else{
85 $this->$attrs = "";
86 }
87 }
88 }
89 }
91 /* Check supplied data */
92 function check()
93 {
94 /* Call common method to give check the hook */
95 $message= plugin::check();
97 if(empty($this->FAIvariableContent)) {
98 $message[]=_("Please specify a value for the attribute 'content'.");
99 }
101 if(empty($this->cn)){
102 $message[] = _("Please enter a name.");
103 }
105 return ($message);
106 }
108 function save()
109 {
110 $tmp=array();
111 foreach($this->attributes as $attrs){
112 $tmp[$attrs] = stripslashes( $this->$attrs);
113 }
115 if(($this->orig_cn)&&($tmp['cn']!=$this->orig_cn)){
116 $tmp['remove']['from'] = $this->orig_cn;
117 $tmp['remove']['to'] = $tmp['cn'];
118 }
120 $tmp['dn'] = $this->dn;
121 $tmp['status'] = $this->status;
122 return($tmp);
123 }
124 }
125 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
126 ?>