replace tabs with spaces
This commit is contained in:
parent
50c38e0efa
commit
c79f0f213b
35 changed files with 27652 additions and 27647 deletions
File diff suppressed because it is too large
Load diff
|
|
@ -1,52 +1,52 @@
|
|||
<?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\controllers;
|
||||
|
||||
|
||||
/**
|
||||
* Controller of the AjaxAgent to return a JSON-string used by AJAX.
|
||||
*
|
||||
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
||||
*/
|
||||
class AjaxController extends \hhu\z\Controller
|
||||
{
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Prefilter.
|
||||
*
|
||||
* @param \nre\core\Request $request Current request
|
||||
* @param \nre\core\Response $response Current response
|
||||
*/
|
||||
public function preFilter(\nre\core\Request $request, \nre\core\Response $response)
|
||||
{
|
||||
parent::preFilter($request, $response);
|
||||
|
||||
// Set content-type
|
||||
$this->response->addHeader("Content-type: application/json; charset=utf-8");
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Action: index.
|
||||
*
|
||||
* Create the JSON-string.
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
}
|
||||
|
||||
}
|
||||
/**
|
||||
* 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\controllers;
|
||||
|
||||
|
||||
/**
|
||||
* Controller of the AjaxAgent to return a JSON-string used by AJAX.
|
||||
*
|
||||
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
||||
*/
|
||||
class AjaxController extends \hhu\z\Controller
|
||||
{
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Prefilter.
|
||||
*
|
||||
* @param \nre\core\Request $request Current request
|
||||
* @param \nre\core\Response $response Current response
|
||||
*/
|
||||
public function preFilter(\nre\core\Request $request, \nre\core\Response $response)
|
||||
{
|
||||
parent::preFilter($request, $response);
|
||||
|
||||
// Set content-type
|
||||
$this->response->addHeader("Content-type: application/json; charset=utf-8");
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Action: index.
|
||||
*
|
||||
* Create the JSON-string.
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
|
|||
|
|
@ -1,37 +1,37 @@
|
|||
<?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\controllers;
|
||||
|
||||
|
||||
/**
|
||||
* Controller of the BinaryAgent to show binary data.
|
||||
*
|
||||
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
||||
*/
|
||||
class BinaryController extends \hhu\z\controllers\IntermediateController
|
||||
{
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Action: index.
|
||||
*
|
||||
* Create binary data.
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
}
|
||||
|
||||
}
|
||||
/**
|
||||
* 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\controllers;
|
||||
|
||||
|
||||
/**
|
||||
* Controller of the BinaryAgent to show binary data.
|
||||
*
|
||||
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
||||
*/
|
||||
class BinaryController extends \hhu\z\controllers\IntermediateController
|
||||
{
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Action: index.
|
||||
*
|
||||
* Create binary data.
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
|
|
@ -1,406 +1,406 @@
|
|||
<?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\controllers;
|
||||
|
||||
|
||||
/**
|
||||
* Controller of the CharactertypesAgent to handle Charactertyes of a
|
||||
* Seminary.
|
||||
*
|
||||
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
||||
*/
|
||||
class CharactertypesController extends \hhu\z\controllers\SeminaryController
|
||||
{
|
||||
/**
|
||||
* Required components
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $components = array('validation');
|
||||
/**
|
||||
* Required models
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $models = array('charactertypes', 'xplevels', 'avatars', 'media');
|
||||
/**
|
||||
* User permissions
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $permissions = array(
|
||||
'index' => array('admin', 'moderator', 'user'),
|
||||
'create' => array('admin', 'moderator', 'user'),
|
||||
'edit' => array('admin', 'moderator', 'user'),
|
||||
'delete' => array('admin', 'moderator', 'user')
|
||||
);
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Action: index.
|
||||
*
|
||||
* List Character types.
|
||||
*
|
||||
* @throws \nre\exceptions\IdNotFoundException
|
||||
* @param string $seminaryUrl URL-Title of a Seminary
|
||||
*/
|
||||
public function index($seminaryUrl)
|
||||
{
|
||||
// Get seminary
|
||||
$seminary = $this->Seminaries->getSeminaryByUrl($seminaryUrl);
|
||||
/**
|
||||
* 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
|
||||
*/
|
||||
|
||||
// Check permissions
|
||||
if(
|
||||
(is_null(self::$character) && count(array_intersect(array('admin', 'moderator'), \hhu\z\controllers\IntermediateController::$user['roles'])) == 0) &&
|
||||
$seminary['created_user_id'] != self::$user['id']
|
||||
) {
|
||||
throw new \nre\exceptions\AccessDeniedException();
|
||||
}
|
||||
|
||||
// Get Character types
|
||||
$charactertypes = $this->Charactertypes->getCharacterTypesForSeminary($seminary['id']);
|
||||
|
||||
// Get Avatars
|
||||
$xplevels = $this->Xplevels->getXPLevelsForSeminary($seminary['id']);
|
||||
if(count($xplevels) > 0)
|
||||
{
|
||||
foreach($charactertypes as &$type)
|
||||
{
|
||||
try {
|
||||
$type['avatar'] = $this->Avatars->getAvatarByTypeAndLevel($seminary['id'], $type['url'], $xplevels[0]['level']);
|
||||
}
|
||||
catch(\nre\exceptions\IdNotFoundException $e) {
|
||||
// No Avatar available
|
||||
}
|
||||
}
|
||||
}
|
||||
namespace hhu\z\controllers;
|
||||
|
||||
|
||||
// Set titile
|
||||
$this->addTitleLocalized('Charactertypes');
|
||||
$this->addTitle($seminary['title']);
|
||||
|
||||
// Pass data to view
|
||||
$this->set('seminary', $seminary);
|
||||
$this->set('xplevels', $xplevels);
|
||||
$this->set('charactertypes', $charactertypes);
|
||||
}
|
||||
/**
|
||||
* Controller of the CharactertypesAgent to handle Charactertyes of a
|
||||
* Seminary.
|
||||
*
|
||||
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
||||
*/
|
||||
class CharactertypesController extends \hhu\z\controllers\SeminaryController
|
||||
{
|
||||
/**
|
||||
* Required components
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $components = array('validation');
|
||||
/**
|
||||
* Required models
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $models = array('charactertypes', 'xplevels', 'avatars', 'media');
|
||||
/**
|
||||
* User permissions
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $permissions = array(
|
||||
'index' => array('admin', 'moderator', 'user'),
|
||||
'create' => array('admin', 'moderator', 'user'),
|
||||
'edit' => array('admin', 'moderator', 'user'),
|
||||
'delete' => array('admin', 'moderator', 'user')
|
||||
);
|
||||
|
||||
|
||||
/**
|
||||
* Action: create.
|
||||
*
|
||||
* Create new Character type for a Seminary.
|
||||
*
|
||||
* @throws \nre\exceptions\IdNotFoundException
|
||||
* @param string $seminaryUrl URL-Title of a Seminary
|
||||
*/
|
||||
public function create($seminaryUrl)
|
||||
{
|
||||
// Get seminary
|
||||
$seminary = $this->Seminaries->getSeminaryByUrl($seminaryUrl);
|
||||
|
||||
// Check permissions
|
||||
if(
|
||||
$seminary['created_user_id'] != self::$user['id'] &&
|
||||
(is_null(self::$character) && count(array_intersect(array('admin'), \hhu\z\controllers\IntermediateController::$user['roles'])) == 0)
|
||||
) {
|
||||
throw new \nre\exceptions\AccessDeniedException();
|
||||
}
|
||||
|
||||
// Values
|
||||
$name = '';
|
||||
$fields = array('charactertypename');
|
||||
$validation = array();
|
||||
|
||||
// Create new Charactertype
|
||||
if($this->request->getRequestMethod() == 'POST' && !is_null($this->request->getPostParam('create')))
|
||||
{
|
||||
// Get params and validate them
|
||||
$validation = $this->Validation->validateParams($this->request->getPostParams(), $fields);
|
||||
$name = $this->request->getPostParam('charactertypename');
|
||||
if($this->Charactertypes->charactertypeNameExists($seminary['id'], $name)) {
|
||||
$validation = $this->Validation->addValidationResult($validation, 'charactertypename', 'exist', true);
|
||||
}
|
||||
|
||||
// Create new Charactertype
|
||||
if($validation === true)
|
||||
{
|
||||
$charactertypeId = $this->Charactertypes->createCharactertype(
|
||||
$this->Auth->getUserId(),
|
||||
$seminary['id'],
|
||||
$name
|
||||
);
|
||||
$charactertype = $this->Charactertypes->getCharactertypeById($charactertypeId);
|
||||
|
||||
// Redirect to editing
|
||||
$this->redirect($this->linker->link(array('edit', $seminary['url'], $charactertype['url']), 1));
|
||||
}
|
||||
}
|
||||
|
||||
// Get validation settings
|
||||
$validationSettings = array();
|
||||
foreach($fields as &$field) {
|
||||
$validationSettings[$field] = \nre\configs\AppConfig::$validation[$field];
|
||||
}
|
||||
|
||||
|
||||
// Set titile
|
||||
$this->addTitleLocalized('Create new Charactertype');
|
||||
$this->addTitle($seminary['title']);
|
||||
|
||||
// Pass data to view
|
||||
$this->set('seminary', $seminary);
|
||||
$this->set('name', $name);
|
||||
$this->set('validation', $validation);
|
||||
$this->set('validationSettings', $validationSettings);
|
||||
}
|
||||
/**
|
||||
* Action: index.
|
||||
*
|
||||
* List Character types.
|
||||
*
|
||||
* @throws \nre\exceptions\IdNotFoundException
|
||||
* @param string $seminaryUrl URL-Title of a Seminary
|
||||
*/
|
||||
public function index($seminaryUrl)
|
||||
{
|
||||
// Get seminary
|
||||
$seminary = $this->Seminaries->getSeminaryByUrl($seminaryUrl);
|
||||
|
||||
// Check permissions
|
||||
if(
|
||||
(is_null(self::$character) && count(array_intersect(array('admin', 'moderator'), \hhu\z\controllers\IntermediateController::$user['roles'])) == 0) &&
|
||||
$seminary['created_user_id'] != self::$user['id']
|
||||
) {
|
||||
throw new \nre\exceptions\AccessDeniedException();
|
||||
}
|
||||
|
||||
// Get Character types
|
||||
$charactertypes = $this->Charactertypes->getCharacterTypesForSeminary($seminary['id']);
|
||||
|
||||
// Get Avatars
|
||||
$xplevels = $this->Xplevels->getXPLevelsForSeminary($seminary['id']);
|
||||
if(count($xplevels) > 0)
|
||||
{
|
||||
foreach($charactertypes as &$type)
|
||||
{
|
||||
try {
|
||||
$type['avatar'] = $this->Avatars->getAvatarByTypeAndLevel($seminary['id'], $type['url'], $xplevels[0]['level']);
|
||||
}
|
||||
catch(\nre\exceptions\IdNotFoundException $e) {
|
||||
// No Avatar available
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Action: edit.
|
||||
*
|
||||
* Edit Character type for a Seminary.
|
||||
*
|
||||
* @throws \nre\exceptions\IdNotFoundException
|
||||
* @param string $seminaryUrl URL-title of a Seminary
|
||||
* @param string $charactertypeUrl URL-title of Character type
|
||||
*/
|
||||
public function edit($seminaryUrl, $charactertypeUrl)
|
||||
{
|
||||
// Get seminary
|
||||
$seminary = $this->Seminaries->getSeminaryByUrl($seminaryUrl);
|
||||
// Set titile
|
||||
$this->addTitleLocalized('Charactertypes');
|
||||
$this->addTitle($seminary['title']);
|
||||
|
||||
// Check permissions
|
||||
if(
|
||||
$seminary['created_user_id'] != self::$user['id'] &&
|
||||
(is_null(self::$character) && count(array_intersect(array('admin', 'moderator'), \hhu\z\controllers\IntermediateController::$user['roles'])) == 0)
|
||||
) {
|
||||
throw new \nre\exceptions\AccessDeniedException();
|
||||
}
|
||||
|
||||
// Get Character type
|
||||
$charactertype = $this->Charactertypes->getCharactertypeByUrl($seminary['id'], $charactertypeUrl);
|
||||
|
||||
// XP-levels
|
||||
$xplevels = $this->Xplevels->getXPLevelsForSeminary($seminary['id']);
|
||||
foreach($xplevels as &$xplevel)
|
||||
{
|
||||
try {
|
||||
$xplevel['avatar'] = $this->Avatars->getAvatarByTypeAndLevel($seminary['id'], $charactertype['url'], $xplevel['level']);
|
||||
}
|
||||
catch(\nre\exceptions\IdNotFoundException $e) {
|
||||
// No Avatar available
|
||||
}
|
||||
}
|
||||
|
||||
// Get allowed mimetypes
|
||||
$mimetypes = \nre\configs\AppConfig::$mimetypes['moodpics'];
|
||||
|
||||
// Values
|
||||
$name = $charactertype['name'];
|
||||
$fields = array('charactertypename');
|
||||
$validation = array();
|
||||
$avatarVariants = array('portrait', 'avatar');
|
||||
$avatarsValidation = true;
|
||||
|
||||
// Check request method
|
||||
if($this->request->getRequestMethod() == 'POST' && !is_null($this->request->getPostParam('edit')))
|
||||
{
|
||||
// Get params and validate them
|
||||
$validation = $this->Validation->validateParams($this->request->getPostParams(), $fields);
|
||||
$name = $this->request->getPostParam('charactertypename');
|
||||
if($this->Charactertypes->charactertypeNameExists($seminary['id'], $name, $charactertype['id'])) {
|
||||
$validation = $this->Validation->addValidationResult($validation, 'charactertypename', 'exist', true);
|
||||
}
|
||||
|
||||
// Validate and upload avatars
|
||||
if(array_key_exists('avatars', $_FILES))
|
||||
{
|
||||
foreach($xplevels as &$xplevel)
|
||||
{
|
||||
if(array_key_exists($xplevel['id'], $_FILES['avatars']['error']))
|
||||
{
|
||||
foreach($avatarVariants as &$variant)
|
||||
{
|
||||
if(array_key_exists($variant, $_FILES['avatars']['error'][$xplevel['id']]) && $_FILES['avatars']['error'][$xplevel['id']][$variant] !== UPLOAD_ERR_NO_FILE)
|
||||
{
|
||||
$avatar = array(
|
||||
'name' => $_FILES['avatars']['name'][$xplevel['id']][$variant],
|
||||
'type' => $_FILES['avatars']['type'][$xplevel['id']][$variant],
|
||||
'tmp_name' => $_FILES['avatars']['tmp_name'][$xplevel['id']][$variant],
|
||||
'error' => $_FILES['avatars']['error'][$xplevel['id']][$variant],
|
||||
'size' => $_FILES['avatars']['size'][$xplevel['id']][$variant]
|
||||
);
|
||||
$avatarValidation = true;
|
||||
|
||||
// Check error
|
||||
if($avatar['error'] !== UPLOAD_ERR_OK) {
|
||||
$avatarValidation = $this->Validation->addValidationResult($avatarValidation, 'avatar', 'error', $avatar['error']);
|
||||
}
|
||||
|
||||
// Check mimetype
|
||||
$avatarMimetype = null;
|
||||
$avatar['mimetype'] = \hhu\z\Utils::getMimetype($avatar['tmp_name'], $avatar['type']);
|
||||
foreach($mimetypes as &$mimetype) {
|
||||
if($mimetype['mimetype'] == $avatar['mimetype']) {
|
||||
$avatarMimetype = $mimetype;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(is_null($avatarMimetype)) {
|
||||
$avatarValidation = $this->Validation->addValidationResult($avatarValidation, 'avatar', 'mimetype', $avatar['mimetype']);
|
||||
}
|
||||
elseif($avatar['size'] > $avatarMimetype['size']) {
|
||||
$avatarValidation = $this->Validation->addValidationResult($avatarValidation, 'avatar', 'size', $avatarMimetype['size']);
|
||||
}
|
||||
|
||||
// Add validation result
|
||||
if(!$avatarValidation !== true)
|
||||
{
|
||||
if(!is_array($avatarsValidation)) {
|
||||
$avatarsValidation = array();
|
||||
}
|
||||
if(!array_key_exists($xplevel['id'], $avatarsValidation)) {
|
||||
$avatarsValidation[$xplevel['id']] = array();
|
||||
}
|
||||
$avatarsValidation[$xplevel['id']][$variant] = $avatarValidation;
|
||||
}
|
||||
|
||||
// Upload avatar
|
||||
if($avatarValidation === true)
|
||||
{
|
||||
$avatar['media_id'] = $this->Media->createAvatarPicture(
|
||||
$this->Auth->getUserId(),
|
||||
$seminary['id'],
|
||||
sprintf('avatar-%d-%d-%s', $charactertype['id'], $xplevel['id'], $variant),
|
||||
'',
|
||||
$avatar['mimetype'],
|
||||
$avatar['tmp_name']
|
||||
);
|
||||
|
||||
// Set avatar
|
||||
if($variant == 'portrait') {
|
||||
$this->Avatars->setAvatarPortraitForTypeAndLevel(
|
||||
$this->Auth->getUserId(),
|
||||
$charactertype['id'],
|
||||
$xplevel['id'],
|
||||
$avatar['media_id']
|
||||
);
|
||||
}
|
||||
else {
|
||||
$this->Avatars->setAvatarForTypeAndLevel(
|
||||
$this->Auth->getUserId(),
|
||||
$charactertype['id'],
|
||||
$xplevel['id'],
|
||||
$avatar['media_id']
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Edit Charactertype
|
||||
if($validation === true && $avatarsValidation === true)
|
||||
{
|
||||
$this->Charactertypes->editCharactertype(
|
||||
$charactertype['id'],
|
||||
$name
|
||||
);
|
||||
$charactertype = $this->Charactertypes->getCharactertypeById($charactertype['id']);
|
||||
|
||||
// Redirect to overview
|
||||
$this->redirect($this->linker->link(array('index', $seminary['url']), 1));
|
||||
}
|
||||
}
|
||||
|
||||
// Get validation settings
|
||||
$validationSettings = array();
|
||||
foreach($fields as &$field) {
|
||||
$validationSettings[$field] = \nre\configs\AppConfig::$validation[$field];
|
||||
}
|
||||
// Pass data to view
|
||||
$this->set('seminary', $seminary);
|
||||
$this->set('xplevels', $xplevels);
|
||||
$this->set('charactertypes', $charactertypes);
|
||||
}
|
||||
|
||||
|
||||
// Set titile
|
||||
$this->addTitleLocalized('Edit Charactertype');
|
||||
$this->addTitle($seminary['title']);
|
||||
|
||||
// Pass data to view
|
||||
$this->set('seminary', $seminary);
|
||||
$this->set('charactertype', $charactertype);
|
||||
$this->set('xplevels', $xplevels);
|
||||
$this->set('name', $name);
|
||||
$this->set('mimetypes', $mimetypes);
|
||||
$this->set('validation', $validation);
|
||||
$this->set('avatarsValidation', $avatarsValidation);
|
||||
$this->set('avatarVariants', $avatarVariants);
|
||||
$this->set('validationSettings', $validationSettings);
|
||||
}
|
||||
/**
|
||||
* Action: create.
|
||||
*
|
||||
* Create new Character type for a Seminary.
|
||||
*
|
||||
* @throws \nre\exceptions\IdNotFoundException
|
||||
* @param string $seminaryUrl URL-Title of a Seminary
|
||||
*/
|
||||
public function create($seminaryUrl)
|
||||
{
|
||||
// Get seminary
|
||||
$seminary = $this->Seminaries->getSeminaryByUrl($seminaryUrl);
|
||||
|
||||
// Check permissions
|
||||
if(
|
||||
$seminary['created_user_id'] != self::$user['id'] &&
|
||||
(is_null(self::$character) && count(array_intersect(array('admin'), \hhu\z\controllers\IntermediateController::$user['roles'])) == 0)
|
||||
) {
|
||||
throw new \nre\exceptions\AccessDeniedException();
|
||||
}
|
||||
|
||||
// Values
|
||||
$name = '';
|
||||
$fields = array('charactertypename');
|
||||
$validation = array();
|
||||
|
||||
// Create new Charactertype
|
||||
if($this->request->getRequestMethod() == 'POST' && !is_null($this->request->getPostParam('create')))
|
||||
{
|
||||
// Get params and validate them
|
||||
$validation = $this->Validation->validateParams($this->request->getPostParams(), $fields);
|
||||
$name = $this->request->getPostParam('charactertypename');
|
||||
if($this->Charactertypes->charactertypeNameExists($seminary['id'], $name)) {
|
||||
$validation = $this->Validation->addValidationResult($validation, 'charactertypename', 'exist', true);
|
||||
}
|
||||
|
||||
// Create new Charactertype
|
||||
if($validation === true)
|
||||
{
|
||||
$charactertypeId = $this->Charactertypes->createCharactertype(
|
||||
$this->Auth->getUserId(),
|
||||
$seminary['id'],
|
||||
$name
|
||||
);
|
||||
$charactertype = $this->Charactertypes->getCharactertypeById($charactertypeId);
|
||||
|
||||
// Redirect to editing
|
||||
$this->redirect($this->linker->link(array('edit', $seminary['url'], $charactertype['url']), 1));
|
||||
}
|
||||
}
|
||||
|
||||
// Get validation settings
|
||||
$validationSettings = array();
|
||||
foreach($fields as &$field) {
|
||||
$validationSettings[$field] = \nre\configs\AppConfig::$validation[$field];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Action: delete.
|
||||
*
|
||||
* Delete Character type for a Seminary.
|
||||
*
|
||||
* @throws \nre\exceptions\IdNotFoundException
|
||||
* @param string $seminaryUrl URL-title of a Seminary
|
||||
* @param string $charactertypeUrl URL-title of Character type
|
||||
*/
|
||||
public function delete($seminaryUrl, $charactertypeUrl)
|
||||
{
|
||||
// Get seminary
|
||||
$seminary = $this->Seminaries->getSeminaryByUrl($seminaryUrl);
|
||||
// Set titile
|
||||
$this->addTitleLocalized('Create new Charactertype');
|
||||
$this->addTitle($seminary['title']);
|
||||
|
||||
// Check permissions
|
||||
if(
|
||||
$seminary['created_user_id'] != self::$user['id'] &&
|
||||
(is_null(self::$character) && count(array_intersect(array('admin'), \hhu\z\controllers\IntermediateController::$user['roles'])) == 0)
|
||||
) {
|
||||
throw new \nre\exceptions\AccessDeniedException();
|
||||
}
|
||||
|
||||
// Get Character type
|
||||
$charactertype = $this->Charactertypes->getCharactertypeByUrl($seminary['id'], $charactertypeUrl);
|
||||
|
||||
// Check request method
|
||||
if($this->request->getRequestMethod() == 'POST')
|
||||
{
|
||||
// Check confirmation
|
||||
if(!is_null($this->request->getPostParam('delete')))
|
||||
{
|
||||
// Delete Character type
|
||||
$this->Charactertypes->deleteCharactertype($charactertype['id']);
|
||||
}
|
||||
|
||||
// Redirect to overview
|
||||
$this->redirect($this->linker->link(array('index', $seminary['url']), 1));
|
||||
}
|
||||
// Pass data to view
|
||||
$this->set('seminary', $seminary);
|
||||
$this->set('name', $name);
|
||||
$this->set('validation', $validation);
|
||||
$this->set('validationSettings', $validationSettings);
|
||||
}
|
||||
|
||||
|
||||
// Set titile
|
||||
$this->addTitleLocalized('Delete Charactertype');
|
||||
$this->addTitle($seminary['title']);
|
||||
|
||||
// Pass data to view
|
||||
$this->set('seminary', $seminary);
|
||||
$this->set('charactertype', $charactertype);
|
||||
}
|
||||
|
||||
}
|
||||
/**
|
||||
* Action: edit.
|
||||
*
|
||||
* Edit Character type for a Seminary.
|
||||
*
|
||||
* @throws \nre\exceptions\IdNotFoundException
|
||||
* @param string $seminaryUrl URL-title of a Seminary
|
||||
* @param string $charactertypeUrl URL-title of Character type
|
||||
*/
|
||||
public function edit($seminaryUrl, $charactertypeUrl)
|
||||
{
|
||||
// Get seminary
|
||||
$seminary = $this->Seminaries->getSeminaryByUrl($seminaryUrl);
|
||||
|
||||
// Check permissions
|
||||
if(
|
||||
$seminary['created_user_id'] != self::$user['id'] &&
|
||||
(is_null(self::$character) && count(array_intersect(array('admin', 'moderator'), \hhu\z\controllers\IntermediateController::$user['roles'])) == 0)
|
||||
) {
|
||||
throw new \nre\exceptions\AccessDeniedException();
|
||||
}
|
||||
|
||||
// Get Character type
|
||||
$charactertype = $this->Charactertypes->getCharactertypeByUrl($seminary['id'], $charactertypeUrl);
|
||||
|
||||
// XP-levels
|
||||
$xplevels = $this->Xplevels->getXPLevelsForSeminary($seminary['id']);
|
||||
foreach($xplevels as &$xplevel)
|
||||
{
|
||||
try {
|
||||
$xplevel['avatar'] = $this->Avatars->getAvatarByTypeAndLevel($seminary['id'], $charactertype['url'], $xplevel['level']);
|
||||
}
|
||||
catch(\nre\exceptions\IdNotFoundException $e) {
|
||||
// No Avatar available
|
||||
}
|
||||
}
|
||||
|
||||
// Get allowed mimetypes
|
||||
$mimetypes = \nre\configs\AppConfig::$mimetypes['moodpics'];
|
||||
|
||||
// Values
|
||||
$name = $charactertype['name'];
|
||||
$fields = array('charactertypename');
|
||||
$validation = array();
|
||||
$avatarVariants = array('portrait', 'avatar');
|
||||
$avatarsValidation = true;
|
||||
|
||||
// Check request method
|
||||
if($this->request->getRequestMethod() == 'POST' && !is_null($this->request->getPostParam('edit')))
|
||||
{
|
||||
// Get params and validate them
|
||||
$validation = $this->Validation->validateParams($this->request->getPostParams(), $fields);
|
||||
$name = $this->request->getPostParam('charactertypename');
|
||||
if($this->Charactertypes->charactertypeNameExists($seminary['id'], $name, $charactertype['id'])) {
|
||||
$validation = $this->Validation->addValidationResult($validation, 'charactertypename', 'exist', true);
|
||||
}
|
||||
|
||||
// Validate and upload avatars
|
||||
if(array_key_exists('avatars', $_FILES))
|
||||
{
|
||||
foreach($xplevels as &$xplevel)
|
||||
{
|
||||
if(array_key_exists($xplevel['id'], $_FILES['avatars']['error']))
|
||||
{
|
||||
foreach($avatarVariants as &$variant)
|
||||
{
|
||||
if(array_key_exists($variant, $_FILES['avatars']['error'][$xplevel['id']]) && $_FILES['avatars']['error'][$xplevel['id']][$variant] !== UPLOAD_ERR_NO_FILE)
|
||||
{
|
||||
$avatar = array(
|
||||
'name' => $_FILES['avatars']['name'][$xplevel['id']][$variant],
|
||||
'type' => $_FILES['avatars']['type'][$xplevel['id']][$variant],
|
||||
'tmp_name' => $_FILES['avatars']['tmp_name'][$xplevel['id']][$variant],
|
||||
'error' => $_FILES['avatars']['error'][$xplevel['id']][$variant],
|
||||
'size' => $_FILES['avatars']['size'][$xplevel['id']][$variant]
|
||||
);
|
||||
$avatarValidation = true;
|
||||
|
||||
// Check error
|
||||
if($avatar['error'] !== UPLOAD_ERR_OK) {
|
||||
$avatarValidation = $this->Validation->addValidationResult($avatarValidation, 'avatar', 'error', $avatar['error']);
|
||||
}
|
||||
|
||||
// Check mimetype
|
||||
$avatarMimetype = null;
|
||||
$avatar['mimetype'] = \hhu\z\Utils::getMimetype($avatar['tmp_name'], $avatar['type']);
|
||||
foreach($mimetypes as &$mimetype) {
|
||||
if($mimetype['mimetype'] == $avatar['mimetype']) {
|
||||
$avatarMimetype = $mimetype;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(is_null($avatarMimetype)) {
|
||||
$avatarValidation = $this->Validation->addValidationResult($avatarValidation, 'avatar', 'mimetype', $avatar['mimetype']);
|
||||
}
|
||||
elseif($avatar['size'] > $avatarMimetype['size']) {
|
||||
$avatarValidation = $this->Validation->addValidationResult($avatarValidation, 'avatar', 'size', $avatarMimetype['size']);
|
||||
}
|
||||
|
||||
// Add validation result
|
||||
if(!$avatarValidation !== true)
|
||||
{
|
||||
if(!is_array($avatarsValidation)) {
|
||||
$avatarsValidation = array();
|
||||
}
|
||||
if(!array_key_exists($xplevel['id'], $avatarsValidation)) {
|
||||
$avatarsValidation[$xplevel['id']] = array();
|
||||
}
|
||||
$avatarsValidation[$xplevel['id']][$variant] = $avatarValidation;
|
||||
}
|
||||
|
||||
// Upload avatar
|
||||
if($avatarValidation === true)
|
||||
{
|
||||
$avatar['media_id'] = $this->Media->createAvatarPicture(
|
||||
$this->Auth->getUserId(),
|
||||
$seminary['id'],
|
||||
sprintf('avatar-%d-%d-%s', $charactertype['id'], $xplevel['id'], $variant),
|
||||
'',
|
||||
$avatar['mimetype'],
|
||||
$avatar['tmp_name']
|
||||
);
|
||||
|
||||
// Set avatar
|
||||
if($variant == 'portrait') {
|
||||
$this->Avatars->setAvatarPortraitForTypeAndLevel(
|
||||
$this->Auth->getUserId(),
|
||||
$charactertype['id'],
|
||||
$xplevel['id'],
|
||||
$avatar['media_id']
|
||||
);
|
||||
}
|
||||
else {
|
||||
$this->Avatars->setAvatarForTypeAndLevel(
|
||||
$this->Auth->getUserId(),
|
||||
$charactertype['id'],
|
||||
$xplevel['id'],
|
||||
$avatar['media_id']
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Edit Charactertype
|
||||
if($validation === true && $avatarsValidation === true)
|
||||
{
|
||||
$this->Charactertypes->editCharactertype(
|
||||
$charactertype['id'],
|
||||
$name
|
||||
);
|
||||
$charactertype = $this->Charactertypes->getCharactertypeById($charactertype['id']);
|
||||
|
||||
// Redirect to overview
|
||||
$this->redirect($this->linker->link(array('index', $seminary['url']), 1));
|
||||
}
|
||||
}
|
||||
|
||||
// Get validation settings
|
||||
$validationSettings = array();
|
||||
foreach($fields as &$field) {
|
||||
$validationSettings[$field] = \nre\configs\AppConfig::$validation[$field];
|
||||
}
|
||||
|
||||
|
||||
// Set titile
|
||||
$this->addTitleLocalized('Edit Charactertype');
|
||||
$this->addTitle($seminary['title']);
|
||||
|
||||
// Pass data to view
|
||||
$this->set('seminary', $seminary);
|
||||
$this->set('charactertype', $charactertype);
|
||||
$this->set('xplevels', $xplevels);
|
||||
$this->set('name', $name);
|
||||
$this->set('mimetypes', $mimetypes);
|
||||
$this->set('validation', $validation);
|
||||
$this->set('avatarsValidation', $avatarsValidation);
|
||||
$this->set('avatarVariants', $avatarVariants);
|
||||
$this->set('validationSettings', $validationSettings);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Action: delete.
|
||||
*
|
||||
* Delete Character type for a Seminary.
|
||||
*
|
||||
* @throws \nre\exceptions\IdNotFoundException
|
||||
* @param string $seminaryUrl URL-title of a Seminary
|
||||
* @param string $charactertypeUrl URL-title of Character type
|
||||
*/
|
||||
public function delete($seminaryUrl, $charactertypeUrl)
|
||||
{
|
||||
// Get seminary
|
||||
$seminary = $this->Seminaries->getSeminaryByUrl($seminaryUrl);
|
||||
|
||||
// Check permissions
|
||||
if(
|
||||
$seminary['created_user_id'] != self::$user['id'] &&
|
||||
(is_null(self::$character) && count(array_intersect(array('admin'), \hhu\z\controllers\IntermediateController::$user['roles'])) == 0)
|
||||
) {
|
||||
throw new \nre\exceptions\AccessDeniedException();
|
||||
}
|
||||
|
||||
// Get Character type
|
||||
$charactertype = $this->Charactertypes->getCharactertypeByUrl($seminary['id'], $charactertypeUrl);
|
||||
|
||||
// Check request method
|
||||
if($this->request->getRequestMethod() == 'POST')
|
||||
{
|
||||
// Check confirmation
|
||||
if(!is_null($this->request->getPostParam('delete')))
|
||||
{
|
||||
// Delete Character type
|
||||
$this->Charactertypes->deleteCharactertype($charactertype['id']);
|
||||
}
|
||||
|
||||
// Redirect to overview
|
||||
$this->redirect($this->linker->link(array('index', $seminary['url']), 1));
|
||||
}
|
||||
|
||||
|
||||
// Set titile
|
||||
$this->addTitleLocalized('Delete Charactertype');
|
||||
$this->addTitle($seminary['title']);
|
||||
|
||||
// Pass data to view
|
||||
$this->set('seminary', $seminary);
|
||||
$this->set('charactertype', $charactertype);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
|
|||
|
|
@ -1,51 +1,51 @@
|
|||
<?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\controllers;
|
||||
|
||||
|
||||
/**
|
||||
* Controller of the Agent to show an error page.
|
||||
*
|
||||
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
||||
*/
|
||||
class ErrorController extends \hhu\z\Controller
|
||||
{
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Action: index.
|
||||
*
|
||||
* Set HTTP-header and print an error message.
|
||||
*
|
||||
* @param int $httpStatusCode HTTP-statuscode of the error that occurred
|
||||
*/
|
||||
public function index($httpStatusCode)
|
||||
{
|
||||
// Set HTTP-header
|
||||
if(!array_key_exists($httpStatusCode, \nre\core\WebUtils::$httpStrings)) {
|
||||
$httpStatusCode = 200;
|
||||
}
|
||||
$this->response->addHeader(\nre\core\WebUtils::getHttpHeader($httpStatusCode));
|
||||
|
||||
// Display statuscode and message
|
||||
$this->set('code', $httpStatusCode);
|
||||
$this->set('string', \nre\core\WebUtils::$httpStrings[$httpStatusCode]);
|
||||
$this->set('userId', $this->Auth->getUserId());
|
||||
}
|
||||
|
||||
}
|
||||
/**
|
||||
* 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\controllers;
|
||||
|
||||
|
||||
/**
|
||||
* Controller of the Agent to show an error page.
|
||||
*
|
||||
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
||||
*/
|
||||
class ErrorController extends \hhu\z\Controller
|
||||
{
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Action: index.
|
||||
*
|
||||
* Set HTTP-header and print an error message.
|
||||
*
|
||||
* @param int $httpStatusCode HTTP-statuscode of the error that occurred
|
||||
*/
|
||||
public function index($httpStatusCode)
|
||||
{
|
||||
// Set HTTP-header
|
||||
if(!array_key_exists($httpStatusCode, \nre\core\WebUtils::$httpStrings)) {
|
||||
$httpStatusCode = 200;
|
||||
}
|
||||
$this->response->addHeader(\nre\core\WebUtils::getHttpHeader($httpStatusCode));
|
||||
|
||||
// Display statuscode and message
|
||||
$this->set('code', $httpStatusCode);
|
||||
$this->set('string', \nre\core\WebUtils::$httpStrings[$httpStatusCode]);
|
||||
$this->set('userId', $this->Auth->getUserId());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
|
|||
|
|
@ -1,37 +1,37 @@
|
|||
<?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\controllers;
|
||||
|
||||
|
||||
/**
|
||||
* Controller of the Agent to display a toplevel error page.
|
||||
*
|
||||
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
||||
*/
|
||||
class FaultController extends \nre\core\Controller
|
||||
{
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Action: index.
|
||||
*
|
||||
* Show the error message.
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
}
|
||||
|
||||
}
|
||||
/**
|
||||
* 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\controllers;
|
||||
|
||||
|
||||
/**
|
||||
* Controller of the Agent to display a toplevel error page.
|
||||
*
|
||||
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
||||
*/
|
||||
class FaultController extends \nre\core\Controller
|
||||
{
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Action: index.
|
||||
*
|
||||
* Show the error message.
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
|
|||
|
|
@ -1,114 +1,114 @@
|
|||
<?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\controllers;
|
||||
|
||||
|
||||
/**
|
||||
* Controller of the HtmlAgent to display a HTML-page.
|
||||
*
|
||||
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
||||
*/
|
||||
class HtmlController extends \hhu\z\Controller
|
||||
{
|
||||
/**
|
||||
* Required components
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $components = array('notification');
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Prefilter.
|
||||
*
|
||||
* @param \nre\core\Request $request Current request
|
||||
* @param \nre\core\Response $response Current response
|
||||
*/
|
||||
public function preFilter(\nre\core\Request $request, \nre\core\Response $response)
|
||||
{
|
||||
parent::preFilter($request, $response);
|
||||
|
||||
// Set content-type
|
||||
$this->response->addHeader("Content-type: text/html; charset=utf-8");
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Postfilter that is executed after running the Controller.
|
||||
*
|
||||
* @param \nre\core\Request $request Current request
|
||||
* @param \nre\core\Response $response Current response
|
||||
*/
|
||||
public function postFilter(\nre\core\Request $request, \nre\core\Response $response)
|
||||
{
|
||||
// Get title
|
||||
$this->set('title', $this->getTitle());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Action: index.
|
||||
*
|
||||
* Create the HTML-structure.
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
// Set the name of the current IntermediateAgent as page title
|
||||
$this->set('title', $this->request->getParam(1, 'intermediate'));
|
||||
|
||||
// Set userdata
|
||||
$this->set('loggedUser', IntermediateController::$user);
|
||||
$this->set('loggedSeminary', SeminaryController::$seminary);
|
||||
$this->set('loggedCharacter', SeminaryController::$character);
|
||||
|
||||
// Set notifications
|
||||
$this->set('notifications', $this->Notification->getNotifications());
|
||||
/**
|
||||
* 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\controllers;
|
||||
|
||||
|
||||
/**
|
||||
* Controller of the HtmlAgent to display a HTML-page.
|
||||
*
|
||||
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
||||
*/
|
||||
class HtmlController extends \hhu\z\Controller
|
||||
{
|
||||
/**
|
||||
* Required components
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $components = array('notification');
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Prefilter.
|
||||
*
|
||||
* @param \nre\core\Request $request Current request
|
||||
* @param \nre\core\Response $response Current response
|
||||
*/
|
||||
public function preFilter(\nre\core\Request $request, \nre\core\Response $response)
|
||||
{
|
||||
parent::preFilter($request, $response);
|
||||
|
||||
// Set content-type
|
||||
$this->response->addHeader("Content-type: text/html; charset=utf-8");
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Postfilter that is executed after running the Controller.
|
||||
*
|
||||
* @param \nre\core\Request $request Current request
|
||||
* @param \nre\core\Response $response Current response
|
||||
*/
|
||||
public function postFilter(\nre\core\Request $request, \nre\core\Response $response)
|
||||
{
|
||||
// Get title
|
||||
$this->set('title', $this->getTitle());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Action: index.
|
||||
*
|
||||
* Create the HTML-structure.
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
// Set the name of the current IntermediateAgent as page title
|
||||
$this->set('title', $this->request->getParam(1, 'intermediate'));
|
||||
|
||||
// Set userdata
|
||||
$this->set('loggedUser', IntermediateController::$user);
|
||||
$this->set('loggedSeminary', SeminaryController::$seminary);
|
||||
$this->set('loggedCharacter', SeminaryController::$character);
|
||||
|
||||
// Set notifications
|
||||
$this->set('notifications', $this->Notification->getNotifications());
|
||||
|
||||
// Set some application data
|
||||
$this->set('mailcontact', \nre\configs\AppConfig::$app['mailcontact']);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Get title information from IntermediateController if possible
|
||||
* and create a title.
|
||||
*
|
||||
* @return string Title for the current page
|
||||
*/
|
||||
private function getTitle()
|
||||
{
|
||||
$title = array();
|
||||
|
||||
// Get title of IntermediateController
|
||||
$intermediateController = $this->agent->getIntermediateAgent()->controller;
|
||||
if($intermediateController instanceof \hhu\z\controllers\IntermediateController) {
|
||||
$title = $intermediateController->getTitle();
|
||||
}
|
||||
if(!is_array($title)) {
|
||||
$title = array($title);
|
||||
}
|
||||
|
||||
// Add application name
|
||||
$title[] = \nre\configs\AppConfig::$app['name'];
|
||||
|
||||
|
||||
// Return title with delimiter
|
||||
return implode(\nre\configs\AppConfig::$misc['title_delimiter'], $title);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Get title information from IntermediateController if possible
|
||||
* and create a title.
|
||||
*
|
||||
* @return string Title for the current page
|
||||
*/
|
||||
private function getTitle()
|
||||
{
|
||||
$title = array();
|
||||
|
||||
// Get title of IntermediateController
|
||||
$intermediateController = $this->agent->getIntermediateAgent()->controller;
|
||||
if($intermediateController instanceof \hhu\z\controllers\IntermediateController) {
|
||||
$title = $intermediateController->getTitle();
|
||||
}
|
||||
if(!is_array($title)) {
|
||||
$title = array($title);
|
||||
}
|
||||
|
||||
// Add application name
|
||||
$title[] = \nre\configs\AppConfig::$app['name'];
|
||||
|
||||
|
||||
// Return title with delimiter
|
||||
return implode(\nre\configs\AppConfig::$misc['title_delimiter'], $title);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
|
|||
|
|
@ -1,54 +1,54 @@
|
|||
<?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\controllers;
|
||||
|
||||
|
||||
/**
|
||||
* Controller of the HtmlmailAgent for generating a HTML-mail message.
|
||||
*
|
||||
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
||||
*/
|
||||
class HtmlmailController extends \nre\core\Controller
|
||||
{
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Prefilter.
|
||||
*
|
||||
* @param \nre\core\Request $request Current request
|
||||
* @param \nre\core\Response $response Current response
|
||||
*/
|
||||
public function preFilter(\nre\core\Request $request, \nre\core\Response $response)
|
||||
{
|
||||
parent::preFilter($request, $response);
|
||||
|
||||
|
||||
// Set linker
|
||||
$this->set('linker', ($request instanceof \hhu\z\requests\MailRequest && !is_null($request->getLinker())) ? $request->getLinker() : null);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Action: index.
|
||||
*
|
||||
* Create HTML-structure of mail message.
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
$this->set('appname', \nre\configs\AppConfig::$app['name']);
|
||||
}
|
||||
|
||||
}
|
||||
/**
|
||||
* 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\controllers;
|
||||
|
||||
|
||||
/**
|
||||
* Controller of the HtmlmailAgent for generating a HTML-mail message.
|
||||
*
|
||||
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
||||
*/
|
||||
class HtmlmailController extends \nre\core\Controller
|
||||
{
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Prefilter.
|
||||
*
|
||||
* @param \nre\core\Request $request Current request
|
||||
* @param \nre\core\Response $response Current response
|
||||
*/
|
||||
public function preFilter(\nre\core\Request $request, \nre\core\Response $response)
|
||||
{
|
||||
parent::preFilter($request, $response);
|
||||
|
||||
|
||||
// Set linker
|
||||
$this->set('linker', ($request instanceof \hhu\z\requests\MailRequest && !is_null($request->getLinker())) ? $request->getLinker() : null);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Action: index.
|
||||
*
|
||||
* Create HTML-structure of mail message.
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
$this->set('appname', \nre\configs\AppConfig::$app['name']);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
|
|||
|
|
@ -1,37 +1,37 @@
|
|||
<?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\controllers;
|
||||
|
||||
|
||||
/**
|
||||
* Controller of the Agent to show an introduction page.
|
||||
*
|
||||
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
||||
*/
|
||||
class IntroductionController extends \hhu\z\controllers\IntermediateController
|
||||
{
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Action: index.
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
// Pass data to view
|
||||
$this->set('userId', $this->Auth->getUserId());
|
||||
}
|
||||
|
||||
}
|
||||
/**
|
||||
* 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\controllers;
|
||||
|
||||
|
||||
/**
|
||||
* Controller of the Agent to show an introduction page.
|
||||
*
|
||||
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
||||
*/
|
||||
class IntroductionController extends \hhu\z\controllers\IntermediateController
|
||||
{
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Action: index.
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
// Pass data to view
|
||||
$this->set('userId', $this->Auth->getUserId());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
|
|
@ -1,136 +1,136 @@
|
|||
<?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\controllers;
|
||||
|
||||
|
||||
/**
|
||||
* Controller of the MailAgent to generate a mail message.
|
||||
*
|
||||
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
||||
*/
|
||||
class MailController extends \nre\core\Controller
|
||||
{
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Prefilter.
|
||||
*
|
||||
* @param \nre\core\Request $request Current request
|
||||
* @param \nre\core\Response $response Current response
|
||||
*/
|
||||
public function preFilter(\nre\core\Request $request, \nre\core\Response $response)
|
||||
{
|
||||
parent::preFilter($request, $response);
|
||||
|
||||
|
||||
// Set linker
|
||||
$this->set('linker', ($request instanceof \hhu\z\requests\MailRequest && !is_null($request->getLinker())) ? $request->getLinker() : null);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Action: userregistration.
|
||||
*
|
||||
* Generate a mail message to notify of a new user registration.
|
||||
*
|
||||
* @param array $receiver User that the message will be send to
|
||||
* @param array $neUser Newly registered user
|
||||
*/
|
||||
public function userregistration($receiver, $newUser)
|
||||
{
|
||||
// Set subject
|
||||
$this->response->setSubject(_('New user registration'));
|
||||
|
||||
|
||||
// Pass data to view
|
||||
$this->set('user', $newUser);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Action: characterregistration.
|
||||
*
|
||||
* Generate a mail message to notify of a new Character
|
||||
* registration.
|
||||
*
|
||||
* @param array $receiver User that the message will be send to
|
||||
* @param array $seminary Seminary which the Character was created for
|
||||
* @param arary $user User of the newly registered Character
|
||||
* @param array $newCharacter Newly registered Character
|
||||
*/
|
||||
public function characterregistration($receiver, $seminary, $user, $newCharacter)
|
||||
{
|
||||
// Set subject
|
||||
$this->response->setSubject(_('New Character registration'));
|
||||
|
||||
|
||||
// Pass data to view
|
||||
$this->set('seminary', $seminary);
|
||||
$this->set('user', $user);
|
||||
$this->set('character', $newCharacter);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Action: charactersubmission.
|
||||
*
|
||||
* Generate a mail message to notify of a new Character
|
||||
* submission for a Quest that needs to be valuated.
|
||||
*
|
||||
* @param array $receiver User that the message will be send to
|
||||
* @param array $seminary Seminary which the Quest belongs to
|
||||
* @param array $questgroup Questgroup of Quest
|
||||
* @param array $quest Quest the answer has been submitted for
|
||||
* @param array $character Character that send the submission
|
||||
*/
|
||||
public function charactersubmission($receiver, $seminary, $questgroup, $quest, $character)
|
||||
{
|
||||
// Set subject
|
||||
$this->response->setSubject(_('New Character submission'));
|
||||
|
||||
|
||||
// Pass data to view
|
||||
$this->set('seminary', $seminary);
|
||||
$this->set('questgroup', $questgroup);
|
||||
$this->set('quest', $quest);
|
||||
$this->set('character', $character);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Action: charactersubmissionapproved.
|
||||
*
|
||||
* Generate a mail message to notify a Character that its
|
||||
* submission has been approved.
|
||||
*
|
||||
* @param array $receiver User that the message will be send to
|
||||
* @param array $seminary Seminary which the Quest belongs to
|
||||
* @param array $questgroup Questgroup of Quest
|
||||
* @param array $quest Quest the answer has been submitted for
|
||||
*/
|
||||
public function charactersubmissionapproved($receiver, $seminary, $questgroup, $quest)
|
||||
{
|
||||
// Set subject
|
||||
$this->response->setSubject(_('Character submission approved'));
|
||||
|
||||
|
||||
// Pass data to view
|
||||
$this->set('seminary', $seminary);
|
||||
$this->set('questgroup', $questgroup);
|
||||
$this->set('quest', $quest);
|
||||
}
|
||||
|
||||
}
|
||||
/**
|
||||
* 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\controllers;
|
||||
|
||||
|
||||
/**
|
||||
* Controller of the MailAgent to generate a mail message.
|
||||
*
|
||||
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
||||
*/
|
||||
class MailController extends \nre\core\Controller
|
||||
{
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Prefilter.
|
||||
*
|
||||
* @param \nre\core\Request $request Current request
|
||||
* @param \nre\core\Response $response Current response
|
||||
*/
|
||||
public function preFilter(\nre\core\Request $request, \nre\core\Response $response)
|
||||
{
|
||||
parent::preFilter($request, $response);
|
||||
|
||||
|
||||
// Set linker
|
||||
$this->set('linker', ($request instanceof \hhu\z\requests\MailRequest && !is_null($request->getLinker())) ? $request->getLinker() : null);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Action: userregistration.
|
||||
*
|
||||
* Generate a mail message to notify of a new user registration.
|
||||
*
|
||||
* @param array $receiver User that the message will be send to
|
||||
* @param array $neUser Newly registered user
|
||||
*/
|
||||
public function userregistration($receiver, $newUser)
|
||||
{
|
||||
// Set subject
|
||||
$this->response->setSubject(_('New user registration'));
|
||||
|
||||
|
||||
// Pass data to view
|
||||
$this->set('user', $newUser);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Action: characterregistration.
|
||||
*
|
||||
* Generate a mail message to notify of a new Character
|
||||
* registration.
|
||||
*
|
||||
* @param array $receiver User that the message will be send to
|
||||
* @param array $seminary Seminary which the Character was created for
|
||||
* @param arary $user User of the newly registered Character
|
||||
* @param array $newCharacter Newly registered Character
|
||||
*/
|
||||
public function characterregistration($receiver, $seminary, $user, $newCharacter)
|
||||
{
|
||||
// Set subject
|
||||
$this->response->setSubject(_('New Character registration'));
|
||||
|
||||
|
||||
// Pass data to view
|
||||
$this->set('seminary', $seminary);
|
||||
$this->set('user', $user);
|
||||
$this->set('character', $newCharacter);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Action: charactersubmission.
|
||||
*
|
||||
* Generate a mail message to notify of a new Character
|
||||
* submission for a Quest that needs to be valuated.
|
||||
*
|
||||
* @param array $receiver User that the message will be send to
|
||||
* @param array $seminary Seminary which the Quest belongs to
|
||||
* @param array $questgroup Questgroup of Quest
|
||||
* @param array $quest Quest the answer has been submitted for
|
||||
* @param array $character Character that send the submission
|
||||
*/
|
||||
public function charactersubmission($receiver, $seminary, $questgroup, $quest, $character)
|
||||
{
|
||||
// Set subject
|
||||
$this->response->setSubject(_('New Character submission'));
|
||||
|
||||
|
||||
// Pass data to view
|
||||
$this->set('seminary', $seminary);
|
||||
$this->set('questgroup', $questgroup);
|
||||
$this->set('quest', $quest);
|
||||
$this->set('character', $character);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Action: charactersubmissionapproved.
|
||||
*
|
||||
* Generate a mail message to notify a Character that its
|
||||
* submission has been approved.
|
||||
*
|
||||
* @param array $receiver User that the message will be send to
|
||||
* @param array $seminary Seminary which the Quest belongs to
|
||||
* @param array $questgroup Questgroup of Quest
|
||||
* @param array $quest Quest the answer has been submitted for
|
||||
*/
|
||||
public function charactersubmissionapproved($receiver, $seminary, $questgroup, $quest)
|
||||
{
|
||||
// Set subject
|
||||
$this->response->setSubject(_('Character submission approved'));
|
||||
|
||||
|
||||
// Pass data to view
|
||||
$this->set('seminary', $seminary);
|
||||
$this->set('questgroup', $questgroup);
|
||||
$this->set('quest', $quest);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
|
|||
|
|
@ -1,39 +1,39 @@
|
|||
<?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\controllers;
|
||||
|
||||
|
||||
/**
|
||||
* Controller of the MailreceiverAgent to generate a mail receiver
|
||||
* salutation.
|
||||
*
|
||||
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
||||
*/
|
||||
class MailreceiverController extends \nre\core\Controller
|
||||
{
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Action: index.
|
||||
*
|
||||
* @param $array $user User receiving mail
|
||||
*/
|
||||
public function index($user)
|
||||
{
|
||||
$this->set('user', $user);
|
||||
}
|
||||
|
||||
}
|
||||
/**
|
||||
* 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\controllers;
|
||||
|
||||
|
||||
/**
|
||||
* Controller of the MailreceiverAgent to generate a mail receiver
|
||||
* salutation.
|
||||
*
|
||||
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
||||
*/
|
||||
class MailreceiverController extends \nre\core\Controller
|
||||
{
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Action: index.
|
||||
*
|
||||
* @param $array $user User receiving mail
|
||||
*/
|
||||
public function index($user)
|
||||
{
|
||||
$this->set('user', $user);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
|
|||
|
|
@ -1,62 +1,62 @@
|
|||
<?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\controllers;
|
||||
|
||||
|
||||
/**
|
||||
* Controller of the MapAgent to display a map.
|
||||
*
|
||||
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
||||
*/
|
||||
class MapController extends \hhu\z\controllers\SeminaryController
|
||||
{
|
||||
/**
|
||||
* Required models
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $models = array('seminaries', 'map');
|
||||
/**
|
||||
* User permissions
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $permissions = array(
|
||||
'index' => array('admin', 'moderator', 'user')
|
||||
);
|
||||
/**
|
||||
* User seminary permissions
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $seminaryPermissions = array(
|
||||
'index' => array('admin', 'moderator', 'user')
|
||||
);
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Action: index.
|
||||
*
|
||||
* Draw the map.
|
||||
*
|
||||
* @throws \nre\exceptions\IdNotFoundException
|
||||
* @param string $seminaryUrl URL-Title of Seminary
|
||||
*/
|
||||
public function index($seminaryUrl)
|
||||
{
|
||||
/**
|
||||
* 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\controllers;
|
||||
|
||||
|
||||
/**
|
||||
* Controller of the MapAgent to display a map.
|
||||
*
|
||||
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
||||
*/
|
||||
class MapController extends \hhu\z\controllers\SeminaryController
|
||||
{
|
||||
/**
|
||||
* Required models
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $models = array('seminaries', 'map');
|
||||
/**
|
||||
* User permissions
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $permissions = array(
|
||||
'index' => array('admin', 'moderator', 'user')
|
||||
);
|
||||
/**
|
||||
* User seminary permissions
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $seminaryPermissions = array(
|
||||
'index' => array('admin', 'moderator', 'user')
|
||||
);
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Action: index.
|
||||
*
|
||||
* Draw the map.
|
||||
*
|
||||
* @throws \nre\exceptions\IdNotFoundException
|
||||
* @param string $seminaryUrl URL-Title of Seminary
|
||||
*/
|
||||
public function index($seminaryUrl)
|
||||
{
|
||||
// Get Seminary
|
||||
$seminary = $this->Seminaries->getSeminaryByUrl($seminaryUrl);
|
||||
$seminary = $this->Seminaries->getSeminaryByUrl($seminaryUrl);
|
||||
|
||||
// Get map
|
||||
$map = $this->Map->getMapOfSeminary($seminary['id']);
|
||||
|
|
@ -65,8 +65,8 @@
|
|||
// Pass data to view
|
||||
$this->set('seminary', $seminary);
|
||||
$this->set('map', $map);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
|
|
@ -1,52 +1,52 @@
|
|||
<?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\controllers;
|
||||
|
||||
|
||||
/**
|
||||
* Controller of the Agent to display a menu.
|
||||
*
|
||||
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
||||
*/
|
||||
class MenuController extends \hhu\z\Controller
|
||||
{
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Prefilter.
|
||||
*
|
||||
* @param \nre\core\Request $request Current request
|
||||
* @param \nre\core\Response $response Current response
|
||||
*/
|
||||
public function preFilter(\nre\core\Request $request, \nre\core\Response $response)
|
||||
{
|
||||
parent::preFilter($request, $response);
|
||||
|
||||
// Set userdata
|
||||
$this->set('loggedUser', IntermediateController::$user);
|
||||
$this->set('loggedCharacter', SeminaryController::$character);
|
||||
$this->set('loggedSeminary', SeminaryController::$seminary);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Action: index.
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
}
|
||||
|
||||
}
|
||||
/**
|
||||
* 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\controllers;
|
||||
|
||||
|
||||
/**
|
||||
* Controller of the Agent to display a menu.
|
||||
*
|
||||
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
||||
*/
|
||||
class MenuController extends \hhu\z\Controller
|
||||
{
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Prefilter.
|
||||
*
|
||||
* @param \nre\core\Request $request Current request
|
||||
* @param \nre\core\Response $response Current response
|
||||
*/
|
||||
public function preFilter(\nre\core\Request $request, \nre\core\Response $response)
|
||||
{
|
||||
parent::preFilter($request, $response);
|
||||
|
||||
// Set userdata
|
||||
$this->set('loggedUser', IntermediateController::$user);
|
||||
$this->set('loggedCharacter', SeminaryController::$character);
|
||||
$this->set('loggedSeminary', SeminaryController::$seminary);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Action: index.
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
|
|
@ -1,346 +1,346 @@
|
|||
<?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\controllers;
|
||||
|
||||
|
||||
/**
|
||||
* Controller of the QuestgroupsAgent to display Questgroups.
|
||||
*
|
||||
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
||||
*/
|
||||
class QuestgroupshierarchyController extends \hhu\z\controllers\SeminaryController
|
||||
{
|
||||
/**
|
||||
* Required components
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $components = array('validation');
|
||||
/**
|
||||
* Required models
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $models = array('seminaries', 'questgroupshierarchy', 'questgroups');
|
||||
/**
|
||||
* User permissions
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $permissions = array(
|
||||
'create' => array('admin', 'moderator', 'user'),
|
||||
'edit' => array('admin', 'moderator', 'user'),
|
||||
'moveup' => array('admin', 'moderator', 'user'),
|
||||
'movedown' => array('admin', 'moderator', 'user'),
|
||||
'delete' => array('admin', 'moderator', 'user')
|
||||
);
|
||||
/**
|
||||
* User seminary permissions
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $seminaryPermissions = array(
|
||||
'create' => array('admin'),
|
||||
'edit' => array('admin'),
|
||||
'moveup' => array('admin'),
|
||||
'movedown' => array('admin'),
|
||||
'delete' => array('admin')
|
||||
);
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Action: create.
|
||||
*
|
||||
* Create a new Questgroupshierarchy.
|
||||
*
|
||||
* @param string $seminaryUrl URL-title of a Seminary
|
||||
*/
|
||||
public function create($seminaryUrl)
|
||||
{
|
||||
// Get seminary
|
||||
$seminary = $this->Seminaries->getSeminaryByUrl($seminaryUrl);
|
||||
|
||||
// Get parent Questgroupshierarchy
|
||||
$parentQuestgroupshierarchy = $this->Questgroupshierarchy->getHierarchyOfSeminary($seminary['id']);
|
||||
|
||||
// Values
|
||||
$titleSingular = '';
|
||||
$titlePlural = '';
|
||||
$validation = array();
|
||||
|
||||
// Create Questgroupshierarchy
|
||||
if($this->request->getRequestMethod() == 'POST' && !is_null($this->request->getPostParam('create')))
|
||||
{
|
||||
// Get params and validate them
|
||||
$titleSingular = $this->request->getPostParam('title_singular');
|
||||
$validation = $this->Validation->addValidationResults(
|
||||
$validation,
|
||||
'titleSingular',
|
||||
$this->Validation->validate($titleSingular, \nre\configs\AppConfig::$validation['questgroupshierarchytitle'])
|
||||
);
|
||||
if($this->Questgroupshierarchy->questgroupshierarchyTitleSingularExists($titleSingular, $seminary['id'])) {
|
||||
$validation = $this->Validation->addValidationResult($validation, 'titleSingular', 'exist', true);
|
||||
}
|
||||
$titlePlural = $this->request->getPostParam('title_plural');
|
||||
$validation = $this->Validation->addValidationResults(
|
||||
$validation,
|
||||
'titlePlural',
|
||||
$this->Validation->validate($titlePlural, \nre\configs\AppConfig::$validation['questgroupshierarchytitle'])
|
||||
);
|
||||
if($this->Questgroupshierarchy->questgroupshierarchyTitleSingularExists($titlePlural, $seminary['id'])) {
|
||||
$validation = $this->Validation->addValidationResult($validation, 'titlePlural', 'exist', true);
|
||||
}
|
||||
|
||||
// Validate parent Questgroupshierarchy
|
||||
$parentQuestgroupshierarchyIndex = null;
|
||||
foreach($parentQuestgroupshierarchy as $index => &$parentHierarchy)
|
||||
{
|
||||
$parentHierarchy['selected'] = ($parentHierarchy['url'] == $this->request->getPostParam('parent'));
|
||||
if($parentHierarchy['selected']) {
|
||||
$parentQuestgroupshierarchyIndex = $index;
|
||||
}
|
||||
}
|
||||
|
||||
// Create new Questgroupshierarchy
|
||||
if($validation === true)
|
||||
{
|
||||
$questgroupshierarchyId = $this->Questgroupshierarchy->createQuestgroupshierarchy(
|
||||
$this->Auth->getUserId(),
|
||||
$seminary['id'],
|
||||
(!is_null($parentQuestgroupshierarchyIndex) ? $parentQuestgroupshierarchy[$parentQuestgroupshierarchyIndex]['id'] : null),
|
||||
$titleSingular,
|
||||
$titlePlural
|
||||
);
|
||||
$questgroupshierarchy = $this->Questgroupshierarchy->getHierarchyById($questgroupshierarchyId);
|
||||
|
||||
// Redirect
|
||||
$this->redirect($this->linker->link(array('seminaries', 'seminary', $seminary['url'])));
|
||||
}
|
||||
}
|
||||
|
||||
// Get validation settings
|
||||
$validationSettings = array(
|
||||
'title' => \nre\configs\AppConfig::$validation['title']
|
||||
);
|
||||
|
||||
|
||||
// Set titile
|
||||
$this->addTitleLocalized('Create Questgroupshierarchy');
|
||||
$this->addTitle($seminary['title']);
|
||||
|
||||
// Pass data to view
|
||||
$this->set('seminary', $seminary);
|
||||
$this->set('titleSingular', $titleSingular);
|
||||
$this->set('titlePlural', $titlePlural);
|
||||
$this->set('parentQuestgroupshierarchy', $parentQuestgroupshierarchy);
|
||||
$this->set('validation', $validation);
|
||||
$this->set('validationSettings', $validationSettings);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Action: edit.
|
||||
*
|
||||
* Edit a Questgroupshierarchy.
|
||||
*
|
||||
* @throws \nre\exceptions\IdNotFoundException
|
||||
* @param string $seminaryUrl URL-title of Seminary
|
||||
* @param string $questgroupshierarchyUrl URL-title of Questgroupshierarchy
|
||||
*/
|
||||
public function edit($seminaryUrl, $questgroupshierarchyUrl)
|
||||
{
|
||||
// Get seminary
|
||||
$seminary = $this->Seminaries->getSeminaryByUrl($seminaryUrl);
|
||||
|
||||
// Get Questgroupshierarchy
|
||||
$questgroupshierarchy = $this->Questgroupshierarchy->getHierarchyByUrl($seminary['id'], $questgroupshierarchyUrl);
|
||||
|
||||
// Values
|
||||
$titleSingular = $questgroupshierarchy['title_singular'];
|
||||
$titlePlural = $questgroupshierarchy['title_plural'];
|
||||
$validation = array();
|
||||
|
||||
// Check request method
|
||||
if($this->request->getRequestMethod() == 'POST' && !is_null($this->request->getPostParam('edit')))
|
||||
{
|
||||
// Get params and validate them
|
||||
$titleSingular = $this->request->getPostParam('title_singular');
|
||||
$validation = $this->Validation->addValidationResults(
|
||||
$validation,
|
||||
'titleSingular',
|
||||
$this->Validation->validate($titleSingular, \nre\configs\AppConfig::$validation['questgroupshierarchytitle'])
|
||||
);
|
||||
if($this->Questgroupshierarchy->questgroupshierarchyTitleSingularExists($titleSingular, $seminary['id'], $questgroupshierarchy['id'])) {
|
||||
$validation = $this->Validation->addValidationResult($validation, 'titleSingular', 'exist', true);
|
||||
}
|
||||
$titlePlural = $this->request->getPostParam('title_plural');
|
||||
$validation = $this->Validation->addValidationResults(
|
||||
$validation,
|
||||
'titlePlural',
|
||||
$this->Validation->validate($titlePlural, \nre\configs\AppConfig::$validation['questgroupshierarchytitle'])
|
||||
);
|
||||
if($this->Questgroupshierarchy->questgroupshierarchyTitleSingularExists($titlePlural, $seminary['id'], $questgroupshierarchy['id'])) {
|
||||
$validation = $this->Validation->addValidationResult($validation, 'titlePlural', 'exist', true);
|
||||
}
|
||||
/**
|
||||
* 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
|
||||
*/
|
||||
|
||||
|
||||
// Edit Questgroup
|
||||
if($validation === true)
|
||||
{
|
||||
$this->Questgroupshierarchy->editQuestgroupshierarchy(
|
||||
$questgroupshierarchy['id'],
|
||||
$titleSingular,
|
||||
$titlePlural
|
||||
);
|
||||
$questgroupshierarchy = $this->Questgroupshierarchy->getHierarchyById($questgroupshierarchy['id']);
|
||||
|
||||
// Redirect to Seminary page
|
||||
$this->redirect($this->linker->link(array('seminaries', 'seminary', $seminary['url'])));
|
||||
}
|
||||
}
|
||||
|
||||
// Get validation settings
|
||||
$validationSettings = array(
|
||||
'title' => \nre\configs\AppConfig::$validation['title']
|
||||
);
|
||||
|
||||
|
||||
// Set titile
|
||||
$this->addTitleLocalized('Edit Questgroupshierarchy');
|
||||
$this->addTitle($seminary['title']);
|
||||
|
||||
// Pass data to view
|
||||
$this->set('seminary', $seminary);
|
||||
$this->set('titleSingular', $titleSingular);
|
||||
$this->set('titlePlural', $titlePlural);
|
||||
$this->set('validation', $validation);
|
||||
$this->set('validationSettings', $validationSettings);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Action: moveup.
|
||||
*
|
||||
* Move a Questgroupshierarchy up (decrement position).
|
||||
*
|
||||
* @throws \nre\exceptions\IdNotFoundException
|
||||
* @param string $seminaryUrl URL-title of Seminary
|
||||
* @param string $questgroupshierarchyUrl URL-title of Questgroupshierarchy
|
||||
*/
|
||||
public function moveup($seminaryUrl, $questgroupshierarchyUrl)
|
||||
{
|
||||
// Get seminary
|
||||
$seminary = $this->Seminaries->getSeminaryByUrl($seminaryUrl);
|
||||
|
||||
// Get Questgroupshierarchy
|
||||
$questgroupshierarchy = $this->Questgroupshierarchy->getHierarchyByUrl($seminary['id'], $questgroupshierarchyUrl);
|
||||
|
||||
// Set position
|
||||
$this->Questgroupshierarchy->moveQuestgroupshierarchy($questgroupshierarchy, true);
|
||||
|
||||
|
||||
// Redirect
|
||||
$referer = $this->request->getGetParam('referer');
|
||||
if(!is_null($referer))
|
||||
{
|
||||
try {
|
||||
$questgroup = $this->Questgroups->getQuestgroupById($referer);
|
||||
$this->redirect($this->linker->link(array('questgroups', 'questgroup', $seminary['url'], $questgroup['url'])));
|
||||
}
|
||||
catch(IdNotFoundException $e) {
|
||||
}
|
||||
}
|
||||
$this->redirect($this->linker->link(array('seminaries', 'seminary', $seminary['url'])));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Action: movedown.
|
||||
*
|
||||
* Move a Questgroupshierarchy down (increment position).
|
||||
*
|
||||
* @throws \nre\exceptions\IdNotFoundException
|
||||
* @param string $seminaryUrl URL-title of Seminary
|
||||
* @param string $questgroupshierarchyUrl URL-title of Questgroupshierarchy
|
||||
*/
|
||||
public function movedown($seminaryUrl, $questgroupshierarchyUrl)
|
||||
{
|
||||
// Get seminary
|
||||
$seminary = $this->Seminaries->getSeminaryByUrl($seminaryUrl);
|
||||
|
||||
// Get Questgroupshierarchy
|
||||
$questgroupshierarchy = $this->Questgroupshierarchy->getHierarchyByUrl($seminary['id'], $questgroupshierarchyUrl);
|
||||
|
||||
// Set position
|
||||
$this->Questgroupshierarchy->moveQuestgroupshierarchy($questgroupshierarchy, false);
|
||||
|
||||
|
||||
// Redirect
|
||||
$referer = $this->request->getGetParam('referer');
|
||||
if(!is_null($referer))
|
||||
{
|
||||
try {
|
||||
$questgroup = $this->Questgroups->getQuestgroupById($referer);
|
||||
$this->redirect($this->linker->link(array('questgroups', 'questgroup', $seminary['url'], $questgroup['url'])));
|
||||
}
|
||||
catch(IdNotFoundException $e) {
|
||||
}
|
||||
}
|
||||
$this->redirect($this->linker->link(array('seminaries', 'seminary', $seminary['url'])));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Action: delete.
|
||||
*
|
||||
* Delete a Questgroupshierarchy.
|
||||
*
|
||||
* @throws \nre\exceptions\IdNotFoundException
|
||||
* @param string $seminaryUrl URL-title of Seminary
|
||||
* @param string $questgroupshierarchyUrl URL-title of Questgroupshierarchy
|
||||
*/
|
||||
public function delete($seminaryUrl, $questgroupshierarchyUrl)
|
||||
{
|
||||
// Get seminary
|
||||
$seminary = $this->Seminaries->getSeminaryByUrl($seminaryUrl);
|
||||
|
||||
// Get Questgroupshierarchy
|
||||
$questgroupshierarchy = $this->Questgroupshierarchy->getHierarchyByUrl($seminary['id'], $questgroupshierarchyUrl);
|
||||
|
||||
// Check request method
|
||||
if($this->request->getRequestMethod() == 'POST')
|
||||
{
|
||||
// Check confirmation
|
||||
if(!is_null($this->request->getPostParam('delete')))
|
||||
{
|
||||
// Delete Questgroupshierarchy
|
||||
$this->Questgroupshierarchy->deleteQuestgroupshierarchy($questgroupshierarchy['id']);
|
||||
}
|
||||
|
||||
// Redirect to Seminary page
|
||||
$this->redirect($this->linker->link(array('seminaries', 'seminary', $seminary['url'])));
|
||||
}
|
||||
|
||||
|
||||
// Set titile
|
||||
$this->addTitleLocalized('Delete Questgroupshierarchy');
|
||||
|
||||
// Show confirmation
|
||||
$this->set('seminary', $seminary);
|
||||
$this->set('questgroupshierarchy', $questgroupshierarchy);
|
||||
}
|
||||
|
||||
}
|
||||
namespace hhu\z\controllers;
|
||||
|
||||
|
||||
/**
|
||||
* Controller of the QuestgroupsAgent to display Questgroups.
|
||||
*
|
||||
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
||||
*/
|
||||
class QuestgroupshierarchyController extends \hhu\z\controllers\SeminaryController
|
||||
{
|
||||
/**
|
||||
* Required components
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $components = array('validation');
|
||||
/**
|
||||
* Required models
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $models = array('seminaries', 'questgroupshierarchy', 'questgroups');
|
||||
/**
|
||||
* User permissions
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $permissions = array(
|
||||
'create' => array('admin', 'moderator', 'user'),
|
||||
'edit' => array('admin', 'moderator', 'user'),
|
||||
'moveup' => array('admin', 'moderator', 'user'),
|
||||
'movedown' => array('admin', 'moderator', 'user'),
|
||||
'delete' => array('admin', 'moderator', 'user')
|
||||
);
|
||||
/**
|
||||
* User seminary permissions
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $seminaryPermissions = array(
|
||||
'create' => array('admin'),
|
||||
'edit' => array('admin'),
|
||||
'moveup' => array('admin'),
|
||||
'movedown' => array('admin'),
|
||||
'delete' => array('admin')
|
||||
);
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Action: create.
|
||||
*
|
||||
* Create a new Questgroupshierarchy.
|
||||
*
|
||||
* @param string $seminaryUrl URL-title of a Seminary
|
||||
*/
|
||||
public function create($seminaryUrl)
|
||||
{
|
||||
// Get seminary
|
||||
$seminary = $this->Seminaries->getSeminaryByUrl($seminaryUrl);
|
||||
|
||||
// Get parent Questgroupshierarchy
|
||||
$parentQuestgroupshierarchy = $this->Questgroupshierarchy->getHierarchyOfSeminary($seminary['id']);
|
||||
|
||||
// Values
|
||||
$titleSingular = '';
|
||||
$titlePlural = '';
|
||||
$validation = array();
|
||||
|
||||
// Create Questgroupshierarchy
|
||||
if($this->request->getRequestMethod() == 'POST' && !is_null($this->request->getPostParam('create')))
|
||||
{
|
||||
// Get params and validate them
|
||||
$titleSingular = $this->request->getPostParam('title_singular');
|
||||
$validation = $this->Validation->addValidationResults(
|
||||
$validation,
|
||||
'titleSingular',
|
||||
$this->Validation->validate($titleSingular, \nre\configs\AppConfig::$validation['questgroupshierarchytitle'])
|
||||
);
|
||||
if($this->Questgroupshierarchy->questgroupshierarchyTitleSingularExists($titleSingular, $seminary['id'])) {
|
||||
$validation = $this->Validation->addValidationResult($validation, 'titleSingular', 'exist', true);
|
||||
}
|
||||
$titlePlural = $this->request->getPostParam('title_plural');
|
||||
$validation = $this->Validation->addValidationResults(
|
||||
$validation,
|
||||
'titlePlural',
|
||||
$this->Validation->validate($titlePlural, \nre\configs\AppConfig::$validation['questgroupshierarchytitle'])
|
||||
);
|
||||
if($this->Questgroupshierarchy->questgroupshierarchyTitleSingularExists($titlePlural, $seminary['id'])) {
|
||||
$validation = $this->Validation->addValidationResult($validation, 'titlePlural', 'exist', true);
|
||||
}
|
||||
|
||||
// Validate parent Questgroupshierarchy
|
||||
$parentQuestgroupshierarchyIndex = null;
|
||||
foreach($parentQuestgroupshierarchy as $index => &$parentHierarchy)
|
||||
{
|
||||
$parentHierarchy['selected'] = ($parentHierarchy['url'] == $this->request->getPostParam('parent'));
|
||||
if($parentHierarchy['selected']) {
|
||||
$parentQuestgroupshierarchyIndex = $index;
|
||||
}
|
||||
}
|
||||
|
||||
// Create new Questgroupshierarchy
|
||||
if($validation === true)
|
||||
{
|
||||
$questgroupshierarchyId = $this->Questgroupshierarchy->createQuestgroupshierarchy(
|
||||
$this->Auth->getUserId(),
|
||||
$seminary['id'],
|
||||
(!is_null($parentQuestgroupshierarchyIndex) ? $parentQuestgroupshierarchy[$parentQuestgroupshierarchyIndex]['id'] : null),
|
||||
$titleSingular,
|
||||
$titlePlural
|
||||
);
|
||||
$questgroupshierarchy = $this->Questgroupshierarchy->getHierarchyById($questgroupshierarchyId);
|
||||
|
||||
// Redirect
|
||||
$this->redirect($this->linker->link(array('seminaries', 'seminary', $seminary['url'])));
|
||||
}
|
||||
}
|
||||
|
||||
// Get validation settings
|
||||
$validationSettings = array(
|
||||
'title' => \nre\configs\AppConfig::$validation['title']
|
||||
);
|
||||
|
||||
|
||||
// Set titile
|
||||
$this->addTitleLocalized('Create Questgroupshierarchy');
|
||||
$this->addTitle($seminary['title']);
|
||||
|
||||
// Pass data to view
|
||||
$this->set('seminary', $seminary);
|
||||
$this->set('titleSingular', $titleSingular);
|
||||
$this->set('titlePlural', $titlePlural);
|
||||
$this->set('parentQuestgroupshierarchy', $parentQuestgroupshierarchy);
|
||||
$this->set('validation', $validation);
|
||||
$this->set('validationSettings', $validationSettings);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Action: edit.
|
||||
*
|
||||
* Edit a Questgroupshierarchy.
|
||||
*
|
||||
* @throws \nre\exceptions\IdNotFoundException
|
||||
* @param string $seminaryUrl URL-title of Seminary
|
||||
* @param string $questgroupshierarchyUrl URL-title of Questgroupshierarchy
|
||||
*/
|
||||
public function edit($seminaryUrl, $questgroupshierarchyUrl)
|
||||
{
|
||||
// Get seminary
|
||||
$seminary = $this->Seminaries->getSeminaryByUrl($seminaryUrl);
|
||||
|
||||
// Get Questgroupshierarchy
|
||||
$questgroupshierarchy = $this->Questgroupshierarchy->getHierarchyByUrl($seminary['id'], $questgroupshierarchyUrl);
|
||||
|
||||
// Values
|
||||
$titleSingular = $questgroupshierarchy['title_singular'];
|
||||
$titlePlural = $questgroupshierarchy['title_plural'];
|
||||
$validation = array();
|
||||
|
||||
// Check request method
|
||||
if($this->request->getRequestMethod() == 'POST' && !is_null($this->request->getPostParam('edit')))
|
||||
{
|
||||
// Get params and validate them
|
||||
$titleSingular = $this->request->getPostParam('title_singular');
|
||||
$validation = $this->Validation->addValidationResults(
|
||||
$validation,
|
||||
'titleSingular',
|
||||
$this->Validation->validate($titleSingular, \nre\configs\AppConfig::$validation['questgroupshierarchytitle'])
|
||||
);
|
||||
if($this->Questgroupshierarchy->questgroupshierarchyTitleSingularExists($titleSingular, $seminary['id'], $questgroupshierarchy['id'])) {
|
||||
$validation = $this->Validation->addValidationResult($validation, 'titleSingular', 'exist', true);
|
||||
}
|
||||
$titlePlural = $this->request->getPostParam('title_plural');
|
||||
$validation = $this->Validation->addValidationResults(
|
||||
$validation,
|
||||
'titlePlural',
|
||||
$this->Validation->validate($titlePlural, \nre\configs\AppConfig::$validation['questgroupshierarchytitle'])
|
||||
);
|
||||
if($this->Questgroupshierarchy->questgroupshierarchyTitleSingularExists($titlePlural, $seminary['id'], $questgroupshierarchy['id'])) {
|
||||
$validation = $this->Validation->addValidationResult($validation, 'titlePlural', 'exist', true);
|
||||
}
|
||||
|
||||
|
||||
// Edit Questgroup
|
||||
if($validation === true)
|
||||
{
|
||||
$this->Questgroupshierarchy->editQuestgroupshierarchy(
|
||||
$questgroupshierarchy['id'],
|
||||
$titleSingular,
|
||||
$titlePlural
|
||||
);
|
||||
$questgroupshierarchy = $this->Questgroupshierarchy->getHierarchyById($questgroupshierarchy['id']);
|
||||
|
||||
// Redirect to Seminary page
|
||||
$this->redirect($this->linker->link(array('seminaries', 'seminary', $seminary['url'])));
|
||||
}
|
||||
}
|
||||
|
||||
// Get validation settings
|
||||
$validationSettings = array(
|
||||
'title' => \nre\configs\AppConfig::$validation['title']
|
||||
);
|
||||
|
||||
|
||||
// Set titile
|
||||
$this->addTitleLocalized('Edit Questgroupshierarchy');
|
||||
$this->addTitle($seminary['title']);
|
||||
|
||||
// Pass data to view
|
||||
$this->set('seminary', $seminary);
|
||||
$this->set('titleSingular', $titleSingular);
|
||||
$this->set('titlePlural', $titlePlural);
|
||||
$this->set('validation', $validation);
|
||||
$this->set('validationSettings', $validationSettings);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Action: moveup.
|
||||
*
|
||||
* Move a Questgroupshierarchy up (decrement position).
|
||||
*
|
||||
* @throws \nre\exceptions\IdNotFoundException
|
||||
* @param string $seminaryUrl URL-title of Seminary
|
||||
* @param string $questgroupshierarchyUrl URL-title of Questgroupshierarchy
|
||||
*/
|
||||
public function moveup($seminaryUrl, $questgroupshierarchyUrl)
|
||||
{
|
||||
// Get seminary
|
||||
$seminary = $this->Seminaries->getSeminaryByUrl($seminaryUrl);
|
||||
|
||||
// Get Questgroupshierarchy
|
||||
$questgroupshierarchy = $this->Questgroupshierarchy->getHierarchyByUrl($seminary['id'], $questgroupshierarchyUrl);
|
||||
|
||||
// Set position
|
||||
$this->Questgroupshierarchy->moveQuestgroupshierarchy($questgroupshierarchy, true);
|
||||
|
||||
|
||||
// Redirect
|
||||
$referer = $this->request->getGetParam('referer');
|
||||
if(!is_null($referer))
|
||||
{
|
||||
try {
|
||||
$questgroup = $this->Questgroups->getQuestgroupById($referer);
|
||||
$this->redirect($this->linker->link(array('questgroups', 'questgroup', $seminary['url'], $questgroup['url'])));
|
||||
}
|
||||
catch(IdNotFoundException $e) {
|
||||
}
|
||||
}
|
||||
$this->redirect($this->linker->link(array('seminaries', 'seminary', $seminary['url'])));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Action: movedown.
|
||||
*
|
||||
* Move a Questgroupshierarchy down (increment position).
|
||||
*
|
||||
* @throws \nre\exceptions\IdNotFoundException
|
||||
* @param string $seminaryUrl URL-title of Seminary
|
||||
* @param string $questgroupshierarchyUrl URL-title of Questgroupshierarchy
|
||||
*/
|
||||
public function movedown($seminaryUrl, $questgroupshierarchyUrl)
|
||||
{
|
||||
// Get seminary
|
||||
$seminary = $this->Seminaries->getSeminaryByUrl($seminaryUrl);
|
||||
|
||||
// Get Questgroupshierarchy
|
||||
$questgroupshierarchy = $this->Questgroupshierarchy->getHierarchyByUrl($seminary['id'], $questgroupshierarchyUrl);
|
||||
|
||||
// Set position
|
||||
$this->Questgroupshierarchy->moveQuestgroupshierarchy($questgroupshierarchy, false);
|
||||
|
||||
|
||||
// Redirect
|
||||
$referer = $this->request->getGetParam('referer');
|
||||
if(!is_null($referer))
|
||||
{
|
||||
try {
|
||||
$questgroup = $this->Questgroups->getQuestgroupById($referer);
|
||||
$this->redirect($this->linker->link(array('questgroups', 'questgroup', $seminary['url'], $questgroup['url'])));
|
||||
}
|
||||
catch(IdNotFoundException $e) {
|
||||
}
|
||||
}
|
||||
$this->redirect($this->linker->link(array('seminaries', 'seminary', $seminary['url'])));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Action: delete.
|
||||
*
|
||||
* Delete a Questgroupshierarchy.
|
||||
*
|
||||
* @throws \nre\exceptions\IdNotFoundException
|
||||
* @param string $seminaryUrl URL-title of Seminary
|
||||
* @param string $questgroupshierarchyUrl URL-title of Questgroupshierarchy
|
||||
*/
|
||||
public function delete($seminaryUrl, $questgroupshierarchyUrl)
|
||||
{
|
||||
// Get seminary
|
||||
$seminary = $this->Seminaries->getSeminaryByUrl($seminaryUrl);
|
||||
|
||||
// Get Questgroupshierarchy
|
||||
$questgroupshierarchy = $this->Questgroupshierarchy->getHierarchyByUrl($seminary['id'], $questgroupshierarchyUrl);
|
||||
|
||||
// Check request method
|
||||
if($this->request->getRequestMethod() == 'POST')
|
||||
{
|
||||
// Check confirmation
|
||||
if(!is_null($this->request->getPostParam('delete')))
|
||||
{
|
||||
// Delete Questgroupshierarchy
|
||||
$this->Questgroupshierarchy->deleteQuestgroupshierarchy($questgroupshierarchy['id']);
|
||||
}
|
||||
|
||||
// Redirect to Seminary page
|
||||
$this->redirect($this->linker->link(array('seminaries', 'seminary', $seminary['url'])));
|
||||
}
|
||||
|
||||
|
||||
// Set titile
|
||||
$this->addTitleLocalized('Delete Questgroupshierarchy');
|
||||
|
||||
// Show confirmation
|
||||
$this->set('seminary', $seminary);
|
||||
$this->set('questgroupshierarchy', $questgroupshierarchy);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue