Code

61fc54a528bf0fa4f4d410a56d098fa6d317df41
[gosa.git] / gosa-core / plugins / personal / samba / class_sambaAccount.inc
1 <?php
2 /*
3    This code is part of GOsa (https://gosa.gonicus.de)
4    Copyright (C) 2004-2005 Cajus Pollmeier
6    This program is free software; you can redistribute it and/or modify
7    it under the terms of the GNU General Public License as published by
8    the Free Software Foundation; either version 2 of the License, or
9    (at your option) any later version.
11    This program is distributed in the hope that it will be useful,
12    but WITHOUT ANY WARRANTY; without even the implied warranty of
13    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14    GNU General Public License for more details.
16    You should have received a copy of the GNU General Public License
17    along with this program; if not, write to the Free Software
18    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19  */
21 class sambaAccount extends plugin
22 {
23   /* Definitions */
24   var $plHeadline= "Samba";
25   var $plDescription= "This does something";
26   var $view_logged = FALSE;
28   /* CLI vars */
29   var $cli_summary= "Manage users samba account";
30   var $cli_description= "Some longer text\nfor help";
31   var $cli_parameters= array("eins" => "Eins ist toll", "zwei" => "Zwei ist noch besser");
33   /* Switch for Samba version */
34   var $samba3= FALSE;
35   var $uidNumber= 65535;
36   var $gidNumber= 65535;
38   /* Samba 2 attributes */
39   var $pwdLastSet= "0";
40   var $logonTime= "0";
41   var $logoffTime= "2147483647";
42   var $kickoffTime= "2147483647";
43   var $pwdCanChange= "0";
44   var $pwdMustChange= "0";
45   var $password_expires= 0;
46   var $acctFlags= "[UX        ]";
47   var $smbHome= "";
48   var $homeDrive= "";
49   var $scriptPath= "";
50   var $profilePath= "";
51   var $rid= "";
52   var $primaryGroupID= "";
54   /* Samba 3 attributes */
55   var $SID= "";
56   var $ridBase= 0;
57   var $sambaSID= "";
58   var $sambaPwdLastSet= "0";
59   var $sambaLogonTime= "0";
60   var $sambaLogoffTime= "2147483647";
61   var $sambaKickoffTime= "2147483647";
62   var $sambaPwdCanChange= "";
63   var $sambaPwdMustChange= "0";
64   var $sambaAcctFlags= "[UX        ]";
65   var $sambaHomePath= "";
66   var $sambaHomeDrive= "";
67   var $sambaLogonScript= "";
68   var $sambaProfilePath= "";
69   var $sambaPrimaryGroupSID= "";
70   var $sambaDomainName= "";
71   var $sambaUserWorkstations= "";
72   var $sambaBadPasswordCount= "";
73   var $sambaBadPasswordTime= "";
74   var $sambaPasswordHistory= "";
75   var $sambaLogonHours= "";
76   var $orig_sambaDomainName= "";
77   var $sambaMungedDial= "";
78   var $mungedObject;
80   /* Helper */
81   var $show_ws_dialog= FALSE;
82   var $logon_time_set= 0;
83   var $logoff_time_set= 0;
84   var $kickoff_time_set= 0;
86   /* attribute list for save action */
87   var $ctxattributes= array();
88   var $attributes= array();
89   var $objectclasses= array();
90   
91   var $uid= "";
92   var $CopyPasteVars = array("kickoff_time_set","logoff_time_set","logon_time_set","mungedObject","orig_sambaDomainName");
94   var $multiple_support = TRUE;
96   function sambaAccount (&$config, $dn= NULL)
97   {
98     /* Load attributes depending on the samba version */
99     $this->samba3= ($config->current['SAMBAVERSION'] == 3);
101     if ($this->samba3){
102       $this->attributes= array ("sambaSID", "sambaPwdLastSet", "sambaLogonTime",
103           "sambaLogoffTime", "sambaKickoffTime", "sambaPwdCanChange",
104           "sambaPwdMustChange", "sambaAcctFlags", "uid", "sambaMungedDial",
105           "sambaHomePath", "sambaHomeDrive", "sambaLogonScript",
106           "sambaProfilePath", "sambaPrimaryGroupSID", "sambaDomainName",
107           "sambaUserWorkstations", "sambaPasswordHistory",
108           "sambaLogonHours", "sambaBadPasswordTime",
109           "sambaBadPasswordCount");
110       $this->objectclasses= array ("sambaSamAccount");
111       $this->mungedObject= new sambaMungedDial;
112       $this->ctxattributes= $this->mungedObject->ctxattributes;
113     } else {
114       $this->attributes= array ("pwdLastSet", "logonTime", "logoffTime", "kickoffTime",
115           "pwdCanChange", "pwdMustChange", "acctFlags", "profilePath", "uid",
116           "smbHome", "homeDrive", "scriptPath", "rid", "primaryGroupID");
117       $this->objectclasses= array ("sambaAccount");
118     }
120     plugin::plugin ($config, $dn);
122     /* Setting uid to default */
123     if(isset($this->attrs['uid'][0])){
124       $this->uid = $this->attrs['uid'][0];
125     }
127     /* Get samba Domain in case of samba 3 */
128     if ($this->samba3 && $this->sambaSID != ""){
129       $this->SID= preg_replace ("/-[^-]+$/", "", $this->sambaSID);
130       $ldap= $this->config->get_ldap_link();
131       $ldap->cd($this->config->current['BASE']);
132       $ldap->search ("(&(objectClass=sambaDomain)(sambaSID=$this->SID))",array("sambaAlgorithmicRidBase","sambaDomainName"));
133       if ($ldap->count() != 0){
134         $attrs= $ldap->fetch();
135         $this->ridBase= $attrs['sambaAlgorithmicRidBase'][0];
136         if ($this->sambaDomainName == ""){
137           $this->sambaDomainName= $attrs['sambaDomainName'][0];
138         }
139       } else {
140         if ($this->sambaDomainName == ""){
141           $this->sambaDomainName= "DEFAULT";
142         }
143         $this->ridBase= $this->config->current['RIDBASE'];
144         $this->SID= $this->config->current['SID'];
145       }
147       /* Save in order to compare later on */
148       $this->orig_sambaDomainName= $this->sambaDomainName;
149     }
151     /* Fill mungedDial field */
152     if ($this->samba3 && isset($this->attrs['sambaMungedDial'])){
153       $this->mungedObject->load($this->sambaMungedDial);
154     }
156     /* Password expiery */
157     if(isset($this->attrs['sambaPwdMustChange']) &&
158         $this->attrs['sambaPwdMustChange'][0] != 0){
159       $this->password_expires= 1;
160     }
162     if(isset($this->attrs['sambaLogonTime']) && ! (
163         $this->attrs['sambaLogonTime'][0] == 0 ||
164         $this->attrs['sambaLogonTime'][0] == 2147483647
165       )){
166       $this->logon_time_set= 1;
167     }
168     if(isset($this->attrs['sambaLogoffTime']) && ! (
169         $this->attrs['sambaLogoffTime'][0] == 0 ||
170         $this->attrs['sambaLogoffTime'][0] == 2147483647
171       )){
172       $this->logoff_time_set= 1;
173     }
174     
175     /* Account expiery */
176     if(isset($this->attrs['sambaKickoffTime']) && ! (
177         $this->attrs['sambaKickoffTime'][0] == 0 ||
178         $this->attrs['sambaKickoffTime'][0] == 2147483647
179       )){
180       $this->kickoff_time_set= 1;
181     }
183     /* Get global filter config */
184     if (!is_global("sambafilter")){
185       $ui= get_userinfo();
186       $base= get_base_from_people($ui->dn);
187       $sambafilter= array( "depselect" => $base, "regex" => "*");
188       register_global("sambafilter", $sambafilter);
189     }
191     /* Save initial account state */
192     $this->initially_was_account= $this->is_account;
193   }
195   function execute()
196   {
197     /* Call parent execute */
198     plugin::execute();
200     /* Log view */
201     if($this->is_account && !$this->view_logged){
202       $this->view_logged = TRUE;
203       new log("view","users/".get_class($this),$this->dn);
204     }
206     /* Do we need to flip is_account state? */
207     if (isset($_POST['modify_state'])){
208       $this->is_account= !$this->is_account;
209     }
210     /* Do we represent a valid account? */
211     if (!$this->is_account && $this->parent === NULL){
212       $display= "<img alt=\"\"src=\"images/stop.png\" align=\"middle\">&nbsp;<b>".
213         _("This account has no samba extensions.")."</b>";
214       $display.= back_to_main();
215       return ($display);
216     }
218     $display ="";
219     if(!$this->multiple_support_active){
221       /* Show tab dialog headers */
222       $display= "";
223       if ($this->parent !== NULL){
224         if ($this->is_account){
225           $display= $this->show_disable_header(_("Remove samba account"),
226               _("This account has samba features enabled. You can disable them by clicking below."));
227         } else {
228           $obj= $this->parent->by_object['posixAccount'];
230           /* Samba3 dependency on posix accounts are enabled
231              in the moment, because I need to rely on unique
232              uidNumbers. There'll be a better solution later
233              on. */
234           if ($obj->is_account){
235             $display= $this->show_enable_header(_("Create samba account"),
236                 _("This account has samba features disabled. You can enable them by clicking below."));
237           } else {
238             $display= $this->show_enable_header(_("Create samba account"),
239                 _("This account has samba features disabled. Posix features are needed for samba accounts, enable them first."), TRUE);
240           }
241           return ($display);
242         }
243       }
244     }
246     $SkipWrite = (!isset($this->parent) || !$this->parent) && !isset($_SESSION['edit']);
248     /* Open Samaba Logong hours dialog */
249     if(isset($_POST['SetSambaLogonHours']) && $this->samba3 && $this->acl_is_writeable("sambaLogonHours")){
250       $this->dialog = new sambaLogonHours($this->config,$this->dn,$this->sambaLogonHours);
251     }
253     /* Cancel dialog */
254     if(isset($_POST['cancel_logonHours'])){
255       $this->dialog = FALSE;
256     }
258     /* Save selected logon hours */
259     if(isset($_POST['save_logonHours'])){
260       $this->dialog->save_object();
261       if($this->acl_is_writeable("sambaLogonHours")){
262         $this->sambaLogonHours = $this->dialog->save();
263       }
264       $this->dialog = FALSE;
265     }
267     /* Display dialog */
268     if((isset($this->dialog)) && (is_object($this->dialog))){
269       $this->dialog->save_object();
270       return($this->dialog->execute());
271     }
274     /* Prepare templating */
275     $smarty= get_smarty();
277     $tmp = $this->plInfo();
278     foreach($tmp['plProvidedAcls'] as $var => $rest){
279       $smarty->assign($var."ACL",$this->getacl($var,$SkipWrite));
280     }
282     if ($this->sambaPwdMustChange=="0"){
283       $date= getdate();
284     } else {
285       $date= getdate($this->sambaPwdMustChange);
286     }
288     if ($this->sambaLogonTime=="2147483647" || $this->sambaLogonTime=="0"){
289       $sambaLogonTime_date= getdate();
290     } else {
291       $sambaLogonTime_date= getdate($this->sambaLogonTime);
292     }
293     
294     if ($this->sambaLogoffTime=="2147483647" || $this->sambaLogoffTime=="0"){
295       $sambaLogoffTime_date= getdate();
296     } else {
297       $sambaLogoffTime_date= getdate($this->sambaLogoffTime);
298     }
299     
300     if ($this->sambaKickoffTime=="2147483647" || $this->sambaKickoffTime=="0"){
301       $sambaKickoffTime_date= getdate();
302     } else {
303       $sambaKickoffTime_date= getdate($this->sambaKickoffTime);
304     }
306     /* Remove user workstations? */
307     if (isset($_POST["delete_ws"]) && isset($_POST['workstation_list'])){
309       if($this->acl_is_writeable("sambaUserWorkstations",$SkipWrite)){
311         $tmp= $this->sambaUserWorkstations;
312         foreach($_POST['workstation_list'] as $name){
313           $tmp= preg_replace("/$name/", '', $tmp);
314           $this->is_modified= TRUE;
315         }
316         $tmp= preg_replace('/,+/', ',', $tmp);
317         $this->sambaUserWorkstations= trim($tmp, ',');
318       }
319     }
321     /* Add user workstation? */
322     if (isset($_POST["add_ws"])){
323       if($this->acl_is_writeable("sambaUserWorkstations",$SkipWrite)){
324         $this->show_ws_dialog= TRUE;
325         $this->dialog= TRUE;
326       }
327     }
329     /* Add user workstation finished? */
330     if (isset($_POST["add_ws_finish"]) || isset($_POST["add_ws_cancel"])){
331       $this->show_ws_dialog= FALSE;
332       $this->dialog= FALSE;
333     }
335     /* Add user workstation? */
336     if (isset($_POST["add_ws_finish"]) && isset($_POST['wslist'])){
337       $tmp= $this->sambaUserWorkstations;
338       foreach($_POST['wslist'] as $ws){
339         $tmp.= ",$ws";
340       }
341       $tmp= preg_replace('/,+/', ',', $tmp);
342       $this->sambaUserWorkstations= trim($tmp, ',');
343       $this->is_modified= TRUE;
344     }
346     /* Show ws dialog */
347     if ($this->show_ws_dialog){
349       /* Save data */
350       $sambafilter= get_global("sambafilter");
351       foreach( array("depselect", "regex") as $type){
352         if (isset($_POST[$type])){
353           $sambafilter[$type]= $_POST[$type];
354         }
355       }
356       if (isset($_GET['search'])){
357         $s= mb_substr($_GET['search'], 0, 1, "UTF8")."*";
358         if ($s == "**"){
359           $s= "*";
360         }
361         $sambafilter['regex']= $s;
362       }
363       register_global("sambafilter", $sambafilter);
365       /* Get workstation list */
366       $exclude= "";
367       foreach(split(',', $this->sambaUserWorkstations) as $ws){
368         $exclude.= "(cn=$ws$)";
369       }
370       if ($exclude != ""){
371         $exclude= "(!(|$exclude))";
372       }
373       $regex= $sambafilter['regex'];
374       $filter= "(&(objectClass=sambaSAMAccount)$exclude(uid=*$)(|(uid=$regex)(cn=$regex)))";
375       $res= get_list($filter, "winworkstation", $sambafilter['depselect'], array("uid"), GL_SUBSEARCH | GL_SIZELIMIT);
376         
377       $wslist= array();
378       foreach ($res as $attrs){
379         $wslist[]= preg_replace('/\$/', '', $attrs['uid'][0]);
380       }
381       asort($wslist);
383       $smarty->assign("search_image", get_template_path('images/search.png'));
384       $smarty->assign("launchimage", get_template_path('images/small_filter.png'));
385       $smarty->assign("tree_image", get_template_path('images/tree.png'));
386       $smarty->assign("deplist", $this->config->idepartments);
387       $smarty->assign("alphabet", generate_alphabet());
388       foreach( array("depselect", "regex") as $type){
389         $smarty->assign("$type", $sambafilter[$type]);
390       }
391       $smarty->assign("hint", print_sizelimit_warning());
392       $smarty->assign("wslist", $wslist);
393       $smarty->assign("apply", apply_filter());
394       $display= $smarty->fetch (get_template_path('samba3_workstations.tpl', TRUE,
395                                 dirname(__FILE__)));
396       return ($display);
397     }
399     /* Fill calendar */
400     $days= array();
401     for($d= 1; $d<32; $d++){
402       $days[]= $d;
403     }
404     $years= array();
405     for($y= $date['year']-4; $y<$date['year']+4; $y++){
406       $years[]= $y;
407     }
408     $months= array(_("January"), _("February"), _("March"), _("April"),
409         _("May"), _("June"), _("July"), _("August"), _("September"),
410         _("October"), _("November"), _("December"));
411     $smarty->assign("day", $date["mday"]);
412     $smarty->assign("days", $days);
413     $smarty->assign("months", $months);
414     $smarty->assign("month", $date["mon"]-1);
415     $smarty->assign("years", $years);
416     $smarty->assign("year", $date["year"]);
417     
418     $sambaLogonTime_days= array();
419     for($d= 1; $d<32; $d++){
420       $sambaLogonTime_days[]= $d;
421     }
422     $sambaLogonTime_years= array();
423     for($y= $date['year']-4; $y<$date['year']+4; $y++){
424       $sambaLogonTime_years[]= $y;
425     }
426     $sambaLogonTime_months= array(_("January"), _("February"), _("March"), _("April"),
427         _("May"), _("June"), _("July"), _("August"), _("September"),
428         _("October"), _("November"), _("December"));
429     $smarty->assign("sambaLogonTime_day", $sambaLogonTime_date["mday"]);
430     $smarty->assign("sambaLogonTime_days", $sambaLogonTime_days);
431     $smarty->assign("sambaLogonTime_months", $sambaLogonTime_months);
432     $smarty->assign("sambaLogonTime_month", $sambaLogonTime_date["mon"]-1);
433     $smarty->assign("sambaLogonTime_years", $sambaLogonTime_years);
434     $smarty->assign("sambaLogonTime_year", $sambaLogonTime_date["year"]);
435     
436     $sambaLogoffTime_days= array();
437     for($d= 1; $d<32; $d++){
438       $sambaLogoffTime_days[]= $d;
439     }
440     $sambaLogoffTime_years= array();
441     for($y= $date['year']-4; $y<$date['year']+4; $y++){
442       $sambaLogoffTime_years[]= $y;
443     }
444     $sambaLogoffTime_months= array(_("January"), _("February"), _("March"), _("April"),
445         _("May"), _("June"), _("July"), _("August"), _("September"),
446         _("October"), _("November"), _("December"));
447     $smarty->assign("sambaLogoffTime_day", $sambaLogoffTime_date["mday"]);
448     $smarty->assign("sambaLogoffTime_days", $sambaLogoffTime_days);
449     $smarty->assign("sambaLogoffTime_months", $sambaLogoffTime_months);
450     $smarty->assign("sambaLogoffTime_month", $sambaLogoffTime_date["mon"]-1);
451     $smarty->assign("sambaLogoffTime_years", $sambaLogoffTime_years);
452     $smarty->assign("sambaLogoffTime_year", $sambaLogoffTime_date["year"]);
453     
454     $sambaKickoffTime_days= array();
455     for($d= 1; $d<32; $d++){
456       $sambaKickoffTime_days[]= $d;
457     }
458     $sambaKickoffTime_years= array();
459     for($y= $date['year']-4; $y<$date['year']+4; $y++){
460       $sambaKickoffTime_years[]= $y;
461     }
462     $sambaKickoffTime_months= array(_("January"), _("February"), _("March"), _("April"),
463         _("May"), _("June"), _("July"), _("August"), _("September"),
464         _("October"), _("November"), _("December"));
465     //$smarty->assign("sambaKickoffTime_day", $sambaKickoffTime_date["mday"]-1);
466     $smarty->assign("sambaKickoffTime_day", $sambaKickoffTime_date["mday"]); // hickert
467     $smarty->assign("sambaKickoffTime_days", $sambaKickoffTime_days);
468     $smarty->assign("sambaKickoffTime_months", $sambaKickoffTime_months);
469     $smarty->assign("sambaKickoffTime_month", $sambaKickoffTime_date["mon"]-1);
470     $smarty->assign("sambaKickoffTime_years", $sambaKickoffTime_years);
471     $smarty->assign("sambaKickoffTime_year", $sambaKickoffTime_date["year"]);
472      
473     /* Fill boxes */
474     if ($this->samba3){
475       $domains= array();
476       foreach($this->config->data['SERVERS']['SAMBA'] as $name => $content){
477         $domains[]= $name;
478       }
479       $smarty->assign("domains", $domains);
480     }
481     $letters= array();
482     for ($i= 68; $i<91; $i++){
483       $letters[]= chr($i).":";
484     }
485     $smarty->assign("drives", $letters);
487     /* Fill terminal server settings */
488     if ($this->samba3){
489       foreach ($this->ctxattributes as $attr){
490         /* Fill common attributes */
491         if (isset($this->mungedObject->ctx[$attr])){
492           $smarty->assign("$attr", $this->mungedObject->ctx[$attr]);
493           // Set field  to blank if value is 0
494           if(in_array($attr, array("CtxMaxConnectionTime", "CtxMaxDisconnectionTime", "CtxMaxIdleTime"))) {
495             if($this->mungedObject->ctx[$attr] == 0) {
496               $smarty->assign("$attr", "");
497             }
498           }
499         } else {
500           $smarty->assign("$attr", "");
501         }
502       }
504       /* Assign enum values for preset items */
505       $shadowModeVals= array( "0" => _("disabled"),
506           "1" => _("input on, notify on"),
507           "2" => _("input on, notify off"),
508           "3" => _("input off, notify on"),
509           "4" => _("input off, nofify off"));
511       $brokenConnModeVals= array(       "0" => _("disconnect"),
512           "1" => _("reset"));
514       $reConnModeVals= array( "0" => _("from any client"),
515           "1" => _("from previous client only"));
517       /* Fill preset items */
518       $smarty->assign("shadow", $shadowModeVals);
519       $smarty->assign("brokenconn", $brokenConnModeVals);
520       $smarty->assign("reconn", $reConnModeVals);
522       /* Fill preset items with values */
523       $smarty->assign("shadowmode", $this->mungedObject->getShadow());
524       $smarty->assign("brokenconnmode", $this->mungedObject->getBrokenConn());
525       $smarty->assign("reconnmode", $this->mungedObject->getReConn());
527       if($_SESSION['js']){
528         /* Set form elements to disabled/enable state */
529         $smarty->assign("tsloginstate", $this->mungedObject->getTsLogin()?"":"disabled");
531         $smarty->assign("inheritstate", "");
532         if($this->acl_is_writeable("AllowLoginOnTerminalServer",$SkipWrite)){
533           $smarty->assign("inheritstate", $this->mungedObject->getInheritMode()?"disabled":"");
534         }
535   
537   
538       }else{
539         $smarty->assign("tsloginstate", "");
540         $smarty->assign("inheritstate", "");
541       }      
543       /* Set checkboxes to checked or unchecked state */
544       $smarty->assign("tslogin", $this->mungedObject->getTsLogin()?"checked":"");
545       $smarty->assign("inherit", $this->mungedObject->getInheritMode()?"checked":"");
546       $smarty->assign("connectclientdrives",
547                       $this->mungedObject->getConnectClientDrives()?"checked":"");
548       $smarty->assign("connectclientprinters",
549                       $this->mungedObject->getConnectClientPrinters()?"checked":"");
550       $smarty->assign("defaultprinter",
551                       $this->mungedObject->getDefaultPrinter()?"checked":"");
552       $smarty->assign("CtxMaxConnectionTimeF",
553                       $this->mungedObject->getCtxMaxConnectionTimeF()?"checked":"");
554       $smarty->assign("CtxMaxDisconnectionTimeF",
555                       $this->mungedObject->getCtxMaxDisconnectionTimeF()?"checked":"");
556       $smarty->assign("CtxMaxIdleTimeF",
557                       $this->mungedObject->getCtxMaxIdleTimeF()?"checked":"");
559       /* Fill sambaUserWorkstations */
560       $ws= split(",", $this->sambaUserWorkstations);
561       sort($ws);
562       
563       /* Tidy checks for empty option, and smarty will produce one if array[0]="" */
564       if(($ws[0]=="")&&(count($ws)==1)) $ws=array();
567       $smarty->assign("workstations", $ws);
568     }
570     /* Variables */
571     foreach($this->attributes as $val){
572       $smarty->assign("$val", $this->$val);
573     }
575     /* 'sambaAcctFlags' checkboxes */
576     /* Check for 'lock-account'-flag: 'D' or 'L' */
577     if (is_integer(strpos($this->sambaAcctFlags, "D")) ||
578         is_integer(strpos($this->sambaAcctFlags, "L"))) {
579         $smarty->assign("flagsD", "checked");
580     } else {
581         $smarty->assign("flagsD", "");
582     }
583     
584     /* Check for no_password_required flag 'N' */
585     if (is_integer(strpos($this->sambaAcctFlags, "N"))) {
586         $smarty->assign("flagsN", "checked");
587     } else {
588         $smarty->assign("flagsN", "");
589     }
591     if($this->samba3){
592       if ($this->sambaPwdCanChange=="1"){
593         $smarty->assign("flagsP", "checked");
594       } else {
595         $smarty->assign("flagsP", "");
596       }
597     }else{
598       if ($this->pwdCanChange=="1"){
599         $smarty->assign("flagsP", "checked");
600       } else {
601         $smarty->assign("flagsP", "");
602       }
603     }
605     if ($this->password_expires=="1"){
606       $smarty->assign("flagsC", "checked");
607     } else {
608       $smarty->assign("flagsC", "");
609     }
610     if ($this->logon_time_set=="1"){
611       $smarty->assign("flagsT", "checked");
612     } else {
613       $smarty->assign("flagsT", "");
614     }
615     if ($this->logoff_time_set=="1"){
616       $smarty->assign("flagsO", "checked");
617     } else {
618       $smarty->assign("flagsO", "");
619     }
620     if ($this->kickoff_time_set=="1"){
621       $smarty->assign("flagsK", "checked");
622     } else {
623       $smarty->assign("flagsK", "");
624     }
625    
627     /* In case of javascript, disable some fields on demand */
628     if ($this->samba3){
629       foreach($this->mungedObject->getOnDemandFlags() as $key => $value) {
630         $smarty->assign("$key", "$value");
631       }
632     }
635     foreach($this->attributes as $attr){
636       if(in_array($attr,$this->multi_boxes)){
637         $smarty->assign("use_".$attr,TRUE);
638       }else{
639         $smarty->assign("use_".$attr,FALSE);
640       }
641     }
642     foreach(array("allow_pwchange","tslogin","CtxWFHomeDir","CtxWFHomeDirDrive","CtxWFProfilePath",
643           "inherit","CtxWorkDirectory","CtxInitialProgram","CtxMaxConnectionTimeF","CtxMaxConnectionTime","CtxMaxDisconnectionTimeF",
644           "CtxMaxDisconnectionTime","CtxMaxIdleTimeF","CtxMaxIdleTime","connectclientdrives",
645           "onnectclientprinters","defaultprinter","shadow","brokenconn",
646           "reconn","allow_pwchange","connectclientprinters","no_password_required","temporary_disable", 
647           "password_expires","logon_time_set","logoff_time_set","kickoff_time_set","SetSambaLogonHours",
648           "workstation_list") as $attr){
649       if(in_array($attr,$this->multi_boxes)){
650         $smarty->assign("use_".$attr,TRUE);
651       }else{
652         $smarty->assign("use_".$attr,FALSE);
653       }
654     }
656     /* Show main page */
657     $smarty->assign("multiple_support",$this->multiple_support_active);
658     if ($this->samba3){
659       $display.= $smarty->fetch (get_template_path('samba3.tpl', TRUE, dirname(__FILE__)));
660     } else {
661       $display.= $smarty->fetch (get_template_path('samba2.tpl', TRUE, dirname(__FILE__)));
662     }
664     return ($display);
665   }
667   function remove_from_parent()
668   {
669     /* Cancel if there's nothing to do here */
670    if (!$this->initially_was_account){
671      return;
672    }
673     
674     /* include global link_info */
675     $ldap= $this->config->get_ldap_link();
677     plugin::remove_from_parent();
679     /* Keep uid attribute for gosaAccount */
680     unset($this->attrs['uid']);
681     unset($this->attrs['uidNumber']);
682     unset($this->attrs['gidNumber']);
684     /* Remove objectClass for sambaIdmapEntry */
685     $tmp= array();
686     for ($i= 0; $i<count($this->attrs["objectClass"]); $i++){
687       if ($this->attrs['objectClass'][$i] != 'sambaIdmapEntry'){
688         $tmp[]= $this->attrs['objectClass'][$i];
689       }
690     }
691     $this->attrs['objectClass']= $tmp;
693     @DEBUG (DEBUG_LDAP, __LINE__, __FUNCTION__, __FILE__,
694         $this->attributes, "Save");
695     $ldap->cd($this->dn);
696     $this->cleanup();
697     $ldap->modify ($this->attrs); 
699     new log("remove","users/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
701     show_ldap_error($ldap->get_error(), sprintf(_("Removing of user/samba account with dn '%s' failed."),$this->dn));
703     /* Optionally execute a command after we're done */
704     $this->handle_post_events("remove", array("uid" => $this->uid));
705   }
708   /* Check for input problems */
709   function check()
710   {
711     /* Call common method to give check the hook */
712     $message= plugin::check();
714     if ($this->samba3){
716       /* Strings */
717       foreach (array( "sambaHomePath" => _("Home directory"),
718             "sambaProfilePath" => _("Profile path")) as $key => $val){
719         if (!$this->mungedObject->is_samba_path($this->$key)){
720           $message[]= sprintf(_("The value specified as '%s' contains invalid characters!"), $val);
721         }
722       }
724       /* Numeric values */
725       foreach (array(   "CtxMaxConnectionTime" => _("Connection"),
726             "CtxMaxDisconnectionTime" => _("Disconnection"),
727             "CtxMaxIdleTime" => _("IDLE")) as $key => $val){
729         if (isset($this->mungedObject->ctx[$key]) && !is_id($this->mungedObject->ctx[$key]) && $val != 0){
730           $message[]= sprintf(_("The timeout property '%s' is checked and contains invalid or no characters!"), $val);
731         }
732       }
734       /* Too many workstations? Windows usrmgr only supports eight */
735       if (substr_count($this->sambaUserWorkstations, ",") >= 8){
736         $message[]= _("The windows user manager only allows eight clients. You've specified more than eight.");
737       }
738     }
740     return ($message);
741   }
744   /* Save data to object */
745   function save_object()
746   {
748     $SkipWrite = (!isset($this->parent) || !$this->parent) && !isset($_SESSION['edit']);
750     /* We only care if we are on the sambaTab... */
751     if (isset($_POST['sambaTab'])){
752       plugin::save_object();
754       /* Take care about access options */
755       if ($this->acl_is_writeable("sambaAcctFlagsL",$SkipWrite) || ($this->acl_is_writeable("sambaAcctFlagsN",$SkipWrite))){
756         if ($this->samba3){
757           $attrname= "sambaPwdCanChange";
758         } else {
759           $attrname= "pwdCanChange";
760         }
761         if (isset($_POST["allow_pwchange"]) && $_POST["allow_pwchange"] == 1){
762           $tmp= 1;
763         } else {
764           $tmp= 0;
765         }
766         if ($this->$attrname != $tmp){
767           $this->is_modified= TRUE;
768         }
769         $this->pwdCanChange= $tmp;
770         $this->sambaPwdCanChange= $tmp;
771       }
772       $tmp= "UX";
773       if (isset($_POST["no_password_required"])){
774         if ($_POST["no_password_required"] == 1){
775           $tmp.= "N";
776         }
777       }
778       if (isset($_POST["password_expires"])){
779         if ($_POST["password_expires"] == 1){
780           $this->password_expires= 1;
781         }
782       } else {
783         $this->password_expires= 0;
784       }
785       if (isset($_POST["temporary_disable"])){
786         if ($_POST["temporary_disable"] == 1){
787           if (is_integer(strpos($this->sambaAcctFlags, "L"))) {
788             $tmp.= "L";
789           } else {
790             $tmp.= "D";
791           }
792         }
793       }
794       if (isset($_POST["logon_time_set"])){
795         if ($_POST["logon_time_set"] == 1){
796           $this->logon_time_set= 1;
797         }
798       } else {
799         $this->logon_time_set= 0;
800       }
801       if (isset($_POST["logoff_time_set"])){
802         if ($_POST["logoff_time_set"] == 1){
803           $this->logoff_time_set= 1;
804         }
805       } else {
806         $this->logoff_time_set= 0;
807       }
808       if (isset($_POST["kickoff_time_set"])){
809         if ($_POST["kickoff_time_set"] == 1){
810           $this->kickoff_time_set= 1;
811         }
812       } else {
813         $this->kickoff_time_set= 0;
814       }
815       
816       $fill= "";
817       for ($i= strlen($tmp); $i<12; $i++){
818         $fill.= " ";
819       }
821       $tmp= "[$tmp$fill]";
823       /* Only save if acl's are set */
824       if ($this->acl_is_writeable("sambaAcctFlagsL",$SkipWrite) || ($this->acl_is_writeable("sambaAcctFlagsN",$SkipWrite))){
825         if ($this->samba3){
826           $attrname= "sambaAcctFlags";
827         } else {
828           $attrname= "acctFlags";
829         }
830         if ($this->$attrname != $tmp){
831           $this->is_modified= TRUE;
832         }
833         $this->$attrname= $tmp;
834       }
836       /* Save sambaDomain attribute */
837       if ($this->acl_is_writeable("sambaDomainName",$SkipWrite) && $this->samba3 && isset ($_POST['sambaDomainName'],$SkipWrite)){
838         $this->sambaDomainName= validate($_POST['sambaDomainName']);
839       }
841       /* Save CTX values */
842       if ($this->samba3){
844         /* Save obvious values */
845         foreach($this->ctxattributes as $val){
846           if (isset($_POST[$val]) && $this->acl_is_writeable("AllowLoginOnTerminalServer",$SkipWrite)){
847             if (get_magic_quotes_gpc()) {
848               $this->mungedObject->ctx[$val]= stripcslashes(validate($_POST[$val]));
849             } else {
850               $this->mungedObject->ctx[$val]= validate($_POST[$val]);
851             }
852           }
853         }
855         /* Save checkbox states. */
856         $this->mungedObject->setTsLogin(!isset($_POST['tslogin'])
857                         && $this->acl_is_writeable("AllowLoginOnTerminalServer",$SkipWrite));
858         // Need to do some index checking to avoid messages like "index ... not found"
859         if(isset($_POST['brokenconn'])) {
860           $this->mungedObject->setBrokenConn($_POST['brokenconn'] == '1'
861                         && $this->acl_is_writeable("AllowLoginOnTerminalServer",$SkipWrite));
862         }
863         if(isset($_POST['reconn'])) {
864           $this->mungedObject->setReConn($_POST['reconn'] == '1'
865                         && $this->acl_is_writeable("AllowLoginOnTerminalServer",$SkipWrite));
866         }
867         $this->mungedObject->setInheritMode(isset($_POST['inherit'])
868                         && $this->acl_is_writeable("AllowLoginOnTerminalServer",$SkipWrite));
869         $this->mungedObject->setCtxMaxConnectionTimeF(!isset($_POST['CtxMaxConnectionTimeF'])
870                         && $this->acl_is_writeable("AllowLoginOnTerminalServer",$SkipWrite));
871         $this->mungedObject->setCtxMaxDisconnectionTimeF(
872                         !isset($_POST['CtxMaxDisconnectionTimeF']) 
873                         && $this->acl_is_writeable("AllowLoginOnTerminalServer",$SkipWrite));
874         $this->mungedObject->setCtxMaxIdleTimeF(!isset($_POST['CtxMaxIdleTimeF'])
875                         && $this->acl_is_writeable("AllowLoginOnTerminalServer",$SkipWrite));
876         $this->mungedObject->setConnectClientDrives(isset($_POST['connectclientdrives'])
877                         && $this->acl_is_writeable("AllowLoginOnTerminalServer",$SkipWrite));
878         $this->mungedObject->setConnectClientPrinters(isset($_POST['connectclientprinters'])  
879                         && $this->acl_is_writeable("AllowLoginOnTerminalServer",$SkipWrite));
880         $this->mungedObject->setDefaultPrinter(isset($_POST['defaultprinter'])
881                         && $this->acl_is_writeable("AllowLoginOnTerminalServer",$SkipWrite));
883         /* Save combo boxes. Takes two values */
884         if(isset($_POST['reconn'])) {
885           $this->mungedObject->setShadow(isset($_POST['shadow']) && $this->acl_is_writeable("AllowLoginOnTerminalServer",$SkipWrite),$_POST['shadow']);
886         }
888         /* Check for changes */
889         if ($this->sambaMungedDial != $this->mungedObject->getMunged()){
890           $this->is_modified= TRUE;
891         }
892       }
893     }
894   }
897   /* Save to LDAP */
898   function save()
899   {
900     /* Load uid and gid of this 'dn' */
901     $ldap= $this->config->get_ldap_link();
902     $ldap->cat($this->dn, array('uidNumber', 'gidNumber'));
903     $tmp= $ldap->fetch();
904     $this->uidNumber= $tmp['uidNumber'][0];
905     $this->gidNumber= $tmp['gidNumber'][0];
907     plugin::save();
909     /* Remove objectClass for sambaIdmapEntry */
910     $tmp= array();
911     for ($i= 0; $i<count($this->attrs["objectClass"]); $i++){
912       if ($this->attrs['objectClass'][$i] != 'sambaIdmapEntry'){
913         $tmp[]= $this->attrs['objectClass'][$i];
914       }
915     }
916     $this->attrs['objectClass']= $tmp;
918     /* Generate rid / primaryGroupId */
919     if ($this->samba3){
920       if (!isset($this->config->data['SERVERS']['SAMBA'][$this->sambaDomainName]['SID'])){
921         print_red (_("Warning: This account has an undefined samba SID assigned. The problem can not be fixed by GOsa!"));
922       } else {
923         $this->SID= $this->config->data['SERVERS']['SAMBA'][$this->sambaDomainName]['SID'];
924         $this->ridBase= $this->config->data['SERVERS']['SAMBA'][$this->sambaDomainName]['RIDBASE'];
925       }
927       /* Need to generate a new uniqe uid/gid combination? */
928       if ($this->sambaSID == "" || $this->orig_sambaDomainName != $this->sambaDomainName){
929         $uidNumber= $this->uidNumber;
930         while(TRUE){
931           $sid= $this->SID."-".($uidNumber*2 + $this->ridBase);
932           $ldap->cd($this->config->current['BASE']);
933           $ldap->search("(sambaSID=$sid)", array("sambaSID"));
934           if ($ldap->count() == 0){
935             break;
936           }
937           $uidNumber++;
938         }
939         $this->attrs['sambaSID']= $sid;
941         /* Check for users primary group */
942         $ldap->cd($this->config->current['BASE']);
943         $ldap->search("(&(objectClass=posixGroup)(gidNumber=".$this->gidNumber."))", array("cn"));
944         if ($ldap->count() != 1){
945           print_red(_("Warning: Can't identify users primary group - no conversion to a samba group possible!"));
946         } else {
947           $attrs= $ldap->fetch();
948           $g= new group($this->config, $ldap->getDN());
949           if ($g->sambaSID == ""){
950             $g->sambaDomainName= $this->sambaDomainName;
951             $g->smbgroup= TRUE;
952             $g->save ();
953           }
954           $this->attrs['sambaPrimaryGroupSID']= $g->sambaSID;
955         }
956       }
958       if ($this->sambaHomeDrive == ""){
959         $this->attrs["sambaHomeDrive"]= array();
960       }
962       /* Generate munged dial value */
963       $this->attrs["sambaMungedDial"]= $this->mungedObject->getMunged();
965       /* User wants me to fake the idMappings? This is useful for
966          making winbind resolve the user names in a reasonable amount
967          of time in combination with larger databases. */
968       if (isset($this->config->current['SAMBAIDMAPPING']) &&
969           preg_match('/true/i', $this->config->current['SAMBAIDMAPPING'])){
970         $this->attrs['objectClass'][]= "sambaIdmapEntry";
971       }
974       /* Password expiery */
975       if ($this->password_expires == "1"){
976         $this->attrs['sambaPwdMustChange']= $this->sambaPwdMustChange;
977       } else {
978         $this->attrs['sambaPwdMustChange']= array();
979       }
980       /* Make sure not to save zero in sambaPwdLastset */
981       if ($this->sambaPwdLastSet != "0"){
982         $this->attrs['sambaPwdLastSet']= $this->sambaPwdLastSet;
983       } else {
984         $this->attrs['sambaPwdLastSet']= array();
985       }
986       /* Account expiery */
987       if ($this->logon_time_set == "1"){
988         $this->attrs['sambaLogonTime']= $this->sambaLogonTime;
989       } else {
990         $this->attrs['sambaLogonTime']= array();
991       }
992       if ($this->logoff_time_set == "1"){
993         $this->attrs['sambaLogoffTime']= $this->sambaLogoffTime;
994       } else {
995         $this->attrs['sambaLogoffTime']= array();
996       }
997       if ($this->kickoff_time_set == "1"){
998         # Add one day in unixtime format to be compatible with usrmgr
999         //$this->attrs['sambaKickoffTime']= $this->sambaKickoffTime + 86400; 
1000         $this->attrs['sambaKickoffTime']= $this->sambaKickoffTime; //hickert 
1001       } else {
1002         $this->attrs['sambaKickoffTime']= array();
1003       }
1004     } else {
1005     /* Not samba3 */
1006       $this->attrs['rid']= $this->uidNumber*2 + 1000;
1007       $this->attrs['primaryGroupID']= $this->gidNumber*2 +1001;
1009       if ($this->homeDrive == ""){
1010         $this->attrs["homeDrive"]= array();
1011       }
1013       /* Password expiery */
1014       if ($this->password_expires == "1"){
1015         $this->attrs['pwdMustChange']= $this->pwdMustChange;
1016       } else {
1017         $this->attrs['pwdMustChange']= 2147483647;
1018       }
1019       /* Make sure not to save zero in pwdLastset */
1020       if ($this->pwdLastSet != "0"){
1021         $this->attrs['pwdLastSet']= $this->pwdLastSet;
1022       } else {
1023         $this->attrs['pwdLastSet']= array();
1024       }
1025       /* Account expiery */
1026       if ($this->logon_time_set == "1"){
1027         $this->attrs['logonTime']= $this->logonTime;
1028       } else {
1029         $this->attrs['logonTime']= array();
1030       }
1031       if ($this->logoff_time_set == "1"){
1032         $this->attrs['logoffTime']= $this->logoffTime;
1033       } else {
1034         $this->attrs['logoffTime']= array();
1035       }
1036       if ($this->kickoff_time_set == "1"){
1037         # Add one day in unixtime format to be compatible with usrmgr
1038         $this->attrs['kickoffTime']= $this->kickoffTime + 86400;
1039       } else {
1040         $this->attrs['kickoffTime']= array();
1041       }
1042     }
1044     /* Write back to ldap */
1045     $ldap->cd($this->dn);
1046     $this->cleanup();
1047     $ldap->modify ($this->attrs); 
1049     if($this->initially_was_account){
1050       new log("modify","users/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
1051     }else{
1052       new log("create","users/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
1053     }
1055     show_ldap_error($ldap->get_error(), sprintf(_("Saving of user/samba account with dn '%s' failed."),$this->dn));
1057     /* Optionally execute a command after we're done */
1058     if ($this->initially_was_account == $this->is_account){
1059       if ($this->is_modified){
1060         $this->handle_post_events("modify", array("uid" => $this->uid));
1061       }
1062     } else {
1063       $this->handle_post_events("add", array("uid" => $this->uid));
1064     }
1065   }
1068   /* Force password set, if this account doesn't have any samba passwords  */
1069   function password_change_needed()
1070   {
1071     if(!$this->initially_was_account && $this->is_account){
1072       $ldap = $this->config->get_ldap_link();
1073       $ldap->cat($this->dn,array("sambaLMPassword","sambaNTPassword"));
1074       $attrs = $ldap->fetch();
1075       if(!isset($attrs['sambaLMPassword']) || !isset($attrs['sambaNTPassword'])){
1076         return(TRUE);
1077       }
1078     }
1079     return(FALSE);
1080   }
1083   function adapt_from_template($dn)
1084   {
1085     plugin::adapt_from_template($dn);
1086     $this->sambaSID= "";
1087     $this->sambaPrimaryGroupSID= "";
1089       /* Fill mungedDial field */
1090     if ($this->samba3 && isset($this->attrs['sambaMungedDial'])){
1091       $this->mungedObject->load($this->sambaMungedDial);
1092     }
1094     /* Password expiery */
1095     if(isset($this->attrs['sambaPwdMustChange']) &&
1096         $this->attrs['sambaPwdMustChange'][0] != 0){
1097       $this->password_expires= 1;
1098     }
1100     if(isset($this->attrs['sambaLogonTime']) && ! (
1101         $this->attrs['sambaLogonTime'][0] == 0 ||
1102         $this->attrs['sambaLogonTime'][0] == 2147483647
1103       )){
1104       $this->logon_time_set= 1;
1105     }
1106     if(isset($this->attrs['sambaLogoffTime']) && ! (
1107         $this->attrs['sambaLogoffTime'][0] == 0 ||
1108         $this->attrs['sambaLogoffTime'][0] == 2147483647
1109       )){
1110       $this->logoff_time_set= 1;
1111     }
1113     /* Account expiery */
1114     if(isset($this->attrs['sambaKickoffTime']) && ! (
1115         $this->attrs['sambaKickoffTime'][0] == 0 ||
1116         $this->attrs['sambaKickoffTime'][0] == 2147483647
1117       )){
1118       $this->kickoff_time_set= 1;
1119     }
1121     /* Get global filter config */
1122     if (!is_global("sambafilter")){
1123       $ui= get_userinfo();
1124       $base= get_base_from_people($ui->dn);
1125       $sambafilter= array( "depselect" => $base, "regex" => "*");
1126       register_global("sambafilter", $sambafilter);
1127     }
1128   }
1130   
1131   static function plInfo()
1132   {
1133     return (array(
1134           "plShortName"     => _("Samba"),
1135           "plDescription"   => _("Samba settings"),
1136           "plSelfModify"    => TRUE,
1137           "plDepends"       => array("user"),
1138           "plPriority"      => 5,
1139           "plSection"     => array("personal" => _("My account")),
1140           "plCategory"    => array("users"),
1141           "plOptions"       => array(),
1143           "plProvidedAcls"  => array(
1144             "AllowLoginOnTerminalServer"  => _("Allow login on terminal server"),
1145             "InheritClientConfig"         => _("Inherit client config"),
1147             "sambaPwdCanChange"     => _("Allow user to change password") ,
1148             "sambaAcctFlagsN"            => _("Login from windows client requires no password"),
1149             "sambaAcctFlagsL"            => _("Lock samba account"),
1152             "sambaKickoffTime"      => _("Account expires") ,
1153             "sambaPwdMustChange"    => _("Password expires") ,
1155             "sambaLogonTime"        => _("Limit Logon Time") ,
1156             "sambaLogoffTime"       => _("Limit Logoff Time") ,
1157             "sambaLogonHours"       => _("Logon hours") ,
1159             "sambaHomePath"         => _("Generic home directory") ,
1160             "sambaHomeDrive"        => _("Generic samba home drive") ,
1161             "sambaLogonScript"      => _("Generic script path") ,
1162             "sambaProfilePath"      => _("Generic profile path") ,
1163             "sambaDomainName"       => _("Domain") ,
1164             "sambaUserWorkstations" => _("Allow connection from")))
1165               );
1166   }    
1168   function enable_multiple_support()
1169   {
1170     plugin::enable_multiple_support();
1171     if($this->samba3){
1172       $this->multiple_support_active = TRUE;
1173     }else{
1174       $this->multiple_support_active = FALSE;
1175     }
1176   } 
1178   function multiple_save_object()
1179   {
1180     $this->save_object();
1181     plugin::multiple_save_object();
1182     foreach(array("allow_pwchange","tslogin","CtxWFHomeDir","CtxWFHomeDirDrive","CtxWFProfilePath",
1183           "inherit","CtxWorkDirectory","CtxInitialProgram","CtxMaxConnectionTimeF","CtxMaxConnectionTime","CtxMaxDisconnectionTimeF",
1184           "CtxMaxDisconnectionTime","CtxMaxIdleTimeF","CtxMaxIdleTime","connectclientdrives",
1185           "onnectclientprinters","defaultprinter","shadow","brokenconn",
1186           "reconn","allow_pwchange","connectclientprinters","no_password_required","temporary_disable",
1187           "password_expires","logon_time_set","logoff_time_set","kickoff_time_set","SetSambaLogonHours",
1188           "workstation_list") as $attr){
1189       if(isset($_POST["use_".$attr])){
1190         $this->multi_boxes[] = $attr;
1191       }
1192     }
1193   }
1195   function multiple_execute()
1196   {
1197     return($this->execute());
1198   } 
1200   function get_multi_edit_values()
1201   {
1202     $ret = plugin::get_multi_edit_values();
1204     /* Terminal Server  */
1205     if(in_array("tslogin",$this->multi_boxes)){
1206       $ret['tslogin'] = $this->mungedObject->getTsLogin();
1207     }
1208     if(in_array("CtxWFHomeDirDrive",$this->multi_boxes)){
1209       $ret['CtxWFHomeDirDrive'] = $this->mungedObject->ctx['CtxWFHomeDirDrive'];
1210     }
1211     if(in_array("CtxWFHomeDir",$this->multi_boxes)){
1212       $ret['CtxWFHomeDir'] = $this->mungedObject->ctx['CtxWFHomeDir'];
1213     }
1214     if(in_array("CtxWFProfilePath",$this->multi_boxes)){
1215       $ret['CtxWFProfilePath'] = $this->mungedObject->ctx['CtxWFProfilePath'];
1216     }
1218     if(in_array("inherit",$this->multi_boxes)){
1219       $ret['inherit'] = $this->mungedObject->getInheritMode();
1220     }       
1221     if(in_array("CtxInitialProgram",$this->multi_boxes)){
1222       $ret['CtxInitialProgram'] = $this->mungedObject->ctx['CtxInitialProgram'];
1223     } 
1224     if(in_array("CtxWorkDirectory",$this->multi_boxes)){
1225       $ret['CtxWorkDirectory'] = $this->mungedObject->ctx['CtxWorkDirectory'];
1226     } 
1228     /* Time Limits. Be careful here, there are some negations  */
1229     if(in_array("CtxMaxConnectionTimeF",$this->multi_boxes)){
1230       $ret["CtxMaxConnectionTimeF"]   =  !$this->mungedObject->getCtxMaxConnectionTimeF();
1231       if(!$ret["CtxMaxConnectionTimeF"]){
1232         $ret["CtxMaxConnectionTime"]   =  $this->mungedObject->ctx['CtxMaxConnectionTime'];
1233       }
1234     }
1235     if(in_array("CtxMaxDisconnectionTimeF",$this->multi_boxes)){
1236       $ret["CtxMaxDisconnectionTimeF"]=  !$this->mungedObject->getCtxMaxDisconnectionTimeF();
1237       if(!$ret["CtxMaxDisconnectionTimeF"]){
1238         $ret["CtxMaxDisconnectionTime"]=  $this->mungedObject->ctx['CtxMaxDisconnectionTime'];
1239       }
1240     }
1241     if(in_array("CtxMaxIdleTimeF",$this->multi_boxes)){
1242       $ret["CtxMaxIdleTimeF"]         =  !$this->mungedObject->getCtxMaxIdleTimeF();
1243       if(!$ret["CtxMaxIdleTimeF"]){
1244         $ret["CtxMaxIdleTime"]         =  $this->mungedObject->ctx['CtxMaxIdleTime'];
1245       }
1246     }
1248     /* Client Devices */
1249     if(in_array("connectclientdrives",$this->multi_boxes)){
1250       $ret["connectclientdrives"]     =  $this->mungedObject->getConnectClientDrives();
1251     }
1252     if(in_array("connectclientprinters",$this->multi_boxes)){
1253       $ret["connectclientprinters"]   =  $this->mungedObject->getConnectClientPrinters();
1254     }
1255     if(in_array("defaultprinter",$this->multi_boxes)){
1256       $ret["defaultprinter"]          =  $this->mungedObject->getDefaultPrinter();
1257     }
1259     /* Misc */
1260     if(in_array("shadow",$this->multi_boxes)){
1261       $ret["shadow"]    =$this->mungedObject->getShadow();
1262     }
1263     if(in_array("brokenconn",$this->multi_boxes)){
1264       $ret["brokenconn"]=$this->mungedObject->getBrokenConn();
1265     }
1266     if(in_array("reconn",$this->multi_boxes)){
1267       $ret["reconn"]    =$this->mungedObject->getReConn();
1268     }
1270     print_a($ret);
1271     return($ret);
1272   }
1274   function set_multi_edit_values($values)
1275   {
1276     plugin::set_multi_edit_values($values);
1278     /* Enable disabled terminal login, this is inverted somehow */
1279     if(isset($values['tslogin']))   $this->mungedObject->setTsLogin(!$values['tslogin']);
1280   
1281     /* Imherit client configuration */
1282     if(isset($values['inherit']))   $this->mungedObject->setInheritMode($values['inherit']);
1283   
1284     /* Get all ctx values posted */
1285     $ctx = array("CtxWFHomeDirDrive","CtxWFHomeDir","CtxWFProfilePath","CtxInitialProgram","CtxWorkDirectory",
1286                  "CtxMaxConnectionTime","CtxMaxDisconnectionTime","CtxMaxIdleTime");
1287     foreach($ctx as $attr){
1288       if(isset($values[$attr])){
1289         $this->mungedObject->ctx[$attr] = $values[$attr] ;
1290       }
1291     }
1293     if(isset($values['CtxMaxConnectionTimeF']))   $this->mungedObject->setCtxMaxConnectionTimeF($values['CtxMaxConnectionTimeF']);
1294     if(isset($values['CtxMaxDisconnectionTimeF']))$this->mungedObject->setCtxMaxDisconnectionTimeF($values['CtxMaxDisconnectionTimeF']);
1295     if(isset($values['CtxMaxIdleTimeF']))         $this->mungedObject->setCtxMaxIdleTimeF($values['CtxMaxIdleTimeF']);
1297     if(isset($values['connectclientdrives']))   $this->mungedObject->setConnectClientDrives($values['connectclientdrives']);
1298     if(isset($values['connectclientprinters'])) $this->mungedObject->setConnectClientPrinters($values['connectclientprinters']);
1299     if(isset($values['defaultprinter']))        $this->mungedObject->setDefaultPrinter($values['defaultprinter']);
1301     if(isset($values['shadow']))        $this->mungedObject->setShadow($values['shadow'],$values['shadow']);
1302     if(isset($values['brokenconn']))    $this->mungedObject->setBrokenConn($values['brokenconn'],$values['brokenconn']);
1303     if(isset($values['reconn']))        $this->mungedObject->setReConn($values['reconn'],$values['reconn']);
1304   }
1307 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
1308 ?>