check if unique values already exists for user and Character registration and send notification mail to moderators

This commit is contained in:
coderkun 2014-04-16 13:42:19 +02:00
commit babfe5b017
11 changed files with 290 additions and 34 deletions

View file

@ -49,6 +49,49 @@
}
/**
* Get users with the given user role.
*
* @param string $userrole User role
* @return array List of users
*/
public function getUsersWithRole($userrole)
{
return $this->db->query(
'SELECT users.id, users.created, users.username, users.url, users.surname, users.prename, users.email '.
'FROM users '.
'LEFT JOIN users_userroles ON users_userroles.user_id = users.id '.
'LEFT JOIN userroles ON userroles.id = users_userroles.userrole_id '.
'WHERE userroles.name = ? '.
'ORDER BY username ASC',
's',
$userrole
);
}
/**
* Get users with the given user Seminary role.
*
* @param int $seminaryId ID of Seminary
* @param string $userseminaryrole User Seminary role
* @return array List of users
*/
public function getUsersWithSeminaryRole($seminaryId, $userseminaryrole)
{
return $this->db->query(
'SELECT users.id, users.created, users.username, users.url, users.surname, users.prename, users.email '.
'FROM users '.
'LEFT JOIN users_userseminaryroles ON users_userseminaryroles.user_id = users.id '.
'LEFT JOIN userseminaryroles ON userseminaryroles.id = users_userseminaryroles.userseminaryrole_id '.
'WHERE users_userseminaryroles.seminary_id = ? AND userseminaryroles.name = ? '.
'ORDER BY username ASC',
'is',
$seminaryId, $userseminaryrole
);
}
/**
* Get a user and its data by its ID.
*
@ -124,6 +167,55 @@
}
/**
* Check if an username already exists.
*
* @param string $username Username to check
* @return boolean Whether username exists or not
*/
public function usernameExists($username)
{
$data = $this->db->query(
'SELECT count(id) AS c '.
'FROM users '.
'WHERE username = ? OR url = ?',
'ss',
$username,
\nre\core\Linker::createLinkParam($username)
);
if(!empty($data)) {
return ($data[0]['c'] > 0);
}
return false;
}
/**
* Check if an email address already exists.
*
* @param string $email Email address to check
* @return boolean Whether email address exists or not
*/
public function emailExists($email)
{
$data = $this->db->query(
'SELECT count(id) AS c '.
'FROM users '.
'WHERE email = ?',
's',
$email
);
if(!empty($data)) {
return ($data[0]['c'] > 0);
}
return false;
}
/**
* Create a new user.
*