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 ="";
17 var $nameIsEditable = true;
19 var $real_LogonName = "";
21 function logonManagementDialog ($config, $dn= NULL,$data=false)
22 {
23 plugin::plugin ($config, $dn);
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 }
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){
77 if(!$this->nameIsEditable && $attr == "LogonName"){
78 continue;
79 }
80 if(isset($_POST[$attr])){
81 $this->$attr = stripslashes($_POST[$attr]);
82 }else{
83 $this->$attr = false;
84 }
85 }
86 }
87 }
89 function check()
90 {
91 /* Call common method to give check the hook */
92 $message= plugin::check();
94 if(preg_match("/[^a-zA-Z]/",$this->LogonName)){
95 $message[] = _("Specified name should only consist of uper-/lowercase characters.");
96 }
98 if(empty($this->LogonName)){
99 $message[] = _("Please specify a valid script name.");
100 }
102 if(preg_match("/[^a-z0-9,\.-;:_\(\)!\? ]/i",$this->LogonDescription)){
103 $message[] = _("Specified description contains invalid characters.");
104 }
106 return $message;
107 }
110 function save()
111 {
112 $a_return= array();
113 foreach($this->attributes as $attr){
114 $a_return[$attr]=$this->$attr;
115 }
117 if(!$this->nameIsEditable){
118 $a_return['LogonName']=$this->real_LogonName;
119 }
121 return($a_return);
122 }
124 }
125 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
126 ?>