Commit bfd908ff authored by Freddy's avatar Freddy
Browse files

Merge branch 'user-exists' into 'master'

Add checkUserExistence

See merge request Cygnus/Cygnus!14
parents 3ab11dea 9800df01
......@@ -586,8 +586,19 @@ class Core extends Password {
} else
return 'success';
}
// User related functions
/** checkUserExistence
* checks if a user exists
* @author Luke081515
* @param $username - The username of the user
* @returs true if the user does exist, false if not
*/
public function checkUserExistence($username) {
$result = $this->httpRequest('action=query&format=json&list=users&usprop=&ususers=' . urlencode($username), $this->job, 'GET');
if (isset($result['query']['users'][0]['missing']))
return false;
return true;
}
/** getUserEditcount
* returns the editcount of a user, false if the user does not exist
* @author Luke081515
......
......@@ -254,6 +254,20 @@ class Debug extends Core {
}
break;
// User information functions
case 'checkUserExistence':
$required = array("username");
$Param = $this->getParams($required);
$this->echoNotice('Starting the function call of checkUserExistence...');
$starttime = microtime(true);
try {
$ret = $this->checkUserExistence($Param[0]);
$endtime = microtime(true);
$this->processFunction($ret, $starttime, $endtime);
} catch (Exception $e) {
$endtime = microtime (true);
$this->processError($e, $starttime, $endtime);
}
break;
case 'getUserEditcount':
$required = array("username");
$Param = $this->getParams($required);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment