4b8c48ce06648326d8dcec5f3eaec86af87cbd2f
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 $filename = gosa_file_name($_FILES['importFile']['tmp_name']);
49 $this->LogonData = file_get_contents($filename);
50 @unlink($filename);
51 }
53 foreach($this->attributes as $attr){
54 $smarty->assign($attr,$this->$attr);
55 if($this->$attr){
56 $smarty->assign($attr."CHK"," checked ");
57 }else{
58 $smarty->assign($attr."CHK","");
59 }
60 }
61 $prios=array(1,2,3,4,5,6,7,8,9,10);
62 $smarty->assign("LogonPrioritys",$prios);
63 $smarty->assign("LogonPriorityKeys",$prios);
65 if(!$this->nameIsEditable){
66 $smarty->assign("LogonNameACL"," disabled ");
67 }else{
68 $smarty->assign("LogonNameACL","");
69 }
72 $display.= $smarty->fetch(get_template_path('logonManagement.tpl', TRUE,dirname(__FILE__)));
73 return($display);
74 }
76 function save_object()
77 {
78 if(isset($_POST['dialogissubmitted'])){
79 foreach($this->attributes as $attr){
81 if(!$this->nameIsEditable && $attr == 'LogonName'){
82 continue;
83 }
84 if(isset($_POST[$attr])){
85 $this->$attr = stripslashes($_POST[$attr]);
86 }
87 }
89 foreach(array("LogonLast","LogonOverload") as $checkBoxes){
90 if(isset($_POST[$checkBoxes])){
91 $this->$checkBoxes = stripslashes($_POST[$checkBoxes]);
92 }else{
93 $this->$checkBoxes = "";
94 }
96 }
97 }
98 }
100 function check()
101 {
102 /* Call common method to give check the hook */
103 $message= plugin::check();
105 if(preg_match("/[^a-zA-Z]/",$this->LogonName)){
106 $message[] = msgPool::invalid(_("Name"),$this->LogonName,"/[a-zA-Z]/");
107 }
109 if(empty($this->LogonName)){
110 $message[] = msgPool::required(_("Script name"));
111 }
113 if(preg_match("/[^a-z0-9,\.-;:_\(\)!\? ]/i",$this->LogonDescription)){
114 $message[] = msgPool::required(_("Description"),$this->LogonDescription,"/[a-z0-9,\.-;:_\(\)!\? ]/i");
115 }
117 return $message;
118 }
121 function save()
122 {
123 $a_return= array();
124 foreach($this->attributes as $attr){
125 $a_return[$attr]=$this->$attr;
126 }
128 if(!$this->nameIsEditable){
129 $a_return['LogonName']=$this->real_LogonName;
130 }
132 return($a_return);
133 }
135 }
136 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
137 ?>