Code

Added logging to ogroup
[gosa.git] / plugins / personal / environment / class_environment.inc
1 <?php
3 class environment extends plugin
4 {
5   /* CLI vars */
6   var $cli_summary          = "Manage server basic objects";
7   var $cli_description      = "Some longer text\nfor help";
8   var $cli_parameters       = array("eins" => "Eins ist toll", "zwei" => "Zwei ist noch besser");
10   /* attribute list for save action */
11   var $ignore_account       = FALSE;
12   var $plHeadline           = "Environment";
13   var $plDescription        = "This does something";
14   var $dialog               = false;    // Indicates that we are currently editing in an seperate dialog
15   
16   var $in_dialog            = false;
17   var $uid                  = "";
19   var $is_group             = false;
20   
21   /* Attribute definition
22    */
24   /* profile management */
25   var $useProfile         = false;  // Specifies if we want to use a Server 
26   var $gotoProfileServer  = "";     // Specifies the selected profile server
27   var $gotoProfileServers = array();// Specifies all available and selectable servers
28   var $gotoProfileFlags   = "";     // Flags enabled  ? only used to set ACL and save 
29   var $gotoProfileFlagC  = "";     // Flag is set to C if we have the profile caching fucntion enabled 
30   
31   var $gotoXResolution    = "auto";     // The selected resolution eg: 1024x768
32   var $gotoXResolutions   = array();// Contains all available resolutions for this account
33   var $gotoProfileFlagL  = "";     // Flag is set to L to enable runtime resolution change 
34   var $gotoProfileQuota   = "";     // User Quota Settings
36   /* Logon script section*/
37   var $gotoLogonScripts   = array();// Contains all available Logon Scripts  
38   var $gotoLogonScript    = "";     // The selected Logon Script
40   /* Printer */
41   var $gotoPrinter        = array();// All available Printer, with their configurations
42   var $gotoPrinterSel     = "";     //  The selected Printer
43   var $gosaDefaultPrinter = "";     // Default printer
45   /* Share */
46   var $gotoShares         = array();// Current Share Options
47   var $gotoShare          = "";     // currently selected Share Option
48   var $gotoShareSelections= array();// Available Shares for this account in Listbox format
49   var $gotoAvailableShares= array();// Available Shares for this account
51   /* Kiosk profile */
52   var $gotoKioskProfile   = "none";     // The selected Kiosk Profile
53   var $gotoKioskProfiles  = array();// All available Kiosk profiles
54   var $newKioskProfiles   = array();
56   /* Hotplug Devices */
57   var $gotoHotplugDevice  = array();     // Selected hotplug
58   var $gotoHotplugDevices = array();// Already configured hotplug devices 
60   var $NewAddedPrinters   = array();
61   var $NewDeletedPrinters = array();
63   /* general settings */
64   // Sets the attributes which will kept on page reload, which will be saved, ...
66   var $CopyPasteVars      = array("gotoHotplugDevices","newKioskProfiles","gotoAvailableShares","gotoShareSelections","gotoPrinterSel","gotoProfileFlagL","gotoXResolutions","gotoProfileFlagC","gotoProfileServers","useProfile","is_group","in_dialog","OrigCn");
68   var $attributes         = array("uid","gotoProfileServer","gotoProfileFlags","gotoHotplugDevice",
69       "gotoXResolution","gotoProfileQuota",
70       "gotoLogonScripts","gotoLogonScript",
71       "gotoPrinter", "gosaDefaultPrinter",
72       "gotoShares","gotoShare",
73       "gotoKioskProfile","gotoKioskProfiles"
74       );
75   var $objectclasses      = array("gotoEnvironment"); // Specifies the objectClass which contains the attributes edited here 
76   var $cn;
77   var $OrigCn;
78   var $add_del_printer_member_was_called = false;
80   function environment ($config, $dn= NULL)
81   {
82     plugin::plugin ($config, $dn);
84     /* Setting uid to default */
85     if(isset($this->attrs['uid'][0])){
86       $this->uid = $this->attrs['uid'][0];
87     }
89     /* Check : Are we currently editing a group or user dialog */
90     if((isset($this->attrs['cn'][0]))&&(!isset($this->attrs['uid'][0]))){
91       $suffix="Group";
92       $this->uid          = $this->attrs['cn'][0];
93       $this->attrs['uid'] = $this->attrs['cn'][0];
94       $this->OrigCn = $this->attrs['cn'][0];
95     }else{
96       $suffix="User";
97     }
99     $this->gotoKioskProfile= preg_replace("/^.*\//i","",$this->gotoKioskProfile);
101     /* Get all Printer assignments */
102     $ldap = $this->config->get_ldap_link();
103     $ldap->cd($this->config->current['BASE']);
104     $ldap->search("(&(objectClass=gotoPrinter)(goto".$suffix."Printer=".$this->uid."))",array("*"));
105     while($printer = $ldap->fetch()){
106       $this->gotoPrinter[$printer['cn'][0]]=$printer;
107       $this->gotoPrinter[$printer['cn'][0]]['mode']="user";
108     }
109     $ldap->search("(&(objectClass=gotoPrinter)(goto".$suffix."AdminPrinter=".$this->uid."))",array("*"));
110     while($printer = $ldap->fetch()){
111       $this->gotoPrinter[$printer['cn'][0]]=$printer;
112       $this->gotoPrinter[$printer['cn'][0]]['mode']="admin";
113     }
115     /* prepare hotplugs */
116     if((isset($this->attrs['gotoHotplugDevice']))&&(is_array($this->attrs['gotoHotplugDevice']))){
117       unset($this->attrs['gotoHotplugDevice']['count']);
118       foreach($this->attrs['gotoHotplugDevice'] as $device){
119         $tmp = $tmp2 = array();
120         $tmp = split("\|",$device);
121         $tmp2['name']        = $tmp[0]; 
122         $tmp2['description'] = $tmp[1]; 
123         $tmp2['id']          = $tmp[2]; 
125         /* Produkt ID */
126         if(!isset($tmp[3])){
127           $tmp[3] = "";
128         }
129         /* Vendor ID */
130         if(!isset($tmp[4])){
131           $tmp[4] = "";
132         }
134         $tmp2['produkt']     = $tmp[3]; 
135         $tmp2['vendor']      = $tmp[4];
137         $this->gotoHotplugDevices[$tmp[0]]=$tmp2;
138       }
139     }
141     /* prepare LogonScripts */
142     if((isset($this->attrs['gotoLogonScript']))&&(is_array($this->attrs['gotoLogonScript']))){
143       unset($this->attrs['gotoLogonScript']['count']);
144       foreach($this->attrs['gotoLogonScript'] as $device){
145         $tmp = $tmp2 = array();
146         $tmp = split("\|",$device);
147         $tmp2['LogonName']        = $tmp[0]; 
148         $tmp2['LogonPriority']    = $tmp[2]; 
149         if(preg_match("/O/i",$tmp[1])){
150           $tmp2['LogonOverload'] = "O";
151         }else{
152           $tmp2['LogonOverload'] = "";
153         }
154         if(preg_match("/L/i",$tmp[1])){
155           $tmp2['LogonLast'] = "L";
156         }else{
157           $tmp2['LogonLast'] = "";
158         }
159         $tmp2['LogonData']        = base64_decode($tmp[3]); 
160         $tmp2['LogonDescription'] = $tmp[4];
161         $this->gotoLogonScripts[$tmp[0]]=$tmp2;
162       }
163     }
165     /* Prepare Shares */
166     if((isset($this->attrs['gotoShare']))&&(is_array($this->attrs['gotoShare']))){
167       unset($this->attrs['gotoShare']['count']);
168       foreach($this->attrs['gotoShare'] as $share){
169         $tmp = $tmp2 = array();
170         $tmp = split("\|",$share);
171         $tmp2['server']      =$tmp[0];
172         $tmp2['name']        =$tmp[1];
174         /* Decode base64 if needed */
175         if (!preg_match('%/%', $tmp[2])){
176           $tmp2['mountPoint']  =base64_decode($tmp[2]);
177         } else {
178           $tmp2['mountPoint']  =$tmp[2];
179         }
181         if(isset($tmp[3])){
182           $tmp2['PwdHash']  =$tmp[3];
183         }else{
184           $tmp2['PwdHash']  ="";
185         }
186         if(isset($tmp[4])){
187           $tmp2['Username']  =$tmp[4];
188         }else{
189           $tmp2['Username']  ="";
190         }
191         $this->gotoShares[$tmp[1]."|".$tmp[0]]=$tmp2;
192       }
193     }
195     for($i = 0 ; $i < strlen($this->gotoProfileFlags) ; $i ++){
196       $chr = $this->gotoProfileFlags[$i];
197       $name = "gotoProfileFlag".$chr;
198       $this->$name=$chr;
199     }
201     if((!empty($this->gotoProfileServer))||($this->gotoProfileFlagC=="C")){
202       $this->useProfile = true;
203     }else{
204       $this->useProfile = false;
205     }
207     /* Set resolutions */
208     $this->gotoXResolutions = array("auto"=>_("auto"),
209                                     "640x480"   =>  "640x480",
210                                     "800x600"   =>  "800x600",
211                                     "1024x768"  =>  "1024x768",
212                                     "1152x864"  =>  "1152x864",
213                                     "1280x768"  =>  "1280x768",
214                                     "1280x1024" =>  "1280x1024");
216     if(isset($this->config->data['MAIN']['RESOLUTION_HOOK'])){
217       $file = $this->config->data['MAIN']['RESOLUTION_HOOK'];
219       if(is_readable($file)){
220         $str = file_get_contents($file);
221         $lines = split("\n",$str);
222         foreach($lines as $line){
223           $line = trim($line);
224           if(!empty($line)){
225             $this->gotoXResolutions[$line]=$line;
226           }
227         }
228         //natcasesort($this->gotoXResolutions);
229       }else{
230         print_red(sprintf(_("You have specified an external resolution hook which can't be read, please check the permission of the file '%s'."),$file));
231       }
232     }
234     $this->gotoProfileServers= $config->getShareServerList() ;
235     $this->gotoShareSelections= $config->getShareList(true);
236     $this->gotoAvailableShares= $config->getShareList(false);  
238     if($this->is_account){
240       if(in_array("gosaAccount",$this->attrs['objectClass'])){
241         @log::log("view","users/".get_class($this),$this->dn);
242       }else{
243         @log::log("view","groups/".get_class($this),$this->dn);
244       }
245     }
246   }
249   /* Detect type of edited object (user|group)*/
250   function detect_grouptype()
251   {
252     if((!isset($this->parent))&&(!$this->is_account)){
253       $this->is_group     = false;
254     }elseif((isset($this->parent))&&(!isset($this->parent->by_object['posixAccount']))){
255       $this->is_group     = true;
256     }else{
257       $this->is_group     = false;
258     }
259   }
262   function execute()
263   {
264     /* Call parent execute */
265     plugin::execute();
267     /* Are we editing from MyAccount and not editing a user */
268     $WriteOnly = (!isset($this->parent)|| !$this->parent) && !isset($_SESSION['edit']);
270     /* Check profile server */
271     if($this->acl_is_writeable("gotoProfileServer",$WriteOnly)){
272       if(!empty($this->gotoProfileServer) && !isset($this->gotoProfileServers[$this->gotoProfileServer])){
273         if(count($this->gotoProfileServers)){
275           /* Get First Profile */
276           $new = key($this->gotoProfileServers);
278           /* Another profile server found */
279           print_red(sprintf(_("Your selected profile server '%s' is no longer available. Setting profile server to '%s'."),
280                 $this->gotoProfileServer,$new));
281         }else{
283           /* No other profile servers found */
284           print_red(sprintf(_("Your selected profile server '%s' is no longer available. Profile server configuration is resetted."),
285                 $this->gotoProfileServer));
286           $this->gotoProfileServer = "";
287         }
288       }
289     }    
291     $this->detect_grouptype();
293     /* Fill templating stuff */
294     $smarty= get_smarty();
295     $display= "";
297     $smarty->assign("is_group",$this->is_group);
299     /* Prepare all variables for smarty */
300     foreach($this->attributes as $s_attr){
301       /* Set value*/
302       $smarty->assign($s_attr,$this->$s_attr);
304       /* Set checkbox state*/
305       if(empty($this->$s_attr)){
306         $smarty->assign($s_attr."CHK","");
307       }else{
308         $smarty->assign($s_attr."CHK"," checked ");
309       }
311       /* Prepare ACL settings*/
312       $smarty->assign($s_attr."ACL",$this->getacl($s_attr,$WriteOnly));
313     }
315     /* Is accout enabled | are we editing from usermenu or admin menu 
316        All these tab management is done here
317      */
320     /* Working from Usermenu an the Account is currently disbled
321      * this->parent :  is only set if we are working in a list of tabs
322      * is_account   :  is only true if the needed objectClass is given
323      */
324     if((!isset($this->parent))&&(!$this->is_account)){
325       /* We are currently editing this tab from usermenu, but this account is not enabled */
326       $smarty->assign("is_account",$this->is_account);
327       /* Load template */
328       $display .= $smarty->fetch(get_template_path('environment.tpl', TRUE));
329       /* Avoid the "You are currently editing ...." message when you leave this tab */
330       $display .= back_to_main(); 
331       /* Display our message to the user */
332       return $display;
335       /* We are currently editing from group tabs, because 
336        * $this->parent is set
337        * posixAccount is not set, so we are not in usertabs.
338        */
339     }elseif((isset($this->parent))&&(!isset($this->parent->by_object['posixAccount']))){
340       $smarty->assign("is_account","true");
341       $this->uid          = $this->cn;
342       $this->attrs['uid'] = $this->cn;
344       /* Change state if needed */
345       if (isset($_POST['modify_state'])){
346         if(($this->acl_is_createable() && !$this->is_account) || 
347             ($this->acl_is_removeable() &&  $this->is_account)){
348           $this->is_account= !$this->is_account;
349         }
350       }
351       /* Group Dialog with enabled environment options */
352       if ($this->is_account){
353         $display= $this->show_enable_header(_("Remove environment extension"),
354             _("Environment extension enabled. You can disable it by clicking below."));
355       } else {
357         /* Environment is disabled 
358            If theres is no posixAccount enabled, you won't be able to enable 
359            environment extensions
360          */
361         if((isset($this->parent->by_object['group']))||(isset($this->attrs['objectClass']))&&((in_array("posixAccount",$this->attrs['objectClass'])))){
362           // 4. There is a PosixAccount
363           $display= $this->show_enable_header(_("Add environment extension"),
364               _("Environment extension disabled. You can enable it by clicking below."));
365           return $display;
366         }else{
367           // 4. There is no PosixAccount
368           $display= $this->show_enable_header(_("Add environment extension"),
369               _("Environment extension disabled. You have to setup a posix account before you can enable this feature."));
370           return $display;
371         }
372       }
373     }else{
374       /* Editing from Usermenu 
375        *  Tell smarty that this accoutn is enabled 
376        */
377       $smarty->assign("is_account","true");
379       /* Change state if needed */
380       if (isset($_POST['modify_state'])){
381         if(($this->acl_is_createable() && !$this->is_account) || 
382             ($this->acl_is_removeable() &&  $this->is_account)){
383           $this->is_account= !$this->is_account;
384         }
385       }
387       if(isset($this->parent)){
389         // 3. Account enabled . Editing from adminmenu
390         if ($this->is_account){
391           $display= $this->show_disable_header(_("Remove environment extension"),
392               _("Environment extension enabled. You can disable it by clicking below."));
393         } else {
395           if($this->parent->by_object['posixAccount']->is_account==true){
396             // 4. There is a PosixAccount
397             $display= $this->show_disable_header(_("Add environment extension"),
398                 _("Environment extension disabled. You can enable it by clicking below."));
399             return $display;
400           }else{
401             // 4. There is a PosixAccount
402             $display= $this->show_disable_header(_("Add environment extension"),
403                 _("Environment extension disabled. You have to setup a posix account before you can enable this feature."),TRUE,TRUE);
404             return $display;
405           }
406         }
407       }
408     }
409     /* Account is Account : is_accounbt=true.
410      * Else we won't reach this. 
411      */
413     /* Prepare all variables for smarty */
414     foreach($this->attributes as $s_attr){
415       /* Set value*/
416       $smarty->assign($s_attr,$this->$s_attr);
418       /* Set checkbox state*/
419       if(empty($this->$s_attr)){
420         $smarty->assign($s_attr."CHK","");
421       }else{
422         $smarty->assign($s_attr."CHK"," checked ");
423       }
425       /* Prepare ACL settings*/
426       $smarty->assign($s_attr."ACL",$this->getacl($s_attr,$WriteOnly));
427     }
429     foreach(array("gotoHotplugDevice","gotoProfileFlagC","gotoProfileFlagL") as $s_attr){
430       $smarty->assign($s_attr."ACL",$this->getacl($s_attr,$WriteOnly));
431     }
433     if($WriteOnly) {
434       $smarty->assign("gotoPrinterACL","r");
435     }else{
436       $smarty->assign("gotoPrinterACL","rw");
437     }
439     if(empty($this->useProfile)){
440       $smarty->assign("useProfileCHK","");
441       $smarty->assign("gotoProfileServerACL" , preg_replace("/w/","",$this->getacl("gotoProfileServer",$WriteOnly)));
442       $smarty->assign("gotoProfileQuotaACL" , preg_replace("/w/","",$this->getacl("gotoProfileQuota",$WriteOnly)));
443       $smarty->assign("gotoProfileFlagCACL" , preg_replace("/w/","",$this->getacl("gotoProfileFlagC",$WriteOnly)));
444     }else{
445       $smarty->assign("useProfileCHK"," checked ");
446     }
447     
448     $smarty->assign("gotoProfileServerWriteable", $this->acl_is_writeable("gotoProfileServer",$WriteOnly));
449     $smarty->assign("gotoProfileACL", $this->getacl("gotoProfileServer",$WriteOnly).$this->getacl("gotoProfileQuota",$WriteOnly));
451     /* HANDLE Profile Settings here 
452      * Assign available Quota and resolution settings
453      * Get all available profile server
454      * Get cache checkbox
455      * Assign this all to Smarty 
456      */
458     if(empty($this->gotoProfileFlagL)){
459       $smarty->assign("gotoProfileFlagLCHK"," ");
460     }else{
461       $smarty->assign("gotoProfileFlagLCHK"," checked ");
462     }
464     if(empty($this->gotoProfileFlagC)){
465       $smarty->assign("gotoProfileFlagCCHK"," ");
466     }else{
467       $smarty->assign("gotoProfileFlagCCHK"," checked ");
468     }
471     $smarty->assign("gotoXResolutions"    , $this->gotoXResolutions);
472     $smarty->assign("gotoXResolutionKeys" , array_flip($this->gotoXResolutions));
474     $smarty->assign("gotoProfileServers",$this->gotoProfileServers);
475     if(!is_array($this->gotoProfileServers)){
476       $this->gotoProfileServers =array();
477     }
478     $smarty->assign("gotoProfileServerKeys",array_flip($this->gotoProfileServers));
480     /* Handle kiosk profiles 
481      * Read available from filesystem
482      * Open management if post is transmitted
483      */
485     /* Save */
486     if(isset($_POST['KioskClose'])){
487       $this->newKioskProfiles = array_merge($this->newKioskProfiles,$this->dialog->save());
489       unset($this->dialog);
490       $this->dialog=NULL;
491       $this->is_dialog = false;
492     }
494     /* Reassign help class */
495     $_SESSION['current_class_for_help'] = get_class($this);
497     /* Open Management Dialog */
498     if(isset($_POST['KioskManagementDialog'])){
499       $this->dialog = new kioskManagementDialog($this->config,$this->dn,$this->newKioskProfiles); 
500       $this->dialog->parent= $this;
501       $this->dialog->acl = $this->acl;
502       $this->is_dialog = true;
503     }
504     $tmp = new kioskManagementDialog($this->config,$this->dn);
505     $list = $tmp->getKioskProfiles($this->newKioskProfiles);
506     $list['none']=_("None");
507     $list = array_reverse($list);
508     $smarty->assign("gotoKioskProfiles",$list);
509     $smarty->assign("gotoKioskProfileKeys",array_flip($list));
511     /* Logonscript Management
512      * Get available LogonScripts (possibly grey out (or mark) these script that are defined for the group) 
513      * Perform add Delete edit Posts 
514      */
516     /* Dialog Save */
517     if(isset($_POST['LogonSave'])){
519       if(!$this->acl_is_writeable("gotoLogonScript")){
520         print_red(_("You are not allowed to write Logon scripts."));
521         unset($this->dialog);
522         $this->dialog=NULL;
523         $this->is_dialog=false;
524       }else{
525         $this->dialog->save_object();
526         if(count($this->dialog->check())!=0){
527           foreach($this->dialog->check() as $msg){
528             print_red($msg);
529           }
530         }else{
531           $tmp = $this->dialog->save();
532           unset($this->dialog);
533           $this->dialog=NULL;
534           $this->is_dialog=false;
535           $this->gotoLogonScripts[$tmp['LogonName']]=$tmp; 
536         }
537       }
538     }
539     
541     /* Dialog Quit without saving */
542     if(isset($_POST['LogonCancel'])){
543       $this->is_dialog= false;
544       unset($this->dialog);
545       $this->dialog= NULL;
546     }
548     /* Check Edit Del New Posts for a selected LogonScript */ 
549     if($this->acl_is_writeable("gotoLogonScript") && 
550         (isset($_POST['gotoLogonScriptNew'])) || isset($_POST['gotoLogonScriptEdit']) ||isset($_POST['gotoLogonScriptDel'])){
552       /* New Logon Script: Open an edit dialog, we don't need a $_POST['gotoLogonScript'] here.
553        * In this case we create a new Logon Script.
554        */
555       if(isset($_POST['gotoLogonScriptNew'])){
556         $this->is_dialog = true;
557         $this->dialog = new logonManagementDialog($this->config,$this->dn);
558       }
560       /* If we receive a Delete request and there is a Script selected in the selectbox, delete this one.
561        * We only can delete if there is an entry selected.
562        */
563       if((isset($_POST['gotoLogonScriptDel']))&&(isset($_POST['gotoLogonScript']))){
564         unset($this->gotoLogonScripts[$_POST['gotoLogonScript']]);
565       }
567       /* In this case we want to edit an existing entry, we open a new Dialog to allow editing.
568        * There must be an entry selected to perform edit request.
569        */
570       if((isset($_POST['gotoLogonScriptEdit']))&&(isset($_POST['gotoLogonScript']))){
571         $is_entry = $this->gotoLogonScripts[$_POST['gotoLogonScript']];
572         $this->is_dialog = true;
573         $this->dialog = new logonManagementDialog($this->config,$this->dn,$is_entry);
574       }
575     }
577     /* Append List to smarty*/
578     $smarty->assign("gotoLogonScripts",   $this->printOutLogonScripts());
579     $smarty->assign("gotoLogonScriptKeys",array_flip($this->printOutLogonScripts()));
581     /* In this section server shares will be defined 
582      * A user can select one of the given shares and a mount point
583      *  and attach this combination to his setup.
584      */
586     $smarty->assign("gotoShareSelections",    $this->gotoShareSelections);
587     if(!is_array($this->gotoShareSelections)){
588       print $this->gotoShareSelections;
589       $this->gotoShareSelections = array();
590     }
591     $smarty->assign("gotoShareSelectionKeys", array_flip($this->gotoShareSelections));
593     /* if $_POST['gotoShareAdd'] is set, we will try to add a new entry 
594      * This entry will be, a combination of mountPoint and sharedefinitions 
595      */
596     if(isset($_POST['gotoShareAdd']) && $this->acl_is_writeable("gotoShare")){
597       /* We assign a share to this user, if we don't know where to mount the share */
598       if((!isset($_POST['gotoShareMountPoint']))||(empty($_POST['gotoShareMountPoint']))||(preg_match("/[\|]/i",$_POST['gotoShareMountPoint']))){
599         print_red(_("You must specify a valid mount point."));
600       }elseif(preg_match('/ /', $_POST['gotoShareMountPoint'])){
601         print_red(_("Spaces are not allowed in the mount path!"));
602       }elseif(!(
603             preg_match("/^\//",$_POST['gotoShareMountPoint'])  ||
604             preg_match("/^~/",$_POST['gotoShareMountPoint']) ||
605             preg_match("/^\$HOME/",$_POST['gotoShareMountPoint']) ||
606             preg_match("/^.HOME/",$_POST['gotoShareMountPoint']) ||
607             preg_match("/^\$USER/",$_POST['gotoShareMountPoint']) ||
608             preg_match("/^.USER/",$_POST['gotoShareMountPoint']) ||
609             preg_match("/^%/",$_POST['gotoShareMountPoint'])
610             )
611           ){
612         print_red(_("You must specify a valid mount point.")); 
613       }else{
614         $a_share = $this->gotoAvailableShares[$_POST['gotoShareSelection']];
615         $s_mount = $_POST['gotoShareMountPoint'];
616         $s_user  = $_POST['ShareUser'];
617         /* Preparing the new assignment */ 
618         $this->gotoShares[$a_share['name']."|".$a_share['server']]=$a_share;
619         $this->gotoShares[$a_share['name']."|".$a_share['server']]['Username']=$s_user;
620         $this->gotoShares[$a_share['name']."|".$a_share['server']]['PwdHash']="";
621         $this->gotoShares[$a_share['name']."|".$a_share['server']]['mountPoint']=$s_mount;
622       }
623     }  
625     /* if the Post  gotoShareDel is set, someone asked GOsa to delete the selected entry (if there is one selected)
626      * If there is no defined share selected, we will abort the deletion without any message 
627      */
628     $once = true;
629     if($this->acl_is_writeable("gotoShare")){
630       foreach($_POST as $name => $value){
631         if((preg_match("/^gotoShareDel_/",$name)) && ($once)){
632           $once = false;  
633           $key  = preg_replace("/^gotoShareDel_/","",$name);
634           $key  = preg_replace("/_+[xy]$/","",$key);
635           $key  = base64_decode($key);
636           if(isset($this->gotoShares[$key])) {
637             unset($this->gotoShares[$key]);
638           }
640           /* Remove corresponding password entry, too. This is a workaround
641              to get rid of old-style entries. */
642           $key= preg_replace("/\|/", "|!", $key);
643           if(isset($this->gotoShares[$key])) {
644             unset($this->gotoShares[$key]);
645           }
646         }
647         if((preg_match("/^gotoShareResetPwd_/",$name)) && ($once)){
648           $once = false;
649           $key  = preg_replace("/^gotoShareResetPwd_/","",$name);
650           $key  = preg_replace("/_+[xy]$/","",$key);
651           $key  = base64_decode($key);
652           $this->gotoShares[$key]['PwdHash'] = "";
653           if(preg_match("/^!/",$this->gotoShares[$key]['server'])){
654             unset($this->gotoShares[$key]);
655           }
656         }
657       }
658     }
659     $divlistShares = new divSelectBox("gotoShares");
660     $divlistShares->SetHeight(100);
663     $tmp = array();
664     if($this->acl_is_readable("gotoShares")){
665       $tmp = $this->printOutAssignedShares();
666     }
668     
669     foreach($tmp as $key => $value){
670       $img = "";
672       /* Check if entry starts with an ! */
673       if(preg_match("/^!/",$this->gotoShares[$key]['server'])){
675         /* If we are currently editing groups environment, skip those ! entries */ 
676         if($this->is_group) continue;
678         /* Create pwd reset images */
679         if($this->gotoShares[$key]['PwdHash'] != ""){
680           $img.= "<input type='image' name='gotoShareResetPwd_".base64_encode($key)." 'src='images/list_reset_password.png' alt='"._("Reset password hash")."' 
681             title='"._("Reset password hash")."'>";
682         }
683         $field1 = array("string" => "<font style=\"color:#C0C0C0\">".$value."</font>" );
684         $field2 = array("string" => $img   , "attach" => "style='border-right:0px;'");
685       }else{
687         /* Create pwd reset img && delete image */
688         if($this->gotoShares[$key]['PwdHash'] != ""){
689           $img.= "<input type='image' name='gotoShareResetPwd_".base64_encode($key)." 'src='images/list_reset_password.png' alt='"._("Reset password hash")."' 
690             title='"._("Reset password hash")."'>";
691           $img.= "&nbsp;";
692         }
693         $img.= "<input type='image' name='gotoShareDel_".base64_encode($key)." 'src='images/edittrash.png' alt='"._("Delete")."' 
694           title='"._("Delete share entry")."'>";
695         $field1 = array("string" => $value);
696         $field2 = array("string" => $img   , "attach" => "style='border-right:0px;'");
697       }
698       $divlistShares->AddEntry(array($field1,$field2));
699     }
700     $smarty->assign("divlistShares",$divlistShares->DrawList());
702     /* Hotplug devices will be handled here 
703      * There are 3 possible methods for this feature
704      * Create a new Hotplug, A Dialog will open where you can specify some hotplug information
705      * Delete will erase an entry, the entry must be selcted in the ListBox first
706      * Editing an entry will open a dialog where the informations about the selcted entry can be changed
707      */
709     /* If there is a new entry wanted, open a new entry by initilising the dialog */
710     if((isset($_POST['gotoHotplugDeviceNew'])) && ($this->acl_is_writeable("gotoHotplugDevice"))){
711       $this->dialog = new hotplugDialog($this->config,$this->dn);
712       $this->is_dialog = true;
713     }
715     /* We have to delete the selected hotplug from the list*/
716     if((isset($_POST['gotoHotplugDeviceDel']))&&(isset($_POST['gotoHotplugDevice'])) && $this->acl_is_writeable("gotoHotplugDevice")){
717       if($this->acl_is_writeable("gotoHotplugDevice")){
718         foreach($_POST['gotoHotplugDevice'] as $name){
719           unset($this->gotoHotplugDevices[$name]);
720         }
721       }
722     }
724     /* There are already defined hotplugs from other users we could use */
725     if(isset($_POST['gotoHotplugDeviceUse']) && $this->acl_is_writeable("gotoHotplugDevice")){
726       $tmp  =array();
727       foreach($this->gotoHotplugDevices as $plugs){
728         $tmp[] = $plugs['name'];
729       }
730       $this->dialog = new hotplugDialog($this->config,$this->dn,true,$tmp);
731       $this->is_dialog = true;
732     }
734     /* Dialog Aborted */
735     if(isset($_POST['HotPlugCancel'])){
736       unset($this->dialog);
737       $this->dialog= NULL;
738       $this->is_dialog = false;
739     }
741     /* Dialod saved */
742     if(isset($_POST['HotPlugSave'])){
744       $this->dialog->save_object();
745       if(count($this->dialog->check())!=0){
746         foreach($this->dialog->check() as $msg){
747           print_red($msg);
748         }
749       }else{
750         $this->dialog->save_object();
751         $a_tmp = $this->dialog->save();
753         if(is_array($a_tmp)){
754           foreach($a_tmp as $name => $hotplug){
755             $this->gotoHotplugDevices[$name]= $hotplug; 
756           }
757         }
758         unset($this->dialog);
759         $this->dialog= NULL;
760         $this->is_dialog = false;
761       }
762     }
763     $smarty->assign("gotoHotplugDevices",$this->printOutHotPlugDevices());
764     $smarty->assign("gotoHotplugDeviceKeys",array_flip($this->printOutHotPlugDevices()));
766     /* Printer Assignment will managed below 
767      * A printer can be assigned in two different ways and two different types
768      * There are 2 types of users assigned to a printer : user and admin
769      * They only differ in the member attribute they will be assigned to. user: gotoUserPrinter admin: gotoadminPrinter
770      * The different types of assigning a user are : 1 assigning a user to a printer 2. assigning a group to a printer
771      */ 
773     /* First handle Add Post. Open a dialog that allows us to select a printer or two */ 
774     if(isset($_POST['gotoPrinterAdd'])){
776       $this->is_dialog=true;
777       $this->dialog = new selectPrinterDialog($this->config,$this->dn,$this->gotoPrinter);
778     }
780     if(isset($_POST['PrinterCancel'])){
781       $this->is_dialog=false;
782       unset($this->dialog);
783       $this->dialog=NULL;
784     }
786     if(isset($_POST['PrinterSave'])){
787       if(count($this->dialog->check())!=0){
788         $tmp = $this->dialog->check();
789         foreach($tmp as $msg){
790           print_red($msg);
791         } 
792       }else{
793         $this->dialog->save_object();
794         $tmp = $this->dialog->save();
795         $tmp2= $this->dialog->getPrinter(true);
797         foreach($tmp as $pname){
798           $printerObj = new printtabs($this->config,$this->config->data['TABS']['PRINTTABS'],$tmp2[$pname]['dn'],"printer");
799           $printerObj->set_acl_base($tmp2[$pname]['dn']);
801           $type = false;
803           if($this->is_group){
805             if(isset($this->NewDeletedPrinters[$pname])){
806               $type = "AddGroup";
807             }elseif($printerObj->by_object['printgeneric']->AddMember("AddGroup",$this->dn)){
808               $type = "AddGroup";
809             }
810           }else{
811             if(isset($this->NewDeletedPrinters[$pname])){
812               $type = "AddUser";
813             }elseif($printerObj->by_object['printgeneric']->AddMember("AddUser",$this->dn)){
814               $type = "AddUser";
815             }
816           }
818           if($type){
819             $this->gotoPrinter[$pname]=$tmp2[$pname];
820             $this->gotoPrinter[$pname]['mode']="user";
821             $this->add_del_printer_member_was_called = true;
823             $this->NewAddedPrinters[$pname] = $pname;
824             if(isset($this->NewDeletedPrinters[$pname])){
825               unset($this->NewDeletedPrinters[$pname]);
826             }
827           }
828         }
830         $this->is_dialog=false;
831         unset($this->dialog);
832         $this->dialog   =NULL;
833       }
834     }
836     if((isset($_POST['gotoPrinterDel']))&&(isset($_POST['gotoPrinterSel']))&&(!empty($_POST['gotoPrinterSel']))){
837       $printer = $_POST['gotoPrinterSel'];
838       foreach($printer as $pname){
840         $printerObj = new printtabs($this->config,$this->config->data['TABS']['PRINTTABS'],$this->gotoPrinter[$pname]['dn'],"printer");
841         $printerObj->set_acl_base($this->gotoPrinter[$pname]['dn']);
843         $type = false;
844         if($this->is_group){
845           if(isset($this->NewAddedPrinters[$pname])){
846             $type = "Group";
847           }elseif($printerObj->by_object['printgeneric']->DelMember("AddGroup",$this->cn)){
848             $type = "Group";
849           }
850         }else{
851           if(isset($this->NewAddedPrinters[$pname])){
852             $type = "User";
853           }elseif($printerObj->by_object['printgeneric']->DelMember("AddUser",$this->uid)){
854             $type = "User";
855           }
856         }
857         if($type){
858           $this->add_del_printer_member_was_called = true;
859           unset($this->gotoPrinter[$pname]);
861           $this->NewDeletedPrinters[$pname] = $pname;
862           if(isset($this->NewAddedPrinters[$pname])){
863             UNSET($this->NewAddedPrinters[$pname]);
864           }
865         }
866       }
867     }
869     if((isset($_POST['gotoPrinterEdit']))&&(isset($_POST['gotoPrinterSel']))&&(!empty($_POST['gotoPrinterSel']))){
870       $printers = $_POST['gotoPrinterSel'];
871       $this->add_del_printer_member_was_called = true;
872       foreach($printers as $printer){
873         if($this->gotoPrinter[$printer]['mode']=="user"){
874           $this->gotoPrinter[$printer]['mode']="admin";
875         }else{
876           $this->gotoPrinter[$printer]['mode']="user";
877         }
878       }
879     }
881     if((isset($_POST['gotoPrinterDefault']))&&(isset($_POST['gotoPrinterSel']))&&(!empty($_POST['gotoPrinterSel']))){
882       if($this->is_group){
883         print_red(_("GOsa default printer flag is not allowed within groups."));
884       }else{
885         if ($this->gosaDefaultPrinter == $_POST['gotoPrinterSel'][0]){
886           $this->gosaDefaultPrinter= "";
887         } else {
888           $this->gosaDefaultPrinter= $_POST['gotoPrinterSel'][0];
889         }
890       }
891     }
893     $smarty->assign("gotoPrinter",$this->printOutPrinterDevices());
894     $smarty->assign("gotoPrinterKeys",array_flip($this->printOutPrinterDevices()));
896     /* General behavior */
897     if((isset($this->dialog))&&($this->dialog!=NULL)&&(!empty($this->dialog))){
898       $this->dialog->save_object();
899       $disp =$this->dialog->execute();
901       $tmp = new kioskManagementDialog($this->config,$this->dn);
902       $list = $tmp->getKioskProfiles($this->newKioskProfiles);
903       $list['none']=_("None");
904       $list = array_reverse($list);
905       if(!isset($list[$this->gotoKioskProfile])){
906         print_red(sprintf(_("The selected kiosk profile '%s' is no longer available, setting current profile to 'none'."),$this->gotoKioskProfile));
907         $this->gotoKioskProfile = 'none';
908       }
909       return($disp);
910     }
912     /* Als smarty vars are set. Get smarty template and generate output */
913     $display.= $smarty->fetch(get_template_path('environment.tpl', TRUE,dirname(__FILE__)));
914     return($display);
915   }
917   function remove_from_parent()
918   {
919     /* only if it was an account*/
920     if (!$this->initially_was_account){
921       return;
922     }
924     /* include global link_info */
925     $ldap= $this->config->get_ldap_link();
927     /* Remove and write to LDAP */
928     plugin::remove_from_parent();
930     /* Don't save our template variables */
931     $skip = array("uid","gotoLogonScripts","gotoPrinter","gotoShares","gotoKioskProfiles","gotoHotplugDevices" );
933     /* Skip all these attributes */
934     foreach($skip as $del){
935       unset($this->attrs[$del]);
936     }
938     @DEBUG (DEBUG_LDAP, __LINE__, __FUNCTION__, __FILE__,$this->attributes, "Save");
940     $ldap->cd($this->dn);
941     $this->cleanup();
942     $ldap->modify ($this->attrs); 
944     if($this->is_group){
945       @log::log("remove","groups/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
946     }else{
947       @log::log("remove","users/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
948     }
950     show_ldap_error($ldap->get_error(), sprintf(_("Removing of user/environment account with dn '%s' failed."),$this->dn));
952     /* Optionally execute a command after we're done */
953     $this->handle_post_events("remove",array("uid" => $this->uid));
954   }
957   /* Save data to object */
958   function save_object()
959   {
960     /* Get all Posted vars 
961      * Setup checkboxes 
962      */
963     $WriteOnly = (!isset($this->parent)|| !$this->parent) && !isset($_SESSION['edit']);
964     if(isset($_POST['iamposted'])){
966       $PACL =  $this->getacl("gotoProfileServer",$WriteOnly).$this->getacl("gotoProfileQuota",$WriteOnly);
968       if(preg_match("/w/",$PACL)){
969         if(isset($_POST['useProfile'])){
970           $this->useProfile = true;
971         }else{
972           $this->useProfile = false;
973         }
974       }
976       if($this->acl_is_writeable("gotoProfileFlagC")){
977         if(isset($_POST['gotoProfileFlagC'])){
978           $this->gotoProfileFlagC = $_POST['gotoProfileFlagC'];
979         }else{
980           $this->gotoProfileFlagC = false;
981         }
982       }
984       if($this->acl_is_writeable("gotoProfileFlagL")){
985         if(isset($_POST['gotoProfileFlagL'])){
986           $this->gotoProfileFlagL = $_POST['gotoProfileFlagL'];
987         }else{
988           $this->gotoProfileFlagL = false;
989         }
990       }
992       plugin::save_object();
993       foreach($this->attributes as $s_attr){
994         if((!isset($_POST[$s_attr])) || 
995             in_array($s_attr,array("gosaDefaultPrinter","gotoShares","gotoHotplugDevices","gotoPrinter","gotoLogonScripts","uid"))) continue;
996         if(!$this->acl_is_writeable($s_attr)){
997           continue;
998         }else{ 
999           if(isset($_POST[$s_attr])){
1000             $this->$s_attr = $_POST[$s_attr];
1001           }else{
1002             $this->$s_attr = false;
1003           }
1004         }
1005       }
1006     }
1007   }
1010   /* Check supplied data */
1011   function check()
1012   {
1013     /* Call common method to give check the hook */
1014     $message= plugin::check();
1016     $this->detect_grouptype();
1018     if(preg_match("/[^0-9]/",$this->gotoProfileQuota)) {
1019       $message[]=_("Please set a valid profile quota size.");
1020     } 
1021     if(!isset($this->attrs['objectClass'])){
1022       $this->attrs['objectClass']=array();
1023     } 
1024     if(!$this->is_group){
1025       if((!((in_array("posixAccount",$this->attrs['objectClass']))||($this->parent->by_object['posixAccount']->is_account==true)))&&(!$this->is_group)){
1026         $message[]=(_("You need to setup a valid posix extension in order to enable evironment features."));  
1027       }
1028     }
1029     return ($message);
1030   }
1033   /* Save to LDAP */
1034   function save()
1035   {
1036     /* If group was renamed, all printer settings get lost
1037      */ 
1038     /* only save changed variables ....*/
1039     if ($this->gotoKioskProfile =="none") $this->gotoKioskProfile ="";
1040     if((!empty($this->gotoKioskProfile))&&($this->gotoKioskProfile != "none")){
1041       if(preg_match("/https/i",$_SERVER['HTTP_REFERER'])){
1042         $method="https://";
1043       }else{
1044         $method="http://";
1045       }
1047       $str = $method.str_replace("//","/",$_SERVER['SERVER_NAME']."/kiosk/");
1048       $this->gotoKioskProfile= $str.$this->gotoKioskProfile;
1049     }else{
1050       $this->gotoKioskProfile= array();
1051     }
1053     plugin::save();
1054     $ldap= $this->config->get_ldap_link();
1056     $realyUsedAttrs= array();
1058     $path = search_config($this->config->data,"environment", "KIOSKPATH"); 
1059     /* Creating Kiosk Profiles */
1060     foreach($this->newKioskProfiles as $file){
1061       $contents = $file['contents'];
1062       $fp = @fopen($path."/".$file['name'],"w");
1063       if(!$fp){
1064         print_red(_("Can't save new kiosk profiles, possibly permission denied for folder")." : ",$path);
1065       }else{
1066         fwrite($fp,$contents,strlen($contents));
1067       }
1068       @unlink($file['tmp_name']);
1069     }
1071     /* Save already used objectClasses */
1072     $ocs        = $this->attrs['objectClass'];
1073     unset($ocs['count']);
1074     $this->attrs = array();
1075     $this->attrs['objectClass']= $ocs;
1076     foreach($this->objectclasses as $objc){
1077       if(!in_array($objc,$this->attrs['objectClass'])){
1078         $this->attrs['objectClass'][]=$objc;
1079       }
1080     }
1082     /* 1. Search all printers that have our uid/cn as member 
1083      * 2. Delete this uid/cn from every single entry and save it again.
1084      * 2.1 There are different types of members: Users / Groups, this will be defined in $suffix
1085      * 2.2 And each type has two modes, Admin (e.g. 'gotoUserAdminPrinter') and Normal 
1086      */
1087     
1088     $this->detect_grouptype();
1090     if($this->add_del_printer_member_was_called){
1092       $types = array( "gotoUserPrinter"       => "AddUser",
1093           "gotoGroupPrinter"      => "AddGroup",
1094           "gotoUserAdminPrinter"  => "AddAdminUser",
1095           "gotoGroupAdminPrinter" => "AddAdminGroup");
1097       if($this->is_group){
1098         $s_suffix = "Group";
1099         $useVar   = "cn";
1100       }else{
1101         $useVar   = "uid";
1102         $s_suffix = "User";
1103       }
1105       /* Remove old entries */
1106       $ldap->search("(&(objectClass=gotoPrinter)(goto".$s_suffix."Printer=".$this->$useVar."))",array("*"));
1107       while($attr = $ldap->fetch()){
1108         $printerObj = NULL;
1109         $printerObj = new printtabs($this->config,$this->config->data['TABS']['PRINTTABS'],$attr['dn'],"printer");
1110         $printerObj->set_acl_base($attr['dn']);
1111         $printerObj->by_object['printgeneric']->DelMember($types["goto".$s_suffix."Printer"],$this->$useVar);
1112         $printerObj->by_object['printgeneric']->save();
1113       }
1115       $ldap->search("(&(objectClass=gotoPrinter)(goto".$s_suffix."AdminPrinter=".$this->$useVar."))",array("*"));
1116       while($attr = $ldap->fetch()){
1117         $printerObj = NULL;
1118         $printerObj = new printtabs($this->config,$this->config->data['TABS']['PRINTTABS'],$attr['dn'],"printer");
1119         $printerObj->set_acl_base($attr['dn']);
1120         $printerObj->by_object['printgeneric']->DelMember($types["goto".$s_suffix."AdminPrinter"],$this->$useVar);
1121         $printerObj->by_object['printgeneric']->save();
1122       }
1124       foreach($this->gotoPrinter as $printer){
1125         $printerObj = NULL;
1126         $printerObj = new printtabs($this->config,$this->config->data['TABS']['PRINTTABS'],$printer['dn'],"printer");
1127         $printerObj->set_acl_base($printer['dn']);
1130         if($printer['mode'] == "admin") {
1131           $attribute = "goto".$s_suffix."AdminPrinter";
1132         }else{
1133           $attribute = "goto".$s_suffix."Printer";
1134         }
1136         $printerObj->by_object['printgeneric']->AddMember($types[$attribute],$this->dn);
1137         $printerObj->by_object['printgeneric']->save();
1138       }
1139     }    
1141     /* Prepare HotPlug devices */
1142     $this->attrs['gotoHotplugDevice'] = array();
1143     foreach($this->gotoHotplugDevices as $name => $device){
1144       $this->attrs['gotoHotplugDevice'][] = $device['name']."|".$device['description']."|".$device['id'].
1145         "|".$device['produkt']."|".$device['vendor'];
1146     }
1148     /* Prepare LogonScripts */
1149     $this->attrs['gotoLogonScript'] = array();
1150     foreach($this->gotoLogonScripts as $name => $script){
1151       $this->attrs['gotoLogonScript'][] =   $script['LogonName']."|".
1152         $script['LogonOverload'].$script['LogonLast']."|".
1153         $script['LogonPriority']."|".
1154         base64_encode($script['LogonData'])."|".
1155         $script['LogonDescription'];
1156     }
1158     /* Prepare Shares */
1159     $this->attrs['gotoShare']=array();
1160     foreach($this->gotoShares as $name => $share){
1161       $mntp= $share['mountPoint'];
1162       if (!preg_match('=^[a-z0-9+\._/%-]+$=i', $mntp)){
1163         $mntp= base64_encode($mntp);
1164       }
1165       $this->attrs['gotoShare'][] =$share['server']."|".$share['name']."|".$mntp."|".$share['PwdHash']."|".$share['Username'];
1166     }
1169     if($this->gotoXResolution == "auto") $this->gotoXResolution ="";
1170     $saveThis = array("gotoProfileQuota","gotoXResolution","gotoProfileServer","gotoKioskProfile","gosaDefaultPrinter");
1172     foreach($saveThis as $tosave){
1173       if(!empty($this->$tosave)){
1174         $this->attrs[$tosave]=$this->$tosave;
1175       }else{
1176         $this->attrs[$tosave]=array();
1177       }
1178     }
1180     /* Prepare Flags */
1181     $this->attrs['gotoProfileFlags'] = array($this->gotoProfileFlagC.$this->gotoProfileFlagL);
1182     if(empty($this->attrs['gotoProfileFlags'][0])){
1183       $this->attrs['gotoProfileFlags']=array();
1184     }
1186     if($this->useProfile == false){
1187       $this->attrs['gotoProfileFlags'] = preg_replace("/C/i","",$this->attrs['gotoProfileFlags']);
1188       $this->attrs['gotoProfileServer']= array(); 
1189     }
1191     $ldap->cat ($this->dn, array('dn'));
1192     if ($ldap->fetch()){
1193       $mode= "modify";
1194     } else {
1195       $mode= "add";
1196       $ldap->cd($this->config->current['BASE']);
1197       $ldap->create_missing_trees(preg_replace('/^[^,]+,/', '', $this->dn));
1198     }
1200     $ldap->cd($this->dn);
1201     $this->cleanup();
1202     $ldap->$mode($this->attrs);
1204     $cat = "users";
1205     if($this->is_group){
1206       $cat = "groups";
1207     }
1209     /* Log last action */ 
1210     if($this->initially_was_account){
1211       @log::log("modify",$cat."/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
1212     }else{
1213       @log::log("create",$cat."/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
1214     }
1216     show_ldap_error($ldap->get_error(), sprintf(_("Saving of user/environment account with dn '%s' failed."),$this->dn));
1217     $this->handle_post_events($mode,array("uid"=>$this->uid));
1218   }
1220   /* Generate ListBox frindly output for the defined shares 
1221    * Possibly Add or remove an attribute here, 
1222    */
1223   function printOutAssignedShares()
1224   {
1225     $a_return = array();
1226     if(is_array($this->gotoShares)){
1227       foreach($this->gotoShares as $share){
1228         if(preg_match("/^!/",$share['server'])){
1229           $a_return[$share['name']."|".$share['server']]= preg_replace("/^!/","",$share['server'])."://".$share['name']." - "._("group share"); 
1230         }else{
1231           $a_return[$share['name']."|".$share['server']]= $share['server']."://".$share['name']." on ".$share['mountPoint']." as ".$share['Username'];
1232         }
1233       }
1234       natcasesort($a_return);
1235     }
1236     return($a_return);
1237   }
1239   /* Generate ListBox frindly output for the definedhotplugs 
1240    * Possibly Add or remove an attribute here,
1241    */
1242   function printOutHotPlugDevices()
1243   {
1244     $a_return= array();
1245     if(is_array($this->gotoHotplugDevices)){
1246       foreach($this->gotoHotplugDevices as $key=>$device){
1247         $a_return[$key] = $device['name']." - ".$device['id'];
1248       }
1249     }
1250     return($a_return);
1251   }
1253   /* Generates ListBox frienly output of used printer devices 
1254    * Append ' - admin' if printer is used in admin mode
1255    */
1256   function printOutPrinterDevices()
1257   {
1258     $a_return = array();
1259     
1260     if($this->acl_is_readable("gotoPrinter")){
1262       if(is_array($this->gotoPrinter)){
1263         foreach($this->gotoPrinter as $printer){
1264           if($printer['mode'] == "admin"){
1265             $a_return[$printer['cn'][0]]= $printer['cn'][0]." - "._("Administrator");
1266           }else{
1267             $a_return[$printer['cn'][0]]= $printer['cn'][0]; 
1268           }
1269           if ($printer['cn'][0] == $this->gosaDefaultPrinter){
1270             $a_return[$printer['cn'][0]].=" - "._("Default printer");
1271           }
1272         }
1273       }
1274     }
1275     return($a_return);
1276   }
1279   function saveCopyDialog()
1280   {
1281     if(isset($_POST['cn'])){
1282       $this->cn = $_POST['cn'];
1283       $this->uid = $_POST['cn'];
1284     }
1285   }
1288   /* Generates ListBox frienly output of used logonscripts 
1289    */
1290   function printOutLogonScripts()
1291   {
1292     $a_return = array();
1293     if(is_array($this->gotoLogonScripts)){
1294       foreach($this->gotoLogonScripts as $script){
1295         $a_return[$script['LogonName']]= $script['LogonPriority']." - ".$script['LogonName']; 
1296       }
1297     }
1298     return($a_return);
1299   }
1302   /* Return plugin informations for acl handling 
1303 #FIXME these ACLs should work for groups too */ 
1304   function plInfo()
1305   {
1306     return (array("plShortName"     => _("Environment"),
1307           "plDescription"   => _("Environment settings"),         // Description
1308           "plSelfModify"    => TRUE,                              
1309           "plDepends"       => array("user", "posixAccount"),     // This plugin depends on 
1310           "plPriority"      => 3,                                 // Position in tabs 
1311           "plSection"     => array("personal" => _("My account")),
1312           "plCategory"    => array("users",
1313                                    "groups"),
1314           "plOptions"       => array("resolution_hook" => array("type" => "string",
1315               "description" => _("Command to extend the list of possible screen resolutions"))),
1317           "plProvidedAcls"  => array(
1319             "gotoProfileFlagL"    => _("Resolution changeable during session") ,
1320             "gotoProfileFlagC"    => _("Cache profile localy") ,
1322             "gotoProfileQuota"    => _("Profile quota") ,
1323             "gotoProfileServer"   => _("Profile server") ,
1325             "gotoXResolution"     => _("Resolution") ,
1326             "gotoKioskProfile"    => _("Kiosk profile") ,
1328             "gosaDefaultPrinter"  => _("Default printer") ,
1329             "gotoLogonScript"     => _("Logon script") ,
1330             "gotoHotplugDevice"   => _("Hotplug devices"),
1331             "gotoShare"           => _("Shares"))
1332             ));
1333   }
1336 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
1337 ?>