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