change user Seminary roles to Character roles
This commit is contained in:
parent
87f58e2c5b
commit
2185a7c2a4
26 changed files with 145 additions and 156 deletions
|
|
@ -17,7 +17,7 @@
|
|||
*
|
||||
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
||||
*/
|
||||
class AchievementsController extends \hhu\z\controllers\SeminaryRoleController
|
||||
class AchievementsController extends \hhu\z\controllers\SeminaryController
|
||||
{
|
||||
/**
|
||||
* Required models
|
||||
|
|
@ -59,7 +59,7 @@
|
|||
$seminary = $this->Seminaries->getSeminaryByUrl($seminaryUrl);
|
||||
|
||||
// Get Character
|
||||
$character = SeminaryRoleController::$character;
|
||||
$character = SeminaryController::$character;
|
||||
|
||||
// Get seldom Achievements
|
||||
$seldomAchievements = $this->Achievements->getSeldomAchievements($seminary['id'], \nre\configs\AppConfig::$misc['achievements_range']);
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@
|
|||
*
|
||||
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
||||
*/
|
||||
class CharactergroupsController extends \hhu\z\controllers\SeminaryRoleController
|
||||
class CharactergroupsController extends \hhu\z\controllers\SeminaryController
|
||||
{
|
||||
/**
|
||||
* Required models
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@
|
|||
*
|
||||
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
||||
*/
|
||||
class CharactergroupsquestsController extends \hhu\z\controllers\SeminaryRoleController
|
||||
class CharactergroupsquestsController extends \hhu\z\controllers\SeminaryController
|
||||
{
|
||||
/**
|
||||
* Required models
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@
|
|||
*
|
||||
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
||||
*/
|
||||
class CharactersController extends \hhu\z\controllers\SeminaryRoleController
|
||||
class CharactersController extends \hhu\z\controllers\SeminaryController
|
||||
{
|
||||
/**
|
||||
* Required models
|
||||
|
|
@ -268,9 +268,10 @@
|
|||
// Send notification mail to system moderators
|
||||
$subject = sprintf('new Character registration: %s', $charactername);
|
||||
$message = sprintf('User “%s” <%s> has registered a new Character “%s” for the Seminary “%s”', self::$user['username'], self::$user['email'], $charactername, self::$seminary['title']);
|
||||
$moderators = $this->Users->getUsersWithSeminaryRole(self::$seminary['id'], 'moderator');
|
||||
foreach($moderators as &$moderator)
|
||||
$characters = $this->Characters->getCharactersWithCharacterRole(self::$seminary['id'], 'moderator');
|
||||
foreach($characters as &$character)
|
||||
{
|
||||
$moderator = $this->Users->getUserById($character['user_id']);
|
||||
\hhu\z\Utils::sendMail($sender, $moderator['email'], $subject, $message);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -50,8 +50,8 @@
|
|||
|
||||
// Set userdata
|
||||
$this->set('loggedUser', IntermediateController::$user);
|
||||
$this->set('loggedSeminary', SeminaryRoleController::$seminary);
|
||||
$this->set('loggedCharacter', SeminaryRoleController::$character);
|
||||
$this->set('loggedSeminary', SeminaryController::$seminary);
|
||||
$this->set('loggedCharacter', SeminaryController::$character);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@
|
|||
*
|
||||
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
||||
*/
|
||||
class LibraryController extends \hhu\z\controllers\SeminaryRoleController
|
||||
class LibraryController extends \hhu\z\controllers\SeminaryController
|
||||
{
|
||||
/**
|
||||
* Required models
|
||||
|
|
@ -59,7 +59,7 @@
|
|||
$seminary = $this->Seminaries->getSeminaryByUrl($seminaryUrl);
|
||||
|
||||
// Get Character
|
||||
$character = SeminaryRoleController::$character;
|
||||
$character = SeminaryController::$character;
|
||||
|
||||
// Get Quest topics
|
||||
$totalQuestcount = 0;
|
||||
|
|
@ -100,7 +100,7 @@
|
|||
$seminary = $this->Seminaries->getSeminaryByUrl($seminaryUrl);
|
||||
|
||||
// Get Character
|
||||
$character = SeminaryRoleController::$character;
|
||||
$character = SeminaryController::$character;
|
||||
|
||||
// Get Questtopic
|
||||
$questtopic = $this->Questtopics->getQuesttopicByUrl($seminary['id'], $questtopicUrl);
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@
|
|||
*
|
||||
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
||||
*/
|
||||
class MediaController extends \hhu\z\controllers\SeminaryRoleController
|
||||
class MediaController extends \hhu\z\controllers\SeminaryController
|
||||
{
|
||||
/**
|
||||
* User permissions
|
||||
|
|
@ -220,7 +220,7 @@
|
|||
$seminary = $this->Seminaries->getSeminaryByUrl($seminaryUrl);
|
||||
|
||||
// Get Character
|
||||
$character = SeminaryRoleController::$character;
|
||||
$character = SeminaryController::$character;
|
||||
|
||||
// Get Achievement
|
||||
$achievement = $this->Achievements->getAchievementByUrl($seminary['id'], $achievementUrl);
|
||||
|
|
|
|||
|
|
@ -35,8 +35,8 @@
|
|||
|
||||
// Set userdata
|
||||
$this->set('loggedUser', IntermediateController::$user);
|
||||
$this->set('loggedCharacter', SeminaryRoleController::$character);
|
||||
$this->set('loggedSeminary', SeminaryRoleController::$seminary);
|
||||
$this->set('loggedCharacter', SeminaryController::$character);
|
||||
$this->set('loggedSeminary', SeminaryController::$seminary);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@
|
|||
*
|
||||
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
||||
*/
|
||||
class QuestgroupsController extends \hhu\z\controllers\SeminaryRoleController
|
||||
class QuestgroupsController extends \hhu\z\controllers\SeminaryController
|
||||
{
|
||||
/**
|
||||
* Required models
|
||||
|
|
@ -71,7 +71,7 @@
|
|||
$character = $this->Characters->getCharacterForUserAndSeminary($this->Auth->getUserId(), $seminary['id']);
|
||||
|
||||
// Check permission
|
||||
if(count(array_intersect(array('admin','moderator'), IntermediateController::$user['seminaryroles'])) == 0)
|
||||
if(count(array_intersect(array('admin','moderator'), SeminaryController::$character['characterroles'])) == 0)
|
||||
{
|
||||
$previousQuestgroup = $this->Questgroups->getPreviousQuestgroup($questgroup['id']);
|
||||
if(!is_null($previousQuestgroup)) {
|
||||
|
|
@ -97,7 +97,7 @@
|
|||
$group['solved'] = $this->Questgroups->hasCharacterSolvedQuestgroup($group['id'], $character['id']);
|
||||
|
||||
// Check permission of Questgroups
|
||||
if($i >= 1 && count(array_intersect(array('admin','moderator'), IntermediateController::$user['seminaryroles'])) == 0)
|
||||
if($i >= 1 && count(array_intersect(array('admin','moderator'), SeminaryController::$character['characterroles'])) == 0)
|
||||
{
|
||||
if(!$hierarchy['questgroups'][$i-1]['solved'])
|
||||
{
|
||||
|
|
@ -170,7 +170,7 @@
|
|||
$quests[] = $currentQuest;
|
||||
}
|
||||
}
|
||||
while(!is_null($currentQuest) && ($currentQuest['solved'] || count(array_intersect(array('admin','moderator'), IntermediateController::$user['seminaryroles'])) > 0));
|
||||
while(!is_null($currentQuest) && ($currentQuest['solved'] || count(array_intersect(array('admin','moderator'), SeminaryController::$character['characterroles'])) > 0));
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@
|
|||
*
|
||||
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
||||
*/
|
||||
class QuestsController extends \hhu\z\controllers\SeminaryRoleController
|
||||
class QuestsController extends \hhu\z\controllers\SeminaryController
|
||||
{
|
||||
/**
|
||||
* Required models
|
||||
|
|
@ -146,7 +146,7 @@
|
|||
$character = $this->Characters->getCharacterForUserAndSeminary($this->Auth->getUserId(), $seminary['id']);
|
||||
|
||||
// Check permissions
|
||||
if(count(array_intersect(array('admin','moderator'), IntermediateController::$user['seminaryroles'])) == 0)
|
||||
if(count(array_intersect(array('admin','moderator'), SeminaryController::$character['characterroles'])) == 0)
|
||||
{
|
||||
$previousQuests = $this->Quests->getPreviousQuests($quest['id']);
|
||||
if(count($previousQuests) == 0)
|
||||
|
|
|
|||
|
|
@ -17,14 +17,14 @@
|
|||
*
|
||||
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
||||
*/
|
||||
class SeminariesController extends \hhu\z\controllers\SeminaryRoleController
|
||||
class SeminariesController extends \hhu\z\controllers\SeminaryController
|
||||
{
|
||||
/**
|
||||
* Required models
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $models = array('seminaries', 'users', 'userseminaryroles', 'questgroupshierarchy', 'questgroups', 'media');
|
||||
public $models = array('seminaries', 'users', 'characterroles', 'questgroupshierarchy', 'questgroups', 'media');
|
||||
/**
|
||||
* User permissions
|
||||
*
|
||||
|
|
@ -72,10 +72,10 @@
|
|||
// Character of currently logged-in user
|
||||
try {
|
||||
$seminary['usercharacter'] = $this->Characters->getCharacterForUserAndSeminary($this->Auth->getUserId(), $seminary['id']);
|
||||
$seminary['usercharacter']['characterroles'] = $this->Characterroles->getCharacterrolesForCharacterById($seminary['usercharacter']['id']);
|
||||
}
|
||||
catch(\nre\exceptions\IdNotFoundException $e) {
|
||||
}
|
||||
$seminary['userroles'] = $this->Userseminaryroles->getUserseminaryrolesForUserById(IntermediateController::$user['id'], $seminary['id']);
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -115,7 +115,7 @@
|
|||
foreach($hierarchy['questgroups'] as $i => &$questgroup)
|
||||
{
|
||||
// Check permission of Questgroups
|
||||
if($i >= 1 && count(array_intersect(array('admin','moderator'), IntermediateController::$user['seminaryroles'])) == 0)
|
||||
if($i >= 1 && count(array_intersect(array('admin','moderator'), SeminaryController::$character['characterroles'])) == 0)
|
||||
{
|
||||
if(!$this->Questgroups->hasCharacterSolvedQuestgroup($hierarchy['questgroups'][$i-1]['id'], $character['id']))
|
||||
{
|
||||
|
|
|
|||
|
|
@ -35,15 +35,15 @@
|
|||
*/
|
||||
public function index()
|
||||
{
|
||||
if(is_null(SeminaryRoleController::$seminary)) {
|
||||
if(is_null(SeminaryController::$seminary)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Get Seminary
|
||||
$seminary = SeminaryRoleController::$seminary;
|
||||
$seminary = SeminaryController::$seminary;
|
||||
|
||||
// Get Character
|
||||
$character = SeminaryRoleController::$character;
|
||||
$character = SeminaryController::$character;
|
||||
if(is_null($character)) {
|
||||
return;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@
|
|||
*
|
||||
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
||||
*/
|
||||
class SeminarymenuController extends \hhu\z\controllers\SeminaryRoleController
|
||||
class SeminarymenuController extends \hhu\z\controllers\SeminaryController
|
||||
{
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -17,21 +17,29 @@
|
|||
*
|
||||
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
||||
*/
|
||||
class UploadsController extends \hhu\z\controllers\IntermediateController
|
||||
class UploadsController extends \hhu\z\controllers\SeminaryController
|
||||
{
|
||||
/**
|
||||
* Required models
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $models = array('uploads', 'users', 'userroles', 'seminaries');
|
||||
public $models = array('uploads', 'users', 'userroles', 'characterroles', 'seminaries');
|
||||
/**
|
||||
* User permissions
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $permissions = array(
|
||||
'index' => array('admin', 'moderator', 'user', 'userseminaryroles')
|
||||
'index' => array('admin', 'moderator', 'user', 'guest')
|
||||
);
|
||||
/**
|
||||
* User seminary permissions
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $seminaryPermissions = array(
|
||||
'seminary' => array('admin', 'moderator', 'user', 'guest')
|
||||
);
|
||||
|
||||
|
||||
|
|
@ -85,9 +93,9 @@
|
|||
// Owner of file
|
||||
if($upload['created_user_id'] != $user['id'])
|
||||
{
|
||||
// Seminary roles
|
||||
$userSeminaryRoles = array_map(function($r) { return $r['name']; }, $this->Userseminaryroles->getUserseminaryrolesForUserById($user['id'], $seminary['id']));
|
||||
if(count(array_intersect(array('admin', 'moderator'), $userSeminaryRoles)) == 0) {
|
||||
// Seminary permissions
|
||||
$characterRoles = array_map(function($r) { return $r['name']; }, $this->Characterroles->getCharacterrolesForCharacterById($character['id']));
|
||||
if(count(array_intersect(array('admin', 'moderator'), $characterRoles)) == 0) {
|
||||
throw new \nre\exceptions\AccessDeniedException();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@
|
|||
*
|
||||
* @var array
|
||||
*/
|
||||
public $models = array('users', 'characters', 'avatars', 'media', 'userseminaryroles');
|
||||
public $models = array('users', 'characters', 'avatars', 'media', 'characterroles');
|
||||
/**
|
||||
* Required components
|
||||
*
|
||||
|
|
@ -87,8 +87,8 @@
|
|||
foreach($characters as &$character)
|
||||
{
|
||||
// Seminary roles
|
||||
$character['user_seminaryroles'] = $this->Userseminaryroles->getUserseminaryrolesForUserById(\hhu\z\controllers\IntermediateController::$user['id'], $character['seminary_id']);
|
||||
$character['user_seminaryroles'] = array_map(function($a) { return $a['name']; }, $character['user_seminaryroles']);
|
||||
$character['characterroles'] = $this->Characterroles->getCharacterrolesForCharacterById($character['id']);
|
||||
$character['characterroles'] = array_map(function($a) { return $a['name']; }, $character['characterroles']);
|
||||
|
||||
// Level
|
||||
$character['xplevel'] = $this->Characters->getXPLevelOfCharacters($character['id']);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue