replace tabs with spaces
This commit is contained in:
parent
50c38e0efa
commit
c79f0f213b
176 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);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
|
|||
|
|
@ -1,91 +1,91 @@
|
|||
<?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 QuestgroupshierarchypathAgent to display the
|
||||
* Questgroups hierarchy path.
|
||||
*
|
||||
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
||||
*/
|
||||
class QuestgroupshierarchypathController extends \hhu\z\Controller
|
||||
{
|
||||
/**
|
||||
* Required models
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $models = array('seminaries', 'questgroups', 'questgroupshierarchy', 'quests', 'questtexts');
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Action: index.
|
||||
*
|
||||
* Calculate and show the hierarchy path of a Questgroup.
|
||||
*
|
||||
* @param string $seminaryUrl URL-Title of a Seminary
|
||||
* @param string $questgroupUrl URL-Title of a Questgroup
|
||||
* @param boolean $showGroup Show the current group itself
|
||||
*/
|
||||
public function index($seminaryUrl, $questgroupUrl, $showGroup=false)
|
||||
{
|
||||
// Get Seminary
|
||||
$seminary = $this->Seminaries->getSeminaryByUrl($seminaryUrl);
|
||||
|
||||
// Get Questgroup
|
||||
$questgroup = $this->Questgroups->getQuestgroupByUrl($seminary['id'], $questgroupUrl);
|
||||
$questgroup['hierarchy'] = $this->Questgroupshierarchy->getHierarchyForQuestgroup($questgroup['id']);
|
||||
|
||||
// Get parent Questgrouphierarchy
|
||||
$currentQuestgroup = $questgroup;
|
||||
$parentQuestgroupshierarchy = array();
|
||||
if($showGroup) {
|
||||
array_unshift($parentQuestgroupshierarchy, $currentQuestgroup);
|
||||
}
|
||||
if(is_null($questgroup['hierarchy']))
|
||||
{
|
||||
// Get related Questgroup
|
||||
$questtexts = $this->Questtexts->getRelatedQuesttextsForQuestgroup($currentQuestgroup['id']);
|
||||
$questtext = $this->Questtexts->pickQuesttextLastEnteredByCharacter(\hhu\z\controllers\SeminaryController::$character['id'], $questtexts);
|
||||
$quest = $this->Quests->getQuestById($questtext['quest_id']);
|
||||
$currentQuestgroup = $this->Questgroups->getQuestgroupById($quest['questgroup_id']);
|
||||
$currentQuestgroup['hierarchy'] = $this->Questgroupshierarchy->getHierarchyForQuestgroup($currentQuestgroup['id']);
|
||||
$quest['questgroup'] = $currentQuestgroup;
|
||||
|
||||
// Use Hierarchy name for optional Questgroup
|
||||
if(!empty($parentQuestgroupshierarchy)) {
|
||||
$parentQuestgroupshierarchy[0]['hierarchy'] = $currentQuestgroup['hierarchy'];
|
||||
unset($parentQuestgroupshierarchy[0]['hierarchy']['questgroup_pos']);
|
||||
}
|
||||
|
||||
array_unshift($parentQuestgroupshierarchy, $quest);
|
||||
array_unshift($parentQuestgroupshierarchy, $currentQuestgroup);
|
||||
}
|
||||
while(!empty($currentQuestgroup['hierarchy']) && !is_null($currentQuestgroup['hierarchy']['parent_questgroup_id']))
|
||||
{
|
||||
$currentQuestgroup = $this->Questgroups->GetQuestgroupById($currentQuestgroup['hierarchy']['parent_questgroup_id']);
|
||||
$currentQuestgroup['hierarchy'] = $this->Questgroupshierarchy->getHierarchyForQuestgroup($currentQuestgroup['id']);
|
||||
array_unshift($parentQuestgroupshierarchy, $currentQuestgroup);
|
||||
}
|
||||
|
||||
|
||||
// Pass data to view
|
||||
$this->set('seminary', $seminary);
|
||||
$this->set('parentquestgroupshierarchy', $parentQuestgroupshierarchy);
|
||||
}
|
||||
|
||||
}
|
||||
/**
|
||||
* 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 QuestgroupshierarchypathAgent to display the
|
||||
* Questgroups hierarchy path.
|
||||
*
|
||||
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
||||
*/
|
||||
class QuestgroupshierarchypathController extends \hhu\z\Controller
|
||||
{
|
||||
/**
|
||||
* Required models
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $models = array('seminaries', 'questgroups', 'questgroupshierarchy', 'quests', 'questtexts');
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Action: index.
|
||||
*
|
||||
* Calculate and show the hierarchy path of a Questgroup.
|
||||
*
|
||||
* @param string $seminaryUrl URL-Title of a Seminary
|
||||
* @param string $questgroupUrl URL-Title of a Questgroup
|
||||
* @param boolean $showGroup Show the current group itself
|
||||
*/
|
||||
public function index($seminaryUrl, $questgroupUrl, $showGroup=false)
|
||||
{
|
||||
// Get Seminary
|
||||
$seminary = $this->Seminaries->getSeminaryByUrl($seminaryUrl);
|
||||
|
||||
// Get Questgroup
|
||||
$questgroup = $this->Questgroups->getQuestgroupByUrl($seminary['id'], $questgroupUrl);
|
||||
$questgroup['hierarchy'] = $this->Questgroupshierarchy->getHierarchyForQuestgroup($questgroup['id']);
|
||||
|
||||
// Get parent Questgrouphierarchy
|
||||
$currentQuestgroup = $questgroup;
|
||||
$parentQuestgroupshierarchy = array();
|
||||
if($showGroup) {
|
||||
array_unshift($parentQuestgroupshierarchy, $currentQuestgroup);
|
||||
}
|
||||
if(is_null($questgroup['hierarchy']))
|
||||
{
|
||||
// Get related Questgroup
|
||||
$questtexts = $this->Questtexts->getRelatedQuesttextsForQuestgroup($currentQuestgroup['id']);
|
||||
$questtext = $this->Questtexts->pickQuesttextLastEnteredByCharacter(\hhu\z\controllers\SeminaryController::$character['id'], $questtexts);
|
||||
$quest = $this->Quests->getQuestById($questtext['quest_id']);
|
||||
$currentQuestgroup = $this->Questgroups->getQuestgroupById($quest['questgroup_id']);
|
||||
$currentQuestgroup['hierarchy'] = $this->Questgroupshierarchy->getHierarchyForQuestgroup($currentQuestgroup['id']);
|
||||
$quest['questgroup'] = $currentQuestgroup;
|
||||
|
||||
// Use Hierarchy name for optional Questgroup
|
||||
if(!empty($parentQuestgroupshierarchy)) {
|
||||
$parentQuestgroupshierarchy[0]['hierarchy'] = $currentQuestgroup['hierarchy'];
|
||||
unset($parentQuestgroupshierarchy[0]['hierarchy']['questgroup_pos']);
|
||||
}
|
||||
|
||||
array_unshift($parentQuestgroupshierarchy, $quest);
|
||||
array_unshift($parentQuestgroupshierarchy, $currentQuestgroup);
|
||||
}
|
||||
while(!empty($currentQuestgroup['hierarchy']) && !is_null($currentQuestgroup['hierarchy']['parent_questgroup_id']))
|
||||
{
|
||||
$currentQuestgroup = $this->Questgroups->GetQuestgroupById($currentQuestgroup['hierarchy']['parent_questgroup_id']);
|
||||
$currentQuestgroup['hierarchy'] = $this->Questgroupshierarchy->getHierarchyForQuestgroup($currentQuestgroup['id']);
|
||||
array_unshift($parentQuestgroupshierarchy, $currentQuestgroup);
|
||||
}
|
||||
|
||||
|
||||
// Pass data to view
|
||||
$this->set('seminary', $seminary);
|
||||
$this->set('parentquestgroupshierarchy', $parentQuestgroupshierarchy);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
|
|
@ -1,89 +1,89 @@
|
|||
<?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 sidebar with Seminary related
|
||||
* information.
|
||||
*
|
||||
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
||||
*/
|
||||
class SeminarybarController extends \hhu\z\Controller
|
||||
{
|
||||
/**
|
||||
* Required models
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $models = array('characters', 'quests', 'questgroups', 'achievements', 'charactergroups', 'avatars', 'media', 'xplevels');
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Action: index.
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
// Do not render at first
|
||||
$this->set('render', false);
|
||||
|
||||
// Get Seminary
|
||||
$seminary = SeminaryController::$seminary;
|
||||
if(is_null($seminary)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Get Character
|
||||
$character = SeminaryController::$character;
|
||||
if(is_null($character)) {
|
||||
return;
|
||||
}
|
||||
$character['rank'] = $this->Characters->getXPRank($seminary['id'], $character['xps']);
|
||||
|
||||
// Get “last” Quest
|
||||
$lastQuest = $this->Quests->getLastQuestForCharacter($character['id']);
|
||||
if(!is_null($lastQuest)) {
|
||||
$lastQuest['questgroup'] = $this->Questgroups->getQuestgroupById($lastQuest['questgroup_id']);
|
||||
}
|
||||
|
||||
// Get last achieved Achievement
|
||||
$achievements = $this->Achievements->getAchievedAchievementsForCharacter($character['id'], false);
|
||||
$lastAchievement = array_shift($achievements);
|
||||
|
||||
// Get Character group members
|
||||
$characterGroups = array();
|
||||
foreach($this->Charactergroups->getGroupsForCharacter($character['id']) as $group)
|
||||
{
|
||||
$groupsgroup = $this->Charactergroups->getGroupsgroupById($group['charactergroupsgroup_id']);
|
||||
if($groupsgroup['preferred'])
|
||||
{
|
||||
$group['members'] = $this->Characters->getCharactersForGroup($group['id']);
|
||||
$characterGroups[] = $group;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Pass data to view
|
||||
$this->set('seminary', $seminary);
|
||||
$this->set('character', $character);
|
||||
$this->set('lastQuest', $lastQuest);
|
||||
$this->set('lastAchievement', $lastAchievement);
|
||||
$this->set('characterGroups', $characterGroups);
|
||||
// Render now
|
||||
$this->set('render', 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
|
||||
*/
|
||||
|
||||
namespace hhu\z\controllers;
|
||||
|
||||
|
||||
/**
|
||||
* Controller of the Agent to display a sidebar with Seminary related
|
||||
* information.
|
||||
*
|
||||
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
||||
*/
|
||||
class SeminarybarController extends \hhu\z\Controller
|
||||
{
|
||||
/**
|
||||
* Required models
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $models = array('characters', 'quests', 'questgroups', 'achievements', 'charactergroups', 'avatars', 'media', 'xplevels');
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Action: index.
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
// Do not render at first
|
||||
$this->set('render', false);
|
||||
|
||||
// Get Seminary
|
||||
$seminary = SeminaryController::$seminary;
|
||||
if(is_null($seminary)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Get Character
|
||||
$character = SeminaryController::$character;
|
||||
if(is_null($character)) {
|
||||
return;
|
||||
}
|
||||
$character['rank'] = $this->Characters->getXPRank($seminary['id'], $character['xps']);
|
||||
|
||||
// Get “last” Quest
|
||||
$lastQuest = $this->Quests->getLastQuestForCharacter($character['id']);
|
||||
if(!is_null($lastQuest)) {
|
||||
$lastQuest['questgroup'] = $this->Questgroups->getQuestgroupById($lastQuest['questgroup_id']);
|
||||
}
|
||||
|
||||
// Get last achieved Achievement
|
||||
$achievements = $this->Achievements->getAchievedAchievementsForCharacter($character['id'], false);
|
||||
$lastAchievement = array_shift($achievements);
|
||||
|
||||
// Get Character group members
|
||||
$characterGroups = array();
|
||||
foreach($this->Charactergroups->getGroupsForCharacter($character['id']) as $group)
|
||||
{
|
||||
$groupsgroup = $this->Charactergroups->getGroupsgroupById($group['charactergroupsgroup_id']);
|
||||
if($groupsgroup['preferred'])
|
||||
{
|
||||
$group['members'] = $this->Characters->getCharactersForGroup($group['id']);
|
||||
$characterGroups[] = $group;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Pass data to view
|
||||
$this->set('seminary', $seminary);
|
||||
$this->set('character', $character);
|
||||
$this->set('lastQuest', $lastQuest);
|
||||
$this->set('lastAchievement', $lastAchievement);
|
||||
$this->set('characterGroups', $characterGroups);
|
||||
// Render now
|
||||
$this->set('render', true);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
|
|||
|
|
@ -1,53 +1,53 @@
|
|||
<?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 with Seminary related
|
||||
* links.
|
||||
*
|
||||
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
||||
*/
|
||||
class SeminarymenuController 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', \hhu\z\controllers\IntermediateController::$user);
|
||||
$this->set('loggedSeminary', \hhu\z\controllers\SeminaryController::$seminary);
|
||||
$this->set('loggedCharacter', \hhu\z\controllers\SeminaryController::$character);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 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 with Seminary related
|
||||
* links.
|
||||
*
|
||||
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
||||
*/
|
||||
class SeminarymenuController 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', \hhu\z\controllers\IntermediateController::$user);
|
||||
$this->set('loggedSeminary', \hhu\z\controllers\SeminaryController::$seminary);
|
||||
$this->set('loggedCharacter', \hhu\z\controllers\SeminaryController::$character);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Action: index.
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
|
|||
|
|
@ -1,55 +1,55 @@
|
|||
<?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 TextmailAgent for generating a simple text-mail
|
||||
* message.
|
||||
*
|
||||
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
||||
*/
|
||||
class TextmailController 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 simple text-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 TextmailAgent for generating a simple text-mail
|
||||
* message.
|
||||
*
|
||||
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
||||
*/
|
||||
class TextmailController 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 simple text-mail message.
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
$this->set('appname', \nre\configs\AppConfig::$app['name']);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
|
|||
|
|
@ -1,318 +1,318 @@
|
|||
<?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 UploadsAgent to process and show user uploads.
|
||||
*
|
||||
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
||||
*/
|
||||
class UploadsController extends \hhu\z\controllers\SeminaryController
|
||||
{
|
||||
/**
|
||||
* Required models
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $models = array('uploads', 'users', 'userroles', 'characterroles', 'seminaries', 'charactergroups');
|
||||
/**
|
||||
* User permissions
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $permissions = array(
|
||||
'seminary' => array('admin', 'moderator', 'user', 'guest'),
|
||||
'charactergroup' => array('admin', 'moderator', 'user', 'guest')
|
||||
);
|
||||
/**
|
||||
* User seminary permissions
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $seminaryPermissions = array(
|
||||
'seminary' => array('admin', 'moderator', 'user', 'guest'),
|
||||
'charactergroup' => array('admin', 'moderator', 'user')
|
||||
);
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 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 headers for caching control
|
||||
$response->addHeader("Pragma: public");
|
||||
$response->addHeader("Cache-control: public, max-age=".(60*60*24));
|
||||
$response->addHeader("Expires: ".gmdate('r', time()+(60*60*24)));
|
||||
$response->addHeader("Date: ".gmdate(\DateTime::RFC822));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Action: seminary.
|
||||
*
|
||||
* Display a Seminary upload.
|
||||
*
|
||||
* @throws \nre\exceptions\AccessDeniedException
|
||||
* @throws \nre\exceptions\IdNotFoundException
|
||||
* @param string $seminaryUrl URL-title of Seminary
|
||||
* @param string $uploadUrl URL-name of the upload
|
||||
* @param string $action Current action (optional)
|
||||
*/
|
||||
public function seminary($seminaryUrl, $uploadUrl, $action=null)
|
||||
{
|
||||
// Get Seminary
|
||||
$seminary = $this->Seminaries->getSeminaryByUrl($seminaryUrl);
|
||||
|
||||
// Get Upload
|
||||
$upload = $this->Uploads->getSeminaryuploadByUrl($seminary['id'], $uploadUrl);
|
||||
|
||||
// Check permissions
|
||||
if(!$upload['public'])
|
||||
{
|
||||
$user = $this->Users->getUserById($this->Auth->getUserId());
|
||||
$user['roles'] = array_map(function($r) { return $r['name']; }, $this->Userroles->getUserrolesForUserById($user['id']));
|
||||
|
||||
// System roles
|
||||
if(count(array_intersect(array('admin', 'moderator'), $user['roles'])) == 0)
|
||||
{
|
||||
// Owner of file
|
||||
if($upload['created_user_id'] != $user['id'])
|
||||
{
|
||||
// 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();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Get file
|
||||
switch($action)
|
||||
{
|
||||
case null:
|
||||
$file = $this->getUploadFile($upload);
|
||||
break;
|
||||
case 'thumbnail':
|
||||
$file = $this->createThumbnail($upload);
|
||||
break;
|
||||
default:
|
||||
throw new \nre\exceptions\ParamsNotValidException($action);
|
||||
break;
|
||||
}
|
||||
if(is_null($file)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
// Pass data to view
|
||||
$this->set('upload', $upload);
|
||||
$this->set('file', $file);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Action: charactergroup.
|
||||
*
|
||||
* Display the icon of a Character group.
|
||||
*
|
||||
* @throws \nre\exceptions\IdNotFoundException
|
||||
* @param string $seminaryUrl URL-Title of a Seminary
|
||||
* @param string $groupsgroupUrl URL-Title of a Character groups-group
|
||||
* @param string $groupUrl URL-Title of a Character group
|
||||
*/
|
||||
public function charactergroup($seminaryUrl, $groupsgroupUrl, $groupUrl)
|
||||
{
|
||||
// Get seminary
|
||||
$seminary = $this->Seminaries->getSeminaryByUrl($seminaryUrl);
|
||||
|
||||
// Get Character groups-group
|
||||
$groupsgroup = $this->Charactergroups->getGroupsgroupByUrl($seminary['id'], $groupsgroupUrl);
|
||||
|
||||
// Get Character group
|
||||
$group = $this->Charactergroups->getGroupByUrl($groupsgroup['id'], $groupUrl);
|
||||
|
||||
// Get Upload
|
||||
$upload = $this->Uploads->getSeminaryuploadById($group['seminaryupload_id']);
|
||||
|
||||
// Get file
|
||||
$file = $this->getUploadFile($upload);
|
||||
if(is_null($file)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
// Pass data to view
|
||||
$this->set('upload', $upload);
|
||||
$this->set('file', $file);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Determine the file for an upload.
|
||||
*
|
||||
* @throws \nre\exceptions\IdNotFoundException
|
||||
* @param array $upload Upload to get file for
|
||||
* @return object File for the upload (or null if upload is cached)
|
||||
*/
|
||||
private function getUploadFile($upload)
|
||||
{
|
||||
// Set content-type
|
||||
$this->response->addHeader("Content-type: ".$upload['mimetype']."");
|
||||
|
||||
// Set filename
|
||||
$upload['filename'] = ROOT.DS.\nre\configs\AppConfig::$dirs['seminaryuploads'].DS.$upload['url'];
|
||||
if(!file_exists($upload['filename'])) {
|
||||
throw new \nre\exceptions\IdNotFoundException($uploadUrl);
|
||||
}
|
||||
|
||||
// Cache
|
||||
if($this->setCacheHeaders($upload['filename'])) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
return file_get_contents($upload['filename']);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Create a thumbnail from an upload.
|
||||
*
|
||||
* @param array $upload Upload to create thumbnail for
|
||||
* @return object Thumbnail for the upload (or null if thumbnail is cached)
|
||||
*/
|
||||
private function createThumbnail($upload)
|
||||
{
|
||||
// Set filename
|
||||
$upload['filename'] = ROOT.DS.\nre\configs\AppConfig::$dirs['seminaryuploads'].DS.$upload['url'];
|
||||
|
||||
// Set content-type
|
||||
$this->response->addHeader("Content-type: image/jpeg");
|
||||
/**
|
||||
* 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 file
|
||||
if(!file_exists($upload['filename'])) {
|
||||
throw new \nre\exceptions\IdNotFoundException($upload['url']);
|
||||
}
|
||||
|
||||
// Cache
|
||||
if($this->setCacheHeaders($upload['filename'])) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// Set geometry
|
||||
$width = 100;
|
||||
$height = 100;
|
||||
|
||||
switch($upload['mimetype'])
|
||||
{
|
||||
case 'image/jpeg':
|
||||
case 'image/png':
|
||||
// Read image from cache
|
||||
$tempFileName = ROOT.DS.\nre\configs\AppConfig::$dirs['temporary'].DS.$upload['url'].'-'.$width.'x'.$height;
|
||||
if(file_exists($tempFileName))
|
||||
{
|
||||
// Check age of file
|
||||
if(date('r', filemtime($tempFileName)+(60*60*24)) > date('r', time())) {
|
||||
// Too old, delete
|
||||
unlink($tempFileName);
|
||||
}
|
||||
else {
|
||||
// Valid, read and return
|
||||
return file_get_contents($tempFileName);
|
||||
}
|
||||
}
|
||||
|
||||
// ImageMagick
|
||||
$im = new \Imagick($upload['filename']);
|
||||
|
||||
// Calculate new size
|
||||
$geometry = $im->getImageGeometry();
|
||||
if($geometry['width'] < $width) {
|
||||
$width = $geometry['width'];
|
||||
}
|
||||
if($geometry['height'] < $height) {
|
||||
$height = $geometry['width'];
|
||||
}
|
||||
|
||||
// Process
|
||||
$im->thumbnailImage($width, $height, true);
|
||||
$im->contrastImage(1);
|
||||
$im->setImageFormat('jpeg');
|
||||
|
||||
// Save temporary file
|
||||
$im->writeImage($tempFileName);
|
||||
|
||||
|
||||
// Return resized image
|
||||
return $im;
|
||||
break;
|
||||
default:
|
||||
throw new \nre\exceptions\ParamsNotValidException('thumbnail');
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
return $this->getUploadFile($upload);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Determine file information and set the HTTP-header for
|
||||
* caching accordingly.
|
||||
*
|
||||
* @param string $fileName Filename
|
||||
* @return boolean HTTP-status 304 was set (in cache)
|
||||
*/
|
||||
private function setCacheHeaders($fileName)
|
||||
{
|
||||
// Determine last change of file
|
||||
$fileLastModified = gmdate('r', filemtime($fileName));
|
||||
|
||||
// Generate E-Tag
|
||||
$fileEtag = hash('sha256', $fileLastModified.$fileName);
|
||||
|
||||
|
||||
// Set header
|
||||
$this->response->addHeader("Last-Modified: ".$fileLastModified);
|
||||
$this->response->addHeader("Etag: ".$fileEtag);
|
||||
// HTTP-status
|
||||
$headerModifiedSince = $this->request->getServerParam('HTTP_IF_MODIFIED_SINCE');
|
||||
$headerNoneMatch = $this->request->getServerParam('HTTP_IF_NONE_MATCH');
|
||||
if(
|
||||
!is_null($headerModifiedSince) && $fileLastModified < strtotime($headerModifiedSince) &&
|
||||
!is_null($headerNoneMatch) && $headerNoneMatch == $fileEtag
|
||||
) {
|
||||
$this->response->setExit(true);
|
||||
$this->response->addHeader(\nre\core\WebUtils::getHttpHeader(304));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
namespace hhu\z\controllers;
|
||||
|
||||
|
||||
/**
|
||||
* Controller of the UploadsAgent to process and show user uploads.
|
||||
*
|
||||
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
||||
*/
|
||||
class UploadsController extends \hhu\z\controllers\SeminaryController
|
||||
{
|
||||
/**
|
||||
* Required models
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $models = array('uploads', 'users', 'userroles', 'characterroles', 'seminaries', 'charactergroups');
|
||||
/**
|
||||
* User permissions
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $permissions = array(
|
||||
'seminary' => array('admin', 'moderator', 'user', 'guest'),
|
||||
'charactergroup' => array('admin', 'moderator', 'user', 'guest')
|
||||
);
|
||||
/**
|
||||
* User seminary permissions
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $seminaryPermissions = array(
|
||||
'seminary' => array('admin', 'moderator', 'user', 'guest'),
|
||||
'charactergroup' => array('admin', 'moderator', 'user')
|
||||
);
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 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 headers for caching control
|
||||
$response->addHeader("Pragma: public");
|
||||
$response->addHeader("Cache-control: public, max-age=".(60*60*24));
|
||||
$response->addHeader("Expires: ".gmdate('r', time()+(60*60*24)));
|
||||
$response->addHeader("Date: ".gmdate(\DateTime::RFC822));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Action: seminary.
|
||||
*
|
||||
* Display a Seminary upload.
|
||||
*
|
||||
* @throws \nre\exceptions\AccessDeniedException
|
||||
* @throws \nre\exceptions\IdNotFoundException
|
||||
* @param string $seminaryUrl URL-title of Seminary
|
||||
* @param string $uploadUrl URL-name of the upload
|
||||
* @param string $action Current action (optional)
|
||||
*/
|
||||
public function seminary($seminaryUrl, $uploadUrl, $action=null)
|
||||
{
|
||||
// Get Seminary
|
||||
$seminary = $this->Seminaries->getSeminaryByUrl($seminaryUrl);
|
||||
|
||||
// Get Upload
|
||||
$upload = $this->Uploads->getSeminaryuploadByUrl($seminary['id'], $uploadUrl);
|
||||
|
||||
// Check permissions
|
||||
if(!$upload['public'])
|
||||
{
|
||||
$user = $this->Users->getUserById($this->Auth->getUserId());
|
||||
$user['roles'] = array_map(function($r) { return $r['name']; }, $this->Userroles->getUserrolesForUserById($user['id']));
|
||||
|
||||
// System roles
|
||||
if(count(array_intersect(array('admin', 'moderator'), $user['roles'])) == 0)
|
||||
{
|
||||
// Owner of file
|
||||
if($upload['created_user_id'] != $user['id'])
|
||||
{
|
||||
// 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();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Get file
|
||||
switch($action)
|
||||
{
|
||||
case null:
|
||||
$file = $this->getUploadFile($upload);
|
||||
break;
|
||||
case 'thumbnail':
|
||||
$file = $this->createThumbnail($upload);
|
||||
break;
|
||||
default:
|
||||
throw new \nre\exceptions\ParamsNotValidException($action);
|
||||
break;
|
||||
}
|
||||
if(is_null($file)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
// Pass data to view
|
||||
$this->set('upload', $upload);
|
||||
$this->set('file', $file);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Action: charactergroup.
|
||||
*
|
||||
* Display the icon of a Character group.
|
||||
*
|
||||
* @throws \nre\exceptions\IdNotFoundException
|
||||
* @param string $seminaryUrl URL-Title of a Seminary
|
||||
* @param string $groupsgroupUrl URL-Title of a Character groups-group
|
||||
* @param string $groupUrl URL-Title of a Character group
|
||||
*/
|
||||
public function charactergroup($seminaryUrl, $groupsgroupUrl, $groupUrl)
|
||||
{
|
||||
// Get seminary
|
||||
$seminary = $this->Seminaries->getSeminaryByUrl($seminaryUrl);
|
||||
|
||||
// Get Character groups-group
|
||||
$groupsgroup = $this->Charactergroups->getGroupsgroupByUrl($seminary['id'], $groupsgroupUrl);
|
||||
|
||||
// Get Character group
|
||||
$group = $this->Charactergroups->getGroupByUrl($groupsgroup['id'], $groupUrl);
|
||||
|
||||
// Get Upload
|
||||
$upload = $this->Uploads->getSeminaryuploadById($group['seminaryupload_id']);
|
||||
|
||||
// Get file
|
||||
$file = $this->getUploadFile($upload);
|
||||
if(is_null($file)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
// Pass data to view
|
||||
$this->set('upload', $upload);
|
||||
$this->set('file', $file);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Determine the file for an upload.
|
||||
*
|
||||
* @throws \nre\exceptions\IdNotFoundException
|
||||
* @param array $upload Upload to get file for
|
||||
* @return object File for the upload (or null if upload is cached)
|
||||
*/
|
||||
private function getUploadFile($upload)
|
||||
{
|
||||
// Set content-type
|
||||
$this->response->addHeader("Content-type: ".$upload['mimetype']."");
|
||||
|
||||
// Set filename
|
||||
$upload['filename'] = ROOT.DS.\nre\configs\AppConfig::$dirs['seminaryuploads'].DS.$upload['url'];
|
||||
if(!file_exists($upload['filename'])) {
|
||||
throw new \nre\exceptions\IdNotFoundException($uploadUrl);
|
||||
}
|
||||
|
||||
// Cache
|
||||
if($this->setCacheHeaders($upload['filename'])) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
return file_get_contents($upload['filename']);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Create a thumbnail from an upload.
|
||||
*
|
||||
* @param array $upload Upload to create thumbnail for
|
||||
* @return object Thumbnail for the upload (or null if thumbnail is cached)
|
||||
*/
|
||||
private function createThumbnail($upload)
|
||||
{
|
||||
// Set filename
|
||||
$upload['filename'] = ROOT.DS.\nre\configs\AppConfig::$dirs['seminaryuploads'].DS.$upload['url'];
|
||||
|
||||
// Set content-type
|
||||
$this->response->addHeader("Content-type: image/jpeg");
|
||||
|
||||
// Check file
|
||||
if(!file_exists($upload['filename'])) {
|
||||
throw new \nre\exceptions\IdNotFoundException($upload['url']);
|
||||
}
|
||||
|
||||
// Cache
|
||||
if($this->setCacheHeaders($upload['filename'])) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// Set geometry
|
||||
$width = 100;
|
||||
$height = 100;
|
||||
|
||||
switch($upload['mimetype'])
|
||||
{
|
||||
case 'image/jpeg':
|
||||
case 'image/png':
|
||||
// Read image from cache
|
||||
$tempFileName = ROOT.DS.\nre\configs\AppConfig::$dirs['temporary'].DS.$upload['url'].'-'.$width.'x'.$height;
|
||||
if(file_exists($tempFileName))
|
||||
{
|
||||
// Check age of file
|
||||
if(date('r', filemtime($tempFileName)+(60*60*24)) > date('r', time())) {
|
||||
// Too old, delete
|
||||
unlink($tempFileName);
|
||||
}
|
||||
else {
|
||||
// Valid, read and return
|
||||
return file_get_contents($tempFileName);
|
||||
}
|
||||
}
|
||||
|
||||
// ImageMagick
|
||||
$im = new \Imagick($upload['filename']);
|
||||
|
||||
// Calculate new size
|
||||
$geometry = $im->getImageGeometry();
|
||||
if($geometry['width'] < $width) {
|
||||
$width = $geometry['width'];
|
||||
}
|
||||
if($geometry['height'] < $height) {
|
||||
$height = $geometry['width'];
|
||||
}
|
||||
|
||||
// Process
|
||||
$im->thumbnailImage($width, $height, true);
|
||||
$im->contrastImage(1);
|
||||
$im->setImageFormat('jpeg');
|
||||
|
||||
// Save temporary file
|
||||
$im->writeImage($tempFileName);
|
||||
|
||||
|
||||
// Return resized image
|
||||
return $im;
|
||||
break;
|
||||
default:
|
||||
throw new \nre\exceptions\ParamsNotValidException('thumbnail');
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
return $this->getUploadFile($upload);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Determine file information and set the HTTP-header for
|
||||
* caching accordingly.
|
||||
*
|
||||
* @param string $fileName Filename
|
||||
* @return boolean HTTP-status 304 was set (in cache)
|
||||
*/
|
||||
private function setCacheHeaders($fileName)
|
||||
{
|
||||
// Determine last change of file
|
||||
$fileLastModified = gmdate('r', filemtime($fileName));
|
||||
|
||||
// Generate E-Tag
|
||||
$fileEtag = hash('sha256', $fileLastModified.$fileName);
|
||||
|
||||
|
||||
// Set header
|
||||
$this->response->addHeader("Last-Modified: ".$fileLastModified);
|
||||
$this->response->addHeader("Etag: ".$fileEtag);
|
||||
// HTTP-status
|
||||
$headerModifiedSince = $this->request->getServerParam('HTTP_IF_MODIFIED_SINCE');
|
||||
$headerNoneMatch = $this->request->getServerParam('HTTP_IF_NONE_MATCH');
|
||||
if(
|
||||
!is_null($headerModifiedSince) && $fileLastModified < strtotime($headerModifiedSince) &&
|
||||
!is_null($headerNoneMatch) && $headerNoneMatch == $fileEtag
|
||||
) {
|
||||
$this->response->setExit(true);
|
||||
$this->response->addHeader(\nre\core\WebUtils::getHttpHeader(304));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
|
|||
|
|
@ -1,47 +1,47 @@
|
|||
<?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 and manage userroles.
|
||||
*
|
||||
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
||||
*/
|
||||
class UserrolesController extends \hhu\z\Controller
|
||||
{
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Action: user.
|
||||
*
|
||||
* Show a user and its details.
|
||||
*
|
||||
* @throws \nre\exceptions\IdNotFoundException
|
||||
* @param string $userUrl URL-Username of an user
|
||||
*/
|
||||
public function user($userUrl)
|
||||
{
|
||||
// Get userroles
|
||||
$roles = $this->Userroles->getUserrolesForUserByUrl($userUrl);
|
||||
|
||||
|
||||
// Pass data to view
|
||||
$this->set('roles', $roles);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
/**
|
||||
* 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 and manage userroles.
|
||||
*
|
||||
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
||||
*/
|
||||
class UserrolesController extends \hhu\z\Controller
|
||||
{
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Action: user.
|
||||
*
|
||||
* Show a user and its details.
|
||||
*
|
||||
* @throws \nre\exceptions\IdNotFoundException
|
||||
* @param string $userUrl URL-Username of an user
|
||||
*/
|
||||
public function user($userUrl)
|
||||
{
|
||||
// Get userroles
|
||||
$roles = $this->Userroles->getUserrolesForUserByUrl($userUrl);
|
||||
|
||||
|
||||
// Pass data to view
|
||||
$this->set('roles', $roles);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
|
|
@ -1,188 +1,188 @@
|
|||
<?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 XplevelsAgent to handle XP-levels of a
|
||||
* Seminary.
|
||||
*
|
||||
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
||||
*/
|
||||
class XplevelsController extends \hhu\z\controllers\SeminaryController
|
||||
{
|
||||
/**
|
||||
* Required components
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $components = array('validation');
|
||||
/**
|
||||
* Required models
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $models = array('xplevels');
|
||||
/**
|
||||
* User permissions
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $permissions = array(
|
||||
'manage' => array('admin', 'moderator', 'user')
|
||||
);
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Action: manage.
|
||||
*
|
||||
* Manage XP-levels.
|
||||
*
|
||||
* @throws \nre\exceptions\IdNotFoundException
|
||||
* @param string $seminaryUrl URL-Title of a Seminary
|
||||
*/
|
||||
public function manage($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 XP-levels
|
||||
$xplevels = $this->Xplevels->getXPLevelsForSeminary($seminary['id']);
|
||||
|
||||
// Values
|
||||
$xplevelsValues = array();
|
||||
foreach($xplevels as &$xplevel) {
|
||||
$xplevelsValues[$xplevel['id']] = $xplevel;
|
||||
}
|
||||
$deletes = array();
|
||||
$validations = array(
|
||||
'edit' => true,
|
||||
'create' => true
|
||||
);
|
||||
|
||||
// Edit
|
||||
$action = null;
|
||||
if($this->request->getRequestMethod() == 'POST')
|
||||
{
|
||||
// Edit and delete XP-levels
|
||||
if(!is_null($this->request->getPostParam('edit')))
|
||||
{
|
||||
$action = 'edit';
|
||||
/**
|
||||
* 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 XplevelsAgent to handle XP-levels of a
|
||||
* Seminary.
|
||||
*
|
||||
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
||||
*/
|
||||
class XplevelsController extends \hhu\z\controllers\SeminaryController
|
||||
{
|
||||
/**
|
||||
* Required components
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $components = array('validation');
|
||||
/**
|
||||
* Required models
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $models = array('xplevels');
|
||||
/**
|
||||
* User permissions
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $permissions = array(
|
||||
'manage' => array('admin', 'moderator', 'user')
|
||||
);
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Action: manage.
|
||||
*
|
||||
* Manage XP-levels.
|
||||
*
|
||||
* @throws \nre\exceptions\IdNotFoundException
|
||||
* @param string $seminaryUrl URL-Title of a Seminary
|
||||
*/
|
||||
public function manage($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 XP-levels
|
||||
$xplevels = $this->Xplevels->getXPLevelsForSeminary($seminary['id']);
|
||||
|
||||
// Values
|
||||
$xplevelsValues = array();
|
||||
foreach($xplevels as &$xplevel) {
|
||||
$xplevelsValues[$xplevel['id']] = $xplevel;
|
||||
}
|
||||
$deletes = array();
|
||||
$validations = array(
|
||||
'edit' => true,
|
||||
'create' => true
|
||||
);
|
||||
|
||||
// Edit
|
||||
$action = null;
|
||||
if($this->request->getRequestMethod() == 'POST')
|
||||
{
|
||||
// Edit and delete XP-levels
|
||||
if(!is_null($this->request->getPostParam('edit')))
|
||||
{
|
||||
$action = 'edit';
|
||||
|
||||
// Get params
|
||||
$xplevelsValues = $this->request->getPostParam('xplevels');
|
||||
$deletes = $this->request->getPostParam('deletes');
|
||||
|
||||
// Validate params
|
||||
if(!is_array($deletes)) {
|
||||
$deletes = array();
|
||||
}
|
||||
foreach($xplevels as &$xplevel)
|
||||
{
|
||||
if(array_key_exists($xplevel['id'], $deletes)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$xplevelValidation = $this->Validation->validateParams($xplevelsValues[$xplevel['id']], array('xps'));
|
||||
if($xplevelValidation !== true)
|
||||
{
|
||||
if(!is_array($validations['edit'])) {
|
||||
$validations['edit'] = array();
|
||||
}
|
||||
if(!array_key_exists($xplevel['id'], $validations['edit']) || !is_array($validations['edit'][$xplevel['id']])) {
|
||||
$validations['edit'][$xplevel['id']] = array();
|
||||
}
|
||||
$validations['edit'][$xplevel['id']] = $this->Validation->addValidationResults($validations['edit'][$xplevel['id']], 'xps', $xplevelValidation);
|
||||
}
|
||||
}
|
||||
|
||||
// Edit and delete
|
||||
if($validations['edit'] === true)
|
||||
{
|
||||
foreach($xplevels as &$xplevel)
|
||||
{
|
||||
// Delete
|
||||
if(array_key_exists($xplevel['id'], $deletes)) {
|
||||
$this->Xplevels->deleteXPLevel($xplevel);
|
||||
}
|
||||
// Edit
|
||||
elseif(array_key_exists($xplevel['id'], $xplevelsValues))
|
||||
{
|
||||
$this->Xplevels->editXPLevel(
|
||||
$xplevel['id'],
|
||||
$xplevelsValues[$xplevel['id']]['xps']
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// Redirect
|
||||
$this->redirect($this->linker->link(null, 3));
|
||||
}
|
||||
}
|
||||
|
||||
// Create XP-level
|
||||
if(!is_null($this->request->getPostParam('create')))
|
||||
{
|
||||
$action = 'create';
|
||||
|
||||
// Get params and validate them
|
||||
$xplevelnew = $this->request->getPostParam('xplevelnew');
|
||||
$validations[$action] = $this->Validation->validateParams($xplevelnew, array('xps'));
|
||||
|
||||
// Create
|
||||
if($validations[$action] === true)
|
||||
{
|
||||
$this->Xplevels->createXPLevel(
|
||||
$this->Auth->getUserId(),
|
||||
$seminary['id'],
|
||||
$xplevelnew['xps']
|
||||
);
|
||||
|
||||
// Redirect
|
||||
$this->redirect($this->linker->link(null, 3));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Get validation settings
|
||||
$validationSettings = array(
|
||||
'xps' => \nre\configs\AppConfig::$validation['xps']
|
||||
);
|
||||
|
||||
|
||||
// Set titile
|
||||
$this->addTitleLocalized('Manage XP-levels');
|
||||
$this->addTitle($seminary['title']);
|
||||
|
||||
// Pass data to view
|
||||
$this->set('seminary', $seminary);
|
||||
$this->set('xplevels', $xplevels);
|
||||
$this->set('xplevelsValues', $xplevelsValues);
|
||||
$this->set('deletes', $deletes);
|
||||
$this->set('action', $action);
|
||||
$this->set('validations', $validations);
|
||||
$this->set('validationSettings', $validationSettings);
|
||||
}
|
||||
|
||||
}
|
||||
// Validate params
|
||||
if(!is_array($deletes)) {
|
||||
$deletes = array();
|
||||
}
|
||||
foreach($xplevels as &$xplevel)
|
||||
{
|
||||
if(array_key_exists($xplevel['id'], $deletes)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$xplevelValidation = $this->Validation->validateParams($xplevelsValues[$xplevel['id']], array('xps'));
|
||||
if($xplevelValidation !== true)
|
||||
{
|
||||
if(!is_array($validations['edit'])) {
|
||||
$validations['edit'] = array();
|
||||
}
|
||||
if(!array_key_exists($xplevel['id'], $validations['edit']) || !is_array($validations['edit'][$xplevel['id']])) {
|
||||
$validations['edit'][$xplevel['id']] = array();
|
||||
}
|
||||
$validations['edit'][$xplevel['id']] = $this->Validation->addValidationResults($validations['edit'][$xplevel['id']], 'xps', $xplevelValidation);
|
||||
}
|
||||
}
|
||||
|
||||
// Edit and delete
|
||||
if($validations['edit'] === true)
|
||||
{
|
||||
foreach($xplevels as &$xplevel)
|
||||
{
|
||||
// Delete
|
||||
if(array_key_exists($xplevel['id'], $deletes)) {
|
||||
$this->Xplevels->deleteXPLevel($xplevel);
|
||||
}
|
||||
// Edit
|
||||
elseif(array_key_exists($xplevel['id'], $xplevelsValues))
|
||||
{
|
||||
$this->Xplevels->editXPLevel(
|
||||
$xplevel['id'],
|
||||
$xplevelsValues[$xplevel['id']]['xps']
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// Redirect
|
||||
$this->redirect($this->linker->link(null, 3));
|
||||
}
|
||||
}
|
||||
|
||||
// Create XP-level
|
||||
if(!is_null($this->request->getPostParam('create')))
|
||||
{
|
||||
$action = 'create';
|
||||
|
||||
// Get params and validate them
|
||||
$xplevelnew = $this->request->getPostParam('xplevelnew');
|
||||
$validations[$action] = $this->Validation->validateParams($xplevelnew, array('xps'));
|
||||
|
||||
// Create
|
||||
if($validations[$action] === true)
|
||||
{
|
||||
$this->Xplevels->createXPLevel(
|
||||
$this->Auth->getUserId(),
|
||||
$seminary['id'],
|
||||
$xplevelnew['xps']
|
||||
);
|
||||
|
||||
// Redirect
|
||||
$this->redirect($this->linker->link(null, 3));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Get validation settings
|
||||
$validationSettings = array(
|
||||
'xps' => \nre\configs\AppConfig::$validation['xps']
|
||||
);
|
||||
|
||||
|
||||
// Set titile
|
||||
$this->addTitleLocalized('Manage XP-levels');
|
||||
$this->addTitle($seminary['title']);
|
||||
|
||||
// Pass data to view
|
||||
$this->set('seminary', $seminary);
|
||||
$this->set('xplevels', $xplevels);
|
||||
$this->set('xplevelsValues', $xplevelsValues);
|
||||
$this->set('deletes', $deletes);
|
||||
$this->set('action', $action);
|
||||
$this->set('validations', $validations);
|
||||
$this->set('validationSettings', $validationSettings);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
|
|||
|
|
@ -1,41 +1,41 @@
|
|||
<?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\components;
|
||||
|
||||
|
||||
/**
|
||||
* Component to handle achievements.
|
||||
*
|
||||
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
||||
*/
|
||||
class AchievementComponent extends \nre\core\Component
|
||||
{
|
||||
/**
|
||||
* Required models
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $models = array('achievements');
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Construct a new Achievements-component.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
}
|
||||
|
||||
}
|
||||
/**
|
||||
* 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\components;
|
||||
|
||||
|
||||
/**
|
||||
* Component to handle achievements.
|
||||
*
|
||||
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
||||
*/
|
||||
class AchievementComponent extends \nre\core\Component
|
||||
{
|
||||
/**
|
||||
* Required models
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $models = array('achievements');
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Construct a new Achievements-component.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
|
|||
|
|
@ -1,79 +1,79 @@
|
|||
<?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\components;
|
||||
|
||||
|
||||
/**
|
||||
* Component to handle authentication and authorization.
|
||||
*
|
||||
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
||||
*/
|
||||
class AuthComponent extends \nre\core\Component
|
||||
{
|
||||
/**
|
||||
* Key to save a user-ID as
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
const KEY_USER_ID = 'user_id';
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Construct a new Auth-component.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
// Start session
|
||||
if(session_id() === '') {
|
||||
session_start();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Set the ID of the user that is currently logged in.
|
||||
*
|
||||
* @param int $userId ID of the currently logged in user
|
||||
*/
|
||||
public function setUserId($userId)
|
||||
{
|
||||
if(is_null($userId)) {
|
||||
unset($_SESSION[self::KEY_USER_ID]);
|
||||
}
|
||||
else {
|
||||
$_SESSION[self::KEY_USER_ID] = $userId;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the ID of the user that is currently logged in.
|
||||
*
|
||||
* @return int ID of the currently logged in user
|
||||
*/
|
||||
public function getUserId()
|
||||
{
|
||||
if(array_key_exists(self::KEY_USER_ID, $_SESSION)) {
|
||||
return $_SESSION[self::KEY_USER_ID];
|
||||
}
|
||||
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
/**
|
||||
* 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\components;
|
||||
|
||||
|
||||
/**
|
||||
* Component to handle authentication and authorization.
|
||||
*
|
||||
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
||||
*/
|
||||
class AuthComponent extends \nre\core\Component
|
||||
{
|
||||
/**
|
||||
* Key to save a user-ID as
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
const KEY_USER_ID = 'user_id';
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Construct a new Auth-component.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
// Start session
|
||||
if(session_id() === '') {
|
||||
session_start();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Set the ID of the user that is currently logged in.
|
||||
*
|
||||
* @param int $userId ID of the currently logged in user
|
||||
*/
|
||||
public function setUserId($userId)
|
||||
{
|
||||
if(is_null($userId)) {
|
||||
unset($_SESSION[self::KEY_USER_ID]);
|
||||
}
|
||||
else {
|
||||
$_SESSION[self::KEY_USER_ID] = $userId;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the ID of the user that is currently logged in.
|
||||
*
|
||||
* @return int ID of the currently logged in user
|
||||
*/
|
||||
public function getUserId()
|
||||
{
|
||||
if(array_key_exists(self::KEY_USER_ID, $_SESSION)) {
|
||||
return $_SESSION[self::KEY_USER_ID];
|
||||
}
|
||||
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
|
|||
|
|
@ -1,108 +1,108 @@
|
|||
<?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\components;
|
||||
|
||||
|
||||
/**
|
||||
* Component to handle user notifications
|
||||
*
|
||||
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
||||
*/
|
||||
class NotificationComponent extends \nre\core\Component
|
||||
{
|
||||
/**
|
||||
* Type: Achievement
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
const TYPE_ACHIEVEMENT = 'achievement';
|
||||
/**
|
||||
* Type: Level-up
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
const TYPE_LEVELUP = 'levelup';
|
||||
/**
|
||||
* Key for Session-Array to store notifications in
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
const SESSION_KEY = 'notifications';
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Construct a new Notification-component.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
// Start session
|
||||
if(session_id() === '') {
|
||||
session_start();
|
||||
}
|
||||
|
||||
// Prepare array
|
||||
if(!array_key_exists(self::SESSION_KEY, $_SESSION)) {
|
||||
$_SESSION[self::SESSION_KEY] = array();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Add a notification.
|
||||
*
|
||||
* @param string $type Type of notification
|
||||
* @param string $message Message to display
|
||||
* @param string $link Optional URL to link to
|
||||
* @param string $image Optional URL of image to display
|
||||
*/
|
||||
public function addNotification($type, $message, $link=null, $image=null)
|
||||
{
|
||||
$_SESSION[self::SESSION_KEY][] = array(
|
||||
'type' => $type,
|
||||
'message' => $message,
|
||||
'link' => $link,
|
||||
'image' => $image
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get all registered notifiactions and clear them.
|
||||
*
|
||||
* @return array List of existing notifications
|
||||
*/
|
||||
public function getNotifications()
|
||||
{
|
||||
$notifications = $_SESSION[self::SESSION_KEY];
|
||||
$this->clearNotifications();
|
||||
|
||||
|
||||
return $notifications;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Clear all notifications currently registered
|
||||
*/
|
||||
public function clearNotifications()
|
||||
{
|
||||
unset($_SESSION[self::SESSION_KEY]);
|
||||
$_SESSION[self::SESSION_KEY] = array();
|
||||
}
|
||||
|
||||
}
|
||||
/**
|
||||
* 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\components;
|
||||
|
||||
|
||||
/**
|
||||
* Component to handle user notifications
|
||||
*
|
||||
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
||||
*/
|
||||
class NotificationComponent extends \nre\core\Component
|
||||
{
|
||||
/**
|
||||
* Type: Achievement
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
const TYPE_ACHIEVEMENT = 'achievement';
|
||||
/**
|
||||
* Type: Level-up
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
const TYPE_LEVELUP = 'levelup';
|
||||
/**
|
||||
* Key for Session-Array to store notifications in
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
const SESSION_KEY = 'notifications';
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Construct a new Notification-component.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
// Start session
|
||||
if(session_id() === '') {
|
||||
session_start();
|
||||
}
|
||||
|
||||
// Prepare array
|
||||
if(!array_key_exists(self::SESSION_KEY, $_SESSION)) {
|
||||
$_SESSION[self::SESSION_KEY] = array();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Add a notification.
|
||||
*
|
||||
* @param string $type Type of notification
|
||||
* @param string $message Message to display
|
||||
* @param string $link Optional URL to link to
|
||||
* @param string $image Optional URL of image to display
|
||||
*/
|
||||
public function addNotification($type, $message, $link=null, $image=null)
|
||||
{
|
||||
$_SESSION[self::SESSION_KEY][] = array(
|
||||
'type' => $type,
|
||||
'message' => $message,
|
||||
'link' => $link,
|
||||
'image' => $image
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get all registered notifiactions and clear them.
|
||||
*
|
||||
* @return array List of existing notifications
|
||||
*/
|
||||
public function getNotifications()
|
||||
{
|
||||
$notifications = $_SESSION[self::SESSION_KEY];
|
||||
$this->clearNotifications();
|
||||
|
||||
|
||||
return $notifications;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Clear all notifications currently registered
|
||||
*/
|
||||
public function clearNotifications()
|
||||
{
|
||||
unset($_SESSION[self::SESSION_KEY]);
|
||||
$_SESSION[self::SESSION_KEY] = array();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
|
|||
|
|
@ -3,25 +3,25 @@
|
|||
/**
|
||||
* 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
|
||||
* @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\components;
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Component to handle data for Questtypes between different Quest states.
|
||||
*
|
||||
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
||||
*
|
||||
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
||||
*/
|
||||
class QuesttypedataComponent extends \nre\core\Component
|
||||
{
|
||||
/**
|
||||
* Session key
|
||||
*
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
const SESSION_KEY = 'questtypes';
|
||||
|
|
@ -45,7 +45,7 @@
|
|||
|
||||
/**
|
||||
* Set data with a key-value pair.
|
||||
*
|
||||
*
|
||||
* @param int $questId ID of Quest to set data for
|
||||
* @param mixed $key Key
|
||||
* @param mixed $value Value
|
||||
|
|
@ -64,7 +64,7 @@
|
|||
|
||||
/**
|
||||
* Get data by a key.
|
||||
*
|
||||
*
|
||||
* @param int $questId ID of Quest to set data for
|
||||
* @param mixed $key Key
|
||||
* @return mixed Value
|
||||
|
|
@ -86,4 +86,4 @@
|
|||
|
||||
}
|
||||
|
||||
?>
|
||||
?>
|
||||
|
|
|
|||
|
|
@ -1,183 +1,183 @@
|
|||
<?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\components;
|
||||
|
||||
|
||||
/**
|
||||
* Component to validate user input.
|
||||
*
|
||||
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
||||
*/
|
||||
class ValidationComponent extends \nre\core\Component
|
||||
{
|
||||
/**
|
||||
* Validation settings
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private $config;
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Construct a new Validation-component.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
// Get validation settings from configuration
|
||||
$this->config = \nre\configs\AppConfig::$validation;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Validate an user input.
|
||||
*
|
||||
* @param mixed $input User input to validate
|
||||
* @param array $settings Validation setting
|
||||
* @return mixed True or the settings the validation fails on
|
||||
*/
|
||||
public function validate($input, $settings)
|
||||
{
|
||||
$validation = array();
|
||||
|
||||
// Min string length
|
||||
if(array_key_exists('minlength', $settings) && strlen($input) < $settings['minlength']) {
|
||||
$validation['minlength'] = $settings['minlength'];
|
||||
}
|
||||
// Max string length
|
||||
if(array_key_exists('maxlength', $settings) && strlen($input) > $settings['maxlength']) {
|
||||
$validation['maxlength'] = $settings['maxlength'];
|
||||
}
|
||||
|
||||
// Regex
|
||||
if(array_key_exists('regex', $settings) && !preg_match($settings['regex'], $input)) {
|
||||
$validation['regex'] = $settings['regex'];
|
||||
}
|
||||
|
||||
|
||||
// Return true or the failed fields
|
||||
if(empty($validation)) {
|
||||
return true;
|
||||
}
|
||||
return $validation;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Validate an user input parameter.
|
||||
*
|
||||
* @param array $params User input parameters
|
||||
* @param array $index Names of parameter to validate and to validate against
|
||||
* @return mixed True or the parameter with settings the validation failed on
|
||||
*/
|
||||
public function validateParam($params, $index)
|
||||
{
|
||||
// Check parameter
|
||||
if(!array_key_exists($index, $params)) {
|
||||
throw new \nre\exceptions\ParamsNotValidException($index);
|
||||
}
|
||||
// Check settings
|
||||
if(!array_key_exists($index, $this->config)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
// Validate parameter and return result
|
||||
return $this->validate($params[$index], $this->config[$index]);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Validate user input parameters.
|
||||
*
|
||||
* @param array $params User input parameters
|
||||
* @param array $indices Names of parameters to validate and to validate against
|
||||
* @return mixed True or the parameters with settings the validation failed on
|
||||
*/
|
||||
public function validateParams($params, $indices)
|
||||
{
|
||||
// Validate parameters
|
||||
$validation = true;
|
||||
foreach($indices as $index) {
|
||||
$validation = $this->addValidationResults($validation, $index, $this->validateParam($params, $index));
|
||||
}
|
||||
|
||||
|
||||
// Return validation results
|
||||
return $validation;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Add a custom determined validation result to a validation
|
||||
* array.
|
||||
*
|
||||
* @param mixed $validation Validation array to add result to
|
||||
* @param string $index Name of parameter of the custom validation result
|
||||
* @param string $setting Name of setting of the custom validation result
|
||||
* @param mixed $result Validation result
|
||||
* @return mixed The altered validation array
|
||||
*/
|
||||
public function addValidationResult($validation, $index, $setting, $result)
|
||||
{
|
||||
// Create validation array
|
||||
if(!is_array($validation)) {
|
||||
$validation = array();
|
||||
}
|
||||
|
||||
// Add validation results
|
||||
if(!array_key_exists($index, $validation)) {
|
||||
$validation[$index] = array();
|
||||
}
|
||||
$validation[$index][$setting] = $result;
|
||||
|
||||
|
||||
// Return new validation result
|
||||
return $validation;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Add custom determined validation results to a validation
|
||||
* arary.
|
||||
*
|
||||
* @param mixed $validation Validation array to add result to
|
||||
* @param string $index Name of parameter of the custom validation result
|
||||
* @param mixed $result Validation result
|
||||
* @return mixed The altered validation array
|
||||
*/
|
||||
public function addValidationResults($validation, $index, $results)
|
||||
{
|
||||
// Create validation array
|
||||
if(!is_array($validation)) {
|
||||
$validation = array();
|
||||
}
|
||||
|
||||
// Add validation results
|
||||
if($results !== true) {
|
||||
$validation[$index] = $results;
|
||||
}
|
||||
|
||||
|
||||
// Return new validation result
|
||||
if(empty($validation)) {
|
||||
return true;
|
||||
}
|
||||
return $validation;
|
||||
}
|
||||
|
||||
}
|
||||
/**
|
||||
* 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\components;
|
||||
|
||||
|
||||
/**
|
||||
* Component to validate user input.
|
||||
*
|
||||
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
||||
*/
|
||||
class ValidationComponent extends \nre\core\Component
|
||||
{
|
||||
/**
|
||||
* Validation settings
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private $config;
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Construct a new Validation-component.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
// Get validation settings from configuration
|
||||
$this->config = \nre\configs\AppConfig::$validation;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Validate an user input.
|
||||
*
|
||||
* @param mixed $input User input to validate
|
||||
* @param array $settings Validation setting
|
||||
* @return mixed True or the settings the validation fails on
|
||||
*/
|
||||
public function validate($input, $settings)
|
||||
{
|
||||
$validation = array();
|
||||
|
||||
// Min string length
|
||||
if(array_key_exists('minlength', $settings) && strlen($input) < $settings['minlength']) {
|
||||
$validation['minlength'] = $settings['minlength'];
|
||||
}
|
||||
// Max string length
|
||||
if(array_key_exists('maxlength', $settings) && strlen($input) > $settings['maxlength']) {
|
||||
$validation['maxlength'] = $settings['maxlength'];
|
||||
}
|
||||
|
||||
// Regex
|
||||
if(array_key_exists('regex', $settings) && !preg_match($settings['regex'], $input)) {
|
||||
$validation['regex'] = $settings['regex'];
|
||||
}
|
||||
|
||||
|
||||
// Return true or the failed fields
|
||||
if(empty($validation)) {
|
||||
return true;
|
||||
}
|
||||
return $validation;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Validate an user input parameter.
|
||||
*
|
||||
* @param array $params User input parameters
|
||||
* @param array $index Names of parameter to validate and to validate against
|
||||
* @return mixed True or the parameter with settings the validation failed on
|
||||
*/
|
||||
public function validateParam($params, $index)
|
||||
{
|
||||
// Check parameter
|
||||
if(!array_key_exists($index, $params)) {
|
||||
throw new \nre\exceptions\ParamsNotValidException($index);
|
||||
}
|
||||
// Check settings
|
||||
if(!array_key_exists($index, $this->config)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
// Validate parameter and return result
|
||||
return $this->validate($params[$index], $this->config[$index]);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Validate user input parameters.
|
||||
*
|
||||
* @param array $params User input parameters
|
||||
* @param array $indices Names of parameters to validate and to validate against
|
||||
* @return mixed True or the parameters with settings the validation failed on
|
||||
*/
|
||||
public function validateParams($params, $indices)
|
||||
{
|
||||
// Validate parameters
|
||||
$validation = true;
|
||||
foreach($indices as $index) {
|
||||
$validation = $this->addValidationResults($validation, $index, $this->validateParam($params, $index));
|
||||
}
|
||||
|
||||
|
||||
// Return validation results
|
||||
return $validation;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Add a custom determined validation result to a validation
|
||||
* array.
|
||||
*
|
||||
* @param mixed $validation Validation array to add result to
|
||||
* @param string $index Name of parameter of the custom validation result
|
||||
* @param string $setting Name of setting of the custom validation result
|
||||
* @param mixed $result Validation result
|
||||
* @return mixed The altered validation array
|
||||
*/
|
||||
public function addValidationResult($validation, $index, $setting, $result)
|
||||
{
|
||||
// Create validation array
|
||||
if(!is_array($validation)) {
|
||||
$validation = array();
|
||||
}
|
||||
|
||||
// Add validation results
|
||||
if(!array_key_exists($index, $validation)) {
|
||||
$validation[$index] = array();
|
||||
}
|
||||
$validation[$index][$setting] = $result;
|
||||
|
||||
|
||||
// Return new validation result
|
||||
return $validation;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Add custom determined validation results to a validation
|
||||
* arary.
|
||||
*
|
||||
* @param mixed $validation Validation array to add result to
|
||||
* @param string $index Name of parameter of the custom validation result
|
||||
* @param mixed $result Validation result
|
||||
* @return mixed The altered validation array
|
||||
*/
|
||||
public function addValidationResults($validation, $index, $results)
|
||||
{
|
||||
// Create validation array
|
||||
if(!is_array($validation)) {
|
||||
$validation = array();
|
||||
}
|
||||
|
||||
// Add validation results
|
||||
if($results !== true) {
|
||||
$validation[$index] = $results;
|
||||
}
|
||||
|
||||
|
||||
// Return new validation result
|
||||
if(empty($validation)) {
|
||||
return true;
|
||||
}
|
||||
return $validation;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue