1 <?php
2 /*!
3 \brief posixAccount plugin
4 \author Cajus Pollmeier <pollmeier@gonicus.de>
5 \version 2.00
6 \date 24.07.2003
8 This class provides the functionality to read and write all attributes
9 relevant for posixAccounts and shadowAccounts from/to the LDAP. It
10 does syntax checking and displays the formulars required.
11 */
13 class posixAccount extends plugin
14 {
15 /* Definitions */
16 var $plHeadline= "UNIX";
17 var $plDescription= "This does something";
19 /* CLI vars */
20 var $cli_summary= "Manage users posix account";
21 var $cli_description= "Some longer text\nfor help";
22 var $cli_parameters= array("eins" => "Eins ist toll", "zwei" => "Zwei ist noch besser");
24 /* Plugin specific values */
25 var $homeDirectory= "";
26 var $loginShell= "/bin/bash";
27 var $uidNumber= "";
28 var $gidNumber= "";
29 var $gecos= "";
30 var $shadowMin= "0";
31 var $shadowMax= "0";
32 var $shadowWarning= "0";
33 var $shadowLastChange= "0";
34 var $shadowInactive= "0";
35 var $shadowExpire= "0";
36 var $gosaDefaultPrinter= "";
37 var $accessTo= array();
38 var $trustModel= "";
40 var $glist=array();
41 var $status= "";
42 var $loginShellList= array();
43 var $groupMembership= array();
44 var $savedGroupMembership= array();
45 var $savedUidNumber= "";
46 var $savedGidNumber= "";
47 var $use_shadowMin= "0";
48 var $use_shadowMax= "0";
49 var $use_shadowWarning= "0";
50 var $use_shadowInactive= "0";
51 var $use_shadowExpire= "0";
52 var $mustchangepassword= "0";
53 var $force_ids= 0;
54 var $group_dialog= FALSE;
55 var $show_ws_dialog= FALSE;
56 var $secondaryGroups= array();
57 var $primaryGroup= 0;
58 var $was_trust_account= FALSE;
59 var $memberGroup = array();
60 var $grouplist = array();
61 var $ui = array();
63 var $GroupRegex = "*";
64 var $GroupUserRegex = "*";
65 var $SubSearch = false;
67 var $view_logged = FALSE;
69 /* attribute list for save action */
70 var $CopyPasteVars =
71 array("grouplist","groupMembership","use_shadowMin",
72 "use_shadowMax","use_shadowWarning","use_shadowInactive","use_shadowExpire",
73 "must_change_password","printerList","grouplist","savedGidNumber","savedUidNumber");
75 var $attributes = array("homeDirectory", "loginShell", "uidNumber", "gidNumber", "gecos",
76 "shadowMin", "shadowMax", "shadowWarning", "shadowInactive", "shadowLastChange",
77 "shadowExpire", "gosaDefaultPrinter", "uid","accessTo","trustModel");
79 var $objectclasses= array("posixAccount", "shadowAccount");
81 var $uid= "";
82 var $multiple_support = TRUE;
84 /* constructor, if 'dn' is set, the node loads the given
85 'dn' from LDAP */
86 function posixAccount (&$config, $dn= NULL)
87 {
88 /* Configuration is fine, allways */
89 $this->config= $config;
91 /* Load bases attributes */
92 plugin::plugin($config, $dn);
94 /* Setting uid to default */
95 if(isset($this->attrs['uid'][0])){
96 $this->uid = $this->attrs['uid'][0];
97 }
99 $ldap= $this->config->get_ldap_link();
101 if ($dn !== NULL){
103 /* Correct is_account. shadowAccount is not required. */
104 if (isset($this->attrs['objectClass']) &&
105 in_array ('posixAccount', $this->attrs['objectClass'])){
107 $this->is_account= TRUE;
108 }
110 /* Is this account a trustAccount? */
111 if ($this->is_account && isset($this->attrs['trustModel'])){
112 $this->trustModel= $this->attrs['trustModel'][0];
113 $this->was_trust_account= TRUE;
114 } else {
115 $this->was_trust_account= FALSE;
116 $this->trustModel= "";
117 }
119 $this->accessTo = array();
120 if ($this->is_account && isset($this->attrs['accessTo'])){
121 for ($i= 0; $i<$this->attrs['accessTo']['count']; $i++){
122 $tmp= $this->attrs['accessTo'][$i];
123 $this->accessTo[$tmp]= $tmp;
124 }
125 }
126 $this->initially_was_account= $this->is_account;
128 /* Fill group */
129 $this->primaryGroup= $this->gidNumber;
131 /* Generate status text */
132 $current= date("U");
134 $current= floor($current / 60 /60 / 24);
136 if (($current >= $this->shadowExpire) && $this->shadowExpire){
137 $this->status= _("expired");
138 if (($current - $this->shadowExpire) < $this->shadowInactive){
139 $this->status.= ", "._("grace time active");
140 }
141 } elseif (($this->shadowLastChange + $this->shadowMin) >= $current){
142 $this->status= _("active, password not changable");
143 } elseif (($this->shadowLastChange + $this->shadowMax) >= $current){
144 $this->status= _("active, password expired");
145 } else {
146 $this->status= _("active");
147 }
149 /* Get group membership */
150 $ldap->cd($this->config->current['BASE']);
151 $ldap->search("(&(objectClass=posixGroup)(memberUid=".$this->uid."))", array("cn", "description"));
153 while ($this->attrs= $ldap->fetch()){
154 if (!isset($this->attrs["description"][0])){
155 $entry= $this->attrs["cn"][0];
156 } else {
157 $dsc= preg_replace ('/^Group of user/', _("Group of user"), $this->attrs["description"][0]);
158 $entry= $this->attrs["cn"][0]." [$dsc]";
159 }
160 $this->groupMembership[$ldap->getDN()]= $entry;
161 }
162 asort($this->groupMembership);
163 reset($this->groupMembership);
164 $this->savedGroupMembership= $this->groupMembership;
165 $this->savedUidNumber= $this->uidNumber;
166 $this->savedGidNumber= $this->gidNumber;
167 }
169 /* Adjust shadow checkboxes */
170 foreach (array("shadowMin", "shadowMax", "shadowWarning", "shadowInactive",
171 "shadowExpire") as $val){
173 if ($this->$val != 0){
174 $oval= "use_".$val;
175 $this->$oval= "1";
176 }
177 }
179 /* Convert to seconds */
180 $this->shadowExpire= $this->convertToSeconds($this->shadowExpire);
182 /* Generate shell list from CONFIG_DIR./shells */
183 if (file_exists(CONFIG_DIR.'/shells')){
184 $shells = file (CONFIG_DIR.'/shells');
185 foreach ($shells as $line){
186 if (!preg_match ("/^#/", $line)){
187 $this->loginShellList[]= trim($line);
188 }
189 }
190 } else {
191 if ($this->loginShell == ""){
192 $this->loginShellList[]= _("unconfigured");
193 }
194 }
196 /* Insert possibly missing loginShell */
197 if ($this->loginShell != "" && !in_array($this->loginShell, $this->loginShellList)){
198 $this->loginShellList[]= $this->loginShell;
199 }
201 /* Generate group list */
202 $this->ui = get_userinfo();
203 $this->secondaryGroups[]= "- "._("automatic")." -";
204 $ldap->cd($this->config->current['BASE']);
205 $ldap->search("(objectClass=posixGroup)", array("cn", "gidNumber"));
206 while($attrs = $ldap->fetch()){
207 $this->secondaryGroups[$attrs['gidNumber'][0]]= $attrs['cn'][0];
208 }
209 asort ($this->secondaryGroups);
211 /* Get global filter config */
212 if (!is_global("sysfilter")){
213 $ui= get_userinfo();
214 $base= get_base_from_people($ui->dn);
215 $sysfilter= array( "depselect" => $base,
216 "regex" => "*");
217 register_global("sysfilter", $sysfilter);
218 }
219 $this->ui = get_userinfo();
220 }
223 /* execute generates the html output for this node */
224 function execute($isCopyPaste = false)
225 {
226 /* Call parent execute */
227 plugin::execute();
228 $display= "";
230 /* Log view */
231 if($this->is_account && !$this->view_logged){
232 $this->view_logged = TRUE;
233 new log("view","users/".get_class($this),$this->dn);
234 }
236 /* Department has changed? */
237 if(isset($_POST['depselect'])){
238 $_SESSION['CurrentMainBase']= validate($_POST['depselect']);
239 }
241 if($this->multiple_support_active){
242 $this->is_account = TRUE;
243 }
245 if(!$isCopyPaste && ! $this->multiple_support_active){
247 /* Do we need to flip is_account state? */
248 if(isset($_POST['modify_state'])){
249 if($this->is_account && $this->acl_is_removeable()){
250 $this->is_account= FALSE;
251 }elseif(!$this->is_account && $this->acl_is_createable()){
252 $this->is_account= TRUE;
253 }
254 }
256 /* Do we represent a valid posixAccount? */
257 if (!$this->is_account && $this->parent === NULL ){
258 $display= "<img alt=\"\" src=\"images/stop.png\" align=\"middle\"> <b>".
259 _("This account has no unix extensions.")."</b>";
260 $display.= back_to_main();
261 return ($display);
262 }
265 /* Show tab dialog headers */
266 if ($this->parent !== NULL){
267 if ($this->is_account){
268 if (isset($this->parent->by_object['sambaAccount'])){
269 $obj= $this->parent->by_object['sambaAccount'];
270 }
271 if (isset($obj) && $obj->is_account == TRUE &&
272 ((isset($this->parent->by_object['sambaAccount']))&&($this->parent->by_object['sambaAccount']->is_account))
273 ||(isset($this->parent->by_object['environment'] ))&&($this->parent->by_object['environment'] ->is_account)){
275 /* Samba3 dependency on posix accounts are enabled
276 in the moment, because I need to rely on unique
277 uidNumbers. There'll be a better solution later
278 on. */
279 $display= $this->show_disable_header(_("Remove posix account"),
280 _("This account has unix features enabled. To disable them, you'll need to remove the samba / environment account first."), TRUE);
281 } else {
282 $display= $this->show_disable_header(_("Remove posix account"),
283 _("This account has posix features enabled. You can disable them by clicking below."));
284 }
285 } else {
286 $display= $this->show_enable_header(_("Create posix account"),
287 _("This account has posix features disabled. You can enable them by clicking below."));
288 return($display);
289 }
290 }
291 }
292 /* Trigger group edit? */
293 if (isset($_POST['edit_groupmembership'])){
294 $this->group_dialog= TRUE;
295 $this->dialog= TRUE;
296 }
298 /* Cancel group edit? */
299 if (isset($_POST['add_groups_cancel']) ||
300 isset($_POST['add_groups_finish'])){
301 $this->group_dialog= FALSE;
302 $this->dialog= FALSE;
303 }
305 /* Add selected groups */
306 if (isset($_POST['add_groups_finish']) && isset($_POST['groups']) &&
307 count($_POST['groups'])){
309 $this->addGroup ($_POST['groups']);
310 }
312 /* Delete selected groups */
313 if (isset($_POST['delete_groupmembership']) &&
314 isset($_POST['group_list']) && count($_POST['group_list'])){
316 $this->delGroup ($_POST['group_list']);
317 }
319 /* Add user workstation? */
320 if (isset($_POST["add_ws"])){
321 $this->show_ws_dialog= TRUE;
322 $this->dialog= TRUE;
323 }
325 /* Add user workstation? */
326 if (isset($_POST["add_ws_finish"]) && isset($_POST['wslist'])){
327 foreach($_POST['wslist'] as $ws){
328 $this->accessTo[$ws]= $ws;
329 }
330 ksort($this->accessTo);
331 $this->is_modified= TRUE;
332 }
334 /* Remove user workstations? */
335 if (isset($_POST["delete_ws"]) && isset($_POST['workstation_list'])){
336 foreach($_POST['workstation_list'] as $name){
337 unset ($this->accessTo[$name]);
338 }
339 $this->is_modified= TRUE;
340 }
342 /* Add user workstation finished? */
343 if (isset($_POST["add_ws_finish"]) || isset($_POST["add_ws_cancel"])){
344 $this->show_ws_dialog= FALSE;
345 $this->dialog= FALSE;
346 }
348 /* Templates now! */
349 $smarty= get_smarty();
351 /* Show ws dialog */
352 if ($this->show_ws_dialog){
353 /* Save data */
354 $sysfilter= get_global("sysfilter");
355 foreach( array("depselect", "regex") as $type){
356 if (isset($_POST[$type])){
357 $sysfilter[$type]= $_POST[$type];
358 }
359 }
360 if (isset($_GET['search'])){
361 $s= mb_substr($_GET['search'], 0, 1, "UTF8")."*";
362 if ($s == "**"){
363 $s= "*";
364 }
365 $sysfilter['regex']= $s;
366 }
367 register_global("sysfilter", $sysfilter);
369 /* Get workstation list */
370 $exclude= "";
371 foreach($this->accessTo as $ws){
372 $exclude.= "(cn=$ws)";
373 }
374 if ($exclude != ""){
375 $exclude= "(!(|$exclude))";
376 }
377 $regex= $sysfilter['regex'];
378 $filter= "(&(|(objectClass=goServer)(objectClass=gotoWorkstation)(objectClass=gotoTerminal))$exclude(cn=*)(cn=$regex))";
379 $res= get_list($filter, "groups", $sysfilter['depselect'], array("cn"), GL_SUBSEARCH | GL_SIZELIMIT);
380 $wslist= array();
381 foreach ($res as $attrs){
382 $wslist[]= preg_replace('/\$/', '', $attrs['cn'][0]);
383 }
384 asort($wslist);
385 $smarty->assign("search_image", get_template_path('images/search.png'));
386 $smarty->assign("launchimage", get_template_path('images/small_filter.png'));
387 $smarty->assign("tree_image", get_template_path('images/tree.png'));
388 $smarty->assign("deplist", $this->config->idepartments);
389 $smarty->assign("alphabet", generate_alphabet());
390 foreach( array("depselect", "regex") as $type){
391 $smarty->assign("$type", $sysfilter[$type]);
392 }
393 $smarty->assign("hint", print_sizelimit_warning());
394 $smarty->assign("wslist", $wslist);
395 $smarty->assign("apply", apply_filter());
396 $display= $smarty->fetch (get_template_path('trust_machines.tpl', TRUE, dirname(__FILE__)));
397 return ($display);
398 }
400 /* Manage group add dialog */
401 if ($this->group_dialog){
403 /* Get global filter config */
404 $this->reload();
406 /* remove already assigned groups */
407 $glist= array();
408 foreach ($this->grouplist as $key => $value){
409 if (!isset($this->groupMembership[$key]) && obj_is_writable($key,"groups/group","memberUid")){
410 $glist[$key]= $value;
411 }
412 }
414 if($this->SubSearch){
415 $smarty->assign("SubSearchCHK"," checked ");
416 }else{
417 $smarty->assign("SubSearchCHK","");
418 }
420 $smarty->assign("regex",$this->GroupRegex);
421 $smarty->assign("guser",$this->GroupUserRegex);
422 $smarty->assign("groups", $glist);
423 $smarty->assign("search_image", get_template_path('images/search.png'));
424 $smarty->assign("launchimage", get_template_path('images/small_filter.png'));
425 $smarty->assign("tree_image", get_template_path('images/tree.png'));
426 $smarty->assign("deplist", $this->config->idepartments);
427 $smarty->assign("alphabet", generate_alphabet());
428 $smarty->assign("depselect",$_SESSION['CurrentMainBase']);
429 $smarty->assign("hint", print_sizelimit_warning());
431 $smarty->assign("apply", apply_filter());
432 $display.= $smarty->fetch (get_template_path('posix_groups.tpl', TRUE, dirname(__FILE__)));
433 return ($display);
434 }
436 /* Show main page */
437 $smarty= get_smarty();
439 /* In 'MyAccount' mode, we must remove write acls if we are not in editing mode. */
440 $SkipWrite = (!isset($this->parent) || !$this->parent) && !isset($_SESSION['edit']);
442 /* Depending on pwmode, currently hardcoded because there are no other methods */
443 if ( 1 == 1 ){
444 $smarty->assign("pwmode", dirname(__FILE__)."/posix_shadow");
446 $shadowMinACL = $this->getacl("shadowMin",$SkipWrite);
447 $smarty->assign("shadowmins", sprintf(_("Password can't be changed up to %s days after last change"),
448 "<input name=\"shadowMin\" size=3 maxlength=4 value=\"".$this->shadowMin."\">"));
450 $shadowMaxACL = $this->getacl("shadowMax",$SkipWrite);
451 $smarty->assign("shadowmaxs", sprintf(_("Password must be changed after %s days"),
452 "<input name=\"shadowMax\" size=3 maxlength=4 value=\"".$this->shadowMax."\">"));
454 $shadowInactiveACL= $this->getacl("shadowInactive",$SkipWrite);
455 $smarty->assign("shadowinactives", sprintf(_("Disable account after %s days of inactivity after password expiery"),
456 "<input name=\"shadowInactive\" size=3 maxlength=4 value=\"".$this->shadowInactive."\">"));
458 $shadowWarningACL = $this->getacl("shadowWarning",$SkipWrite);
459 $smarty->assign("shadowwarnings", sprintf(_("Warn user %s days before password expiery"),
460 "<input name=\"shadowWarning\" size=3 maxlength=4 value=\"".$this->shadowWarning."\">"));
462 foreach( array("use_shadowMin", "use_shadowMax",
463 "use_shadowExpire", "use_shadowInactive","use_shadowWarning") as $val){
464 if ($this->$val == 1){
465 $smarty->assign("$val", "checked");
466 } else {
467 $smarty->assign("$val", "");
468 }
469 $smarty->assign("$val"."ACL", $this->getacl($val,$SkipWrite));
470 }
472 if($this->mustchangepassword){
473 $smarty->assign("mustchangepassword", "checked");
474 } else {
475 $smarty->assign("mustchangepassword", "");
476 }
477 $smarty->assign("mustchangepasswordACL", $this->getacl("mustchangepassword",$SkipWrite));
478 }
480 /* Fill calendar */
481 /* If this $this->shadowExpire is empty
482 use current date as base for calculating selectbox values.
483 (This attribute is empty if this is a new user )*/
484 if(empty($this->shadowExpire)){
485 $date= getdate(time());
486 }else{
487 $date= getdate($this->shadowExpire);
488 }
490 $days= array();
491 for($d= 1; $d<32; $d++){
492 $days[$d]= $d;
493 }
494 $years= array();
495 for($y= $date['year']-10; $y<$date['year']+10; $y++){
496 $years[]= $y;
497 }
498 $months= array(_("January"), _("February"), _("March"), _("April"),
499 _("May"), _("June"), _("July"), _("August"), _("September"),
500 _("October"), _("November"), _("December"));
501 $smarty->assign("day", $date["mday"]);
502 $smarty->assign("days", $days);
503 $smarty->assign("months", $months);
504 $smarty->assign("month", $date["mon"]-1);
505 $smarty->assign("years", $years);
506 $smarty->assign("year", $date["year"]);
508 /* Fill arrays */
509 $smarty->assign("shells", $this->loginShellList);
510 $smarty->assign("secondaryGroups", $this->secondaryGroups);
511 $smarty->assign("primaryGroup", $this->primaryGroup);
512 if (!count($this->groupMembership)){
513 $smarty->assign("groupMembership", array(" "));
514 } else {
515 $smarty->assign("groupMembership", $this->groupMembership);
516 }
517 if (count($this->groupMembership) > 16){
518 $smarty->assign("groups", "too_many_for_nfs");
519 } else {
520 $smarty->assign("groups", "");
521 }
523 /* Avoid "Undefined index: forceMode" */
524 $smarty->assign("forceMode", "");
526 /* Checkboxes */
527 if ($this->force_ids == 1){
528 $smarty->assign("force_ids", "checked");
529 if ($_SESSION['js']){
530 $smarty->assign("forceMode", "");
531 }
532 } else {
533 if ($_SESSION['js']){
534 $smarty->assign("forceMode", "disabled");
535 }
536 $smarty->assign("force_ids", "");
537 }
541 $smarty->assign("force_idsACL", $this->getacl("uidNumber",$SkipWrite).$this->getacl("gidNumber",$SkipWrite));
543 foreach(array("primaryGroup") as $val){
544 if(in_array($val,$this->multi_boxes)){
545 $smarty->assign("use_".$val,TRUE);
546 }else{
547 $smarty->assign("use_".$val,FALSE);
548 }
549 }
552 /* Load attributes and acl's */
553 foreach($this->attributes as $val){
554 if(in_array($val,$this->multi_boxes)){
555 $smarty->assign("use_".$val,TRUE);
556 }else{
557 $smarty->assign("use_".$val,FALSE);
558 }
560 if(($_SESSION["js"])&&(($val=="uidNumber")||($val=="gidNumber")))
561 {
562 $smarty->assign("$val"."ACL",$this->getacl($val,$SkipWrite));
563 $smarty->assign("$val", $this->$val);
564 continue;
565 }
566 $smarty->assign("$val", $this->$val);
567 $smarty->assign("$val"."ACL", $this->getacl($val,$SkipWrite));
568 }
569 if($SkipWrite){
570 $smarty->assign("groupMembershipACL","r");
571 }else{
572 $smarty->assign("groupMembershipACL","rw");
573 }
574 $smarty->assign("status", $this->status);
576 /* Work on trust modes */
577 $smarty->assign("trusthide", " disabled ");
578 $smarty->assign("trustmodeACL", $this->getacl("trustModel",$SkipWrite));
579 if ($this->trustModel == "fullaccess"){
580 $trustmode= 1;
581 // pervent double disable tag in html code, this will disturb our clean w3c html
582 $smarty->assign("trustmode", $this->getacl("trustModel",$SkipWrite));
584 } elseif ($this->trustModel == "byhost"){
585 $trustmode= 2;
586 $smarty->assign("trusthide", "");
587 } else {
588 // pervent double disable tag in html code, this will disturb our clean w3c html
589 $smarty->assign("trustmode", $this->getacl("trustModel",$SkipWrite));
590 $trustmode= 0;
591 }
592 $smarty->assign("trustmode", $trustmode);
593 $smarty->assign("trustmodes", array( 0 => _("disabled"), 1 => _("full access"),
594 2 => _("allow access to these hosts")));
598 if((count($this->accessTo))==0)
599 $smarty->assign("emptyArrAccess",true);
600 else
601 $smarty->assign("emptyArrAccess",false);
605 $smarty->assign("workstations", $this->accessTo);
607 $smarty->assign("apply", apply_filter());
608 $smarty->assign("multiple_support" , $this->multiple_support_active);
609 $display.= $smarty->fetch (get_template_path('generic.tpl', TRUE, dirname(__FILE__)));
610 return($display);
611 }
614 /* remove object from parent */
615 function remove_from_parent()
616 {
617 /* Cancel if there's nothing to do here */
618 if ((!$this->initially_was_account) || (!$this->acl_is_removeable())){
619 return;
620 }
622 /* include global link_info */
623 $ldap= $this->config->get_ldap_link();
625 /* Remove and write to LDAP */
626 plugin::remove_from_parent();
628 /* Zero out array */
629 $this->attrs['gosaHostACL']= array();
631 /* Keep uid, because we need it for authentification! */
632 unset($this->attrs['uid']);
633 unset($this->attrs['trustModel']);
635 @DEBUG (DEBUG_LDAP, __LINE__, __FUNCTION__, __FILE__,
636 $this->attributes, "Save");
637 $ldap->cd($this->dn);
638 $this->cleanup();
639 $ldap->modify ($this->attrs);
641 new log("remove","users/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
643 show_ldap_error($ldap->get_error(), sprintf(_("Removing of user/posix account with dn '%s' failed."),$this->dn));
645 /* Delete group only if cn is uid and there are no other
646 members inside */
647 $ldap->cd ($this->config->current['BASE']);
648 $ldap->search ("(&(objectClass=posixGroup)(gidNumber=".$this->gidNumber."))", array("cn", "memberUid"));
649 if ($ldap->count() != 0){
650 $attrs= $ldap->fetch();
651 if ($attrs['cn'][0] == $this->uid &&
652 !isset($this->attrs['memberUid'])){
654 $ldap->rmDir($ldap->getDN());
655 }
656 }
658 /* Optionally execute a command after we're done */
659 $this->handle_post_events("remove",array("uid" => $this->uid));
660 }
663 function save_object()
664 {
665 if (isset($_POST['posixTab'])){
666 /* Save values to object */
667 plugin::save_object();
670 /* Save force GID checkbox */
671 if($this->acl_is_writeable("gidNumber") || $this->acl_is_writeable("uidNumber")){
672 if (isset ($_POST['force_ids'])){
673 $data= 1;
674 } else {
675 $data= 0;
676 }
677 if ($this->force_ids != $data){
678 $this->is_modified= TRUE;
679 }
680 $this->force_ids= $data;
681 }
683 /*Save primary group settings */
684 if($this->acl_is_writeable("primaryGroup") && isset($_POST['primaryGroup'])){
685 $data= $_POST['primaryGroup'];
686 if ($this->primaryGroup != $data){
687 $this->is_modified= TRUE;
688 }
689 $this->primaryGroup= $_POST['primaryGroup'];
690 }
692 foreach(array("shadowMin","shadowMax","shadowExpire","shadowInactive","shadowWarning","mustchangepassword") as $var) {
693 if($this->acl_is_writeable($var)){
694 $use_var = "use_".$var;
695 if(isset($_POST['use_'.$var])){
696 $this->$use_var = true;
697 $this->$var = $_POST[$var];
698 }else{
699 $this->$use_var = false;
700 $this->$var = 0;
701 }
702 }
703 }
705 /* Trust mode - special handling */
706 if($this->acl_is_writeable("trustModel")){
707 if (isset($_POST['trustmode'])){
708 $saved= $this->trustModel;
709 if ($_POST['trustmode'] == "1"){
710 $this->trustModel= "fullaccess";
711 } elseif ($_POST['trustmode'] == "2"){
712 $this->trustModel= "byhost";
713 } else {
714 $this->trustModel= "";
715 }
716 if ($this->trustModel != $saved){
717 $this->is_modified= TRUE;
718 }
719 }
720 }
721 }
723 /* Get regex from alphabet */
724 if(isset($_GET['search'])){
725 $this->GroupRegex = $_GET['search']."*";
726 }
728 /* Check checkboxes and regexes */
729 if(isset($_POST["PosixGroupDialogPosted"])){
731 if(isset($_POST['SubSearch']) && ($_POST['SubSearch'])){
732 $this->SubSearch = true;
733 }else{
734 $this->SubSearch = false;
735 }
736 if(isset($_POST['guser'])){
737 $this->GroupUserRegex = $_POST['guser'];
738 }
739 if(isset($_POST['regex'])){
740 $this->GroupRegex = $_POST['regex'];
741 }
742 }
743 $this->GroupRegex = preg_replace("/\*\**/","*",$this->GroupRegex);
744 $this->GroupUserRegex = preg_replace("/\*\**/","*",$this->GroupUserRegex);
745 }
748 /* Save data to LDAP, depending on is_account we save or delete */
749 function save()
750 {
752 /* include global link_info */
753 $ldap= $this->config->get_ldap_link();
755 /* Adapt shadow values */
756 if (!$this->use_shadowExpire){
757 $this->shadowExpire= "0";
758 } else {
759 /* Transform seconds to days here */
760 $this->shadowExpire= (int)($this->shadowExpire / (60 * 60 * 24)) ;
761 }
762 if (!$this->use_shadowMax){
763 $this->shadowMax= "0";
764 }
765 if ($this->mustchangepassword){
766 $this->shadowLastChange= (int)(date("U") / 86400) - $this->shadowMax - 1;
767 } else {
768 $this->shadowLastChange= (int)(date("U") / 86400);
769 }
770 if (!$this->use_shadowWarning){
771 $this->shadowWarning= "0";
772 }
774 /* Check what to do with ID's */
775 if ($this->force_ids == 0){
777 /* Use id's that are already set */
778 if ($this->savedUidNumber != ""){
779 $this->uidNumber= $this->savedUidNumber;
780 $this->gidNumber= $this->savedGidNumber;
781 } else {
783 /* Calculate new id's. We need to place a lock before calling get_next_id
784 to get real unique values. */
785 $wait= 10;
786 while (get_lock("uidnumber") != ""){
787 sleep (1);
789 /* Oups - timed out */
790 if ($wait-- == 0){
791 print_red (_("Failed: overriding lock"));
792 break;
793 }
794 }
796 add_lock ("uidnumber", "gosa");
797 $this->uidNumber= $this->get_next_id("uidNumber", $this->dn);
798 if ($this->savedGidNumber != ""){
799 $this->gidNumber= $this->savedGidNumber;
800 } else {
801 $this->gidNumber= $this->get_next_id("gidNumber", $this->dn);
802 }
803 }
805 if ($this->primaryGroup != 0){
806 $this->gidNumber= $this->primaryGroup;
807 }
808 }
810 if ($this->use_shadowMin != "1" ) {
811 $this->shadowMin = "";
812 }
814 if (($this->use_shadowMax != "1") && ($this->mustchangepassword != "1")) {
815 $this->shadowMax = "";
816 }
818 if ($this->use_shadowWarning != "1" ) {
819 $this->shadowWarning = "";
820 }
822 if ($this->use_shadowInactive != "1" ) {
823 $this->shadowInactive = "";
824 }
826 if ($this->use_shadowExpire != "1" ) {
827 $this->shadowExpire = "";
828 }
830 /* Fill gecos */
831 if (isset($this->parent) && $this->parent !== NULL){
832 $this->gecos= rewrite($this->parent->by_object['user']->cn);
833 if (!preg_match('/^[a-z0-9 -]+$/i', $this->gecos)){
834 $this->gecos= "";
835 }
836 }
838 foreach(array("shadowMin","shadowMax","shadowWarning","shadowInactive","shadowExpire") as $attr){
839 $this->$attr = (int) $this->$attr;
840 }
841 /* Call parents save to prepare $this->attrs */
842 plugin::save();
844 /* Trust accounts */
845 $objectclasses= array();
846 foreach ($this->attrs['objectClass'] as $key => $class){
847 if (preg_match('/trustAccount/i', $class)){
848 continue;
849 }
850 $objectclasses[]= $this->attrs['objectClass'][$key];
851 }
852 $this->attrs['objectClass']= $objectclasses;
853 if ($this->trustModel != ""){
854 $this->attrs['objectClass'][]= "trustAccount";
855 $this->attrs['trustModel']= $this->trustModel;
856 $this->attrs['accessTo']= array();
857 if ($this->trustModel == "byhost"){
858 foreach ($this->accessTo as $host){
859 $this->attrs['accessTo'][]= $host;
860 }
861 }
862 } else {
863 if ($this->was_trust_account){
864 $this->attrs['accessTo']= array();
865 $this->attrs['trustModel']= array();
866 }
867 }
869 if(empty($this->attrs['gosaDefaultPrinter'])){
870 $thid->attrs['gosaDefaultPrinter']=array();
871 }
874 /* Save data to LDAP */
875 $ldap->cd($this->dn);
876 $this->cleanup();
877 unset($this->attrs['uid']);
878 $ldap->modify ($this->attrs);
880 /* Log last action */
881 if($this->initially_was_account){
882 new log("modify","users/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
883 }else{
884 new log("create","users/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
885 }
887 show_ldap_error($ldap->get_error(), sprintf(_("Saving of user/posix account with dn '%s' failed."),$this->dn));
889 /* Remove lock needed for unique id generation */
890 del_lock ("uidnumber");
892 /* Posix accounts have group interrelationship,
893 take care about these here if this is a new user without forced gidNumber. */
894 if ($this->force_ids == 0 && $this->primaryGroup == 0 && !$this->initially_was_account){
895 $ldap->cd($this->config->current['BASE']);
896 $ldap->search("(&(objectClass=posixGroup)(gidNumber=".$this->gidNumber."))", array("cn"));
898 /* Create group if it doesn't exist */
899 if ($ldap->count() == 0){
900 $groupdn= preg_replace ('/^'.$this->config->current['DNMODE'].'=[^,]+,'.get_people_ou().'/i', 'cn='.$this->uid.','.get_groups_ou(), $this->dn);
902 $g= new group($this->config, $groupdn);
903 $g->cn= $this->uid;
904 $g->force_gid= 1;
905 $g->gidNumber= $this->gidNumber;
906 $g->description= "Group of user ".$this->givenName." ".$this->sn;
907 $g->save ();
908 }
909 }
911 /* Take care about groupMembership values: add to groups */
912 foreach ($this->groupMembership as $key => $value){
913 if (!isset($this->savedGroupMembership[$key])){
914 $g= new grouptabs($this->config,$this->config->data['TABS']['GROUPTABS'], $key,"groups");
915 $g->set_acl_base($key);
916 $g->by_object['group']->addUser($this->uid);
917 $g->save();
918 }
919 }
921 /* Remove from groups not listed in groupMembership */
922 foreach ($this->savedGroupMembership as $key => $value){
923 if (!isset($this->groupMembership[$key])){
924 $g= new grouptabs($this->config,$this->config->data['TABS']['GROUPTABS'], $key,"groups");
925 $g->set_acl_base($key);
926 $g->by_object['group']->removeUser ($this->uid);
927 $g->save();
928 }
929 }
931 /* Optionally execute a command after we're done */
932 if ($this->initially_was_account == $this->is_account){
933 if ($this->is_modified){
934 $this->handle_post_events("modify",array("uid" => $this->uid));
935 }
936 } else {
937 $this->handle_post_events("add" ,array("uid"=> $this->uid));
938 }
939 }
941 /* Check formular input */
942 function check()
943 {
944 /* Include global link_info */
945 $ldap= $this->config->get_ldap_link();
947 /* Append groups as memberGroup: to check hook
948 */
949 $tmp_attributes = $this->attributes;
950 $this->attributes[] = "memberGroup";
951 $this->memberGroup = array();
952 foreach($this->groupMembership as $dn => $name){
953 $this->memberGroup[] = $name;
954 }
956 /* Call common method to give check the hook */
957 $message= plugin::check();
958 $this->attributes = $tmp_attributes;
960 /* must: homeDirectory */
961 if ($this->homeDirectory == ""){
962 $message[]= _("The required field 'Home directory' is not set.");
963 }
964 if (!is_path($this->homeDirectory)){
965 $message[]= _("Please enter a valid path in 'Home directory' field.");
966 }
968 /* Check ID's if they are forced by user */
969 if ($this->force_ids == "1"){
971 /* Valid uid/gid? */
972 if (!is_id($this->uidNumber)){
973 $message[]= _("Value specified as 'UID' is not valid.");
974 } else {
975 if ($this->uidNumber < $this->config->current['MINID']){
976 $message[]= _("Value specified as 'UID' is too small.");
977 }
978 }
979 if (!is_id($this->gidNumber)){
980 $message[]= _("Value specified as 'GID' is not valid.");
981 } else {
982 if ($this->gidNumber < $this->config->current['MINID']){
983 $message[]= _("Value specified as 'GID' is too small.");
984 }
985 }
986 }
988 /* Check shadow settings, well I like spaghetties... */
989 if ($this->use_shadowMin){
990 if (!is_id($this->shadowMin)){
991 $message[]= _("Value specified as 'shadowMin' is not valid.");
992 }
993 }
994 if ($this->use_shadowMax){
995 if (!is_id($this->shadowMax)){
996 $message[]= _("Value specified as 'shadowMax' is not valid.");
997 }
998 }
999 if ($this->use_shadowWarning){
1000 if (!is_id($this->shadowWarning)){
1001 $message[]= _("Value specified as 'shadowWarning' is not valid.");
1002 }
1003 if (!$this->use_shadowMax){
1004 $message[]= _("'shadowWarning' without 'shadowMax' makes no sense.");
1005 }
1006 if ($this->shadowWarning > $this->shadowMax){
1007 $message[]= _("Value specified as 'shadowWarning' should be smaller than 'shadowMax'.");
1008 }
1009 if ($this->use_shadowMin && $this->shadowWarning < $this->shadowMin){
1010 $message[]= _("Value specified as 'shadowWarning' should be greater than 'shadowMin'.");
1011 }
1012 }
1013 if ($this->use_shadowInactive){
1014 if (!is_id($this->shadowInactive)){
1015 $message[]= _("Value specified as 'shadowInactive' is not valid.");
1016 }
1017 if (!$this->use_shadowMax){
1018 $message[]= _("'shadowInactive' without 'shadowMax' makes no sense.");
1019 }
1020 }
1021 if ($this->use_shadowMin && $this->use_shadowMax){
1022 if ($this->shadowMin > $this->shadowMax){
1023 $message[]= _("Value specified as 'shadowMin' should be smaller than 'shadowMax'.");
1024 }
1025 }
1027 // if(empty($this->gosaDefaultPrinter)){
1028 // $message[]= _("You need to specify a valid default printer.");
1029 // }
1031 return ($message);
1032 }
1034 function addGroup ($groups)
1035 {
1036 /* include global link_info */
1037 $ldap= $this->config->get_ldap_link();
1039 /* Walk through groups and add the descriptive entry if not exists */
1040 foreach ($groups as $value){
1041 if (!array_key_exists($value, $this->groupMembership)){
1042 $ldap->cat($value, array('cn', 'description', 'dn'));
1043 $attrs= $ldap->fetch();
1044 error_reporting (0);
1045 if (!isset($attrs['description'][0])){
1046 $entry= $attrs["cn"][0];
1047 } else {
1048 $dsc= preg_replace ('/^Group of user/', _("Group of user"), $attrs["description"][0]);
1049 $entry= $attrs["cn"][0]." [$dsc]";
1050 }
1051 error_reporting (E_ALL | E_STRICT);
1053 if(obj_is_writable($attrs['dn'],"groups/group","memberUid")){
1054 $this->groupMembership[$attrs['dn']]= $entry;
1055 }
1056 }
1057 }
1059 /* Sort groups */
1060 asort ($this->groupMembership);
1061 reset ($this->groupMembership);
1062 }
1065 /* Del posix user from some groups */
1066 function delGroup ($groups)
1067 {
1068 $dest= array();
1069 foreach($groups as $dn_to_del){
1070 if(isset($this->groupMembership[$dn_to_del]) && obj_is_writable($dn_to_del,"groups/group","memberUid")){
1071 unset($this->groupMembership[$dn_to_del]);
1072 }
1073 }
1074 }
1077 /* Adapt from template, using 'dn' */
1078 function adapt_from_template($dn)
1079 {
1080 /* Include global link_info */
1081 $ldap= $this->config->get_ldap_link();
1083 plugin::adapt_from_template($dn);
1084 $template= $this->attrs['uid'][0];
1086 /* Adapt group membership */
1087 $ldap->cd($this->config->current['BASE']);
1088 $ldap->search("(&(objectClass=posixGroup)(memberUid=".$this->attrs["uid"][0]."))", array("description", "cn"));
1090 while ($this->attrs= $ldap->fetch()){
1091 if (!isset($this->attrs["description"][0])){
1092 $entry= $this->attrs["cn"][0];
1093 } else {
1094 $entry= $this->attrs["cn"][0]." [".$this->attrs["description"][0]."]";
1095 }
1096 $this->groupMembership[$ldap->getDN()]= $entry;
1097 }
1099 /* Fix primary group settings */
1100 $ldap->cd($this->config->current['BASE']);
1101 $ldap->search("(&(objectClass=posixGroup)(cn=$template)(gidNumber=".$this->gidNumber."))", array("cn"));
1102 if ($ldap->count() != 1){
1103 $this->primaryGroup= $this->gidNumber;
1104 }
1106 $ldap->cd($this->config->current['BASE']);
1107 $ldap->search("(&(objectClass=gosaUserTemplate)(uid=".$template.")(accessTo=*))", array("cn","accessTo"));
1108 while($attr = $ldap->fetch()){
1109 $tmp = $attr['accessTo'];
1110 unset ($tmp['count']);
1111 $this->accessTo = $tmp;
1112 }
1114 /* Adjust shadow checkboxes */
1115 foreach (array("shadowMin", "shadowMax", "shadowWarning", "shadowInactive") as $val){
1116 if ($this->$val != 0){
1117 $oval= "use_".$val;
1118 $this->$oval= "1";
1119 }
1120 }
1122 /* FIXME: NEED review of this section */
1123 /* Need to check shadowExpire separately */
1125 /*
1126 * If shadowExpire is not enabled in the template, it's a UNIX timestamp - so don't convert it to seconds.
1127 * The check is a hack - if difference between timestamp generated above and here is max 1 day.
1128 */
1129 if(abs($this->shadowExpire - time())>86400) {
1130 $this->shadowExpire= $this->convertToSeconds($this->shadowExpire);
1131 }
1133 /* Only enable checkbox, if shadowExpire is in the future */
1134 if($this->shadowExpire > time()) {
1135 $this->use_shadowExpire= "1";
1136 }
1137 }
1139 function convertToSeconds($val)
1140 {
1141 if ($val != 0){
1142 $val*= 60 * 60 * 24;
1143 } else {
1144 $date= getdate();
1145 $val= floor($date[0] / (60*60*24)) * 60 * 60 * 24;
1146 }
1147 return($val);
1148 }
1151 function get_next_id($attrib, $dn)
1152 {
1153 $ids= array();
1154 $ldap= $this->config->get_ldap_link();
1156 $ldap->cd ($this->config->current['BASE']);
1157 if (preg_match('/gidNumber/i', $attrib)){
1158 $oc= "posixGroup";
1159 } else {
1160 $oc= "posixAccount";
1161 }
1162 $ldap->search ("(&(objectClass=$oc)($attrib=*))", array("$attrib"));
1164 /* Get list of ids */
1165 while ($attrs= $ldap->fetch()){
1166 $ids[]= (int)$attrs["$attrib"][0];
1167 }
1169 /* Add the nobody id */
1170 $ids[]= 65534;
1172 /* get the ranges */
1173 $tmp = array('0'=> 1000);
1174 if (preg_match('/posixAccount/', $oc) && isset($this->config->current['UIDBASE'])) {
1175 $tmp= split('-',$this->config->current['UIDBASE']);
1176 } elseif(isset($this->config->current['GIDBASE'])){
1177 $tmp= split('-',$this->config->current['GIDBASE']);
1178 }
1180 /* Set hwm to max if not set - for backward compatibility */
1181 $lwm= $tmp[0];
1182 if (isset($tmp[1])){
1183 $hwm= $tmp[1];
1184 } else {
1185 $hwm= pow(2,32);
1186 }
1188 /* Find out next free id near to UID_BASE */
1189 if (!isset($this->config->current['BASE_HOOK'])){
1190 $base= $lwm;
1191 } else {
1192 /* Call base hook */
1193 $base= get_base_from_hook($dn, $attrib);
1194 }
1195 for ($id= $base; $id++; $id < pow(2,32)){
1196 if (!in_array($id, $ids)){
1197 return ($id);
1198 }
1199 }
1201 /* Should not happen */
1202 if ($id == $hwm){
1203 print_red(_("Too many users, can't allocate a free ID!"));
1204 exit;
1205 }
1207 }
1209 function reload()
1210 {
1211 /* Set base for all searches */
1212 $base = $_SESSION['CurrentMainBase'];
1213 $base = $base;
1214 $ldap = $this->config->get_ldap_link();
1215 $attrs = array("cn", "description", "gidNumber");
1216 $Flags = GL_SIZELIMIT;
1218 /* Get groups */
1219 if ($this->GroupUserRegex == '*'){
1220 $filter = "(&(objectClass=posixGroup)(cn=".$this->GroupRegex."))";
1221 } else {
1222 $filter= "(&(objectClass=posixGroup)(cn=".$this->GroupRegex.")(memberUid=".$this->GroupUserRegex."))";
1223 }
1224 if($this->SubSearch){
1225 $Flags |= GL_SUBSEARCH;
1226 }else{
1227 $base = get_groups_ou().$base;
1228 }
1230 $res= get_list($filter, "groups", $base,$attrs, $Flags);
1232 /* check sizelimit */
1233 if (preg_match("/size limit/i", $ldap->error)){
1234 $_SESSION['limit_exceeded']= TRUE;
1235 }
1237 /* Create a list of users */
1238 $this->grouplist = array();
1239 foreach ($res as $value){
1240 $this->grouplist[$value['gidNumber'][0]]= $value;
1241 }
1243 $tmp=array();
1244 foreach($this->grouplist as $tkey => $val ){
1245 $tmp[strtolower($val['cn'][0]).$val['cn'][0]]=$val;
1246 }
1248 /* Sort index */
1249 ksort($tmp);
1251 /* Recreate index array[dn]=cn[description]*/
1252 $this->grouplist=array();
1253 foreach($tmp as $val){
1254 if(isset($val['description'])){
1255 $this->grouplist[$val['dn']]=$val['cn'][0]." [".$val['description'][0]."]";
1256 }else{
1257 $this->grouplist[$val['dn']]=$val['cn'][0];
1258 }
1259 }
1261 reset ($this->grouplist);
1262 }
1265 /* Get posts from copy & paste dialog */
1266 function saveCopyDialog()
1267 {
1268 if(isset($_POST['homeDirectory'])){
1269 $this->homeDirectory = $_POST['homeDirectory'];
1270 if (isset ($_POST['force_ids'])){
1271 $data= 1;
1272 $this->gidNumber = $_POST['gidNumber'];
1273 $this->uidNumber = $_POST['uidNumber'];
1274 } else {
1275 $data= 0;
1276 }
1277 if ($this->force_ids != $data){
1278 $this->is_modified= TRUE;
1279 }
1280 $this->force_ids= $data;
1281 }
1282 }
1285 /* Create the posix dialog part for copy & paste */
1286 function getCopyDialog()
1287 {
1288 /* Skip dialog creation if this is not a valid account*/
1289 if(!$this->is_account) return("");
1290 if ($this->force_ids == 1){
1291 $force_ids = "checked";
1292 if ($_SESSION['js']){
1293 $forceMode = "";
1294 }
1295 } else {
1296 if ($_SESSION['js']){
1297 if($this->acl != "#none#")
1298 $forceMode ="disabled";
1299 }
1300 $force_ids = "";
1301 }
1303 $sta = "";
1305 /* Open group add dialog */
1306 if(isset($_POST['edit_groupmembership'])){
1307 $this->group_dialog = TRUE;
1308 $sta = "SubDialog";
1309 }
1311 /* If the group-add dialog is closed, call execute
1312 to ensure that the membership is updatd */
1313 if(isset($_POST['add_groups_finish']) || isset($_POST['add_groups_cancel'])){
1314 $this->execute();
1315 $this->group_dialog =FALSE;
1316 }
1318 if($this->group_dialog){
1319 $str = $this->execute(true);
1320 $ret = array();
1321 $ret['string'] = $str;
1322 $ret['status'] = $sta;
1323 return($ret);
1324 }
1326 /* If a group member should be deleted, simply call execute */
1327 if(isset($_POST['delete_groupmembership'])){
1328 $this->execute();
1329 }
1331 /* Assigned informations to smarty */
1332 $smarty = get_smarty();
1333 $smarty->assign("homeDirectory",$this->homeDirectory);
1334 $smarty->assign("uidNumber",$this->uidNumber);
1335 $smarty->assign("gidNumber",$this->gidNumber);
1336 $smarty->assign("forceMode",$forceMode);
1337 $smarty->assign("force_ids",$force_ids);
1338 if (!count($this->groupMembership)){
1339 $smarty->assign("groupMembership", array(" "));
1340 } else {
1341 $smarty->assign("groupMembership", $this->groupMembership);
1342 }
1344 /* Display wars message if there are more than 16 group members */
1345 if (count($this->groupMembership) > 16){
1346 $smarty->assign("groups", "too_many_for_nfs");
1347 } else {
1348 $smarty->assign("groups", "");
1349 }
1350 $str = $smarty->fetch(get_template_path("paste_generic.tpl",TRUE,dirname(__FILE__)));
1352 $ret = array();
1353 $ret['string'] = $str;
1354 $ret['status'] = $sta;
1355 return($ret);
1356 }
1359 function PrepareForCopyPaste($source)
1360 {
1361 plugin::PrepareForCopyPaste($source);
1363 /* Avoid using the same gid/uid number as source user */
1364 $this->savedUidNumber = $this->get_next_id("gidNumber", $this->dn);
1365 $this->savedGidNumber = $this->get_next_id("uidNumber", $this->dn);
1366 }
1369 function multiple_execute()
1370 {
1371 return($this->execute());
1372 }
1375 static function plInfo()
1376 {
1377 return (array(
1378 "plDescription" => _("POSIX account"),
1379 "plSelfModify" => TRUE,
1380 "plDepends" => array("user"),
1381 "plPriority" => 2,
1382 "plSection" => array("personal" => _("My account")),
1383 "plCategory" => array("users"),
1384 "plOptions" => array(),
1386 "plProvidedAcls" => array(
1388 "homeDirectory" => _("Home directory"),
1389 "loginShell" => _("Shell"),
1390 "uidNumber" => _("User ID"),
1391 "gidNumber" => _("Group ID"),
1393 "mustchangepassword"=> _("Force password change on login"),
1394 "shadowMin" => _("Shadow min"),
1395 "shadowMax" => _("Shadow max"),
1396 "shadowWarning" => _("Shadow warning"),
1397 "shadowInactive" => _("Shadow inactive"),
1398 "shadowExpire" => _("Shadow expire"),
1399 "trustModel" => _("System trust model")))
1400 );
1401 }
1403 function get_multi_edit_values()
1404 {
1405 $ret = plugin::get_multi_edit_values();
1406 return($ret);
1407 }
1410 function multiple_save_object()
1411 {
1412 if(isset($_POST['posix_mulitple_edit'])){
1413 plugin::multiple_save_object();
1414 foreach(array("primaryGroup") as $val){
1415 if(isset($_POST["use_".$val])){
1416 $this->multi_boxes[] = $val;
1417 }
1418 }
1420 /* Save primary group settings */
1421 if($this->acl_is_writeable("primaryGroup") && isset($_POST['primaryGroup'])){
1422 $data= $_POST['primaryGroup'];
1423 if ($this->primaryGroup != $data){
1424 $this->is_modified= TRUE;
1425 }
1426 $this->primaryGroup= $_POST['primaryGroup'];
1427 }
1428 }
1429 }
1430 }
1432 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
1433 ?>