replace tabs with spaces
This commit is contained in:
parent
50c38e0efa
commit
c79f0f213b
176 changed files with 27652 additions and 27647 deletions
64
.htaccess
64
.htaccess
|
|
@ -5,40 +5,46 @@ ErrorDocument 404 /www/error404.html
|
||||||
ErrorDocument 500 /www/error500.html
|
ErrorDocument 500 /www/error500.html
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<IfModule mod_authz_core.c>
|
<IfModule mod_authz_core.c>
|
||||||
Require all granted
|
Require all granted
|
||||||
|
|
||||||
<Files ~ "\.inc$">
|
<Files ~ "\.inc$">
|
||||||
Require all denied
|
Require all denied
|
||||||
</Files>
|
</Files>
|
||||||
<Files ~ "\.tpl$">
|
|
||||||
Require all denied
|
<Files ~ "\.tpl$">
|
||||||
</Files>
|
Require all denied
|
||||||
<Files ~ "\.log$">
|
</Files>
|
||||||
Require all denied
|
|
||||||
</Files>
|
<Files ~ "\.log$">
|
||||||
|
Require all denied
|
||||||
|
</Files>
|
||||||
</IfModule>
|
</IfModule>
|
||||||
|
|
||||||
<IfModule !mod_authz_core.c>
|
<IfModule !mod_authz_core.c>
|
||||||
Allow From All
|
Allow From All
|
||||||
|
|
||||||
<Files ~ "\.inc$">
|
<Files ~ "\.inc$">
|
||||||
Order Deny,Allow
|
Order Deny,Allow
|
||||||
Deny From All
|
Deny From All
|
||||||
</Files>
|
</Files>
|
||||||
<Files ~ "\.tpl$">
|
|
||||||
Order Deny,Allow
|
<Files ~ "\.tpl$">
|
||||||
Deny From All
|
Order Deny,Allow
|
||||||
</Files>
|
Deny From All
|
||||||
<Files ~ "\.log$">
|
</Files>
|
||||||
Order Deny,Allow
|
|
||||||
Deny From All
|
<Files ~ "\.log$">
|
||||||
</Files>
|
Order Deny,Allow
|
||||||
|
Deny From All
|
||||||
|
</Files>
|
||||||
</IfModule>
|
</IfModule>
|
||||||
|
|
||||||
|
|
||||||
<IfModule mod_rewrite.c>
|
<IfModule mod_rewrite.c>
|
||||||
RewriteEngine On
|
RewriteEngine On
|
||||||
|
|
||||||
RewriteBase /
|
RewriteBase /
|
||||||
RewriteRule ^(.*)$ www/$1 [L]
|
RewriteRule ^(.*)$ www/$1 [L]
|
||||||
</IfModule>
|
</IfModule>
|
||||||
|
|
|
||||||
|
|
@ -1,38 +1,38 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Legend of Z
|
* The Legend of Z
|
||||||
*
|
*
|
||||||
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
||||||
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
|
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
|
||||||
* @license http://www.gnu.org/licenses/gpl.html
|
* @license http://www.gnu.org/licenses/gpl.html
|
||||||
* @link https://bitbucket.org/coderkun/the-legend-of-z
|
* @link https://bitbucket.org/coderkun/the-legend-of-z
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace hhu\z\agents\bottomlevel;
|
namespace hhu\z\agents\bottomlevel;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Agent to generate a mail receiver salutation.
|
* Agent to generate a mail receiver salutation.
|
||||||
*
|
*
|
||||||
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
||||||
*/
|
*/
|
||||||
class MailreceiverAgent extends \nre\agents\BottomlevelAgent
|
class MailreceiverAgent extends \nre\agents\BottomlevelAgent
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Action: index.
|
* Action: index.
|
||||||
*
|
*
|
||||||
* @param \nre\core\Request $request Current request
|
* @param \nre\core\Request $request Current request
|
||||||
* @param \nre\core\Response $response Current response
|
* @param \nre\core\Response $response Current response
|
||||||
*/
|
*/
|
||||||
public function index(\nre\core\Request $request, \nre\core\Response $response)
|
public function index(\nre\core\Request $request, \nre\core\Response $response)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
|
||||||
|
|
@ -1,40 +1,40 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Legend of Z
|
* The Legend of Z
|
||||||
*
|
*
|
||||||
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
||||||
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
|
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
|
||||||
* @license http://www.gnu.org/licenses/gpl.html
|
* @license http://www.gnu.org/licenses/gpl.html
|
||||||
* @link https://bitbucket.org/coderkun/the-legend-of-z
|
* @link https://bitbucket.org/coderkun/the-legend-of-z
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace hhu\z\agents\bottomlevel;
|
namespace hhu\z\agents\bottomlevel;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Agent to display a menu.
|
* Agent to display a menu.
|
||||||
*
|
*
|
||||||
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
||||||
*/
|
*/
|
||||||
class MenuAgent extends \nre\agents\BottomlevelAgent
|
class MenuAgent extends \nre\agents\BottomlevelAgent
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Action: index.
|
* Action: index.
|
||||||
*
|
*
|
||||||
* @param \nre\core\Request $request Current request
|
* @param \nre\core\Request $request Current request
|
||||||
* @param \nre\core\Response $response Current response
|
* @param \nre\core\Response $response Current response
|
||||||
*/
|
*/
|
||||||
public function index(\nre\core\Request $request, \nre\core\Response $response)
|
public function index(\nre\core\Request $request, \nre\core\Response $response)
|
||||||
{
|
{
|
||||||
// Add Seminary menu
|
// Add Seminary menu
|
||||||
$this->addSubAgent('Seminarymenu');
|
$this->addSubAgent('Seminarymenu');
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
|
||||||
|
|
@ -1,38 +1,38 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Legend of Z
|
* The Legend of Z
|
||||||
*
|
*
|
||||||
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
||||||
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
|
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
|
||||||
* @license http://www.gnu.org/licenses/gpl.html
|
* @license http://www.gnu.org/licenses/gpl.html
|
||||||
* @link https://bitbucket.org/coderkun/the-legend-of-z
|
* @link https://bitbucket.org/coderkun/the-legend-of-z
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace hhu\z\agents\bottomlevel;
|
namespace hhu\z\agents\bottomlevel;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Agent to display the Questgroups hierarchy path.
|
* Agent to display the Questgroups hierarchy path.
|
||||||
*
|
*
|
||||||
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
||||||
*/
|
*/
|
||||||
class QuestgroupshierarchypathAgent extends \nre\agents\BottomlevelAgent
|
class QuestgroupshierarchypathAgent extends \nre\agents\BottomlevelAgent
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Action: index.
|
* Action: index.
|
||||||
*
|
*
|
||||||
* @param \nre\core\Request $request Current request
|
* @param \nre\core\Request $request Current request
|
||||||
* @param \nre\core\Response $response Current response
|
* @param \nre\core\Response $response Current response
|
||||||
*/
|
*/
|
||||||
public function index(\nre\core\Request $request, \nre\core\Response $response)
|
public function index(\nre\core\Request $request, \nre\core\Response $response)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
|
||||||
|
|
@ -1,38 +1,38 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Legend of Z
|
* The Legend of Z
|
||||||
*
|
*
|
||||||
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
||||||
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
|
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
|
||||||
* @license http://www.gnu.org/licenses/gpl.html
|
* @license http://www.gnu.org/licenses/gpl.html
|
||||||
* @link https://bitbucket.org/coderkun/the-legend-of-z
|
* @link https://bitbucket.org/coderkun/the-legend-of-z
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace hhu\z\agents\bottomlevel;
|
namespace hhu\z\agents\bottomlevel;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Agent to display a sidebar with Seminary related information.
|
* Agent to display a sidebar with Seminary related information.
|
||||||
*
|
*
|
||||||
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
||||||
*/
|
*/
|
||||||
class SeminarybarAgent extends \nre\agents\BottomlevelAgent
|
class SeminarybarAgent extends \nre\agents\BottomlevelAgent
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Action: index.
|
* Action: index.
|
||||||
*
|
*
|
||||||
* @param \nre\core\Request $request Current request
|
* @param \nre\core\Request $request Current request
|
||||||
* @param \nre\core\Response $response Current response
|
* @param \nre\core\Response $response Current response
|
||||||
*/
|
*/
|
||||||
public function index(\nre\core\Request $request, \nre\core\Response $response)
|
public function index(\nre\core\Request $request, \nre\core\Response $response)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
|
||||||
|
|
@ -1,38 +1,38 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Legend of Z
|
* The Legend of Z
|
||||||
*
|
*
|
||||||
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
||||||
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
|
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
|
||||||
* @license http://www.gnu.org/licenses/gpl.html
|
* @license http://www.gnu.org/licenses/gpl.html
|
||||||
* @link https://bitbucket.org/coderkun/the-legend-of-z
|
* @link https://bitbucket.org/coderkun/the-legend-of-z
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace hhu\z\agents\bottomlevel;
|
namespace hhu\z\agents\bottomlevel;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Agent to display a menu with Seminary related links.
|
* Agent to display a menu with Seminary related links.
|
||||||
*
|
*
|
||||||
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
||||||
*/
|
*/
|
||||||
class SeminarymenuAgent extends \nre\agents\BottomlevelAgent
|
class SeminarymenuAgent extends \nre\agents\BottomlevelAgent
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Action: index.
|
* Action: index.
|
||||||
*
|
*
|
||||||
* @param \nre\core\Request $request Current request
|
* @param \nre\core\Request $request Current request
|
||||||
* @param \nre\core\Response $response Current response
|
* @param \nre\core\Response $response Current response
|
||||||
*/
|
*/
|
||||||
public function index(\nre\core\Request $request, \nre\core\Response $response)
|
public function index(\nre\core\Request $request, \nre\core\Response $response)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
|
||||||
|
|
@ -1,38 +1,38 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Legend of Z
|
* The Legend of Z
|
||||||
*
|
*
|
||||||
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
||||||
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
|
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
|
||||||
* @license http://www.gnu.org/licenses/gpl.html
|
* @license http://www.gnu.org/licenses/gpl.html
|
||||||
* @link https://bitbucket.org/coderkun/the-legend-of-z
|
* @link https://bitbucket.org/coderkun/the-legend-of-z
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace hhu\z\agents\bottomlevel;
|
namespace hhu\z\agents\bottomlevel;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Agent to display and manage userroles.
|
* Agent to display and manage userroles.
|
||||||
*
|
*
|
||||||
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
||||||
*/
|
*/
|
||||||
class UserrolesAgent extends \nre\agents\BottomlevelAgent
|
class UserrolesAgent extends \nre\agents\BottomlevelAgent
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Action: user.
|
* Action: user.
|
||||||
*
|
*
|
||||||
* @param \nre\core\Request $request Current request
|
* @param \nre\core\Request $request Current request
|
||||||
* @param \nre\core\Response $response Current response
|
* @param \nre\core\Response $response Current response
|
||||||
*/
|
*/
|
||||||
public function user(\nre\core\Request $request, \nre\core\Response $response)
|
public function user(\nre\core\Request $request, \nre\core\Response $response)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
|
||||||
|
|
@ -1,38 +1,38 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Legend of Z
|
* The Legend of Z
|
||||||
*
|
*
|
||||||
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
||||||
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
|
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
|
||||||
* @license http://www.gnu.org/licenses/gpl.html
|
* @license http://www.gnu.org/licenses/gpl.html
|
||||||
* @link https://bitbucket.org/coderkun/the-legend-of-z
|
* @link https://bitbucket.org/coderkun/the-legend-of-z
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace hhu\z\agents\intermediate;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
namespace hhu\z\agents\intermediate;
|
||||||
* Agent to list Achievements.
|
|
||||||
*
|
|
||||||
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
/**
|
||||||
*/
|
* Agent to list Achievements.
|
||||||
class AchievementsAgent extends \nre\agents\IntermediateAgent
|
*
|
||||||
{
|
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
||||||
|
*/
|
||||||
|
class AchievementsAgent extends \nre\agents\IntermediateAgent
|
||||||
|
{
|
||||||
|
|
||||||
/**
|
|
||||||
* Action: index.
|
|
||||||
*
|
|
||||||
* @param \nre\core\Request $request Current request
|
/**
|
||||||
* @param \nre\core\Response $response Current response
|
* Action: index.
|
||||||
*/
|
*
|
||||||
public function index(\nre\core\Request $request, \nre\core\Response $response)
|
* @param \nre\core\Request $request Current request
|
||||||
{
|
* @param \nre\core\Response $response Current response
|
||||||
}
|
*/
|
||||||
|
public function index(\nre\core\Request $request, \nre\core\Response $response)
|
||||||
}
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
|
||||||
|
|
@ -1,38 +1,38 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Legend of Z
|
* The Legend of Z
|
||||||
*
|
*
|
||||||
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
||||||
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
|
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
|
||||||
* @license http://www.gnu.org/licenses/gpl.html
|
* @license http://www.gnu.org/licenses/gpl.html
|
||||||
* @link https://bitbucket.org/coderkun/the-legend-of-z
|
* @link https://bitbucket.org/coderkun/the-legend-of-z
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace hhu\z\agents\intermediate;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
namespace hhu\z\agents\intermediate;
|
||||||
* Agent to display Character groups.
|
|
||||||
*
|
|
||||||
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
/**
|
||||||
*/
|
* Agent to display Character groups.
|
||||||
class CharactergroupsAgent extends \nre\agents\IntermediateAgent
|
*
|
||||||
{
|
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
||||||
|
*/
|
||||||
|
class CharactergroupsAgent extends \nre\agents\IntermediateAgent
|
||||||
|
{
|
||||||
|
|
||||||
/**
|
|
||||||
* Action: index.
|
|
||||||
*
|
|
||||||
* @param \nre\core\Request $request Current request
|
/**
|
||||||
* @param \nre\core\Response $response Current response
|
* Action: index.
|
||||||
*/
|
*
|
||||||
public function index(\nre\core\Request $request, \nre\core\Response $response)
|
* @param \nre\core\Request $request Current request
|
||||||
{
|
* @param \nre\core\Response $response Current response
|
||||||
}
|
*/
|
||||||
|
public function index(\nre\core\Request $request, \nre\core\Response $response)
|
||||||
}
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
|
||||||
|
|
@ -1,38 +1,38 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Legend of Z
|
* The Legend of Z
|
||||||
*
|
*
|
||||||
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
||||||
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
|
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
|
||||||
* @license http://www.gnu.org/licenses/gpl.html
|
* @license http://www.gnu.org/licenses/gpl.html
|
||||||
* @link https://bitbucket.org/coderkun/the-legend-of-z
|
* @link https://bitbucket.org/coderkun/the-legend-of-z
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace hhu\z\agents\intermediate;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
namespace hhu\z\agents\intermediate;
|
||||||
* Agent to display Character groups Quests.
|
|
||||||
*
|
|
||||||
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
/**
|
||||||
*/
|
* Agent to display Character groups Quests.
|
||||||
class CharactergroupsquestsAgent extends \nre\agents\IntermediateAgent
|
*
|
||||||
{
|
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
||||||
|
*/
|
||||||
|
class CharactergroupsquestsAgent extends \nre\agents\IntermediateAgent
|
||||||
|
{
|
||||||
|
|
||||||
/**
|
|
||||||
* Action: index.
|
|
||||||
*
|
|
||||||
* @param \nre\core\Request $request Current request
|
/**
|
||||||
* @param \nre\core\Response $response Current response
|
* Action: index.
|
||||||
*/
|
*
|
||||||
public function index(\nre\core\Request $request, \nre\core\Response $response)
|
* @param \nre\core\Request $request Current request
|
||||||
{
|
* @param \nre\core\Response $response Current response
|
||||||
}
|
*/
|
||||||
|
public function index(\nre\core\Request $request, \nre\core\Response $response)
|
||||||
}
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
|
||||||
|
|
@ -1,49 +1,49 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Legend of Z
|
* The Legend of Z
|
||||||
*
|
*
|
||||||
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
||||||
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
|
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
|
||||||
* @license http://www.gnu.org/licenses/gpl.html
|
* @license http://www.gnu.org/licenses/gpl.html
|
||||||
* @link https://bitbucket.org/coderkun/the-legend-of-z
|
* @link https://bitbucket.org/coderkun/the-legend-of-z
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace hhu\z\agents\intermediate;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
namespace hhu\z\agents\intermediate;
|
||||||
* Agent to list registered Characters and their data.
|
|
||||||
*
|
|
||||||
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
/**
|
||||||
*/
|
* Agent to list registered Characters and their data.
|
||||||
class CharactersAgent extends \nre\agents\IntermediateAgent
|
*
|
||||||
{
|
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
||||||
|
*/
|
||||||
|
class CharactersAgent extends \nre\agents\IntermediateAgent
|
||||||
|
{
|
||||||
|
|
||||||
/**
|
|
||||||
* Action: index.
|
|
||||||
*
|
|
||||||
* @param \nre\core\Request $request Current request
|
/**
|
||||||
* @param \nre\core\Response $response Current response
|
* Action: index.
|
||||||
*/
|
*
|
||||||
public function index(\nre\core\Request $request, \nre\core\Response $response)
|
* @param \nre\core\Request $request Current request
|
||||||
{
|
* @param \nre\core\Response $response Current response
|
||||||
}
|
*/
|
||||||
|
public function index(\nre\core\Request $request, \nre\core\Response $response)
|
||||||
|
{
|
||||||
/**
|
}
|
||||||
* Action: character.
|
|
||||||
*
|
|
||||||
* @param \nre\core\Request $request Current request
|
/**
|
||||||
* @param \nre\core\Response $response Current response
|
* Action: character.
|
||||||
*/
|
*
|
||||||
public function character(\nre\core\Request $request, \nre\core\Response $response)
|
* @param \nre\core\Request $request Current request
|
||||||
{
|
* @param \nre\core\Response $response Current response
|
||||||
}
|
*/
|
||||||
|
public function character(\nre\core\Request $request, \nre\core\Response $response)
|
||||||
}
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
|
||||||
|
|
@ -1,38 +1,38 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Legend of Z
|
* The Legend of Z
|
||||||
*
|
*
|
||||||
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
||||||
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
|
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
|
||||||
* @license http://www.gnu.org/licenses/gpl.html
|
* @license http://www.gnu.org/licenses/gpl.html
|
||||||
* @link https://bitbucket.org/coderkun/the-legend-of-z
|
* @link https://bitbucket.org/coderkun/the-legend-of-z
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace hhu\z\agents\intermediate;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
namespace hhu\z\agents\intermediate;
|
||||||
* Agent to handle Charactertyes of a Seminary.
|
|
||||||
*
|
|
||||||
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
/**
|
||||||
*/
|
* Agent to handle Charactertyes of a Seminary.
|
||||||
class CharactertypesAgent extends \nre\agents\IntermediateAgent
|
*
|
||||||
{
|
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
||||||
|
*/
|
||||||
|
class CharactertypesAgent extends \nre\agents\IntermediateAgent
|
||||||
|
{
|
||||||
|
|
||||||
/**
|
|
||||||
* Action: index.
|
|
||||||
*
|
|
||||||
* @param \nre\core\Request $request Current request
|
/**
|
||||||
* @param \nre\core\Response $response Current response
|
* Action: index.
|
||||||
*/
|
*
|
||||||
public function index(\nre\core\Request $request, \nre\core\Response $response)
|
* @param \nre\core\Request $request Current request
|
||||||
{
|
* @param \nre\core\Response $response Current response
|
||||||
}
|
*/
|
||||||
|
public function index(\nre\core\Request $request, \nre\core\Response $response)
|
||||||
}
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
|
||||||
|
|
@ -1,38 +1,38 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Legend of Z
|
* The Legend of Z
|
||||||
*
|
*
|
||||||
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
||||||
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
|
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
|
||||||
* @license http://www.gnu.org/licenses/gpl.html
|
* @license http://www.gnu.org/licenses/gpl.html
|
||||||
* @link https://bitbucket.org/coderkun/the-legend-of-z
|
* @link https://bitbucket.org/coderkun/the-legend-of-z
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace hhu\z\agents\intermediate;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
namespace hhu\z\agents\intermediate;
|
||||||
* Agent to show an error page.
|
|
||||||
*
|
|
||||||
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
/**
|
||||||
*/
|
* Agent to show an error page.
|
||||||
class ErrorAgent extends \nre\agents\IntermediateAgent
|
*
|
||||||
{
|
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
||||||
|
*/
|
||||||
|
class ErrorAgent extends \nre\agents\IntermediateAgent
|
||||||
|
{
|
||||||
|
|
||||||
/**
|
|
||||||
* Action: index.
|
|
||||||
*
|
|
||||||
* @param \nre\core\Request $request Current request
|
/**
|
||||||
* @param \nre\core\Response $response Current response
|
* Action: index.
|
||||||
*/
|
*
|
||||||
public function index(\nre\core\Request $request, \nre\core\Response $response)
|
* @param \nre\core\Request $request Current request
|
||||||
{
|
* @param \nre\core\Response $response Current response
|
||||||
}
|
*/
|
||||||
|
public function index(\nre\core\Request $request, \nre\core\Response $response)
|
||||||
}
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
|
||||||
|
|
@ -1,38 +1,38 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Legend of Z
|
* The Legend of Z
|
||||||
*
|
*
|
||||||
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
||||||
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
|
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
|
||||||
* @license http://www.gnu.org/licenses/gpl.html
|
* @license http://www.gnu.org/licenses/gpl.html
|
||||||
* @link https://bitbucket.org/coderkun/the-legend-of-z
|
* @link https://bitbucket.org/coderkun/the-legend-of-z
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace hhu\z\agents\intermediate;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
namespace hhu\z\agents\intermediate;
|
||||||
* Agent to show an introduction page.
|
|
||||||
*
|
|
||||||
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
/**
|
||||||
*/
|
* Agent to show an introduction page.
|
||||||
class IntroductionAgent extends \nre\agents\IntermediateAgent
|
*
|
||||||
{
|
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
||||||
|
*/
|
||||||
|
class IntroductionAgent extends \nre\agents\IntermediateAgent
|
||||||
|
{
|
||||||
|
|
||||||
/**
|
|
||||||
* Action: index.
|
|
||||||
*
|
|
||||||
* @param \nre\core\Request $request Current request
|
/**
|
||||||
* @param \nre\core\Response $response Current response
|
* Action: index.
|
||||||
*/
|
*
|
||||||
public function index(\nre\core\Request $request, \nre\core\Response $response)
|
* @param \nre\core\Request $request Current request
|
||||||
{
|
* @param \nre\core\Response $response Current response
|
||||||
}
|
*/
|
||||||
|
public function index(\nre\core\Request $request, \nre\core\Response $response)
|
||||||
}
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
|
||||||
|
|
@ -1,38 +1,38 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Legend of Z
|
* The Legend of Z
|
||||||
*
|
*
|
||||||
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
||||||
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
|
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
|
||||||
* @license http://www.gnu.org/licenses/gpl.html
|
* @license http://www.gnu.org/licenses/gpl.html
|
||||||
* @link https://bitbucket.org/coderkun/the-legend-of-z
|
* @link https://bitbucket.org/coderkun/the-legend-of-z
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace hhu\z\agents\intermediate;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
namespace hhu\z\agents\intermediate;
|
||||||
* Agent to list Quest topics.
|
|
||||||
*
|
|
||||||
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
/**
|
||||||
*/
|
* Agent to list Quest topics.
|
||||||
class LibraryAgent extends \nre\agents\IntermediateAgent
|
*
|
||||||
{
|
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
||||||
|
*/
|
||||||
|
class LibraryAgent extends \nre\agents\IntermediateAgent
|
||||||
|
{
|
||||||
|
|
||||||
/**
|
|
||||||
* Action: index.
|
|
||||||
*
|
|
||||||
* @param \nre\core\Request $request Current request
|
/**
|
||||||
* @param \nre\core\Response $response Current response
|
* Action: index.
|
||||||
*/
|
*
|
||||||
public function index(\nre\core\Request $request, \nre\core\Response $response)
|
* @param \nre\core\Request $request Current request
|
||||||
{
|
* @param \nre\core\Response $response Current response
|
||||||
}
|
*/
|
||||||
|
public function index(\nre\core\Request $request, \nre\core\Response $response)
|
||||||
}
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
|
||||||
|
|
@ -1,38 +1,38 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Legend of Z
|
* The Legend of Z
|
||||||
*
|
*
|
||||||
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
||||||
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
|
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
|
||||||
* @license http://www.gnu.org/licenses/gpl.html
|
* @license http://www.gnu.org/licenses/gpl.html
|
||||||
* @link https://bitbucket.org/coderkun/the-legend-of-z
|
* @link https://bitbucket.org/coderkun/the-legend-of-z
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace hhu\z\agents\intermediate;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
namespace hhu\z\agents\intermediate;
|
||||||
* Agent to generate a mail-message.
|
|
||||||
*
|
|
||||||
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
/**
|
||||||
*/
|
* Agent to generate a mail-message.
|
||||||
class MailAgent extends \nre\agents\IntermediateAgent
|
*
|
||||||
{
|
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
||||||
|
*/
|
||||||
|
class MailAgent extends \nre\agents\IntermediateAgent
|
||||||
|
{
|
||||||
|
|
||||||
/**
|
|
||||||
* Action: index.
|
|
||||||
*
|
|
||||||
* @param \nre\core\Request $request Current request
|
/**
|
||||||
* @param \nre\core\Response $response Current response
|
* Action: index.
|
||||||
*/
|
*
|
||||||
public function index(\nre\core\Request $request, \nre\core\Response $response)
|
* @param \nre\core\Request $request Current request
|
||||||
{
|
* @param \nre\core\Response $response Current response
|
||||||
}
|
*/
|
||||||
|
public function index(\nre\core\Request $request, \nre\core\Response $response)
|
||||||
}
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
|
||||||
|
|
@ -1,38 +1,38 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Legend of Z
|
* The Legend of Z
|
||||||
*
|
*
|
||||||
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
||||||
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
|
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
|
||||||
* @license http://www.gnu.org/licenses/gpl.html
|
* @license http://www.gnu.org/licenses/gpl.html
|
||||||
* @link https://bitbucket.org/coderkun/the-legend-of-z
|
* @link https://bitbucket.org/coderkun/the-legend-of-z
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace hhu\z\agents\intermediate;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
namespace hhu\z\agents\intermediate;
|
||||||
* Agent to display a map.
|
|
||||||
*
|
|
||||||
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
/**
|
||||||
*/
|
* Agent to display a map.
|
||||||
class MapAgent extends \nre\agents\IntermediateAgent
|
*
|
||||||
{
|
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
||||||
|
*/
|
||||||
|
class MapAgent extends \nre\agents\IntermediateAgent
|
||||||
|
{
|
||||||
|
|
||||||
/**
|
|
||||||
* Action: index.
|
|
||||||
*
|
|
||||||
* @param \nre\core\Request $request Current request
|
/**
|
||||||
* @param \nre\core\Response $response Current response
|
* Action: index.
|
||||||
*/
|
*
|
||||||
public function index(\nre\core\Request $request, \nre\core\Response $response)
|
* @param \nre\core\Request $request Current request
|
||||||
{
|
* @param \nre\core\Response $response Current response
|
||||||
}
|
*/
|
||||||
|
public function index(\nre\core\Request $request, \nre\core\Response $response)
|
||||||
}
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
|
||||||
|
|
@ -1,38 +1,38 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Legend of Z
|
* The Legend of Z
|
||||||
*
|
*
|
||||||
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
||||||
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
|
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
|
||||||
* @license http://www.gnu.org/licenses/gpl.html
|
* @license http://www.gnu.org/licenses/gpl.html
|
||||||
* @link https://bitbucket.org/coderkun/the-legend-of-z
|
* @link https://bitbucket.org/coderkun/the-legend-of-z
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace hhu\z\agents\intermediate;
|
namespace hhu\z\agents\intermediate;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Agent to process and show media.
|
* Agent to process and show media.
|
||||||
*
|
*
|
||||||
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
||||||
*/
|
*/
|
||||||
class MediaAgent extends \nre\agents\IntermediateAgent
|
class MediaAgent extends \nre\agents\IntermediateAgent
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Action: index.
|
* Action: index.
|
||||||
*
|
*
|
||||||
* @param \nre\core\Request $request Current request
|
* @param \nre\core\Request $request Current request
|
||||||
* @param \nre\core\Response $response Current response
|
* @param \nre\core\Response $response Current response
|
||||||
*/
|
*/
|
||||||
public function index(\nre\core\Request $request, \nre\core\Response $response)
|
public function index(\nre\core\Request $request, \nre\core\Response $response)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
|
||||||
|
|
@ -1,99 +1,99 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Legend of Z
|
* The Legend of Z
|
||||||
*
|
*
|
||||||
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
||||||
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
|
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
|
||||||
* @license http://www.gnu.org/licenses/gpl.html
|
* @license http://www.gnu.org/licenses/gpl.html
|
||||||
* @link https://bitbucket.org/coderkun/the-legend-of-z
|
* @link https://bitbucket.org/coderkun/the-legend-of-z
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace hhu\z\agents\intermediate;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
namespace hhu\z\agents\intermediate;
|
||||||
* Agent to display Questgroups.
|
|
||||||
*
|
|
||||||
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
|
||||||
*/
|
|
||||||
class QuestgroupsAgent extends \nre\agents\IntermediateAgent
|
|
||||||
{
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Action: questgroup.
|
|
||||||
*
|
|
||||||
* @param \nre\core\Request $request Current request
|
|
||||||
* @param \nre\core\Response $response Current response
|
|
||||||
*/
|
|
||||||
public function questgroup(\nre\core\Request $request, \nre\core\Response $response)
|
|
||||||
{
|
|
||||||
$this->addSubAgent('Questgroupshierarchypath', 'index', $request->getParam(3), $request->getParam(4));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Action: edit.
|
|
||||||
*
|
|
||||||
* @param \nre\core\Request $request Current request
|
|
||||||
* @param \nre\core\Response $response Current response
|
|
||||||
*/
|
|
||||||
public function edit(\nre\core\Request $request, \nre\core\Response $response)
|
|
||||||
{
|
|
||||||
$this->addSubAgent('Questgroupshierarchypath', 'index', $request->getParam(3), $request->getParam(4));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Action: edittexts.
|
* Agent to display Questgroups.
|
||||||
*
|
*
|
||||||
* @param \nre\core\Request $request Current request
|
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
||||||
* @param \nre\core\Response $response Current response
|
*/
|
||||||
*/
|
class QuestgroupsAgent extends \nre\agents\IntermediateAgent
|
||||||
public function edittexts(\nre\core\Request $request, \nre\core\Response $response)
|
{
|
||||||
{
|
|
||||||
$this->addSubAgent('Questgroupshierarchypath', 'index', $request->getParam(3), $request->getParam(4));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Action: moveup.
|
|
||||||
*
|
|
||||||
* @param \nre\core\Request $request Current request
|
|
||||||
* @param \nre\core\Response $response Current response
|
|
||||||
*/
|
|
||||||
public function moveup(\nre\core\Request $request, \nre\core\Response $response)
|
|
||||||
{
|
|
||||||
$this->addSubAgent('Questgroupshierarchypath', 'index', $request->getParam(3), $request->getParam(4));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Action: movedown.
|
|
||||||
*
|
|
||||||
* @param \nre\core\Request $request Current request
|
|
||||||
* @param \nre\core\Response $response Current response
|
|
||||||
*/
|
|
||||||
public function movedown(\nre\core\Request $request, \nre\core\Response $response)
|
|
||||||
{
|
|
||||||
$this->addSubAgent('Questgroupshierarchypath', 'index', $request->getParam(3), $request->getParam(4));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Action: delete.
|
* Action: questgroup.
|
||||||
*
|
*
|
||||||
* @param \nre\core\Request $request Current request
|
* @param \nre\core\Request $request Current request
|
||||||
* @param \nre\core\Response $response Current response
|
* @param \nre\core\Response $response Current response
|
||||||
*/
|
*/
|
||||||
public function delete(\nre\core\Request $request, \nre\core\Response $response)
|
public function questgroup(\nre\core\Request $request, \nre\core\Response $response)
|
||||||
{
|
{
|
||||||
$this->addSubAgent('Questgroupshierarchypath', 'index', $request->getParam(3), $request->getParam(4));
|
$this->addSubAgent('Questgroupshierarchypath', 'index', $request->getParam(3), $request->getParam(4));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
|
||||||
|
/**
|
||||||
|
* Action: edit.
|
||||||
|
*
|
||||||
|
* @param \nre\core\Request $request Current request
|
||||||
|
* @param \nre\core\Response $response Current response
|
||||||
|
*/
|
||||||
|
public function edit(\nre\core\Request $request, \nre\core\Response $response)
|
||||||
|
{
|
||||||
|
$this->addSubAgent('Questgroupshierarchypath', 'index', $request->getParam(3), $request->getParam(4));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Action: edittexts.
|
||||||
|
*
|
||||||
|
* @param \nre\core\Request $request Current request
|
||||||
|
* @param \nre\core\Response $response Current response
|
||||||
|
*/
|
||||||
|
public function edittexts(\nre\core\Request $request, \nre\core\Response $response)
|
||||||
|
{
|
||||||
|
$this->addSubAgent('Questgroupshierarchypath', 'index', $request->getParam(3), $request->getParam(4));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Action: moveup.
|
||||||
|
*
|
||||||
|
* @param \nre\core\Request $request Current request
|
||||||
|
* @param \nre\core\Response $response Current response
|
||||||
|
*/
|
||||||
|
public function moveup(\nre\core\Request $request, \nre\core\Response $response)
|
||||||
|
{
|
||||||
|
$this->addSubAgent('Questgroupshierarchypath', 'index', $request->getParam(3), $request->getParam(4));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Action: movedown.
|
||||||
|
*
|
||||||
|
* @param \nre\core\Request $request Current request
|
||||||
|
* @param \nre\core\Response $response Current response
|
||||||
|
*/
|
||||||
|
public function movedown(\nre\core\Request $request, \nre\core\Response $response)
|
||||||
|
{
|
||||||
|
$this->addSubAgent('Questgroupshierarchypath', 'index', $request->getParam(3), $request->getParam(4));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Action: delete.
|
||||||
|
*
|
||||||
|
* @param \nre\core\Request $request Current request
|
||||||
|
* @param \nre\core\Response $response Current response
|
||||||
|
*/
|
||||||
|
public function delete(\nre\core\Request $request, \nre\core\Response $response)
|
||||||
|
{
|
||||||
|
$this->addSubAgent('Questgroupshierarchypath', 'index', $request->getParam(3), $request->getParam(4));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
|
||||||
|
|
@ -1,24 +1,24 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Legend of Z
|
* The Legend of Z
|
||||||
*
|
*
|
||||||
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
||||||
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
|
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
|
||||||
* @license http://www.gnu.org/licenses/gpl.html
|
* @license http://www.gnu.org/licenses/gpl.html
|
||||||
* @link https://bitbucket.org/coderkun/the-legend-of-z
|
* @link https://bitbucket.org/coderkun/the-legend-of-z
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace hhu\z\agents\intermediate;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
namespace hhu\z\agents\intermediate;
|
||||||
* Agent to manage Questgroupshierarchy.
|
|
||||||
*
|
|
||||||
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
/**
|
||||||
*/
|
* Agent to manage Questgroupshierarchy.
|
||||||
class QuestgroupshierarchyAgent extends \nre\agents\IntermediateAgent
|
*
|
||||||
{
|
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
||||||
}
|
*/
|
||||||
|
class QuestgroupshierarchyAgent extends \nre\agents\IntermediateAgent
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
|
||||||
|
|
@ -1,123 +1,123 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Legend of Z
|
* The Legend of Z
|
||||||
*
|
*
|
||||||
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
||||||
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
|
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
|
||||||
* @license http://www.gnu.org/licenses/gpl.html
|
* @license http://www.gnu.org/licenses/gpl.html
|
||||||
* @link https://bitbucket.org/coderkun/the-legend-of-z
|
* @link https://bitbucket.org/coderkun/the-legend-of-z
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace hhu\z\agents\intermediate;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
namespace hhu\z\agents\intermediate;
|
||||||
* Agent to display Quests.
|
|
||||||
*
|
|
||||||
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
|
||||||
*/
|
|
||||||
class QuestsAgent extends \nre\agents\IntermediateAgent
|
|
||||||
{
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Action: quest.
|
|
||||||
*
|
|
||||||
* @param \nre\core\Request $request Current request
|
|
||||||
* @param \nre\core\Response $response Current response
|
|
||||||
*/
|
|
||||||
public function quest(\nre\core\Request $request, \nre\core\Response $response)
|
|
||||||
{
|
|
||||||
$this->addSubAgent('Questgroupshierarchypath', 'index', $request->getParam(3), $request->getParam(4), true);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Action: submissions.
|
|
||||||
*
|
|
||||||
* @param \nre\core\Request $request Current request
|
|
||||||
* @param \nre\core\Response $response Current response
|
|
||||||
*/
|
|
||||||
public function submissions(\nre\core\Request $request, \nre\core\Response $response)
|
|
||||||
{
|
|
||||||
$this->addSubAgent('Questgroupshierarchypath', 'index', $request->getParam(3), $request->getParam(4), true);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Action: submission.
|
|
||||||
*
|
|
||||||
* @param \nre\core\Request $request Current request
|
|
||||||
* @param \nre\core\Response $response Current response
|
|
||||||
*/
|
|
||||||
public function submission(\nre\core\Request $request, \nre\core\Response $response)
|
|
||||||
{
|
|
||||||
$this->addSubAgent('Questgroupshierarchypath', 'index', $request->getParam(3), $request->getParam(4), true);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Action: create.
|
* Agent to display Quests.
|
||||||
*
|
*
|
||||||
* @param \nre\core\Request $request Current request
|
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
||||||
* @param \nre\core\Response $response Current response
|
*/
|
||||||
*/
|
class QuestsAgent extends \nre\agents\IntermediateAgent
|
||||||
public function create(\nre\core\Request $request, \nre\core\Response $response)
|
{
|
||||||
{
|
|
||||||
$this->addSubAgent('Questgroupshierarchypath', 'index', $request->getParam(3), $request->getParam(4), true);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Action: edit.
|
|
||||||
*
|
|
||||||
* @param \nre\core\Request $request Current request
|
|
||||||
* @param \nre\core\Response $response Current response
|
|
||||||
*/
|
|
||||||
public function edit(\nre\core\Request $request, \nre\core\Response $response)
|
|
||||||
{
|
|
||||||
$this->addSubAgent('Questgroupshierarchypath', 'index', $request->getParam(3), $request->getParam(4), true);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Action: edittask.
|
* Action: quest.
|
||||||
*
|
*
|
||||||
* @param \nre\core\Request $request Current request
|
* @param \nre\core\Request $request Current request
|
||||||
* @param \nre\core\Response $response Current response
|
* @param \nre\core\Response $response Current response
|
||||||
*/
|
*/
|
||||||
public function edittask(\nre\core\Request $request, \nre\core\Response $response)
|
public function quest(\nre\core\Request $request, \nre\core\Response $response)
|
||||||
{
|
{
|
||||||
$this->addSubAgent('Questgroupshierarchypath', 'index', $request->getParam(3), $request->getParam(4), true);
|
$this->addSubAgent('Questgroupshierarchypath', 'index', $request->getParam(3), $request->getParam(4), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Action: edittexts.
|
* Action: submissions.
|
||||||
*
|
*
|
||||||
* @param \nre\core\Request $request Current request
|
* @param \nre\core\Request $request Current request
|
||||||
* @param \nre\core\Response $response Current response
|
* @param \nre\core\Response $response Current response
|
||||||
*/
|
*/
|
||||||
public function edittexts(\nre\core\Request $request, \nre\core\Response $response)
|
public function submissions(\nre\core\Request $request, \nre\core\Response $response)
|
||||||
{
|
{
|
||||||
$this->addSubAgent('Questgroupshierarchypath', 'index', $request->getParam(3), $request->getParam(4), true);
|
$this->addSubAgent('Questgroupshierarchypath', 'index', $request->getParam(3), $request->getParam(4), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Action: delete.
|
* Action: submission.
|
||||||
*
|
*
|
||||||
* @param \nre\core\Request $request Current request
|
* @param \nre\core\Request $request Current request
|
||||||
* @param \nre\core\Response $response Current response
|
* @param \nre\core\Response $response Current response
|
||||||
*/
|
*/
|
||||||
public function delete(\nre\core\Request $request, \nre\core\Response $response)
|
public function submission(\nre\core\Request $request, \nre\core\Response $response)
|
||||||
{
|
{
|
||||||
$this->addSubAgent('Questgroupshierarchypath', 'index', $request->getParam(3), $request->getParam(4), true);
|
$this->addSubAgent('Questgroupshierarchypath', 'index', $request->getParam(3), $request->getParam(4), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
|
||||||
|
/**
|
||||||
|
* Action: create.
|
||||||
|
*
|
||||||
|
* @param \nre\core\Request $request Current request
|
||||||
|
* @param \nre\core\Response $response Current response
|
||||||
|
*/
|
||||||
|
public function create(\nre\core\Request $request, \nre\core\Response $response)
|
||||||
|
{
|
||||||
|
$this->addSubAgent('Questgroupshierarchypath', 'index', $request->getParam(3), $request->getParam(4), true);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Action: edit.
|
||||||
|
*
|
||||||
|
* @param \nre\core\Request $request Current request
|
||||||
|
* @param \nre\core\Response $response Current response
|
||||||
|
*/
|
||||||
|
public function edit(\nre\core\Request $request, \nre\core\Response $response)
|
||||||
|
{
|
||||||
|
$this->addSubAgent('Questgroupshierarchypath', 'index', $request->getParam(3), $request->getParam(4), true);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Action: edittask.
|
||||||
|
*
|
||||||
|
* @param \nre\core\Request $request Current request
|
||||||
|
* @param \nre\core\Response $response Current response
|
||||||
|
*/
|
||||||
|
public function edittask(\nre\core\Request $request, \nre\core\Response $response)
|
||||||
|
{
|
||||||
|
$this->addSubAgent('Questgroupshierarchypath', 'index', $request->getParam(3), $request->getParam(4), true);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Action: edittexts.
|
||||||
|
*
|
||||||
|
* @param \nre\core\Request $request Current request
|
||||||
|
* @param \nre\core\Response $response Current response
|
||||||
|
*/
|
||||||
|
public function edittexts(\nre\core\Request $request, \nre\core\Response $response)
|
||||||
|
{
|
||||||
|
$this->addSubAgent('Questgroupshierarchypath', 'index', $request->getParam(3), $request->getParam(4), true);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Action: delete.
|
||||||
|
*
|
||||||
|
* @param \nre\core\Request $request Current request
|
||||||
|
* @param \nre\core\Response $response Current response
|
||||||
|
*/
|
||||||
|
public function delete(\nre\core\Request $request, \nre\core\Response $response)
|
||||||
|
{
|
||||||
|
$this->addSubAgent('Questgroupshierarchypath', 'index', $request->getParam(3), $request->getParam(4), true);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
|
||||||
|
|
@ -1,38 +1,38 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Legend of Z
|
* The Legend of Z
|
||||||
*
|
*
|
||||||
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
||||||
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
|
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
|
||||||
* @license http://www.gnu.org/licenses/gpl.html
|
* @license http://www.gnu.org/licenses/gpl.html
|
||||||
* @link https://bitbucket.org/coderkun/the-legend-of-z
|
* @link https://bitbucket.org/coderkun/the-legend-of-z
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace hhu\z\agents\intermediate;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
namespace hhu\z\agents\intermediate;
|
||||||
* Agent to list registered seminaries.
|
|
||||||
*
|
|
||||||
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
/**
|
||||||
*/
|
* Agent to list registered seminaries.
|
||||||
class SeminariesAgent extends \nre\agents\IntermediateAgent
|
*
|
||||||
{
|
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
||||||
|
*/
|
||||||
|
class SeminariesAgent extends \nre\agents\IntermediateAgent
|
||||||
|
{
|
||||||
|
|
||||||
/**
|
|
||||||
* Action: index.
|
|
||||||
*
|
|
||||||
* @param \nre\core\Request $request Current request
|
/**
|
||||||
* @param \nre\core\Response $response Current response
|
* Action: index.
|
||||||
*/
|
*
|
||||||
public function index(\nre\core\Request $request, \nre\core\Response $response)
|
* @param \nre\core\Request $request Current request
|
||||||
{
|
* @param \nre\core\Response $response Current response
|
||||||
}
|
*/
|
||||||
|
public function index(\nre\core\Request $request, \nre\core\Response $response)
|
||||||
}
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
|
||||||
|
|
@ -1,38 +1,38 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Legend of Z
|
* The Legend of Z
|
||||||
*
|
*
|
||||||
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
||||||
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
|
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
|
||||||
* @license http://www.gnu.org/licenses/gpl.html
|
* @license http://www.gnu.org/licenses/gpl.html
|
||||||
* @link https://bitbucket.org/coderkun/the-legend-of-z
|
* @link https://bitbucket.org/coderkun/the-legend-of-z
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace hhu\z\agents\intermediate;
|
namespace hhu\z\agents\intermediate;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Agent to process and show user uploads.
|
* Agent to process and show user uploads.
|
||||||
*
|
*
|
||||||
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
||||||
*/
|
*/
|
||||||
class UploadsAgent extends \nre\agents\IntermediateAgent
|
class UploadsAgent extends \nre\agents\IntermediateAgent
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Action: index.
|
* Action: index.
|
||||||
*
|
*
|
||||||
* @param \nre\core\Request $request Current request
|
* @param \nre\core\Request $request Current request
|
||||||
* @param \nre\core\Response $response Current response
|
* @param \nre\core\Response $response Current response
|
||||||
*/
|
*/
|
||||||
public function index(\nre\core\Request $request, \nre\core\Response $response)
|
public function index(\nre\core\Request $request, \nre\core\Response $response)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
|
||||||
|
|
@ -1,50 +1,50 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Legend of Z
|
* The Legend of Z
|
||||||
*
|
*
|
||||||
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
||||||
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
|
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
|
||||||
* @license http://www.gnu.org/licenses/gpl.html
|
* @license http://www.gnu.org/licenses/gpl.html
|
||||||
* @link https://bitbucket.org/coderkun/the-legend-of-z
|
* @link https://bitbucket.org/coderkun/the-legend-of-z
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace hhu\z\agents\intermediate;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
namespace hhu\z\agents\intermediate;
|
||||||
* Agent to list registered users and their data.
|
|
||||||
*
|
|
||||||
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
/**
|
||||||
*/
|
* Agent to list registered users and their data.
|
||||||
class UsersAgent extends \nre\agents\IntermediateAgent
|
*
|
||||||
{
|
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
||||||
|
*/
|
||||||
|
class UsersAgent extends \nre\agents\IntermediateAgent
|
||||||
|
{
|
||||||
|
|
||||||
/**
|
|
||||||
* Action: index.
|
|
||||||
*
|
|
||||||
* @param \nre\core\Request $request Current request
|
/**
|
||||||
* @param \nre\core\Response $response Current response
|
* Action: index.
|
||||||
*/
|
*
|
||||||
public function index(\nre\core\Request $request, \nre\core\Response $response)
|
* @param \nre\core\Request $request Current request
|
||||||
{
|
* @param \nre\core\Response $response Current response
|
||||||
}
|
*/
|
||||||
|
public function index(\nre\core\Request $request, \nre\core\Response $response)
|
||||||
|
{
|
||||||
/**
|
}
|
||||||
* Action: user.
|
|
||||||
*
|
|
||||||
* @param \nre\core\Request $request Current request
|
/**
|
||||||
* @param \nre\core\Response $response Current response
|
* Action: user.
|
||||||
*/
|
*
|
||||||
public function user(\nre\core\Request $request, \nre\core\Response $response)
|
* @param \nre\core\Request $request Current request
|
||||||
{
|
* @param \nre\core\Response $response Current response
|
||||||
$this->addSubAgent('Userroles', 'user');
|
*/
|
||||||
}
|
public function user(\nre\core\Request $request, \nre\core\Response $response)
|
||||||
|
{
|
||||||
}
|
$this->addSubAgent('Userroles', 'user');
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
|
||||||
|
|
@ -1,38 +1,38 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Legend of Z
|
* The Legend of Z
|
||||||
*
|
*
|
||||||
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
||||||
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
|
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
|
||||||
* @license http://www.gnu.org/licenses/gpl.html
|
* @license http://www.gnu.org/licenses/gpl.html
|
||||||
* @link https://bitbucket.org/coderkun/the-legend-of-z
|
* @link https://bitbucket.org/coderkun/the-legend-of-z
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace hhu\z\agents\intermediate;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
namespace hhu\z\agents\intermediate;
|
||||||
* Agent to handle XP-levels of a Seminary.
|
|
||||||
*
|
|
||||||
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
/**
|
||||||
*/
|
* Agent to handle XP-levels of a Seminary.
|
||||||
class XplevelsAgent extends \nre\agents\IntermediateAgent
|
*
|
||||||
{
|
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
||||||
|
*/
|
||||||
|
class XplevelsAgent extends \nre\agents\IntermediateAgent
|
||||||
|
{
|
||||||
|
|
||||||
/**
|
|
||||||
* Action: index.
|
|
||||||
*
|
|
||||||
* @param \nre\core\Request $request Current request
|
/**
|
||||||
* @param \nre\core\Response $response Current response
|
* Action: index.
|
||||||
*/
|
*
|
||||||
public function index(\nre\core\Request $request, \nre\core\Response $response)
|
* @param \nre\core\Request $request Current request
|
||||||
{
|
* @param \nre\core\Response $response Current response
|
||||||
}
|
*/
|
||||||
|
public function index(\nre\core\Request $request, \nre\core\Response $response)
|
||||||
}
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
|
||||||
|
|
@ -1,80 +1,80 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Legend of Z
|
* The Legend of Z
|
||||||
*
|
*
|
||||||
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
||||||
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
|
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
|
||||||
* @license http://www.gnu.org/licenses/gpl.html
|
* @license http://www.gnu.org/licenses/gpl.html
|
||||||
* @link https://bitbucket.org/coderkun/the-legend-of-z
|
* @link https://bitbucket.org/coderkun/the-legend-of-z
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace hhu\z\agents\toplevel;
|
namespace hhu\z\agents\toplevel;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Agent to return a JSON-string used by AJAX.
|
* Agent to return a JSON-string used by AJAX.
|
||||||
*
|
*
|
||||||
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
||||||
*/
|
*/
|
||||||
class AjaxAgent extends \hhu\z\agents\ToplevelAgent
|
class AjaxAgent extends \hhu\z\agents\ToplevelAgent
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Construct a new AjaxAgent.
|
* Construct a new AjaxAgent.
|
||||||
*
|
*
|
||||||
* @param \nre\core\Request $request Current request
|
* @param \nre\core\Request $request Current request
|
||||||
* @param \nre\core\Response $response Current response
|
* @param \nre\core\Response $response Current response
|
||||||
* @param \nre\core\Logger $log Logger instance
|
* @param \nre\core\Logger $log Logger instance
|
||||||
*/
|
*/
|
||||||
protected function __construct(\nre\core\Request $request, \nre\core\Response $response, \nre\core\Logger $log=null)
|
protected function __construct(\nre\core\Request $request, \nre\core\Response $response, \nre\core\Logger $log=null)
|
||||||
{
|
{
|
||||||
parent::__construct($request, $response, $log);
|
parent::__construct($request, $response, $log);
|
||||||
|
|
||||||
|
|
||||||
$this->setLanguage($request);
|
$this->setLanguage($request);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Action: index.
|
* Action: index.
|
||||||
*
|
*
|
||||||
* @param \nre\core\Request $request Current request
|
* @param \nre\core\Request $request Current request
|
||||||
* @param \nre\core\Response $response Current response
|
* @param \nre\core\Response $response Current response
|
||||||
*/
|
*/
|
||||||
public function index(\nre\core\Request $request, \nre\core\Response $response)
|
public function index(\nre\core\Request $request, \nre\core\Response $response)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set requested language.
|
* Set requested language.
|
||||||
*
|
*
|
||||||
* @param \nre\core\Request $request Current request
|
* @param \nre\core\Request $request Current request
|
||||||
*/
|
*/
|
||||||
private function setLanguage(\nre\core\Request $request)
|
private function setLanguage(\nre\core\Request $request)
|
||||||
{
|
{
|
||||||
// Set domain
|
// Set domain
|
||||||
$domain = \nre\configs\AppConfig::$app['genericname'];
|
$domain = \nre\configs\AppConfig::$app['genericname'];
|
||||||
|
|
||||||
// Get language
|
// Get language
|
||||||
$locale = $request->getGetParam('lang', 'language');
|
$locale = $request->getGetParam('lang', 'language');
|
||||||
if(is_null($locale)) {
|
if(is_null($locale)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Load translation
|
// Load translation
|
||||||
putenv("LC_ALL=$locale");
|
putenv("LC_ALL=$locale");
|
||||||
setlocale(LC_ALL, $locale);
|
setlocale(LC_ALL, $locale);
|
||||||
bindtextdomain($domain, ROOT.DS.\nre\configs\AppConfig::$dirs['locale']);
|
bindtextdomain($domain, ROOT.DS.\nre\configs\AppConfig::$dirs['locale']);
|
||||||
textdomain($domain);
|
textdomain($domain);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
|
||||||
|
|
@ -1,51 +1,51 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Legend of Z
|
* The Legend of Z
|
||||||
*
|
*
|
||||||
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
||||||
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
|
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
|
||||||
* @license http://www.gnu.org/licenses/gpl.html
|
* @license http://www.gnu.org/licenses/gpl.html
|
||||||
* @link https://bitbucket.org/coderkun/the-legend-of-z
|
* @link https://bitbucket.org/coderkun/the-legend-of-z
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace hhu\z\agents\toplevel;
|
namespace hhu\z\agents\toplevel;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Agent to display binary data (e. g. images).
|
* Agent to display binary data (e. g. images).
|
||||||
*
|
*
|
||||||
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
||||||
*/
|
*/
|
||||||
class BinaryAgent extends \hhu\z\agents\ToplevelAgent
|
class BinaryAgent extends \hhu\z\agents\ToplevelAgent
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Construct a new BinaryAgent.
|
* Construct a new BinaryAgent.
|
||||||
*
|
*
|
||||||
* @param \nre\core\Request $request Current request
|
* @param \nre\core\Request $request Current request
|
||||||
* @param \nre\core\Response $response Current response
|
* @param \nre\core\Response $response Current response
|
||||||
* @param \nre\core\Logger $log Logger instance
|
* @param \nre\core\Logger $log Logger instance
|
||||||
*/
|
*/
|
||||||
protected function __construct(\nre\core\Request $request, \nre\core\Response $response, \nre\core\Logger $log=null)
|
protected function __construct(\nre\core\Request $request, \nre\core\Response $response, \nre\core\Logger $log=null)
|
||||||
{
|
{
|
||||||
parent::__construct($request, $response, $log);
|
parent::__construct($request, $response, $log);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Action: index.
|
* Action: index.
|
||||||
*
|
*
|
||||||
* @param \nre\core\Request $request Current request
|
* @param \nre\core\Request $request Current request
|
||||||
* @param \nre\core\Response $response Current response
|
* @param \nre\core\Response $response Current response
|
||||||
*/
|
*/
|
||||||
public function index(\nre\core\Request $request, \nre\core\Response $response)
|
public function index(\nre\core\Request $request, \nre\core\Response $response)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
|
||||||
|
|
@ -1,38 +1,38 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Legend of Z
|
* The Legend of Z
|
||||||
*
|
*
|
||||||
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
||||||
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
|
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
|
||||||
* @license http://www.gnu.org/licenses/gpl.html
|
* @license http://www.gnu.org/licenses/gpl.html
|
||||||
* @link https://bitbucket.org/coderkun/the-legend-of-z
|
* @link https://bitbucket.org/coderkun/the-legend-of-z
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace hhu\z\agents\toplevel;
|
namespace hhu\z\agents\toplevel;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Agent to display a toplevel error page.
|
* Agent to display a toplevel error page.
|
||||||
*
|
*
|
||||||
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
||||||
*/
|
*/
|
||||||
class FaultAgent extends \nre\agents\ToplevelAgent
|
class FaultAgent extends \nre\agents\ToplevelAgent
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Action: index.
|
* Action: index.
|
||||||
*
|
*
|
||||||
* @param \nre\core\Request $request Current request
|
* @param \nre\core\Request $request Current request
|
||||||
* @param \nre\core\Response $response Current response
|
* @param \nre\core\Response $response Current response
|
||||||
*/
|
*/
|
||||||
public function index(\nre\core\Request $request, \nre\core\Response $response)
|
public function index(\nre\core\Request $request, \nre\core\Response $response)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
|
||||||
|
|
@ -1,58 +1,58 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Legend of Z
|
* The Legend of Z
|
||||||
*
|
*
|
||||||
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
||||||
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
|
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
|
||||||
* @license http://www.gnu.org/licenses/gpl.html
|
* @license http://www.gnu.org/licenses/gpl.html
|
||||||
* @link https://bitbucket.org/coderkun/the-legend-of-z
|
* @link https://bitbucket.org/coderkun/the-legend-of-z
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace hhu\z\agents\toplevel;
|
namespace hhu\z\agents\toplevel;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Agent to display a HTML-page.
|
* Agent to display a HTML-page.
|
||||||
*
|
*
|
||||||
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
||||||
*/
|
*/
|
||||||
class HtmlAgent extends \hhu\z\agents\ToplevelAgent
|
class HtmlAgent extends \hhu\z\agents\ToplevelAgent
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Construct a new HtmlAgent.
|
* Construct a new HtmlAgent.
|
||||||
*
|
*
|
||||||
* @param \nre\core\Request $request Current request
|
* @param \nre\core\Request $request Current request
|
||||||
* @param \nre\core\Response $response Current response
|
* @param \nre\core\Response $response Current response
|
||||||
* @param \nre\core\Logger $log Logger instance
|
* @param \nre\core\Logger $log Logger instance
|
||||||
*/
|
*/
|
||||||
protected function __construct(\nre\core\Request $request, \nre\core\Response $response, \nre\core\Logger $log=null)
|
protected function __construct(\nre\core\Request $request, \nre\core\Response $response, \nre\core\Logger $log=null)
|
||||||
{
|
{
|
||||||
parent::__construct($request, $response, $log);
|
parent::__construct($request, $response, $log);
|
||||||
|
|
||||||
|
|
||||||
$this->setLanguage($request);
|
$this->setLanguage($request);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Action: index.
|
* Action: index.
|
||||||
*
|
*
|
||||||
* @param \nre\core\Request $request Current request
|
* @param \nre\core\Request $request Current request
|
||||||
* @param \nre\core\Response $response Current response
|
* @param \nre\core\Response $response Current response
|
||||||
*/
|
*/
|
||||||
public function index(\nre\core\Request $request, \nre\core\Response $response)
|
public function index(\nre\core\Request $request, \nre\core\Response $response)
|
||||||
{
|
{
|
||||||
// Add menu
|
// Add menu
|
||||||
$this->addSubAgent('Menu');
|
$this->addSubAgent('Menu');
|
||||||
|
|
||||||
// Add Seminary sidebar
|
// Add Seminary sidebar
|
||||||
$this->addSubAgent('Seminarybar');
|
$this->addSubAgent('Seminarybar');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,52 +1,52 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Legend of Z
|
* The Legend of Z
|
||||||
*
|
*
|
||||||
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
||||||
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
|
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
|
||||||
* @license http://www.gnu.org/licenses/gpl.html
|
* @license http://www.gnu.org/licenses/gpl.html
|
||||||
* @link https://bitbucket.org/coderkun/the-legend-of-z
|
* @link https://bitbucket.org/coderkun/the-legend-of-z
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace hhu\z\agents\toplevel;
|
namespace hhu\z\agents\toplevel;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Agent for generating a HTML-mail message.
|
* Agent for generating a HTML-mail message.
|
||||||
*
|
*
|
||||||
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
||||||
*/
|
*/
|
||||||
class HtmlmailAgent extends \hhu\z\agents\ToplevelAgent
|
class HtmlmailAgent extends \hhu\z\agents\ToplevelAgent
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Construct a new HtmlmailAgent.
|
* Construct a new HtmlmailAgent.
|
||||||
*
|
*
|
||||||
* @param \nre\core\Request $request Current request
|
* @param \nre\core\Request $request Current request
|
||||||
* @param \nre\core\Response $response Current response
|
* @param \nre\core\Response $response Current response
|
||||||
* @param \nre\core\Logger $log Logger instance
|
* @param \nre\core\Logger $log Logger instance
|
||||||
*/
|
*/
|
||||||
protected function __construct(\nre\core\Request $request, \nre\core\Response $response, \nre\core\Logger $log=null)
|
protected function __construct(\nre\core\Request $request, \nre\core\Response $response, \nre\core\Logger $log=null)
|
||||||
{
|
{
|
||||||
parent::__construct($request, $response, $log);
|
parent::__construct($request, $response, $log);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Action: index.
|
* Action: index.
|
||||||
*
|
*
|
||||||
* @param \nre\core\Request $request Current request
|
* @param \nre\core\Request $request Current request
|
||||||
* @param \nre\core\Response $response Current response
|
* @param \nre\core\Response $response Current response
|
||||||
*/
|
*/
|
||||||
public function index(\nre\core\Request $request, \nre\core\Response $response)
|
public function index(\nre\core\Request $request, \nre\core\Response $response)
|
||||||
{
|
{
|
||||||
$this->addSubagent('mailreceiver', 'index', $request->getParam(3));
|
$this->addSubagent('mailreceiver', 'index', $request->getParam(3));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
|
||||||
|
|
@ -1,54 +1,53 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Legend of Z
|
* The Legend of Z
|
||||||
*
|
*
|
||||||
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
||||||
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
|
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
|
||||||
* @license http://www.gnu.org/licenses/gpl.html
|
* @license http://www.gnu.org/licenses/gpl.html
|
||||||
* @link https://bitbucket.org/coderkun/the-legend-of-z
|
* @link https://bitbucket.org/coderkun/the-legend-of-z
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace hhu\z\agents\toplevel;
|
namespace hhu\z\agents\toplevel;
|
||||||
|
|
||||||
|
/**
|
||||||
/**
|
* Agent for generating a simple text-mail message.
|
||||||
* Agent for generating a simple text-mail message.
|
*
|
||||||
*
|
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
||||||
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
*/
|
||||||
*/
|
class TextmailAgent extends \hhu\z\agents\ToplevelAgent
|
||||||
class TextmailAgent extends \hhu\z\agents\ToplevelAgent
|
{
|
||||||
{
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
/**
|
* Construct a new TextmailAgent.
|
||||||
* Construct a new TextmailAgent.
|
*
|
||||||
*
|
* @param \nre\core\Request $request Current request
|
||||||
* @param \nre\core\Request $request Current request
|
* @param \nre\core\Response $response Current response
|
||||||
* @param \nre\core\Response $response Current response
|
* @param \nre\core\Logger $log Logger instance
|
||||||
* @param \nre\core\Logger $log Logger instance
|
*/
|
||||||
*/
|
protected function __construct(\nre\core\Request $request, \nre\core\Response $response, \nre\core\Logger $log=null)
|
||||||
protected function __construct(\nre\core\Request $request, \nre\core\Response $response, \nre\core\Logger $log=null)
|
{
|
||||||
{
|
parent::__construct($request, $response, $log);
|
||||||
parent::__construct($request, $response, $log);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
/**
|
* Action: index.
|
||||||
* Action: index.
|
*
|
||||||
*
|
* @param \nre\core\Request $request Current request
|
||||||
* @param \nre\core\Request $request Current request
|
* @param \nre\core\Response $response Current response
|
||||||
* @param \nre\core\Response $response Current response
|
*/
|
||||||
*/
|
public function index(\nre\core\Request $request, \nre\core\Response $response)
|
||||||
public function index(\nre\core\Request $request, \nre\core\Response $response)
|
{
|
||||||
{
|
$this->addSubagent('mailreceiver', 'index', $request->getParam(3));
|
||||||
$this->addSubagent('mailreceiver', 'index', $request->getParam(3));
|
}
|
||||||
}
|
|
||||||
|
}
|
||||||
}
|
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
|
||||||
|
|
@ -1,134 +1,134 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Legend of Z
|
* The Legend of Z
|
||||||
*
|
*
|
||||||
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
||||||
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
|
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
|
||||||
* @license http://www.gnu.org/licenses/gpl.html
|
* @license http://www.gnu.org/licenses/gpl.html
|
||||||
* @link https://bitbucket.org/coderkun/the-legend-of-z
|
* @link https://bitbucket.org/coderkun/the-legend-of-z
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace hhu\z;
|
namespace hhu\z;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Abstract class for implementing an application Controller.
|
* Abstract class for implementing an application Controller.
|
||||||
*
|
*
|
||||||
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
||||||
*/
|
*/
|
||||||
abstract class Controller extends \nre\core\Controller
|
abstract class Controller extends \nre\core\Controller
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Required components
|
* Required components
|
||||||
*
|
*
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
public $components = array('auth');
|
public $components = array('auth');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Logger instance
|
* Logger instance
|
||||||
*
|
*
|
||||||
* @var \nre\core\Logger
|
* @var \nre\core\Logger
|
||||||
*/
|
*/
|
||||||
protected $log = null;
|
protected $log = null;
|
||||||
/**
|
/**
|
||||||
* Linker instance
|
* Linker instance
|
||||||
*
|
*
|
||||||
* @var \nre\core\Linker
|
* @var \nre\core\Linker
|
||||||
*/
|
*/
|
||||||
protected $linker = null;
|
protected $linker = null;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Construct a new application Controller.
|
* Construct a new application Controller.
|
||||||
*
|
*
|
||||||
* @throws \nre\exceptions\DriverNotFoundException
|
* @throws \nre\exceptions\DriverNotFoundException
|
||||||
* @throws \nre\exceptions\DriverNotValidException
|
* @throws \nre\exceptions\DriverNotValidException
|
||||||
* @throws \nre\exceptions\ModelNotValidException
|
* @throws \nre\exceptions\ModelNotValidException
|
||||||
* @throws \nre\exceptions\ModelNotFoundException
|
* @throws \nre\exceptions\ModelNotFoundException
|
||||||
* @throws \nre\exceptions\ViewNotFoundException
|
* @throws \nre\exceptions\ViewNotFoundException
|
||||||
* @param string $layoutName Name of the current Layout
|
* @param string $layoutName Name of the current Layout
|
||||||
* @param string $action Current Action
|
* @param string $action Current Action
|
||||||
* @param \nre\core\Agent $agent Corresponding Agent
|
* @param \nre\core\Agent $agent Corresponding Agent
|
||||||
*/
|
*/
|
||||||
public function __construct($layoutName, $action, $agent)
|
public function __construct($layoutName, $action, $agent)
|
||||||
{
|
{
|
||||||
parent::__construct($layoutName, $action, $agent);
|
parent::__construct($layoutName, $action, $agent);
|
||||||
|
|
||||||
// Create logger
|
// Create logger
|
||||||
$this->log = new \nre\core\Logger();
|
$this->log = new \nre\core\Logger();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Prefilter that is executed before running the Controller.
|
* Prefilter that is executed before running the Controller.
|
||||||
*
|
*
|
||||||
* @param \nre\core\Request $request Current request
|
* @param \nre\core\Request $request Current request
|
||||||
* @param \nre\core\Response $response Current response
|
* @param \nre\core\Response $response Current response
|
||||||
*/
|
*/
|
||||||
public function preFilter(\nre\core\Request $request, \nre\core\Response $response)
|
public function preFilter(\nre\core\Request $request, \nre\core\Response $response)
|
||||||
{
|
{
|
||||||
parent::preFilter($request, $response);
|
parent::preFilter($request, $response);
|
||||||
|
|
||||||
// Create linker
|
// Create linker
|
||||||
$this->linker = new \nre\core\Linker($request);
|
$this->linker = new \nre\core\Linker($request);
|
||||||
$this->set('linker', $this->linker);
|
$this->set('linker', $this->linker);
|
||||||
|
|
||||||
// Create text formatter
|
// Create text formatter
|
||||||
$this->set('t', new \hhu\z\TextFormatter($this->linker));
|
$this->set('t', new \hhu\z\TextFormatter($this->linker));
|
||||||
|
|
||||||
// Create date and time and number formatter
|
// Create date and time and number formatter
|
||||||
$this->set('dateFormatter', new \IntlDateFormatter(
|
$this->set('dateFormatter', new \IntlDateFormatter(
|
||||||
//\nre\core\Config::getDefault('locale'),
|
//\nre\core\Config::getDefault('locale'),
|
||||||
\Locale::getDefault(),
|
\Locale::getDefault(),
|
||||||
\IntlDateFormatter::MEDIUM,
|
\IntlDateFormatter::MEDIUM,
|
||||||
\IntlDateFormatter::NONE,
|
\IntlDateFormatter::NONE,
|
||||||
NULL
|
NULL
|
||||||
));
|
));
|
||||||
$this->set('timeFormatter', new \IntlDateFormatter(
|
$this->set('timeFormatter', new \IntlDateFormatter(
|
||||||
//\nre\core\Config::getDefault('locale'),
|
//\nre\core\Config::getDefault('locale'),
|
||||||
\Locale::getDefault(),
|
\Locale::getDefault(),
|
||||||
\IntlDateFormatter::NONE,
|
\IntlDateFormatter::NONE,
|
||||||
\IntlDateFormatter::SHORT,
|
\IntlDateFormatter::SHORT,
|
||||||
NULL
|
NULL
|
||||||
));
|
));
|
||||||
$this->set('numberFormatter', new \NumberFormatter(
|
$this->set('numberFormatter', new \NumberFormatter(
|
||||||
//\nre\core\Config::getDefault('locale'),
|
//\nre\core\Config::getDefault('locale'),
|
||||||
\Locale::getDefault(),
|
\Locale::getDefault(),
|
||||||
\NumberFormatter::DEFAULT_STYLE
|
\NumberFormatter::DEFAULT_STYLE
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Postfilter that is executed after running the Controller.
|
* Postfilter that is executed after running the Controller.
|
||||||
*
|
*
|
||||||
* @param \nre\core\Request $request Current request
|
* @param \nre\core\Request $request Current request
|
||||||
* @param \nre\core\Response $response Current response
|
* @param \nre\core\Response $response Current response
|
||||||
*/
|
*/
|
||||||
public function postFilter(\nre\core\Request $request, \nre\core\Response $response)
|
public function postFilter(\nre\core\Request $request, \nre\core\Response $response)
|
||||||
{
|
{
|
||||||
parent::postFilter($request, $response);
|
parent::postFilter($request, $response);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Log an error.
|
* Log an error.
|
||||||
*
|
*
|
||||||
* @param string $message Error message to log
|
* @param string $message Error message to log
|
||||||
* @param int $logMode Log mode (optional)
|
* @param int $logMode Log mode (optional)
|
||||||
*/
|
*/
|
||||||
protected function log($message, $logMode=\nre\core\Logger::LOGMODE_AUTO)
|
protected function log($message, $logMode=\nre\core\Logger::LOGMODE_AUTO)
|
||||||
{
|
{
|
||||||
$this->log->log($message, $logMode);
|
$this->log->log($message, $logMode);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
|
||||||
|
|
@ -1,42 +1,42 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Legend of Z
|
* The Legend of Z
|
||||||
*
|
*
|
||||||
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
||||||
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
|
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
|
||||||
* @license http://www.gnu.org/licenses/gpl.html
|
* @license http://www.gnu.org/licenses/gpl.html
|
||||||
* @link https://bitbucket.org/coderkun/the-legend-of-z
|
* @link https://bitbucket.org/coderkun/the-legend-of-z
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace hhu\z;
|
namespace hhu\z;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Abstract class for implementing an application Model.
|
* Abstract class for implementing an application Model.
|
||||||
*
|
*
|
||||||
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
||||||
*/
|
*/
|
||||||
class Model extends \nre\models\DatabaseModel
|
class Model extends \nre\models\DatabaseModel
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Construct a new application Model.
|
* Construct a new application Model.
|
||||||
*
|
*
|
||||||
* @throws \nre\exceptions\DatamodelException
|
* @throws \nre\exceptions\DatamodelException
|
||||||
* @throws \nre\exceptions\DriverNotFoundException
|
* @throws \nre\exceptions\DriverNotFoundException
|
||||||
* @throws \nre\exceptions\DriverNotValidException
|
* @throws \nre\exceptions\DriverNotValidException
|
||||||
* @throws \nre\exceptions\ModelNotValidException
|
* @throws \nre\exceptions\ModelNotValidException
|
||||||
* @throws \nre\exceptions\ModelNotFoundException
|
* @throws \nre\exceptions\ModelNotFoundException
|
||||||
*/
|
*/
|
||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
parent::__construct('mysqli', \nre\configs\AppConfig::$database);
|
parent::__construct('mysqli', \nre\configs\AppConfig::$database);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
|
||||||
|
|
@ -1,149 +1,149 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Legend of Z
|
* The Legend of Z
|
||||||
*
|
*
|
||||||
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
||||||
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
|
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
|
||||||
* @license http://www.gnu.org/licenses/gpl.html
|
* @license http://www.gnu.org/licenses/gpl.html
|
||||||
* @link https://bitbucket.org/coderkun/the-legend-of-z
|
* @link https://bitbucket.org/coderkun/the-legend-of-z
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace hhu\z;
|
namespace hhu\z;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class to format text with different syntax tags.
|
* Class to format text with different syntax tags.
|
||||||
*
|
*
|
||||||
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
||||||
*/
|
*/
|
||||||
class TextFormatter
|
class TextFormatter
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Linker to create links.
|
* Linker to create links.
|
||||||
*
|
*
|
||||||
* @var \nre\core\Linker
|
* @var \nre\core\Linker
|
||||||
*/
|
*/
|
||||||
private $linker;
|
private $linker;
|
||||||
/**
|
/**
|
||||||
* Media-Model to retrieve media data
|
* Media-Model to retrieve media data
|
||||||
*
|
*
|
||||||
* @static
|
* @static
|
||||||
* @var \nre\core\Model
|
* @var \nre\core\Model
|
||||||
*/
|
*/
|
||||||
private static $Media = null;
|
private static $Media = null;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new text formatter.
|
* Create a new text formatter.
|
||||||
*
|
*
|
||||||
* @param \nre\core\Linker $linker Linker to create links with
|
* @param \nre\core\Linker $linker Linker to create links with
|
||||||
*/
|
*/
|
||||||
public function __construct(\nre\core\Linker $linker)
|
public function __construct(\nre\core\Linker $linker)
|
||||||
{
|
{
|
||||||
$this->linker = $linker;
|
$this->linker = $linker;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Format a string.
|
* Format a string.
|
||||||
*
|
*
|
||||||
* @param string $string String to format
|
* @param string $string String to format
|
||||||
* @return string Formatted string
|
* @return string Formatted string
|
||||||
*/
|
*/
|
||||||
public function t($string)
|
public function t($string)
|
||||||
{
|
{
|
||||||
// Remove chars
|
// Remove chars
|
||||||
$string = htmlspecialchars($string, ENT_NOQUOTES);
|
$string = htmlspecialchars($string, ENT_NOQUOTES);
|
||||||
|
|
||||||
// Important text
|
// Important text
|
||||||
$string = str_replace('[strong]', '<strong>', $string);
|
$string = str_replace('[strong]', '<strong>', $string);
|
||||||
$string = str_replace('[/strong]', '</strong>', $string);
|
$string = str_replace('[/strong]', '</strong>', $string);
|
||||||
|
|
||||||
// Create tables
|
// Create tables
|
||||||
$string = preg_replace('/(\[table\])\s+/u', '$1', $string);
|
$string = preg_replace('/(\[table\])\s+/u', '$1', $string);
|
||||||
$string = preg_replace('/\s*(\[tr\])\s*/u', '$1', $string);
|
$string = preg_replace('/\s*(\[tr\])\s*/u', '$1', $string);
|
||||||
$string = preg_replace('%\s+(\[/table\])%u', '$1', $string);
|
$string = preg_replace('%\s+(\[/table\])%u', '$1', $string);
|
||||||
$string = preg_replace('%\s*(\[/tr\])\s*%u', '$1', $string);
|
$string = preg_replace('%\s*(\[/tr\])\s*%u', '$1', $string);
|
||||||
$string = str_replace('[table]', '</p><table>', $string);
|
$string = str_replace('[table]', '</p><table>', $string);
|
||||||
$string = str_replace('[/table]', '</table><p>', $string);
|
$string = str_replace('[/table]', '</table><p>', $string);
|
||||||
$string = str_replace('[tr]', '<tr>', $string);
|
$string = str_replace('[tr]', '<tr>', $string);
|
||||||
$string = str_replace('[/tr]', '</tr>', $string);
|
$string = str_replace('[/tr]', '</tr>', $string);
|
||||||
$string = str_replace('[th]', '<th>', $string);
|
$string = str_replace('[th]', '<th>', $string);
|
||||||
$string = str_replace('[/th]', '</th>', $string);
|
$string = str_replace('[/th]', '</th>', $string);
|
||||||
$string = str_replace('[td]', '<td>', $string);
|
$string = str_replace('[td]', '<td>', $string);
|
||||||
$string = str_replace('[/td]', '</td>', $string);
|
$string = str_replace('[/td]', '</td>', $string);
|
||||||
|
|
||||||
// Create links
|
// Create links
|
||||||
$string = preg_replace('!(^|\s)"([^"]+)":(https?://[^\s]+)(\s|$)!i', '$1<a href="$3">$2</a>$4', $string);
|
$string = preg_replace('!(^|\s)"([^"]+)":(https?://[^\s]+)(\s|$)!i', '$1<a href="$3">$2</a>$4', $string);
|
||||||
$string = preg_replace('!(^|\s)(https?://[^\s]+)(\s|$)!i', '$1<a href="$2">$2</a>$3', $string);
|
$string = preg_replace('!(^|\s)(https?://[^\s]+)(\s|$)!i', '$1<a href="$2">$2</a>$3', $string);
|
||||||
|
|
||||||
// Handle Seminarymedia
|
// Handle Seminarymedia
|
||||||
$seminarymedia = array();
|
$seminarymedia = array();
|
||||||
preg_match_all('/\[seminarymedia:(\d+)\]/iu', $string, $matches); //, PREG_SET_ORDER | PREG_OFFSET_CAPTURE);
|
preg_match_all('/\[seminarymedia:(\d+)\]/iu', $string, $matches); //, PREG_SET_ORDER | PREG_OFFSET_CAPTURE);
|
||||||
$seminarymediaIds = array_unique($matches[1]);
|
$seminarymediaIds = array_unique($matches[1]);
|
||||||
foreach($seminarymediaIds as &$seminarymediaId)
|
foreach($seminarymediaIds as &$seminarymediaId)
|
||||||
{
|
{
|
||||||
$replacement = null;
|
$replacement = null;
|
||||||
if(!is_null(\hhu\z\controllers\SeminaryController::$seminary) && $this->loadMediaModel())
|
if(!is_null(\hhu\z\controllers\SeminaryController::$seminary) && $this->loadMediaModel())
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
$medium = self::$Media->getSeminaryMediaById($seminarymediaId);
|
$medium = self::$Media->getSeminaryMediaById($seminarymediaId);
|
||||||
$replacement = sprintf(
|
$replacement = sprintf(
|
||||||
'<img src="%s" alt="%s" />',
|
'<img src="%s" alt="%s" />',
|
||||||
$this->linker->link(array('media','seminary', \hhu\z\controllers\SeminaryController::$seminary['url'],$medium['url'])),
|
$this->linker->link(array('media','seminary', \hhu\z\controllers\SeminaryController::$seminary['url'],$medium['url'])),
|
||||||
$medium['description']
|
$medium['description']
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
catch(\nre\exceptions\IdNotFoundException $e) {
|
catch(\nre\exceptions\IdNotFoundException $e) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$seminarymedia[$seminarymediaId] = $replacement;
|
$seminarymedia[$seminarymediaId] = $replacement;
|
||||||
}
|
}
|
||||||
foreach($seminarymedia as $seminarymediaId => $replacement) {
|
foreach($seminarymedia as $seminarymediaId => $replacement) {
|
||||||
$string = str_replace("[seminarymedia:$seminarymediaId]", $replacement, $string);
|
$string = str_replace("[seminarymedia:$seminarymediaId]", $replacement, $string);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Return processed string
|
// Return processed string
|
||||||
return nl2br($string);
|
return nl2br($string);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Load the Media-Model if it is not loaded
|
* Load the Media-Model if it is not loaded
|
||||||
*
|
*
|
||||||
* @return boolean Whether the Media-Model has been loaded or not
|
* @return boolean Whether the Media-Model has been loaded or not
|
||||||
*/
|
*/
|
||||||
private function loadMediaModel()
|
private function loadMediaModel()
|
||||||
{
|
{
|
||||||
// Do not load Model if it has already been loaded
|
// Do not load Model if it has already been loaded
|
||||||
if(!is_null(self::$Media)) {
|
if(!is_null(self::$Media)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// Load class
|
// Load class
|
||||||
Model::load('media');
|
Model::load('media');
|
||||||
|
|
||||||
// Construct Model
|
// Construct Model
|
||||||
self::$Media = Model::factory('media');
|
self::$Media = Model::factory('media');
|
||||||
}
|
}
|
||||||
catch(\Exception $e) {
|
catch(\Exception $e) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Return whether Media-Model has been loaded or not
|
// Return whether Media-Model has been loaded or not
|
||||||
return !is_null(self::$Media);
|
return !is_null(self::$Media);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
|
||||||
420
app/Utils.inc
420
app/Utils.inc
|
|
@ -1,214 +1,214 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Legend of Z
|
* The Legend of Z
|
||||||
*
|
*
|
||||||
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
||||||
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
|
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
|
||||||
* @license http://www.gnu.org/licenses/gpl.html
|
* @license http://www.gnu.org/licenses/gpl.html
|
||||||
* @link https://bitbucket.org/coderkun/the-legend-of-z
|
* @link https://bitbucket.org/coderkun/the-legend-of-z
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace hhu\z;
|
namespace hhu\z;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class for implementing utility methods.
|
* Class for implementing utility methods.
|
||||||
*
|
*
|
||||||
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
||||||
*/
|
*/
|
||||||
class Utils
|
class Utils
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Mask HTML-chars for save output.
|
* Mask HTML-chars for save output.
|
||||||
*
|
*
|
||||||
* @static
|
* @static
|
||||||
* @param string $string String to be masked
|
* @param string $string String to be masked
|
||||||
* @return string Masked string
|
* @return string Masked string
|
||||||
*/
|
*/
|
||||||
public static function t($string)
|
public static function t($string)
|
||||||
{
|
{
|
||||||
return nl2br(htmlspecialchars($string));
|
return nl2br(htmlspecialchars($string));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ‚htmlspecialchars‘ with support for UTF-8.
|
* ‚htmlspecialchars‘ with support for UTF-8.
|
||||||
*
|
*
|
||||||
* @static
|
* @static
|
||||||
* @param string $string String to be masked
|
* @param string $string String to be masked
|
||||||
* @return string Masked string
|
* @return string Masked string
|
||||||
*/
|
*/
|
||||||
public static function htmlspecialchars_utf8($string)
|
public static function htmlspecialchars_utf8($string)
|
||||||
{
|
{
|
||||||
return htmlspecialchars($string, ENT_COMPAT, 'UTF-8');
|
return htmlspecialchars($string, ENT_COMPAT, 'UTF-8');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Cut a string to the given length but only word boundaries.
|
* Cut a string to the given length but only word boundaries.
|
||||||
*
|
*
|
||||||
* @static
|
* @static
|
||||||
* @param string $string String to cut
|
* @param string $string String to cut
|
||||||
* @param int $length Length to cut string
|
* @param int $length Length to cut string
|
||||||
* @param int $scope Maximum length to cut string regardless word boundaries
|
* @param int $scope Maximum length to cut string regardless word boundaries
|
||||||
* @return string Cutted string
|
* @return string Cutted string
|
||||||
*/
|
*/
|
||||||
public static function shortenString($string, $length, $scope)
|
public static function shortenString($string, $length, $scope)
|
||||||
{
|
{
|
||||||
// Determine length
|
// Determine length
|
||||||
$length = min($length, strlen($string));
|
$length = min($length, strlen($string));
|
||||||
|
|
||||||
// Look for word boundary
|
// Look for word boundary
|
||||||
if(($pos = strpos($string, ' ', $length)) !== false)
|
if(($pos = strpos($string, ' ', $length)) !== false)
|
||||||
{
|
{
|
||||||
// Check if boundary is outside of scope
|
// Check if boundary is outside of scope
|
||||||
if($pos > $length + $scope) {
|
if($pos > $length + $scope) {
|
||||||
$pos = strrpos(substr($string, 0, $pos), ' ');
|
$pos = strrpos(substr($string, 0, $pos), ' ');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$pos = strlen($string);
|
$pos = strlen($string);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Cut string and return it
|
// Cut string and return it
|
||||||
return substr($string, 0, $pos);
|
return substr($string, 0, $pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Send an e‑mail.
|
* Send an e‑mail.
|
||||||
*
|
*
|
||||||
* @throws \hhu\z\exceptions\MailingException
|
* @throws \hhu\z\exceptions\MailingException
|
||||||
* @param mixed $to One (string) or many (array) receivers
|
* @param mixed $to One (string) or many (array) receivers
|
||||||
* @param string $messageAction Message Action
|
* @param string $messageAction Message Action
|
||||||
* @param boolean $html Whether mail should be formatted as HTML or not
|
* @param boolean $html Whether mail should be formatted as HTML or not
|
||||||
* @param array $params Parameters to pass
|
* @param array $params Parameters to pass
|
||||||
* @param \nre\core\Linker $linker Linker instance
|
* @param \nre\core\Linker $linker Linker instance
|
||||||
*/
|
*/
|
||||||
public static function sendMail($to, $messageAction, $html=false, $params=null, $linker=null)
|
public static function sendMail($to, $messageAction, $html=false, $params=null, $linker=null)
|
||||||
{
|
{
|
||||||
// Check configuration
|
// Check configuration
|
||||||
if(
|
if(
|
||||||
empty(\nre\configs\AppConfig::$mail['host']) ||
|
empty(\nre\configs\AppConfig::$mail['host']) ||
|
||||||
empty(\nre\configs\AppConfig::$mail['port']) ||
|
empty(\nre\configs\AppConfig::$mail['port']) ||
|
||||||
empty(\nre\configs\AppConfig::$mail['username'])
|
empty(\nre\configs\AppConfig::$mail['username'])
|
||||||
) {
|
) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Load classes
|
// Load classes
|
||||||
\hhu\z\lib\PHPMailerAutoload::load();
|
\hhu\z\lib\PHPMailerAutoload::load();
|
||||||
\hhu\z\lib\PHPMailer::load();
|
\hhu\z\lib\PHPMailer::load();
|
||||||
\hhu\z\lib\SMTP::load();
|
\hhu\z\lib\SMTP::load();
|
||||||
|
|
||||||
// Create mailer
|
// Create mailer
|
||||||
$mail = new \PHPMailer();
|
$mail = new \PHPMailer();
|
||||||
|
|
||||||
// Configure mailer
|
// Configure mailer
|
||||||
$mail->isSMTP();
|
$mail->isSMTP();
|
||||||
$mail->Host = \nre\configs\AppConfig::$mail['host'];
|
$mail->Host = \nre\configs\AppConfig::$mail['host'];
|
||||||
$mail->Port = \nre\configs\AppConfig::$mail['port'];
|
$mail->Port = \nre\configs\AppConfig::$mail['port'];
|
||||||
$mail->SMTPAuth = true;
|
$mail->SMTPAuth = true;
|
||||||
$mail->Username = \nre\configs\AppConfig::$mail['username'];
|
$mail->Username = \nre\configs\AppConfig::$mail['username'];
|
||||||
$mail->Password = \nre\configs\AppConfig::$mail['password'];
|
$mail->Password = \nre\configs\AppConfig::$mail['password'];
|
||||||
$mail->SMTPSecure = \nre\configs\AppConfig::$mail['secure'];
|
$mail->SMTPSecure = \nre\configs\AppConfig::$mail['secure'];
|
||||||
|
|
||||||
// Set properties
|
// Set properties
|
||||||
$mail->CharSet = 'UTF-8';
|
$mail->CharSet = 'UTF-8';
|
||||||
$mail->From = \nre\configs\AppConfig::$app['mailsender'];
|
$mail->From = \nre\configs\AppConfig::$app['mailsender'];
|
||||||
$mail->FromName = \nre\configs\AppConfig::$app['name'];
|
$mail->FromName = \nre\configs\AppConfig::$app['name'];
|
||||||
if(!is_array($to)) {
|
if(!is_array($to)) {
|
||||||
$to = array($to);
|
$to = array($to);
|
||||||
}
|
}
|
||||||
foreach($to as &$receiver) {
|
foreach($to as &$receiver) {
|
||||||
$mail->addAddress($receiver);
|
$mail->addAddress($receiver);
|
||||||
}
|
}
|
||||||
if($html) {
|
if($html) {
|
||||||
$mail->isHTML(true);
|
$mail->isHTML(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create message
|
// Create message
|
||||||
try {
|
try {
|
||||||
// Create MailApi
|
// Create MailApi
|
||||||
$mailApi = new \hhu\z\apis\MailApi();
|
$mailApi = new \hhu\z\apis\MailApi();
|
||||||
if(!is_null($linker)) {
|
if(!is_null($linker)) {
|
||||||
$mailApi->setLinker($linker);
|
$mailApi->setLinker($linker);
|
||||||
}
|
}
|
||||||
$mailApi->setMessage($messageAction);
|
$mailApi->setMessage($messageAction);
|
||||||
$mailApi->setParams($params);
|
$mailApi->setParams($params);
|
||||||
if($html) {
|
if($html) {
|
||||||
$mailApi->setHTML();
|
$mailApi->setHTML();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Render message
|
// Render message
|
||||||
$exception = $mailApi->run();
|
$exception = $mailApi->run();
|
||||||
if(!is_null($exception)) {
|
if(!is_null($exception)) {
|
||||||
return $exception;
|
return $exception;
|
||||||
}
|
}
|
||||||
$mail->Subject = $mailApi->getSubject();
|
$mail->Subject = $mailApi->getSubject();
|
||||||
$mail->Body = $mailApi->render();
|
$mail->Body = $mailApi->render();
|
||||||
|
|
||||||
// Try to render alternativ plaintext message
|
// Try to render alternativ plaintext message
|
||||||
if($html)
|
if($html)
|
||||||
{
|
{
|
||||||
$mailApi->setHTML(false);
|
$mailApi->setHTML(false);
|
||||||
|
|
||||||
// Render message
|
// Render message
|
||||||
$exception = $mailApi->run();
|
$exception = $mailApi->run();
|
||||||
if(is_null($exception))
|
if(is_null($exception))
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
$mail->AltBody = $mailApi->render();
|
$mail->AltBody = $mailApi->render();
|
||||||
}
|
}
|
||||||
catch(\nre\core\Exception $e) {
|
catch(\nre\core\Exception $e) {
|
||||||
// No alternative plaintext available
|
// No alternative plaintext available
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch(\nre\core\Exception $e) {
|
catch(\nre\core\Exception $e) {
|
||||||
throw new \hhu\z\exceptions\MailingException($e->getMessage());
|
throw new \hhu\z\exceptions\MailingException($e->getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Return status
|
// Return status
|
||||||
if(!$mail->send()) {
|
if(!$mail->send()) {
|
||||||
throw new \hhu\z\exceptions\MailingException($mail->ErrorInfo);
|
throw new \hhu\z\exceptions\MailingException($mail->ErrorInfo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Detect Mimetype of a file.
|
* Detect Mimetype of a file.
|
||||||
*
|
*
|
||||||
* @param string $filename Name of file to detect Mimetype of
|
* @param string $filename Name of file to detect Mimetype of
|
||||||
* @param string $defaultMimetype Default Mimetype to use
|
* @param string $defaultMimetype Default Mimetype to use
|
||||||
* @return string Detected Mimetype of file
|
* @return string Detected Mimetype of file
|
||||||
*/
|
*/
|
||||||
public static function getMimetype($filename, $defaultMimetype=null)
|
public static function getMimetype($filename, $defaultMimetype=null)
|
||||||
{
|
{
|
||||||
$mimetype = (!is_null($defaultMimetype)) ? $defaultMimetype : 'application/octet-stream';
|
$mimetype = (!is_null($defaultMimetype)) ? $defaultMimetype : 'application/octet-stream';
|
||||||
// Use Fileinfo
|
// Use Fileinfo
|
||||||
if(class_exists('\finfo'))
|
if(class_exists('\finfo'))
|
||||||
{
|
{
|
||||||
$finfo = new \finfo(FILEINFO_MIME_TYPE);
|
$finfo = new \finfo(FILEINFO_MIME_TYPE);
|
||||||
if(!is_null($finfo)) {
|
if(!is_null($finfo)) {
|
||||||
$mimetype = $finfo->file($filename);
|
$mimetype = $finfo->file($filename);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Use deprecated mime_content_type()
|
// Use deprecated mime_content_type()
|
||||||
elseif(function_exists('mime_content_type')) {
|
elseif(function_exists('mime_content_type')) {
|
||||||
$mimetype = mime_content_type($filename);
|
$mimetype = mime_content_type($filename);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return $mimetype;
|
return $mimetype;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
|
||||||
|
|
@ -1,268 +1,268 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Legend of Z
|
* The Legend of Z
|
||||||
*
|
*
|
||||||
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
||||||
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
|
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
|
||||||
* @license http://www.gnu.org/licenses/gpl.html
|
* @license http://www.gnu.org/licenses/gpl.html
|
||||||
* @link https://bitbucket.org/coderkun/the-legend-of-z
|
* @link https://bitbucket.org/coderkun/the-legend-of-z
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace hhu\z\agents;
|
namespace hhu\z\agents;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Abstract class for implementing a QuesttypeAgent.
|
* Abstract class for implementing a QuesttypeAgent.
|
||||||
*
|
*
|
||||||
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
||||||
*/
|
*/
|
||||||
abstract class QuesttypeAgent extends \nre\agents\BottomlevelAgent
|
abstract class QuesttypeAgent extends \nre\agents\BottomlevelAgent
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Current request
|
* Current request
|
||||||
*
|
*
|
||||||
* @var \nre\core\Request
|
* @var \nre\core\Request
|
||||||
*/
|
*/
|
||||||
private $request;
|
private $request;
|
||||||
/**
|
/**
|
||||||
* Current response
|
* Current response
|
||||||
*
|
*
|
||||||
* @var \nre\core\Response
|
* @var \nre\core\Response
|
||||||
*/
|
*/
|
||||||
private $response;
|
private $response;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Load a QuesttypeAgent.
|
* Load a QuesttypeAgent.
|
||||||
*
|
*
|
||||||
* @static
|
* @static
|
||||||
* @throws \hhu\z\exceptions\QuesttypeAgentNotFoundException
|
* @throws \hhu\z\exceptions\QuesttypeAgentNotFoundException
|
||||||
* @throws \hhu\z\exceptions\QuesttypeAgentNotValidException
|
* @throws \hhu\z\exceptions\QuesttypeAgentNotValidException
|
||||||
* @param string $questtypeName Name of the QuesttypeAgent to load
|
* @param string $questtypeName Name of the QuesttypeAgent to load
|
||||||
*/
|
*/
|
||||||
public static function load($questtypeName)
|
public static function load($questtypeName)
|
||||||
{
|
{
|
||||||
// Determine full classname
|
// Determine full classname
|
||||||
$className = self::getClassName($questtypeName);
|
$className = self::getClassName($questtypeName);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// Load class
|
// Load class
|
||||||
static::loadClass($questtypeName, $className);
|
static::loadClass($questtypeName, $className);
|
||||||
|
|
||||||
// Validate class
|
// Validate class
|
||||||
static::checkClass($className, get_class());
|
static::checkClass($className, get_class());
|
||||||
}
|
}
|
||||||
catch(\nre\exceptions\ClassNotValidException $e) {
|
catch(\nre\exceptions\ClassNotValidException $e) {
|
||||||
throw new \hhu\z\exceptions\QuesttypeAgentNotValidException($e->getClassName());
|
throw new \hhu\z\exceptions\QuesttypeAgentNotValidException($e->getClassName());
|
||||||
}
|
}
|
||||||
catch(\nre\exceptions\ClassNotFoundException $e) {
|
catch(\nre\exceptions\ClassNotFoundException $e) {
|
||||||
throw new \hhu\z\exceptions\QuesttypeAgentNotFoundException($e->getClassName());
|
throw new \hhu\z\exceptions\QuesttypeAgentNotFoundException($e->getClassName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Instantiate a QuesttypeAgent (Factory Pattern).
|
* Instantiate a QuesttypeAgent (Factory Pattern).
|
||||||
*
|
*
|
||||||
* @static
|
* @static
|
||||||
* @throws \nre\exceptions\DatamodelException
|
* @throws \nre\exceptions\DatamodelException
|
||||||
* @throws \nre\exceptions\DriverNotValidException
|
* @throws \nre\exceptions\DriverNotValidException
|
||||||
* @throws \nre\exceptions\DriverNotFoundException
|
* @throws \nre\exceptions\DriverNotFoundException
|
||||||
* @throws \nre\exceptions\ViewNotFoundException
|
* @throws \nre\exceptions\ViewNotFoundException
|
||||||
* @throws \hhu\z\exceptions\QuesttypeModelNotValidException
|
* @throws \hhu\z\exceptions\QuesttypeModelNotValidException
|
||||||
* @throws \hhu\z\exceptions\QuesttypeModelNotFoundException
|
* @throws \hhu\z\exceptions\QuesttypeModelNotFoundException
|
||||||
* @throws \hhu\z\exceptions\QuesttypeControllerNotValidException
|
* @throws \hhu\z\exceptions\QuesttypeControllerNotValidException
|
||||||
* @throws \hhu\z\exceptions\QuesttypeControllerNotFoundException
|
* @throws \hhu\z\exceptions\QuesttypeControllerNotFoundException
|
||||||
* @param string $questtypeName Name of the QuesttypeAgent to instantiate
|
* @param string $questtypeName Name of the QuesttypeAgent to instantiate
|
||||||
* @param Request $request Current request
|
* @param Request $request Current request
|
||||||
* @param Response $response Current respone
|
* @param Response $response Current respone
|
||||||
* @param Logger $log Log-system
|
* @param Logger $log Log-system
|
||||||
*/
|
*/
|
||||||
public static function factory($questtypeName, \nre\core\Request $request, \nre\core\Response $response, \nre\core\Logger $log=null)
|
public static function factory($questtypeName, \nre\core\Request $request, \nre\core\Response $response, \nre\core\Logger $log=null)
|
||||||
{
|
{
|
||||||
// Determine full classname
|
// Determine full classname
|
||||||
$className = self::getClassName($questtypeName);
|
$className = self::getClassName($questtypeName);
|
||||||
|
|
||||||
// Construct and return Questmodule
|
// Construct and return Questmodule
|
||||||
return new $className($request, $response, $log);
|
return new $className($request, $response, $log);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Determine the Agent-classname for the given Questtype-name.
|
* Determine the Agent-classname for the given Questtype-name.
|
||||||
*
|
*
|
||||||
* @static
|
* @static
|
||||||
* @param string $questtypeName Questtype-name to get Agent-classname of
|
* @param string $questtypeName Questtype-name to get Agent-classname of
|
||||||
* @param string $agentType Agent type of given Agent name
|
* @param string $agentType Agent type of given Agent name
|
||||||
* @return string Classname for the Questtype-name
|
* @return string Classname for the Questtype-name
|
||||||
*/
|
*/
|
||||||
private static function getClassName($questtypeName, $agentType=null)
|
private static function getClassName($questtypeName, $agentType=null)
|
||||||
{
|
{
|
||||||
$className = \nre\core\ClassLoader::concatClassNames($questtypeName, \nre\core\ClassLoader::stripClassType(\nre\core\ClassLoader::stripNamespace(get_class())), 'agent');
|
$className = \nre\core\ClassLoader::concatClassNames($questtypeName, \nre\core\ClassLoader::stripClassType(\nre\core\ClassLoader::stripNamespace(get_class())), 'agent');
|
||||||
|
|
||||||
|
|
||||||
return \nre\configs\AppConfig::$app['namespace']."questtypes\\$className";
|
return \nre\configs\AppConfig::$app['namespace']."questtypes\\$className";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Load the class of a QuesttypeAgent.
|
* Load the class of a QuesttypeAgent.
|
||||||
*
|
*
|
||||||
* @static
|
* @static
|
||||||
* @throws \nre\exceptions\ClassNotFoundException
|
* @throws \nre\exceptions\ClassNotFoundException
|
||||||
* @param string $questtypeName Name of the QuesttypeAgent to load
|
* @param string $questtypeName Name of the QuesttypeAgent to load
|
||||||
* @param string $fullClassName Name of the class to load
|
* @param string $fullClassName Name of the class to load
|
||||||
*/
|
*/
|
||||||
private static function loadClass($questtypeName, $fullClassName)
|
private static function loadClass($questtypeName, $fullClassName)
|
||||||
{
|
{
|
||||||
// Determine folder to look in
|
// Determine folder to look in
|
||||||
$className = explode('\\', $fullClassName);
|
$className = explode('\\', $fullClassName);
|
||||||
$className = array_pop($className);
|
$className = array_pop($className);
|
||||||
|
|
||||||
// Determine filename
|
// Determine filename
|
||||||
$fileName = ROOT.DS.\nre\configs\AppConfig::$dirs['questtypes'].DS.strtolower($questtypeName).DS.$className.\nre\configs\CoreConfig::getFileExt('includes');
|
$fileName = ROOT.DS.\nre\configs\AppConfig::$dirs['questtypes'].DS.strtolower($questtypeName).DS.$className.\nre\configs\CoreConfig::getFileExt('includes');
|
||||||
|
|
||||||
// Check file
|
// Check file
|
||||||
if(!file_exists($fileName))
|
if(!file_exists($fileName))
|
||||||
{
|
{
|
||||||
throw new \nre\exceptions\ClassNotFoundException(
|
throw new \nre\exceptions\ClassNotFoundException(
|
||||||
$fullClassName
|
$fullClassName
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Include file
|
// Include file
|
||||||
include_once($fileName);
|
include_once($fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check inheritance of the QuesttypeAgent-class.
|
* Check inheritance of the QuesttypeAgent-class.
|
||||||
*
|
*
|
||||||
* @static
|
* @static
|
||||||
* @throws \nre\exceptions\ClassNotValidException
|
* @throws \nre\exceptions\ClassNotValidException
|
||||||
* @param string $className Name of the class to check
|
* @param string $className Name of the class to check
|
||||||
* @param string $parentClassName Name of the parent class
|
* @param string $parentClassName Name of the parent class
|
||||||
*/
|
*/
|
||||||
public static function checkClass($className, $parentClassName)
|
public static function checkClass($className, $parentClassName)
|
||||||
{
|
{
|
||||||
// Check if class is subclass of parent class
|
// Check if class is subclass of parent class
|
||||||
if(!is_subclass_of($className, $parentClassName)) {
|
if(!is_subclass_of($className, $parentClassName)) {
|
||||||
throw new \nre\exceptions\ClassNotValidException(
|
throw new \nre\exceptions\ClassNotValidException(
|
||||||
$className
|
$className
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Construct a new QuesttypeAgent.
|
* Construct a new QuesttypeAgent.
|
||||||
*
|
*
|
||||||
* @throws \nre\exceptions\DatamodelException
|
* @throws \nre\exceptions\DatamodelException
|
||||||
* @throws \nre\exceptions\DriverNotValidException
|
* @throws \nre\exceptions\DriverNotValidException
|
||||||
* @throws \nre\exceptions\DriverNotFoundException
|
* @throws \nre\exceptions\DriverNotFoundException
|
||||||
* @throws \nre\exceptions\ViewNotFoundException
|
* @throws \nre\exceptions\ViewNotFoundException
|
||||||
* @throws \nre\exceptions\ModelNotValidException
|
* @throws \nre\exceptions\ModelNotValidException
|
||||||
* @throws \nre\exceptions\ModelNotFoundException
|
* @throws \nre\exceptions\ModelNotFoundException
|
||||||
* @throws \hhu\z\exceptions\QuesttypeModelNotValidException
|
* @throws \hhu\z\exceptions\QuesttypeModelNotValidException
|
||||||
* @throws \hhu\z\exceptions\QuesttypeModelNotFoundException
|
* @throws \hhu\z\exceptions\QuesttypeModelNotFoundException
|
||||||
* @throws \hhu\z\exceptions\QuesttypeControllerNotValidException
|
* @throws \hhu\z\exceptions\QuesttypeControllerNotValidException
|
||||||
* @throws \hhu\z\exceptions\QuesttypeControllerNotFoundException
|
* @throws \hhu\z\exceptions\QuesttypeControllerNotFoundException
|
||||||
* @param \nre\core\Request $request Current request
|
* @param \nre\core\Request $request Current request
|
||||||
* @param \nre\core\Response $response Current response
|
* @param \nre\core\Response $response Current response
|
||||||
* @param \nre\core\Logger $log Log-system
|
* @param \nre\core\Logger $log Log-system
|
||||||
*/
|
*/
|
||||||
protected function __construct(\nre\core\Request $request, \nre\core\Response $response, \nre\core\Logger $log=null)
|
protected function __construct(\nre\core\Request $request, \nre\core\Response $response, \nre\core\Logger $log=null)
|
||||||
{
|
{
|
||||||
// Store values
|
// Store values
|
||||||
$this->request = $request;
|
$this->request = $request;
|
||||||
$this->response = $response;
|
$this->response = $response;
|
||||||
|
|
||||||
|
|
||||||
// Call parent constructor
|
// Call parent constructor
|
||||||
parent::__construct($request, $response, $log);
|
parent::__construct($request, $response, $log);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Save the answers of a Character for a Quest.
|
* Save the answers of a Character for a Quest.
|
||||||
*
|
*
|
||||||
* @param array $seminary Current Seminary data
|
* @param array $seminary Current Seminary data
|
||||||
* @param array $questgroup Current Questgroup data
|
* @param array $questgroup Current Questgroup data
|
||||||
* @param array $quest Current Quest data
|
* @param array $quest Current Quest data
|
||||||
* @param array $character Current Character data
|
* @param array $character Current Character data
|
||||||
* @param array $answers Character answers for the Quest
|
* @param array $answers Character answers for the Quest
|
||||||
*/
|
*/
|
||||||
public function saveAnswersOfCharacter($seminary, $questgroup, $quest, $character, $answers)
|
public function saveAnswersOfCharacter($seminary, $questgroup, $quest, $character, $answers)
|
||||||
{
|
{
|
||||||
$this->controller->saveAnswersOfCharacter($seminary, $questgroup, $quest, $character, $answers);
|
$this->controller->saveAnswersOfCharacter($seminary, $questgroup, $quest, $character, $answers);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if answers of a Character for a Quest match the correct ones.
|
* Check if answers of a Character for a Quest match the correct ones.
|
||||||
*
|
*
|
||||||
* @param array $seminary Current Seminary data
|
* @param array $seminary Current Seminary data
|
||||||
* @param array $questgroup Current Questgroup data
|
* @param array $questgroup Current Questgroup data
|
||||||
* @param array $quest Current Quest data
|
* @param array $quest Current Quest data
|
||||||
* @param array $character Current Character data
|
* @param array $character Current Character data
|
||||||
* @param array $answers Character answers for the Quest
|
* @param array $answers Character answers for the Quest
|
||||||
*/
|
*/
|
||||||
public function matchAnswersOfCharacter($seminary, $questgroup, $quest, $character, $answers)
|
public function matchAnswersOfCharacter($seminary, $questgroup, $quest, $character, $answers)
|
||||||
{
|
{
|
||||||
return $this->controller->matchAnswersOfCharacter($seminary, $questgroup, $quest, $character, $answers);
|
return $this->controller->matchAnswersOfCharacter($seminary, $questgroup, $quest, $character, $answers);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Load the Controller of this Agent.
|
* Load the Controller of this Agent.
|
||||||
*
|
*
|
||||||
* @throws \nre\exceptions\DatamodelException
|
* @throws \nre\exceptions\DatamodelException
|
||||||
* @throws \nre\exceptions\DriverNotValidException
|
* @throws \nre\exceptions\DriverNotValidException
|
||||||
* @throws \nre\exceptions\DriverNotFoundException
|
* @throws \nre\exceptions\DriverNotFoundException
|
||||||
* @throws \nre\exceptions\ViewNotFoundException
|
* @throws \nre\exceptions\ViewNotFoundException
|
||||||
* @throws \nre\exceptions\ModelNotValidException
|
* @throws \nre\exceptions\ModelNotValidException
|
||||||
* @throws \nre\exceptions\ModelNotFoundException
|
* @throws \nre\exceptions\ModelNotFoundException
|
||||||
* @throws \hhu\z\exceptions\QuesttypeModelNotValidException
|
* @throws \hhu\z\exceptions\QuesttypeModelNotValidException
|
||||||
* @throws \hhu\z\exceptions\QuesttypeModelNotFoundException
|
* @throws \hhu\z\exceptions\QuesttypeModelNotFoundException
|
||||||
* @throws \hhu\z\exceptions\QuesttypeControllerNotValidException
|
* @throws \hhu\z\exceptions\QuesttypeControllerNotValidException
|
||||||
* @throws \hhu\z\exceptions\QuesttypeControllerNotFoundException
|
* @throws \hhu\z\exceptions\QuesttypeControllerNotFoundException
|
||||||
*/
|
*/
|
||||||
protected function loadController()
|
protected function loadController()
|
||||||
{
|
{
|
||||||
// Determine Controller name
|
// Determine Controller name
|
||||||
$controllerName = \nre\core\ClassLoader::stripClassType(\nre\core\ClassLoader::getClassName(get_class($this)));
|
$controllerName = \nre\core\ClassLoader::stripClassType(\nre\core\ClassLoader::getClassName(get_class($this)));
|
||||||
|
|
||||||
// Determine ToplevelAgent
|
// Determine ToplevelAgent
|
||||||
$toplevelAgentName = $this->response->getParam(0);
|
$toplevelAgentName = $this->response->getParam(0);
|
||||||
if(is_null($toplevelAgentName)) {
|
if(is_null($toplevelAgentName)) {
|
||||||
$toplevelAgentName = $this->request->getParam(0, 'toplevel');
|
$toplevelAgentName = $this->request->getParam(0, 'toplevel');
|
||||||
$this->response->addParam($toplevelAgentName);
|
$this->response->addParam($toplevelAgentName);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Determine Action
|
// Determine Action
|
||||||
$action = $this->response->getParam(2);
|
$action = $this->response->getParam(2);
|
||||||
if(is_null($action)) {
|
if(is_null($action)) {
|
||||||
$action = $this->request->getParam(2, 'action');
|
$action = $this->request->getParam(2, 'action');
|
||||||
$this->response->addParam($action);
|
$this->response->addParam($action);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Load Controller
|
// Load Controller
|
||||||
\hhu\z\controllers\QuesttypeController::load($controllerName);
|
\hhu\z\controllers\QuesttypeController::load($controllerName);
|
||||||
|
|
||||||
// Construct Controller
|
// Construct Controller
|
||||||
$this->controller = \hhu\z\controllers\QuesttypeController::factory($controllerName, $toplevelAgentName, $action, $this);
|
$this->controller = \hhu\z\controllers\QuesttypeController::factory($controllerName, $toplevelAgentName, $action, $this);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
|
||||||
|
|
@ -1,43 +1,43 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Legend of Z
|
* The Legend of Z
|
||||||
*
|
*
|
||||||
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
||||||
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
|
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
|
||||||
* @license http://www.gnu.org/licenses/gpl.html
|
* @license http://www.gnu.org/licenses/gpl.html
|
||||||
* @link https://bitbucket.org/coderkun/the-legend-of-z
|
* @link https://bitbucket.org/coderkun/the-legend-of-z
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace hhu\z\agents;
|
namespace hhu\z\agents;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Abstract class for implementing an application Controller.
|
* Abstract class for implementing an application Controller.
|
||||||
*
|
*
|
||||||
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
||||||
*/
|
*/
|
||||||
abstract class ToplevelAgent extends \nre\agents\ToplevelAgent
|
abstract class ToplevelAgent extends \nre\agents\ToplevelAgent
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Construct a new ToplevlAgent
|
* Construct a new ToplevlAgent
|
||||||
*
|
*
|
||||||
* @param \nre\core\Request $request Current request
|
* @param \nre\core\Request $request Current request
|
||||||
* @param \nre\core\Response $response Current response
|
* @param \nre\core\Response $response Current response
|
||||||
* @param \nre\core\Logger $log Logger instance
|
* @param \nre\core\Logger $log Logger instance
|
||||||
*/
|
*/
|
||||||
protected function __construct(\nre\core\Request $request, \nre\core\Response $response, \nre\core\Logger $log=null)
|
protected function __construct(\nre\core\Request $request, \nre\core\Response $response, \nre\core\Logger $log=null)
|
||||||
{
|
{
|
||||||
parent::__construct($request, $response, $log);
|
parent::__construct($request, $response, $log);
|
||||||
|
|
||||||
|
|
||||||
// Set timezone
|
// Set timezone
|
||||||
date_default_timezone_set(\nre\configs\AppConfig::$app['timeZone']);
|
date_default_timezone_set(\nre\configs\AppConfig::$app['timeZone']);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
|
||||||
|
|
@ -1,202 +1,202 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Legend of Z
|
* The Legend of Z
|
||||||
*
|
*
|
||||||
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
||||||
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
|
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
|
||||||
* @license http://www.gnu.org/licenses/gpl.html
|
* @license http://www.gnu.org/licenses/gpl.html
|
||||||
* @link https://bitbucket.org/coderkun/the-legend-of-z
|
* @link https://bitbucket.org/coderkun/the-legend-of-z
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace hhu\z\apis;
|
namespace hhu\z\apis;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* MailApi-implementation.
|
* MailApi-implementation.
|
||||||
*
|
*
|
||||||
* This class runs and renders e‑mail text and subject.
|
* This class runs and renders e‑mail text and subject.
|
||||||
*
|
*
|
||||||
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
||||||
*/
|
*/
|
||||||
class MailApi extends \nre\core\Api
|
class MailApi extends \nre\core\Api
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Construct a new MailApi.
|
* Construct a new MailApi.
|
||||||
*/
|
*/
|
||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
parent::__construct(
|
parent::__construct(
|
||||||
new \hhu\z\requests\MailRequest(),
|
new \hhu\z\requests\MailRequest(),
|
||||||
new \hhu\z\responses\MailResponse()
|
new \hhu\z\responses\MailResponse()
|
||||||
);
|
);
|
||||||
|
|
||||||
// Set ToplevelAgent
|
// Set ToplevelAgent
|
||||||
$this->request->addParam(\nre\configs\AppConfig::$defaults['toplevel-mail']);
|
$this->request->addParam(\nre\configs\AppConfig::$defaults['toplevel-mail']);
|
||||||
$this->request->addParam(\nre\configs\AppConfig::$defaults['intermediate-mail']);
|
$this->request->addParam(\nre\configs\AppConfig::$defaults['intermediate-mail']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set linker instance for creating links.
|
* Set linker instance for creating links.
|
||||||
*
|
*
|
||||||
* @param \nre\core\Linker $linker Linker instance for creating links
|
* @param \nre\core\Linker $linker Linker instance for creating links
|
||||||
*/
|
*/
|
||||||
public function setLinker(\nre\core\Linker $linker)
|
public function setLinker(\nre\core\Linker $linker)
|
||||||
{
|
{
|
||||||
$this->request->setLinker($linker);
|
$this->request->setLinker($linker);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Use a ToplevelAgent for HTML-mail
|
* Use a ToplevelAgent for HTML-mail
|
||||||
*
|
*
|
||||||
* @param bool $html Whether to use HTML or not
|
* @param bool $html Whether to use HTML or not
|
||||||
*/
|
*/
|
||||||
public function setHTML($html=true)
|
public function setHTML($html=true)
|
||||||
{
|
{
|
||||||
// Save params
|
// Save params
|
||||||
$params = $this->request->getParams(1);
|
$params = $this->request->getParams(1);
|
||||||
|
|
||||||
// Set ToplevelAgent
|
// Set ToplevelAgent
|
||||||
$this->request->clearParams();
|
$this->request->clearParams();
|
||||||
if($html) {
|
if($html) {
|
||||||
$this->request->addParam(\nre\configs\AppConfig::$defaults['toplevel-htmlmail']);
|
$this->request->addParam(\nre\configs\AppConfig::$defaults['toplevel-htmlmail']);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$this->request->addParam(\nre\configs\AppConfig::$defaults['toplevel-mail']);
|
$this->request->addParam(\nre\configs\AppConfig::$defaults['toplevel-mail']);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Restore params
|
// Restore params
|
||||||
if(!empty($params)) {
|
if(!empty($params)) {
|
||||||
$this->addParams($params);
|
$this->addParams($params);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the Action for the message to render.
|
* Set the Action for the message to render.
|
||||||
*
|
*
|
||||||
* @param string $messageAgent Agent to handle the message
|
* @param string $messageAgent Agent to handle the message
|
||||||
*/
|
*/
|
||||||
public function setMessage($messageAgent)
|
public function setMessage($messageAgent)
|
||||||
{
|
{
|
||||||
// Save params
|
// Save params
|
||||||
$params = $this->request->getParams(3);
|
$params = $this->request->getParams(3);
|
||||||
|
|
||||||
// Set messageAgent
|
// Set messageAgent
|
||||||
$this->request->clearParams(2);
|
$this->request->clearParams(2);
|
||||||
$this->request->addParam($messageAgent);
|
$this->request->addParam($messageAgent);
|
||||||
|
|
||||||
// Restore params
|
// Restore params
|
||||||
if(!empty($params)) {
|
if(!empty($params)) {
|
||||||
$this->addParams($params);
|
$this->addParams($params);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set additional params to pass to the Action.
|
* Set additional params to pass to the Action.
|
||||||
*
|
*
|
||||||
* @param array $params Additional params to set
|
* @param array $params Additional params to set
|
||||||
*/
|
*/
|
||||||
public function setParams($params)
|
public function setParams($params)
|
||||||
{
|
{
|
||||||
// Add placeholder params
|
// Add placeholder params
|
||||||
for($i=3; $i<count($this->request->getParams()); $i++) {
|
for($i=3; $i<count($this->request->getParams()); $i++) {
|
||||||
$this->request->addParam(null);
|
$this->request->addParam(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set params
|
// Set params
|
||||||
call_user_func_array(
|
call_user_func_array(
|
||||||
array(
|
array(
|
||||||
$this->request,
|
$this->request,
|
||||||
'addParams'
|
'addParams'
|
||||||
),
|
),
|
||||||
$params
|
$params
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the subject set by the Controller.
|
* Return the subject set by the Controller.
|
||||||
*
|
*
|
||||||
* @return string Subject set by Controller
|
* @return string Subject set by Controller
|
||||||
*/
|
*/
|
||||||
public function getSubject()
|
public function getSubject()
|
||||||
{
|
{
|
||||||
return $this->response->getSubject();
|
return $this->response->getSubject();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Run mailtext generation.
|
* Run mailtext generation.
|
||||||
*
|
*
|
||||||
* This method runs the generation of mailtext.
|
* This method runs the generation of mailtext.
|
||||||
*
|
*
|
||||||
* @return \Exception Occured exception or null
|
* @return \Exception Occured exception or null
|
||||||
*/
|
*/
|
||||||
public function run()
|
public function run()
|
||||||
{
|
{
|
||||||
// Set response
|
// Set response
|
||||||
$this->response->clearParams();
|
$this->response->clearParams();
|
||||||
foreach($this->request->getParams() as $param) {
|
foreach($this->request->getParams() as $param) {
|
||||||
$this->response->addParam($param);
|
$this->response->addParam($param);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Run
|
// Run
|
||||||
try {
|
try {
|
||||||
$exception = parent::run();
|
$exception = parent::run();
|
||||||
|
|
||||||
|
|
||||||
return $exception;
|
return $exception;
|
||||||
}
|
}
|
||||||
catch(\nre\Exception $e) {
|
catch(\nre\Exception $e) {
|
||||||
return $e;
|
return $e;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Render output.
|
* Render output.
|
||||||
*
|
*
|
||||||
* @return string Rendered output
|
* @return string Rendered output
|
||||||
*/
|
*/
|
||||||
public function render()
|
public function render()
|
||||||
{
|
{
|
||||||
// Generate output
|
// Generate output
|
||||||
parent::render();
|
parent::render();
|
||||||
|
|
||||||
|
|
||||||
// Return output
|
// Return output
|
||||||
return $this->response->getOutput();
|
return $this->response->getOutput();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add multiple request params.
|
* Add multiple request params.
|
||||||
*
|
*
|
||||||
* @param array $params Request params to add
|
* @param array $params Request params to add
|
||||||
*/
|
*/
|
||||||
private function addParams($params)
|
private function addParams($params)
|
||||||
{
|
{
|
||||||
call_user_func_array(
|
call_user_func_array(
|
||||||
array(
|
array(
|
||||||
$this->request,
|
$this->request,
|
||||||
'addParams'
|
'addParams'
|
||||||
),
|
),
|
||||||
$params
|
$params
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
|
||||||
|
|
@ -1,197 +1,197 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Legend of Z
|
* The Legend of Z
|
||||||
*
|
*
|
||||||
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
||||||
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
|
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
|
||||||
* @license http://www.gnu.org/licenses/gpl.html
|
* @license http://www.gnu.org/licenses/gpl.html
|
||||||
* @link https://bitbucket.org/coderkun/the-legend-of-z
|
* @link https://bitbucket.org/coderkun/the-legend-of-z
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace hhu\z\controllers;
|
namespace hhu\z\controllers;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Abstract class for implementing a Controller of an IntermediateAgent.
|
* Abstract class for implementing a Controller of an IntermediateAgent.
|
||||||
*
|
*
|
||||||
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
||||||
*/
|
*/
|
||||||
abstract class IntermediateController extends \hhu\z\Controller
|
abstract class IntermediateController extends \hhu\z\Controller
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Required models
|
* Required models
|
||||||
*
|
*
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
public $models = array('users', 'userroles', 'seminaries', 'characters');
|
public $models = array('users', 'userroles', 'seminaries', 'characters');
|
||||||
/**
|
/**
|
||||||
* Current user
|
* Current user
|
||||||
*
|
*
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
public static $user = null;
|
public static $user = null;
|
||||||
/**
|
/**
|
||||||
* Title information
|
* Title information
|
||||||
*
|
*
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
private $title = array();
|
private $title = array();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Construct a new IntermediateController.
|
* Construct a new IntermediateController.
|
||||||
*
|
*
|
||||||
* @throws \nre\exceptions\DriverNotFoundException
|
* @throws \nre\exceptions\DriverNotFoundException
|
||||||
* @throws \nre\exceptions\DriverNotValidException
|
* @throws \nre\exceptions\DriverNotValidException
|
||||||
* @throws \nre\exceptions\ModelNotValidException
|
* @throws \nre\exceptions\ModelNotValidException
|
||||||
* @throws \nre\exceptions\ModelNotFoundException
|
* @throws \nre\exceptions\ModelNotFoundException
|
||||||
* @throws \nre\exceptions\ViewNotFoundException
|
* @throws \nre\exceptions\ViewNotFoundException
|
||||||
* @param string $layoutName Name of the current Layout
|
* @param string $layoutName Name of the current Layout
|
||||||
* @param string $action Current Action
|
* @param string $action Current Action
|
||||||
* @param \nre\core\Agent $agent Corresponding Agent
|
* @param \nre\core\Agent $agent Corresponding Agent
|
||||||
*/
|
*/
|
||||||
public function __construct($layoutName, $action, $agent)
|
public function __construct($layoutName, $action, $agent)
|
||||||
{
|
{
|
||||||
parent::__construct($layoutName, $action, $agent);
|
parent::__construct($layoutName, $action, $agent);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Prefilter that is executed before running the Controller.
|
* Prefilter that is executed before running the Controller.
|
||||||
*
|
*
|
||||||
* @param \nre\core\Request $request Current request
|
* @param \nre\core\Request $request Current request
|
||||||
* @param \nre\core\Response $response Current response
|
* @param \nre\core\Response $response Current response
|
||||||
*/
|
*/
|
||||||
public function preFilter(\nre\core\Request $request, \nre\core\Response $response)
|
public function preFilter(\nre\core\Request $request, \nre\core\Response $response)
|
||||||
{
|
{
|
||||||
parent::preFilter($request, $response);
|
parent::preFilter($request, $response);
|
||||||
|
|
||||||
// Get userdata
|
// Get userdata
|
||||||
try {
|
try {
|
||||||
self::$user = $this->Users->getUserById($this->Auth->getUserId());
|
self::$user = $this->Users->getUserById($this->Auth->getUserId());
|
||||||
self::$user['roles'] = array_map(function($r) { return $r['name']; }, $this->Userroles->getUserrolesForUserById(self::$user['id']));
|
self::$user['roles'] = array_map(function($r) { return $r['name']; }, $this->Userroles->getUserrolesForUserById(self::$user['id']));
|
||||||
}
|
}
|
||||||
catch(\nre\exceptions\IdNotFoundException $e) {
|
catch(\nre\exceptions\IdNotFoundException $e) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check permissions
|
// Check permissions
|
||||||
$this->checkPermission($request, $response);
|
$this->checkPermission($request, $response);
|
||||||
|
|
||||||
// Set userdata
|
// Set userdata
|
||||||
$this->set('loggedUser', self::$user);
|
$this->set('loggedUser', self::$user);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Postfilter that is executed after running the Controller.
|
* Postfilter that is executed after running the Controller.
|
||||||
*
|
*
|
||||||
* @param \nre\core\Request $request Current request
|
* @param \nre\core\Request $request Current request
|
||||||
* @param \nre\core\Response $response Current response
|
* @param \nre\core\Response $response Current response
|
||||||
*/
|
*/
|
||||||
public function postFilter(\nre\core\Request $request, \nre\core\Response $response)
|
public function postFilter(\nre\core\Request $request, \nre\core\Response $response)
|
||||||
{
|
{
|
||||||
parent::postFilter($request, $response);
|
parent::postFilter($request, $response);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return current title information.
|
* Return current title information.
|
||||||
*
|
*
|
||||||
* @return string Title information
|
* @return string Title information
|
||||||
*/
|
*/
|
||||||
public function getTitle()
|
public function getTitle()
|
||||||
{
|
{
|
||||||
return $this->title;
|
return $this->title;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add a piece of information to the current title.
|
* Add a piece of information to the current title.
|
||||||
*
|
*
|
||||||
* @param string $title Title information
|
* @param string $title Title information
|
||||||
*/
|
*/
|
||||||
protected function addTitle($title)
|
protected function addTitle($title)
|
||||||
{
|
{
|
||||||
$this->title[] = $title;
|
$this->title[] = $title;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add a piece of information to the current title and localize
|
* Add a piece of information to the current title and localize
|
||||||
* it.
|
* it.
|
||||||
*
|
*
|
||||||
* @param string $title Title information
|
* @param string $title Title information
|
||||||
*/
|
*/
|
||||||
protected function addTitleLocalized($title)
|
protected function addTitleLocalized($title)
|
||||||
{
|
{
|
||||||
$title = gettext($title);
|
$title = gettext($title);
|
||||||
|
|
||||||
$args = func_get_args();
|
$args = func_get_args();
|
||||||
if(count($args) > 0) {
|
if(count($args) > 0) {
|
||||||
$title = call_user_func_array(
|
$title = call_user_func_array(
|
||||||
'sprintf',
|
'sprintf',
|
||||||
array_merge(
|
array_merge(
|
||||||
array($title),
|
array($title),
|
||||||
array_slice($args, 1)
|
array_slice($args, 1)
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
$this->title[] = $title;
|
$this->title[] = $title;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check user permissions.
|
* Check user permissions.
|
||||||
*
|
*
|
||||||
* @throws \nre\exceptions\AccessDeniedException
|
* @throws \nre\exceptions\AccessDeniedException
|
||||||
* @param \nre\core\Request $request Current request
|
* @param \nre\core\Request $request Current request
|
||||||
* @param \nre\core\Response $response Current response
|
* @param \nre\core\Response $response Current response
|
||||||
*/
|
*/
|
||||||
private function checkPermission(\nre\core\Request $request, \nre\core\Response $response)
|
private function checkPermission(\nre\core\Request $request, \nre\core\Response $response)
|
||||||
{
|
{
|
||||||
// Determine user
|
// Determine user
|
||||||
$userRoles = array('guest');
|
$userRoles = array('guest');
|
||||||
if(!is_null(self::$user)) {
|
if(!is_null(self::$user)) {
|
||||||
$userRoles = self::$user['roles'];
|
$userRoles = self::$user['roles'];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Do not check error pages
|
// Do not check error pages
|
||||||
if($response->getParam(0, 'toplevel') == \nre\core\Config::getDefault('toplevel-error')) {
|
if($response->getParam(0, 'toplevel') == \nre\core\Config::getDefault('toplevel-error')) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if($response->getParam(1, 'intermediate') == \nre\core\Config::getDefault('intermediate-error')) {
|
if($response->getParam(1, 'intermediate') == \nre\core\Config::getDefault('intermediate-error')) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Determine permissions of Intermediate Controller for current action
|
// Determine permissions of Intermediate Controller for current action
|
||||||
$controller = $this->agent->controller;
|
$controller = $this->agent->controller;
|
||||||
$action = $this->request->getParam(2, 'action');
|
$action = $this->request->getParam(2, 'action');
|
||||||
if(!property_exists($controller, 'permissions')) {
|
if(!property_exists($controller, 'permissions')) {
|
||||||
return; // Allow if nothing is specified
|
return; // Allow if nothing is specified
|
||||||
}
|
}
|
||||||
if(!array_key_exists($action, $controller->permissions)) {
|
if(!array_key_exists($action, $controller->permissions)) {
|
||||||
return; // Allow if Action is not specified
|
return; // Allow if Action is not specified
|
||||||
}
|
}
|
||||||
$permissions = $controller->permissions[$action];
|
$permissions = $controller->permissions[$action];
|
||||||
|
|
||||||
|
|
||||||
// Check permissions
|
// Check permissions
|
||||||
if(count(array_intersect($userRoles, $permissions)) == 0) {
|
if(count(array_intersect($userRoles, $permissions)) == 0) {
|
||||||
throw new \nre\exceptions\AccessDeniedException();
|
throw new \nre\exceptions\AccessDeniedException();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
|
||||||
|
|
@ -1,320 +1,320 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Legend of Z
|
* The Legend of Z
|
||||||
*
|
*
|
||||||
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
||||||
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
|
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
|
||||||
* @license http://www.gnu.org/licenses/gpl.html
|
* @license http://www.gnu.org/licenses/gpl.html
|
||||||
* @link https://bitbucket.org/coderkun/the-legend-of-z
|
* @link https://bitbucket.org/coderkun/the-legend-of-z
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace hhu\z\controllers;
|
namespace hhu\z\controllers;
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Abstract class for implementing a QuesttypeController.
|
|
||||||
*
|
|
||||||
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
|
||||||
*/
|
|
||||||
abstract class QuesttypeController extends \hhu\z\Controller
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* Required models
|
|
||||||
*
|
|
||||||
* @var array
|
|
||||||
*/
|
|
||||||
public $models = array('seminaries', 'questgroups', 'quests', 'characters');
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Save the answers of a Character for a Quest.
|
|
||||||
*
|
|
||||||
* @param array $seminary Current Seminary data
|
|
||||||
* @param array $questgroup Current Questgroup data
|
|
||||||
* @param array $quest Current Quest data
|
|
||||||
* @param array $character Current Character data
|
|
||||||
* @param array $answers Character answers for the Quest
|
|
||||||
*/
|
|
||||||
public abstract function saveAnswersOfCharacter($seminary, $questgroup, $quest, $character, $answers);
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Save additional data for the answers of a Character for a Quest.
|
|
||||||
*
|
|
||||||
* @param array $seminary Current Seminary data
|
|
||||||
* @param array $questgroup Current Questgroup data
|
|
||||||
* @param array $quest Current Quest data
|
|
||||||
* @param array $character Current Character data
|
|
||||||
* @param array $data Additional (POST-) data
|
|
||||||
*/
|
|
||||||
public abstract function saveDataForCharacterAnswers($seminary, $questgroup, $quest, $character, $data);
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Check if answers of a Character for a Quest match the correct ones.
|
|
||||||
*
|
|
||||||
* @param array $seminary Current Seminary data
|
|
||||||
* @param array $questgroup Current Questgroup data
|
|
||||||
* @param array $quest Current Quest data
|
|
||||||
* @param array $character Current Character data
|
|
||||||
* @param array $answers Character answers for the Quest
|
|
||||||
* @return boolean True/false for a right/wrong answer or null for moderator evaluation
|
|
||||||
*/
|
|
||||||
public abstract function matchAnswersOfCharacter($seminary, $questgroup, $quest, $character, $answers);
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Action: quest.
|
|
||||||
*
|
|
||||||
* Show the task of a Quest.
|
|
||||||
*
|
|
||||||
* @param array $seminary Current Seminary data
|
|
||||||
* @param array $questgroup Current Questgroup data
|
|
||||||
* @param array $quest Current Quest data
|
|
||||||
* @param array $character Current Character data
|
|
||||||
* @param \Exception $exception Character submission exception
|
|
||||||
*/
|
|
||||||
public abstract function quest($seminary, $questgroup, $quest, $character, $exception);
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Action: submission.
|
|
||||||
*
|
|
||||||
* Show the submission of a Character for a Quest.
|
|
||||||
*
|
|
||||||
* @param array $seminary Current Seminary data
|
|
||||||
* @param array $questgroup Current Questgroup data
|
|
||||||
* @param array $quest Current Quest data
|
|
||||||
* @param array $character Current Character data
|
|
||||||
*/
|
|
||||||
public abstract function submission($seminary, $questgroup, $quest, $character);
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Action: edittask.
|
* Abstract class for implementing a QuesttypeController.
|
||||||
*
|
*
|
||||||
* Edit the task of a Quest.
|
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
||||||
*
|
*/
|
||||||
* @param array $seminary Current Seminary data
|
abstract class QuesttypeController extends \hhu\z\Controller
|
||||||
* @param array $questgroup Current Questgroup data
|
{
|
||||||
* @param array $quest Current Quest data
|
/**
|
||||||
*/
|
* Required models
|
||||||
public abstract function edittask($seminary, $questgroup, $quest);
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
public $models = array('seminaries', 'questgroups', 'quests', 'characters');
|
||||||
|
|
||||||
/**
|
|
||||||
* Load a QuesttypeController.
|
|
||||||
*
|
|
||||||
* @static
|
/**
|
||||||
* @throws \hhu\z\exceptions\QuesttypeControllerNotFoundException
|
* Save the answers of a Character for a Quest.
|
||||||
* @throws \hhu\z\exceptions\QuesttypeControllerNotValidException
|
*
|
||||||
* @param string $controllerName Name of the QuesttypeController to load
|
* @param array $seminary Current Seminary data
|
||||||
*/
|
* @param array $questgroup Current Questgroup data
|
||||||
public static function load($controllerName)
|
* @param array $quest Current Quest data
|
||||||
{
|
* @param array $character Current Character data
|
||||||
// Determine full classname
|
* @param array $answers Character answers for the Quest
|
||||||
$className = self::getClassName($controllerName);
|
*/
|
||||||
|
public abstract function saveAnswersOfCharacter($seminary, $questgroup, $quest, $character, $answers);
|
||||||
try {
|
|
||||||
// Load class
|
|
||||||
static::loadClass($controllerName, $className);
|
/**
|
||||||
|
* Save additional data for the answers of a Character for a Quest.
|
||||||
// Validate class
|
*
|
||||||
static::checkClass($className, get_class());
|
* @param array $seminary Current Seminary data
|
||||||
}
|
* @param array $questgroup Current Questgroup data
|
||||||
catch(\nre\exceptions\ClassNotValidException $e) {
|
* @param array $quest Current Quest data
|
||||||
throw new \hhu\z\exceptions\QuesttypeControllerNotValidException($e->getClassName());
|
* @param array $character Current Character data
|
||||||
}
|
* @param array $data Additional (POST-) data
|
||||||
catch(\nre\exceptions\ClassNotFoundException $e) {
|
*/
|
||||||
throw new \hhu\z\exceptions\QuesttypeControllerNotFoundException($e->getClassName());
|
public abstract function saveDataForCharacterAnswers($seminary, $questgroup, $quest, $character, $data);
|
||||||
}
|
|
||||||
}
|
|
||||||
|
/**
|
||||||
|
* Check if answers of a Character for a Quest match the correct ones.
|
||||||
/**
|
*
|
||||||
* Instantiate a QuesttypeController (Factory Pattern).
|
* @param array $seminary Current Seminary data
|
||||||
*
|
* @param array $questgroup Current Questgroup data
|
||||||
* @static
|
* @param array $quest Current Quest data
|
||||||
* @throws \nre\exceptions\DatamodelException
|
* @param array $character Current Character data
|
||||||
* @throws \nre\exceptions\DriverNotFoundException
|
* @param array $answers Character answers for the Quest
|
||||||
* @throws \nre\exceptions\DriverNotValidException
|
* @return boolean True/false for a right/wrong answer or null for moderator evaluation
|
||||||
* @throws \nre\exceptions\ModelNotValidException
|
*/
|
||||||
* @throws \nre\exceptions\ModelNotFoundException
|
public abstract function matchAnswersOfCharacter($seminary, $questgroup, $quest, $character, $answers);
|
||||||
* @throws \nre\exceptions\ViewNotFoundException
|
|
||||||
* @throws \hhu\z\exceptions\QuesttypeModelNotValidException
|
|
||||||
* @throws \hhu\z\exceptions\QuesttypeModelNotFoundException
|
/**
|
||||||
* @param string $controllerName Name of the QuesttypeController to instantiate
|
* Action: quest.
|
||||||
* @param string $layoutName Name of the current Layout
|
*
|
||||||
* @param string $action Current Action
|
* Show the task of a Quest.
|
||||||
* @param \nre\core\Agent $agent Corresponding Agent
|
*
|
||||||
*/
|
* @param array $seminary Current Seminary data
|
||||||
public static function factory($controllerName, $layoutName, $action, $agent)
|
* @param array $questgroup Current Questgroup data
|
||||||
{
|
* @param array $quest Current Quest data
|
||||||
// Determine full classname
|
* @param array $character Current Character data
|
||||||
$className = self::getClassName($controllerName);
|
* @param \Exception $exception Character submission exception
|
||||||
|
*/
|
||||||
// Construct and return Controller
|
public abstract function quest($seminary, $questgroup, $quest, $character, $exception);
|
||||||
return new $className($layoutName, $action, $agent);
|
|
||||||
}
|
|
||||||
|
/**
|
||||||
|
* Action: submission.
|
||||||
/**
|
*
|
||||||
* Determine the Controller-classname for the given Questtype-name.
|
* Show the submission of a Character for a Quest.
|
||||||
*
|
*
|
||||||
* @static
|
* @param array $seminary Current Seminary data
|
||||||
* @param string $questtypeName Questtype-name to get Controller-classname of
|
* @param array $questgroup Current Questgroup data
|
||||||
* @return string Classname for the Questtype-name
|
* @param array $quest Current Quest data
|
||||||
*/
|
* @param array $character Current Character data
|
||||||
private static function getClassName($questtypeName)
|
*/
|
||||||
{
|
public abstract function submission($seminary, $questgroup, $quest, $character);
|
||||||
$className = \nre\core\ClassLoader::concatClassNames($questtypeName, \nre\core\ClassLoader::stripClassType(\nre\core\ClassLoader::stripNamespace(get_class())), 'controller');
|
|
||||||
|
|
||||||
|
/**
|
||||||
return \nre\configs\AppConfig::$app['namespace']."questtypes\\$className";
|
* Action: edittask.
|
||||||
}
|
*
|
||||||
|
* Edit the task of a Quest.
|
||||||
|
*
|
||||||
/**
|
* @param array $seminary Current Seminary data
|
||||||
* Load the class of a QuesttypeController
|
* @param array $questgroup Current Questgroup data
|
||||||
*
|
* @param array $quest Current Quest data
|
||||||
* @static
|
*/
|
||||||
* @throws \nre\exceptions\ClassNotFoundException
|
public abstract function edittask($seminary, $questgroup, $quest);
|
||||||
* @param string $questtypeName Name of the QuesttypeController to load
|
|
||||||
* @param string $fullClassName Name of the class to load
|
|
||||||
*/
|
|
||||||
private static function loadClass($questtypeName, $fullClassName)
|
|
||||||
{
|
/**
|
||||||
// Determine folder to look in
|
* Load a QuesttypeController.
|
||||||
$className = explode('\\', $fullClassName);
|
*
|
||||||
$className = array_pop($className);
|
* @static
|
||||||
|
* @throws \hhu\z\exceptions\QuesttypeControllerNotFoundException
|
||||||
// Determine filename
|
* @throws \hhu\z\exceptions\QuesttypeControllerNotValidException
|
||||||
$fileName = ROOT.DS.\nre\configs\AppConfig::$dirs['questtypes'].DS.strtolower($questtypeName).DS.$className.\nre\configs\CoreConfig::getFileExt('includes');
|
* @param string $controllerName Name of the QuesttypeController to load
|
||||||
|
*/
|
||||||
// Check file
|
public static function load($controllerName)
|
||||||
if(!file_exists($fileName))
|
{
|
||||||
{
|
// Determine full classname
|
||||||
throw new \nre\exceptions\ClassNotFoundException(
|
$className = self::getClassName($controllerName);
|
||||||
$fullClassName
|
|
||||||
);
|
try {
|
||||||
}
|
// Load class
|
||||||
|
static::loadClass($controllerName, $className);
|
||||||
// Include file
|
|
||||||
include_once($fileName);
|
// Validate class
|
||||||
}
|
static::checkClass($className, get_class());
|
||||||
|
}
|
||||||
|
catch(\nre\exceptions\ClassNotValidException $e) {
|
||||||
/**
|
throw new \hhu\z\exceptions\QuesttypeControllerNotValidException($e->getClassName());
|
||||||
* Check inheritance of the QuesttypeController-class.
|
}
|
||||||
*
|
catch(\nre\exceptions\ClassNotFoundException $e) {
|
||||||
* @static
|
throw new \hhu\z\exceptions\QuesttypeControllerNotFoundException($e->getClassName());
|
||||||
* @throws \nre\exceptions\ClassNotValidException
|
}
|
||||||
* @param string $className Name of the class to check
|
}
|
||||||
* @param string $parentClassName Name of the parent class
|
|
||||||
*/
|
|
||||||
public static function checkClass($className, $parentClassName)
|
/**
|
||||||
{
|
* Instantiate a QuesttypeController (Factory Pattern).
|
||||||
// Check if class is subclass of parent class
|
*
|
||||||
if(!is_subclass_of($className, $parentClassName)) {
|
* @static
|
||||||
throw new \nre\exceptions\ClassNotValidException(
|
* @throws \nre\exceptions\DatamodelException
|
||||||
$className
|
* @throws \nre\exceptions\DriverNotFoundException
|
||||||
);
|
* @throws \nre\exceptions\DriverNotValidException
|
||||||
}
|
* @throws \nre\exceptions\ModelNotValidException
|
||||||
}
|
* @throws \nre\exceptions\ModelNotFoundException
|
||||||
|
* @throws \nre\exceptions\ViewNotFoundException
|
||||||
|
* @throws \hhu\z\exceptions\QuesttypeModelNotValidException
|
||||||
|
* @throws \hhu\z\exceptions\QuesttypeModelNotFoundException
|
||||||
|
* @param string $controllerName Name of the QuesttypeController to instantiate
|
||||||
/**
|
* @param string $layoutName Name of the current Layout
|
||||||
* Construct a new application Controller.
|
* @param string $action Current Action
|
||||||
*
|
* @param \nre\core\Agent $agent Corresponding Agent
|
||||||
* @throws \nre\exceptions\DriverNotFoundException
|
*/
|
||||||
* @throws \nre\exceptions\DriverNotValidException
|
public static function factory($controllerName, $layoutName, $action, $agent)
|
||||||
* @throws \nre\exceptions\ModelNotValidException
|
{
|
||||||
* @throws \nre\exceptions\ModelNotFoundException
|
// Determine full classname
|
||||||
* @throws \nre\exceptions\ViewNotFoundException
|
$className = self::getClassName($controllerName);
|
||||||
* @throws \hhu\z\exceptions\QuesttypeModelNotValidException
|
|
||||||
* @throws \hhu\z\exceptions\QuesttypeModelNotFoundException
|
// Construct and return Controller
|
||||||
* @param string $layoutName Name of the current Layout
|
return new $className($layoutName, $action, $agent);
|
||||||
* @param string $action Current Action
|
}
|
||||||
* @param Agent $agent Corresponding Agent
|
|
||||||
*/
|
|
||||||
public function __construct($layoutName, $action, $agent)
|
/**
|
||||||
{
|
* Determine the Controller-classname for the given Questtype-name.
|
||||||
parent::__construct($layoutName, $action, $agent);
|
*
|
||||||
}
|
* @static
|
||||||
|
* @param string $questtypeName Questtype-name to get Controller-classname of
|
||||||
|
* @return string Classname for the Questtype-name
|
||||||
|
*/
|
||||||
|
private static function getClassName($questtypeName)
|
||||||
/**
|
{
|
||||||
* Load the Models of this Controller.
|
$className = \nre\core\ClassLoader::concatClassNames($questtypeName, \nre\core\ClassLoader::stripClassType(\nre\core\ClassLoader::stripNamespace(get_class())), 'controller');
|
||||||
*
|
|
||||||
* @throws \nre\exceptions\DatamodelException
|
|
||||||
* @throws \nre\exceptions\DriverNotFoundException
|
return \nre\configs\AppConfig::$app['namespace']."questtypes\\$className";
|
||||||
* @throws \nre\exceptions\DriverNotValidException
|
}
|
||||||
* @throws \nre\exceptions\ModelNotValidException
|
|
||||||
* @throws \nre\exceptions\ModelNotFoundException
|
|
||||||
* @throws \hhu\z\exceptions\QuesttypeModelNotValidException
|
/**
|
||||||
* @throws \hhu\z\exceptions\QuesttypeModelNotFoundException
|
* Load the class of a QuesttypeController
|
||||||
*/
|
*
|
||||||
protected function loadModels()
|
* @static
|
||||||
{
|
* @throws \nre\exceptions\ClassNotFoundException
|
||||||
// Load default models
|
* @param string $questtypeName Name of the QuesttypeController to load
|
||||||
parent::loadModels();
|
* @param string $fullClassName Name of the class to load
|
||||||
|
*/
|
||||||
// Load QuesttypeModel
|
private static function loadClass($questtypeName, $fullClassName)
|
||||||
$this->loadModel();
|
{
|
||||||
}
|
// Determine folder to look in
|
||||||
|
$className = explode('\\', $fullClassName);
|
||||||
|
$className = array_pop($className);
|
||||||
/**
|
|
||||||
* Load the Model of the Questtype.
|
// Determine filename
|
||||||
*
|
$fileName = ROOT.DS.\nre\configs\AppConfig::$dirs['questtypes'].DS.strtolower($questtypeName).DS.$className.\nre\configs\CoreConfig::getFileExt('includes');
|
||||||
* @throws \hhu\z\exceptions\QuesttypeModelNotValidException
|
|
||||||
* @throws \hhu\z\exceptions\QuesttypeModelNotFoundException
|
// Check file
|
||||||
*/
|
if(!file_exists($fileName))
|
||||||
private function loadModel()
|
{
|
||||||
{
|
throw new \nre\exceptions\ClassNotFoundException(
|
||||||
// Determine Model
|
$fullClassName
|
||||||
$model = \nre\core\ClassLoader::stripClassType(\nre\core\ClassLoader::stripClassType(\nre\core\ClassLoader::stripNamespace(get_class($this))));
|
);
|
||||||
|
}
|
||||||
// Load class
|
|
||||||
\hhu\z\models\QuesttypeModel::load($model);
|
// Include file
|
||||||
|
include_once($fileName);
|
||||||
// Construct Model
|
}
|
||||||
$modelName = ucfirst(strtolower($model));
|
|
||||||
$this->$modelName = \hhu\z\models\QuesttypeModel::factory($model);
|
|
||||||
}
|
/**
|
||||||
|
* Check inheritance of the QuesttypeController-class.
|
||||||
|
*
|
||||||
/**
|
* @static
|
||||||
* Load the View of this QuesttypeController.
|
* @throws \nre\exceptions\ClassNotValidException
|
||||||
*
|
* @param string $className Name of the class to check
|
||||||
* @throws \nre\exceptions\ViewNotFoundException
|
* @param string $parentClassName Name of the parent class
|
||||||
* @param string $layoutName Name of the current Layout
|
*/
|
||||||
* @param string $action Current Action
|
public static function checkClass($className, $parentClassName)
|
||||||
*/
|
{
|
||||||
protected function loadView($layoutName, $action)
|
// Check if class is subclass of parent class
|
||||||
{
|
if(!is_subclass_of($className, $parentClassName)) {
|
||||||
// Check Layout name
|
throw new \nre\exceptions\ClassNotValidException(
|
||||||
if(is_null($layoutName)) {
|
$className
|
||||||
return;
|
);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
// Determine controller name
|
|
||||||
$controllerName = \nre\core\ClassLoader::stripClassType(\nre\core\ClassLoader::getClassName(get_class($this)));
|
|
||||||
|
|
||||||
|
|
||||||
// Load view
|
/**
|
||||||
$this->view = \hhu\z\views\QuesttypeView::loadAndFactory($layoutName, $controllerName, $action);
|
* Construct a new application Controller.
|
||||||
}
|
*
|
||||||
|
* @throws \nre\exceptions\DriverNotFoundException
|
||||||
}
|
* @throws \nre\exceptions\DriverNotValidException
|
||||||
|
* @throws \nre\exceptions\ModelNotValidException
|
||||||
|
* @throws \nre\exceptions\ModelNotFoundException
|
||||||
|
* @throws \nre\exceptions\ViewNotFoundException
|
||||||
|
* @throws \hhu\z\exceptions\QuesttypeModelNotValidException
|
||||||
|
* @throws \hhu\z\exceptions\QuesttypeModelNotFoundException
|
||||||
|
* @param string $layoutName Name of the current Layout
|
||||||
|
* @param string $action Current Action
|
||||||
|
* @param Agent $agent Corresponding Agent
|
||||||
|
*/
|
||||||
|
public function __construct($layoutName, $action, $agent)
|
||||||
|
{
|
||||||
|
parent::__construct($layoutName, $action, $agent);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Load the Models of this Controller.
|
||||||
|
*
|
||||||
|
* @throws \nre\exceptions\DatamodelException
|
||||||
|
* @throws \nre\exceptions\DriverNotFoundException
|
||||||
|
* @throws \nre\exceptions\DriverNotValidException
|
||||||
|
* @throws \nre\exceptions\ModelNotValidException
|
||||||
|
* @throws \nre\exceptions\ModelNotFoundException
|
||||||
|
* @throws \hhu\z\exceptions\QuesttypeModelNotValidException
|
||||||
|
* @throws \hhu\z\exceptions\QuesttypeModelNotFoundException
|
||||||
|
*/
|
||||||
|
protected function loadModels()
|
||||||
|
{
|
||||||
|
// Load default models
|
||||||
|
parent::loadModels();
|
||||||
|
|
||||||
|
// Load QuesttypeModel
|
||||||
|
$this->loadModel();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Load the Model of the Questtype.
|
||||||
|
*
|
||||||
|
* @throws \hhu\z\exceptions\QuesttypeModelNotValidException
|
||||||
|
* @throws \hhu\z\exceptions\QuesttypeModelNotFoundException
|
||||||
|
*/
|
||||||
|
private function loadModel()
|
||||||
|
{
|
||||||
|
// Determine Model
|
||||||
|
$model = \nre\core\ClassLoader::stripClassType(\nre\core\ClassLoader::stripClassType(\nre\core\ClassLoader::stripNamespace(get_class($this))));
|
||||||
|
|
||||||
|
// Load class
|
||||||
|
\hhu\z\models\QuesttypeModel::load($model);
|
||||||
|
|
||||||
|
// Construct Model
|
||||||
|
$modelName = ucfirst(strtolower($model));
|
||||||
|
$this->$modelName = \hhu\z\models\QuesttypeModel::factory($model);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Load the View of this QuesttypeController.
|
||||||
|
*
|
||||||
|
* @throws \nre\exceptions\ViewNotFoundException
|
||||||
|
* @param string $layoutName Name of the current Layout
|
||||||
|
* @param string $action Current Action
|
||||||
|
*/
|
||||||
|
protected function loadView($layoutName, $action)
|
||||||
|
{
|
||||||
|
// Check Layout name
|
||||||
|
if(is_null($layoutName)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Determine controller name
|
||||||
|
$controllerName = \nre\core\ClassLoader::stripClassType(\nre\core\ClassLoader::getClassName(get_class($this)));
|
||||||
|
|
||||||
|
|
||||||
|
// Load view
|
||||||
|
$this->view = \hhu\z\views\QuesttypeView::loadAndFactory($layoutName, $controllerName, $action);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
|
||||||
|
|
@ -1,328 +1,328 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Legend of Z
|
* The Legend of Z
|
||||||
*
|
*
|
||||||
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
||||||
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
|
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
|
||||||
* @license http://www.gnu.org/licenses/gpl.html
|
* @license http://www.gnu.org/licenses/gpl.html
|
||||||
* @link https://bitbucket.org/coderkun/the-legend-of-z
|
* @link https://bitbucket.org/coderkun/the-legend-of-z
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace hhu\z\controllers;
|
namespace hhu\z\controllers;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Abstract class for implementing a Controller for a Seminary and its
|
* Abstract class for implementing a Controller for a Seminary and its
|
||||||
* concepts.
|
* concepts.
|
||||||
*
|
*
|
||||||
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
||||||
*/
|
*/
|
||||||
abstract class SeminaryController extends \hhu\z\controllers\IntermediateController
|
abstract class SeminaryController extends \hhu\z\controllers\IntermediateController
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Required components
|
* Required components
|
||||||
*
|
*
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
public $components = array('achievement', 'auth', 'notification');
|
public $components = array('achievement', 'auth', 'notification');
|
||||||
/**
|
/**
|
||||||
* Required models
|
* Required models
|
||||||
*
|
*
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
public $models = array('seminaries', 'characters', 'characterroles', 'xplevels', 'avatars', 'achievements');
|
public $models = array('seminaries', 'characters', 'characterroles', 'xplevels', 'avatars', 'achievements');
|
||||||
/**
|
/**
|
||||||
* Current Seminary
|
* Current Seminary
|
||||||
*
|
*
|
||||||
* var array
|
* var array
|
||||||
*/
|
*/
|
||||||
public static $seminary = null;
|
public static $seminary = null;
|
||||||
/**
|
/**
|
||||||
* Character of current user and Seminary
|
* Character of current user and Seminary
|
||||||
*
|
*
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
public static $character = null;
|
public static $character = null;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Construct a new Seminary Controller.
|
* Construct a new Seminary Controller.
|
||||||
*
|
*
|
||||||
* @throws \nre\exceptions\DriverNotFoundException
|
* @throws \nre\exceptions\DriverNotFoundException
|
||||||
* @throws \nre\exceptions\DriverNotValidException
|
* @throws \nre\exceptions\DriverNotValidException
|
||||||
* @throws \nre\exceptions\ModelNotValidException
|
* @throws \nre\exceptions\ModelNotValidException
|
||||||
* @throws \nre\exceptions\ModelNotFoundException
|
* @throws \nre\exceptions\ModelNotFoundException
|
||||||
* @throws \nre\exceptions\ViewNotFoundException
|
* @throws \nre\exceptions\ViewNotFoundException
|
||||||
* @param string $layoutName Name of the current Layout
|
* @param string $layoutName Name of the current Layout
|
||||||
* @param string $action Current Action
|
* @param string $action Current Action
|
||||||
* @param \nre\core\Agent $agent Corresponding Agent
|
* @param \nre\core\Agent $agent Corresponding Agent
|
||||||
*/
|
*/
|
||||||
public function __construct($layoutName, $action, $agent)
|
public function __construct($layoutName, $action, $agent)
|
||||||
{
|
{
|
||||||
parent::__construct($layoutName, $action, $agent);
|
parent::__construct($layoutName, $action, $agent);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Prefilter that is executed before running the Controller.
|
* Prefilter that is executed before running the Controller.
|
||||||
*
|
*
|
||||||
* @param \nre\core\Request $request Current request
|
* @param \nre\core\Request $request Current request
|
||||||
* @param \nre\core\Response $response Current response
|
* @param \nre\core\Response $response Current response
|
||||||
*/
|
*/
|
||||||
public function preFilter(\nre\core\Request $request, \nre\core\Response $response)
|
public function preFilter(\nre\core\Request $request, \nre\core\Response $response)
|
||||||
{
|
{
|
||||||
parent::preFilter($request, $response);
|
parent::preFilter($request, $response);
|
||||||
|
|
||||||
// Get Seminary and Character data
|
// Get Seminary and Character data
|
||||||
try {
|
try {
|
||||||
self::$seminary = $this->Seminaries->getSeminaryByUrl($this->request->getParam(3));
|
self::$seminary = $this->Seminaries->getSeminaryByUrl($this->request->getParam(3));
|
||||||
if(!is_null(self::$user))
|
if(!is_null(self::$user))
|
||||||
{
|
{
|
||||||
self::$character = $this->Characters->getCharacterForUserAndSeminary(self::$user['id'], self::$seminary['id']);
|
self::$character = $this->Characters->getCharacterForUserAndSeminary(self::$user['id'], self::$seminary['id']);
|
||||||
self::$character['characterroles'] = array_map(function($r) { return $r['name']; }, $this->Characterroles->getCharacterrolesForCharacterById(self::$character['id']));
|
self::$character['characterroles'] = array_map(function($r) { return $r['name']; }, $this->Characterroles->getCharacterrolesForCharacterById(self::$character['id']));
|
||||||
try {
|
try {
|
||||||
self::$character['xplevel'] = $this->Xplevels->getXPLevelById(self::$character['xplevel_id']);
|
self::$character['xplevel'] = $this->Xplevels->getXPLevelById(self::$character['xplevel_id']);
|
||||||
self::$character['avatar'] = $this->Avatars->getAvatarByTypeAndLevel(self::$seminary['id'], self::$character['charactertype_url'], self::$character['xplevel']['level']);
|
self::$character['avatar'] = $this->Avatars->getAvatarByTypeAndLevel(self::$seminary['id'], self::$character['charactertype_url'], self::$character['xplevel']['level']);
|
||||||
}
|
}
|
||||||
catch(\nre\exceptions\IdNotFoundException $e) {
|
catch(\nre\exceptions\IdNotFoundException $e) {
|
||||||
// No Avatar available
|
// No Avatar available
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch(\nre\exceptions\IdNotFoundException $e) {
|
catch(\nre\exceptions\IdNotFoundException $e) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check permissions
|
// Check permissions
|
||||||
$this->checkPermission($request, $response);
|
$this->checkPermission($request, $response);
|
||||||
|
|
||||||
// Check achievements
|
// Check achievements
|
||||||
$this->checkAchievements($request, $response, 'date');
|
$this->checkAchievements($request, $response, 'date');
|
||||||
$this->checkAchievements($request, $response, 'achievement');
|
$this->checkAchievements($request, $response, 'achievement');
|
||||||
|
|
||||||
// Set Seminary and Character data
|
// Set Seminary and Character data
|
||||||
$this->set('loggedSeminary', self::$seminary);
|
$this->set('loggedSeminary', self::$seminary);
|
||||||
$this->set('loggedCharacter', self::$character);
|
$this->set('loggedCharacter', self::$character);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Postfilter that is executed after running the Controller.
|
* Postfilter that is executed after running the Controller.
|
||||||
*
|
*
|
||||||
* @param \nre\core\Request $request Current request
|
* @param \nre\core\Request $request Current request
|
||||||
* @param \nre\core\Response $response Current response
|
* @param \nre\core\Response $response Current response
|
||||||
*/
|
*/
|
||||||
public function postFilter(\nre\core\Request $request, \nre\core\Response $response)
|
public function postFilter(\nre\core\Request $request, \nre\core\Response $response)
|
||||||
{
|
{
|
||||||
parent::postFilter($request, $response);
|
parent::postFilter($request, $response);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check user permissions.
|
* Check user permissions.
|
||||||
*
|
*
|
||||||
* @throws AccessDeniedException
|
* @throws AccessDeniedException
|
||||||
* @param \nre\core\Request $request Current request
|
* @param \nre\core\Request $request Current request
|
||||||
* @param \nre\core\Response $response Current response
|
* @param \nre\core\Response $response Current response
|
||||||
*/
|
*/
|
||||||
private function checkPermission(\nre\core\Request $request, \nre\core\Response $response)
|
private function checkPermission(\nre\core\Request $request, \nre\core\Response $response)
|
||||||
{
|
{
|
||||||
// Do not check index page
|
// Do not check index page
|
||||||
if(is_null($request->getParam(3))) {
|
if(is_null($request->getParam(3))) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Determine permissions for current action
|
// Determine permissions for current action
|
||||||
$action = $this->request->getParam(2, 'action');
|
$action = $this->request->getParam(2, 'action');
|
||||||
if(!property_exists($this, 'seminaryPermissions')) {
|
if(!property_exists($this, 'seminaryPermissions')) {
|
||||||
return; // Allow if nothing is specified
|
return; // Allow if nothing is specified
|
||||||
}
|
}
|
||||||
if(!array_key_exists($action, $this->seminaryPermissions)) {
|
if(!array_key_exists($action, $this->seminaryPermissions)) {
|
||||||
return; // Allow if Action is not specified
|
return; // Allow if Action is not specified
|
||||||
}
|
}
|
||||||
$permissions = $this->seminaryPermissions[$action];
|
$permissions = $this->seminaryPermissions[$action];
|
||||||
|
|
||||||
|
|
||||||
// Check permissions
|
// Check permissions
|
||||||
if(is_null(self::$character) || !array_key_exists('characterroles', self::$character) || count(array_intersect(self::$character['characterroles'], $permissions)) == 0) {
|
if(is_null(self::$character) || !array_key_exists('characterroles', self::$character) || count(array_intersect(self::$character['characterroles'], $permissions)) == 0) {
|
||||||
throw new \nre\exceptions\AccessDeniedException();
|
throw new \nre\exceptions\AccessDeniedException();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check for newly achieved Achievements.
|
* Check for newly achieved Achievements.
|
||||||
*
|
*
|
||||||
* @param \nre\core\Request $request Current request
|
* @param \nre\core\Request $request Current request
|
||||||
* @param \nre\core\Response $response Current response
|
* @param \nre\core\Response $response Current response
|
||||||
* @param array $checkConditions Conditions to check
|
* @param array $checkConditions Conditions to check
|
||||||
*/
|
*/
|
||||||
protected function checkAchievements(\nre\core\Request $request, \nre\core\Response $response, $checkConditions=null)
|
protected function checkAchievements(\nre\core\Request $request, \nre\core\Response $response, $checkConditions=null)
|
||||||
{
|
{
|
||||||
// Do not check MediaController
|
// Do not check MediaController
|
||||||
if($this->request->getParam(0, 'toplevel') != \nre\configs\AppConfig::$defaults['toplevel']) {
|
if($this->request->getParam(0, 'toplevel') != \nre\configs\AppConfig::$defaults['toplevel']) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if Character is present
|
// Check if Character is present
|
||||||
if(is_null(self::$character)) {
|
if(is_null(self::$character)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set conditions to check
|
// Set conditions to check
|
||||||
if(!is_null($checkConditions) && !is_array($checkConditions)) {
|
if(!is_null($checkConditions) && !is_array($checkConditions)) {
|
||||||
$checkConditions = array($checkConditions);
|
$checkConditions = array($checkConditions);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get unachieved Achievments
|
// Get unachieved Achievments
|
||||||
$achievements = $this->Achievements->getUnachhievedAchievementsForCharacter(self::$seminary['id'], self::$character['id']);
|
$achievements = $this->Achievements->getUnachhievedAchievementsForCharacter(self::$seminary['id'], self::$character['id']);
|
||||||
if(in_array('user', self::$character['characterroles'])) {
|
if(in_array('user', self::$character['characterroles'])) {
|
||||||
$achievements = array_merge($achievements, $this->Achievements->getUnachievedOnlyOnceAchievementsForSeminary(self::$seminary['id']));
|
$achievements = array_merge($achievements, $this->Achievements->getUnachievedOnlyOnceAchievementsForSeminary(self::$seminary['id']));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check conditions
|
// Check conditions
|
||||||
foreach($achievements as &$achievement)
|
foreach($achievements as &$achievement)
|
||||||
{
|
{
|
||||||
// Check condition to test
|
// Check condition to test
|
||||||
if(!is_null($checkConditions) && !in_array($achievement['condition'], $checkConditions)) {
|
if(!is_null($checkConditions) && !in_array($achievement['condition'], $checkConditions)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check deadline
|
// Check deadline
|
||||||
if(!is_null($achievement['deadline']) && $achievement['deadline'] < date('Y-m-d H:i:s')) {
|
if(!is_null($achievement['deadline']) && $achievement['deadline'] < date('Y-m-d H:i:s')) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get conditions
|
// Get conditions
|
||||||
$conditions = array();
|
$conditions = array();
|
||||||
$progress = 0;
|
$progress = 0;
|
||||||
switch($achievement['condition'])
|
switch($achievement['condition'])
|
||||||
{
|
{
|
||||||
// Date conditions
|
// Date conditions
|
||||||
case 'date':
|
case 'date':
|
||||||
$conditionsDate = $this->Achievements->getAchievementConditionsDate($achievement['id']);
|
$conditionsDate = $this->Achievements->getAchievementConditionsDate($achievement['id']);
|
||||||
foreach($conditionsDate as &$condition)
|
foreach($conditionsDate as &$condition)
|
||||||
{
|
{
|
||||||
$conditions[] = array(
|
$conditions[] = array(
|
||||||
'func' => 'checkAchievementConditionDate',
|
'func' => 'checkAchievementConditionDate',
|
||||||
'params' => array(
|
'params' => array(
|
||||||
$condition['select']
|
$condition['select']
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
// Character conditions
|
// Character conditions
|
||||||
case 'character':
|
case 'character':
|
||||||
$conditionsCharacter = $this->Achievements->getAchievementConditionsCharacter($achievement['id']);
|
$conditionsCharacter = $this->Achievements->getAchievementConditionsCharacter($achievement['id']);
|
||||||
foreach($conditionsCharacter as &$condition)
|
foreach($conditionsCharacter as &$condition)
|
||||||
{
|
{
|
||||||
$conditions[] = array(
|
$conditions[] = array(
|
||||||
'func' => 'checkAchievementConditionCharacter',
|
'func' => 'checkAchievementConditionCharacter',
|
||||||
'params' => array(
|
'params' => array(
|
||||||
$condition['field'],
|
$condition['field'],
|
||||||
$condition['value'],
|
$condition['value'],
|
||||||
self::$character['id']
|
self::$character['id']
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
// Quest conditions
|
// Quest conditions
|
||||||
case 'quest':
|
case 'quest':
|
||||||
$conditionsQuest = $this->Achievements->getAchievementConditionsQuest($achievement['id']);
|
$conditionsQuest = $this->Achievements->getAchievementConditionsQuest($achievement['id']);
|
||||||
foreach($conditionsQuest as &$condition)
|
foreach($conditionsQuest as &$condition)
|
||||||
{
|
{
|
||||||
$conditions[] = array(
|
$conditions[] = array(
|
||||||
'func' => 'checkAchievementConditionQuest',
|
'func' => 'checkAchievementConditionQuest',
|
||||||
'params' => array(
|
'params' => array(
|
||||||
$condition['field'],
|
$condition['field'],
|
||||||
$condition['count'],
|
$condition['count'],
|
||||||
$condition['value'],
|
$condition['value'],
|
||||||
$condition['status'],
|
$condition['status'],
|
||||||
$condition['groupby'],
|
$condition['groupby'],
|
||||||
$condition['quest_id'],
|
$condition['quest_id'],
|
||||||
self::$character['id']
|
self::$character['id']
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
// Achievement conditions
|
// Achievement conditions
|
||||||
case 'achievement':
|
case 'achievement':
|
||||||
$conditionsAchievement = $this->Achievements->getAchievementConditionsAchievement($achievement['id']);
|
$conditionsAchievement = $this->Achievements->getAchievementConditionsAchievement($achievement['id']);
|
||||||
foreach($conditionsAchievement as &$condition)
|
foreach($conditionsAchievement as &$condition)
|
||||||
{
|
{
|
||||||
$conditions[] = array(
|
$conditions[] = array(
|
||||||
'func' => 'checkAchievementConditionAchievement',
|
'func' => 'checkAchievementConditionAchievement',
|
||||||
'params' => array(
|
'params' => array(
|
||||||
$condition['field'],
|
$condition['field'],
|
||||||
$condition['count'],
|
$condition['count'],
|
||||||
$condition['value'],
|
$condition['value'],
|
||||||
$condition['groupby'],
|
$condition['groupby'],
|
||||||
$condition['meta_achievement_id'],
|
$condition['meta_achievement_id'],
|
||||||
self::$character['id']
|
self::$character['id']
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Do not achieve Achievements without conditions
|
// Do not achieve Achievements without conditions
|
||||||
if(empty($conditions)) {
|
if(empty($conditions)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check conditions
|
// Check conditions
|
||||||
$achieved = ($achievement['all_conditions'] == 1);
|
$achieved = ($achievement['all_conditions'] == 1);
|
||||||
foreach($conditions as &$condition)
|
foreach($conditions as &$condition)
|
||||||
{
|
{
|
||||||
// Calculate result of condition
|
// Calculate result of condition
|
||||||
$result = call_user_func_array(
|
$result = call_user_func_array(
|
||||||
array(
|
array(
|
||||||
$this->Achievements,
|
$this->Achievements,
|
||||||
$condition['func']
|
$condition['func']
|
||||||
),
|
),
|
||||||
$condition['params']
|
$condition['params']
|
||||||
);
|
);
|
||||||
|
|
||||||
// The overall result and abort if possible
|
// The overall result and abort if possible
|
||||||
if($achievement['all_conditions'])
|
if($achievement['all_conditions'])
|
||||||
{
|
{
|
||||||
if(!$result) {
|
if(!$result) {
|
||||||
$achieved = false;
|
$achieved = false;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if($result) {
|
if($result) {
|
||||||
$achieved = true;
|
$achieved = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Achievement achieved
|
// Achievement achieved
|
||||||
if($achieved)
|
if($achieved)
|
||||||
{
|
{
|
||||||
// Set status
|
// Set status
|
||||||
$this->Achievements->setAchievementAchieved($achievement['id'], self::$character['id']);
|
$this->Achievements->setAchievementAchieved($achievement['id'], self::$character['id']);
|
||||||
|
|
||||||
// Add notification
|
// Add notification
|
||||||
$this->Notification->addNotification(
|
$this->Notification->addNotification(
|
||||||
\hhu\z\controllers\components\NotificationComponent::TYPE_ACHIEVEMENT,
|
\hhu\z\controllers\components\NotificationComponent::TYPE_ACHIEVEMENT,
|
||||||
$achievement['title'],
|
$achievement['title'],
|
||||||
$this->linker->link(array('achievements', 'index', self::$seminary['url']), 0, true, null, true, $achievement['url']),
|
$this->linker->link(array('achievements', 'index', self::$seminary['url']), 0, true, null, true, $achievement['url']),
|
||||||
(!is_null($achievement['achieved_achievementsmedia_id']) ? $this->linker->link(array('media','achievement',self::$seminary['url'],$achievement['url'])) : null)
|
(!is_null($achievement['achieved_achievementsmedia_id']) ? $this->linker->link(array('media','achievement',self::$seminary['url'],$achievement['url'])) : null)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
|
||||||
|
|
@ -1,79 +1,79 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Legend of Z
|
* The Legend of Z
|
||||||
*
|
*
|
||||||
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
||||||
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
|
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
|
||||||
* @license http://www.gnu.org/licenses/gpl.html
|
* @license http://www.gnu.org/licenses/gpl.html
|
||||||
* @link https://bitbucket.org/coderkun/the-legend-of-z
|
* @link https://bitbucket.org/coderkun/the-legend-of-z
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace hhu\z\exceptions;
|
namespace hhu\z\exceptions;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Exception: File copy went wrong
|
* Exception: File copy went wrong
|
||||||
*
|
*
|
||||||
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
||||||
*/
|
*/
|
||||||
class FileCopyException extends \nre\core\Exception
|
class FileCopyException extends \nre\core\Exception
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Error code
|
* Error code
|
||||||
*
|
*
|
||||||
* @var int
|
* @var int
|
||||||
*/
|
*/
|
||||||
const CODE = 204;
|
const CODE = 204;
|
||||||
/**
|
/**
|
||||||
* Error message
|
* Error message
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
const MESSAGE = 'File copy went wrong';
|
const MESSAGE = 'File copy went wrong';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Nested error
|
* Nested error
|
||||||
*
|
*
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
private $nestedError;
|
private $nestedError;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Construct a new exception.
|
* Construct a new exception.
|
||||||
*
|
*
|
||||||
* @param array $nestedError Nested error
|
* @param array $nestedError Nested error
|
||||||
* @param string $message Error message
|
* @param string $message Error message
|
||||||
* @param int $code Error code
|
* @param int $code Error code
|
||||||
*/
|
*/
|
||||||
function __construct($nestedError, $message=self::MESSAGE, $code=self::CODE)
|
function __construct($nestedError, $message=self::MESSAGE, $code=self::CODE)
|
||||||
{
|
{
|
||||||
parent::__construct(
|
parent::__construct(
|
||||||
$message,
|
$message,
|
||||||
$code,
|
$code,
|
||||||
$nestedError['message']
|
$nestedError['message']
|
||||||
);
|
);
|
||||||
|
|
||||||
// Store values
|
// Store values
|
||||||
$this->nestedError = $nestedError;
|
$this->nestedError = $nestedError;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get nested error.
|
* Get nested error.
|
||||||
*
|
*
|
||||||
* @return Nested error
|
* @return Nested error
|
||||||
*/
|
*/
|
||||||
public function getNestedError()
|
public function getNestedError()
|
||||||
{
|
{
|
||||||
return $this->nestedError;
|
return $this->nestedError;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
|
||||||
|
|
@ -1,79 +1,79 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Legend of Z
|
* The Legend of Z
|
||||||
*
|
*
|
||||||
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
||||||
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
|
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
|
||||||
* @license http://www.gnu.org/licenses/gpl.html
|
* @license http://www.gnu.org/licenses/gpl.html
|
||||||
* @link https://bitbucket.org/coderkun/the-legend-of-z
|
* @link https://bitbucket.org/coderkun/the-legend-of-z
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace hhu\z\exceptions;
|
namespace hhu\z\exceptions;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Exception: File upload went wrong
|
* Exception: File upload went wrong
|
||||||
*
|
*
|
||||||
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
||||||
*/
|
*/
|
||||||
class FileUploadException extends \nre\core\Exception
|
class FileUploadException extends \nre\core\Exception
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Error code
|
* Error code
|
||||||
*
|
*
|
||||||
* @var int
|
* @var int
|
||||||
*/
|
*/
|
||||||
const CODE = 203;
|
const CODE = 203;
|
||||||
/**
|
/**
|
||||||
* Error message
|
* Error message
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
const MESSAGE = 'File upload went wrong';
|
const MESSAGE = 'File upload went wrong';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Nested message
|
* Nested message
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
private $nestedMessage;
|
private $nestedMessage;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Construct a new exception.
|
* Construct a new exception.
|
||||||
*
|
*
|
||||||
* @param string $nestedMessage Nested message
|
* @param string $nestedMessage Nested message
|
||||||
* @param string $message Error message
|
* @param string $message Error message
|
||||||
* @param int $code Error code
|
* @param int $code Error code
|
||||||
*/
|
*/
|
||||||
function __construct($nestedMessage=null, $message=self::MESSAGE, $code=self::CODE)
|
function __construct($nestedMessage=null, $message=self::MESSAGE, $code=self::CODE)
|
||||||
{
|
{
|
||||||
parent::__construct(
|
parent::__construct(
|
||||||
$message,
|
$message,
|
||||||
$code,
|
$code,
|
||||||
$nestedMessage
|
$nestedMessage
|
||||||
);
|
);
|
||||||
|
|
||||||
// Store values
|
// Store values
|
||||||
$this->nestedMessage = $nestedMessage;
|
$this->nestedMessage = $nestedMessage;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get nested message.
|
* Get nested message.
|
||||||
*
|
*
|
||||||
* @return Nested message
|
* @return Nested message
|
||||||
*/
|
*/
|
||||||
public function getNestedMessage()
|
public function getNestedMessage()
|
||||||
{
|
{
|
||||||
return $this->nestedMessage;
|
return $this->nestedMessage;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
|
||||||
|
|
@ -1,79 +1,79 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Legend of Z
|
* The Legend of Z
|
||||||
*
|
*
|
||||||
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
||||||
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
|
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
|
||||||
* @license http://www.gnu.org/licenses/gpl.html
|
* @license http://www.gnu.org/licenses/gpl.html
|
||||||
* @link https://bitbucket.org/coderkun/the-legend-of-z
|
* @link https://bitbucket.org/coderkun/the-legend-of-z
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace hhu\z\exceptions;
|
namespace hhu\z\exceptions;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Exception during sending of an e‑mail.
|
* Exception during sending of an e‑mail.
|
||||||
*
|
*
|
||||||
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
||||||
*/
|
*/
|
||||||
class MailingException extends \nre\core\Exception
|
class MailingException extends \nre\core\Exception
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Error code
|
* Error code
|
||||||
*
|
*
|
||||||
* @var int
|
* @var int
|
||||||
*/
|
*/
|
||||||
const CODE = 300;
|
const CODE = 300;
|
||||||
/**
|
/**
|
||||||
* Error message
|
* Error message
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
const MESSAGE = 'Error sending e‑mail';
|
const MESSAGE = 'Error sending e‑mail';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Nested error message
|
* Nested error message
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
private $error;
|
private $error;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Construct a new exception.
|
* Construct a new exception.
|
||||||
*
|
*
|
||||||
* @param int $error Nested error message
|
* @param int $error Nested error message
|
||||||
* @param string $message Error message
|
* @param string $message Error message
|
||||||
* @param int $code Error code
|
* @param int $code Error code
|
||||||
*/
|
*/
|
||||||
function __construct($error, $message=self::MESSAGE, $code=self::CODE)
|
function __construct($error, $message=self::MESSAGE, $code=self::CODE)
|
||||||
{
|
{
|
||||||
parent::__construct(
|
parent::__construct(
|
||||||
$message,
|
$message,
|
||||||
$code,
|
$code,
|
||||||
$error
|
$error
|
||||||
);
|
);
|
||||||
|
|
||||||
// Store values
|
// Store values
|
||||||
$this->error = $error;
|
$this->error = $error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get nested error message.
|
* Get nested error message.
|
||||||
*
|
*
|
||||||
* @return string Nested error message
|
* @return string Nested error message
|
||||||
*/
|
*/
|
||||||
public function getError()
|
public function getError()
|
||||||
{
|
{
|
||||||
return $this->error;
|
return $this->error;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
|
||||||
|
|
@ -1,54 +1,54 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Legend of Z
|
* The Legend of Z
|
||||||
*
|
*
|
||||||
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
||||||
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
|
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
|
||||||
* @license http://www.gnu.org/licenses/gpl.html
|
* @license http://www.gnu.org/licenses/gpl.html
|
||||||
* @link https://bitbucket.org/coderkun/the-legend-of-z
|
* @link https://bitbucket.org/coderkun/the-legend-of-z
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace hhu\z\exceptions;
|
namespace hhu\z\exceptions;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Exception: File exceeds size maximum.
|
* Exception: File exceeds size maximum.
|
||||||
*
|
*
|
||||||
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
||||||
*/
|
*/
|
||||||
class MaxFilesizeException extends \nre\core\Exception
|
class MaxFilesizeException extends \nre\core\Exception
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Error code
|
* Error code
|
||||||
*
|
*
|
||||||
* @var int
|
* @var int
|
||||||
*/
|
*/
|
||||||
const CODE = 202;
|
const CODE = 202;
|
||||||
/**
|
/**
|
||||||
* Error message
|
* Error message
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
const MESSAGE = 'File exceeds size maximum';
|
const MESSAGE = 'File exceeds size maximum';
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Construct a new exception.
|
* Construct a new exception.
|
||||||
*
|
*
|
||||||
* @param string $message Error message
|
* @param string $message Error message
|
||||||
* @param int $code Error code
|
* @param int $code Error code
|
||||||
*/
|
*/
|
||||||
function __construct($message=self::MESSAGE, $code=self::CODE)
|
function __construct($message=self::MESSAGE, $code=self::CODE)
|
||||||
{
|
{
|
||||||
parent::__construct(
|
parent::__construct(
|
||||||
$message,
|
$message,
|
||||||
$code
|
$code
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
|
||||||
|
|
@ -1,79 +1,79 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Legend of Z
|
* The Legend of Z
|
||||||
*
|
*
|
||||||
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
||||||
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
|
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
|
||||||
* @license http://www.gnu.org/licenses/gpl.html
|
* @license http://www.gnu.org/licenses/gpl.html
|
||||||
* @link https://bitbucket.org/coderkun/the-legend-of-z
|
* @link https://bitbucket.org/coderkun/the-legend-of-z
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace hhu\z\exceptions;
|
namespace hhu\z\exceptions;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Exception: QuesttypeAgent not found.
|
* Exception: QuesttypeAgent not found.
|
||||||
*
|
*
|
||||||
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
||||||
*/
|
*/
|
||||||
class QuesttypeAgentNotFoundException extends \nre\core\Exception
|
class QuesttypeAgentNotFoundException extends \nre\core\Exception
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Error code
|
* Error code
|
||||||
*
|
*
|
||||||
* @var int
|
* @var int
|
||||||
*/
|
*/
|
||||||
const CODE = 101;
|
const CODE = 101;
|
||||||
/**
|
/**
|
||||||
* Error message
|
* Error message
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
const MESSAGE = 'QuesttypeAgent not found';
|
const MESSAGE = 'QuesttypeAgent not found';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Name of the class that was not found
|
* Name of the class that was not found
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
private $questtypeName;
|
private $questtypeName;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Construct a new exception.
|
* Construct a new exception.
|
||||||
*
|
*
|
||||||
* @param string $questtypeName Name of the QuesttypeAgent that was not found
|
* @param string $questtypeName Name of the QuesttypeAgent that was not found
|
||||||
* @param string $message Error message
|
* @param string $message Error message
|
||||||
* @param int $code Error code
|
* @param int $code Error code
|
||||||
*/
|
*/
|
||||||
function __construct($questtypeName, $message=self::MESSAGE, $code=self::CODE)
|
function __construct($questtypeName, $message=self::MESSAGE, $code=self::CODE)
|
||||||
{
|
{
|
||||||
parent::__construct(
|
parent::__construct(
|
||||||
$message,
|
$message,
|
||||||
$code,
|
$code,
|
||||||
$questtypeName
|
$questtypeName
|
||||||
);
|
);
|
||||||
|
|
||||||
// Store values
|
// Store values
|
||||||
$this->questtypeName = $questtypeName;
|
$this->questtypeName = $questtypeName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the name of the QuesttypeAgent that was not found.
|
* Get the name of the QuesttypeAgent that was not found.
|
||||||
*
|
*
|
||||||
* @return string Name of the QuesttypeAgent that was not found
|
* @return string Name of the QuesttypeAgent that was not found
|
||||||
*/
|
*/
|
||||||
public function getClassName()
|
public function getClassName()
|
||||||
{
|
{
|
||||||
return $this->questtypeName;
|
return $this->questtypeName;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
|
||||||
|
|
@ -1,79 +1,79 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Legend of Z
|
* The Legend of Z
|
||||||
*
|
*
|
||||||
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
||||||
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
|
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
|
||||||
* @license http://www.gnu.org/licenses/gpl.html
|
* @license http://www.gnu.org/licenses/gpl.html
|
||||||
* @link https://bitbucket.org/coderkun/the-legend-of-z
|
* @link https://bitbucket.org/coderkun/the-legend-of-z
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace hhu\z\exceptions;
|
namespace hhu\z\exceptions;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Exception: QuesttypeAgent not valid.
|
* Exception: QuesttypeAgent not valid.
|
||||||
*
|
*
|
||||||
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
||||||
*/
|
*/
|
||||||
class QuesttypeAgentNotValidException extends \nre\core\Exception
|
class QuesttypeAgentNotValidException extends \nre\core\Exception
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Error code
|
* Error code
|
||||||
*
|
*
|
||||||
* @var int
|
* @var int
|
||||||
*/
|
*/
|
||||||
const CODE = 102;
|
const CODE = 102;
|
||||||
/**
|
/**
|
||||||
* Error message
|
* Error message
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
const MESSAGE = 'QuesttypeAgent not valid';
|
const MESSAGE = 'QuesttypeAgent not valid';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Name of the invalid class
|
* Name of the invalid class
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
private $questtypeName;
|
private $questtypeName;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Construct a new exception.
|
* Construct a new exception.
|
||||||
*
|
*
|
||||||
* @param string $questtypeName Name of the invalid QuesttypeAgent
|
* @param string $questtypeName Name of the invalid QuesttypeAgent
|
||||||
* @param string $message Error message
|
* @param string $message Error message
|
||||||
* @param int $code Error code
|
* @param int $code Error code
|
||||||
*/
|
*/
|
||||||
function __construct($questtypeName, $message=self::MESSAGE, $code=self::CODE)
|
function __construct($questtypeName, $message=self::MESSAGE, $code=self::CODE)
|
||||||
{
|
{
|
||||||
parent::__construct(
|
parent::__construct(
|
||||||
$message,
|
$message,
|
||||||
$code,
|
$code,
|
||||||
$questtypeName
|
$questtypeName
|
||||||
);
|
);
|
||||||
|
|
||||||
// Store value
|
// Store value
|
||||||
$this->questtypeName = $questtypeName;
|
$this->questtypeName = $questtypeName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the name of the invalid QuesttypeAgent.
|
* Get the name of the invalid QuesttypeAgent.
|
||||||
*
|
*
|
||||||
* @return string Name of the invalid QuesttypeAgent
|
* @return string Name of the invalid QuesttypeAgent
|
||||||
*/
|
*/
|
||||||
public function getClassName()
|
public function getClassName()
|
||||||
{
|
{
|
||||||
return $this->questtypeName;
|
return $this->questtypeName;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
|
||||||
|
|
@ -1,79 +1,79 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Legend of Z
|
* The Legend of Z
|
||||||
*
|
*
|
||||||
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
* @author Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
||||||
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
|
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
|
||||||
* @license http://www.gnu.org/licenses/gpl.html
|
* @license http://www.gnu.org/licenses/gpl.html
|
||||||
* @link https://bitbucket.org/coderkun/the-legend-of-z
|
* @link https://bitbucket.org/coderkun/the-legend-of-z
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace hhu\z\exceptions;
|
namespace hhu\z\exceptions;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Exception: QuesttypeController not found.
|
* Exception: QuesttypeController not found.
|
||||||
*
|
*
|
||||||
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
||||||
*/
|
*/
|
||||||
class QuesttypeControllerNotFoundException extends \nre\core\Exception
|
class QuesttypeControllerNotFoundException extends \nre\core\Exception
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Error code
|
* Error code
|
||||||
*
|
*
|
||||||
* @var int
|
* @var int
|
||||||
*/
|
*/
|
||||||
const CODE = 103;
|
const CODE = 103;
|
||||||
/**
|
/**
|
||||||
* Error message
|
* Error message
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
const MESSAGE = 'QuesttypeController not found';
|
const MESSAGE = 'QuesttypeController not found';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Name of the class that was not found
|
* Name of the class that was not found
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
private $questtypeName;
|
private $questtypeName;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Construct a new exception.
|
* Construct a new exception.
|
||||||
*
|
*
|
||||||
* @param string $questtypeName Name of the QuesttypeController that was not found
|
* @param string $questtypeName Name of the QuesttypeController that was not found
|
||||||
* @param string $message Error message
|
* @param string $message Error message
|
||||||
* @param int $code Error code
|
* @param int $code Error code
|
||||||
*/
|
*/
|
||||||
function __construct($questtypeName, $message=self::MESSAGE, $code=self::CODE)
|
function __construct($questtypeName, $message=self::MESSAGE, $code=self::CODE)
|
||||||
{
|
{
|
||||||
parent::__construct(
|
parent::__construct(
|
||||||
$message,
|
$message,
|
||||||
$code,
|
$code,
|
||||||
$questtypeName
|
$questtypeName
|
||||||
);
|
);
|
||||||
|
|
||||||
// Store values
|
// Store values
|
||||||
$this->questtypeName = $questtypeName;
|
$this->questtypeName = $questtypeName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the name of the QuesttypeController that was not found.
|
* Get the name of the QuesttypeController that was not found.
|
||||||
*
|
*
|
||||||
* @return string Name of the QuesttypeController that was not found
|
* @return string Name of the QuesttypeController that was not found
|
||||||
*/
|
*/
|
||||||
public function getClassName()
|
public function getClassName()
|
||||||
{
|
{
|
||||||
return $this->questtypeName;
|
return $this->questtypeName;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
|
||||||
|
|
@ -1,79 +1,79 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Legend of Z
|
* The Legend of Z
|
||||||
*
|
*
|
||||||
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
||||||
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
|
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
|
||||||
* @license http://www.gnu.org/licenses/gpl.html
|
* @license http://www.gnu.org/licenses/gpl.html
|
||||||
* @link https://bitbucket.org/coderkun/the-legend-of-z
|
* @link https://bitbucket.org/coderkun/the-legend-of-z
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace hhu\z\exceptions;
|
namespace hhu\z\exceptions;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Exception: QuesttypeController not valid.
|
* Exception: QuesttypeController not valid.
|
||||||
*
|
*
|
||||||
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
||||||
*/
|
*/
|
||||||
class QuesttypeControllerNotValidException extends \nre\core\Exception
|
class QuesttypeControllerNotValidException extends \nre\core\Exception
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Error code
|
* Error code
|
||||||
*
|
*
|
||||||
* @var int
|
* @var int
|
||||||
*/
|
*/
|
||||||
const CODE = 104;
|
const CODE = 104;
|
||||||
/**
|
/**
|
||||||
* Error message
|
* Error message
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
const MESSAGE = 'QuesttypeController not valid';
|
const MESSAGE = 'QuesttypeController not valid';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Name of the invalid class
|
* Name of the invalid class
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
private $questtypeName;
|
private $questtypeName;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Construct a new exception.
|
* Construct a new exception.
|
||||||
*
|
*
|
||||||
* @param string $questtypeName Name of the invalid QuesttypeController
|
* @param string $questtypeName Name of the invalid QuesttypeController
|
||||||
* @param string $message Error message
|
* @param string $message Error message
|
||||||
* @param int $code Error code
|
* @param int $code Error code
|
||||||
*/
|
*/
|
||||||
function __construct($questtypeName, $message=self::MESSAGE, $code=self::CODE)
|
function __construct($questtypeName, $message=self::MESSAGE, $code=self::CODE)
|
||||||
{
|
{
|
||||||
parent::__construct(
|
parent::__construct(
|
||||||
$message,
|
$message,
|
||||||
$code,
|
$code,
|
||||||
$questtypeName
|
$questtypeName
|
||||||
);
|
);
|
||||||
|
|
||||||
// Store value
|
// Store value
|
||||||
$this->questtypeName = $questtypeName;
|
$this->questtypeName = $questtypeName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the name of the invalid QuesttypeController.
|
* Get the name of the invalid QuesttypeController.
|
||||||
*
|
*
|
||||||
* @return string Name of the invalid QuesttypeController
|
* @return string Name of the invalid QuesttypeController
|
||||||
*/
|
*/
|
||||||
public function getClassName()
|
public function getClassName()
|
||||||
{
|
{
|
||||||
return $this->questtypeName;
|
return $this->questtypeName;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
|
||||||
|
|
@ -1,79 +1,79 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Legend of Z
|
* The Legend of Z
|
||||||
*
|
*
|
||||||
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
||||||
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
|
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
|
||||||
* @license http://www.gnu.org/licenses/gpl.html
|
* @license http://www.gnu.org/licenses/gpl.html
|
||||||
* @link https://bitbucket.org/coderkun/the-legend-of-z
|
* @link https://bitbucket.org/coderkun/the-legend-of-z
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace hhu\z\exceptions;
|
namespace hhu\z\exceptions;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Exception: QuesttypeModel not found.
|
* Exception: QuesttypeModel not found.
|
||||||
*
|
*
|
||||||
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
||||||
*/
|
*/
|
||||||
class QuesttypeModelNotFoundException extends \nre\core\Exception
|
class QuesttypeModelNotFoundException extends \nre\core\Exception
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Error code
|
* Error code
|
||||||
*
|
*
|
||||||
* @var int
|
* @var int
|
||||||
*/
|
*/
|
||||||
const CODE = 105;
|
const CODE = 105;
|
||||||
/**
|
/**
|
||||||
* Error message
|
* Error message
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
const MESSAGE = 'QuesttypeModel not found';
|
const MESSAGE = 'QuesttypeModel not found';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Name of the class that was not found
|
* Name of the class that was not found
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
private $questtypeName;
|
private $questtypeName;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Construct a new exception.
|
* Construct a new exception.
|
||||||
*
|
*
|
||||||
* @param string $questtypeName Name of the QuesttypeModel that was not found
|
* @param string $questtypeName Name of the QuesttypeModel that was not found
|
||||||
* @param string $message Error message
|
* @param string $message Error message
|
||||||
* @param int $code Error code
|
* @param int $code Error code
|
||||||
*/
|
*/
|
||||||
function __construct($questtypeName, $message=self::MESSAGE, $code=self::CODE)
|
function __construct($questtypeName, $message=self::MESSAGE, $code=self::CODE)
|
||||||
{
|
{
|
||||||
parent::__construct(
|
parent::__construct(
|
||||||
$message,
|
$message,
|
||||||
$code,
|
$code,
|
||||||
$questtypeName
|
$questtypeName
|
||||||
);
|
);
|
||||||
|
|
||||||
// Store values
|
// Store values
|
||||||
$this->questtypeName = $questtypeName;
|
$this->questtypeName = $questtypeName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the name of the QuesttypeModel that was not found.
|
* Get the name of the QuesttypeModel that was not found.
|
||||||
*
|
*
|
||||||
* @return string Name of the QuesttypeModel that was not found
|
* @return string Name of the QuesttypeModel that was not found
|
||||||
*/
|
*/
|
||||||
public function getClassName()
|
public function getClassName()
|
||||||
{
|
{
|
||||||
return $this->questtypeName;
|
return $this->questtypeName;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
|
||||||
|
|
@ -1,79 +1,79 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Legend of Z
|
* The Legend of Z
|
||||||
*
|
*
|
||||||
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
||||||
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
|
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
|
||||||
* @license http://www.gnu.org/licenses/gpl.html
|
* @license http://www.gnu.org/licenses/gpl.html
|
||||||
* @link https://bitbucket.org/coderkun/the-legend-of-z
|
* @link https://bitbucket.org/coderkun/the-legend-of-z
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace hhu\z\exceptions;
|
namespace hhu\z\exceptions;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Exception: QuesttypeModel not valid.
|
* Exception: QuesttypeModel not valid.
|
||||||
*
|
*
|
||||||
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
||||||
*/
|
*/
|
||||||
class QuesttypeModelNotValidException extends \nre\core\Exception
|
class QuesttypeModelNotValidException extends \nre\core\Exception
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Error code
|
* Error code
|
||||||
*
|
*
|
||||||
* @var int
|
* @var int
|
||||||
*/
|
*/
|
||||||
const CODE = 106;
|
const CODE = 106;
|
||||||
/**
|
/**
|
||||||
* Error message
|
* Error message
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
const MESSAGE = 'QuesttypeModel not valid';
|
const MESSAGE = 'QuesttypeModel not valid';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Name of the invalid class
|
* Name of the invalid class
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
private $questtypeName;
|
private $questtypeName;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Construct a new exception.
|
* Construct a new exception.
|
||||||
*
|
*
|
||||||
* @param string $questtypeName Name of the invalid QuesttypeModel
|
* @param string $questtypeName Name of the invalid QuesttypeModel
|
||||||
* @param string $message Error message
|
* @param string $message Error message
|
||||||
* @param int $code Error code
|
* @param int $code Error code
|
||||||
*/
|
*/
|
||||||
function __construct($questtypeName, $message=self::MESSAGE, $code=self::CODE)
|
function __construct($questtypeName, $message=self::MESSAGE, $code=self::CODE)
|
||||||
{
|
{
|
||||||
parent::__construct(
|
parent::__construct(
|
||||||
$message,
|
$message,
|
||||||
$code,
|
$code,
|
||||||
$questtypeName
|
$questtypeName
|
||||||
);
|
);
|
||||||
|
|
||||||
// Store value
|
// Store value
|
||||||
$this->questtypeName = $questtypeName;
|
$this->questtypeName = $questtypeName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the name of the invalid QuesttypeModel.
|
* Get the name of the invalid QuesttypeModel.
|
||||||
*
|
*
|
||||||
* @return string Name of the invalid QuesttypeModel
|
* @return string Name of the invalid QuesttypeModel
|
||||||
*/
|
*/
|
||||||
public function getClassName()
|
public function getClassName()
|
||||||
{
|
{
|
||||||
return $this->questtypeName;
|
return $this->questtypeName;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
|
||||||
|
|
@ -1,79 +1,79 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Legend of Z
|
* The Legend of Z
|
||||||
*
|
*
|
||||||
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
||||||
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
|
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
|
||||||
* @license http://www.gnu.org/licenses/gpl.html
|
* @license http://www.gnu.org/licenses/gpl.html
|
||||||
* @link https://bitbucket.org/coderkun/the-legend-of-z
|
* @link https://bitbucket.org/coderkun/the-legend-of-z
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace hhu\z\exceptions;
|
namespace hhu\z\exceptions;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Exception: Character submission not valid.
|
* Exception: Character submission not valid.
|
||||||
*
|
*
|
||||||
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
||||||
*/
|
*/
|
||||||
class SubmissionNotValidException extends \nre\core\Exception
|
class SubmissionNotValidException extends \nre\core\Exception
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Error code
|
* Error code
|
||||||
*
|
*
|
||||||
* @var int
|
* @var int
|
||||||
*/
|
*/
|
||||||
const CODE = 200;
|
const CODE = 200;
|
||||||
/**
|
/**
|
||||||
* Error message
|
* Error message
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
const MESSAGE = 'Character submission not valid';
|
const MESSAGE = 'Character submission not valid';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Nested exception
|
* Nested exception
|
||||||
*
|
*
|
||||||
* @var Exception
|
* @var Exception
|
||||||
*/
|
*/
|
||||||
private $nestedException;
|
private $nestedException;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Construct a new exception.
|
* Construct a new exception.
|
||||||
*
|
*
|
||||||
* @param string $nestedException Nested exception
|
* @param string $nestedException Nested exception
|
||||||
* @param string $message Error message
|
* @param string $message Error message
|
||||||
* @param int $code Error code
|
* @param int $code Error code
|
||||||
*/
|
*/
|
||||||
function __construct($nestedException, $message=self::MESSAGE, $code=self::CODE)
|
function __construct($nestedException, $message=self::MESSAGE, $code=self::CODE)
|
||||||
{
|
{
|
||||||
parent::__construct(
|
parent::__construct(
|
||||||
$message,
|
$message,
|
||||||
$code,
|
$code,
|
||||||
$nestedException
|
$nestedException
|
||||||
);
|
);
|
||||||
|
|
||||||
// Store value
|
// Store value
|
||||||
$this->nestedException = $nestedException;
|
$this->nestedException = $nestedException;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get Nested exception.
|
* Get Nested exception.
|
||||||
*
|
*
|
||||||
* @return string Nested exception
|
* @return string Nested exception
|
||||||
*/
|
*/
|
||||||
public function getNestedException()
|
public function getNestedException()
|
||||||
{
|
{
|
||||||
return $this->nestedException;
|
return $this->nestedException;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
|
||||||
|
|
@ -1,79 +1,79 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Legend of Z
|
* The Legend of Z
|
||||||
*
|
*
|
||||||
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
||||||
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
|
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
|
||||||
* @license http://www.gnu.org/licenses/gpl.html
|
* @license http://www.gnu.org/licenses/gpl.html
|
||||||
* @link https://bitbucket.org/coderkun/the-legend-of-z
|
* @link https://bitbucket.org/coderkun/the-legend-of-z
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace hhu\z\exceptions;
|
namespace hhu\z\exceptions;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Exception: File has wrong filetype.
|
* Exception: File has wrong filetype.
|
||||||
*
|
*
|
||||||
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
||||||
*/
|
*/
|
||||||
class WrongFiletypeException extends \nre\core\Exception
|
class WrongFiletypeException extends \nre\core\Exception
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Error code
|
* Error code
|
||||||
*
|
*
|
||||||
* @var int
|
* @var int
|
||||||
*/
|
*/
|
||||||
const CODE = 201;
|
const CODE = 201;
|
||||||
/**
|
/**
|
||||||
* Error message
|
* Error message
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
const MESSAGE = 'File has wrong type “%s”';
|
const MESSAGE = 'File has wrong type “%s”';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Type of file
|
* Type of file
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
private $type;
|
private $type;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Construct a new exception.
|
* Construct a new exception.
|
||||||
*
|
*
|
||||||
* @param string $type Type of file
|
* @param string $type Type of file
|
||||||
* @param string $message Error message
|
* @param string $message Error message
|
||||||
* @param int $code Error code
|
* @param int $code Error code
|
||||||
*/
|
*/
|
||||||
function __construct($type, $message=self::MESSAGE, $code=self::CODE)
|
function __construct($type, $message=self::MESSAGE, $code=self::CODE)
|
||||||
{
|
{
|
||||||
parent::__construct(
|
parent::__construct(
|
||||||
$message,
|
$message,
|
||||||
$code,
|
$code,
|
||||||
$type
|
$type
|
||||||
);
|
);
|
||||||
|
|
||||||
// Store values
|
// Store values
|
||||||
$this->type = $type;
|
$this->type = $type;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get type of file.
|
* Get type of file.
|
||||||
*
|
*
|
||||||
* @return Type of file
|
* @return Type of file
|
||||||
*/
|
*/
|
||||||
public function getType()
|
public function getType()
|
||||||
{
|
{
|
||||||
return $this->type;
|
return $this->type;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
|
||||||
|
|
@ -1,38 +1,38 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Legend of Z
|
* The Legend of Z
|
||||||
*
|
*
|
||||||
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
||||||
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
|
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
|
||||||
* @license http://www.gnu.org/licenses/gpl.html
|
* @license http://www.gnu.org/licenses/gpl.html
|
||||||
* @link https://bitbucket.org/coderkun/the-legend-of-z
|
* @link https://bitbucket.org/coderkun/the-legend-of-z
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace hhu\z\lib
|
namespace hhu\z\lib
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class to ensure that Compatibility library below is loaded.
|
* Class to ensure that Compatibility library below is loaded.
|
||||||
*
|
*
|
||||||
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
||||||
*/
|
*/
|
||||||
class PHPMailer
|
class PHPMailer
|
||||||
{
|
{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Call this function to ensure this file is loaded.
|
* Call this function to ensure this file is loaded.
|
||||||
*/
|
*/
|
||||||
public static function load()
|
public static function load()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* PHPMailer - PHP email creation and transport class.
|
* PHPMailer - PHP email creation and transport class.
|
||||||
|
|
|
||||||
|
|
@ -1,39 +1,39 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Legend of Z
|
* The Legend of Z
|
||||||
*
|
*
|
||||||
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
||||||
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
|
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
|
||||||
* @license http://www.gnu.org/licenses/gpl.html
|
* @license http://www.gnu.org/licenses/gpl.html
|
||||||
* @link https://bitbucket.org/coderkun/the-legend-of-z
|
* @link https://bitbucket.org/coderkun/the-legend-of-z
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace hhu\z\lib
|
namespace hhu\z\lib
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class to ensure that Compatibility library below is loaded.
|
* Class to ensure that Compatibility library below is loaded.
|
||||||
*
|
*
|
||||||
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
||||||
*/
|
*/
|
||||||
class PHPMailerAutoload
|
class PHPMailerAutoload
|
||||||
{
|
{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Call this function to ensure this file is loaded.
|
* Call this function to ensure this file is loaded.
|
||||||
*/
|
*/
|
||||||
public static function load()
|
public static function load()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* PHPMailer SPL autoloader.
|
* PHPMailer SPL autoloader.
|
||||||
* PHP Version 5
|
* PHP Version 5
|
||||||
|
|
|
||||||
|
|
@ -1,37 +1,37 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Legend of Z
|
* The Legend of Z
|
||||||
*
|
*
|
||||||
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
||||||
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
|
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
|
||||||
* @license http://www.gnu.org/licenses/gpl.html
|
* @license http://www.gnu.org/licenses/gpl.html
|
||||||
* @link https://bitbucket.org/coderkun/the-legend-of-z
|
* @link https://bitbucket.org/coderkun/the-legend-of-z
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace hhu\z\lib
|
namespace hhu\z\lib
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class to ensure that Compatibility library below is loaded.
|
* Class to ensure that Compatibility library below is loaded.
|
||||||
*
|
*
|
||||||
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
||||||
*/
|
*/
|
||||||
class Password
|
class Password
|
||||||
{
|
{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Call this function to ensure this file is loaded.
|
* Call this function to ensure this file is loaded.
|
||||||
*/
|
*/
|
||||||
public static function load()
|
public static function load()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,38 +1,38 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Legend of Z
|
* The Legend of Z
|
||||||
*
|
*
|
||||||
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
||||||
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
|
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
|
||||||
* @license http://www.gnu.org/licenses/gpl.html
|
* @license http://www.gnu.org/licenses/gpl.html
|
||||||
* @link https://bitbucket.org/coderkun/the-legend-of-z
|
* @link https://bitbucket.org/coderkun/the-legend-of-z
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace hhu\z\lib
|
namespace hhu\z\lib
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class to ensure that Compatibility library below is loaded.
|
* Class to ensure that Compatibility library below is loaded.
|
||||||
*
|
*
|
||||||
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
||||||
*/
|
*/
|
||||||
class SMTP
|
class SMTP
|
||||||
{
|
{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Call this function to ensure this file is loaded.
|
* Call this function to ensure this file is loaded.
|
||||||
*/
|
*/
|
||||||
public static function load()
|
public static function load()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* PHPMailer RFC821 SMTP email transport class.
|
* PHPMailer RFC821 SMTP email transport class.
|
||||||
|
|
|
||||||
|
|
@ -1,31 +1,31 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Legend of Z
|
* The Legend of Z
|
||||||
*
|
*
|
||||||
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
||||||
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
|
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
|
||||||
* @license http://www.gnu.org/licenses/gpl.html
|
* @license http://www.gnu.org/licenses/gpl.html
|
||||||
* @link https://bitbucket.org/coderkun/the-legend-of-z
|
* @link https://bitbucket.org/coderkun/the-legend-of-z
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace hhu\z\models;
|
namespace hhu\z\models;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Abstract class for implementing a QuesttypeModel.
|
* Abstract class for implementing a QuesttypeModel.
|
||||||
*
|
*
|
||||||
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
||||||
*/
|
*/
|
||||||
abstract class QuesttypeModel extends \hhu\z\Model
|
abstract class QuesttypeModel extends \hhu\z\Model
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Copy a Quest.
|
* Copy a Quest.
|
||||||
*
|
*
|
||||||
* @param int $userId ID of creating user
|
* @param int $userId ID of creating user
|
||||||
* @param int $sourceQuestId ID of Quest to copy from
|
* @param int $sourceQuestId ID of Quest to copy from
|
||||||
* @param int $targetQuestId ID of Quest to copy to
|
* @param int $targetQuestId ID of Quest to copy to
|
||||||
|
|
@ -34,132 +34,132 @@
|
||||||
public abstract function copyQuest($userId, $sourceQuestId, $targetQuestId, $seminaryMediaIds);
|
public abstract function copyQuest($userId, $sourceQuestId, $targetQuestId, $seminaryMediaIds);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Load a Model.
|
* Load a Model.
|
||||||
*
|
*
|
||||||
* @static
|
* @static
|
||||||
* @throws \hhu\z\exceptions\QuesttypeModelNotFoundException
|
* @throws \hhu\z\exceptions\QuesttypeModelNotFoundException
|
||||||
* @throws \hhu\z\exceptions\QuesttypeModelNotValidException
|
* @throws \hhu\z\exceptions\QuesttypeModelNotValidException
|
||||||
* @param string $modelName Name of the QuesttypeModel to load
|
* @param string $modelName Name of the QuesttypeModel to load
|
||||||
*/
|
*/
|
||||||
public static function load($modelName)
|
public static function load($modelName)
|
||||||
{
|
{
|
||||||
// Determine full classname
|
// Determine full classname
|
||||||
$className = self::getClassName($modelName);
|
$className = self::getClassName($modelName);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// Load class
|
// Load class
|
||||||
static::loadClass($modelName, $className);
|
static::loadClass($modelName, $className);
|
||||||
|
|
||||||
// Validate class
|
// Validate class
|
||||||
static::checkClass($className, get_class());
|
static::checkClass($className, get_class());
|
||||||
}
|
}
|
||||||
catch(\nre\exceptions\ClassNotValidException $e) {
|
catch(\nre\exceptions\ClassNotValidException $e) {
|
||||||
throw new \hhu\z\exceptions\QuesttypeModelNotValidException($e->getClassName());
|
throw new \hhu\z\exceptions\QuesttypeModelNotValidException($e->getClassName());
|
||||||
}
|
}
|
||||||
catch(\nre\exceptions\ClassNotFoundException $e) {
|
catch(\nre\exceptions\ClassNotFoundException $e) {
|
||||||
throw new \hhu\z\exceptions\QuesttypeModelNotFoundException($e->getClassName());
|
throw new \hhu\z\exceptions\QuesttypeModelNotFoundException($e->getClassName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Instantiate a QuesttypeModel (Factory Pattern).
|
* Instantiate a QuesttypeModel (Factory Pattern).
|
||||||
*
|
*
|
||||||
* @static
|
* @static
|
||||||
* @param string $questtypeName Name of the QuesttypeModel to instantiate
|
* @param string $questtypeName Name of the QuesttypeModel to instantiate
|
||||||
*/
|
*/
|
||||||
public static function factory($questtypeName)
|
public static function factory($questtypeName)
|
||||||
{
|
{
|
||||||
// Determine full classname
|
// Determine full classname
|
||||||
$className = self::getClassName($questtypeName);
|
$className = self::getClassName($questtypeName);
|
||||||
|
|
||||||
// Construct and return Model
|
// Construct and return Model
|
||||||
return new $className();
|
return new $className();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Determine the Model-classname for the given Questtype-name.
|
* Determine the Model-classname for the given Questtype-name.
|
||||||
*
|
*
|
||||||
* @static
|
* @static
|
||||||
* @param string $questtypeName Questtype-name to get Model-classname of
|
* @param string $questtypeName Questtype-name to get Model-classname of
|
||||||
* @return string Classname for the Questtype-name
|
* @return string Classname for the Questtype-name
|
||||||
*/
|
*/
|
||||||
private static function getClassName($questtypeName)
|
private static function getClassName($questtypeName)
|
||||||
{
|
{
|
||||||
$className = \nre\core\ClassLoader::concatClassNames($questtypeName, \nre\core\ClassLoader::stripClassType(\nre\core\ClassLoader::stripNamespace(get_class())), 'model');
|
$className = \nre\core\ClassLoader::concatClassNames($questtypeName, \nre\core\ClassLoader::stripClassType(\nre\core\ClassLoader::stripNamespace(get_class())), 'model');
|
||||||
|
|
||||||
|
|
||||||
return \nre\configs\AppConfig::$app['namespace']."questtypes\\$className";
|
return \nre\configs\AppConfig::$app['namespace']."questtypes\\$className";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Load the class of a QuesttypeModel.
|
* Load the class of a QuesttypeModel.
|
||||||
*
|
*
|
||||||
* @static
|
* @static
|
||||||
* @throws \nre\exceptions\ClassNotFoundException
|
* @throws \nre\exceptions\ClassNotFoundException
|
||||||
* @param string $questtypeName Name of the QuesttypeModel to load
|
* @param string $questtypeName Name of the QuesttypeModel to load
|
||||||
* @param string $fullClassName Name of the class to load
|
* @param string $fullClassName Name of the class to load
|
||||||
*/
|
*/
|
||||||
private static function loadClass($questtypeName, $fullClassName)
|
private static function loadClass($questtypeName, $fullClassName)
|
||||||
{
|
{
|
||||||
// Determine folder to look in
|
// Determine folder to look in
|
||||||
$className = explode('\\', $fullClassName);
|
$className = explode('\\', $fullClassName);
|
||||||
$className = array_pop($className);
|
$className = array_pop($className);
|
||||||
|
|
||||||
// Determine filename
|
// Determine filename
|
||||||
$fileName = ROOT.DS.\nre\configs\AppConfig::$dirs['questtypes'].DS.strtolower($questtypeName).DS.$className.\nre\configs\CoreConfig::getFileExt('includes');
|
$fileName = ROOT.DS.\nre\configs\AppConfig::$dirs['questtypes'].DS.strtolower($questtypeName).DS.$className.\nre\configs\CoreConfig::getFileExt('includes');
|
||||||
|
|
||||||
// Check file
|
// Check file
|
||||||
if(!file_exists($fileName))
|
if(!file_exists($fileName))
|
||||||
{
|
{
|
||||||
throw new \nre\exceptions\ClassNotFoundException(
|
throw new \nre\exceptions\ClassNotFoundException(
|
||||||
$fullClassName
|
$fullClassName
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Include file
|
// Include file
|
||||||
include_once($fileName);
|
include_once($fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check inheritance of the QuesttypeModel-class.
|
* Check inheritance of the QuesttypeModel-class.
|
||||||
*
|
*
|
||||||
* @static
|
* @static
|
||||||
* @throws \nre\exceptions\ClassNotValidException
|
* @throws \nre\exceptions\ClassNotValidException
|
||||||
* @param string $className Name of the class to check
|
* @param string $className Name of the class to check
|
||||||
* @param string $parentClassName Name of the parent class
|
* @param string $parentClassName Name of the parent class
|
||||||
*/
|
*/
|
||||||
public static function checkClass($className, $parentClassName)
|
public static function checkClass($className, $parentClassName)
|
||||||
{
|
{
|
||||||
// Check if class is subclass of parent class
|
// Check if class is subclass of parent class
|
||||||
if(!is_subclass_of($className, $parentClassName)) {
|
if(!is_subclass_of($className, $parentClassName)) {
|
||||||
throw new \nre\exceptions\ClassNotValidException(
|
throw new \nre\exceptions\ClassNotValidException(
|
||||||
$className
|
$className
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Construct a new QuesttypeModel.
|
* Construct a new QuesttypeModel.
|
||||||
*
|
*
|
||||||
* @throws \nre\exceptions\DatamodelException
|
* @throws \nre\exceptions\DatamodelException
|
||||||
* @throws \nre\exceptions\DriverNotFoundException
|
* @throws \nre\exceptions\DriverNotFoundException
|
||||||
* @throws \nre\exceptions\DriverNotValidException
|
* @throws \nre\exceptions\DriverNotValidException
|
||||||
* @throws \hhu\z\exceptions\QuesttypeModelNotValidException
|
* @throws \hhu\z\exceptions\QuesttypeModelNotValidException
|
||||||
* @throws \hhu\z\exceptions\QuesttypeModelNotFoundException
|
* @throws \hhu\z\exceptions\QuesttypeModelNotFoundException
|
||||||
*/
|
*/
|
||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
parent::__construct();
|
parent::__construct();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
|
||||||
|
|
@ -1,92 +1,92 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Legend of Z
|
* The Legend of Z
|
||||||
*
|
*
|
||||||
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
||||||
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
|
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
|
||||||
* @license http://www.gnu.org/licenses/gpl.html
|
* @license http://www.gnu.org/licenses/gpl.html
|
||||||
* @link https://bitbucket.org/coderkun/the-legend-of-z
|
* @link https://bitbucket.org/coderkun/the-legend-of-z
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace hhu\z\requests;
|
namespace hhu\z\requests;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Representation of a mail-request.
|
* Representation of a mail-request.
|
||||||
*
|
*
|
||||||
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
||||||
*/
|
*/
|
||||||
class MailRequest extends \nre\core\Request
|
class MailRequest extends \nre\core\Request
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Linker
|
* Linker
|
||||||
*
|
*
|
||||||
* @var \nre\core\Linker
|
* @var \nre\core\Linker
|
||||||
*/
|
*/
|
||||||
private $linker = null;
|
private $linker = null;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add a parameter.
|
* Add a parameter.
|
||||||
*
|
*
|
||||||
* @param mixed $value Value of parameter
|
* @param mixed $value Value of parameter
|
||||||
*/
|
*/
|
||||||
public function addParam($value)
|
public function addParam($value)
|
||||||
{
|
{
|
||||||
$this->params[] = $value;
|
$this->params[] = $value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add multiple parameters.
|
* Add multiple parameters.
|
||||||
*
|
*
|
||||||
* @param mixed $value1 Value of first parameter
|
* @param mixed $value1 Value of first parameter
|
||||||
* @param mixed … Values of further parameters
|
* @param mixed … Values of further parameters
|
||||||
*/
|
*/
|
||||||
public function addParams($value1)
|
public function addParams($value1)
|
||||||
{
|
{
|
||||||
$this->params = array_merge(
|
$this->params = array_merge(
|
||||||
$this->params,
|
$this->params,
|
||||||
func_get_args()
|
func_get_args()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Delete all stored parameters (from offset on).
|
* Delete all stored parameters (from offset on).
|
||||||
*
|
*
|
||||||
* @param int $offset Offset-index
|
* @param int $offset Offset-index
|
||||||
*/
|
*/
|
||||||
public function clearParams($offset=0)
|
public function clearParams($offset=0)
|
||||||
{
|
{
|
||||||
$this->params = array_slice($this->params, 0, $offset);
|
$this->params = array_slice($this->params, 0, $offset);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set linker instance for creating links.
|
* Set linker instance for creating links.
|
||||||
*
|
*
|
||||||
* @param Linker $linker Linker instance for creating links
|
* @param Linker $linker Linker instance for creating links
|
||||||
*/
|
*/
|
||||||
public function setLinker(\nre\core\Linker $linker)
|
public function setLinker(\nre\core\Linker $linker)
|
||||||
{
|
{
|
||||||
$this->linker = $linker;
|
$this->linker = $linker;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get linker instance for creating links.
|
* Get linker instance for creating links.
|
||||||
*
|
*
|
||||||
* @return \nre\core\Linker Linker instance for creating links
|
* @return \nre\core\Linker Linker instance for creating links
|
||||||
*/
|
*/
|
||||||
public function getLinker()
|
public function getLinker()
|
||||||
{
|
{
|
||||||
return $this->linker;
|
return $this->linker;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
|
||||||
|
|
@ -1,55 +1,55 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Legend of Z
|
* The Legend of Z
|
||||||
*
|
*
|
||||||
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
||||||
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
|
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
|
||||||
* @license http://www.gnu.org/licenses/gpl.html
|
* @license http://www.gnu.org/licenses/gpl.html
|
||||||
* @link https://bitbucket.org/coderkun/the-legend-of-z
|
* @link https://bitbucket.org/coderkun/the-legend-of-z
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace hhu\z\responses;
|
namespace hhu\z\responses;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Representation of a mail-response.
|
* Representation of a mail-response.
|
||||||
*
|
*
|
||||||
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
||||||
*/
|
*/
|
||||||
class MailResponse extends \nre\core\Response
|
class MailResponse extends \nre\core\Response
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Mail subject
|
* Mail subject
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
private $subject = null;
|
private $subject = null;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set subject.
|
* Set subject.
|
||||||
*
|
*
|
||||||
* @param string $subject Subject to set
|
* @param string $subject Subject to set
|
||||||
*/
|
*/
|
||||||
public function setSubject($subject)
|
public function setSubject($subject)
|
||||||
{
|
{
|
||||||
$this->subject = $subject;
|
$this->subject = $subject;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get subject.
|
* Get subject.
|
||||||
*
|
*
|
||||||
* @return string Subject
|
* @return string Subject
|
||||||
*/
|
*/
|
||||||
public function getSubject()
|
public function getSubject()
|
||||||
{
|
{
|
||||||
return $this->subject;
|
return $this->subject;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
|
||||||
|
|
@ -1,76 +1,76 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Legend of Z
|
* The Legend of Z
|
||||||
*
|
*
|
||||||
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
||||||
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
|
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
|
||||||
* @license http://www.gnu.org/licenses/gpl.html
|
* @license http://www.gnu.org/licenses/gpl.html
|
||||||
* @link https://bitbucket.org/coderkun/the-legend-of-z
|
* @link https://bitbucket.org/coderkun/the-legend-of-z
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace hhu\z\views;
|
namespace hhu\z\views;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Abstract class for implementing a QuesttypeView.
|
* Abstract class for implementing a QuesttypeView.
|
||||||
*
|
*
|
||||||
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
||||||
*/
|
*/
|
||||||
class QuesttypeView extends \nre\core\View
|
class QuesttypeView extends \nre\core\View
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Load and instantiate the QuesttypeView of a QuesttypeAgent.
|
* Load and instantiate the QuesttypeView of a QuesttypeAgent.
|
||||||
*
|
*
|
||||||
* @throws \nre\exceptions\ViewNotFoundException
|
* @throws \nre\exceptions\ViewNotFoundException
|
||||||
* @param string $layoutName Name of Layout in use
|
* @param string $layoutName Name of Layout in use
|
||||||
* @param string $agentName Name of the Agent
|
* @param string $agentName Name of the Agent
|
||||||
* @param string $action Current Action
|
* @param string $action Current Action
|
||||||
* @param bool $isToplevel Agent is a ToplevelAgent
|
* @param bool $isToplevel Agent is a ToplevelAgent
|
||||||
*/
|
*/
|
||||||
public static function loadAndFactory($layoutName, $agentName=null, $action=null, $isToplevel=false)
|
public static function loadAndFactory($layoutName, $agentName=null, $action=null, $isToplevel=false)
|
||||||
{
|
{
|
||||||
return new QuesttypeView($layoutName, $agentName, $action, $isToplevel);
|
return new QuesttypeView($layoutName, $agentName, $action, $isToplevel);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Construct a new QuesttypeView.
|
* Construct a new QuesttypeView.
|
||||||
*
|
*
|
||||||
* @throws \nre\exceptions\ViewNotFoundException
|
* @throws \nre\exceptions\ViewNotFoundException
|
||||||
* @param string $layoutName Name of Layout in use
|
* @param string $layoutName Name of Layout in use
|
||||||
* @param string $agentName Name of the Agent
|
* @param string $agentName Name of the Agent
|
||||||
* @param string $action Current Action
|
* @param string $action Current Action
|
||||||
* @param bool $isToplevel Agent is a ToplevelAgent
|
* @param bool $isToplevel Agent is a ToplevelAgent
|
||||||
*/
|
*/
|
||||||
protected function __construct($layoutName, $agentName=null, $action=null, $isToplevel=false)
|
protected function __construct($layoutName, $agentName=null, $action=null, $isToplevel=false)
|
||||||
{
|
{
|
||||||
// Create template filename
|
// Create template filename
|
||||||
// LayoutName
|
// LayoutName
|
||||||
$fileName = ROOT.DS.\nre\configs\AppConfig::$dirs['questtypes'].DS.strtolower($agentName).DS.strtolower($layoutName).DS;
|
$fileName = ROOT.DS.\nre\configs\AppConfig::$dirs['questtypes'].DS.strtolower($agentName).DS.strtolower($layoutName).DS;
|
||||||
|
|
||||||
// Action
|
// Action
|
||||||
$fileName .= strtolower($action);
|
$fileName .= strtolower($action);
|
||||||
|
|
||||||
// File extension
|
// File extension
|
||||||
$fileName .= \nre\configs\CoreConfig::getFileExt('views');
|
$fileName .= \nre\configs\CoreConfig::getFileExt('views');
|
||||||
|
|
||||||
|
|
||||||
// Check template file
|
// Check template file
|
||||||
if(!file_exists($fileName)) {
|
if(!file_exists($fileName)) {
|
||||||
throw new \nre\exceptions\ViewNotFoundException($fileName);
|
throw new \nre\exceptions\ViewNotFoundException($fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Save filename
|
// Save filename
|
||||||
$this->templateFilename = $fileName;
|
$this->templateFilename = $fileName;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load diff
|
|
@ -1,52 +1,52 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Legend of Z
|
* The Legend of Z
|
||||||
*
|
*
|
||||||
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
||||||
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
|
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
|
||||||
* @license http://www.gnu.org/licenses/gpl.html
|
* @license http://www.gnu.org/licenses/gpl.html
|
||||||
* @link https://bitbucket.org/coderkun/the-legend-of-z
|
* @link https://bitbucket.org/coderkun/the-legend-of-z
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace hhu\z\controllers;
|
namespace hhu\z\controllers;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Controller of the AjaxAgent to return a JSON-string used by AJAX.
|
* Controller of the AjaxAgent to return a JSON-string used by AJAX.
|
||||||
*
|
*
|
||||||
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
||||||
*/
|
*/
|
||||||
class AjaxController extends \hhu\z\Controller
|
class AjaxController extends \hhu\z\Controller
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Prefilter.
|
* Prefilter.
|
||||||
*
|
*
|
||||||
* @param \nre\core\Request $request Current request
|
* @param \nre\core\Request $request Current request
|
||||||
* @param \nre\core\Response $response Current response
|
* @param \nre\core\Response $response Current response
|
||||||
*/
|
*/
|
||||||
public function preFilter(\nre\core\Request $request, \nre\core\Response $response)
|
public function preFilter(\nre\core\Request $request, \nre\core\Response $response)
|
||||||
{
|
{
|
||||||
parent::preFilter($request, $response);
|
parent::preFilter($request, $response);
|
||||||
|
|
||||||
// Set content-type
|
// Set content-type
|
||||||
$this->response->addHeader("Content-type: application/json; charset=utf-8");
|
$this->response->addHeader("Content-type: application/json; charset=utf-8");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Action: index.
|
* Action: index.
|
||||||
*
|
*
|
||||||
* Create the JSON-string.
|
* Create the JSON-string.
|
||||||
*/
|
*/
|
||||||
public function index()
|
public function index()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
|
||||||
|
|
@ -1,37 +1,37 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Legend of Z
|
* The Legend of Z
|
||||||
*
|
*
|
||||||
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
||||||
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
|
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
|
||||||
* @license http://www.gnu.org/licenses/gpl.html
|
* @license http://www.gnu.org/licenses/gpl.html
|
||||||
* @link https://bitbucket.org/coderkun/the-legend-of-z
|
* @link https://bitbucket.org/coderkun/the-legend-of-z
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace hhu\z\controllers;
|
namespace hhu\z\controllers;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Controller of the BinaryAgent to show binary data.
|
* Controller of the BinaryAgent to show binary data.
|
||||||
*
|
*
|
||||||
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
||||||
*/
|
*/
|
||||||
class BinaryController extends \hhu\z\controllers\IntermediateController
|
class BinaryController extends \hhu\z\controllers\IntermediateController
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Action: index.
|
* Action: index.
|
||||||
*
|
*
|
||||||
* Create binary data.
|
* Create binary data.
|
||||||
*/
|
*/
|
||||||
public function index()
|
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
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Legend of Z
|
* The Legend of Z
|
||||||
*
|
*
|
||||||
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
||||||
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
|
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
|
||||||
* @license http://www.gnu.org/licenses/gpl.html
|
* @license http://www.gnu.org/licenses/gpl.html
|
||||||
* @link https://bitbucket.org/coderkun/the-legend-of-z
|
* @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);
|
|
||||||
|
|
||||||
// Check permissions
|
namespace hhu\z\controllers;
|
||||||
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
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// Set titile
|
/**
|
||||||
$this->addTitleLocalized('Charactertypes');
|
* Controller of the CharactertypesAgent to handle Charactertyes of a
|
||||||
$this->addTitle($seminary['title']);
|
* Seminary.
|
||||||
|
*
|
||||||
// Pass data to view
|
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
||||||
$this->set('seminary', $seminary);
|
*/
|
||||||
$this->set('xplevels', $xplevels);
|
class CharactertypesController extends \hhu\z\controllers\SeminaryController
|
||||||
$this->set('charactertypes', $charactertypes);
|
{
|
||||||
}
|
/**
|
||||||
|
* 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');
|
* Action: index.
|
||||||
$this->addTitle($seminary['title']);
|
*
|
||||||
|
* List Character types.
|
||||||
// Pass data to view
|
*
|
||||||
$this->set('seminary', $seminary);
|
* @throws \nre\exceptions\IdNotFoundException
|
||||||
$this->set('name', $name);
|
* @param string $seminaryUrl URL-Title of a Seminary
|
||||||
$this->set('validation', $validation);
|
*/
|
||||||
$this->set('validationSettings', $validationSettings);
|
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
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
// Set titile
|
||||||
* Action: edit.
|
$this->addTitleLocalized('Charactertypes');
|
||||||
*
|
$this->addTitle($seminary['title']);
|
||||||
* 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
|
// Pass data to view
|
||||||
if(
|
$this->set('seminary', $seminary);
|
||||||
$seminary['created_user_id'] != self::$user['id'] &&
|
$this->set('xplevels', $xplevels);
|
||||||
(is_null(self::$character) && count(array_intersect(array('admin', 'moderator'), \hhu\z\controllers\IntermediateController::$user['roles'])) == 0)
|
$this->set('charactertypes', $charactertypes);
|
||||||
) {
|
}
|
||||||
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');
|
* Action: create.
|
||||||
$this->addTitle($seminary['title']);
|
*
|
||||||
|
* Create new Character type for a Seminary.
|
||||||
// Pass data to view
|
*
|
||||||
$this->set('seminary', $seminary);
|
* @throws \nre\exceptions\IdNotFoundException
|
||||||
$this->set('charactertype', $charactertype);
|
* @param string $seminaryUrl URL-Title of a Seminary
|
||||||
$this->set('xplevels', $xplevels);
|
*/
|
||||||
$this->set('name', $name);
|
public function create($seminaryUrl)
|
||||||
$this->set('mimetypes', $mimetypes);
|
{
|
||||||
$this->set('validation', $validation);
|
// Get seminary
|
||||||
$this->set('avatarsValidation', $avatarsValidation);
|
$seminary = $this->Seminaries->getSeminaryByUrl($seminaryUrl);
|
||||||
$this->set('avatarVariants', $avatarVariants);
|
|
||||||
$this->set('validationSettings', $validationSettings);
|
// 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
|
||||||
* Action: delete.
|
$this->addTitleLocalized('Create new Charactertype');
|
||||||
*
|
$this->addTitle($seminary['title']);
|
||||||
* 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
|
// Pass data to view
|
||||||
if(
|
$this->set('seminary', $seminary);
|
||||||
$seminary['created_user_id'] != self::$user['id'] &&
|
$this->set('name', $name);
|
||||||
(is_null(self::$character) && count(array_intersect(array('admin'), \hhu\z\controllers\IntermediateController::$user['roles'])) == 0)
|
$this->set('validation', $validation);
|
||||||
) {
|
$this->set('validationSettings', $validationSettings);
|
||||||
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');
|
* Action: edit.
|
||||||
$this->addTitle($seminary['title']);
|
*
|
||||||
|
* Edit Character type for a Seminary.
|
||||||
// Pass data to view
|
*
|
||||||
$this->set('seminary', $seminary);
|
* @throws \nre\exceptions\IdNotFoundException
|
||||||
$this->set('charactertype', $charactertype);
|
* @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
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Legend of Z
|
* The Legend of Z
|
||||||
*
|
*
|
||||||
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
||||||
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
|
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
|
||||||
* @license http://www.gnu.org/licenses/gpl.html
|
* @license http://www.gnu.org/licenses/gpl.html
|
||||||
* @link https://bitbucket.org/coderkun/the-legend-of-z
|
* @link https://bitbucket.org/coderkun/the-legend-of-z
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace hhu\z\controllers;
|
namespace hhu\z\controllers;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Controller of the Agent to show an error page.
|
* Controller of the Agent to show an error page.
|
||||||
*
|
*
|
||||||
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
||||||
*/
|
*/
|
||||||
class ErrorController extends \hhu\z\Controller
|
class ErrorController extends \hhu\z\Controller
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Action: index.
|
* Action: index.
|
||||||
*
|
*
|
||||||
* Set HTTP-header and print an error message.
|
* Set HTTP-header and print an error message.
|
||||||
*
|
*
|
||||||
* @param int $httpStatusCode HTTP-statuscode of the error that occurred
|
* @param int $httpStatusCode HTTP-statuscode of the error that occurred
|
||||||
*/
|
*/
|
||||||
public function index($httpStatusCode)
|
public function index($httpStatusCode)
|
||||||
{
|
{
|
||||||
// Set HTTP-header
|
// Set HTTP-header
|
||||||
if(!array_key_exists($httpStatusCode, \nre\core\WebUtils::$httpStrings)) {
|
if(!array_key_exists($httpStatusCode, \nre\core\WebUtils::$httpStrings)) {
|
||||||
$httpStatusCode = 200;
|
$httpStatusCode = 200;
|
||||||
}
|
}
|
||||||
$this->response->addHeader(\nre\core\WebUtils::getHttpHeader($httpStatusCode));
|
$this->response->addHeader(\nre\core\WebUtils::getHttpHeader($httpStatusCode));
|
||||||
|
|
||||||
// Display statuscode and message
|
// Display statuscode and message
|
||||||
$this->set('code', $httpStatusCode);
|
$this->set('code', $httpStatusCode);
|
||||||
$this->set('string', \nre\core\WebUtils::$httpStrings[$httpStatusCode]);
|
$this->set('string', \nre\core\WebUtils::$httpStrings[$httpStatusCode]);
|
||||||
$this->set('userId', $this->Auth->getUserId());
|
$this->set('userId', $this->Auth->getUserId());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
|
||||||
|
|
@ -1,37 +1,37 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Legend of Z
|
* The Legend of Z
|
||||||
*
|
*
|
||||||
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
||||||
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
|
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
|
||||||
* @license http://www.gnu.org/licenses/gpl.html
|
* @license http://www.gnu.org/licenses/gpl.html
|
||||||
* @link https://bitbucket.org/coderkun/the-legend-of-z
|
* @link https://bitbucket.org/coderkun/the-legend-of-z
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace hhu\z\controllers;
|
namespace hhu\z\controllers;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Controller of the Agent to display a toplevel error page.
|
* Controller of the Agent to display a toplevel error page.
|
||||||
*
|
*
|
||||||
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
||||||
*/
|
*/
|
||||||
class FaultController extends \nre\core\Controller
|
class FaultController extends \nre\core\Controller
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Action: index.
|
* Action: index.
|
||||||
*
|
*
|
||||||
* Show the error message.
|
* Show the error message.
|
||||||
*/
|
*/
|
||||||
public function index()
|
public function index()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
|
||||||
|
|
@ -1,114 +1,114 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Legend of Z
|
* The Legend of Z
|
||||||
*
|
*
|
||||||
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
||||||
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
|
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
|
||||||
* @license http://www.gnu.org/licenses/gpl.html
|
* @license http://www.gnu.org/licenses/gpl.html
|
||||||
* @link https://bitbucket.org/coderkun/the-legend-of-z
|
* @link https://bitbucket.org/coderkun/the-legend-of-z
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace hhu\z\controllers;
|
namespace hhu\z\controllers;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Controller of the HtmlAgent to display a HTML-page.
|
* Controller of the HtmlAgent to display a HTML-page.
|
||||||
*
|
*
|
||||||
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
||||||
*/
|
*/
|
||||||
class HtmlController extends \hhu\z\Controller
|
class HtmlController extends \hhu\z\Controller
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Required components
|
* Required components
|
||||||
*
|
*
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
public $components = array('notification');
|
public $components = array('notification');
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Prefilter.
|
* Prefilter.
|
||||||
*
|
*
|
||||||
* @param \nre\core\Request $request Current request
|
* @param \nre\core\Request $request Current request
|
||||||
* @param \nre\core\Response $response Current response
|
* @param \nre\core\Response $response Current response
|
||||||
*/
|
*/
|
||||||
public function preFilter(\nre\core\Request $request, \nre\core\Response $response)
|
public function preFilter(\nre\core\Request $request, \nre\core\Response $response)
|
||||||
{
|
{
|
||||||
parent::preFilter($request, $response);
|
parent::preFilter($request, $response);
|
||||||
|
|
||||||
// Set content-type
|
// Set content-type
|
||||||
$this->response->addHeader("Content-type: text/html; charset=utf-8");
|
$this->response->addHeader("Content-type: text/html; charset=utf-8");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Postfilter that is executed after running the Controller.
|
* Postfilter that is executed after running the Controller.
|
||||||
*
|
*
|
||||||
* @param \nre\core\Request $request Current request
|
* @param \nre\core\Request $request Current request
|
||||||
* @param \nre\core\Response $response Current response
|
* @param \nre\core\Response $response Current response
|
||||||
*/
|
*/
|
||||||
public function postFilter(\nre\core\Request $request, \nre\core\Response $response)
|
public function postFilter(\nre\core\Request $request, \nre\core\Response $response)
|
||||||
{
|
{
|
||||||
// Get title
|
// Get title
|
||||||
$this->set('title', $this->getTitle());
|
$this->set('title', $this->getTitle());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Action: index.
|
* Action: index.
|
||||||
*
|
*
|
||||||
* Create the HTML-structure.
|
* Create the HTML-structure.
|
||||||
*/
|
*/
|
||||||
public function index()
|
public function index()
|
||||||
{
|
{
|
||||||
// Set the name of the current IntermediateAgent as page title
|
// Set the name of the current IntermediateAgent as page title
|
||||||
$this->set('title', $this->request->getParam(1, 'intermediate'));
|
$this->set('title', $this->request->getParam(1, 'intermediate'));
|
||||||
|
|
||||||
// Set userdata
|
// Set userdata
|
||||||
$this->set('loggedUser', IntermediateController::$user);
|
$this->set('loggedUser', IntermediateController::$user);
|
||||||
$this->set('loggedSeminary', SeminaryController::$seminary);
|
$this->set('loggedSeminary', SeminaryController::$seminary);
|
||||||
$this->set('loggedCharacter', SeminaryController::$character);
|
$this->set('loggedCharacter', SeminaryController::$character);
|
||||||
|
|
||||||
// Set notifications
|
// Set notifications
|
||||||
$this->set('notifications', $this->Notification->getNotifications());
|
$this->set('notifications', $this->Notification->getNotifications());
|
||||||
|
|
||||||
// Set some application data
|
// Set some application data
|
||||||
$this->set('mailcontact', \nre\configs\AppConfig::$app['mailcontact']);
|
$this->set('mailcontact', \nre\configs\AppConfig::$app['mailcontact']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get title information from IntermediateController if possible
|
* Get title information from IntermediateController if possible
|
||||||
* and create a title.
|
* and create a title.
|
||||||
*
|
*
|
||||||
* @return string Title for the current page
|
* @return string Title for the current page
|
||||||
*/
|
*/
|
||||||
private function getTitle()
|
private function getTitle()
|
||||||
{
|
{
|
||||||
$title = array();
|
$title = array();
|
||||||
|
|
||||||
// Get title of IntermediateController
|
// Get title of IntermediateController
|
||||||
$intermediateController = $this->agent->getIntermediateAgent()->controller;
|
$intermediateController = $this->agent->getIntermediateAgent()->controller;
|
||||||
if($intermediateController instanceof \hhu\z\controllers\IntermediateController) {
|
if($intermediateController instanceof \hhu\z\controllers\IntermediateController) {
|
||||||
$title = $intermediateController->getTitle();
|
$title = $intermediateController->getTitle();
|
||||||
}
|
}
|
||||||
if(!is_array($title)) {
|
if(!is_array($title)) {
|
||||||
$title = array($title);
|
$title = array($title);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add application name
|
// Add application name
|
||||||
$title[] = \nre\configs\AppConfig::$app['name'];
|
$title[] = \nre\configs\AppConfig::$app['name'];
|
||||||
|
|
||||||
|
|
||||||
// Return title with delimiter
|
// Return title with delimiter
|
||||||
return implode(\nre\configs\AppConfig::$misc['title_delimiter'], $title);
|
return implode(\nre\configs\AppConfig::$misc['title_delimiter'], $title);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
|
||||||
|
|
@ -1,54 +1,54 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Legend of Z
|
* The Legend of Z
|
||||||
*
|
*
|
||||||
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
||||||
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
|
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
|
||||||
* @license http://www.gnu.org/licenses/gpl.html
|
* @license http://www.gnu.org/licenses/gpl.html
|
||||||
* @link https://bitbucket.org/coderkun/the-legend-of-z
|
* @link https://bitbucket.org/coderkun/the-legend-of-z
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace hhu\z\controllers;
|
namespace hhu\z\controllers;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Controller of the HtmlmailAgent for generating a HTML-mail message.
|
* Controller of the HtmlmailAgent for generating a HTML-mail message.
|
||||||
*
|
*
|
||||||
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
||||||
*/
|
*/
|
||||||
class HtmlmailController extends \nre\core\Controller
|
class HtmlmailController extends \nre\core\Controller
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Prefilter.
|
* Prefilter.
|
||||||
*
|
*
|
||||||
* @param \nre\core\Request $request Current request
|
* @param \nre\core\Request $request Current request
|
||||||
* @param \nre\core\Response $response Current response
|
* @param \nre\core\Response $response Current response
|
||||||
*/
|
*/
|
||||||
public function preFilter(\nre\core\Request $request, \nre\core\Response $response)
|
public function preFilter(\nre\core\Request $request, \nre\core\Response $response)
|
||||||
{
|
{
|
||||||
parent::preFilter($request, $response);
|
parent::preFilter($request, $response);
|
||||||
|
|
||||||
|
|
||||||
// Set linker
|
// Set linker
|
||||||
$this->set('linker', ($request instanceof \hhu\z\requests\MailRequest && !is_null($request->getLinker())) ? $request->getLinker() : null);
|
$this->set('linker', ($request instanceof \hhu\z\requests\MailRequest && !is_null($request->getLinker())) ? $request->getLinker() : null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Action: index.
|
* Action: index.
|
||||||
*
|
*
|
||||||
* Create HTML-structure of mail message.
|
* Create HTML-structure of mail message.
|
||||||
*/
|
*/
|
||||||
public function index()
|
public function index()
|
||||||
{
|
{
|
||||||
$this->set('appname', \nre\configs\AppConfig::$app['name']);
|
$this->set('appname', \nre\configs\AppConfig::$app['name']);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
|
||||||
|
|
@ -1,37 +1,37 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Legend of Z
|
* The Legend of Z
|
||||||
*
|
*
|
||||||
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
||||||
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
|
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
|
||||||
* @license http://www.gnu.org/licenses/gpl.html
|
* @license http://www.gnu.org/licenses/gpl.html
|
||||||
* @link https://bitbucket.org/coderkun/the-legend-of-z
|
* @link https://bitbucket.org/coderkun/the-legend-of-z
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace hhu\z\controllers;
|
namespace hhu\z\controllers;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Controller of the Agent to show an introduction page.
|
* Controller of the Agent to show an introduction page.
|
||||||
*
|
*
|
||||||
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
||||||
*/
|
*/
|
||||||
class IntroductionController extends \hhu\z\controllers\IntermediateController
|
class IntroductionController extends \hhu\z\controllers\IntermediateController
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Action: index.
|
* Action: index.
|
||||||
*/
|
*/
|
||||||
public function index()
|
public function index()
|
||||||
{
|
{
|
||||||
// Pass data to view
|
// Pass data to view
|
||||||
$this->set('userId', $this->Auth->getUserId());
|
$this->set('userId', $this->Auth->getUserId());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load diff
|
|
@ -1,136 +1,136 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Legend of Z
|
* The Legend of Z
|
||||||
*
|
*
|
||||||
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
||||||
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
|
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
|
||||||
* @license http://www.gnu.org/licenses/gpl.html
|
* @license http://www.gnu.org/licenses/gpl.html
|
||||||
* @link https://bitbucket.org/coderkun/the-legend-of-z
|
* @link https://bitbucket.org/coderkun/the-legend-of-z
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace hhu\z\controllers;
|
namespace hhu\z\controllers;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Controller of the MailAgent to generate a mail message.
|
* Controller of the MailAgent to generate a mail message.
|
||||||
*
|
*
|
||||||
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
||||||
*/
|
*/
|
||||||
class MailController extends \nre\core\Controller
|
class MailController extends \nre\core\Controller
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Prefilter.
|
* Prefilter.
|
||||||
*
|
*
|
||||||
* @param \nre\core\Request $request Current request
|
* @param \nre\core\Request $request Current request
|
||||||
* @param \nre\core\Response $response Current response
|
* @param \nre\core\Response $response Current response
|
||||||
*/
|
*/
|
||||||
public function preFilter(\nre\core\Request $request, \nre\core\Response $response)
|
public function preFilter(\nre\core\Request $request, \nre\core\Response $response)
|
||||||
{
|
{
|
||||||
parent::preFilter($request, $response);
|
parent::preFilter($request, $response);
|
||||||
|
|
||||||
|
|
||||||
// Set linker
|
// Set linker
|
||||||
$this->set('linker', ($request instanceof \hhu\z\requests\MailRequest && !is_null($request->getLinker())) ? $request->getLinker() : null);
|
$this->set('linker', ($request instanceof \hhu\z\requests\MailRequest && !is_null($request->getLinker())) ? $request->getLinker() : null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Action: userregistration.
|
* Action: userregistration.
|
||||||
*
|
*
|
||||||
* Generate a mail message to notify of a new user registration.
|
* Generate a mail message to notify of a new user registration.
|
||||||
*
|
*
|
||||||
* @param array $receiver User that the message will be send to
|
* @param array $receiver User that the message will be send to
|
||||||
* @param array $neUser Newly registered user
|
* @param array $neUser Newly registered user
|
||||||
*/
|
*/
|
||||||
public function userregistration($receiver, $newUser)
|
public function userregistration($receiver, $newUser)
|
||||||
{
|
{
|
||||||
// Set subject
|
// Set subject
|
||||||
$this->response->setSubject(_('New user registration'));
|
$this->response->setSubject(_('New user registration'));
|
||||||
|
|
||||||
|
|
||||||
// Pass data to view
|
// Pass data to view
|
||||||
$this->set('user', $newUser);
|
$this->set('user', $newUser);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Action: characterregistration.
|
* Action: characterregistration.
|
||||||
*
|
*
|
||||||
* Generate a mail message to notify of a new Character
|
* Generate a mail message to notify of a new Character
|
||||||
* registration.
|
* registration.
|
||||||
*
|
*
|
||||||
* @param array $receiver User that the message will be send to
|
* @param array $receiver User that the message will be send to
|
||||||
* @param array $seminary Seminary which the Character was created for
|
* @param array $seminary Seminary which the Character was created for
|
||||||
* @param arary $user User of the newly registered Character
|
* @param arary $user User of the newly registered Character
|
||||||
* @param array $newCharacter Newly registered Character
|
* @param array $newCharacter Newly registered Character
|
||||||
*/
|
*/
|
||||||
public function characterregistration($receiver, $seminary, $user, $newCharacter)
|
public function characterregistration($receiver, $seminary, $user, $newCharacter)
|
||||||
{
|
{
|
||||||
// Set subject
|
// Set subject
|
||||||
$this->response->setSubject(_('New Character registration'));
|
$this->response->setSubject(_('New Character registration'));
|
||||||
|
|
||||||
|
|
||||||
// Pass data to view
|
// Pass data to view
|
||||||
$this->set('seminary', $seminary);
|
$this->set('seminary', $seminary);
|
||||||
$this->set('user', $user);
|
$this->set('user', $user);
|
||||||
$this->set('character', $newCharacter);
|
$this->set('character', $newCharacter);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Action: charactersubmission.
|
* Action: charactersubmission.
|
||||||
*
|
*
|
||||||
* Generate a mail message to notify of a new Character
|
* Generate a mail message to notify of a new Character
|
||||||
* submission for a Quest that needs to be valuated.
|
* submission for a Quest that needs to be valuated.
|
||||||
*
|
*
|
||||||
* @param array $receiver User that the message will be send to
|
* @param array $receiver User that the message will be send to
|
||||||
* @param array $seminary Seminary which the Quest belongs to
|
* @param array $seminary Seminary which the Quest belongs to
|
||||||
* @param array $questgroup Questgroup of Quest
|
* @param array $questgroup Questgroup of Quest
|
||||||
* @param array $quest Quest the answer has been submitted for
|
* @param array $quest Quest the answer has been submitted for
|
||||||
* @param array $character Character that send the submission
|
* @param array $character Character that send the submission
|
||||||
*/
|
*/
|
||||||
public function charactersubmission($receiver, $seminary, $questgroup, $quest, $character)
|
public function charactersubmission($receiver, $seminary, $questgroup, $quest, $character)
|
||||||
{
|
{
|
||||||
// Set subject
|
// Set subject
|
||||||
$this->response->setSubject(_('New Character submission'));
|
$this->response->setSubject(_('New Character submission'));
|
||||||
|
|
||||||
|
|
||||||
// Pass data to view
|
// Pass data to view
|
||||||
$this->set('seminary', $seminary);
|
$this->set('seminary', $seminary);
|
||||||
$this->set('questgroup', $questgroup);
|
$this->set('questgroup', $questgroup);
|
||||||
$this->set('quest', $quest);
|
$this->set('quest', $quest);
|
||||||
$this->set('character', $character);
|
$this->set('character', $character);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Action: charactersubmissionapproved.
|
* Action: charactersubmissionapproved.
|
||||||
*
|
*
|
||||||
* Generate a mail message to notify a Character that its
|
* Generate a mail message to notify a Character that its
|
||||||
* submission has been approved.
|
* submission has been approved.
|
||||||
*
|
*
|
||||||
* @param array $receiver User that the message will be send to
|
* @param array $receiver User that the message will be send to
|
||||||
* @param array $seminary Seminary which the Quest belongs to
|
* @param array $seminary Seminary which the Quest belongs to
|
||||||
* @param array $questgroup Questgroup of Quest
|
* @param array $questgroup Questgroup of Quest
|
||||||
* @param array $quest Quest the answer has been submitted for
|
* @param array $quest Quest the answer has been submitted for
|
||||||
*/
|
*/
|
||||||
public function charactersubmissionapproved($receiver, $seminary, $questgroup, $quest)
|
public function charactersubmissionapproved($receiver, $seminary, $questgroup, $quest)
|
||||||
{
|
{
|
||||||
// Set subject
|
// Set subject
|
||||||
$this->response->setSubject(_('Character submission approved'));
|
$this->response->setSubject(_('Character submission approved'));
|
||||||
|
|
||||||
|
|
||||||
// Pass data to view
|
// Pass data to view
|
||||||
$this->set('seminary', $seminary);
|
$this->set('seminary', $seminary);
|
||||||
$this->set('questgroup', $questgroup);
|
$this->set('questgroup', $questgroup);
|
||||||
$this->set('quest', $quest);
|
$this->set('quest', $quest);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
|
||||||
|
|
@ -1,39 +1,39 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Legend of Z
|
* The Legend of Z
|
||||||
*
|
*
|
||||||
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
||||||
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
|
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
|
||||||
* @license http://www.gnu.org/licenses/gpl.html
|
* @license http://www.gnu.org/licenses/gpl.html
|
||||||
* @link https://bitbucket.org/coderkun/the-legend-of-z
|
* @link https://bitbucket.org/coderkun/the-legend-of-z
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace hhu\z\controllers;
|
namespace hhu\z\controllers;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Controller of the MailreceiverAgent to generate a mail receiver
|
* Controller of the MailreceiverAgent to generate a mail receiver
|
||||||
* salutation.
|
* salutation.
|
||||||
*
|
*
|
||||||
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
||||||
*/
|
*/
|
||||||
class MailreceiverController extends \nre\core\Controller
|
class MailreceiverController extends \nre\core\Controller
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Action: index.
|
* Action: index.
|
||||||
*
|
*
|
||||||
* @param $array $user User receiving mail
|
* @param $array $user User receiving mail
|
||||||
*/
|
*/
|
||||||
public function index($user)
|
public function index($user)
|
||||||
{
|
{
|
||||||
$this->set('user', $user);
|
$this->set('user', $user);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
|
||||||
|
|
@ -1,62 +1,62 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Legend of Z
|
* The Legend of Z
|
||||||
*
|
*
|
||||||
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
||||||
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
|
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
|
||||||
* @license http://www.gnu.org/licenses/gpl.html
|
* @license http://www.gnu.org/licenses/gpl.html
|
||||||
* @link https://bitbucket.org/coderkun/the-legend-of-z
|
* @link https://bitbucket.org/coderkun/the-legend-of-z
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace hhu\z\controllers;
|
namespace hhu\z\controllers;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Controller of the MapAgent to display a map.
|
* Controller of the MapAgent to display a map.
|
||||||
*
|
*
|
||||||
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
||||||
*/
|
*/
|
||||||
class MapController extends \hhu\z\controllers\SeminaryController
|
class MapController extends \hhu\z\controllers\SeminaryController
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Required models
|
* Required models
|
||||||
*
|
*
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
public $models = array('seminaries', 'map');
|
public $models = array('seminaries', 'map');
|
||||||
/**
|
/**
|
||||||
* User permissions
|
* User permissions
|
||||||
*
|
*
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
public $permissions = array(
|
public $permissions = array(
|
||||||
'index' => array('admin', 'moderator', 'user')
|
'index' => array('admin', 'moderator', 'user')
|
||||||
);
|
);
|
||||||
/**
|
/**
|
||||||
* User seminary permissions
|
* User seminary permissions
|
||||||
*
|
*
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
public $seminaryPermissions = array(
|
public $seminaryPermissions = array(
|
||||||
'index' => array('admin', 'moderator', 'user')
|
'index' => array('admin', 'moderator', 'user')
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Action: index.
|
* Action: index.
|
||||||
*
|
*
|
||||||
* Draw the map.
|
* Draw the map.
|
||||||
*
|
*
|
||||||
* @throws \nre\exceptions\IdNotFoundException
|
* @throws \nre\exceptions\IdNotFoundException
|
||||||
* @param string $seminaryUrl URL-Title of Seminary
|
* @param string $seminaryUrl URL-Title of Seminary
|
||||||
*/
|
*/
|
||||||
public function index($seminaryUrl)
|
public function index($seminaryUrl)
|
||||||
{
|
{
|
||||||
// Get Seminary
|
// Get Seminary
|
||||||
$seminary = $this->Seminaries->getSeminaryByUrl($seminaryUrl);
|
$seminary = $this->Seminaries->getSeminaryByUrl($seminaryUrl);
|
||||||
|
|
||||||
// Get map
|
// Get map
|
||||||
$map = $this->Map->getMapOfSeminary($seminary['id']);
|
$map = $this->Map->getMapOfSeminary($seminary['id']);
|
||||||
|
|
@ -65,8 +65,8 @@
|
||||||
// Pass data to view
|
// Pass data to view
|
||||||
$this->set('seminary', $seminary);
|
$this->set('seminary', $seminary);
|
||||||
$this->set('map', $map);
|
$this->set('map', $map);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load diff
|
|
@ -1,52 +1,52 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Legend of Z
|
* The Legend of Z
|
||||||
*
|
*
|
||||||
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
||||||
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
|
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
|
||||||
* @license http://www.gnu.org/licenses/gpl.html
|
* @license http://www.gnu.org/licenses/gpl.html
|
||||||
* @link https://bitbucket.org/coderkun/the-legend-of-z
|
* @link https://bitbucket.org/coderkun/the-legend-of-z
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace hhu\z\controllers;
|
namespace hhu\z\controllers;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Controller of the Agent to display a menu.
|
* Controller of the Agent to display a menu.
|
||||||
*
|
*
|
||||||
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
||||||
*/
|
*/
|
||||||
class MenuController extends \hhu\z\Controller
|
class MenuController extends \hhu\z\Controller
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Prefilter.
|
* Prefilter.
|
||||||
*
|
*
|
||||||
* @param \nre\core\Request $request Current request
|
* @param \nre\core\Request $request Current request
|
||||||
* @param \nre\core\Response $response Current response
|
* @param \nre\core\Response $response Current response
|
||||||
*/
|
*/
|
||||||
public function preFilter(\nre\core\Request $request, \nre\core\Response $response)
|
public function preFilter(\nre\core\Request $request, \nre\core\Response $response)
|
||||||
{
|
{
|
||||||
parent::preFilter($request, $response);
|
parent::preFilter($request, $response);
|
||||||
|
|
||||||
// Set userdata
|
// Set userdata
|
||||||
$this->set('loggedUser', IntermediateController::$user);
|
$this->set('loggedUser', IntermediateController::$user);
|
||||||
$this->set('loggedCharacter', SeminaryController::$character);
|
$this->set('loggedCharacter', SeminaryController::$character);
|
||||||
$this->set('loggedSeminary', SeminaryController::$seminary);
|
$this->set('loggedSeminary', SeminaryController::$seminary);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Action: index.
|
* Action: index.
|
||||||
*/
|
*/
|
||||||
public function index()
|
public function index()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load diff
|
|
@ -1,346 +1,346 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Legend of Z
|
* The Legend of Z
|
||||||
*
|
*
|
||||||
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
||||||
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
|
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
|
||||||
* @license http://www.gnu.org/licenses/gpl.html
|
* @license http://www.gnu.org/licenses/gpl.html
|
||||||
* @link https://bitbucket.org/coderkun/the-legend-of-z
|
* @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);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
namespace hhu\z\controllers;
|
||||||
// Edit Questgroup
|
|
||||||
if($validation === true)
|
|
||||||
{
|
/**
|
||||||
$this->Questgroupshierarchy->editQuestgroupshierarchy(
|
* Controller of the QuestgroupsAgent to display Questgroups.
|
||||||
$questgroupshierarchy['id'],
|
*
|
||||||
$titleSingular,
|
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
||||||
$titlePlural
|
*/
|
||||||
);
|
class QuestgroupshierarchyController extends \hhu\z\controllers\SeminaryController
|
||||||
$questgroupshierarchy = $this->Questgroupshierarchy->getHierarchyById($questgroupshierarchy['id']);
|
{
|
||||||
|
/**
|
||||||
// Redirect to Seminary page
|
* Required components
|
||||||
$this->redirect($this->linker->link(array('seminaries', 'seminary', $seminary['url'])));
|
*
|
||||||
}
|
* @var array
|
||||||
}
|
*/
|
||||||
|
public $components = array('validation');
|
||||||
// Get validation settings
|
/**
|
||||||
$validationSettings = array(
|
* Required models
|
||||||
'title' => \nre\configs\AppConfig::$validation['title']
|
*
|
||||||
);
|
* @var array
|
||||||
|
*/
|
||||||
|
public $models = array('seminaries', 'questgroupshierarchy', 'questgroups');
|
||||||
// Set titile
|
/**
|
||||||
$this->addTitleLocalized('Edit Questgroupshierarchy');
|
* User permissions
|
||||||
$this->addTitle($seminary['title']);
|
*
|
||||||
|
* @var array
|
||||||
// Pass data to view
|
*/
|
||||||
$this->set('seminary', $seminary);
|
public $permissions = array(
|
||||||
$this->set('titleSingular', $titleSingular);
|
'create' => array('admin', 'moderator', 'user'),
|
||||||
$this->set('titlePlural', $titlePlural);
|
'edit' => array('admin', 'moderator', 'user'),
|
||||||
$this->set('validation', $validation);
|
'moveup' => array('admin', 'moderator', 'user'),
|
||||||
$this->set('validationSettings', $validationSettings);
|
'movedown' => array('admin', 'moderator', 'user'),
|
||||||
}
|
'delete' => array('admin', 'moderator', 'user')
|
||||||
|
);
|
||||||
|
/**
|
||||||
/**
|
* User seminary permissions
|
||||||
* Action: moveup.
|
*
|
||||||
*
|
* @var array
|
||||||
* Move a Questgroupshierarchy up (decrement position).
|
*/
|
||||||
*
|
public $seminaryPermissions = array(
|
||||||
* @throws \nre\exceptions\IdNotFoundException
|
'create' => array('admin'),
|
||||||
* @param string $seminaryUrl URL-title of Seminary
|
'edit' => array('admin'),
|
||||||
* @param string $questgroupshierarchyUrl URL-title of Questgroupshierarchy
|
'moveup' => array('admin'),
|
||||||
*/
|
'movedown' => array('admin'),
|
||||||
public function moveup($seminaryUrl, $questgroupshierarchyUrl)
|
'delete' => array('admin')
|
||||||
{
|
);
|
||||||
// Get seminary
|
|
||||||
$seminary = $this->Seminaries->getSeminaryByUrl($seminaryUrl);
|
|
||||||
|
|
||||||
// Get Questgroupshierarchy
|
|
||||||
$questgroupshierarchy = $this->Questgroupshierarchy->getHierarchyByUrl($seminary['id'], $questgroupshierarchyUrl);
|
/**
|
||||||
|
* Action: create.
|
||||||
// Set position
|
*
|
||||||
$this->Questgroupshierarchy->moveQuestgroupshierarchy($questgroupshierarchy, true);
|
* Create a new Questgroupshierarchy.
|
||||||
|
*
|
||||||
|
* @param string $seminaryUrl URL-title of a Seminary
|
||||||
// Redirect
|
*/
|
||||||
$referer = $this->request->getGetParam('referer');
|
public function create($seminaryUrl)
|
||||||
if(!is_null($referer))
|
{
|
||||||
{
|
// Get seminary
|
||||||
try {
|
$seminary = $this->Seminaries->getSeminaryByUrl($seminaryUrl);
|
||||||
$questgroup = $this->Questgroups->getQuestgroupById($referer);
|
|
||||||
$this->redirect($this->linker->link(array('questgroups', 'questgroup', $seminary['url'], $questgroup['url'])));
|
// Get parent Questgroupshierarchy
|
||||||
}
|
$parentQuestgroupshierarchy = $this->Questgroupshierarchy->getHierarchyOfSeminary($seminary['id']);
|
||||||
catch(IdNotFoundException $e) {
|
|
||||||
}
|
// Values
|
||||||
}
|
$titleSingular = '';
|
||||||
$this->redirect($this->linker->link(array('seminaries', 'seminary', $seminary['url'])));
|
$titlePlural = '';
|
||||||
}
|
$validation = array();
|
||||||
|
|
||||||
|
// Create Questgroupshierarchy
|
||||||
/**
|
if($this->request->getRequestMethod() == 'POST' && !is_null($this->request->getPostParam('create')))
|
||||||
* Action: movedown.
|
{
|
||||||
*
|
// Get params and validate them
|
||||||
* Move a Questgroupshierarchy down (increment position).
|
$titleSingular = $this->request->getPostParam('title_singular');
|
||||||
*
|
$validation = $this->Validation->addValidationResults(
|
||||||
* @throws \nre\exceptions\IdNotFoundException
|
$validation,
|
||||||
* @param string $seminaryUrl URL-title of Seminary
|
'titleSingular',
|
||||||
* @param string $questgroupshierarchyUrl URL-title of Questgroupshierarchy
|
$this->Validation->validate($titleSingular, \nre\configs\AppConfig::$validation['questgroupshierarchytitle'])
|
||||||
*/
|
);
|
||||||
public function movedown($seminaryUrl, $questgroupshierarchyUrl)
|
if($this->Questgroupshierarchy->questgroupshierarchyTitleSingularExists($titleSingular, $seminary['id'])) {
|
||||||
{
|
$validation = $this->Validation->addValidationResult($validation, 'titleSingular', 'exist', true);
|
||||||
// Get seminary
|
}
|
||||||
$seminary = $this->Seminaries->getSeminaryByUrl($seminaryUrl);
|
$titlePlural = $this->request->getPostParam('title_plural');
|
||||||
|
$validation = $this->Validation->addValidationResults(
|
||||||
// Get Questgroupshierarchy
|
$validation,
|
||||||
$questgroupshierarchy = $this->Questgroupshierarchy->getHierarchyByUrl($seminary['id'], $questgroupshierarchyUrl);
|
'titlePlural',
|
||||||
|
$this->Validation->validate($titlePlural, \nre\configs\AppConfig::$validation['questgroupshierarchytitle'])
|
||||||
// Set position
|
);
|
||||||
$this->Questgroupshierarchy->moveQuestgroupshierarchy($questgroupshierarchy, false);
|
if($this->Questgroupshierarchy->questgroupshierarchyTitleSingularExists($titlePlural, $seminary['id'])) {
|
||||||
|
$validation = $this->Validation->addValidationResult($validation, 'titlePlural', 'exist', true);
|
||||||
|
}
|
||||||
// Redirect
|
|
||||||
$referer = $this->request->getGetParam('referer');
|
// Validate parent Questgroupshierarchy
|
||||||
if(!is_null($referer))
|
$parentQuestgroupshierarchyIndex = null;
|
||||||
{
|
foreach($parentQuestgroupshierarchy as $index => &$parentHierarchy)
|
||||||
try {
|
{
|
||||||
$questgroup = $this->Questgroups->getQuestgroupById($referer);
|
$parentHierarchy['selected'] = ($parentHierarchy['url'] == $this->request->getPostParam('parent'));
|
||||||
$this->redirect($this->linker->link(array('questgroups', 'questgroup', $seminary['url'], $questgroup['url'])));
|
if($parentHierarchy['selected']) {
|
||||||
}
|
$parentQuestgroupshierarchyIndex = $index;
|
||||||
catch(IdNotFoundException $e) {
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
$this->redirect($this->linker->link(array('seminaries', 'seminary', $seminary['url'])));
|
// Create new Questgroupshierarchy
|
||||||
}
|
if($validation === true)
|
||||||
|
{
|
||||||
|
$questgroupshierarchyId = $this->Questgroupshierarchy->createQuestgroupshierarchy(
|
||||||
/**
|
$this->Auth->getUserId(),
|
||||||
* Action: delete.
|
$seminary['id'],
|
||||||
*
|
(!is_null($parentQuestgroupshierarchyIndex) ? $parentQuestgroupshierarchy[$parentQuestgroupshierarchyIndex]['id'] : null),
|
||||||
* Delete a Questgroupshierarchy.
|
$titleSingular,
|
||||||
*
|
$titlePlural
|
||||||
* @throws \nre\exceptions\IdNotFoundException
|
);
|
||||||
* @param string $seminaryUrl URL-title of Seminary
|
$questgroupshierarchy = $this->Questgroupshierarchy->getHierarchyById($questgroupshierarchyId);
|
||||||
* @param string $questgroupshierarchyUrl URL-title of Questgroupshierarchy
|
|
||||||
*/
|
// Redirect
|
||||||
public function delete($seminaryUrl, $questgroupshierarchyUrl)
|
$this->redirect($this->linker->link(array('seminaries', 'seminary', $seminary['url'])));
|
||||||
{
|
}
|
||||||
// Get seminary
|
}
|
||||||
$seminary = $this->Seminaries->getSeminaryByUrl($seminaryUrl);
|
|
||||||
|
// Get validation settings
|
||||||
// Get Questgroupshierarchy
|
$validationSettings = array(
|
||||||
$questgroupshierarchy = $this->Questgroupshierarchy->getHierarchyByUrl($seminary['id'], $questgroupshierarchyUrl);
|
'title' => \nre\configs\AppConfig::$validation['title']
|
||||||
|
);
|
||||||
// Check request method
|
|
||||||
if($this->request->getRequestMethod() == 'POST')
|
|
||||||
{
|
// Set titile
|
||||||
// Check confirmation
|
$this->addTitleLocalized('Create Questgroupshierarchy');
|
||||||
if(!is_null($this->request->getPostParam('delete')))
|
$this->addTitle($seminary['title']);
|
||||||
{
|
|
||||||
// Delete Questgroupshierarchy
|
// Pass data to view
|
||||||
$this->Questgroupshierarchy->deleteQuestgroupshierarchy($questgroupshierarchy['id']);
|
$this->set('seminary', $seminary);
|
||||||
}
|
$this->set('titleSingular', $titleSingular);
|
||||||
|
$this->set('titlePlural', $titlePlural);
|
||||||
// Redirect to Seminary page
|
$this->set('parentQuestgroupshierarchy', $parentQuestgroupshierarchy);
|
||||||
$this->redirect($this->linker->link(array('seminaries', 'seminary', $seminary['url'])));
|
$this->set('validation', $validation);
|
||||||
}
|
$this->set('validationSettings', $validationSettings);
|
||||||
|
}
|
||||||
|
|
||||||
// Set titile
|
|
||||||
$this->addTitleLocalized('Delete Questgroupshierarchy');
|
/**
|
||||||
|
* Action: edit.
|
||||||
// Show confirmation
|
*
|
||||||
$this->set('seminary', $seminary);
|
* Edit a Questgroupshierarchy.
|
||||||
$this->set('questgroupshierarchy', $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
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Legend of Z
|
* The Legend of Z
|
||||||
*
|
*
|
||||||
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
||||||
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
|
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
|
||||||
* @license http://www.gnu.org/licenses/gpl.html
|
* @license http://www.gnu.org/licenses/gpl.html
|
||||||
* @link https://bitbucket.org/coderkun/the-legend-of-z
|
* @link https://bitbucket.org/coderkun/the-legend-of-z
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace hhu\z\controllers;
|
namespace hhu\z\controllers;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Controller of QuestgroupshierarchypathAgent to display the
|
* Controller of QuestgroupshierarchypathAgent to display the
|
||||||
* Questgroups hierarchy path.
|
* Questgroups hierarchy path.
|
||||||
*
|
*
|
||||||
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
||||||
*/
|
*/
|
||||||
class QuestgroupshierarchypathController extends \hhu\z\Controller
|
class QuestgroupshierarchypathController extends \hhu\z\Controller
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Required models
|
* Required models
|
||||||
*
|
*
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
public $models = array('seminaries', 'questgroups', 'questgroupshierarchy', 'quests', 'questtexts');
|
public $models = array('seminaries', 'questgroups', 'questgroupshierarchy', 'quests', 'questtexts');
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Action: index.
|
* Action: index.
|
||||||
*
|
*
|
||||||
* Calculate and show the hierarchy path of a Questgroup.
|
* Calculate and show the hierarchy path of a Questgroup.
|
||||||
*
|
*
|
||||||
* @param string $seminaryUrl URL-Title of a Seminary
|
* @param string $seminaryUrl URL-Title of a Seminary
|
||||||
* @param string $questgroupUrl URL-Title of a Questgroup
|
* @param string $questgroupUrl URL-Title of a Questgroup
|
||||||
* @param boolean $showGroup Show the current group itself
|
* @param boolean $showGroup Show the current group itself
|
||||||
*/
|
*/
|
||||||
public function index($seminaryUrl, $questgroupUrl, $showGroup=false)
|
public function index($seminaryUrl, $questgroupUrl, $showGroup=false)
|
||||||
{
|
{
|
||||||
// Get Seminary
|
// Get Seminary
|
||||||
$seminary = $this->Seminaries->getSeminaryByUrl($seminaryUrl);
|
$seminary = $this->Seminaries->getSeminaryByUrl($seminaryUrl);
|
||||||
|
|
||||||
// Get Questgroup
|
// Get Questgroup
|
||||||
$questgroup = $this->Questgroups->getQuestgroupByUrl($seminary['id'], $questgroupUrl);
|
$questgroup = $this->Questgroups->getQuestgroupByUrl($seminary['id'], $questgroupUrl);
|
||||||
$questgroup['hierarchy'] = $this->Questgroupshierarchy->getHierarchyForQuestgroup($questgroup['id']);
|
$questgroup['hierarchy'] = $this->Questgroupshierarchy->getHierarchyForQuestgroup($questgroup['id']);
|
||||||
|
|
||||||
// Get parent Questgrouphierarchy
|
// Get parent Questgrouphierarchy
|
||||||
$currentQuestgroup = $questgroup;
|
$currentQuestgroup = $questgroup;
|
||||||
$parentQuestgroupshierarchy = array();
|
$parentQuestgroupshierarchy = array();
|
||||||
if($showGroup) {
|
if($showGroup) {
|
||||||
array_unshift($parentQuestgroupshierarchy, $currentQuestgroup);
|
array_unshift($parentQuestgroupshierarchy, $currentQuestgroup);
|
||||||
}
|
}
|
||||||
if(is_null($questgroup['hierarchy']))
|
if(is_null($questgroup['hierarchy']))
|
||||||
{
|
{
|
||||||
// Get related Questgroup
|
// Get related Questgroup
|
||||||
$questtexts = $this->Questtexts->getRelatedQuesttextsForQuestgroup($currentQuestgroup['id']);
|
$questtexts = $this->Questtexts->getRelatedQuesttextsForQuestgroup($currentQuestgroup['id']);
|
||||||
$questtext = $this->Questtexts->pickQuesttextLastEnteredByCharacter(\hhu\z\controllers\SeminaryController::$character['id'], $questtexts);
|
$questtext = $this->Questtexts->pickQuesttextLastEnteredByCharacter(\hhu\z\controllers\SeminaryController::$character['id'], $questtexts);
|
||||||
$quest = $this->Quests->getQuestById($questtext['quest_id']);
|
$quest = $this->Quests->getQuestById($questtext['quest_id']);
|
||||||
$currentQuestgroup = $this->Questgroups->getQuestgroupById($quest['questgroup_id']);
|
$currentQuestgroup = $this->Questgroups->getQuestgroupById($quest['questgroup_id']);
|
||||||
$currentQuestgroup['hierarchy'] = $this->Questgroupshierarchy->getHierarchyForQuestgroup($currentQuestgroup['id']);
|
$currentQuestgroup['hierarchy'] = $this->Questgroupshierarchy->getHierarchyForQuestgroup($currentQuestgroup['id']);
|
||||||
$quest['questgroup'] = $currentQuestgroup;
|
$quest['questgroup'] = $currentQuestgroup;
|
||||||
|
|
||||||
// Use Hierarchy name for optional Questgroup
|
// Use Hierarchy name for optional Questgroup
|
||||||
if(!empty($parentQuestgroupshierarchy)) {
|
if(!empty($parentQuestgroupshierarchy)) {
|
||||||
$parentQuestgroupshierarchy[0]['hierarchy'] = $currentQuestgroup['hierarchy'];
|
$parentQuestgroupshierarchy[0]['hierarchy'] = $currentQuestgroup['hierarchy'];
|
||||||
unset($parentQuestgroupshierarchy[0]['hierarchy']['questgroup_pos']);
|
unset($parentQuestgroupshierarchy[0]['hierarchy']['questgroup_pos']);
|
||||||
}
|
}
|
||||||
|
|
||||||
array_unshift($parentQuestgroupshierarchy, $quest);
|
array_unshift($parentQuestgroupshierarchy, $quest);
|
||||||
array_unshift($parentQuestgroupshierarchy, $currentQuestgroup);
|
array_unshift($parentQuestgroupshierarchy, $currentQuestgroup);
|
||||||
}
|
}
|
||||||
while(!empty($currentQuestgroup['hierarchy']) && !is_null($currentQuestgroup['hierarchy']['parent_questgroup_id']))
|
while(!empty($currentQuestgroup['hierarchy']) && !is_null($currentQuestgroup['hierarchy']['parent_questgroup_id']))
|
||||||
{
|
{
|
||||||
$currentQuestgroup = $this->Questgroups->GetQuestgroupById($currentQuestgroup['hierarchy']['parent_questgroup_id']);
|
$currentQuestgroup = $this->Questgroups->GetQuestgroupById($currentQuestgroup['hierarchy']['parent_questgroup_id']);
|
||||||
$currentQuestgroup['hierarchy'] = $this->Questgroupshierarchy->getHierarchyForQuestgroup($currentQuestgroup['id']);
|
$currentQuestgroup['hierarchy'] = $this->Questgroupshierarchy->getHierarchyForQuestgroup($currentQuestgroup['id']);
|
||||||
array_unshift($parentQuestgroupshierarchy, $currentQuestgroup);
|
array_unshift($parentQuestgroupshierarchy, $currentQuestgroup);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Pass data to view
|
// Pass data to view
|
||||||
$this->set('seminary', $seminary);
|
$this->set('seminary', $seminary);
|
||||||
$this->set('parentquestgroupshierarchy', $parentQuestgroupshierarchy);
|
$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
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Legend of Z
|
* The Legend of Z
|
||||||
*
|
*
|
||||||
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
||||||
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
|
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
|
||||||
* @license http://www.gnu.org/licenses/gpl.html
|
* @license http://www.gnu.org/licenses/gpl.html
|
||||||
* @link https://bitbucket.org/coderkun/the-legend-of-z
|
* @link https://bitbucket.org/coderkun/the-legend-of-z
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace hhu\z\controllers;
|
namespace hhu\z\controllers;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Controller of the Agent to display a sidebar with Seminary related
|
* Controller of the Agent to display a sidebar with Seminary related
|
||||||
* information.
|
* information.
|
||||||
*
|
*
|
||||||
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
||||||
*/
|
*/
|
||||||
class SeminarybarController extends \hhu\z\Controller
|
class SeminarybarController extends \hhu\z\Controller
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Required models
|
* Required models
|
||||||
*
|
*
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
public $models = array('characters', 'quests', 'questgroups', 'achievements', 'charactergroups', 'avatars', 'media', 'xplevels');
|
public $models = array('characters', 'quests', 'questgroups', 'achievements', 'charactergroups', 'avatars', 'media', 'xplevels');
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Action: index.
|
* Action: index.
|
||||||
*/
|
*/
|
||||||
public function index()
|
public function index()
|
||||||
{
|
{
|
||||||
// Do not render at first
|
// Do not render at first
|
||||||
$this->set('render', false);
|
$this->set('render', false);
|
||||||
|
|
||||||
// Get Seminary
|
// Get Seminary
|
||||||
$seminary = SeminaryController::$seminary;
|
$seminary = SeminaryController::$seminary;
|
||||||
if(is_null($seminary)) {
|
if(is_null($seminary)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get Character
|
// Get Character
|
||||||
$character = SeminaryController::$character;
|
$character = SeminaryController::$character;
|
||||||
if(is_null($character)) {
|
if(is_null($character)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$character['rank'] = $this->Characters->getXPRank($seminary['id'], $character['xps']);
|
$character['rank'] = $this->Characters->getXPRank($seminary['id'], $character['xps']);
|
||||||
|
|
||||||
// Get “last” Quest
|
// Get “last” Quest
|
||||||
$lastQuest = $this->Quests->getLastQuestForCharacter($character['id']);
|
$lastQuest = $this->Quests->getLastQuestForCharacter($character['id']);
|
||||||
if(!is_null($lastQuest)) {
|
if(!is_null($lastQuest)) {
|
||||||
$lastQuest['questgroup'] = $this->Questgroups->getQuestgroupById($lastQuest['questgroup_id']);
|
$lastQuest['questgroup'] = $this->Questgroups->getQuestgroupById($lastQuest['questgroup_id']);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get last achieved Achievement
|
// Get last achieved Achievement
|
||||||
$achievements = $this->Achievements->getAchievedAchievementsForCharacter($character['id'], false);
|
$achievements = $this->Achievements->getAchievedAchievementsForCharacter($character['id'], false);
|
||||||
$lastAchievement = array_shift($achievements);
|
$lastAchievement = array_shift($achievements);
|
||||||
|
|
||||||
// Get Character group members
|
// Get Character group members
|
||||||
$characterGroups = array();
|
$characterGroups = array();
|
||||||
foreach($this->Charactergroups->getGroupsForCharacter($character['id']) as $group)
|
foreach($this->Charactergroups->getGroupsForCharacter($character['id']) as $group)
|
||||||
{
|
{
|
||||||
$groupsgroup = $this->Charactergroups->getGroupsgroupById($group['charactergroupsgroup_id']);
|
$groupsgroup = $this->Charactergroups->getGroupsgroupById($group['charactergroupsgroup_id']);
|
||||||
if($groupsgroup['preferred'])
|
if($groupsgroup['preferred'])
|
||||||
{
|
{
|
||||||
$group['members'] = $this->Characters->getCharactersForGroup($group['id']);
|
$group['members'] = $this->Characters->getCharactersForGroup($group['id']);
|
||||||
$characterGroups[] = $group;
|
$characterGroups[] = $group;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Pass data to view
|
// Pass data to view
|
||||||
$this->set('seminary', $seminary);
|
$this->set('seminary', $seminary);
|
||||||
$this->set('character', $character);
|
$this->set('character', $character);
|
||||||
$this->set('lastQuest', $lastQuest);
|
$this->set('lastQuest', $lastQuest);
|
||||||
$this->set('lastAchievement', $lastAchievement);
|
$this->set('lastAchievement', $lastAchievement);
|
||||||
$this->set('characterGroups', $characterGroups);
|
$this->set('characterGroups', $characterGroups);
|
||||||
// Render now
|
// Render now
|
||||||
$this->set('render', true);
|
$this->set('render', true);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
|
||||||
|
|
@ -1,53 +1,53 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Legend of Z
|
* The Legend of Z
|
||||||
*
|
*
|
||||||
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
||||||
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
|
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
|
||||||
* @license http://www.gnu.org/licenses/gpl.html
|
* @license http://www.gnu.org/licenses/gpl.html
|
||||||
* @link https://bitbucket.org/coderkun/the-legend-of-z
|
* @link https://bitbucket.org/coderkun/the-legend-of-z
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace hhu\z\controllers;
|
namespace hhu\z\controllers;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Controller of the Agent to display a menu with Seminary related
|
* Controller of the Agent to display a menu with Seminary related
|
||||||
* links.
|
* links.
|
||||||
*
|
*
|
||||||
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
||||||
*/
|
*/
|
||||||
class SeminarymenuController extends \hhu\z\Controller
|
class SeminarymenuController extends \hhu\z\Controller
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Prefilter.
|
* Prefilter.
|
||||||
*
|
*
|
||||||
* @param \nre\core\Request $request Current request
|
* @param \nre\core\Request $request Current request
|
||||||
* @param \nre\core\Response $response Current response
|
* @param \nre\core\Response $response Current response
|
||||||
*/
|
*/
|
||||||
public function preFilter(\nre\core\Request $request, \nre\core\Response $response)
|
public function preFilter(\nre\core\Request $request, \nre\core\Response $response)
|
||||||
{
|
{
|
||||||
parent::preFilter($request, $response);
|
parent::preFilter($request, $response);
|
||||||
|
|
||||||
// Set userdata
|
// Set userdata
|
||||||
$this->set('loggedUser', \hhu\z\controllers\IntermediateController::$user);
|
$this->set('loggedUser', \hhu\z\controllers\IntermediateController::$user);
|
||||||
$this->set('loggedSeminary', \hhu\z\controllers\SeminaryController::$seminary);
|
$this->set('loggedSeminary', \hhu\z\controllers\SeminaryController::$seminary);
|
||||||
$this->set('loggedCharacter', \hhu\z\controllers\SeminaryController::$character);
|
$this->set('loggedCharacter', \hhu\z\controllers\SeminaryController::$character);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Action: index.
|
* Action: index.
|
||||||
*/
|
*/
|
||||||
public function index()
|
public function index()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
|
||||||
|
|
@ -1,55 +1,55 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Legend of Z
|
* The Legend of Z
|
||||||
*
|
*
|
||||||
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
||||||
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
|
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
|
||||||
* @license http://www.gnu.org/licenses/gpl.html
|
* @license http://www.gnu.org/licenses/gpl.html
|
||||||
* @link https://bitbucket.org/coderkun/the-legend-of-z
|
* @link https://bitbucket.org/coderkun/the-legend-of-z
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace hhu\z\controllers;
|
namespace hhu\z\controllers;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Controller of the TextmailAgent for generating a simple text-mail
|
* Controller of the TextmailAgent for generating a simple text-mail
|
||||||
* message.
|
* message.
|
||||||
*
|
*
|
||||||
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
||||||
*/
|
*/
|
||||||
class TextmailController extends \nre\core\Controller
|
class TextmailController extends \nre\core\Controller
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Prefilter.
|
* Prefilter.
|
||||||
*
|
*
|
||||||
* @param \nre\core\Request $request Current request
|
* @param \nre\core\Request $request Current request
|
||||||
* @param \nre\core\Response $response Current response
|
* @param \nre\core\Response $response Current response
|
||||||
*/
|
*/
|
||||||
public function preFilter(\nre\core\Request $request, \nre\core\Response $response)
|
public function preFilter(\nre\core\Request $request, \nre\core\Response $response)
|
||||||
{
|
{
|
||||||
parent::preFilter($request, $response);
|
parent::preFilter($request, $response);
|
||||||
|
|
||||||
|
|
||||||
// Set linker
|
// Set linker
|
||||||
$this->set('linker', ($request instanceof \hhu\z\requests\MailRequest && !is_null($request->getLinker())) ? $request->getLinker() : null);
|
$this->set('linker', ($request instanceof \hhu\z\requests\MailRequest && !is_null($request->getLinker())) ? $request->getLinker() : null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Action: index.
|
* Action: index.
|
||||||
*
|
*
|
||||||
* Create simple text-mail message.
|
* Create simple text-mail message.
|
||||||
*/
|
*/
|
||||||
public function index()
|
public function index()
|
||||||
{
|
{
|
||||||
$this->set('appname', \nre\configs\AppConfig::$app['name']);
|
$this->set('appname', \nre\configs\AppConfig::$app['name']);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
|
||||||
|
|
@ -1,318 +1,318 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Legend of Z
|
* The Legend of Z
|
||||||
*
|
*
|
||||||
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
||||||
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
|
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
|
||||||
* @license http://www.gnu.org/licenses/gpl.html
|
* @license http://www.gnu.org/licenses/gpl.html
|
||||||
* @link https://bitbucket.org/coderkun/the-legend-of-z
|
* @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");
|
|
||||||
|
|
||||||
// Check file
|
namespace hhu\z\controllers;
|
||||||
if(!file_exists($upload['filename'])) {
|
|
||||||
throw new \nre\exceptions\IdNotFoundException($upload['url']);
|
|
||||||
}
|
/**
|
||||||
|
* Controller of the UploadsAgent to process and show user uploads.
|
||||||
// Cache
|
*
|
||||||
if($this->setCacheHeaders($upload['filename'])) {
|
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
||||||
return null;
|
*/
|
||||||
}
|
class UploadsController extends \hhu\z\controllers\SeminaryController
|
||||||
|
{
|
||||||
// Set geometry
|
/**
|
||||||
$width = 100;
|
* Required models
|
||||||
$height = 100;
|
*
|
||||||
|
* @var array
|
||||||
switch($upload['mimetype'])
|
*/
|
||||||
{
|
public $models = array('uploads', 'users', 'userroles', 'characterroles', 'seminaries', 'charactergroups');
|
||||||
case 'image/jpeg':
|
/**
|
||||||
case 'image/png':
|
* User permissions
|
||||||
// Read image from cache
|
*
|
||||||
$tempFileName = ROOT.DS.\nre\configs\AppConfig::$dirs['temporary'].DS.$upload['url'].'-'.$width.'x'.$height;
|
* @var array
|
||||||
if(file_exists($tempFileName))
|
*/
|
||||||
{
|
public $permissions = array(
|
||||||
// Check age of file
|
'seminary' => array('admin', 'moderator', 'user', 'guest'),
|
||||||
if(date('r', filemtime($tempFileName)+(60*60*24)) > date('r', time())) {
|
'charactergroup' => array('admin', 'moderator', 'user', 'guest')
|
||||||
// Too old, delete
|
);
|
||||||
unlink($tempFileName);
|
/**
|
||||||
}
|
* User seminary permissions
|
||||||
else {
|
*
|
||||||
// Valid, read and return
|
* @var array
|
||||||
return file_get_contents($tempFileName);
|
*/
|
||||||
}
|
public $seminaryPermissions = array(
|
||||||
}
|
'seminary' => array('admin', 'moderator', 'user', 'guest'),
|
||||||
|
'charactergroup' => array('admin', 'moderator', 'user')
|
||||||
// ImageMagick
|
);
|
||||||
$im = new \Imagick($upload['filename']);
|
|
||||||
|
|
||||||
// Calculate new size
|
|
||||||
$geometry = $im->getImageGeometry();
|
|
||||||
if($geometry['width'] < $width) {
|
/**
|
||||||
$width = $geometry['width'];
|
* Prefilter.
|
||||||
}
|
*
|
||||||
if($geometry['height'] < $height) {
|
* @param \nre\core\Request $request Current request
|
||||||
$height = $geometry['width'];
|
* @param \nre\core\Response $response Current response
|
||||||
}
|
*/
|
||||||
|
public function preFilter(\nre\core\Request $request, \nre\core\Response $response)
|
||||||
// Process
|
{
|
||||||
$im->thumbnailImage($width, $height, true);
|
parent::preFilter($request, $response);
|
||||||
$im->contrastImage(1);
|
|
||||||
$im->setImageFormat('jpeg');
|
// Set headers for caching control
|
||||||
|
$response->addHeader("Pragma: public");
|
||||||
// Save temporary file
|
$response->addHeader("Cache-control: public, max-age=".(60*60*24));
|
||||||
$im->writeImage($tempFileName);
|
$response->addHeader("Expires: ".gmdate('r', time()+(60*60*24)));
|
||||||
|
$response->addHeader("Date: ".gmdate(\DateTime::RFC822));
|
||||||
|
}
|
||||||
// Return resized image
|
|
||||||
return $im;
|
|
||||||
break;
|
/**
|
||||||
default:
|
* Action: seminary.
|
||||||
throw new \nre\exceptions\ParamsNotValidException('thumbnail');
|
*
|
||||||
break;
|
* Display a Seminary upload.
|
||||||
}
|
*
|
||||||
|
* @throws \nre\exceptions\AccessDeniedException
|
||||||
|
* @throws \nre\exceptions\IdNotFoundException
|
||||||
return $this->getUploadFile($upload);
|
* @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)
|
||||||
* Determine file information and set the HTTP-header for
|
{
|
||||||
* caching accordingly.
|
// Get Seminary
|
||||||
*
|
$seminary = $this->Seminaries->getSeminaryByUrl($seminaryUrl);
|
||||||
* @param string $fileName Filename
|
|
||||||
* @return boolean HTTP-status 304 was set (in cache)
|
// Get Upload
|
||||||
*/
|
$upload = $this->Uploads->getSeminaryuploadByUrl($seminary['id'], $uploadUrl);
|
||||||
private function setCacheHeaders($fileName)
|
|
||||||
{
|
// Check permissions
|
||||||
// Determine last change of file
|
if(!$upload['public'])
|
||||||
$fileLastModified = gmdate('r', filemtime($fileName));
|
{
|
||||||
|
$user = $this->Users->getUserById($this->Auth->getUserId());
|
||||||
// Generate E-Tag
|
$user['roles'] = array_map(function($r) { return $r['name']; }, $this->Userroles->getUserrolesForUserById($user['id']));
|
||||||
$fileEtag = hash('sha256', $fileLastModified.$fileName);
|
|
||||||
|
// System roles
|
||||||
|
if(count(array_intersect(array('admin', 'moderator'), $user['roles'])) == 0)
|
||||||
// Set header
|
{
|
||||||
$this->response->addHeader("Last-Modified: ".$fileLastModified);
|
// Owner of file
|
||||||
$this->response->addHeader("Etag: ".$fileEtag);
|
if($upload['created_user_id'] != $user['id'])
|
||||||
// HTTP-status
|
{
|
||||||
$headerModifiedSince = $this->request->getServerParam('HTTP_IF_MODIFIED_SINCE');
|
// Seminary permissions
|
||||||
$headerNoneMatch = $this->request->getServerParam('HTTP_IF_NONE_MATCH');
|
$characterRoles = array_map(function($r) { return $r['name']; }, $this->Characterroles->getCharacterrolesForCharacterById($character['id']));
|
||||||
if(
|
if(count(array_intersect(array('admin', 'moderator'), $characterRoles)) == 0) {
|
||||||
!is_null($headerModifiedSince) && $fileLastModified < strtotime($headerModifiedSince) &&
|
throw new \nre\exceptions\AccessDeniedException();
|
||||||
!is_null($headerNoneMatch) && $headerNoneMatch == $fileEtag
|
}
|
||||||
) {
|
}
|
||||||
$this->response->setExit(true);
|
}
|
||||||
$this->response->addHeader(\nre\core\WebUtils::getHttpHeader(304));
|
}
|
||||||
|
|
||||||
return true;
|
// Get file
|
||||||
}
|
switch($action)
|
||||||
|
{
|
||||||
|
case null:
|
||||||
return false;
|
$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
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Legend of Z
|
* The Legend of Z
|
||||||
*
|
*
|
||||||
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
||||||
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
|
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
|
||||||
* @license http://www.gnu.org/licenses/gpl.html
|
* @license http://www.gnu.org/licenses/gpl.html
|
||||||
* @link https://bitbucket.org/coderkun/the-legend-of-z
|
* @link https://bitbucket.org/coderkun/the-legend-of-z
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace hhu\z\controllers;
|
namespace hhu\z\controllers;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Controller of the Agent to display and manage userroles.
|
* Controller of the Agent to display and manage userroles.
|
||||||
*
|
*
|
||||||
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
||||||
*/
|
*/
|
||||||
class UserrolesController extends \hhu\z\Controller
|
class UserrolesController extends \hhu\z\Controller
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Action: user.
|
* Action: user.
|
||||||
*
|
*
|
||||||
* Show a user and its details.
|
* Show a user and its details.
|
||||||
*
|
*
|
||||||
* @throws \nre\exceptions\IdNotFoundException
|
* @throws \nre\exceptions\IdNotFoundException
|
||||||
* @param string $userUrl URL-Username of an user
|
* @param string $userUrl URL-Username of an user
|
||||||
*/
|
*/
|
||||||
public function user($userUrl)
|
public function user($userUrl)
|
||||||
{
|
{
|
||||||
// Get userroles
|
// Get userroles
|
||||||
$roles = $this->Userroles->getUserrolesForUserByUrl($userUrl);
|
$roles = $this->Userroles->getUserrolesForUserByUrl($userUrl);
|
||||||
|
|
||||||
|
|
||||||
// Pass data to view
|
// Pass data to view
|
||||||
$this->set('roles', $roles);
|
$this->set('roles', $roles);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load diff
|
|
@ -1,188 +1,188 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Legend of Z
|
* The Legend of Z
|
||||||
*
|
*
|
||||||
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
||||||
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
|
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
|
||||||
* @license http://www.gnu.org/licenses/gpl.html
|
* @license http://www.gnu.org/licenses/gpl.html
|
||||||
* @link https://bitbucket.org/coderkun/the-legend-of-z
|
* @link https://bitbucket.org/coderkun/the-legend-of-z
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace hhu\z\controllers;
|
namespace hhu\z\controllers;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Controller of the XplevelsAgent to handle XP-levels of a
|
* Controller of the XplevelsAgent to handle XP-levels of a
|
||||||
* Seminary.
|
* Seminary.
|
||||||
*
|
*
|
||||||
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
||||||
*/
|
*/
|
||||||
class XplevelsController extends \hhu\z\controllers\SeminaryController
|
class XplevelsController extends \hhu\z\controllers\SeminaryController
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Required components
|
* Required components
|
||||||
*
|
*
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
public $components = array('validation');
|
public $components = array('validation');
|
||||||
/**
|
/**
|
||||||
* Required models
|
* Required models
|
||||||
*
|
*
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
public $models = array('xplevels');
|
public $models = array('xplevels');
|
||||||
/**
|
/**
|
||||||
* User permissions
|
* User permissions
|
||||||
*
|
*
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
public $permissions = array(
|
public $permissions = array(
|
||||||
'manage' => array('admin', 'moderator', 'user')
|
'manage' => array('admin', 'moderator', 'user')
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Action: manage.
|
* Action: manage.
|
||||||
*
|
*
|
||||||
* Manage XP-levels.
|
* Manage XP-levels.
|
||||||
*
|
*
|
||||||
* @throws \nre\exceptions\IdNotFoundException
|
* @throws \nre\exceptions\IdNotFoundException
|
||||||
* @param string $seminaryUrl URL-Title of a Seminary
|
* @param string $seminaryUrl URL-Title of a Seminary
|
||||||
*/
|
*/
|
||||||
public function manage($seminaryUrl)
|
public function manage($seminaryUrl)
|
||||||
{
|
{
|
||||||
// Get seminary
|
// Get seminary
|
||||||
$seminary = $this->Seminaries->getSeminaryByUrl($seminaryUrl);
|
$seminary = $this->Seminaries->getSeminaryByUrl($seminaryUrl);
|
||||||
|
|
||||||
// Check permissions
|
// Check permissions
|
||||||
if(
|
if(
|
||||||
(is_null(self::$character) && count(array_intersect(array('admin', 'moderator'), \hhu\z\controllers\IntermediateController::$user['roles'])) == 0) &&
|
(is_null(self::$character) && count(array_intersect(array('admin', 'moderator'), \hhu\z\controllers\IntermediateController::$user['roles'])) == 0) &&
|
||||||
$seminary['created_user_id'] != self::$user['id']
|
$seminary['created_user_id'] != self::$user['id']
|
||||||
) {
|
) {
|
||||||
throw new \nre\exceptions\AccessDeniedException();
|
throw new \nre\exceptions\AccessDeniedException();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get XP-levels
|
// Get XP-levels
|
||||||
$xplevels = $this->Xplevels->getXPLevelsForSeminary($seminary['id']);
|
$xplevels = $this->Xplevels->getXPLevelsForSeminary($seminary['id']);
|
||||||
|
|
||||||
// Values
|
// Values
|
||||||
$xplevelsValues = array();
|
$xplevelsValues = array();
|
||||||
foreach($xplevels as &$xplevel) {
|
foreach($xplevels as &$xplevel) {
|
||||||
$xplevelsValues[$xplevel['id']] = $xplevel;
|
$xplevelsValues[$xplevel['id']] = $xplevel;
|
||||||
}
|
}
|
||||||
$deletes = array();
|
$deletes = array();
|
||||||
$validations = array(
|
$validations = array(
|
||||||
'edit' => true,
|
'edit' => true,
|
||||||
'create' => true
|
'create' => true
|
||||||
);
|
);
|
||||||
|
|
||||||
// Edit
|
// Edit
|
||||||
$action = null;
|
$action = null;
|
||||||
if($this->request->getRequestMethod() == 'POST')
|
if($this->request->getRequestMethod() == 'POST')
|
||||||
{
|
{
|
||||||
// Edit and delete XP-levels
|
// Edit and delete XP-levels
|
||||||
if(!is_null($this->request->getPostParam('edit')))
|
if(!is_null($this->request->getPostParam('edit')))
|
||||||
{
|
{
|
||||||
$action = 'edit';
|
$action = 'edit';
|
||||||
|
|
||||||
// Get params
|
// Get params
|
||||||
$xplevelsValues = $this->request->getPostParam('xplevels');
|
$xplevelsValues = $this->request->getPostParam('xplevels');
|
||||||
$deletes = $this->request->getPostParam('deletes');
|
$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
|
// Validate params
|
||||||
if($validations[$action] === true)
|
if(!is_array($deletes)) {
|
||||||
{
|
$deletes = array();
|
||||||
$this->Xplevels->createXPLevel(
|
}
|
||||||
$this->Auth->getUserId(),
|
foreach($xplevels as &$xplevel)
|
||||||
$seminary['id'],
|
{
|
||||||
$xplevelnew['xps']
|
if(array_key_exists($xplevel['id'], $deletes)) {
|
||||||
);
|
continue;
|
||||||
|
}
|
||||||
// Redirect
|
|
||||||
$this->redirect($this->linker->link(null, 3));
|
$xplevelValidation = $this->Validation->validateParams($xplevelsValues[$xplevel['id']], array('xps'));
|
||||||
}
|
if($xplevelValidation !== true)
|
||||||
}
|
{
|
||||||
}
|
if(!is_array($validations['edit'])) {
|
||||||
|
$validations['edit'] = array();
|
||||||
// Get validation settings
|
}
|
||||||
$validationSettings = array(
|
if(!array_key_exists($xplevel['id'], $validations['edit']) || !is_array($validations['edit'][$xplevel['id']])) {
|
||||||
'xps' => \nre\configs\AppConfig::$validation['xps']
|
$validations['edit'][$xplevel['id']] = array();
|
||||||
);
|
}
|
||||||
|
$validations['edit'][$xplevel['id']] = $this->Validation->addValidationResults($validations['edit'][$xplevel['id']], 'xps', $xplevelValidation);
|
||||||
|
}
|
||||||
// Set titile
|
}
|
||||||
$this->addTitleLocalized('Manage XP-levels');
|
|
||||||
$this->addTitle($seminary['title']);
|
// Edit and delete
|
||||||
|
if($validations['edit'] === true)
|
||||||
// Pass data to view
|
{
|
||||||
$this->set('seminary', $seminary);
|
foreach($xplevels as &$xplevel)
|
||||||
$this->set('xplevels', $xplevels);
|
{
|
||||||
$this->set('xplevelsValues', $xplevelsValues);
|
// Delete
|
||||||
$this->set('deletes', $deletes);
|
if(array_key_exists($xplevel['id'], $deletes)) {
|
||||||
$this->set('action', $action);
|
$this->Xplevels->deleteXPLevel($xplevel);
|
||||||
$this->set('validations', $validations);
|
}
|
||||||
$this->set('validationSettings', $validationSettings);
|
// 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
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Legend of Z
|
* The Legend of Z
|
||||||
*
|
*
|
||||||
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
||||||
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
|
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
|
||||||
* @license http://www.gnu.org/licenses/gpl.html
|
* @license http://www.gnu.org/licenses/gpl.html
|
||||||
* @link https://bitbucket.org/coderkun/the-legend-of-z
|
* @link https://bitbucket.org/coderkun/the-legend-of-z
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace hhu\z\controllers\components;
|
namespace hhu\z\controllers\components;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Component to handle achievements.
|
* Component to handle achievements.
|
||||||
*
|
*
|
||||||
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
||||||
*/
|
*/
|
||||||
class AchievementComponent extends \nre\core\Component
|
class AchievementComponent extends \nre\core\Component
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Required models
|
* Required models
|
||||||
*
|
*
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
public $models = array('achievements');
|
public $models = array('achievements');
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Construct a new Achievements-component.
|
* Construct a new Achievements-component.
|
||||||
*/
|
*/
|
||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
|
||||||
|
|
@ -1,79 +1,79 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Legend of Z
|
* The Legend of Z
|
||||||
*
|
*
|
||||||
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
||||||
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
|
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
|
||||||
* @license http://www.gnu.org/licenses/gpl.html
|
* @license http://www.gnu.org/licenses/gpl.html
|
||||||
* @link https://bitbucket.org/coderkun/the-legend-of-z
|
* @link https://bitbucket.org/coderkun/the-legend-of-z
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace hhu\z\controllers\components;
|
namespace hhu\z\controllers\components;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Component to handle authentication and authorization.
|
* Component to handle authentication and authorization.
|
||||||
*
|
*
|
||||||
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
||||||
*/
|
*/
|
||||||
class AuthComponent extends \nre\core\Component
|
class AuthComponent extends \nre\core\Component
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Key to save a user-ID as
|
* Key to save a user-ID as
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
const KEY_USER_ID = 'user_id';
|
const KEY_USER_ID = 'user_id';
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Construct a new Auth-component.
|
* Construct a new Auth-component.
|
||||||
*/
|
*/
|
||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
// Start session
|
// Start session
|
||||||
if(session_id() === '') {
|
if(session_id() === '') {
|
||||||
session_start();
|
session_start();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the ID of the user that is currently logged in.
|
* Set the ID of the user that is currently logged in.
|
||||||
*
|
*
|
||||||
* @param int $userId ID of the currently logged in user
|
* @param int $userId ID of the currently logged in user
|
||||||
*/
|
*/
|
||||||
public function setUserId($userId)
|
public function setUserId($userId)
|
||||||
{
|
{
|
||||||
if(is_null($userId)) {
|
if(is_null($userId)) {
|
||||||
unset($_SESSION[self::KEY_USER_ID]);
|
unset($_SESSION[self::KEY_USER_ID]);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$_SESSION[self::KEY_USER_ID] = $userId;
|
$_SESSION[self::KEY_USER_ID] = $userId;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the ID of the user that is currently logged in.
|
* Get the ID of the user that is currently logged in.
|
||||||
*
|
*
|
||||||
* @return int ID of the currently logged in user
|
* @return int ID of the currently logged in user
|
||||||
*/
|
*/
|
||||||
public function getUserId()
|
public function getUserId()
|
||||||
{
|
{
|
||||||
if(array_key_exists(self::KEY_USER_ID, $_SESSION)) {
|
if(array_key_exists(self::KEY_USER_ID, $_SESSION)) {
|
||||||
return $_SESSION[self::KEY_USER_ID];
|
return $_SESSION[self::KEY_USER_ID];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
|
||||||
|
|
@ -1,108 +1,108 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Legend of Z
|
* The Legend of Z
|
||||||
*
|
*
|
||||||
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
||||||
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
|
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
|
||||||
* @license http://www.gnu.org/licenses/gpl.html
|
* @license http://www.gnu.org/licenses/gpl.html
|
||||||
* @link https://bitbucket.org/coderkun/the-legend-of-z
|
* @link https://bitbucket.org/coderkun/the-legend-of-z
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace hhu\z\controllers\components;
|
namespace hhu\z\controllers\components;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Component to handle user notifications
|
* Component to handle user notifications
|
||||||
*
|
*
|
||||||
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
||||||
*/
|
*/
|
||||||
class NotificationComponent extends \nre\core\Component
|
class NotificationComponent extends \nre\core\Component
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Type: Achievement
|
* Type: Achievement
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
const TYPE_ACHIEVEMENT = 'achievement';
|
const TYPE_ACHIEVEMENT = 'achievement';
|
||||||
/**
|
/**
|
||||||
* Type: Level-up
|
* Type: Level-up
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
const TYPE_LEVELUP = 'levelup';
|
const TYPE_LEVELUP = 'levelup';
|
||||||
/**
|
/**
|
||||||
* Key for Session-Array to store notifications in
|
* Key for Session-Array to store notifications in
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
const SESSION_KEY = 'notifications';
|
const SESSION_KEY = 'notifications';
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Construct a new Notification-component.
|
* Construct a new Notification-component.
|
||||||
*/
|
*/
|
||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
// Start session
|
// Start session
|
||||||
if(session_id() === '') {
|
if(session_id() === '') {
|
||||||
session_start();
|
session_start();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Prepare array
|
// Prepare array
|
||||||
if(!array_key_exists(self::SESSION_KEY, $_SESSION)) {
|
if(!array_key_exists(self::SESSION_KEY, $_SESSION)) {
|
||||||
$_SESSION[self::SESSION_KEY] = array();
|
$_SESSION[self::SESSION_KEY] = array();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add a notification.
|
* Add a notification.
|
||||||
*
|
*
|
||||||
* @param string $type Type of notification
|
* @param string $type Type of notification
|
||||||
* @param string $message Message to display
|
* @param string $message Message to display
|
||||||
* @param string $link Optional URL to link to
|
* @param string $link Optional URL to link to
|
||||||
* @param string $image Optional URL of image to display
|
* @param string $image Optional URL of image to display
|
||||||
*/
|
*/
|
||||||
public function addNotification($type, $message, $link=null, $image=null)
|
public function addNotification($type, $message, $link=null, $image=null)
|
||||||
{
|
{
|
||||||
$_SESSION[self::SESSION_KEY][] = array(
|
$_SESSION[self::SESSION_KEY][] = array(
|
||||||
'type' => $type,
|
'type' => $type,
|
||||||
'message' => $message,
|
'message' => $message,
|
||||||
'link' => $link,
|
'link' => $link,
|
||||||
'image' => $image
|
'image' => $image
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get all registered notifiactions and clear them.
|
* Get all registered notifiactions and clear them.
|
||||||
*
|
*
|
||||||
* @return array List of existing notifications
|
* @return array List of existing notifications
|
||||||
*/
|
*/
|
||||||
public function getNotifications()
|
public function getNotifications()
|
||||||
{
|
{
|
||||||
$notifications = $_SESSION[self::SESSION_KEY];
|
$notifications = $_SESSION[self::SESSION_KEY];
|
||||||
$this->clearNotifications();
|
$this->clearNotifications();
|
||||||
|
|
||||||
|
|
||||||
return $notifications;
|
return $notifications;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Clear all notifications currently registered
|
* Clear all notifications currently registered
|
||||||
*/
|
*/
|
||||||
public function clearNotifications()
|
public function clearNotifications()
|
||||||
{
|
{
|
||||||
unset($_SESSION[self::SESSION_KEY]);
|
unset($_SESSION[self::SESSION_KEY]);
|
||||||
$_SESSION[self::SESSION_KEY] = array();
|
$_SESSION[self::SESSION_KEY] = array();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
|
||||||
|
|
@ -3,25 +3,25 @@
|
||||||
/**
|
/**
|
||||||
* The Legend of Z
|
* The Legend of Z
|
||||||
*
|
*
|
||||||
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
||||||
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
|
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
|
||||||
* @license http://www.gnu.org/licenses/gpl.html
|
* @license http://www.gnu.org/licenses/gpl.html
|
||||||
* @link https://bitbucket.org/coderkun/the-legend-of-z
|
* @link https://bitbucket.org/coderkun/the-legend-of-z
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace hhu\z\controllers\components;
|
namespace hhu\z\controllers\components;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Component to handle data for Questtypes between different Quest states.
|
* 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
|
class QuesttypedataComponent extends \nre\core\Component
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Session key
|
* Session key
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
const SESSION_KEY = 'questtypes';
|
const SESSION_KEY = 'questtypes';
|
||||||
|
|
@ -45,7 +45,7 @@
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set data with a key-value pair.
|
* Set data with a key-value pair.
|
||||||
*
|
*
|
||||||
* @param int $questId ID of Quest to set data for
|
* @param int $questId ID of Quest to set data for
|
||||||
* @param mixed $key Key
|
* @param mixed $key Key
|
||||||
* @param mixed $value Value
|
* @param mixed $value Value
|
||||||
|
|
@ -64,7 +64,7 @@
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get data by a key.
|
* Get data by a key.
|
||||||
*
|
*
|
||||||
* @param int $questId ID of Quest to set data for
|
* @param int $questId ID of Quest to set data for
|
||||||
* @param mixed $key Key
|
* @param mixed $key Key
|
||||||
* @return mixed Value
|
* @return mixed Value
|
||||||
|
|
@ -86,4 +86,4 @@
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
|
||||||
|
|
@ -1,183 +1,183 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Legend of Z
|
* The Legend of Z
|
||||||
*
|
*
|
||||||
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
||||||
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
|
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
|
||||||
* @license http://www.gnu.org/licenses/gpl.html
|
* @license http://www.gnu.org/licenses/gpl.html
|
||||||
* @link https://bitbucket.org/coderkun/the-legend-of-z
|
* @link https://bitbucket.org/coderkun/the-legend-of-z
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace hhu\z\controllers\components;
|
namespace hhu\z\controllers\components;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Component to validate user input.
|
* Component to validate user input.
|
||||||
*
|
*
|
||||||
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
||||||
*/
|
*/
|
||||||
class ValidationComponent extends \nre\core\Component
|
class ValidationComponent extends \nre\core\Component
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Validation settings
|
* Validation settings
|
||||||
*
|
*
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
private $config;
|
private $config;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Construct a new Validation-component.
|
* Construct a new Validation-component.
|
||||||
*/
|
*/
|
||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
// Get validation settings from configuration
|
// Get validation settings from configuration
|
||||||
$this->config = \nre\configs\AppConfig::$validation;
|
$this->config = \nre\configs\AppConfig::$validation;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Validate an user input.
|
* Validate an user input.
|
||||||
*
|
*
|
||||||
* @param mixed $input User input to validate
|
* @param mixed $input User input to validate
|
||||||
* @param array $settings Validation setting
|
* @param array $settings Validation setting
|
||||||
* @return mixed True or the settings the validation fails on
|
* @return mixed True or the settings the validation fails on
|
||||||
*/
|
*/
|
||||||
public function validate($input, $settings)
|
public function validate($input, $settings)
|
||||||
{
|
{
|
||||||
$validation = array();
|
$validation = array();
|
||||||
|
|
||||||
// Min string length
|
// Min string length
|
||||||
if(array_key_exists('minlength', $settings) && strlen($input) < $settings['minlength']) {
|
if(array_key_exists('minlength', $settings) && strlen($input) < $settings['minlength']) {
|
||||||
$validation['minlength'] = $settings['minlength'];
|
$validation['minlength'] = $settings['minlength'];
|
||||||
}
|
}
|
||||||
// Max string length
|
// Max string length
|
||||||
if(array_key_exists('maxlength', $settings) && strlen($input) > $settings['maxlength']) {
|
if(array_key_exists('maxlength', $settings) && strlen($input) > $settings['maxlength']) {
|
||||||
$validation['maxlength'] = $settings['maxlength'];
|
$validation['maxlength'] = $settings['maxlength'];
|
||||||
}
|
}
|
||||||
|
|
||||||
// Regex
|
// Regex
|
||||||
if(array_key_exists('regex', $settings) && !preg_match($settings['regex'], $input)) {
|
if(array_key_exists('regex', $settings) && !preg_match($settings['regex'], $input)) {
|
||||||
$validation['regex'] = $settings['regex'];
|
$validation['regex'] = $settings['regex'];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Return true or the failed fields
|
// Return true or the failed fields
|
||||||
if(empty($validation)) {
|
if(empty($validation)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return $validation;
|
return $validation;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Validate an user input parameter.
|
* Validate an user input parameter.
|
||||||
*
|
*
|
||||||
* @param array $params User input parameters
|
* @param array $params User input parameters
|
||||||
* @param array $index Names of parameter to validate and to validate against
|
* @param array $index Names of parameter to validate and to validate against
|
||||||
* @return mixed True or the parameter with settings the validation failed on
|
* @return mixed True or the parameter with settings the validation failed on
|
||||||
*/
|
*/
|
||||||
public function validateParam($params, $index)
|
public function validateParam($params, $index)
|
||||||
{
|
{
|
||||||
// Check parameter
|
// Check parameter
|
||||||
if(!array_key_exists($index, $params)) {
|
if(!array_key_exists($index, $params)) {
|
||||||
throw new \nre\exceptions\ParamsNotValidException($index);
|
throw new \nre\exceptions\ParamsNotValidException($index);
|
||||||
}
|
}
|
||||||
// Check settings
|
// Check settings
|
||||||
if(!array_key_exists($index, $this->config)) {
|
if(!array_key_exists($index, $this->config)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Validate parameter and return result
|
// Validate parameter and return result
|
||||||
return $this->validate($params[$index], $this->config[$index]);
|
return $this->validate($params[$index], $this->config[$index]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Validate user input parameters.
|
* Validate user input parameters.
|
||||||
*
|
*
|
||||||
* @param array $params User input parameters
|
* @param array $params User input parameters
|
||||||
* @param array $indices Names of parameters to validate and to validate against
|
* @param array $indices Names of parameters to validate and to validate against
|
||||||
* @return mixed True or the parameters with settings the validation failed on
|
* @return mixed True or the parameters with settings the validation failed on
|
||||||
*/
|
*/
|
||||||
public function validateParams($params, $indices)
|
public function validateParams($params, $indices)
|
||||||
{
|
{
|
||||||
// Validate parameters
|
// Validate parameters
|
||||||
$validation = true;
|
$validation = true;
|
||||||
foreach($indices as $index) {
|
foreach($indices as $index) {
|
||||||
$validation = $this->addValidationResults($validation, $index, $this->validateParam($params, $index));
|
$validation = $this->addValidationResults($validation, $index, $this->validateParam($params, $index));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Return validation results
|
// Return validation results
|
||||||
return $validation;
|
return $validation;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add a custom determined validation result to a validation
|
* Add a custom determined validation result to a validation
|
||||||
* array.
|
* array.
|
||||||
*
|
*
|
||||||
* @param mixed $validation Validation array to add result to
|
* @param mixed $validation Validation array to add result to
|
||||||
* @param string $index Name of parameter of the custom validation result
|
* @param string $index Name of parameter of the custom validation result
|
||||||
* @param string $setting Name of setting of the custom validation result
|
* @param string $setting Name of setting of the custom validation result
|
||||||
* @param mixed $result Validation result
|
* @param mixed $result Validation result
|
||||||
* @return mixed The altered validation array
|
* @return mixed The altered validation array
|
||||||
*/
|
*/
|
||||||
public function addValidationResult($validation, $index, $setting, $result)
|
public function addValidationResult($validation, $index, $setting, $result)
|
||||||
{
|
{
|
||||||
// Create validation array
|
// Create validation array
|
||||||
if(!is_array($validation)) {
|
if(!is_array($validation)) {
|
||||||
$validation = array();
|
$validation = array();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add validation results
|
// Add validation results
|
||||||
if(!array_key_exists($index, $validation)) {
|
if(!array_key_exists($index, $validation)) {
|
||||||
$validation[$index] = array();
|
$validation[$index] = array();
|
||||||
}
|
}
|
||||||
$validation[$index][$setting] = $result;
|
$validation[$index][$setting] = $result;
|
||||||
|
|
||||||
|
|
||||||
// Return new validation result
|
// Return new validation result
|
||||||
return $validation;
|
return $validation;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add custom determined validation results to a validation
|
* Add custom determined validation results to a validation
|
||||||
* arary.
|
* arary.
|
||||||
*
|
*
|
||||||
* @param mixed $validation Validation array to add result to
|
* @param mixed $validation Validation array to add result to
|
||||||
* @param string $index Name of parameter of the custom validation result
|
* @param string $index Name of parameter of the custom validation result
|
||||||
* @param mixed $result Validation result
|
* @param mixed $result Validation result
|
||||||
* @return mixed The altered validation array
|
* @return mixed The altered validation array
|
||||||
*/
|
*/
|
||||||
public function addValidationResults($validation, $index, $results)
|
public function addValidationResults($validation, $index, $results)
|
||||||
{
|
{
|
||||||
// Create validation array
|
// Create validation array
|
||||||
if(!is_array($validation)) {
|
if(!is_array($validation)) {
|
||||||
$validation = array();
|
$validation = array();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add validation results
|
// Add validation results
|
||||||
if($results !== true) {
|
if($results !== true) {
|
||||||
$validation[$index] = $results;
|
$validation[$index] = $results;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Return new validation result
|
// Return new validation result
|
||||||
if(empty($validation)) {
|
if(empty($validation)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return $validation;
|
return $validation;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load diff
|
|
@ -1,182 +1,182 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Legend of Z
|
* The Legend of Z
|
||||||
*
|
*
|
||||||
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
||||||
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
|
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
|
||||||
* @license http://www.gnu.org/licenses/gpl.html
|
* @license http://www.gnu.org/licenses/gpl.html
|
||||||
* @link https://bitbucket.org/coderkun/the-legend-of-z
|
* @link https://bitbucket.org/coderkun/the-legend-of-z
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace hhu\z\models;
|
namespace hhu\z\models;
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Model to interact with Avatars-tables.
|
|
||||||
*
|
|
||||||
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
|
||||||
*/
|
|
||||||
class AvatarsModel extends \hhu\z\Model
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* Required models
|
|
||||||
*
|
|
||||||
* @var array
|
|
||||||
*/
|
|
||||||
public $models = array('media');
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Construct a new AvatarsModel.
|
|
||||||
*/
|
|
||||||
public function __construct()
|
|
||||||
{
|
|
||||||
parent::__construct();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get an Avatar by its ID
|
|
||||||
*
|
|
||||||
* @param int $avatarId ID of Avatar
|
|
||||||
* @return array Avatar data
|
|
||||||
*/
|
|
||||||
public function getAvatarById($avatarId)
|
|
||||||
{
|
|
||||||
$data = $this->db->query(
|
|
||||||
'SELECT id, charactertype_id, xplevel_id, avatarpicture_id, small_avatarpicture_id '.
|
|
||||||
'FROM avatars '.
|
|
||||||
'WHERE id = ?',
|
|
||||||
'i',
|
|
||||||
$avatarId
|
|
||||||
);
|
|
||||||
if(!empty($data)) {
|
|
||||||
return $data[0];
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get an Avatar by its Character type and XP-level.
|
|
||||||
*
|
|
||||||
* @param int $seminaryId ID of Seminary
|
|
||||||
* @param string $charactertypeUrl URL-title of Character type
|
|
||||||
* @param int $xplevel XP-level
|
|
||||||
* @return array Avatar data
|
|
||||||
*/
|
|
||||||
public function getAvatarByTypeAndLevel($seminaryId, $charactertypeUrl, $xplevel)
|
|
||||||
{
|
|
||||||
$data = $this->db->query(
|
|
||||||
'SELECT avatars.id, charactertype_id, xplevel_id, avatarpicture_id, small_avatarpicture_id '.
|
|
||||||
'FROM avatars '.
|
|
||||||
'INNER JOIN charactertypes ON charactertypes.id = avatars.charactertype_id '.
|
|
||||||
'INNER JOIN xplevels ON xplevels.id = avatars.xplevel_id AND xplevels.seminary_id = charactertypes.seminary_id '.
|
|
||||||
'WHERE charactertypes.seminary_id = ? AND charactertypes.url = ? AND xplevels.level = ?',
|
|
||||||
'isi',
|
|
||||||
$seminaryId,
|
|
||||||
$charactertypeUrl,
|
|
||||||
$xplevel
|
|
||||||
);
|
|
||||||
if(empty($data)) {
|
|
||||||
throw new \nre\exceptions\IdNotFoundException($charactertypeUrl);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
return $data[0];
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get an Avatar by its Character type and XP-level.
|
* Model to interact with Avatars-tables.
|
||||||
*
|
*
|
||||||
* @param int $charactertypeId ID of Character type
|
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
||||||
* @param int $xplevelId ID of XP-level
|
*/
|
||||||
* @return array Avatar data
|
class AvatarsModel extends \hhu\z\Model
|
||||||
*/
|
{
|
||||||
public function getAvatarByTypeAndLevelId($charactertypeId, $xplevelId)
|
/**
|
||||||
{
|
* Required models
|
||||||
$data = $this->db->query(
|
*
|
||||||
'SELECT id, charactertype_id, xplevel_id, avatarpicture_id, small_avatarpicture_id '.
|
* @var array
|
||||||
'FROM avatars '.
|
*/
|
||||||
'WHERE charactertype_id = ? AND xplevel_id = ?',
|
public $models = array('media');
|
||||||
'ii',
|
|
||||||
$charactertypeId,
|
|
||||||
$xplevelId
|
|
||||||
);
|
|
||||||
if(empty($data)) {
|
|
||||||
throw new \nre\exceptions\IdNotFoundException($charactertypeId.'-'.$xplevelId);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
return $data[0];
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set the picture for an Avatar.
|
|
||||||
*
|
|
||||||
* @param int $userId ID of creating user
|
|
||||||
* @param int $charactertypeId ID of Charactertype of Avatar
|
|
||||||
* @param int $xplevelId ID of XP-level of Avatar
|
|
||||||
* @param int $avatarpictureId ID of Avatar picture to set
|
|
||||||
*/
|
|
||||||
public function setAvatarForTypeAndLevel($userId, $charactertypeId, $xplevelId, $avatarpictureId)
|
|
||||||
{
|
|
||||||
$this->db->query(
|
|
||||||
'INSERT INTO avatars '.
|
|
||||||
'(created_user_id, charactertype_id, xplevel_id, avatarpicture_id) '.
|
|
||||||
'VALUES '.
|
|
||||||
'(?, ?, ?, ?) '.
|
|
||||||
'ON DUPLICATE KEY UPDATE '.
|
|
||||||
'avatarpicture_id = ?',
|
|
||||||
'iiiii',
|
|
||||||
$userId,
|
|
||||||
$charactertypeId,
|
|
||||||
$xplevelId,
|
|
||||||
$avatarpictureId,
|
|
||||||
$avatarpictureId
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the portrait picture for an Avatar.
|
* Construct a new AvatarsModel.
|
||||||
*
|
*/
|
||||||
* @param int $userId ID of creating user
|
public function __construct()
|
||||||
* @param int $charactertypeId ID of Charactertype of Avatar
|
{
|
||||||
* @param int $xplevelId ID of XP-level of Avatar
|
parent::__construct();
|
||||||
* @param int $avatarpictureId ID of Avatar portrait picture to set
|
}
|
||||||
*/
|
|
||||||
public function setAvatarPortraitForTypeAndLevel($userId, $charactertypeId, $xplevelId, $avatarpictureId)
|
|
||||||
{
|
|
||||||
$this->db->query(
|
|
||||||
'INSERT INTO avatars '.
|
/**
|
||||||
'(created_user_id, charactertype_id, xplevel_id, small_avatarpicture_id) '.
|
* Get an Avatar by its ID
|
||||||
'VALUES '.
|
*
|
||||||
'(?, ?, ?, ?) '.
|
* @param int $avatarId ID of Avatar
|
||||||
'ON DUPLICATE KEY UPDATE '.
|
* @return array Avatar data
|
||||||
'small_avatarpicture_id = ?',
|
*/
|
||||||
'iiiii',
|
public function getAvatarById($avatarId)
|
||||||
$userId,
|
{
|
||||||
$charactertypeId,
|
$data = $this->db->query(
|
||||||
$xplevelId,
|
'SELECT id, charactertype_id, xplevel_id, avatarpicture_id, small_avatarpicture_id '.
|
||||||
$avatarpictureId,
|
'FROM avatars '.
|
||||||
$avatarpictureId
|
'WHERE id = ?',
|
||||||
);
|
'i',
|
||||||
}
|
$avatarId
|
||||||
|
);
|
||||||
|
if(!empty($data)) {
|
||||||
|
return $data[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get an Avatar by its Character type and XP-level.
|
||||||
|
*
|
||||||
|
* @param int $seminaryId ID of Seminary
|
||||||
|
* @param string $charactertypeUrl URL-title of Character type
|
||||||
|
* @param int $xplevel XP-level
|
||||||
|
* @return array Avatar data
|
||||||
|
*/
|
||||||
|
public function getAvatarByTypeAndLevel($seminaryId, $charactertypeUrl, $xplevel)
|
||||||
|
{
|
||||||
|
$data = $this->db->query(
|
||||||
|
'SELECT avatars.id, charactertype_id, xplevel_id, avatarpicture_id, small_avatarpicture_id '.
|
||||||
|
'FROM avatars '.
|
||||||
|
'INNER JOIN charactertypes ON charactertypes.id = avatars.charactertype_id '.
|
||||||
|
'INNER JOIN xplevels ON xplevels.id = avatars.xplevel_id AND xplevels.seminary_id = charactertypes.seminary_id '.
|
||||||
|
'WHERE charactertypes.seminary_id = ? AND charactertypes.url = ? AND xplevels.level = ?',
|
||||||
|
'isi',
|
||||||
|
$seminaryId,
|
||||||
|
$charactertypeUrl,
|
||||||
|
$xplevel
|
||||||
|
);
|
||||||
|
if(empty($data)) {
|
||||||
|
throw new \nre\exceptions\IdNotFoundException($charactertypeUrl);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
return $data[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get an Avatar by its Character type and XP-level.
|
||||||
|
*
|
||||||
|
* @param int $charactertypeId ID of Character type
|
||||||
|
* @param int $xplevelId ID of XP-level
|
||||||
|
* @return array Avatar data
|
||||||
|
*/
|
||||||
|
public function getAvatarByTypeAndLevelId($charactertypeId, $xplevelId)
|
||||||
|
{
|
||||||
|
$data = $this->db->query(
|
||||||
|
'SELECT id, charactertype_id, xplevel_id, avatarpicture_id, small_avatarpicture_id '.
|
||||||
|
'FROM avatars '.
|
||||||
|
'WHERE charactertype_id = ? AND xplevel_id = ?',
|
||||||
|
'ii',
|
||||||
|
$charactertypeId,
|
||||||
|
$xplevelId
|
||||||
|
);
|
||||||
|
if(empty($data)) {
|
||||||
|
throw new \nre\exceptions\IdNotFoundException($charactertypeId.'-'.$xplevelId);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
return $data[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the picture for an Avatar.
|
||||||
|
*
|
||||||
|
* @param int $userId ID of creating user
|
||||||
|
* @param int $charactertypeId ID of Charactertype of Avatar
|
||||||
|
* @param int $xplevelId ID of XP-level of Avatar
|
||||||
|
* @param int $avatarpictureId ID of Avatar picture to set
|
||||||
|
*/
|
||||||
|
public function setAvatarForTypeAndLevel($userId, $charactertypeId, $xplevelId, $avatarpictureId)
|
||||||
|
{
|
||||||
|
$this->db->query(
|
||||||
|
'INSERT INTO avatars '.
|
||||||
|
'(created_user_id, charactertype_id, xplevel_id, avatarpicture_id) '.
|
||||||
|
'VALUES '.
|
||||||
|
'(?, ?, ?, ?) '.
|
||||||
|
'ON DUPLICATE KEY UPDATE '.
|
||||||
|
'avatarpicture_id = ?',
|
||||||
|
'iiiii',
|
||||||
|
$userId,
|
||||||
|
$charactertypeId,
|
||||||
|
$xplevelId,
|
||||||
|
$avatarpictureId,
|
||||||
|
$avatarpictureId
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the portrait picture for an Avatar.
|
||||||
|
*
|
||||||
|
* @param int $userId ID of creating user
|
||||||
|
* @param int $charactertypeId ID of Charactertype of Avatar
|
||||||
|
* @param int $xplevelId ID of XP-level of Avatar
|
||||||
|
* @param int $avatarpictureId ID of Avatar portrait picture to set
|
||||||
|
*/
|
||||||
|
public function setAvatarPortraitForTypeAndLevel($userId, $charactertypeId, $xplevelId, $avatarpictureId)
|
||||||
|
{
|
||||||
|
$this->db->query(
|
||||||
|
'INSERT INTO avatars '.
|
||||||
|
'(created_user_id, charactertype_id, xplevel_id, small_avatarpicture_id) '.
|
||||||
|
'VALUES '.
|
||||||
|
'(?, ?, ?, ?) '.
|
||||||
|
'ON DUPLICATE KEY UPDATE '.
|
||||||
|
'small_avatarpicture_id = ?',
|
||||||
|
'iiiii',
|
||||||
|
$userId,
|
||||||
|
$charactertypeId,
|
||||||
|
$xplevelId,
|
||||||
|
$avatarpictureId,
|
||||||
|
$avatarpictureId
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Copy all Avatars from a Seminary.
|
* Copy all Avatars from a Seminary.
|
||||||
*
|
*
|
||||||
* @param int $userId ID of copying user
|
* @param int $userId ID of copying user
|
||||||
* @param array $charactertypeIds Mapping of Charactertype-IDs from source Seminary to target Seminary
|
* @param array $charactertypeIds Mapping of Charactertype-IDs from source Seminary to target Seminary
|
||||||
* @param array $xplevelIds Mapping of XP-level-IDs from source Seminary to targetSeminary
|
* @param array $xplevelIds Mapping of XP-level-IDs from source Seminary to targetSeminary
|
||||||
|
|
@ -217,7 +217,7 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load diff
|
|
@ -1,383 +1,383 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Legend of Z
|
* The Legend of Z
|
||||||
*
|
*
|
||||||
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
||||||
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
|
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
|
||||||
* @license http://www.gnu.org/licenses/gpl.html
|
* @license http://www.gnu.org/licenses/gpl.html
|
||||||
* @link https://bitbucket.org/coderkun/the-legend-of-z
|
* @link https://bitbucket.org/coderkun/the-legend-of-z
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace hhu\z\models;
|
namespace hhu\z\models;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Model of the CharactergroupsquestsAgent to interact with
|
* Model of the CharactergroupsquestsAgent to interact with
|
||||||
* Charactergroupsquests-table.
|
* Charactergroupsquests-table.
|
||||||
*
|
*
|
||||||
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
|
||||||
*/
|
*/
|
||||||
class CharactergroupsquestsModel extends \hhu\z\Model
|
class CharactergroupsquestsModel extends \hhu\z\Model
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Required models
|
* Required models
|
||||||
*
|
*
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
public $models = array('uploads', 'media');
|
public $models = array('uploads', 'media');
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Construct a new CharactergroupsquestsModel.
|
* Construct a new CharactergroupsquestsModel.
|
||||||
*/
|
*/
|
||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
parent::__construct();
|
parent::__construct();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get Character groups Quests of a Character groups-groups.
|
* Get Character groups Quests of a Character groups-groups.
|
||||||
*
|
*
|
||||||
* @param int $groupsgroupId ID of the Character groups-group
|
* @param int $groupsgroupId ID of the Character groups-group
|
||||||
* @return array Character groups Quest data
|
* @return array Character groups Quest data
|
||||||
*/
|
*/
|
||||||
public function getQuestsForCharactergroupsgroup($groupsgroupId)
|
public function getQuestsForCharactergroupsgroup($groupsgroupId)
|
||||||
{
|
{
|
||||||
return $this->db->query(
|
return $this->db->query(
|
||||||
'SELECT id, questgroups_id, title, url, xps, questsmedia_id '.
|
'SELECT id, questgroups_id, title, url, xps, questsmedia_id '.
|
||||||
'FROM charactergroupsquests '.
|
'FROM charactergroupsquests '.
|
||||||
'WHERE charactergroupsgroup_id = ? '.
|
'WHERE charactergroupsgroup_id = ? '.
|
||||||
'ORDER BY created ASC',
|
'ORDER BY created ASC',
|
||||||
'i',
|
'i',
|
||||||
$groupsgroupId
|
$groupsgroupId
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get a Character groups Quest by its URL.
|
* Get a Character groups Quest by its URL.
|
||||||
*
|
*
|
||||||
* @throws \nre\exceptions\IdNotFoundException
|
* @throws \nre\exceptions\IdNotFoundException
|
||||||
* @param int $groupsgroupId ID of the Character groups-group
|
* @param int $groupsgroupId ID of the Character groups-group
|
||||||
* @param string $questUrl URL-title of the Character groups Quest
|
* @param string $questUrl URL-title of the Character groups Quest
|
||||||
* @return array Character groups Quest data
|
* @return array Character groups Quest data
|
||||||
*/
|
*/
|
||||||
public function getQuestByUrl($groupsgroupId, $questUrl)
|
public function getQuestByUrl($groupsgroupId, $questUrl)
|
||||||
{
|
{
|
||||||
$data = $this->db->query(
|
$data = $this->db->query(
|
||||||
'SELECT id, questgroups_id, title, url, description, xps, rules, won_text, lost_text, questsmedia_id '.
|
'SELECT id, questgroups_id, title, url, description, xps, rules, won_text, lost_text, questsmedia_id '.
|
||||||
'FROM charactergroupsquests '.
|
'FROM charactergroupsquests '.
|
||||||
'WHERE charactergroupsgroup_id = ? AND url = ?',
|
'WHERE charactergroupsgroup_id = ? AND url = ?',
|
||||||
'is',
|
'is',
|
||||||
$groupsgroupId,
|
$groupsgroupId,
|
||||||
$questUrl
|
$questUrl
|
||||||
);
|
);
|
||||||
if(empty($data)) {
|
if(empty($data)) {
|
||||||
throw new \nre\exceptions\IdNotFoundException($questUrl);
|
throw new \nre\exceptions\IdNotFoundException($questUrl);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return $data[0];
|
return $data[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get a Character groups Quest by its ID.
|
* Get a Character groups Quest by its ID.
|
||||||
*
|
*
|
||||||
* @throws \nre\exceptions\IdNotFoundException
|
* @throws \nre\exceptions\IdNotFoundException
|
||||||
* @param int $questId ID of the Character groups Quest
|
* @param int $questId ID of the Character groups Quest
|
||||||
* @return array Character groups Quest data
|
* @return array Character groups Quest data
|
||||||
*/
|
*/
|
||||||
public function getQuestById($questId)
|
public function getQuestById($questId)
|
||||||
{
|
{
|
||||||
$data = $this->db->query(
|
$data = $this->db->query(
|
||||||
'SELECT id, questgroups_id, title, url, description, xps, rules, won_text, lost_text, questsmedia_id '.
|
'SELECT id, questgroups_id, title, url, description, xps, rules, won_text, lost_text, questsmedia_id '.
|
||||||
'FROM charactergroupsquests '.
|
'FROM charactergroupsquests '.
|
||||||
'WHERE id = ?',
|
'WHERE id = ?',
|
||||||
'i',
|
'i',
|
||||||
$questId
|
$questId
|
||||||
);
|
);
|
||||||
if(empty($data)) {
|
if(empty($data)) {
|
||||||
throw new \nre\exceptions\IdNotFoundException($questUrl);
|
throw new \nre\exceptions\IdNotFoundException($questUrl);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return $data[0];
|
return $data[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get Character groups Quests for a Character group.
|
* Get Character groups Quests for a Character group.
|
||||||
*
|
*
|
||||||
* @param int $groupId ID of the Character group
|
* @param int $groupId ID of the Character group
|
||||||
* @return array Character groups Quests
|
* @return array Character groups Quests
|
||||||
*/
|
*/
|
||||||
public function getQuestsForGroup($groupId)
|
public function getQuestsForGroup($groupId)
|
||||||
{
|
{
|
||||||
$quests = $this->db->query(
|
$quests = $this->db->query(
|
||||||
'SELECT charactergroupsquests.id, charactergroupsquests_groups.created, charactergroupsquests.title, charactergroupsquests.url, charactergroupsquests.xps, charactergroupsquests_groups.xps_factor '.
|
'SELECT charactergroupsquests.id, charactergroupsquests_groups.created, charactergroupsquests.title, charactergroupsquests.url, charactergroupsquests.xps, charactergroupsquests_groups.xps_factor '.
|
||||||
'FROM charactergroupsquests_groups '.
|
'FROM charactergroupsquests_groups '.
|
||||||
'LEFT JOIN charactergroupsquests ON charactergroupsquests.id = charactergroupsquests_groups.charactergroupsquest_id '.
|
'LEFT JOIN charactergroupsquests ON charactergroupsquests.id = charactergroupsquests_groups.charactergroupsquest_id '.
|
||||||
'WHERE charactergroupsquests_groups.charactergroup_id = ? '.
|
'WHERE charactergroupsquests_groups.charactergroup_id = ? '.
|
||||||
'ORDER BY charactergroupsquests.created ASC',
|
'ORDER BY charactergroupsquests.created ASC',
|
||||||
'i',
|
'i',
|
||||||
$groupId
|
$groupId
|
||||||
);
|
);
|
||||||
foreach($quests as &$quest) {
|
foreach($quests as &$quest) {
|
||||||
$quest['group_xps'] = round($quest['xps'] * $quest['xps_factor'], 1);
|
$quest['group_xps'] = round($quest['xps'] * $quest['xps_factor'], 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return $quests;
|
return $quests;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get XPs of a Character group for a Character groups Quest.
|
* Get XPs of a Character group for a Character groups Quest.
|
||||||
*
|
*
|
||||||
* @param int $questId ID of Character groups Quest
|
* @param int $questId ID of Character groups Quest
|
||||||
* @param int $groupId ID of Character group to get XPs of
|
* @param int $groupId ID of Character group to get XPs of
|
||||||
* @return array XP-record
|
* @return array XP-record
|
||||||
*/
|
*/
|
||||||
public function getXPsOfGroupForQuest($questId, $groupId)
|
public function getXPsOfGroupForQuest($questId, $groupId)
|
||||||
{
|
{
|
||||||
$data = $this->db->query(
|
$data = $this->db->query(
|
||||||
'SELECT charactergroupsquests_groups.created, charactergroupsquests_groups.xps_factor, charactergroupsquests.xps '.
|
'SELECT charactergroupsquests_groups.created, charactergroupsquests_groups.xps_factor, charactergroupsquests.xps '.
|
||||||
'FROM charactergroupsquests_groups '.
|
'FROM charactergroupsquests_groups '.
|
||||||
'LEFT JOIN charactergroupsquests ON charactergroupsquests.id = charactergroupsquests_groups.charactergroupsquest_id '.
|
'LEFT JOIN charactergroupsquests ON charactergroupsquests.id = charactergroupsquests_groups.charactergroupsquest_id '.
|
||||||
'WHERE charactergroupsquests_groups.charactergroupsquest_id = ? AND charactergroupsquests_groups.charactergroup_id = ?',
|
'WHERE charactergroupsquests_groups.charactergroupsquest_id = ? AND charactergroupsquests_groups.charactergroup_id = ?',
|
||||||
'ii',
|
'ii',
|
||||||
$questId,
|
$questId,
|
||||||
$groupId
|
$groupId
|
||||||
);
|
);
|
||||||
if(empty($data)) {
|
if(empty($data)) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
$data = $data[0];
|
$data = $data[0];
|
||||||
$data['xps'] = round($data['xps'] * $data['xps_factor'], 1);
|
$data['xps'] = round($data['xps'] * $data['xps_factor'], 1);
|
||||||
|
|
||||||
|
|
||||||
return $data;
|
return $data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set XPs of a Character group for a Character groups Quest.
|
* Set XPs of a Character group for a Character groups Quest.
|
||||||
*
|
*
|
||||||
* @param int $questId ID of Character groups Quest
|
* @param int $questId ID of Character groups Quest
|
||||||
* @param int $groupId ID of Character group to set XPs of
|
* @param int $groupId ID of Character group to set XPs of
|
||||||
* @param float $xpsFactor XPs-factor
|
* @param float $xpsFactor XPs-factor
|
||||||
*/
|
*/
|
||||||
public function setXPsOfGroupForQuest($questId, $groupId, $xpsFactor)
|
public function setXPsOfGroupForQuest($questId, $groupId, $xpsFactor)
|
||||||
{
|
{
|
||||||
$this->db->query(
|
$this->db->query(
|
||||||
'INSERT INTO charactergroupsquests_groups '.
|
'INSERT INTO charactergroupsquests_groups '.
|
||||||
'(charactergroupsquest_id, charactergroup_id, xps_factor) '.
|
'(charactergroupsquest_id, charactergroup_id, xps_factor) '.
|
||||||
'VALUES '.
|
'VALUES '.
|
||||||
'(?, ?, ?) '.
|
'(?, ?, ?) '.
|
||||||
'ON DUPLICATE KEY UPDATE '.
|
'ON DUPLICATE KEY UPDATE '.
|
||||||
'xps_factor = ?',
|
'xps_factor = ?',
|
||||||
'iidd',
|
'iidd',
|
||||||
$questId,
|
$questId,
|
||||||
$groupId,
|
$groupId,
|
||||||
$xpsFactor,
|
$xpsFactor,
|
||||||
$xpsFactor
|
$xpsFactor
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Remove a Character group from a Character groups Quest.
|
* Remove a Character group from a Character groups Quest.
|
||||||
*
|
*
|
||||||
* @param int $questId ID of Character groups Quest
|
* @param int $questId ID of Character groups Quest
|
||||||
* @param int $groupId ID of Character group to remove
|
* @param int $groupId ID of Character group to remove
|
||||||
*/
|
*/
|
||||||
public function deleteGroupForQuest($questId, $groupId)
|
public function deleteGroupForQuest($questId, $groupId)
|
||||||
{
|
{
|
||||||
$this->db->query(
|
$this->db->query(
|
||||||
'DELETE FROM charactergroupsquests_groups '.
|
'DELETE FROM charactergroupsquests_groups '.
|
||||||
'WHERE charactergroupsquest_id = ? AND charactergroup_id = ?',
|
'WHERE charactergroupsquest_id = ? AND charactergroup_id = ?',
|
||||||
'ii',
|
'ii',
|
||||||
$questId, $groupId
|
$questId, $groupId
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if a Character groups Quest title already exists.
|
* Check if a Character groups Quest title already exists.
|
||||||
*
|
*
|
||||||
* @param string $name Character groups Quest title to check
|
* @param string $name Character groups Quest title to check
|
||||||
* @param int $questId Do not check this ID (for editing)
|
* @param int $questId Do not check this ID (for editing)
|
||||||
* @return boolean Whether Character groups Quest title exists or not
|
* @return boolean Whether Character groups Quest title exists or not
|
||||||
*/
|
*/
|
||||||
public function characterGroupsQuestTitleExists($title, $questId=null)
|
public function characterGroupsQuestTitleExists($title, $questId=null)
|
||||||
{
|
{
|
||||||
$data = $this->db->query(
|
$data = $this->db->query(
|
||||||
'SELECT id '.
|
'SELECT id '.
|
||||||
'FROM charactergroupsquests '.
|
'FROM charactergroupsquests '.
|
||||||
'WHERE title = ? OR url = ?',
|
'WHERE title = ? OR url = ?',
|
||||||
'ss',
|
'ss',
|
||||||
$title,
|
$title,
|
||||||
\nre\core\Linker::createLinkParam($title)
|
\nre\core\Linker::createLinkParam($title)
|
||||||
);
|
);
|
||||||
|
|
||||||
return (!empty($data) && (is_null($questId) || $questId != $data[0]['id']));
|
return (!empty($data) && (is_null($questId) || $questId != $data[0]['id']));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the media for a Character groups Quest.
|
* Set the media for a Character groups Quest.
|
||||||
*
|
*
|
||||||
* @param int $questId ID of Quest to upload media for
|
* @param int $questId ID of Quest to upload media for
|
||||||
* @param int $mediaId ID of Quests media
|
* @param int $mediaId ID of Quests media
|
||||||
*/
|
*/
|
||||||
public function setMediaForQuest($questId, $mediaId)
|
public function setMediaForQuest($questId, $mediaId)
|
||||||
{
|
{
|
||||||
$this->db->query(
|
$this->db->query(
|
||||||
'UPDATE charactergroupsquests '.
|
'UPDATE charactergroupsquests '.
|
||||||
'SET questsmedia_id = ? '.
|
'SET questsmedia_id = ? '.
|
||||||
'WHERE id = ?',
|
'WHERE id = ?',
|
||||||
'ii',
|
'ii',
|
||||||
$mediaId,
|
$mediaId,
|
||||||
$questId
|
$questId
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Upload a media for a Character groups Quest.
|
* Upload a media for a Character groups Quest.
|
||||||
*
|
*
|
||||||
* @param int $userId ID of user that does the upload
|
* @param int $userId ID of user that does the upload
|
||||||
* @param int $seminaryId ID of Seminary
|
* @param int $seminaryId ID of Seminary
|
||||||
* @param int $questId ID of Quest to upload media for
|
* @param int $questId ID of Quest to upload media for
|
||||||
* @param array $file File-array of file to upload
|
* @param array $file File-array of file to upload
|
||||||
* @param string $filename Filename for media
|
* @param string $filename Filename for media
|
||||||
* @return boolean Whether upload succeeded or not
|
* @return boolean Whether upload succeeded or not
|
||||||
*/
|
*/
|
||||||
public function uploadMediaForQuest($userId, $seminaryId, $questId, $file, $filename)
|
public function uploadMediaForQuest($userId, $seminaryId, $questId, $file, $filename)
|
||||||
{
|
{
|
||||||
// Save file on harddrive
|
// Save file on harddrive
|
||||||
$uploadId = $this->Uploads->uploadSeminaryFile($userId, $seminaryId, $file['name'], $filename, $file['tmp_name'], $file['type']);
|
$uploadId = $this->Uploads->uploadSeminaryFile($userId, $seminaryId, $file['name'], $filename, $file['tmp_name'], $file['type']);
|
||||||
if($uploadId === false) {
|
if($uploadId === false) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create database record
|
// Create database record
|
||||||
$this->db->query(
|
$this->db->query(
|
||||||
'INSERT INTO charactergroupsquests_seminaryuploads '.
|
'INSERT INTO charactergroupsquests_seminaryuploads '.
|
||||||
'(seminaryupload_id, charactergroupsquest_id, created_user_id) '.
|
'(seminaryupload_id, charactergroupsquest_id, created_user_id) '.
|
||||||
'VALUES '.
|
'VALUES '.
|
||||||
'(?, ?, ?) ',
|
'(?, ?, ?) ',
|
||||||
'iii',
|
'iii',
|
||||||
$uploadId, $questId, $userId
|
$uploadId, $questId, $userId
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get uploaded Medai for a Character groups Quest.
|
* Get uploaded Medai for a Character groups Quest.
|
||||||
*
|
*
|
||||||
* @param int $questId ID of Quest to get media for
|
* @param int $questId ID of Quest to get media for
|
||||||
* @return array Seminary uploads
|
* @return array Seminary uploads
|
||||||
*/
|
*/
|
||||||
public function getMediaForQuest($questId)
|
public function getMediaForQuest($questId)
|
||||||
{
|
{
|
||||||
return $this->db->query(
|
return $this->db->query(
|
||||||
'SELECT seminaryupload_id, created, created_user_id '.
|
'SELECT seminaryupload_id, created, created_user_id '.
|
||||||
'FROM charactergroupsquests_seminaryuploads '.
|
'FROM charactergroupsquests_seminaryuploads '.
|
||||||
'WHERE charactergroupsquest_id = ?',
|
'WHERE charactergroupsquest_id = ?',
|
||||||
'i',
|
'i',
|
||||||
$questId
|
$questId
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new Character groups Quest.
|
* Create a new Character groups Quest.
|
||||||
*
|
*
|
||||||
* @param int $userId ID of user
|
* @param int $userId ID of user
|
||||||
* @param int $groupsgroupId ID of Character groups-group
|
* @param int $groupsgroupId ID of Character groups-group
|
||||||
* @param int $questgroupId ID of Quest group
|
* @param int $questgroupId ID of Quest group
|
||||||
* @param string $title Title of new Quest
|
* @param string $title Title of new Quest
|
||||||
* @param string $description Description of new Quset
|
* @param string $description Description of new Quset
|
||||||
* @param int $xps Amount of XPs for new Quest
|
* @param int $xps Amount of XPs for new Quest
|
||||||
* @param string $rules Rules of new Quest
|
* @param string $rules Rules of new Quest
|
||||||
* @param string $wonText Won-text of new Quset
|
* @param string $wonText Won-text of new Quset
|
||||||
* @param string $lostText Lost-text of new Quest
|
* @param string $lostText Lost-text of new Quest
|
||||||
* @return int ID of newly created Quest
|
* @return int ID of newly created Quest
|
||||||
*/
|
*/
|
||||||
public function createQuest($userId, $groupsgroupId, $questgroupId, $title, $description, $xps, $rules, $wonText, $lostText)
|
public function createQuest($userId, $groupsgroupId, $questgroupId, $title, $description, $xps, $rules, $wonText, $lostText)
|
||||||
{
|
{
|
||||||
$this->db->query(
|
$this->db->query(
|
||||||
'INSERT INTO charactergroupsquests '.
|
'INSERT INTO charactergroupsquests '.
|
||||||
'(created_user_id, charactergroupsgroup_id, questgroups_id, title, url, description, xps, rules, won_text, lost_text) '.
|
'(created_user_id, charactergroupsgroup_id, questgroups_id, title, url, description, xps, rules, won_text, lost_text) '.
|
||||||
'VALUES '.
|
'VALUES '.
|
||||||
'(?, ?, ?, ?, ?, ?, ?, ?, ?, ?)',
|
'(?, ?, ?, ?, ?, ?, ?, ?, ?, ?)',
|
||||||
'iiisssdsss',
|
'iiisssdsss',
|
||||||
$userId,
|
$userId,
|
||||||
$groupsgroupId,
|
$groupsgroupId,
|
||||||
$questgroupId,
|
$questgroupId,
|
||||||
$title,
|
$title,
|
||||||
\nre\core\Linker::createLinkParam($title),
|
\nre\core\Linker::createLinkParam($title),
|
||||||
$description,
|
$description,
|
||||||
$xps,
|
$xps,
|
||||||
$rules,
|
$rules,
|
||||||
$wonText,
|
$wonText,
|
||||||
$lostText
|
$lostText
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
return $this->db->getInsertId();
|
return $this->db->getInsertId();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Edit a Character groups Quest.
|
* Edit a Character groups Quest.
|
||||||
*
|
*
|
||||||
* @param int $questId ID of Character groups Quest to edit
|
* @param int $questId ID of Character groups Quest to edit
|
||||||
* @param int $groupsgroupId ID of Character groups-group
|
* @param int $groupsgroupId ID of Character groups-group
|
||||||
* @param int $questgroupId ID of Quest group
|
* @param int $questgroupId ID of Quest group
|
||||||
* @param string $title Title of new Quest
|
* @param string $title Title of new Quest
|
||||||
* @param string $description Description of new Quset
|
* @param string $description Description of new Quset
|
||||||
* @param int $xps Amount of XPs for new Quest
|
* @param int $xps Amount of XPs for new Quest
|
||||||
* @param string $rules Rules of new Quest
|
* @param string $rules Rules of new Quest
|
||||||
* @param string $wonText Won-text of new Quset
|
* @param string $wonText Won-text of new Quset
|
||||||
* @param string $lostText Lost-text of new Quest
|
* @param string $lostText Lost-text of new Quest
|
||||||
*/
|
*/
|
||||||
public function editQuest($questId, $groupsgroupId, $questgroupId, $title, $description, $xps, $rules, $wonText, $lostText)
|
public function editQuest($questId, $groupsgroupId, $questgroupId, $title, $description, $xps, $rules, $wonText, $lostText)
|
||||||
{
|
{
|
||||||
$this->db->query(
|
$this->db->query(
|
||||||
'UPDATE charactergroupsquests '.
|
'UPDATE charactergroupsquests '.
|
||||||
'SET charactergroupsgroup_id = ?, questgroups_id = ?, title = ?, url = ?, description = ?, xps = ?, rules = ?, won_text = ?, lost_text= ? '.
|
'SET charactergroupsgroup_id = ?, questgroups_id = ?, title = ?, url = ?, description = ?, xps = ?, rules = ?, won_text = ?, lost_text= ? '.
|
||||||
'WHERE id = ?',
|
'WHERE id = ?',
|
||||||
'iisssdsssi',
|
'iisssdsssi',
|
||||||
$groupsgroupId,
|
$groupsgroupId,
|
||||||
$questgroupId,
|
$questgroupId,
|
||||||
$title,
|
$title,
|
||||||
\nre\core\Linker::createLinkParam($title),
|
\nre\core\Linker::createLinkParam($title),
|
||||||
$description,
|
$description,
|
||||||
$xps,
|
$xps,
|
||||||
$rules,
|
$rules,
|
||||||
$wonText,
|
$wonText,
|
||||||
$lostText,
|
$lostText,
|
||||||
$questId
|
$questId
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Copy all Character groups Quests from a Seminary.
|
* Copy all Character groups Quests from a Seminary.
|
||||||
*
|
*
|
||||||
* @param int $userId ID of copying user
|
* @param int $userId ID of copying user
|
||||||
* @param array $groupsgroupIds Mapping of Character groups-group-IDs from source Seminary to target Seminary
|
* @param array $groupsgroupIds Mapping of Character groups-group-IDs from source Seminary to target Seminary
|
||||||
* @param array $questgroupIds Mapping of Questgroup-IDs from source Seminary to target Seminary
|
* @param array $questgroupIds Mapping of Questgroup-IDs from source Seminary to target Seminary
|
||||||
|
|
@ -424,17 +424,17 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Delete a Character groups Quest.
|
* Delete a Character groups Quest.
|
||||||
*
|
*
|
||||||
* @param int $questId ID of Character groups Quest to delete
|
* @param int $questId ID of Character groups Quest to delete
|
||||||
*/
|
*/
|
||||||
public function deleteQuest($questId)
|
public function deleteQuest($questId)
|
||||||
{
|
{
|
||||||
$this->db->query('DELETE FROM charactergroupsquests WHERE id = ?', 'i', $questId);
|
$this->db->query('DELETE FROM charactergroupsquests WHERE id = ?', 'i', $questId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
|
||||||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue