diff options
author | ben <ben@36083f99-b078-4883-b0ff-0f9b5a30f544> | 2009-02-04 13:05:44 +0000 |
---|---|---|
committer | ben <ben@36083f99-b078-4883-b0ff-0f9b5a30f544> | 2009-02-04 13:05:44 +0000 |
commit | a8d7ea23f8868aa70dd6fe87482e3b860e0b615f (patch) | |
tree | d05bc4749587fcd8141d70d5c1ca505793150ac2 /engine/lib/users.php | |
parent | 114bf6e56152d407f660cf5060972f3bfa4fd8ff (diff) | |
download | elgg-a8d7ea23f8868aa70dd6fe87482e3b860e0b615f.tar.gz elgg-a8d7ea23f8868aa70dd6fe87482e3b860e0b615f.tar.bz2 |
Moves access permissions references over to using the ACCESS_* constants defined in access.php. Refs #687
git-svn-id: https://code.elgg.org/elgg/trunk@2639 36083f99-b078-4883-b0ff-0f9b5a30f544
Diffstat (limited to 'engine/lib/users.php')
-rw-r--r-- | engine/lib/users.php | 192 |
1 files changed, 96 insertions, 96 deletions
diff --git a/engine/lib/users.php b/engine/lib/users.php index baf3b5950..adbea4ede 100644 --- a/engine/lib/users.php +++ b/engine/lib/users.php @@ -46,7 +46,7 @@ $this->attributes['salt'] = "";
$this->attributes['email'] = "";
$this->attributes['language'] = "";
- $this->attributes['code'] = ""; + $this->attributes['code'] = "";
$this->attributes['banned'] = "no";
$this->attributes['tables_split'] = 2;
}
@@ -156,25 +156,25 @@ return parent::delete();
- } - - /** - * Ban this user. - * - * @param string $reason Optional reason - */ - public function ban($reason = "") { return ban_user($this->guid, $reason); } - - /** - * Unban this user. - */ - public function unban() { return unban_user($this->guid); } - - /** - * Is this user banned or not? - * - * @return bool - */ + }
+
+ /**
+ * Ban this user.
+ *
+ * @param string $reason Optional reason
+ */
+ public function ban($reason = "") { return ban_user($this->guid, $reason); }
+
+ /**
+ * Unban this user.
+ */
+ public function unban() { return unban_user($this->guid); }
+
+ /**
+ * Is this user banned or not?
+ *
+ * @return bool
+ */
public function isBanned() { return $this->banned == 'yes'; }
/**
@@ -419,78 +419,78 @@ }
return false;
- } - - /** - * Disables all of a user's entities - * - * @param int $owner_guid The owner GUID - * @return true|false Depending on success - */ - function disable_user_entities($owner_guid) { - - global $CONFIG; - $owner_guid = (int) $owner_guid; - if ($entity = get_entity($owner_guid)) { - if (trigger_elgg_event('disable',$entity->type,$entity)) { - if ($entity->canEdit()) { - $res = update_data("UPDATE {$CONFIG->dbprefix}entities set enabled='no' where owner_guid={$owner_guid} or container_guid = {$owner_guid}"); - return $res; - } - } - } - return false; - - } - - /** - * Ban a user - * - * @param int $user_guid The user guid - * @param string $reason A reason - */ - function ban_user($user_guid, $reason = "") - { - global $CONFIG; - - $user_guid = (int)$user_guid; - $reason = sanitise_string($reason); - - $user = get_entity($user_guid); - - if (($user) && ($user->canEdit()) && ($user instanceof ElggUser)) - { - // Add reason - if ($reason) - create_metadata($user_guid, 'ban_reason', $reason,'', 0, 2); - - // Set ban flag - return update_data("UPDATE {$CONFIG->dbprefix}users_entity set banned='yes' where guid=$user_guid"); - } - - return false; - } - - /** - * Unban a user. - * - * @param int $user_guid Unban a user. - */ - function unban_user($user_guid) - { - global $CONFIG; - - $user_guid = (int)$user_guid; - - $user = get_entity($user_guid); - - if (($user) && ($user->canEdit()) && ($user instanceof ElggUser)) - { - create_metadata($user_guid, 'ban_reason', '','', 0, 2); - return update_data("UPDATE {$CONFIG->dbprefix}users_entity set banned='no' where guid=$user_guid"); - } - - return false; + }
+
+ /**
+ * Disables all of a user's entities
+ *
+ * @param int $owner_guid The owner GUID
+ * @return true|false Depending on success
+ */
+ function disable_user_entities($owner_guid) {
+
+ global $CONFIG;
+ $owner_guid = (int) $owner_guid;
+ if ($entity = get_entity($owner_guid)) {
+ if (trigger_elgg_event('disable',$entity->type,$entity)) {
+ if ($entity->canEdit()) {
+ $res = update_data("UPDATE {$CONFIG->dbprefix}entities set enabled='no' where owner_guid={$owner_guid} or container_guid = {$owner_guid}");
+ return $res;
+ }
+ }
+ }
+ return false;
+
+ }
+
+ /**
+ * Ban a user
+ *
+ * @param int $user_guid The user guid
+ * @param string $reason A reason
+ */
+ function ban_user($user_guid, $reason = "")
+ {
+ global $CONFIG;
+
+ $user_guid = (int)$user_guid;
+ $reason = sanitise_string($reason);
+
+ $user = get_entity($user_guid);
+
+ if (($user) && ($user->canEdit()) && ($user instanceof ElggUser))
+ {
+ // Add reason
+ if ($reason)
+ create_metadata($user_guid, 'ban_reason', $reason,'', 0, ACCESS_PUBLIC);
+
+ // Set ban flag
+ return update_data("UPDATE {$CONFIG->dbprefix}users_entity set banned='yes' where guid=$user_guid");
+ }
+
+ return false;
+ }
+
+ /**
+ * Unban a user.
+ *
+ * @param int $user_guid Unban a user.
+ */
+ function unban_user($user_guid)
+ {
+ global $CONFIG;
+
+ $user_guid = (int)$user_guid;
+
+ $user = get_entity($user_guid);
+
+ if (($user) && ($user->canEdit()) && ($user instanceof ElggUser))
+ {
+ create_metadata($user_guid, 'ban_reason', '','', 0, ACCESS_PUBLIC);
+ return update_data("UPDATE {$CONFIG->dbprefix}users_entity set banned='no' where guid=$user_guid");
+ }
+
+ return false;
}
/**
@@ -930,7 +930,7 @@ {
// generate code
$code = generate_random_cleartext_password();
- //create_metadata($user_guid, 'conf_code', $code,'', 0, 0);
+ //create_metadata($user_guid, 'conf_code', $code,'', 0, ACCESS_PRIVATE);
set_private_setting($user_guid, 'passwd_conf_code', $code);
// generate link
@@ -1016,8 +1016,8 @@ {
if (!$status) $method = '';
- create_metadata($user_guid, 'validated', $status,'', 0, 2);
- create_metadata($user_guid, 'validated_method', $method,'', 0, 2);
+ create_metadata($user_guid, 'validated', $status,'', 0, ACCESS_PUBLIC);
+ create_metadata($user_guid, 'validated_method', $method,'', 0, ACCESS_PUBLIC);
return true;
}
@@ -1225,7 +1225,7 @@ $user->username = $username;
$user->email = $email;
$user->name = $name;
- $user->access_id = 2;
+ $user->access_id = ACCESS_PUBLIC;
$user->salt = generate_random_cleartext_password(); // Note salt generated before password!
$user->password = generate_user_password($user, $password);
$user->save();
|