summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTom Needham <needham.thomas@gmail.com>2012-07-29 16:07:51 +0000
committerTom Needham <needham.thomas@gmail.com>2012-07-29 16:07:51 +0000
commit0836366d8703b2663d11e2989f8dbbb3f7c0c18b (patch)
tree6cbba68004fa905d42de18ef933c84e09cec88a1
parent18f6552a086a94fd0dda5e7a47755c4560b15755 (diff)
downloadnextcloud-server-0836366d8703b2663d11e2989f8dbbb3f7c0c18b.tar.gz
nextcloud-server-0836366d8703b2663d11e2989f8dbbb3f7c0c18b.zip
Methods to disable and enable users
-rw-r--r--lib/user.php37
1 files changed, 35 insertions, 2 deletions
diff --git a/lib/user.php b/lib/user.php
index e3c9c23effa..49a0a2a10ce 100644
--- a/lib/user.php
+++ b/lib/user.php
@@ -208,8 +208,9 @@ class OC_User {
OC_Hook::emit( "OC_User", "pre_login", array( "run" => &$run, "uid" => $uid ));
if( $run ){
- $uid=self::checkPassword( $uid, $password );
- if($uid){
+ $uid = self::checkPassword( $uid, $password );
+ $enabled = self::isEnabled($uid);
+ if($uid && $enabled){
session_regenerate_id(true);
self::setUserId($uid);
OC_Hook::emit( "OC_User", "post_login", array( "uid" => $uid, 'password'=>$password ));
@@ -363,6 +364,38 @@ class OC_User {
}
return false;
}
+
+ /**
+ * disables a user
+ * @param string $userid the user to disable
+ */
+ public static function disableUser($userid){
+ $query = "INSERT INTO *PREFIX*preferences (`userid`, `appid`, `configkey`, `configvalue`) VALUES(?, ?, ?, ?)";
+ $query = OC_DB::prepare($query);
+ $query->execute(array($userid, 'core', 'enabled', 'false'));
+ }
+
+ /**
+ * enable a user
+ * @param string $userid
+ */
+ public static function enableUser($userid){
+ $query = "DELETE FROM *PREFIX*preferences WHERE userid = ? AND appid = ? AND configkey = ? AND configvalue = ?";
+ $query = OC_DB::prepare($query);
+ $query->execute(array($userid, 'core', 'enabled', 'false'));
+ }
+
+ /**
+ * checks if a user is enabled
+ * @param string $userid
+ * @return bool
+ */
+ public static function isEnabled($userid){
+ $query = "SELECT userid FROM *PREFIX*preferences WHERE userid = ? AND appid = ? AND configkey = ? AND configvalue = ?";
+ $query = OC_DB::prepare($query);
+ $results = $query->execute(array($userid, 'core', 'enabled', 'false'));
+ return $results->numRows() ? false : true;
+ }
/**
* @brief Set cookie value to use in next page load