23 "USERCARD:CHOOSEGROUP"
29 $err = parent::preRefresh();
31 if ($this->
getRawValue(
"US_STATUS") ==
'D')
$err.= (
$err ==
"" ?
"" :
"\n") . _(
"user is deactivated");
35 $user = $this->getAccount();
36 if (!
$user->isAffected())
return sprintf(_(
"user #%d does not exist") , $iduser);
38 if ($this->
getRawValue(
"us_login") !=
'-')
$err = _(
"user has not identificator");
43 if ($oa) $oa->needed =
true;
48 if ($oa) $oa->needed =
true;
50 $oa->setOption(
"firstopen",
"yes");
57 $u = $this->getAccount();
59 $this->
setValue(
"us_incumbents", $u->getIncumbents(
false));
72 return _(
"user cannot be revived");
80 $err =
simpleQuery($this->dbaccess, sprintf(
"SELECT id, fid from users, groups where groups.iduser=%d and users.id = groups.idgroup;", $this->
getRawValue(
"us_whatid")) , $groupIds,
false,
false);
83 foreach ($groupIds as $gid) {
84 $gids[$gid[
"id"]] = $gid[
"fid"];
99 simpleQuery($this->dbaccess, sprintf(
"SELECT id, fid from users, groups where groups.iduser=%d and users.id = groups.idgroup;", $gid) , $groupIds,
false,
false);
102 foreach ($groupIds as $gid) {
103 $gids[$gid[
"id"]] = $gid[
"fid"];
106 foreach ($gids as $systemGid => $docGid) {
109 $groupIds = $gids + $pgids;
124 function refreshParentGroup()
127 foreach (
$tgid as $gid) {
131 $gdoc =
new_Doc($this->dbaccess, $gid);
132 if ($gdoc->isAlive()) {
133 $gdoc->insertGroups();
146 $wuser = $this->getAccount(
true);
148 if (
$wuser->isAffected()) {
149 $this->SetValue(MyAttributes::us_whatid,
$wuser->id);
150 $this->SetValue(MyAttributes::us_lname,
$wuser->lastname);
151 $this->SetValue(MyAttributes::us_fname,
$wuser->firstname);
152 $this->SetValue(MyAttributes::us_passwd1,
" ");
153 $this->SetValue(MyAttributes::us_passwd2,
" ");
154 $this->SetValue(MyAttributes::us_login,
$wuser->login);
155 $this->SetValue(MyAttributes::us_status,
$wuser->status);
156 $this->SetValue(MyAttributes::us_passdelay,
$wuser->passdelay);
157 $this->SetValue(MyAttributes::us_expires,
$wuser->expires);
158 $this->SetValue(MyAttributes::us_daydelay,
$wuser->passdelay / 3600 / 24);
159 if (
$wuser->substitute > 0) {
162 $this->
clearValue(MyAttributes::us_substitute);
165 $rolesIds =
$wuser->getRoles(
false);
167 $this->SetValue(
"us_roles", $rolesIds);
169 $mail =
$wuser->getMail();
174 $this->SetValue(MyAttributes::us_mail, $mail);
175 $this->SetValue(MyAttributes::us_extmail, $mail);
178 if (
$wuser->passdelay <> 0) {
179 $this->SetValue(MyAttributes::us_expiresd, strftime(
"%Y-%m-%d",
$wuser->expires));
180 $this->SetValue(MyAttributes::us_expirest, strftime(
"%H:%M",
$wuser->expires));
182 $this->SetValue(MyAttributes::us_expiresd,
" ");
183 $this->SetValue(MyAttributes::us_expirest,
" ");
186 $g = new \Group(
"",
$wid);
189 if (count($g->groups) > 0) {
190 $gt = new \Account($this->dbaccess);
191 foreach ($g->groups as $gid) {
194 $tgtitle[] = $this->
getTitle($gt->fid);
197 $this->SetValue(MyAttributes::us_idgroup,
$tgid);
198 $this->SetValue(MyAttributes::us_group, $tgtitle);
204 $err = sprintf(_(
"user %d does not exist") ,
$wid);
213 function setToDefaultGroup()
221 $grp = new_doc($this->dbaccess, $grpid);
222 if ($grp->isAlive()) {
223 $err = $grp->insertDocument($this->initid);
236 $ed = floatval($action->getParam(
"AUTHENT_ACCOUNTEXPIREDELAY"));
238 $expdate = time() + ($ed * 24 * 3600);
239 $err = $this->SetValue(
"us_accexpiredate", strftime(
"%Y-%m-%d 00:00:00", $expdate));
263 return self::postStore();
276 if ($daydelay == - 1) $passdelay = $daydelay;
277 else $passdelay = intval($daydelay) * 3600 * 24;
287 $expirest = $this->
getRawValue(
"us_expirest",
"00:00");
289 $expdate = $expiresd .
" " . $expirest .
":00";
291 if ($expdate !=
"") {
292 if (preg_match(
"|([0-9][0-9])/([0-9][0-9])/(2[0-9][0-9][0-9]) ([0-2][0-9]):([0-5][0-9]):([0-5][0-9])|", $expdate, $reg)) {
293 $expires = mktime($reg[4], $reg[5], $reg[6], $reg[2], $reg[1], $reg[3]);
294 }
else if (preg_match(
"|(2[0-9][0-9][0-9])-([0-9][0-9])-([0-9][0-9]) ([0-2][0-9]):([0-5][0-9]):([0-5][0-9])|", $expdate, $reg)) {
295 $expires = mktime($reg[4], $reg[5], $reg[6], $reg[2], $reg[3], $reg[1]);
301 $user = $this->getAccount();
303 $user = new \Account(
"");
304 $this->wuser = &
$user;
309 foreach ($allRoles as $arole) {
310 if ($arole[
"us_rolesorigin"] !=
"group") $roles[] = $arole[
"us_roles"];
312 $roleIds = $this->getSystemIds($roles);
314 if ($substitute) $substitute = $this->
getDocValue($substitute,
"us_whatid");
315 $err.=
$user->updateUser($fid, $lname, $fname, $expires, $passdelay,
$login,
$status, $pwd1, $pwd2, $extmail, $roleIds, $substitute);
319 $this->
setValue(MyAttributes::us_meid, $this->
id);
321 $this->
modify(
false, array(
322 MyAttributes::us_whatid,
323 MyAttributes::us_meid
325 $err = $this->setGroups();
326 if ($newuser)
$err.= $this->setToDefaultGroup();
331 $err = $this->RefreshDocUser();
334 if ($errldap !=
"") AddWarningMsg($errldap);
340 if (($email !=
"") && ($email[0] !=
"<")) $this->
setValue(
"us_mail", $email);
351 parent::PostDelete();
353 $user = $this->getAccount();
366 $_POST[
"gidnew"] =
"N";
380 foreach ($allRoles as $arole) {
381 if ($arole[
"us_rolesorigin"] !=
"group") $roles[] = $arole[
"us_roles"];
383 $this->
setValue(
"us_roles", $roles);
389 $passFrame->setVisibility(
"H");
393 $passFrame->setVisibility(
"H");
402 $u = $this->getAccount();
404 $directRoleIds = $u->getRoles();
405 $allParents = $u->getUserParents();
406 $allRoles = $allGroup = array();
407 foreach ($allParents as $aParent) {
409 else $allGroup[] = $aParent;
413 foreach ($allRoles as $role) {
414 if (in_array($role[
"id"], $directRoleIds)) {
418 "us_roles" => $role[
"fid"],
420 "us_rolegorigin" => $group
426 foreach ($allGroup as $aGroup) {
427 simpleQuery($this->dbaccess, sprintf(
"select idgroup from groups where iduser=%d and idgroup=%d", $aGroup[
"id"], $rid) , $gr);
429 $tgroup[] = $aGroup[
"fid"];
434 $group = implode(
'<BR>', $tgroup);
436 "us_roles" => $role[
"fid"],
438 "us_rolegorigin" => $group
450 $wu = $this->getAccount();
451 if ($wu && $wu->isAffected()) {
452 return $wu->getMail($rawmail);
473 $wu = $this->getAccount();
474 if ($wu && $wu->isAffected()) {
475 return $wu->password;
485 if ($pwd1 <> $pwd2) {
486 $err = _(
"the 2 passwords are not the same");
487 }
else if (($pwd1 ==
"") && ($this->
getRawValue(
"us_whatid") ==
"")) {
488 if (
$login !=
"-")
$err = _(
"passwords must not be empty");
498 $minLength = intval(
getParam(
"AUTHENT_PWDMINLENGTH"));
499 $minDigitLength = intval(
getParam(
"AUTHENT_PWDMINDIGITLENGTH"));
500 $minUpperLength = intval(
getParam(
"AUTHENT_PWDMINUPPERALPHALENGTH"));
501 $minLowerLength = intval(
getParam(
"AUTHENT_PWDMINLOWERALPHALENGTH"));
502 $minSymbolLength = intval(
getParam(
"AUTHENT_PWDMINSYMBOLLENGTH"));
504 if (preg_match(
'/[\p{C}]/u', $pwd)) {
505 return _(
"Control characters are not allowed");
508 $msg = sprintf(_(
"Your password is not secure."));
509 if ($minLength > 0) $msg.=
"\n " . sprintf(_(
"It must contains at least %d characters (total length)") , $minLength);
510 if ($minDigitLength + $minUpperLength + $minLowerLength + $minSymbolLength > 0) $msg.=
" " . sprintf(_(
"with these conditions"));
511 if ($minDigitLength) {
512 if ($minDigitLength > 1) $msg.=
"\n - " . sprintf(_(
"at least %d digits") , $minDigitLength);
513 else $msg.=
"\n - " . sprintf(_(
"at least one digit"));
515 if ($minUpperLength) {
516 if ($minUpperLength > 1) $msg.=
"\n - " . sprintf(_(
"at least %d uppercase alpha characters") , $minUpperLength);
517 else $msg.=
"\n - " . sprintf(_(
"at least one uppercase alpha character"));
519 if ($minLowerLength) {
520 if ($minLowerLength > 1) $msg.=
"\n - " . sprintf(_(
"at least %d lowercase alpha characters") , $minLowerLength);
521 else $msg.=
"\n - " . sprintf(_(
"at least one lowercase alpha character"));
523 if ($minSymbolLength) {
524 if ($minSymbolLength > 1) $msg.=
"\n - " . sprintf(_(
"at least %d symbol characters") , $minSymbolLength);
525 else $msg.=
"\n - " . sprintf(_(
"at least one symbol character"));
527 if (mb_strlen($pwd) < $minLength) {
528 $err = _(
"Not enough characters.") .
"\n";
529 return nl2br(
$err . $msg);
533 if ($minDigitLength) {
534 preg_match_all(
'/[0-9]/', $pwd, $matches);
535 $alphanum+= count($matches[0]);
536 if (count($matches[0]) < $minDigitLength) {
537 $err = _(
"Not enough digits.") .
"\n";
538 return nl2br(
$err . $msg);
541 if ($minUpperLength) {
542 preg_match_all(
'/[\p{Lu}]/u', $pwd, $matches);
543 $alphanum+= count($matches[0]);
544 if (count($matches[0]) < $minUpperLength) {
545 $err = _(
"Not enough uppercase characters.") .
"\n";
546 return nl2br(
$err . $msg);
549 if ($minLowerLength) {
550 preg_match_all(
'/[\p{Ll}]/u', $pwd, $matches);
551 $alphanum+= count($matches[0]);
552 if (count($matches[0]) < $minLowerLength) {
553 $err = _(
"Not enough lowercase characters.") .
"\n";
554 return nl2br(
$err . $msg);
557 if ($minSymbolLength) {
558 if ((mb_strlen($pwd) - $alphanum) < $minSymbolLength) {
559 $err = _(
"Not enough special characters.") .
"\n";
560 return nl2br(
$err . $msg);
576 if (($expiresd <>
"") && ($daydelay == 0)) {
577 $err = _(
"Expiration delay must not be 0 to keep expiration date");
595 $this->lay = new \Layout(
getLayoutFile(
"FDL",
"editbodycard.xml") , $action);
597 $this->attributes->attr[
'us_tab_system']->visibility =
'R';
598 $this->attributes->attr[
'us_fr_userchange']->visibility =
'R';
601 $this->attributes->attr[
'us_extmail']->mvisibility =
'W';
602 $this->attributes->attr[
'us_extmail']->fieldSet = $this->attributes->attr[
'us_fr_coord'];
603 $this->attributes->attr[
'us_extmail']->ordered = $this->attributes->attr[
'us_pphone']->ordered - 1;
604 $this->attributes->orderAttributes();
626 $wuser = $this->getAccount();
627 if (!
$wuser->isAffected()) {
628 return sprintf(_(
"user #%d does not exist") , $idwuser);
631 $wuser->password_new = $password;
644 if ($this->
getRawValue(
"us_whatid") == 1)
return "";
645 $lf = intval($this->
getRawValue(
"us_loginfailure", 0)) + 1;
646 $err = $this->SetValue(
"us_loginfailure", $lf);
648 $this->
modify(
false, array(
660 if ($this->
getRawValue(
"us_whatid") == 1)
return "";
663 if (intval($this->
getRawValue(
"us_loginfailure")) > 0) {
682 $u = $this->getAccount();
683 if ($u && ($u->substitute == $this->getSystemUserId())) {
684 return parent::control($aclname,
true);
686 return parent::control($aclname,
$strict);
696 if (!$action->parent->hasPermission(
'FUSERS',
'FUSERS')) {
717 if (!$action->parent->hasPermission(
'FUSERS',
'FUSERS')) {
738 if (!$action->parent->hasPermission(
'FUSERS',
'FUSERS')) {
760 if ($this->
getRawValue(
"us_whatid") == 1)
return false;
761 $u = $this->getAccount();
763 return $u->status !=
'D';
775 if ($this->
canEdit() !=
'' || !$action->parent->hasPermission(
'FUSERS',
'FUSERS')) {
776 return _(
"current user cannot deactivate account");
782 $err = $this->SetValue(
"us_status",
'A');
803 if ($this->
canEdit() !=
'' || !$action->parent->hasPermission(
'FUSERS',
'FUSERS')) {
804 return _(
"current user cannot deactivate account");
810 $err = $this->SetValue(
"us_status",
'D');
821 if ($this->
getRawValue(
"us_whatid") == 1)
return false;
826 if (preg_match(
"|([0-9][0-9])/([0-9][0-9])/(2[0-9][0-9][0-9])|", $expd, $reg)) {
827 $expires = mktime(0, 0, 0, $reg[2], $reg[1], $reg[3]);
828 }
else if (preg_match(
"|(2[0-9][0-9][0-9])-([0-9][0-9])-([0-9][0-9])|", $expd, $reg)) {
829 $expires = mktime(0, 0, 0, $reg[2], $reg[3], $reg[1]);
831 return ($expires <= time());
clearArrayValues($idAttr)
& getAttribute($idAttr, &$oa=null, $useMask=true)
control($aclname, $strict=false)
preImport(array $extra=array())
canEdit($verifyDomain=true)
constraintPassword($pwd1, $pwd2, $login)
getArrayRawValues($idAttr, $index=-1)
getLDAPValue($idattr, $index="")
getFamilyParameterValue($idp, $def="")
viewprop($target="_self", $ulink=true, $abstract=false)
modify($nopost=false, $sfields="", $nopre=false)
getDocValue($docid, $attrid, $def=" ", $latest=false)
addArrayRow($idAttr, $tv, $index=-1)
getLayoutFile($app, $layfile)
static getMailAttribute()
editbodycard($target="_self", $ulink=true, $abstract=false, $onlyopt=false)
setValue($attrid, $value, $index=-1, &$kvalue=null)
getMultipleRawValues($idAttr, $def="", $index=-1)
editlikeperson($target="finfo", $ulink=true, $abstract="Y")
getParam($param, $defv="")
getTitle($id="-1", $def="", $latest=false)
deprecatedFunction($msg= '')
constraintExpires($expiresd, $expirest, $daydelay)
new_Doc($dbaccess, $id= '', $latest=false)
simpleQuery($dbaccess, $query, &$result=array(), $singlecolumn=false, $singleresult=false, $useStrict=null)
if($file) if($subject==""&&$file) if($subject=="") $err
getRawValue($idAttr, $def="")