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