1 <?php
2 class logonManagementDialog extends plugin
3 {
4 var $pathTitle = "Logon scripts";
6 /* attribute list for save action */
7 var $ignore_account = TRUE;
8 var $attributes = array("LogonName","LogonPriority","LogonLast","LogonOverload","LogonData","LogonDescription");
9 var $objectclasses = array("whatever");
10 var $use_existing = false;
12 var $LogonName =""; // Name for the LogonScript
13 var $LogonPriority =""; // Priority defines the order in which the scripts will be processed
14 var $LogonLast =""; // Is this script marked as the last, all following scripts will be skipped
15 var $LogonOverload =""; // If Overload is activated this script is overlaodable by a group script with same prio
16 var $LogonData =""; // The script itself
17 var $LogonDescription ="";
19 var $nameIsEditable = true;
21 var $real_LogonName = "";
23 function logonManagementDialog (&$config, $dn= NULL,$data=false)
24 {
25 plugin::plugin ($config, $dn);
27 if($data){
28 $this->LogonName = $data['LogonName'];
29 $this->LogonPriority = $data['LogonPriority'];
30 $this->LogonOverload = $data['LogonOverload'];
31 $this->LogonLast = $data['LogonLast'];
32 $this->LogonData = $data['LogonData'];
33 $this->LogonDescription = $data['LogonDescription'];
34 $this->nameIsEditable = false;
35 $this->real_LogonName = $data['LogonName'];
36 }
37 }
39 function execute()
40 {
41 /* Call parent execute */
42 plugin::execute();
44 $smarty= get_smarty();
45 $display= "";
47 if((isset($_POST['StartImport']))&&(isset($_FILES['importFile']))){
48 $this->LogonData = file_get_contents($_FILES['importFile']['tmp_name']);
49 @unlink($_FILES['importFile']['tmp_name']);
50 }
52 foreach($this->attributes as $attr){
53 $smarty->assign($attr,$this->$attr);
54 if($this->$attr){
55 $smarty->assign($attr."CHK"," checked ");
56 }else{
57 $smarty->assign($attr."CHK","");
58 }
59 }
60 $prios=array(1,2,3,4,5,6,7,8,9,10);
61 $smarty->assign("LogonPrioritys",$prios);
62 $smarty->assign("LogonPriorityKeys",$prios);
64 if(!$this->nameIsEditable){
65 $smarty->assign("LogonNameACL"," disabled ");
66 }else{
67 $smarty->assign("LogonNameACL","");
68 }
71 $display.= $smarty->fetch(get_template_path('logonManagement.tpl', TRUE,dirname(__FILE__)));
72 return($display);
73 }
75 function save_object()
76 {
77 if(isset($_POST['dialogissubmitted'])){
78 foreach($this->attributes as $attr){
80 if(!$this->nameIsEditable && $attr == 'LogonName'){
81 continue;
82 }
83 if(isset($_POST[$attr])){
84 $this->$attr = stripslashes($_POST[$attr]);
85 }
86 }
88 foreach(array("LogonLast","LogonOverload") as $checkBoxes){
89 if(isset($_POST[$checkBoxes])){
90 $this->$checkBoxes = stripslashes($_POST[$checkBoxes]);
91 }else{
92 $this->$checkBoxes = "";
93 }
95 }
96 }
97 }
99 function check()
100 {
101 /* Call common method to give check the hook */
102 $message= plugin::check();
104 if(preg_match("/[^a-zA-Z]/",$this->LogonName)){
105 $message[] = msgPool::invalid(_("Name"),$this->LogonName,"/[a-zA-Z]/");
106 }
108 if(empty($this->LogonName)){
109 $message[] = msgPool::required(_("Script name"));
110 }
112 if(preg_match("/[^a-z0-9,\.-;:_\(\)!\? ]/i",$this->LogonDescription)){
113 $message[] = msgPool::required(_("Description"),$this->LogonDescription,"/[a-z0-9,\.-;:_\(\)!\? ]/i");
114 }
116 return $message;
117 }
120 function save()
121 {
122 $a_return= array();
123 foreach($this->attributes as $attr){
124 $a_return[$attr]=$this->$attr;
125 }
127 if(!$this->nameIsEditable){
128 $a_return['LogonName']=$this->real_LogonName;
129 }
131 return($a_return);
132 }
134 }
135 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
136 ?>