Code

Added a first set of reference changes - nearly untested
[gosa.git] / plugins / personal / environment / class_logonManagementDialog.inc
1 <?php
2 class logonManagementDialog extends plugin
3 {
4   /* CLI vars */
5   var $cli_summary          = "Manage server basic objects";
6   var $cli_description      = "Some longer text\nfor help";
7   var $cli_parameters       = array("eins" => "Eins ist toll", "zwei" => "Zwei ist noch besser");
9   /* attribute list for save action */
10   var $ignore_account       = TRUE;
11   var $attributes           = array("LogonName","LogonPriority","LogonLast","LogonOverload","LogonData","LogonDescription");
12   var $objectclasses        = array("whatever");
13   var $use_existing         = false;  
15   var $LogonName        ="";  // Name for the LogonScript
16   var $LogonPriority    ="";  // Priority defines the order in which the scripts will be processed 
17   var $LogonLast        ="";  // Is this script marked as the last, all following scripts will be skipped
18   var $LogonOverload    ="";  // If Overload is activated this script is overlaodable by a group script with same prio
19   var $LogonData        ="";  // The script itself
20   var $LogonDescription ="";
21     
22   var $nameIsEditable = true;
24   var $real_LogonName = "";
26   function logonManagementDialog (&$config, $dn= NULL,$data=false)
27   {
28     plugin::plugin ($config, $dn);
29     
30     if($data){
31       $this->LogonName        = $data['LogonName'];
32       $this->LogonPriority    = $data['LogonPriority'];
33       $this->LogonOverload    = $data['LogonOverload'];
34       $this->LogonLast        = $data['LogonLast'];
35       $this->LogonData        = $data['LogonData'];
36       $this->LogonDescription = $data['LogonDescription'];
37       $this->nameIsEditable   = false;
38       $this->real_LogonName   = $data['LogonName'];
39     }
40   }
42   function execute()
43   {
44         /* Call parent execute */
45         plugin::execute();
47     $smarty= get_smarty();
48     $display= "";
50     if((isset($_POST['StartImport']))&&(isset($_FILES['importFile']))){
51       $this->LogonData = file_get_contents($_FILES['importFile']['tmp_name']);
52       @unlink($_FILES['importFile']['tmp_name']);
53     }
55     foreach($this->attributes as $attr){
56       $smarty->assign($attr,$this->$attr);
57       if($this->$attr){
58         $smarty->assign($attr."CHK"," checked ");
59       }else{
60         $smarty->assign($attr."CHK","");
61       }
62     }
63     $prios=array(1,2,3,4,5,6,7,8,9,10);
64     $smarty->assign("LogonPrioritys",$prios);
65     $smarty->assign("LogonPriorityKeys",$prios);
67     if(!$this->nameIsEditable){
68       $smarty->assign("LogonNameACL"," disabled ");
69     }else{
70       $smarty->assign("LogonNameACL","");
71     }
72   
74     $display.= $smarty->fetch(get_template_path('logonManagement.tpl', TRUE,dirname(__FILE__)));
75     return($display);
76   }
78   function save_object()
79   {
80     if(isset($_POST['dialogissubmitted'])){
81       foreach($this->attributes as $attr){
83         if(!$this->nameIsEditable && $attr == 'LogonName'){
84           continue;
85         }
86         if(isset($_POST[$attr])){
87           $this->$attr = stripslashes($_POST[$attr]); 
88         }
89       }
91       foreach(array("LogonLast","LogonOverload") as $checkBoxes){
92         if(isset($_POST[$checkBoxes])){
93           $this->$checkBoxes = stripslashes($_POST[$checkBoxes]);
94         }else{
95           $this->$checkBoxes = "";
96         }
98       }
99     }
100   }
102   function check()
103   {
104     /* Call common method to give check the hook */
105     $message= plugin::check();
106   
107     if(preg_match("/[^a-zA-Z]/",$this->LogonName)){
108       $message[] = _("Specified name should only consist of upper-/lowercase characters.");
109     }
111     if(empty($this->LogonName)){
112       $message[] = _("Please specify a valid script name.");
113     }
115     if(preg_match("/[^a-z0-9,\.-;:_\(\)!\? ]/i",$this->LogonDescription)){
116       $message[] = _("Specified description contains invalid characters.");
117     }
119     return $message;
120   }
123   function save()
124   {
125     $a_return= array();
126     foreach($this->attributes as $attr){
127       $a_return[$attr]=$this->$attr;
128     }  
130     if(!$this->nameIsEditable){
131       $a_return['LogonName']=$this->real_LogonName;
132     }
134     return($a_return); 
135   }
138 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
139 ?>