Newer
Older
if ($vars['username'] && strcasecmp($vars['username'], $user->getEmail()))
$account->set('username', $vars['username']);
if ($vars['passwd1'] && !$vars['sendemail']) {
$account->set('passwd', Passwd::hash($vars['passwd1']));
$account->setStatus(UserAccountStatus::CONFIRMED);
if ($vars['pwreset-flag'])
$account->setStatus(UserAccountStatus::REQUIRE_PASSWD_RESET);
if ($vars['forbid-pwreset-flag'])
$account->setStatus(UserAccountStatus::FORBID_PASSWD_RESET);
elseif ($vars['backend'] && $vars['backend'] != 'client') {
// Auto confirm remote accounts
$account->setStatus(UserAccountStatus::CONFIRMED);
if (!$account->isConfirmed() && $vars['sendemail'])
$account->sendConfirmEmail();
return $account;
}
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
class UserAccountStatus {
var $flag;
const CONFIRMED = 0x0001;
const LOCKED = 0x0002;
const REQUIRE_PASSWD_RESET = 0x0004;
const FORBID_PASSWD_RESET = 0x0008;
function __construct($flag) {
$this->flag = $flag;
}
function check($flag) {
return 0 !== ($this->flag & $flag);
}
function isLocked() {
return $this->check(self::LOCKED);
}
function isConfirmed() {
return $this->check(self::CONFIRMED);
}
function __toString() {
if ($this->isLocked())
return 'Locked (Administrative)';
if (!$this->isConfirmed())
return 'Locked (Pending Activation)';
// ... Other flags here (password reset, etc).
return 'Active (Registered)';
}
}
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
/*
* Generic user list.
*/
class UserList implements IteratorAggregate, ArrayAccess {
private $users;
function __construct($list = array()) {
$this->users = $list;
}
function add($user) {
$this->offsetSet(null, $user);
}
function offsetSet($offset, $value) {
if (is_null($offset))
$this->users[] = $value;
else
$this->users[$offset] = $value;
}
function offsetExists($offset) {
return isset($this->users[$offset]);
}
function offsetUnset($offset) {
unset($this->users[$offset]);
}
function offsetGet($offset) {
return isset($this->users[$offset]) ? $this->users[$offset] : null;
}
function getIterator() {
return new ArrayIterator($this->users);
}
function __toString() {
$list = array();
foreach($this->users as $user) {
if (is_object($user))
$list [] = $user->getName();
}
return $list ? implode(', ', $list) : '';
}
}
require_once(INCLUDE_DIR . 'class.organization.php');
UserAccount::_inspect();