change user Seminary roles to Character roles

This commit is contained in:
coderkun 2014-04-23 20:06:58 +02:00
commit 2185a7c2a4
26 changed files with 145 additions and 156 deletions

View file

@ -0,0 +1,57 @@
<?php
/**
* The Legend of Z
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
* @license http://www.gnu.org/licenses/gpl.html
* @link https://bitbucket.org/coderkun/the-legend-of-z
*/
namespace hhu\z\models;
/**
* Model to interact with characterroles-table.
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
*/
class CharacterrolesModel extends \hhu\z\Model
{
/**
* Construct a new CharacterrolesModel.
*/
public function __construct()
{
parent::__construct();
}
/**
* Get all characterroles for a Character referenced by its ID.
*
* @param int $userId ID of an user
* @return array Characterroles for a Character
*/
public function getCharacterrolesForCharacterById($characterId)
{
return $this->db->query(
'SELECT characterroles.id, characterroles.created, characterroles.name '.
'FROM characters_characterroles '.
'LEFT JOIN characterroles ON characterroles.id = characters_characterroles.characterrole_id '.
'WHERE characters_characterroles.character_id = ?',
'i',
$characterId
);
}
}
?>

View file

@ -468,6 +468,29 @@
);
}
/**
* Get Characters with the given Character role.
*
* @param int $seminaryId ID of Seminary
* @param string $characterrole Character role
* @return array List of users
*/
public function getCharactersWithCharacterRole($seminaryId, $characterrole)
{
return $this->db->query(
'SELECT characters.id, characters.created, characters.charactertype_id, characters.name, characters.url, characters.user_id, characters.xps, characters.xplevel, characters.avatar_id, charactertypes.name AS charactertype_name, charactertypes.url AS charactertype_url, seminaries.id AS seminary_url, seminaries.title AS seminary_title, seminaries.url AS seminary_url '.
'FROM v_characters AS characters '.
'LEFT JOIN charactertypes ON charactertypes.id = characters.charactertype_id '.
'LEFT JOIN seminaries ON seminaries.id = charactertypes.seminary_id '.
'LEFT JOIN characters_characterroles ON characters_characterroles.character_id = characters.id '.
'LEFT JOIN characterroles ON characterroles.id = characters_characterroles.characterrole_id '.
'WHERE seminaries.id = ? AND characterroles.name = ?',
'is',
$seminaryId, $characterrole
);
}
}
?>

View file

@ -70,28 +70,6 @@
}
/**
* 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.
*

View file

@ -1,78 +0,0 @@
<?php
/**
* The Legend of Z
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
* @license http://www.gnu.org/licenses/gpl.html
* @link https://bitbucket.org/coderkun/the-legend-of-z
*/
namespace hhu\z\models;
/**
* Model to interact with userseminaryroles-table.
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
*/
class UserseminaryrolesModel extends \hhu\z\Model
{
/**
* Construct a new UserseminaryrolesModel.
*/
public function __construct()
{
parent::__construct();
}
/**
* Get all userseminaryroles for an user referenced by its ID.
*
* @param int $userId ID of an user
* @return array Userseminaryroles for an user
*/
public function getUserseminaryrolesForUserById($userId, $seminaryId)
{
return $this->db->query(
'SELECT userseminaryroles.id, userseminaryroles.created, userseminaryroles.name '.
'FROM users_userseminaryroles '.
'LEFT JOIN userseminaryroles ON userseminaryroles.id = users_userseminaryroles.userseminaryrole_id '.
'WHERE users_userseminaryroles.user_id = ? AND users_userseminaryroles.seminary_id = ?',
'ii',
$userId, $seminaryId
);
}
/**
* Get all userseminaryroles for an user referenced by its
* URL-username.
*
* @param string $userUrl URL-Username of an user
* @return array Userseminaryroles for an user
*/
public function getUserrolesForUserByUrl($userUrl)
{
return $this->db->query(
'SELECT userroles.id, userroles.created, userroles.name '.
'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.url = ?',
's',
$userUrl
);
}
}
?>