Code

Run code to update printer objects not only when a printer is added
[gosa.git] / trunk / 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     if(isset($_GET['getLogonData'])){
51       send_binary_content($this->LogonData, $this->real_LogonName);
52     }
54     /* Create download button*/
55     if($this->dn != "new" && $this->LogonData != ""){
56       $smarty->assign("DownMe","<a href='?plug=".$_GET['plug']."&getLogonData'>
57           <img src='images/save.png' alt='"._("Download")."' title='"._("Download")."' border=0 class='center'>
58         </a>");
59     }else{
60       $smarty->assign("DownMe","");
61     }
63     foreach($this->attributes as $attr){
64       $smarty->assign($attr,$this->$attr);
65       if($this->$attr){
66         $smarty->assign($attr."CHK"," checked ");
67       }else{
68         $smarty->assign($attr."CHK","");
69       }
70     }
71     $smarty->assign("LogonPriority",$this->LogonPriority);
72     $prios=array(1,2,3,4,5,6,7,8,9,10);
73     $smarty->assign("LogonPrioritys",$prios);
74     $smarty->assign("LogonPriorityKeys",$prios);
76     if(!$this->nameIsEditable){
77       $smarty->assign("LogonNameACL"," disabled ");
78     }else{
79       $smarty->assign("LogonNameACL","");
80     }
81   
83     $display.= $smarty->fetch(get_template_path('logonManagement.tpl', TRUE,dirname(__FILE__)));
84     return($display);
85   }
87   function save_object()
88   {
89     if(isset($_POST['dialogissubmitted'])){
90       foreach($this->attributes as $attr){
92         if(!$this->nameIsEditable && $attr == 'LogonName'){
93           continue;
94         }
95         if(isset($_POST[$attr])){
96           $this->$attr = stripslashes($_POST[$attr]); 
97         }
98       }
100       foreach(array("LogonLast","LogonOverload") as $checkBoxes){
101         if(isset($_POST[$checkBoxes])){
102           $this->$checkBoxes = stripslashes($_POST[$checkBoxes]);
103         }else{
104           $this->$checkBoxes = "";
105         }
107       }
108     }
109   }
111   function check()
112   {
113     /* Call common method to give check the hook */
114     $message= plugin::check();
115   
116     if(preg_match("/[^a-zA-Z]/",$this->LogonName)){
117       $message[] = msgPool::invalid(_("Name"),$this->LogonName,"/[a-zA-Z]/");
118     }
120     if(empty($this->LogonName)){
121       $message[] = msgPool::required(_("Script name"));
122     }
124     if(preg_match("/[^a-z0-9,\.-;:_\(\)!\? ]/i",$this->LogonDescription)){
125       $message[] = msgPool::required(_("Description"),$this->LogonDescription,"/[a-z0-9,\.-;:_\(\)!\? ]/i");
126     }
128     return $message;
129   }
132   function save()
133   {
134     $a_return= array();
135     foreach($this->attributes as $attr){
136       $a_return[$attr]=$this->$attr;
137     }  
139     if(!$this->nameIsEditable){
140       $a_return['LogonName']=$this->real_LogonName;
141     }
143     return($a_return); 
144   }
147 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
148 ?>