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