31 "USERCARD:CHOOSEGROUP"
45 if ($this->
getValue(
"US_STATUS") ==
'D')
$err.= (
$err ==
"" ?
"" :
"\n") . _(
"user is deactivated");
47 $this->
SetValue(
"US_MEID", $this->
id);
48 $iduser = $this->
getValue(
"US_WHATID");
50 $user = $this->getWUser();
51 if (!
$user->isAffected())
return sprintf(_(
"user #%d does not exist") , $iduser);
53 if ($this->
getValue(
"us_login") !=
'-')
$err = _(
"user has not identificator");
55 if ($oa) $oa->needed =
true;
57 if ($oa) $oa->needed =
true;
59 $oa->setOption(
"firstopen",
"yes");
68 return ($this->
getValue(
"US_STATUS") !=
'D');
76 if ($this->
id == 0)
return array();
78 include_once (
"FDL/freedom_util.php");
79 include_once (
"FDL/Lib.Dir.php");
81 $sqlfilters[] =
"in_textlist(grp_idruser,{$this->id})";
93 $err =
simpleQuery($this->dbaccess, sprintf(
"SELECT id, fid from users, groups where groups.iduser=%d and users.id = groups.idgroup;", $this->
getValue(
"us_whatid")) , $groupIds,
false,
false);
96 foreach ($groupIds as $gid) {
97 $gids[$gid[
"id"]] = $gid[
"fid"];
111 $err =
simpleQuery($this->dbaccess, sprintf(
"SELECT id, fid from users, groups where groups.iduser=%d and users.id = groups.idgroup;", $gid) , $groupIds,
false,
false);
114 foreach ($groupIds as $gid) {
115 $gids[$gid[
"id"]] = $gid[
"fid"];
118 foreach ($gids as $systemGid => $docGid) {
121 $groupIds = $gids + $pgids;
139 foreach (
$tgid as $gid) {
140 $gdoc =
new_Doc($this->dbaccess, $gid);
141 if ($gdoc->isAlive()) {
142 $gdoc->insertGroups();
155 $wuser = $this->getWuser(
true);
157 if ($wuser->isAffected()) {
158 $this->
SetValue(
"US_WHATID", $wuser->id);
159 $this->
SetValue(
"US_LNAME", $wuser->lastname);
160 $this->
SetValue(
"US_FNAME", $wuser->firstname);
161 $this->
SetValue(
"US_PASSWD", $wuser->password);
164 $this->
SetValue(
"US_LOGIN", $wuser->login);
165 $this->
SetValue(
"US_STATUS", $wuser->status);
166 $this->
SetValue(
"US_PASSDELAY", $wuser->passdelay);
167 $this->
SetValue(
"US_EXPIRES", $wuser->expires);
168 $this->
SetValue(
"US_DAYDELAY", $wuser->passdelay / 3600 / 24);
169 $this->
SetValue(
"US_IDDOMAIN", $wuser->iddomain);
170 include_once (
"Class.Domain.php");
171 $dom =
new Domain(
"", $wuser->iddomain);
172 $this->
SetValue(
"US_DOMAIN", $dom->name);
173 $mail = $wuser->getMail();
175 else $this->
SetValue(
"US_MAIL", $mail);
176 if ($wuser->passdelay <> 0) {
177 $this->
SetValue(
"US_EXPIRESD", strftime(
"%d/%m/%Y", $wuser->expires));
178 $this->
SetValue(
"US_EXPIREST", strftime(
"%H:%M", $wuser->expires));
180 $this->
SetValue(
"US_EXPIRESD",
" ");
181 $this->
SetValue(
"US_EXPIREST",
" ");
184 $this->
SetValue(
"US_MEID", $this->
id);
188 if (count($g->groups) > 0) {
189 foreach ($g->groups as $gid) {
190 $gt =
new User(
"", $gid);
191 $tgid[$gid] = $gt->fid;
192 $tglogin[$gid] = $this->
getTitle($gt->fid);
194 $this->
SetValue(
"US_GROUP", $tglogin);
202 $err = sprintf(_(
"user %d does not exist") ,
$wid);
215 $grp = new_doc($this->dbaccess, $grpid);
216 if ($grp->isAlive()) {
217 $err = $grp->addFile($this->initid);
227 $ed = $action->getParam(
"AUTHENT_ACCOUNTEXPIREDELAY");
229 $expdate = time() + ($ed * 24 * 3600);
230 $err = $this->
SetValue(
"us_accexpiredate", strftime(
"%d/%m/%Y 00:00:00", $expdate));
242 $uid = $this->GetValue(
"US_WHATID");
243 $lname = $this->GetValue(
"US_LNAME");
244 $fname = $this->GetValue(
"US_FNAME");
245 $pwd1 = $this->GetValue(
"US_PASSWD1");
246 $pwd2 = $this->GetValue(
"US_PASSWD2");
247 $pwd = $this->GetValue(
"US_PASSWD");
248 $expires = $this->GetValue(
"US_EXPIRES");
249 $daydelay = $this->GetValue(
"US_DAYDELAY");
250 if ($daydelay == - 1) $passdelay = $daydelay;
251 else $passdelay = intval($daydelay) * 3600 * 24;
252 $status = $this->GetValue(
"US_STATUS");
253 $login = $this->GetValue(
"US_LOGIN");
254 $extmail = $this->GetValue(
"US_EXTMAIL", $this->
getValue(
"us_homemail",
" "));
259 $expiresd = $this->GetValue(
"US_EXPIRESD");
260 $expirest = $this->GetValue(
"US_EXPIREST",
"00:00");
262 $expdate = $expiresd .
" " . $expirest .
":00";
264 if ($expdate !=
"") {
265 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)) {
266 $expires = mktime($reg[4], $reg[5], $reg[6], $reg[2], $reg[1], $reg[3]);
267 }
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)) {
268 $expires = mktime($reg[4], $reg[5], $reg[6], $reg[2], $reg[3], $reg[1]);
272 $iddomain = $this->GetValue(
"US_IDDOMAIN");
273 $domain = $this->GetValue(
"US_DOMAIN");
277 $user = $this->getWUser();
280 $this->wuser = &
$user;
283 $err.=
$user->SetUsers($fid, $lname, $fname, $expires, $passdelay, $login, $status, $pwd1, $pwd2, $iddomain, $extmail);
286 $this->setValue(
"US_WHATID",
$user->id);
287 $this->
modify(
false, array(
290 $err = $this->setGroups();
293 if (($pwd1 ==
"") && ($pwd1 == $pwd2) && ($pwd !=
"")) {
294 if (($pwd !=
$user->password) && (strlen($pwd) > 12)) {
295 $user->password = $pwd;
309 if ($this->
getValue(
"us_login") ==
"-") {
310 $this->setValue(
"US_IDDOMAIN",
"0");
312 if (($email !=
"") && ($email[0] !=
"<")) $this->setValue(
"us_mail", $email);
313 else $this->deleteValue(
"us_mail");
317 $this->setValue(
"US_LDAPDN", $this->
getLDAPValue(
"dn", 1));
325 $user = $this->getWUser();
336 $_POST[
"gidnew"] =
"N";
345 if ($pwd1 <> $pwd2) {
346 $err = _(
"the 2 passwords are not the same");
347 }
else if (($pwd1 ==
"") && ($this->
getValue(
"us_whatid") ==
"")) {
348 if ($login !=
"-")
$err = _(
"passwords must not be empty");
360 if (($expiresd <>
"") && ($daydelay == 0)) {
361 $err = _(
"Expiration delay must not be 0 to keep expiration date");
376 $this->attributes->attr[
'us_tab_system']->visibility =
'R';
377 $this->attributes->attr[
'us_fr_userchange']->visibility =
'R';
379 if ($this->
getValue(
"us_iddomain") == 0) {
380 $this->attributes->attr[
'us_extmail']->mvisibility =
'W';
381 $this->attributes->attr[
'us_extmail']->fieldSet = $this->attributes->attr[
'us_fr_coord'];
382 $this->attributes->attr[
'us_extmail']->ordered = $this->attributes->attr[
'us_pphone']->ordered - 1;
383 uasort($this->attributes->attr,
"tordered");
394 $action->parent->AddCssRef(
"USERCARD:faddbook.css",
true);
395 $action->parent->AddJsRef($action->GetParam(
"CORE_PUBURL") .
"/USERCARD/Layout/faddbook.js");
429 foreach (
$la as $k => $v) {
431 if (($va || ($v->type ==
"array")) && (!in_array($v->id,
$ta)) && (!$v->inArray())) {
433 if ((($v->mvisibility ==
"R") || ($v->mvisibility ==
"W"))) {
434 if ($v->type ==
"array") {
438 "lothers" => $v->labelText,
443 $tabs[$v->fieldSet->labelText][] = $v->id;
447 "lothers" => $v->labelText,
449 "vothers" => $this->getHtmlValue($v, $va,
$target, $ulink) ,
452 $tabs[$v->fieldSet->labelText][] = $v->id;
457 $this->lay->setBlockData(
"OTHERS",
$to);
458 $this->lay->set(
"HasOTHERS", (count(
$to) > 0));
459 $this->lay->set(
"HasDOMAIN", ($this->
getValue(
"US_IDDOMAIN") > 9));
460 $this->lay->set(
"HasDPassword", (intval($this->
getValue(
"US_DAYDELAY")) != 0));
462 foreach ($tabs as $k => $v) {
465 "aids" =>
"['" . implode(
"','", $v) .
"']"
468 $this->lay->setBlockData(
"TABS", $ltabs);
469 $this->lay->set(
"CanEdit", ($this->control(
"edit") ==
""));
483 $action->parent->AddCssRef(
"USERCARD:faddbook.css",
true);
484 $action->parent->AddJsRef($action->GetParam(
"CORE_PUBURL") .
"/USERCARD/Layout/faddbook.js");
485 $firsttab = getHttpVars(
"tab");
530 $la = $this->getNormalAttributes();
532 $this->lay->set(
"editgroup", (
$la[
"us_group"]->mvisibility ==
"W"));
533 $this->lay->set(
"firsttab", $firsttab);
537 foreach (
$la as $k => $v) {
539 if (!$v->inArray() && (!in_array($v->id,
$ta))) {
540 if ($v->mvisibility !=
"I") {
541 if ($v->type ==
"array") {
544 if ($v->mvisibility !=
"H") {
546 "lothers" => $v->labelText,
551 $tabs[$v->fieldSet->labelText][] = $v->id;
560 if ($v->mvisibility !=
"H") {
562 "lothers" => $v->labelText,
567 $tabs[$v->fieldSet->labelText][] = $v->id;
578 $this->lay->setBlockData(
"OTHERS",
$to);
579 $this->lay->setBlockData(
"IHIDDENS", $th);
580 $this->lay->set(
"HasOTHERS", (count(
$to) > 0));
582 foreach ($tabs as $k => $v) {
585 "aids" =>
"['" . implode(
"','", $v) .
"']"
588 $this->lay->setBlockData(
"TABS", $ltabs);
596 $idwuser = $this->
getValue(
"US_WHATID");
598 $wuser = $this->getWUser();
599 if (!$wuser->isAffected()) {
600 return sprintf(_(
"user #%d does not exist") , $idwuser);
604 $err = $wuser->modify();
625 if ($this->
getValue(
"us_whatid") == 1)
return "";
626 $lf = $this->
getValue(
"us_loginfailure", 0) + 1;
640 if ($this->
getValue(
"us_whatid") == 1)
return "";
641 if (intval($this->
getValue(
"us_loginfailure")) > 0) {
642 $err = $this->setValue(
"us_loginfailure", 0);
658 if (!$action->parent->hasPermission(
'FUSERS',
'FUSERS')) {
666 if ($this->
getValue(
'us_whatid') == 1) {
670 if ($this->
getValue(
"us_loginfailure") <= 0) {
678 if (!$action->parent->hasPermission(
'FUSERS',
'FUSERS')) {
686 if ($this->
getValue(
'us_whatid') == 1) {
690 if ($this->
getValue(
'us_status',
'A') ==
'A') {
698 if (!$action->parent->hasPermission(
'FUSERS',
'FUSERS')) {
706 if ($this->
getValue(
'us_whatid') == 1) {
710 if ($this->
getValue(
'us_status',
'A') !=
'A') {
720 if ($this->
getValue(
"us_whatid") == 1)
return false;
721 return ($this->
getValue(
"us_status",
'A') ==
'A');
727 if ($this->
canEdit() !=
'' || !$action->parent->hasPermission(
'FUSERS',
'FUSERS')) {
728 return _(
"current user cannot activate account");
731 if ($this->
getValue(
"us_whatid") == 1) {
745 if ($this->
getValue(
"us_whatid") == 1)
return false;
746 return ($this->
getValue(
"us_status",
'A') !=
'A');
752 if ($this->
canEdit() !=
'' || !$action->parent->hasPermission(
'FUSERS',
'FUSERS')) {
753 return _(
"current user cannot deactivate account");
756 if ($this->
getValue(
"us_whatid") == 1) {
770 if ($this->
getValue(
"us_whatid") == 1)
return false;
771 $expd = $this->GetValue(
"us_accexpiredate");
775 if (preg_match(
"|([0-9][0-9])/([0-9][0-9])/(2[0-9][0-9][0-9])|", $expd, $reg)) {
776 $expires = mktime(0, 0, 0, $reg[2], $reg[1], $reg[3]);
777 }
else if (preg_match(
"|(2[0-9][0-9][0-9])-([0-9][0-9])-([0-9][0-9]|", $expd, $reg)) {
778 $expires = mktime(0, 0, 0, $reg[2], $reg[3], $reg[1]);
780 return ($expires <= time());