Code

Removed CLI
[gosa.git] / gosa-plugins / goto / personal / environment / class_logonManagementDialog.inc
1 <?php
2 class logonManagementDialog extends plugin
3 {
4   /* attribute list for save action */
5   var $ignore_account       = TRUE;
6   var $attributes           = array("LogonName","LogonPriority","LogonLast","LogonOverload","LogonData","LogonDescription");
7   var $objectclasses        = array("whatever");
8   var $use_existing         = false;  
10   var $LogonName        ="";  // Name for the LogonScript
11   var $LogonPriority    ="";  // Priority defines the order in which the scripts will be processed 
12   var $LogonLast        ="";  // Is this script marked as the last, all following scripts will be skipped
13   var $LogonOverload    ="";  // If Overload is activated this script is overlaodable by a group script with same prio
14   var $LogonData        ="";  // The script itself
15   var $LogonDescription ="";
16     
17   var $nameIsEditable = true;
19   var $real_LogonName = "";
21   function logonManagementDialog (&$config, $dn= NULL,$data=false)
22   {
23     plugin::plugin ($config, $dn);
24     
25     if($data){
26       $this->LogonName        = $data['LogonName'];
27       $this->LogonPriority    = $data['LogonPriority'];
28       $this->LogonOverload    = $data['LogonOverload'];
29       $this->LogonLast        = $data['LogonLast'];
30       $this->LogonData        = $data['LogonData'];
31       $this->LogonDescription = $data['LogonDescription'];
32       $this->nameIsEditable   = false;
33       $this->real_LogonName   = $data['LogonName'];
34     }
35   }
37   function execute()
38   {
39         /* Call parent execute */
40         plugin::execute();
42     $smarty= get_smarty();
43     $display= "";
45     if((isset($_POST['StartImport']))&&(isset($_FILES['importFile']))){
46       $this->LogonData = file_get_contents($_FILES['importFile']['tmp_name']);
47       @unlink($_FILES['importFile']['tmp_name']);
48     }
50     foreach($this->attributes as $attr){
51       $smarty->assign($attr,$this->$attr);
52       if($this->$attr){
53         $smarty->assign($attr."CHK"," checked ");
54       }else{
55         $smarty->assign($attr."CHK","");
56       }
57     }
58     $prios=array(1,2,3,4,5,6,7,8,9,10);
59     $smarty->assign("LogonPrioritys",$prios);
60     $smarty->assign("LogonPriorityKeys",$prios);
62     if(!$this->nameIsEditable){
63       $smarty->assign("LogonNameACL"," disabled ");
64     }else{
65       $smarty->assign("LogonNameACL","");
66     }
67   
69     $display.= $smarty->fetch(get_template_path('logonManagement.tpl', TRUE,dirname(__FILE__)));
70     return($display);
71   }
73   function save_object()
74   {
75     if(isset($_POST['dialogissubmitted'])){
76       foreach($this->attributes as $attr){
78         if(!$this->nameIsEditable && $attr == 'LogonName'){
79           continue;
80         }
81         if(isset($_POST[$attr])){
82           $this->$attr = stripslashes($_POST[$attr]); 
83         }
84       }
86       foreach(array("LogonLast","LogonOverload") as $checkBoxes){
87         if(isset($_POST[$checkBoxes])){
88           $this->$checkBoxes = stripslashes($_POST[$checkBoxes]);
89         }else{
90           $this->$checkBoxes = "";
91         }
93       }
94     }
95   }
97   function check()
98   {
99     /* Call common method to give check the hook */
100     $message= plugin::check();
101   
102     if(preg_match("/[^a-zA-Z]/",$this->LogonName)){
103       $message[] = _("Specified name should only consist of upper-/lowercase characters.");
104     }
106     if(empty($this->LogonName)){
107       $message[] = _("Please specify a valid script name.");
108     }
110     if(preg_match("/[^a-z0-9,\.-;:_\(\)!\? ]/i",$this->LogonDescription)){
111       $message[] = _("Specified description contains invalid characters.");
112     }
114     return $message;
115   }
118   function save()
119   {
120     $a_return= array();
121     foreach($this->attributes as $attr){
122       $a_return[$attr]=$this->$attr;
123     }  
125     if(!$this->nameIsEditable){
126       $a_return['LogonName']=$this->real_LogonName;
127     }
129     return($a_return); 
130   }
133 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
134 ?>