replace tabs with spaces

This commit is contained in:
oliver 2015-05-12 09:49:53 +02:00
commit c79f0f213b
176 changed files with 27652 additions and 27647 deletions

View file

@ -5,40 +5,46 @@ ErrorDocument 404 /www/error404.html
ErrorDocument 500 /www/error500.html
<IfModule mod_authz_core.c>
Require all granted
Require all granted
<Files ~ "\.inc$">
Require all denied
</Files>
<Files ~ "\.tpl$">
Require all denied
</Files>
<Files ~ "\.log$">
Require all denied
</Files>
<Files ~ "\.inc$">
Require all denied
</Files>
<Files ~ "\.tpl$">
Require all denied
</Files>
<Files ~ "\.log$">
Require all denied
</Files>
</IfModule>
<IfModule !mod_authz_core.c>
Allow From All
<Files ~ "\.inc$">
Order Deny,Allow
Deny From All
</Files>
<Files ~ "\.tpl$">
Order Deny,Allow
Deny From All
</Files>
<Files ~ "\.log$">
Order Deny,Allow
Deny From All
</Files>
<IfModule !mod_authz_core.c>
Allow From All
<Files ~ "\.inc$">
Order Deny,Allow
Deny From All
</Files>
<Files ~ "\.tpl$">
Order Deny,Allow
Deny From All
</Files>
<Files ~ "\.log$">
Order Deny,Allow
Deny From All
</Files>
</IfModule>
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteEngine On
RewriteBase /
RewriteRule ^(.*)$ www/$1 [L]
RewriteBase /
RewriteRule ^(.*)$ www/$1 [L]
</IfModule>

View file

@ -1,38 +1,38 @@
<?php
/**
* The Legend of Z
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
* @license http://www.gnu.org/licenses/gpl.html
* @link https://bitbucket.org/coderkun/the-legend-of-z
*/
/**
* The Legend of Z
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
* @license http://www.gnu.org/licenses/gpl.html
* @link https://bitbucket.org/coderkun/the-legend-of-z
*/
namespace hhu\z\agents\bottomlevel;
namespace hhu\z\agents\bottomlevel;
/**
* Agent to generate a mail receiver salutation.
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
*/
class MailreceiverAgent extends \nre\agents\BottomlevelAgent
{
/**
* Agent to generate a mail receiver salutation.
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
*/
class MailreceiverAgent extends \nre\agents\BottomlevelAgent
{
/**
* Action: index.
*
* @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: index.
*
* @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)
{
}
}
}
?>

View file

@ -1,40 +1,40 @@
<?php
/**
* The Legend of Z
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
* @license http://www.gnu.org/licenses/gpl.html
* @link https://bitbucket.org/coderkun/the-legend-of-z
*/
/**
* The Legend of Z
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
* @license http://www.gnu.org/licenses/gpl.html
* @link https://bitbucket.org/coderkun/the-legend-of-z
*/
namespace hhu\z\agents\bottomlevel;
namespace hhu\z\agents\bottomlevel;
/**
* Agent to display a menu.
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
*/
class MenuAgent extends \nre\agents\BottomlevelAgent
{
/**
* Agent to display a menu.
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
*/
class MenuAgent extends \nre\agents\BottomlevelAgent
{
/**
* Action: index.
*
* @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)
{
// Add Seminary menu
$this->addSubAgent('Seminarymenu');
}
/**
* Action: index.
*
* @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)
{
// Add Seminary menu
$this->addSubAgent('Seminarymenu');
}
}
}
?>

View file

@ -1,38 +1,38 @@
<?php
/**
* The Legend of Z
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
* @license http://www.gnu.org/licenses/gpl.html
* @link https://bitbucket.org/coderkun/the-legend-of-z
*/
/**
* The Legend of Z
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
* @license http://www.gnu.org/licenses/gpl.html
* @link https://bitbucket.org/coderkun/the-legend-of-z
*/
namespace hhu\z\agents\bottomlevel;
namespace hhu\z\agents\bottomlevel;
/**
* Agent to display the Questgroups hierarchy path.
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
*/
class QuestgroupshierarchypathAgent extends \nre\agents\BottomlevelAgent
{
/**
* Agent to display the Questgroups hierarchy path.
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
*/
class QuestgroupshierarchypathAgent extends \nre\agents\BottomlevelAgent
{
/**
* Action: index.
*
* @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: index.
*
* @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)
{
}
}
}
?>

View file

@ -1,38 +1,38 @@
<?php
/**
* The Legend of Z
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
* @license http://www.gnu.org/licenses/gpl.html
* @link https://bitbucket.org/coderkun/the-legend-of-z
*/
/**
* The Legend of Z
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
* @license http://www.gnu.org/licenses/gpl.html
* @link https://bitbucket.org/coderkun/the-legend-of-z
*/
namespace hhu\z\agents\bottomlevel;
namespace hhu\z\agents\bottomlevel;
/**
* Agent to display a sidebar with Seminary related information.
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
*/
class SeminarybarAgent extends \nre\agents\BottomlevelAgent
{
/**
* Agent to display a sidebar with Seminary related information.
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
*/
class SeminarybarAgent extends \nre\agents\BottomlevelAgent
{
/**
* Action: index.
*
* @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: index.
*
* @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)
{
}
}
}
?>

View file

@ -1,38 +1,38 @@
<?php
/**
* The Legend of Z
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
* @license http://www.gnu.org/licenses/gpl.html
* @link https://bitbucket.org/coderkun/the-legend-of-z
*/
/**
* The Legend of Z
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
* @license http://www.gnu.org/licenses/gpl.html
* @link https://bitbucket.org/coderkun/the-legend-of-z
*/
namespace hhu\z\agents\bottomlevel;
namespace hhu\z\agents\bottomlevel;
/**
* Agent to display a menu with Seminary related links.
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
*/
class SeminarymenuAgent extends \nre\agents\BottomlevelAgent
{
/**
* Agent to display a menu with Seminary related links.
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
*/
class SeminarymenuAgent extends \nre\agents\BottomlevelAgent
{
/**
* Action: index.
*
* @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: index.
*
* @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)
{
}
}
}
?>

View file

@ -1,38 +1,38 @@
<?php
/**
* The Legend of Z
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
* @license http://www.gnu.org/licenses/gpl.html
* @link https://bitbucket.org/coderkun/the-legend-of-z
*/
/**
* The Legend of Z
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
* @license http://www.gnu.org/licenses/gpl.html
* @link https://bitbucket.org/coderkun/the-legend-of-z
*/
namespace hhu\z\agents\bottomlevel;
namespace hhu\z\agents\bottomlevel;
/**
* Agent to display and manage userroles.
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
*/
class UserrolesAgent extends \nre\agents\BottomlevelAgent
{
/**
* Agent to display and manage userroles.
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
*/
class UserrolesAgent extends \nre\agents\BottomlevelAgent
{
/**
* Action: user.
*
* @param \nre\core\Request $request Current request
* @param \nre\core\Response $response Current response
*/
public function user(\nre\core\Request $request, \nre\core\Response $response)
{
}
/**
* Action: user.
*
* @param \nre\core\Request $request Current request
* @param \nre\core\Response $response Current response
*/
public function user(\nre\core\Request $request, \nre\core\Response $response)
{
}
}
}
?>

View file

@ -1,38 +1,38 @@
<?php
/**
* The Legend of Z
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
* @license http://www.gnu.org/licenses/gpl.html
* @link https://bitbucket.org/coderkun/the-legend-of-z
*/
/**
* The Legend of Z
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
* @license http://www.gnu.org/licenses/gpl.html
* @link https://bitbucket.org/coderkun/the-legend-of-z
*/
namespace hhu\z\agents\intermediate;
namespace hhu\z\agents\intermediate;
/**
* Agent to list Achievements.
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
*/
class AchievementsAgent extends \nre\agents\IntermediateAgent
{
/**
* Agent to list Achievements.
*
* @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
*/
public function index(\nre\core\Request $request, \nre\core\Response $response)
{
}
/**
* Action: index.
*
* @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)
{
}
}
}
?>

View file

@ -1,38 +1,38 @@
<?php
/**
* The Legend of Z
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
* @license http://www.gnu.org/licenses/gpl.html
* @link https://bitbucket.org/coderkun/the-legend-of-z
*/
/**
* The Legend of Z
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
* @license http://www.gnu.org/licenses/gpl.html
* @link https://bitbucket.org/coderkun/the-legend-of-z
*/
namespace hhu\z\agents\intermediate;
namespace hhu\z\agents\intermediate;
/**
* Agent to display Character groups.
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
*/
class CharactergroupsAgent extends \nre\agents\IntermediateAgent
{
/**
* Agent to display Character groups.
*
* @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
*/
public function index(\nre\core\Request $request, \nre\core\Response $response)
{
}
/**
* Action: index.
*
* @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)
{
}
}
}
?>

View file

@ -1,38 +1,38 @@
<?php
/**
* The Legend of Z
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
* @license http://www.gnu.org/licenses/gpl.html
* @link https://bitbucket.org/coderkun/the-legend-of-z
*/
/**
* The Legend of Z
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
* @license http://www.gnu.org/licenses/gpl.html
* @link https://bitbucket.org/coderkun/the-legend-of-z
*/
namespace hhu\z\agents\intermediate;
namespace hhu\z\agents\intermediate;
/**
* Agent to display Character groups Quests.
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
*/
class CharactergroupsquestsAgent extends \nre\agents\IntermediateAgent
{
/**
* Agent to display Character groups Quests.
*
* @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
*/
public function index(\nre\core\Request $request, \nre\core\Response $response)
{
}
/**
* Action: index.
*
* @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)
{
}
}
}
?>

View file

@ -1,49 +1,49 @@
<?php
/**
* The Legend of Z
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
* @license http://www.gnu.org/licenses/gpl.html
* @link https://bitbucket.org/coderkun/the-legend-of-z
*/
/**
* The Legend of Z
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
* @license http://www.gnu.org/licenses/gpl.html
* @link https://bitbucket.org/coderkun/the-legend-of-z
*/
namespace hhu\z\agents\intermediate;
namespace hhu\z\agents\intermediate;
/**
* Agent to list registered Characters and their data.
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
*/
class CharactersAgent extends \nre\agents\IntermediateAgent
{
/**
* Agent to list registered Characters and their data.
*
* @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
*/
public function index(\nre\core\Request $request, \nre\core\Response $response)
{
}
/**
* Action: index.
*
* @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
*/
public function character(\nre\core\Request $request, \nre\core\Response $response)
{
}
/**
* Action: character.
*
* @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)
{
}
}
}
?>

View file

@ -1,38 +1,38 @@
<?php
/**
* The Legend of Z
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
* @license http://www.gnu.org/licenses/gpl.html
* @link https://bitbucket.org/coderkun/the-legend-of-z
*/
/**
* The Legend of Z
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
* @license http://www.gnu.org/licenses/gpl.html
* @link https://bitbucket.org/coderkun/the-legend-of-z
*/
namespace hhu\z\agents\intermediate;
namespace hhu\z\agents\intermediate;
/**
* Agent to handle Charactertyes of a Seminary.
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
*/
class CharactertypesAgent extends \nre\agents\IntermediateAgent
{
/**
* Agent to handle Charactertyes of a Seminary.
*
* @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
*/
public function index(\nre\core\Request $request, \nre\core\Response $response)
{
}
/**
* Action: index.
*
* @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)
{
}
}
}
?>

View file

@ -1,38 +1,38 @@
<?php
/**
* The Legend of Z
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
* @license http://www.gnu.org/licenses/gpl.html
* @link https://bitbucket.org/coderkun/the-legend-of-z
*/
/**
* The Legend of Z
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
* @license http://www.gnu.org/licenses/gpl.html
* @link https://bitbucket.org/coderkun/the-legend-of-z
*/
namespace hhu\z\agents\intermediate;
namespace hhu\z\agents\intermediate;
/**
* Agent to show an error page.
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
*/
class ErrorAgent extends \nre\agents\IntermediateAgent
{
/**
* Agent to show an error page.
*
* @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
*/
public function index(\nre\core\Request $request, \nre\core\Response $response)
{
}
/**
* Action: index.
*
* @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)
{
}
}
}
?>

View file

@ -1,38 +1,38 @@
<?php
/**
* The Legend of Z
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
* @license http://www.gnu.org/licenses/gpl.html
* @link https://bitbucket.org/coderkun/the-legend-of-z
*/
/**
* The Legend of Z
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
* @license http://www.gnu.org/licenses/gpl.html
* @link https://bitbucket.org/coderkun/the-legend-of-z
*/
namespace hhu\z\agents\intermediate;
namespace hhu\z\agents\intermediate;
/**
* Agent to show an introduction page.
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
*/
class IntroductionAgent extends \nre\agents\IntermediateAgent
{
/**
* Agent to show an introduction page.
*
* @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
*/
public function index(\nre\core\Request $request, \nre\core\Response $response)
{
}
/**
* Action: index.
*
* @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)
{
}
}
}
?>

View file

@ -1,38 +1,38 @@
<?php
/**
* The Legend of Z
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
* @license http://www.gnu.org/licenses/gpl.html
* @link https://bitbucket.org/coderkun/the-legend-of-z
*/
/**
* The Legend of Z
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
* @license http://www.gnu.org/licenses/gpl.html
* @link https://bitbucket.org/coderkun/the-legend-of-z
*/
namespace hhu\z\agents\intermediate;
namespace hhu\z\agents\intermediate;
/**
* Agent to list Quest topics.
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
*/
class LibraryAgent extends \nre\agents\IntermediateAgent
{
/**
* Agent to list Quest topics.
*
* @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
*/
public function index(\nre\core\Request $request, \nre\core\Response $response)
{
}
/**
* Action: index.
*
* @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)
{
}
}
}
?>

View file

@ -1,38 +1,38 @@
<?php
/**
* The Legend of Z
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
* @license http://www.gnu.org/licenses/gpl.html
* @link https://bitbucket.org/coderkun/the-legend-of-z
*/
/**
* The Legend of Z
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
* @license http://www.gnu.org/licenses/gpl.html
* @link https://bitbucket.org/coderkun/the-legend-of-z
*/
namespace hhu\z\agents\intermediate;
namespace hhu\z\agents\intermediate;
/**
* Agent to generate a mail-message.
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
*/
class MailAgent extends \nre\agents\IntermediateAgent
{
/**
* Agent to generate a mail-message.
*
* @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
*/
public function index(\nre\core\Request $request, \nre\core\Response $response)
{
}
/**
* Action: index.
*
* @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)
{
}
}
}
?>

View file

@ -1,38 +1,38 @@
<?php
/**
* The Legend of Z
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
* @license http://www.gnu.org/licenses/gpl.html
* @link https://bitbucket.org/coderkun/the-legend-of-z
*/
/**
* The Legend of Z
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
* @license http://www.gnu.org/licenses/gpl.html
* @link https://bitbucket.org/coderkun/the-legend-of-z
*/
namespace hhu\z\agents\intermediate;
namespace hhu\z\agents\intermediate;
/**
* Agent to display a map.
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
*/
class MapAgent extends \nre\agents\IntermediateAgent
{
/**
* Agent to display a map.
*
* @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
*/
public function index(\nre\core\Request $request, \nre\core\Response $response)
{
}
/**
* Action: index.
*
* @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)
{
}
}
}
?>

View file

@ -1,38 +1,38 @@
<?php
/**
* The Legend of Z
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
* @license http://www.gnu.org/licenses/gpl.html
* @link https://bitbucket.org/coderkun/the-legend-of-z
*/
/**
* The Legend of Z
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
* @license http://www.gnu.org/licenses/gpl.html
* @link https://bitbucket.org/coderkun/the-legend-of-z
*/
namespace hhu\z\agents\intermediate;
namespace hhu\z\agents\intermediate;
/**
* Agent to process and show media.
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
*/
class MediaAgent extends \nre\agents\IntermediateAgent
{
/**
* Agent to process and show media.
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
*/
class MediaAgent extends \nre\agents\IntermediateAgent
{
/**
* Action: index.
*
* @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: index.
*
* @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)
{
}
}
}
?>

View file

@ -1,99 +1,99 @@
<?php
/**
* The Legend of Z
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
* @license http://www.gnu.org/licenses/gpl.html
* @link https://bitbucket.org/coderkun/the-legend-of-z
*/
/**
* The Legend of Z
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
* @license http://www.gnu.org/licenses/gpl.html
* @link https://bitbucket.org/coderkun/the-legend-of-z
*/
namespace hhu\z\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
{
/**
* 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: 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: 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: 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: 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: 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));
}
/**
* 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));
}
}
}
?>

View file

@ -1,24 +1,24 @@
<?php
/**
* The Legend of Z
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
* @license http://www.gnu.org/licenses/gpl.html
* @link https://bitbucket.org/coderkun/the-legend-of-z
*/
/**
* The Legend of Z
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
* @license http://www.gnu.org/licenses/gpl.html
* @link https://bitbucket.org/coderkun/the-legend-of-z
*/
namespace hhu\z\agents\intermediate;
namespace hhu\z\agents\intermediate;
/**
* Agent to manage Questgroupshierarchy.
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
*/
class QuestgroupshierarchyAgent extends \nre\agents\IntermediateAgent
{
}
/**
* Agent to manage Questgroupshierarchy.
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
*/
class QuestgroupshierarchyAgent extends \nre\agents\IntermediateAgent
{
}
?>

View file

@ -1,123 +1,123 @@
<?php
/**
* The Legend of Z
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
* @license http://www.gnu.org/licenses/gpl.html
* @link https://bitbucket.org/coderkun/the-legend-of-z
*/
/**
* The Legend of Z
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
* @license http://www.gnu.org/licenses/gpl.html
* @link https://bitbucket.org/coderkun/the-legend-of-z
*/
namespace hhu\z\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
{
/**
* 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: 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: 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: 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.
*
* @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: 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: 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: 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: 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);
}
/**
* 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);
}
}
}
?>

View file

@ -1,38 +1,38 @@
<?php
/**
* The Legend of Z
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
* @license http://www.gnu.org/licenses/gpl.html
* @link https://bitbucket.org/coderkun/the-legend-of-z
*/
/**
* The Legend of Z
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
* @license http://www.gnu.org/licenses/gpl.html
* @link https://bitbucket.org/coderkun/the-legend-of-z
*/
namespace hhu\z\agents\intermediate;
namespace hhu\z\agents\intermediate;
/**
* Agent to list registered seminaries.
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
*/
class SeminariesAgent extends \nre\agents\IntermediateAgent
{
/**
* Agent to list registered seminaries.
*
* @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
*/
public function index(\nre\core\Request $request, \nre\core\Response $response)
{
}
/**
* Action: index.
*
* @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)
{
}
}
}
?>

View file

@ -1,38 +1,38 @@
<?php
/**
* The Legend of Z
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
* @license http://www.gnu.org/licenses/gpl.html
* @link https://bitbucket.org/coderkun/the-legend-of-z
*/
/**
* The Legend of Z
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
* @license http://www.gnu.org/licenses/gpl.html
* @link https://bitbucket.org/coderkun/the-legend-of-z
*/
namespace hhu\z\agents\intermediate;
namespace hhu\z\agents\intermediate;
/**
* Agent to process and show user uploads.
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
*/
class UploadsAgent extends \nre\agents\IntermediateAgent
{
/**
* Agent to process and show user uploads.
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
*/
class UploadsAgent extends \nre\agents\IntermediateAgent
{
/**
* Action: index.
*
* @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: index.
*
* @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)
{
}
}
}
?>

View file

@ -1,50 +1,50 @@
<?php
/**
* The Legend of Z
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
* @license http://www.gnu.org/licenses/gpl.html
* @link https://bitbucket.org/coderkun/the-legend-of-z
*/
/**
* The Legend of Z
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
* @license http://www.gnu.org/licenses/gpl.html
* @link https://bitbucket.org/coderkun/the-legend-of-z
*/
namespace hhu\z\agents\intermediate;
namespace hhu\z\agents\intermediate;
/**
* Agent to list registered users and their data.
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
*/
class UsersAgent extends \nre\agents\IntermediateAgent
{
/**
* Agent to list registered users and their data.
*
* @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
*/
public function index(\nre\core\Request $request, \nre\core\Response $response)
{
}
/**
* Action: index.
*
* @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
*/
public function user(\nre\core\Request $request, \nre\core\Response $response)
{
$this->addSubAgent('Userroles', 'user');
}
/**
* Action: user.
*
* @param \nre\core\Request $request Current request
* @param \nre\core\Response $response Current response
*/
public function user(\nre\core\Request $request, \nre\core\Response $response)
{
$this->addSubAgent('Userroles', 'user');
}
}
}
?>

View file

@ -1,38 +1,38 @@
<?php
/**
* The Legend of Z
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
* @license http://www.gnu.org/licenses/gpl.html
* @link https://bitbucket.org/coderkun/the-legend-of-z
*/
/**
* The Legend of Z
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
* @license http://www.gnu.org/licenses/gpl.html
* @link https://bitbucket.org/coderkun/the-legend-of-z
*/
namespace hhu\z\agents\intermediate;
namespace hhu\z\agents\intermediate;
/**
* Agent to handle XP-levels of a Seminary.
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
*/
class XplevelsAgent extends \nre\agents\IntermediateAgent
{
/**
* Agent to handle XP-levels of a Seminary.
*
* @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
*/
public function index(\nre\core\Request $request, \nre\core\Response $response)
{
}
/**
* Action: index.
*
* @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)
{
}
}
}
?>

View file

@ -1,80 +1,80 @@
<?php
/**
* The Legend of Z
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
* @license http://www.gnu.org/licenses/gpl.html
* @link https://bitbucket.org/coderkun/the-legend-of-z
*/
/**
* The Legend of Z
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
* @license http://www.gnu.org/licenses/gpl.html
* @link https://bitbucket.org/coderkun/the-legend-of-z
*/
namespace hhu\z\agents\toplevel;
namespace hhu\z\agents\toplevel;
/**
* Agent to return a JSON-string used by AJAX.
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
*/
class AjaxAgent extends \hhu\z\agents\ToplevelAgent
{
/**
* Agent to return a JSON-string used by AJAX.
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
*/
class AjaxAgent extends \hhu\z\agents\ToplevelAgent
{
/**
* Construct a new AjaxAgent.
*
* @param \nre\core\Request $request Current request
* @param \nre\core\Response $response Current response
* @param \nre\core\Logger $log Logger instance
*/
protected function __construct(\nre\core\Request $request, \nre\core\Response $response, \nre\core\Logger $log=null)
{
parent::__construct($request, $response, $log);
/**
* Construct a new AjaxAgent.
*
* @param \nre\core\Request $request Current request
* @param \nre\core\Response $response Current response
* @param \nre\core\Logger $log Logger instance
*/
protected function __construct(\nre\core\Request $request, \nre\core\Response $response, \nre\core\Logger $log=null)
{
parent::__construct($request, $response, $log);
$this->setLanguage($request);
}
$this->setLanguage($request);
}
/**
* Action: index.
*
* @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: index.
*
* @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)
{
}
/**
* Set requested language.
*
* @param \nre\core\Request $request Current request
*/
private function setLanguage(\nre\core\Request $request)
{
// Set domain
$domain = \nre\configs\AppConfig::$app['genericname'];
/**
* Set requested language.
*
* @param \nre\core\Request $request Current request
*/
private function setLanguage(\nre\core\Request $request)
{
// Set domain
$domain = \nre\configs\AppConfig::$app['genericname'];
// Get language
$locale = $request->getGetParam('lang', 'language');
if(is_null($locale)) {
return;
}
// Get language
$locale = $request->getGetParam('lang', 'language');
if(is_null($locale)) {
return;
}
// Load translation
putenv("LC_ALL=$locale");
setlocale(LC_ALL, $locale);
bindtextdomain($domain, ROOT.DS.\nre\configs\AppConfig::$dirs['locale']);
textdomain($domain);
}
// Load translation
putenv("LC_ALL=$locale");
setlocale(LC_ALL, $locale);
bindtextdomain($domain, ROOT.DS.\nre\configs\AppConfig::$dirs['locale']);
textdomain($domain);
}
}
}
?>

View file

@ -1,51 +1,51 @@
<?php
/**
* The Legend of Z
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
* @license http://www.gnu.org/licenses/gpl.html
* @link https://bitbucket.org/coderkun/the-legend-of-z
*/
/**
* The Legend of Z
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
* @license http://www.gnu.org/licenses/gpl.html
* @link https://bitbucket.org/coderkun/the-legend-of-z
*/
namespace hhu\z\agents\toplevel;
namespace hhu\z\agents\toplevel;
/**
* Agent to display binary data (e.g. images).
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
*/
class BinaryAgent extends \hhu\z\agents\ToplevelAgent
{
/**
* Agent to display binary data (e.g. images).
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
*/
class BinaryAgent extends \hhu\z\agents\ToplevelAgent
{
/**
* Construct a new BinaryAgent.
*
* @param \nre\core\Request $request Current request
* @param \nre\core\Response $response Current response
* @param \nre\core\Logger $log Logger instance
*/
protected function __construct(\nre\core\Request $request, \nre\core\Response $response, \nre\core\Logger $log=null)
{
parent::__construct($request, $response, $log);
}
/**
* Construct a new BinaryAgent.
*
* @param \nre\core\Request $request Current request
* @param \nre\core\Response $response Current response
* @param \nre\core\Logger $log Logger instance
*/
protected function __construct(\nre\core\Request $request, \nre\core\Response $response, \nre\core\Logger $log=null)
{
parent::__construct($request, $response, $log);
}
/**
* Action: index.
*
* @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: index.
*
* @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)
{
}
}
}
?>

View file

@ -1,38 +1,38 @@
<?php
/**
* The Legend of Z
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
* @license http://www.gnu.org/licenses/gpl.html
* @link https://bitbucket.org/coderkun/the-legend-of-z
*/
/**
* The Legend of Z
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
* @license http://www.gnu.org/licenses/gpl.html
* @link https://bitbucket.org/coderkun/the-legend-of-z
*/
namespace hhu\z\agents\toplevel;
namespace hhu\z\agents\toplevel;
/**
* Agent to display a toplevel error page.
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
*/
class FaultAgent extends \nre\agents\ToplevelAgent
{
/**
* Agent to display a toplevel error page.
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
*/
class FaultAgent extends \nre\agents\ToplevelAgent
{
/**
* Action: index.
*
* @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: index.
*
* @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)
{
}
}
}
?>

View file

@ -1,58 +1,58 @@
<?php
/**
* The Legend of Z
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
* @license http://www.gnu.org/licenses/gpl.html
* @link https://bitbucket.org/coderkun/the-legend-of-z
*/
/**
* The Legend of Z
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
* @license http://www.gnu.org/licenses/gpl.html
* @link https://bitbucket.org/coderkun/the-legend-of-z
*/
namespace hhu\z\agents\toplevel;
namespace hhu\z\agents\toplevel;
/**
* Agent to display a HTML-page.
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
*/
class HtmlAgent extends \hhu\z\agents\ToplevelAgent
{
/**
* Agent to display a HTML-page.
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
*/
class HtmlAgent extends \hhu\z\agents\ToplevelAgent
{
/**
* Construct a new HtmlAgent.
*
* @param \nre\core\Request $request Current request
* @param \nre\core\Response $response Current response
* @param \nre\core\Logger $log Logger instance
*/
protected function __construct(\nre\core\Request $request, \nre\core\Response $response, \nre\core\Logger $log=null)
{
parent::__construct($request, $response, $log);
/**
* Construct a new HtmlAgent.
*
* @param \nre\core\Request $request Current request
* @param \nre\core\Response $response Current response
* @param \nre\core\Logger $log Logger instance
*/
protected function __construct(\nre\core\Request $request, \nre\core\Response $response, \nre\core\Logger $log=null)
{
parent::__construct($request, $response, $log);
$this->setLanguage($request);
}
$this->setLanguage($request);
}
/**
* Action: index.
*
* @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)
{
// Add menu
$this->addSubAgent('Menu');
/**
* Action: index.
*
* @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)
{
// Add menu
$this->addSubAgent('Menu');
// Add Seminary sidebar
$this->addSubAgent('Seminarybar');
}
// Add Seminary sidebar
$this->addSubAgent('Seminarybar');
}

View file

@ -1,52 +1,52 @@
<?php
/**
* The Legend of Z
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
* @license http://www.gnu.org/licenses/gpl.html
* @link https://bitbucket.org/coderkun/the-legend-of-z
*/
/**
* The Legend of Z
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
* @license http://www.gnu.org/licenses/gpl.html
* @link https://bitbucket.org/coderkun/the-legend-of-z
*/
namespace hhu\z\agents\toplevel;
namespace hhu\z\agents\toplevel;
/**
* Agent for generating a HTML-mail message.
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
*/
class HtmlmailAgent extends \hhu\z\agents\ToplevelAgent
{
/**
* Agent for generating a HTML-mail message.
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
*/
class HtmlmailAgent extends \hhu\z\agents\ToplevelAgent
{
/**
* Construct a new HtmlmailAgent.
*
* @param \nre\core\Request $request Current request
* @param \nre\core\Response $response Current response
* @param \nre\core\Logger $log Logger instance
*/
protected function __construct(\nre\core\Request $request, \nre\core\Response $response, \nre\core\Logger $log=null)
{
parent::__construct($request, $response, $log);
}
/**
* Construct a new HtmlmailAgent.
*
* @param \nre\core\Request $request Current request
* @param \nre\core\Response $response Current response
* @param \nre\core\Logger $log Logger instance
*/
protected function __construct(\nre\core\Request $request, \nre\core\Response $response, \nre\core\Logger $log=null)
{
parent::__construct($request, $response, $log);
}
/**
* Action: index.
*
* @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)
{
$this->addSubagent('mailreceiver', 'index', $request->getParam(3));
}
/**
* Action: index.
*
* @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)
{
$this->addSubagent('mailreceiver', 'index', $request->getParam(3));
}
}
}
?>

View file

@ -1,54 +1,53 @@
<?php
/**
* The Legend of Z
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
* @license http://www.gnu.org/licenses/gpl.html
* @link https://bitbucket.org/coderkun/the-legend-of-z
*/
/**
* The Legend of Z
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
* @license http://www.gnu.org/licenses/gpl.html
* @link https://bitbucket.org/coderkun/the-legend-of-z
*/
namespace hhu\z\agents\toplevel;
namespace hhu\z\agents\toplevel;
/**
* Agent for generating a simple text-mail message.
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
*/
class TextmailAgent extends \hhu\z\agents\ToplevelAgent
{
/**
* Agent for generating a simple text-mail message.
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
*/
class TextmailAgent extends \hhu\z\agents\ToplevelAgent
{
/**
* Construct a new TextmailAgent.
*
* @param \nre\core\Request $request Current request
* @param \nre\core\Response $response Current response
* @param \nre\core\Logger $log Logger instance
*/
protected function __construct(\nre\core\Request $request, \nre\core\Response $response, \nre\core\Logger $log=null)
{
parent::__construct($request, $response, $log);
}
/**
* Construct a new TextmailAgent.
*
* @param \nre\core\Request $request Current request
* @param \nre\core\Response $response Current response
* @param \nre\core\Logger $log Logger instance
*/
protected function __construct(\nre\core\Request $request, \nre\core\Response $response, \nre\core\Logger $log=null)
{
parent::__construct($request, $response, $log);
}
/**
* Action: index.
*
* @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)
{
$this->addSubagent('mailreceiver', 'index', $request->getParam(3));
}
/**
* Action: index.
*
* @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)
{
$this->addSubagent('mailreceiver', 'index', $request->getParam(3));
}
}
}
?>

View file

@ -1,134 +1,134 @@
<?php
/**
* The Legend of Z
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
* @license http://www.gnu.org/licenses/gpl.html
* @link https://bitbucket.org/coderkun/the-legend-of-z
*/
/**
* The Legend of Z
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
* @license http://www.gnu.org/licenses/gpl.html
* @link https://bitbucket.org/coderkun/the-legend-of-z
*/
namespace hhu\z;
namespace hhu\z;
/**
* Abstract class for implementing an application Controller.
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
*/
abstract class Controller extends \nre\core\Controller
{
/**
* Required components
*
* @var array
*/
public $components = array('auth');
/**
* Abstract class for implementing an application Controller.
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
*/
abstract class Controller extends \nre\core\Controller
{
/**
* Required components
*
* @var array
*/
public $components = array('auth');
/**
* Logger instance
*
* @var \nre\core\Logger
*/
protected $log = null;
/**
* Linker instance
*
* @var \nre\core\Linker
*/
protected $linker = null;
/**
* Logger instance
*
* @var \nre\core\Logger
*/
protected $log = null;
/**
* Linker instance
*
* @var \nre\core\Linker
*/
protected $linker = null;
/**
* 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
* @param string $layoutName Name of the current Layout
* @param string $action Current Action
* @param \nre\core\Agent $agent Corresponding Agent
*/
public function __construct($layoutName, $action, $agent)
{
parent::__construct($layoutName, $action, $agent);
/**
* 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
* @param string $layoutName Name of the current Layout
* @param string $action Current Action
* @param \nre\core\Agent $agent Corresponding Agent
*/
public function __construct($layoutName, $action, $agent)
{
parent::__construct($layoutName, $action, $agent);
// Create logger
$this->log = new \nre\core\Logger();
}
// Create logger
$this->log = new \nre\core\Logger();
}
/**
* Prefilter that is executed before running the Controller.
*
* @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);
/**
* Prefilter that is executed before running the Controller.
*
* @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);
// Create linker
$this->linker = new \nre\core\Linker($request);
$this->set('linker', $this->linker);
// Create linker
$this->linker = new \nre\core\Linker($request);
$this->set('linker', $this->linker);
// Create text formatter
$this->set('t', new \hhu\z\TextFormatter($this->linker));
// Create text formatter
$this->set('t', new \hhu\z\TextFormatter($this->linker));
// Create date and time and number formatter
$this->set('dateFormatter', new \IntlDateFormatter(
//\nre\core\Config::getDefault('locale'),
// Create date and time and number formatter
$this->set('dateFormatter', new \IntlDateFormatter(
//\nre\core\Config::getDefault('locale'),
\Locale::getDefault(),
\IntlDateFormatter::MEDIUM,
\IntlDateFormatter::NONE,
NULL
));
$this->set('timeFormatter', new \IntlDateFormatter(
//\nre\core\Config::getDefault('locale'),
\IntlDateFormatter::MEDIUM,
\IntlDateFormatter::NONE,
NULL
));
$this->set('timeFormatter', new \IntlDateFormatter(
//\nre\core\Config::getDefault('locale'),
\Locale::getDefault(),
\IntlDateFormatter::NONE,
\IntlDateFormatter::SHORT,
NULL
));
$this->set('numberFormatter', new \NumberFormatter(
//\nre\core\Config::getDefault('locale'),
\IntlDateFormatter::NONE,
\IntlDateFormatter::SHORT,
NULL
));
$this->set('numberFormatter', new \NumberFormatter(
//\nre\core\Config::getDefault('locale'),
\Locale::getDefault(),
\NumberFormatter::DEFAULT_STYLE
));
}
\NumberFormatter::DEFAULT_STYLE
));
}
/**
* Postfilter that is executed after running the Controller.
*
* @param \nre\core\Request $request Current request
* @param \nre\core\Response $response Current response
*/
public function postFilter(\nre\core\Request $request, \nre\core\Response $response)
{
parent::postFilter($request, $response);
}
/**
* Postfilter that is executed after running the Controller.
*
* @param \nre\core\Request $request Current request
* @param \nre\core\Response $response Current response
*/
public function postFilter(\nre\core\Request $request, \nre\core\Response $response)
{
parent::postFilter($request, $response);
}
/**
* Log an error.
*
* @param string $message Error message to log
* @param int $logMode Log mode (optional)
*/
protected function log($message, $logMode=\nre\core\Logger::LOGMODE_AUTO)
{
$this->log->log($message, $logMode);
}
/**
* Log an error.
*
* @param string $message Error message to log
* @param int $logMode Log mode (optional)
*/
protected function log($message, $logMode=\nre\core\Logger::LOGMODE_AUTO)
{
$this->log->log($message, $logMode);
}
}
}
?>

View file

@ -1,42 +1,42 @@
<?php
/**
* The Legend of Z
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
* @license http://www.gnu.org/licenses/gpl.html
* @link https://bitbucket.org/coderkun/the-legend-of-z
*/
/**
* The Legend of Z
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
* @license http://www.gnu.org/licenses/gpl.html
* @link https://bitbucket.org/coderkun/the-legend-of-z
*/
namespace hhu\z;
namespace hhu\z;
/**
* Abstract class for implementing an application Model.
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
*/
class Model extends \nre\models\DatabaseModel
{
/**
* Abstract class for implementing an application Model.
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
*/
class Model extends \nre\models\DatabaseModel
{
/**
* Construct a new application Model.
*
* @throws \nre\exceptions\DatamodelException
* @throws \nre\exceptions\DriverNotFoundException
* @throws \nre\exceptions\DriverNotValidException
* @throws \nre\exceptions\ModelNotValidException
* @throws \nre\exceptions\ModelNotFoundException
*/
public function __construct()
{
parent::__construct('mysqli', \nre\configs\AppConfig::$database);
}
/**
* Construct a new application Model.
*
* @throws \nre\exceptions\DatamodelException
* @throws \nre\exceptions\DriverNotFoundException
* @throws \nre\exceptions\DriverNotValidException
* @throws \nre\exceptions\ModelNotValidException
* @throws \nre\exceptions\ModelNotFoundException
*/
public function __construct()
{
parent::__construct('mysqli', \nre\configs\AppConfig::$database);
}
}
}
?>

View file

@ -1,149 +1,149 @@
<?php
/**
* The Legend of Z
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
* @license http://www.gnu.org/licenses/gpl.html
* @link https://bitbucket.org/coderkun/the-legend-of-z
*/
/**
* The Legend of Z
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
* @license http://www.gnu.org/licenses/gpl.html
* @link https://bitbucket.org/coderkun/the-legend-of-z
*/
namespace hhu\z;
namespace hhu\z;
/**
* Class to format text with different syntax tags.
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
*/
class TextFormatter
{
/**
* Linker to create links.
*
* @var \nre\core\Linker
*/
private $linker;
/**
* Media-Model to retrieve media data
*
* @static
* @var \nre\core\Model
*/
private static $Media = null;
/**
* Class to format text with different syntax tags.
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
*/
class TextFormatter
{
/**
* Linker to create links.
*
* @var \nre\core\Linker
*/
private $linker;
/**
* Media-Model to retrieve media data
*
* @static
* @var \nre\core\Model
*/
private static $Media = null;
/**
* Create a new text formatter.
*
* @param \nre\core\Linker $linker Linker to create links with
*/
public function __construct(\nre\core\Linker $linker)
{
$this->linker = $linker;
}
/**
* Create a new text formatter.
*
* @param \nre\core\Linker $linker Linker to create links with
*/
public function __construct(\nre\core\Linker $linker)
{
$this->linker = $linker;
}
/**
* Format a string.
*
* @param string $string String to format
* @return string Formatted string
*/
public function t($string)
{
// Remove chars
$string = htmlspecialchars($string, ENT_NOQUOTES);
/**
* Format a string.
*
* @param string $string String to format
* @return string Formatted string
*/
public function t($string)
{
// Remove chars
$string = htmlspecialchars($string, ENT_NOQUOTES);
// Important text
$string = str_replace('[strong]', '<strong>', $string);
$string = str_replace('[/strong]', '</strong>', $string);
// Important text
$string = str_replace('[strong]', '<strong>', $string);
$string = str_replace('[/strong]', '</strong>', $string);
// Create tables
$string = preg_replace('/(\[table\])\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*(\[/tr\])\s*%u', '$1', $string);
$string = str_replace('[table]', '</p><table>', $string);
$string = str_replace('[/table]', '</table><p>', $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('[td]', '<td>', $string);
$string = str_replace('[/td]', '</td>', $string);
// Create tables
$string = preg_replace('/(\[table\])\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*(\[/tr\])\s*%u', '$1', $string);
$string = str_replace('[table]', '</p><table>', $string);
$string = str_replace('[/table]', '</table><p>', $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('[td]', '<td>', $string);
$string = str_replace('[/td]', '</td>', $string);
// 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="$2">$2</a>$3', $string);
// 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="$2">$2</a>$3', $string);
// Handle Seminarymedia
$seminarymedia = array();
preg_match_all('/\[seminarymedia:(\d+)\]/iu', $string, $matches); //, PREG_SET_ORDER | PREG_OFFSET_CAPTURE);
$seminarymediaIds = array_unique($matches[1]);
foreach($seminarymediaIds as &$seminarymediaId)
{
$replacement = null;
if(!is_null(\hhu\z\controllers\SeminaryController::$seminary) && $this->loadMediaModel())
{
try {
$medium = self::$Media->getSeminaryMediaById($seminarymediaId);
$replacement = sprintf(
'<img src="%s" alt="%s" />',
$this->linker->link(array('media','seminary', \hhu\z\controllers\SeminaryController::$seminary['url'],$medium['url'])),
$medium['description']
);
}
catch(\nre\exceptions\IdNotFoundException $e) {
}
}
// Handle Seminarymedia
$seminarymedia = array();
preg_match_all('/\[seminarymedia:(\d+)\]/iu', $string, $matches); //, PREG_SET_ORDER | PREG_OFFSET_CAPTURE);
$seminarymediaIds = array_unique($matches[1]);
foreach($seminarymediaIds as &$seminarymediaId)
{
$replacement = null;
if(!is_null(\hhu\z\controllers\SeminaryController::$seminary) && $this->loadMediaModel())
{
try {
$medium = self::$Media->getSeminaryMediaById($seminarymediaId);
$replacement = sprintf(
'<img src="%s" alt="%s" />',
$this->linker->link(array('media','seminary', \hhu\z\controllers\SeminaryController::$seminary['url'],$medium['url'])),
$medium['description']
);
}
catch(\nre\exceptions\IdNotFoundException $e) {
}
}
$seminarymedia[$seminarymediaId] = $replacement;
}
foreach($seminarymedia as $seminarymediaId => $replacement) {
$string = str_replace("[seminarymedia:$seminarymediaId]", $replacement, $string);
}
$seminarymedia[$seminarymediaId] = $replacement;
}
foreach($seminarymedia as $seminarymediaId => $replacement) {
$string = str_replace("[seminarymedia:$seminarymediaId]", $replacement, $string);
}
// Return processed string
return nl2br($string);
}
// Return processed string
return nl2br($string);
}
/**
* Load the Media-Model if it is not loaded
*
* @return boolean Whether the Media-Model has been loaded or not
*/
private function loadMediaModel()
{
// Do not load Model if it has already been loaded
if(!is_null(self::$Media)) {
return true;
}
/**
* Load the Media-Model if it is not loaded
*
* @return boolean Whether the Media-Model has been loaded or not
*/
private function loadMediaModel()
{
// Do not load Model if it has already been loaded
if(!is_null(self::$Media)) {
return true;
}
try {
// Load class
Model::load('media');
try {
// Load class
Model::load('media');
// Construct Model
self::$Media = Model::factory('media');
}
catch(\Exception $e) {
}
// Construct Model
self::$Media = Model::factory('media');
}
catch(\Exception $e) {
}
// Return whether Media-Model has been loaded or not
return !is_null(self::$Media);
}
// Return whether Media-Model has been loaded or not
return !is_null(self::$Media);
}
}
}
?>

View file

@ -1,214 +1,214 @@
<?php
/**
* The Legend of Z
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
* @license http://www.gnu.org/licenses/gpl.html
* @link https://bitbucket.org/coderkun/the-legend-of-z
*/
/**
* The Legend of Z
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
* @license http://www.gnu.org/licenses/gpl.html
* @link https://bitbucket.org/coderkun/the-legend-of-z
*/
namespace hhu\z;
namespace hhu\z;
/**
* Class for implementing utility methods.
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
*/
class Utils
{
/**
* Class for implementing utility methods.
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
*/
class Utils
{
/**
* Mask HTML-chars for save output.
*
* @static
* @param string $string String to be masked
* @return string Masked string
*/
public static function t($string)
{
return nl2br(htmlspecialchars($string));
}
/**
* Mask HTML-chars for save output.
*
* @static
* @param string $string String to be masked
* @return string Masked string
*/
public static function t($string)
{
return nl2br(htmlspecialchars($string));
}
/**
* htmlspecialchars with support for UTF-8.
*
* @static
* @param string $string String to be masked
* @return string Masked string
*/
public static function htmlspecialchars_utf8($string)
{
return htmlspecialchars($string, ENT_COMPAT, 'UTF-8');
}
/**
* htmlspecialchars with support for UTF-8.
*
* @static
* @param string $string String to be masked
* @return string Masked string
*/
public static function htmlspecialchars_utf8($string)
{
return htmlspecialchars($string, ENT_COMPAT, 'UTF-8');
}
/**
* Cut a string to the given length but only word boundaries.
*
* @static
* @param string $string String to cut
* @param int $length Length to cut string
* @param int $scope Maximum length to cut string regardless word boundaries
* @return string Cutted string
*/
public static function shortenString($string, $length, $scope)
{
// Determine length
$length = min($length, strlen($string));
/**
* Cut a string to the given length but only word boundaries.
*
* @static
* @param string $string String to cut
* @param int $length Length to cut string
* @param int $scope Maximum length to cut string regardless word boundaries
* @return string Cutted string
*/
public static function shortenString($string, $length, $scope)
{
// Determine length
$length = min($length, strlen($string));
// Look for word boundary
if(($pos = strpos($string, ' ', $length)) !== false)
{
// Check if boundary is outside of scope
if($pos > $length + $scope) {
$pos = strrpos(substr($string, 0, $pos), ' ');
}
}
else {
$pos = strlen($string);
}
// Look for word boundary
if(($pos = strpos($string, ' ', $length)) !== false)
{
// Check if boundary is outside of scope
if($pos > $length + $scope) {
$pos = strrpos(substr($string, 0, $pos), ' ');
}
}
else {
$pos = strlen($string);
}
// Cut string and return it
return substr($string, 0, $pos);
}
// Cut string and return it
return substr($string, 0, $pos);
}
/**
* Send an email.
*
* @throws \hhu\z\exceptions\MailingException
* @param mixed $to One (string) or many (array) receivers
* @param string $messageAction Message Action
* @param boolean $html Whether mail should be formatted as HTML or not
* @param array $params Parameters to pass
* @param \nre\core\Linker $linker Linker instance
*/
public static function sendMail($to, $messageAction, $html=false, $params=null, $linker=null)
{
// Check configuration
if(
empty(\nre\configs\AppConfig::$mail['host']) ||
empty(\nre\configs\AppConfig::$mail['port']) ||
empty(\nre\configs\AppConfig::$mail['username'])
) {
return;
}
/**
* Send an email.
*
* @throws \hhu\z\exceptions\MailingException
* @param mixed $to One (string) or many (array) receivers
* @param string $messageAction Message Action
* @param boolean $html Whether mail should be formatted as HTML or not
* @param array $params Parameters to pass
* @param \nre\core\Linker $linker Linker instance
*/
public static function sendMail($to, $messageAction, $html=false, $params=null, $linker=null)
{
// Check configuration
if(
empty(\nre\configs\AppConfig::$mail['host']) ||
empty(\nre\configs\AppConfig::$mail['port']) ||
empty(\nre\configs\AppConfig::$mail['username'])
) {
return;
}
// Load classes
\hhu\z\lib\PHPMailerAutoload::load();
\hhu\z\lib\PHPMailer::load();
\hhu\z\lib\SMTP::load();
// Load classes
\hhu\z\lib\PHPMailerAutoload::load();
\hhu\z\lib\PHPMailer::load();
\hhu\z\lib\SMTP::load();
// Create mailer
$mail = new \PHPMailer();
// Create mailer
$mail = new \PHPMailer();
// Configure mailer
$mail->isSMTP();
$mail->Host = \nre\configs\AppConfig::$mail['host'];
$mail->Port = \nre\configs\AppConfig::$mail['port'];
$mail->SMTPAuth = true;
$mail->Username = \nre\configs\AppConfig::$mail['username'];
$mail->Password = \nre\configs\AppConfig::$mail['password'];
$mail->SMTPSecure = \nre\configs\AppConfig::$mail['secure'];
// Configure mailer
$mail->isSMTP();
$mail->Host = \nre\configs\AppConfig::$mail['host'];
$mail->Port = \nre\configs\AppConfig::$mail['port'];
$mail->SMTPAuth = true;
$mail->Username = \nre\configs\AppConfig::$mail['username'];
$mail->Password = \nre\configs\AppConfig::$mail['password'];
$mail->SMTPSecure = \nre\configs\AppConfig::$mail['secure'];
// Set properties
$mail->CharSet = 'UTF-8';
$mail->From = \nre\configs\AppConfig::$app['mailsender'];
$mail->FromName = \nre\configs\AppConfig::$app['name'];
if(!is_array($to)) {
$to = array($to);
}
foreach($to as &$receiver) {
$mail->addAddress($receiver);
}
if($html) {
$mail->isHTML(true);
}
// Set properties
$mail->CharSet = 'UTF-8';
$mail->From = \nre\configs\AppConfig::$app['mailsender'];
$mail->FromName = \nre\configs\AppConfig::$app['name'];
if(!is_array($to)) {
$to = array($to);
}
foreach($to as &$receiver) {
$mail->addAddress($receiver);
}
if($html) {
$mail->isHTML(true);
}
// Create message
try {
// Create MailApi
$mailApi = new \hhu\z\apis\MailApi();
if(!is_null($linker)) {
$mailApi->setLinker($linker);
}
$mailApi->setMessage($messageAction);
$mailApi->setParams($params);
if($html) {
$mailApi->setHTML();
}
// Create message
try {
// Create MailApi
$mailApi = new \hhu\z\apis\MailApi();
if(!is_null($linker)) {
$mailApi->setLinker($linker);
}
$mailApi->setMessage($messageAction);
$mailApi->setParams($params);
if($html) {
$mailApi->setHTML();
}
// Render message
$exception = $mailApi->run();
if(!is_null($exception)) {
return $exception;
}
$mail->Subject = $mailApi->getSubject();
$mail->Body = $mailApi->render();
// Render message
$exception = $mailApi->run();
if(!is_null($exception)) {
return $exception;
}
$mail->Subject = $mailApi->getSubject();
$mail->Body = $mailApi->render();
// Try to render alternativ plaintext message
if($html)
{
$mailApi->setHTML(false);
// Try to render alternativ plaintext message
if($html)
{
$mailApi->setHTML(false);
// Render message
$exception = $mailApi->run();
if(is_null($exception))
{
try {
$mail->AltBody = $mailApi->render();
}
catch(\nre\core\Exception $e) {
// No alternative plaintext available
}
}
}
}
catch(\nre\core\Exception $e) {
throw new \hhu\z\exceptions\MailingException($e->getMessage());
}
// Render message
$exception = $mailApi->run();
if(is_null($exception))
{
try {
$mail->AltBody = $mailApi->render();
}
catch(\nre\core\Exception $e) {
// No alternative plaintext available
}
}
}
}
catch(\nre\core\Exception $e) {
throw new \hhu\z\exceptions\MailingException($e->getMessage());
}
// Return status
if(!$mail->send()) {
throw new \hhu\z\exceptions\MailingException($mail->ErrorInfo);
}
}
// Return status
if(!$mail->send()) {
throw new \hhu\z\exceptions\MailingException($mail->ErrorInfo);
}
}
/**
* Detect Mimetype of a file.
*
* @param string $filename Name of file to detect Mimetype of
* @param string $defaultMimetype Default Mimetype to use
* @return string Detected Mimetype of file
*/
public static function getMimetype($filename, $defaultMimetype=null)
{
$mimetype = (!is_null($defaultMimetype)) ? $defaultMimetype : 'application/octet-stream';
// Use Fileinfo
if(class_exists('\finfo'))
{
$finfo = new \finfo(FILEINFO_MIME_TYPE);
if(!is_null($finfo)) {
$mimetype = $finfo->file($filename);
}
}
// Use deprecated mime_content_type()
elseif(function_exists('mime_content_type')) {
$mimetype = mime_content_type($filename);
}
/**
* Detect Mimetype of a file.
*
* @param string $filename Name of file to detect Mimetype of
* @param string $defaultMimetype Default Mimetype to use
* @return string Detected Mimetype of file
*/
public static function getMimetype($filename, $defaultMimetype=null)
{
$mimetype = (!is_null($defaultMimetype)) ? $defaultMimetype : 'application/octet-stream';
// Use Fileinfo
if(class_exists('\finfo'))
{
$finfo = new \finfo(FILEINFO_MIME_TYPE);
if(!is_null($finfo)) {
$mimetype = $finfo->file($filename);
}
}
// Use deprecated mime_content_type()
elseif(function_exists('mime_content_type')) {
$mimetype = mime_content_type($filename);
}
return $mimetype;
}
return $mimetype;
}
}
}
?>

View file

@ -1,268 +1,268 @@
<?php
/**
* The Legend of Z
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
* @license http://www.gnu.org/licenses/gpl.html
* @link https://bitbucket.org/coderkun/the-legend-of-z
*/
/**
* The Legend of Z
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
* @license http://www.gnu.org/licenses/gpl.html
* @link https://bitbucket.org/coderkun/the-legend-of-z
*/
namespace hhu\z\agents;
namespace hhu\z\agents;
/**
* Abstract class for implementing a QuesttypeAgent.
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
*/
abstract class QuesttypeAgent extends \nre\agents\BottomlevelAgent
{
/**
* Current request
*
* @var \nre\core\Request
*/
private $request;
/**
* Current response
*
* @var \nre\core\Response
*/
private $response;
/**
* Abstract class for implementing a QuesttypeAgent.
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
*/
abstract class QuesttypeAgent extends \nre\agents\BottomlevelAgent
{
/**
* Current request
*
* @var \nre\core\Request
*/
private $request;
/**
* Current response
*
* @var \nre\core\Response
*/
private $response;
/**
* Load a QuesttypeAgent.
*
* @static
* @throws \hhu\z\exceptions\QuesttypeAgentNotFoundException
* @throws \hhu\z\exceptions\QuesttypeAgentNotValidException
* @param string $questtypeName Name of the QuesttypeAgent to load
*/
public static function load($questtypeName)
{
// Determine full classname
$className = self::getClassName($questtypeName);
/**
* Load a QuesttypeAgent.
*
* @static
* @throws \hhu\z\exceptions\QuesttypeAgentNotFoundException
* @throws \hhu\z\exceptions\QuesttypeAgentNotValidException
* @param string $questtypeName Name of the QuesttypeAgent to load
*/
public static function load($questtypeName)
{
// Determine full classname
$className = self::getClassName($questtypeName);
try {
// Load class
static::loadClass($questtypeName, $className);
try {
// Load class
static::loadClass($questtypeName, $className);
// Validate class
static::checkClass($className, get_class());
}
catch(\nre\exceptions\ClassNotValidException $e) {
throw new \hhu\z\exceptions\QuesttypeAgentNotValidException($e->getClassName());
}
catch(\nre\exceptions\ClassNotFoundException $e) {
throw new \hhu\z\exceptions\QuesttypeAgentNotFoundException($e->getClassName());
}
}
// Validate class
static::checkClass($className, get_class());
}
catch(\nre\exceptions\ClassNotValidException $e) {
throw new \hhu\z\exceptions\QuesttypeAgentNotValidException($e->getClassName());
}
catch(\nre\exceptions\ClassNotFoundException $e) {
throw new \hhu\z\exceptions\QuesttypeAgentNotFoundException($e->getClassName());
}
}
/**
* Instantiate a QuesttypeAgent (Factory Pattern).
*
* @static
* @throws \nre\exceptions\DatamodelException
* @throws \nre\exceptions\DriverNotValidException
* @throws \nre\exceptions\DriverNotFoundException
* @throws \nre\exceptions\ViewNotFoundException
* @throws \hhu\z\exceptions\QuesttypeModelNotValidException
* @throws \hhu\z\exceptions\QuesttypeModelNotFoundException
* @throws \hhu\z\exceptions\QuesttypeControllerNotValidException
* @throws \hhu\z\exceptions\QuesttypeControllerNotFoundException
* @param string $questtypeName Name of the QuesttypeAgent to instantiate
* @param Request $request Current request
* @param Response $response Current respone
* @param Logger $log Log-system
*/
public static function factory($questtypeName, \nre\core\Request $request, \nre\core\Response $response, \nre\core\Logger $log=null)
{
// Determine full classname
$className = self::getClassName($questtypeName);
/**
* Instantiate a QuesttypeAgent (Factory Pattern).
*
* @static
* @throws \nre\exceptions\DatamodelException
* @throws \nre\exceptions\DriverNotValidException
* @throws \nre\exceptions\DriverNotFoundException
* @throws \nre\exceptions\ViewNotFoundException
* @throws \hhu\z\exceptions\QuesttypeModelNotValidException
* @throws \hhu\z\exceptions\QuesttypeModelNotFoundException
* @throws \hhu\z\exceptions\QuesttypeControllerNotValidException
* @throws \hhu\z\exceptions\QuesttypeControllerNotFoundException
* @param string $questtypeName Name of the QuesttypeAgent to instantiate
* @param Request $request Current request
* @param Response $response Current respone
* @param Logger $log Log-system
*/
public static function factory($questtypeName, \nre\core\Request $request, \nre\core\Response $response, \nre\core\Logger $log=null)
{
// Determine full classname
$className = self::getClassName($questtypeName);
// Construct and return Questmodule
return new $className($request, $response, $log);
}
// Construct and return Questmodule
return new $className($request, $response, $log);
}
/**
* Determine the Agent-classname for the given Questtype-name.
*
* @static
* @param string $questtypeName Questtype-name to get Agent-classname of
* @param string $agentType Agent type of given Agent name
* @return string Classname for the Questtype-name
*/
private static function getClassName($questtypeName, $agentType=null)
{
$className = \nre\core\ClassLoader::concatClassNames($questtypeName, \nre\core\ClassLoader::stripClassType(\nre\core\ClassLoader::stripNamespace(get_class())), 'agent');
/**
* Determine the Agent-classname for the given Questtype-name.
*
* @static
* @param string $questtypeName Questtype-name to get Agent-classname of
* @param string $agentType Agent type of given Agent name
* @return string Classname for the Questtype-name
*/
private static function getClassName($questtypeName, $agentType=null)
{
$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.
*
* @static
* @throws \nre\exceptions\ClassNotFoundException
* @param string $questtypeName Name of the QuesttypeAgent to load
* @param string $fullClassName Name of the class to load
*/
private static function loadClass($questtypeName, $fullClassName)
{
// Determine folder to look in
$className = explode('\\', $fullClassName);
$className = array_pop($className);
/**
* Load the class of a QuesttypeAgent.
*
* @static
* @throws \nre\exceptions\ClassNotFoundException
* @param string $questtypeName Name of the QuesttypeAgent to load
* @param string $fullClassName Name of the class to load
*/
private static function loadClass($questtypeName, $fullClassName)
{
// Determine folder to look in
$className = explode('\\', $fullClassName);
$className = array_pop($className);
// Determine filename
$fileName = ROOT.DS.\nre\configs\AppConfig::$dirs['questtypes'].DS.strtolower($questtypeName).DS.$className.\nre\configs\CoreConfig::getFileExt('includes');
// Determine filename
$fileName = ROOT.DS.\nre\configs\AppConfig::$dirs['questtypes'].DS.strtolower($questtypeName).DS.$className.\nre\configs\CoreConfig::getFileExt('includes');
// Check file
if(!file_exists($fileName))
{
throw new \nre\exceptions\ClassNotFoundException(
$fullClassName
);
}
// Check file
if(!file_exists($fileName))
{
throw new \nre\exceptions\ClassNotFoundException(
$fullClassName
);
}
// Include file
include_once($fileName);
}
// Include file
include_once($fileName);
}
/**
* Check inheritance of the QuesttypeAgent-class.
*
* @static
* @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)
{
// Check if class is subclass of parent class
if(!is_subclass_of($className, $parentClassName)) {
throw new \nre\exceptions\ClassNotValidException(
$className
);
}
}
/**
* Check inheritance of the QuesttypeAgent-class.
*
* @static
* @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)
{
// Check if class is subclass of parent class
if(!is_subclass_of($className, $parentClassName)) {
throw new \nre\exceptions\ClassNotValidException(
$className
);
}
}
/**
* Construct a new QuesttypeAgent.
*
* @throws \nre\exceptions\DatamodelException
* @throws \nre\exceptions\DriverNotValidException
* @throws \nre\exceptions\DriverNotFoundException
* @throws \nre\exceptions\ViewNotFoundException
* @throws \nre\exceptions\ModelNotValidException
* @throws \nre\exceptions\ModelNotFoundException
* @throws \hhu\z\exceptions\QuesttypeModelNotValidException
* @throws \hhu\z\exceptions\QuesttypeModelNotFoundException
* @throws \hhu\z\exceptions\QuesttypeControllerNotValidException
* @throws \hhu\z\exceptions\QuesttypeControllerNotFoundException
* @param \nre\core\Request $request Current request
* @param \nre\core\Response $response Current response
* @param \nre\core\Logger $log Log-system
*/
protected function __construct(\nre\core\Request $request, \nre\core\Response $response, \nre\core\Logger $log=null)
{
// Store values
$this->request = $request;
$this->response = $response;
/**
* Construct a new QuesttypeAgent.
*
* @throws \nre\exceptions\DatamodelException
* @throws \nre\exceptions\DriverNotValidException
* @throws \nre\exceptions\DriverNotFoundException
* @throws \nre\exceptions\ViewNotFoundException
* @throws \nre\exceptions\ModelNotValidException
* @throws \nre\exceptions\ModelNotFoundException
* @throws \hhu\z\exceptions\QuesttypeModelNotValidException
* @throws \hhu\z\exceptions\QuesttypeModelNotFoundException
* @throws \hhu\z\exceptions\QuesttypeControllerNotValidException
* @throws \hhu\z\exceptions\QuesttypeControllerNotFoundException
* @param \nre\core\Request $request Current request
* @param \nre\core\Response $response Current response
* @param \nre\core\Logger $log Log-system
*/
protected function __construct(\nre\core\Request $request, \nre\core\Response $response, \nre\core\Logger $log=null)
{
// Store values
$this->request = $request;
$this->response = $response;
// Call parent constructor
parent::__construct($request, $response, $log);
}
// Call parent constructor
parent::__construct($request, $response, $log);
}
/**
* 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 function saveAnswersOfCharacter($seminary, $questgroup, $quest, $character, $answers)
{
$this->controller->saveAnswersOfCharacter($seminary, $questgroup, $quest, $character, $answers);
}
/**
* 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 function 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.
*
* @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 function matchAnswersOfCharacter($seminary, $questgroup, $quest, $character, $answers)
{
return $this->controller->matchAnswersOfCharacter($seminary, $questgroup, $quest, $character, $answers);
}
/**
* 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
*/
public function matchAnswersOfCharacter($seminary, $questgroup, $quest, $character, $answers)
{
return $this->controller->matchAnswersOfCharacter($seminary, $questgroup, $quest, $character, $answers);
}
/**
* Load the Controller of this Agent.
*
* @throws \nre\exceptions\DatamodelException
* @throws \nre\exceptions\DriverNotValidException
* @throws \nre\exceptions\DriverNotFoundException
* @throws \nre\exceptions\ViewNotFoundException
* @throws \nre\exceptions\ModelNotValidException
* @throws \nre\exceptions\ModelNotFoundException
* @throws \hhu\z\exceptions\QuesttypeModelNotValidException
* @throws \hhu\z\exceptions\QuesttypeModelNotFoundException
* @throws \hhu\z\exceptions\QuesttypeControllerNotValidException
* @throws \hhu\z\exceptions\QuesttypeControllerNotFoundException
*/
protected function loadController()
{
// Determine Controller name
$controllerName = \nre\core\ClassLoader::stripClassType(\nre\core\ClassLoader::getClassName(get_class($this)));
/**
* Load the Controller of this Agent.
*
* @throws \nre\exceptions\DatamodelException
* @throws \nre\exceptions\DriverNotValidException
* @throws \nre\exceptions\DriverNotFoundException
* @throws \nre\exceptions\ViewNotFoundException
* @throws \nre\exceptions\ModelNotValidException
* @throws \nre\exceptions\ModelNotFoundException
* @throws \hhu\z\exceptions\QuesttypeModelNotValidException
* @throws \hhu\z\exceptions\QuesttypeModelNotFoundException
* @throws \hhu\z\exceptions\QuesttypeControllerNotValidException
* @throws \hhu\z\exceptions\QuesttypeControllerNotFoundException
*/
protected function loadController()
{
// Determine Controller name
$controllerName = \nre\core\ClassLoader::stripClassType(\nre\core\ClassLoader::getClassName(get_class($this)));
// Determine ToplevelAgent
$toplevelAgentName = $this->response->getParam(0);
if(is_null($toplevelAgentName)) {
$toplevelAgentName = $this->request->getParam(0, 'toplevel');
$this->response->addParam($toplevelAgentName);
}
// Determine ToplevelAgent
$toplevelAgentName = $this->response->getParam(0);
if(is_null($toplevelAgentName)) {
$toplevelAgentName = $this->request->getParam(0, 'toplevel');
$this->response->addParam($toplevelAgentName);
}
// Determine Action
$action = $this->response->getParam(2);
if(is_null($action)) {
$action = $this->request->getParam(2, 'action');
$this->response->addParam($action);
}
// Determine Action
$action = $this->response->getParam(2);
if(is_null($action)) {
$action = $this->request->getParam(2, 'action');
$this->response->addParam($action);
}
// Load Controller
\hhu\z\controllers\QuesttypeController::load($controllerName);
// Load Controller
\hhu\z\controllers\QuesttypeController::load($controllerName);
// Construct Controller
$this->controller = \hhu\z\controllers\QuesttypeController::factory($controllerName, $toplevelAgentName, $action, $this);
}
// Construct Controller
$this->controller = \hhu\z\controllers\QuesttypeController::factory($controllerName, $toplevelAgentName, $action, $this);
}
}
}
?>

View file

@ -1,43 +1,43 @@
<?php
/**
* The Legend of Z
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
* @license http://www.gnu.org/licenses/gpl.html
* @link https://bitbucket.org/coderkun/the-legend-of-z
*/
/**
* The Legend of Z
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
* @license http://www.gnu.org/licenses/gpl.html
* @link https://bitbucket.org/coderkun/the-legend-of-z
*/
namespace hhu\z\agents;
namespace hhu\z\agents;
/**
* Abstract class for implementing an application Controller.
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
*/
abstract class ToplevelAgent extends \nre\agents\ToplevelAgent
{
/**
* Abstract class for implementing an application Controller.
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
*/
abstract class ToplevelAgent extends \nre\agents\ToplevelAgent
{
/**
* Construct a new ToplevlAgent
*
* @param \nre\core\Request $request Current request
* @param \nre\core\Response $response Current response
* @param \nre\core\Logger $log Logger instance
*/
protected function __construct(\nre\core\Request $request, \nre\core\Response $response, \nre\core\Logger $log=null)
{
parent::__construct($request, $response, $log);
/**
* Construct a new ToplevlAgent
*
* @param \nre\core\Request $request Current request
* @param \nre\core\Response $response Current response
* @param \nre\core\Logger $log Logger instance
*/
protected function __construct(\nre\core\Request $request, \nre\core\Response $response, \nre\core\Logger $log=null)
{
parent::__construct($request, $response, $log);
// Set timezone
date_default_timezone_set(\nre\configs\AppConfig::$app['timeZone']);
}
}
// Set timezone
date_default_timezone_set(\nre\configs\AppConfig::$app['timeZone']);
}
}
?>

View file

@ -1,202 +1,202 @@
<?php
/**
* The Legend of Z
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
* @license http://www.gnu.org/licenses/gpl.html
* @link https://bitbucket.org/coderkun/the-legend-of-z
*/
/**
* The Legend of Z
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
* @license http://www.gnu.org/licenses/gpl.html
* @link https://bitbucket.org/coderkun/the-legend-of-z
*/
namespace hhu\z\apis;
namespace hhu\z\apis;
/**
* MailApi-implementation.
*
* This class runs and renders email text and subject.
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
*/
class MailApi extends \nre\core\Api
{
/**
* MailApi-implementation.
*
* This class runs and renders email text and subject.
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
*/
class MailApi extends \nre\core\Api
{
/**
* Construct a new MailApi.
*/
public function __construct()
{
parent::__construct(
new \hhu\z\requests\MailRequest(),
new \hhu\z\responses\MailResponse()
);
/**
* Construct a new MailApi.
*/
public function __construct()
{
parent::__construct(
new \hhu\z\requests\MailRequest(),
new \hhu\z\responses\MailResponse()
);
// Set ToplevelAgent
$this->request->addParam(\nre\configs\AppConfig::$defaults['toplevel-mail']);
$this->request->addParam(\nre\configs\AppConfig::$defaults['intermediate-mail']);
}
// Set ToplevelAgent
$this->request->addParam(\nre\configs\AppConfig::$defaults['toplevel-mail']);
$this->request->addParam(\nre\configs\AppConfig::$defaults['intermediate-mail']);
}
/**
* Set linker instance for creating links.
*
* @param \nre\core\Linker $linker Linker instance for creating links
*/
public function setLinker(\nre\core\Linker $linker)
{
$this->request->setLinker($linker);
}
/**
* Set linker instance for creating links.
*
* @param \nre\core\Linker $linker Linker instance for creating links
*/
public function setLinker(\nre\core\Linker $linker)
{
$this->request->setLinker($linker);
}
/**
* Use a ToplevelAgent for HTML-mail
*
* @param bool $html Whether to use HTML or not
*/
public function setHTML($html=true)
{
// Save params
$params = $this->request->getParams(1);
/**
* Use a ToplevelAgent for HTML-mail
*
* @param bool $html Whether to use HTML or not
*/
public function setHTML($html=true)
{
// Save params
$params = $this->request->getParams(1);
// Set ToplevelAgent
$this->request->clearParams();
if($html) {
$this->request->addParam(\nre\configs\AppConfig::$defaults['toplevel-htmlmail']);
}
else {
$this->request->addParam(\nre\configs\AppConfig::$defaults['toplevel-mail']);
}
// Set ToplevelAgent
$this->request->clearParams();
if($html) {
$this->request->addParam(\nre\configs\AppConfig::$defaults['toplevel-htmlmail']);
}
else {
$this->request->addParam(\nre\configs\AppConfig::$defaults['toplevel-mail']);
}
// Restore params
if(!empty($params)) {
$this->addParams($params);
}
}
// Restore params
if(!empty($params)) {
$this->addParams($params);
}
}
/**
* Set the Action for the message to render.
*
* @param string $messageAgent Agent to handle the message
*/
public function setMessage($messageAgent)
{
// Save params
$params = $this->request->getParams(3);
/**
* Set the Action for the message to render.
*
* @param string $messageAgent Agent to handle the message
*/
public function setMessage($messageAgent)
{
// Save params
$params = $this->request->getParams(3);
// Set messageAgent
$this->request->clearParams(2);
$this->request->addParam($messageAgent);
// Set messageAgent
$this->request->clearParams(2);
$this->request->addParam($messageAgent);
// Restore params
if(!empty($params)) {
$this->addParams($params);
}
}
// Restore params
if(!empty($params)) {
$this->addParams($params);
}
}
/**
* Set additional params to pass to the Action.
*
* @param array $params Additional params to set
*/
public function setParams($params)
{
// Add placeholder params
for($i=3; $i<count($this->request->getParams()); $i++) {
$this->request->addParam(null);
}
/**
* Set additional params to pass to the Action.
*
* @param array $params Additional params to set
*/
public function setParams($params)
{
// Add placeholder params
for($i=3; $i<count($this->request->getParams()); $i++) {
$this->request->addParam(null);
}
// Set params
call_user_func_array(
array(
$this->request,
'addParams'
),
$params
);
}
// Set params
call_user_func_array(
array(
$this->request,
'addParams'
),
$params
);
}
/**
* Return the subject set by the Controller.
*
* @return string Subject set by Controller
*/
public function getSubject()
{
return $this->response->getSubject();
}
/**
* Return the subject set by the Controller.
*
* @return string Subject set by Controller
*/
public function getSubject()
{
return $this->response->getSubject();
}
/**
* Run mailtext generation.
*
* This method runs the generation of mailtext.
*
* @return \Exception Occured exception or null
*/
public function run()
{
// Set response
$this->response->clearParams();
foreach($this->request->getParams() as $param) {
$this->response->addParam($param);
}
/**
* Run mailtext generation.
*
* This method runs the generation of mailtext.
*
* @return \Exception Occured exception or null
*/
public function run()
{
// Set response
$this->response->clearParams();
foreach($this->request->getParams() as $param) {
$this->response->addParam($param);
}
// Run
try {
$exception = parent::run();
// Run
try {
$exception = parent::run();
return $exception;
}
catch(\nre\Exception $e) {
return $e;
}
}
return $exception;
}
catch(\nre\Exception $e) {
return $e;
}
}
/**
* Render output.
*
* @return string Rendered output
*/
public function render()
{
// Generate output
parent::render();
/**
* Render output.
*
* @return string Rendered output
*/
public function render()
{
// Generate output
parent::render();
// Return output
return $this->response->getOutput();
}
// Return output
return $this->response->getOutput();
}
/**
* Add multiple request params.
*
* @param array $params Request params to add
*/
private function addParams($params)
{
call_user_func_array(
array(
$this->request,
'addParams'
),
$params
);
}
/**
* Add multiple request params.
*
* @param array $params Request params to add
*/
private function addParams($params)
{
call_user_func_array(
array(
$this->request,
'addParams'
),
$params
);
}
}
}
?>

View file

@ -1,197 +1,197 @@
<?php
/**
* The Legend of Z
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
* @license http://www.gnu.org/licenses/gpl.html
* @link https://bitbucket.org/coderkun/the-legend-of-z
*/
/**
* The Legend of Z
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
* @license http://www.gnu.org/licenses/gpl.html
* @link https://bitbucket.org/coderkun/the-legend-of-z
*/
namespace hhu\z\controllers;
namespace hhu\z\controllers;
/**
* Abstract class for implementing a Controller of an IntermediateAgent.
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
*/
abstract class IntermediateController extends \hhu\z\Controller
{
/**
* Required models
*
* @var array
*/
public $models = array('users', 'userroles', 'seminaries', 'characters');
/**
* Current user
*
* @var array
*/
public static $user = null;
/**
* Title information
*
* @var array
*/
private $title = array();
/**
* Abstract class for implementing a Controller of an IntermediateAgent.
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
*/
abstract class IntermediateController extends \hhu\z\Controller
{
/**
* Required models
*
* @var array
*/
public $models = array('users', 'userroles', 'seminaries', 'characters');
/**
* Current user
*
* @var array
*/
public static $user = null;
/**
* Title information
*
* @var array
*/
private $title = array();
/**
* Construct a new IntermediateController.
*
* @throws \nre\exceptions\DriverNotFoundException
* @throws \nre\exceptions\DriverNotValidException
* @throws \nre\exceptions\ModelNotValidException
* @throws \nre\exceptions\ModelNotFoundException
* @throws \nre\exceptions\ViewNotFoundException
* @param string $layoutName Name of the current Layout
* @param string $action Current Action
* @param \nre\core\Agent $agent Corresponding Agent
*/
public function __construct($layoutName, $action, $agent)
{
parent::__construct($layoutName, $action, $agent);
}
/**
* Construct a new IntermediateController.
*
* @throws \nre\exceptions\DriverNotFoundException
* @throws \nre\exceptions\DriverNotValidException
* @throws \nre\exceptions\ModelNotValidException
* @throws \nre\exceptions\ModelNotFoundException
* @throws \nre\exceptions\ViewNotFoundException
* @param string $layoutName Name of the current Layout
* @param string $action Current Action
* @param \nre\core\Agent $agent Corresponding Agent
*/
public function __construct($layoutName, $action, $agent)
{
parent::__construct($layoutName, $action, $agent);
}
/**
* Prefilter that is executed before running the Controller.
*
* @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);
/**
* Prefilter that is executed before running the Controller.
*
* @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);
// Get userdata
try {
self::$user = $this->Users->getUserById($this->Auth->getUserId());
self::$user['roles'] = array_map(function($r) { return $r['name']; }, $this->Userroles->getUserrolesForUserById(self::$user['id']));
}
catch(\nre\exceptions\IdNotFoundException $e) {
}
// Get userdata
try {
self::$user = $this->Users->getUserById($this->Auth->getUserId());
self::$user['roles'] = array_map(function($r) { return $r['name']; }, $this->Userroles->getUserrolesForUserById(self::$user['id']));
}
catch(\nre\exceptions\IdNotFoundException $e) {
}
// Check permissions
$this->checkPermission($request, $response);
// Check permissions
$this->checkPermission($request, $response);
// Set userdata
$this->set('loggedUser', self::$user);
}
// Set userdata
$this->set('loggedUser', self::$user);
}
/**
* Postfilter that is executed after running the Controller.
*
* @param \nre\core\Request $request Current request
* @param \nre\core\Response $response Current response
*/
public function postFilter(\nre\core\Request $request, \nre\core\Response $response)
{
parent::postFilter($request, $response);
}
/**
* Postfilter that is executed after running the Controller.
*
* @param \nre\core\Request $request Current request
* @param \nre\core\Response $response Current response
*/
public function postFilter(\nre\core\Request $request, \nre\core\Response $response)
{
parent::postFilter($request, $response);
}
/**
* Return current title information.
*
* @return string Title information
*/
public function getTitle()
{
return $this->title;
}
/**
* Return current title information.
*
* @return string Title information
*/
public function getTitle()
{
return $this->title;
}
/**
* Add a piece of information to the current title.
*
* @param string $title Title information
*/
protected function addTitle($title)
{
$this->title[] = $title;
}
/**
* Add a piece of information to the current title.
*
* @param string $title Title information
*/
protected function addTitle($title)
{
$this->title[] = $title;
}
/**
* Add a piece of information to the current title and localize
* it.
*
* @param string $title Title information
*/
protected function addTitleLocalized($title)
{
$title = gettext($title);
/**
* Add a piece of information to the current title and localize
* it.
*
* @param string $title Title information
*/
protected function addTitleLocalized($title)
{
$title = gettext($title);
$args = func_get_args();
if(count($args) > 0) {
$title = call_user_func_array(
'sprintf',
array_merge(
array($title),
array_slice($args, 1)
)
);
}
$args = func_get_args();
if(count($args) > 0) {
$title = call_user_func_array(
'sprintf',
array_merge(
array($title),
array_slice($args, 1)
)
);
}
$this->title[] = $title;
}
$this->title[] = $title;
}
/**
* Check user permissions.
*
* @throws \nre\exceptions\AccessDeniedException
* @param \nre\core\Request $request Current request
* @param \nre\core\Response $response Current response
*/
private function checkPermission(\nre\core\Request $request, \nre\core\Response $response)
{
// Determine user
$userRoles = array('guest');
if(!is_null(self::$user)) {
$userRoles = self::$user['roles'];
}
/**
* Check user permissions.
*
* @throws \nre\exceptions\AccessDeniedException
* @param \nre\core\Request $request Current request
* @param \nre\core\Response $response Current response
*/
private function checkPermission(\nre\core\Request $request, \nre\core\Response $response)
{
// Determine user
$userRoles = array('guest');
if(!is_null(self::$user)) {
$userRoles = self::$user['roles'];
}
// Do not check error pages
if($response->getParam(0, 'toplevel') == \nre\core\Config::getDefault('toplevel-error')) {
return;
}
if($response->getParam(1, 'intermediate') == \nre\core\Config::getDefault('intermediate-error')) {
return;
}
// Do not check error pages
if($response->getParam(0, 'toplevel') == \nre\core\Config::getDefault('toplevel-error')) {
return;
}
if($response->getParam(1, 'intermediate') == \nre\core\Config::getDefault('intermediate-error')) {
return;
}
// Determine permissions of Intermediate Controller for current action
$controller = $this->agent->controller;
$action = $this->request->getParam(2, 'action');
if(!property_exists($controller, 'permissions')) {
return; // Allow if nothing is specified
}
if(!array_key_exists($action, $controller->permissions)) {
return; // Allow if Action is not specified
}
$permissions = $controller->permissions[$action];
// Determine permissions of Intermediate Controller for current action
$controller = $this->agent->controller;
$action = $this->request->getParam(2, 'action');
if(!property_exists($controller, 'permissions')) {
return; // Allow if nothing is specified
}
if(!array_key_exists($action, $controller->permissions)) {
return; // Allow if Action is not specified
}
$permissions = $controller->permissions[$action];
// Check permissions
if(count(array_intersect($userRoles, $permissions)) == 0) {
throw new \nre\exceptions\AccessDeniedException();
}
}
// Check permissions
if(count(array_intersect($userRoles, $permissions)) == 0) {
throw new \nre\exceptions\AccessDeniedException();
}
}
}
}
?>

View file

@ -1,320 +1,320 @@
<?php
/**
* The Legend of Z
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
* @license http://www.gnu.org/licenses/gpl.html
* @link https://bitbucket.org/coderkun/the-legend-of-z
*/
/**
* The Legend of Z
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
* @license http://www.gnu.org/licenses/gpl.html
* @link https://bitbucket.org/coderkun/the-legend-of-z
*/
namespace hhu\z\controllers;
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');
/**
* 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 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);
/**
* 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);
/**
* 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: 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: 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.
*
* Edit the task of a Quest.
*
* @param array $seminary Current Seminary data
* @param array $questgroup Current Questgroup data
* @param array $quest Current Quest data
*/
public abstract function edittask($seminary, $questgroup, $quest);
/**
* Action: edittask.
*
* Edit the task of a Quest.
*
* @param array $seminary Current Seminary data
* @param array $questgroup Current Questgroup data
* @param array $quest Current Quest data
*/
public abstract function edittask($seminary, $questgroup, $quest);
/**
* Load a QuesttypeController.
*
* @static
* @throws \hhu\z\exceptions\QuesttypeControllerNotFoundException
* @throws \hhu\z\exceptions\QuesttypeControllerNotValidException
* @param string $controllerName Name of the QuesttypeController to load
*/
public static function load($controllerName)
{
// Determine full classname
$className = self::getClassName($controllerName);
/**
* Load a QuesttypeController.
*
* @static
* @throws \hhu\z\exceptions\QuesttypeControllerNotFoundException
* @throws \hhu\z\exceptions\QuesttypeControllerNotValidException
* @param string $controllerName Name of the QuesttypeController to load
*/
public static function load($controllerName)
{
// Determine full classname
$className = self::getClassName($controllerName);
try {
// Load class
static::loadClass($controllerName, $className);
try {
// Load class
static::loadClass($controllerName, $className);
// Validate class
static::checkClass($className, get_class());
}
catch(\nre\exceptions\ClassNotValidException $e) {
throw new \hhu\z\exceptions\QuesttypeControllerNotValidException($e->getClassName());
}
catch(\nre\exceptions\ClassNotFoundException $e) {
throw new \hhu\z\exceptions\QuesttypeControllerNotFoundException($e->getClassName());
}
}
// Validate class
static::checkClass($className, get_class());
}
catch(\nre\exceptions\ClassNotValidException $e) {
throw new \hhu\z\exceptions\QuesttypeControllerNotValidException($e->getClassName());
}
catch(\nre\exceptions\ClassNotFoundException $e) {
throw new \hhu\z\exceptions\QuesttypeControllerNotFoundException($e->getClassName());
}
}
/**
* Instantiate a QuesttypeController (Factory Pattern).
*
* @static
* @throws \nre\exceptions\DatamodelException
* @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
* @param string $action Current Action
* @param \nre\core\Agent $agent Corresponding Agent
*/
public static function factory($controllerName, $layoutName, $action, $agent)
{
// Determine full classname
$className = self::getClassName($controllerName);
/**
* Instantiate a QuesttypeController (Factory Pattern).
*
* @static
* @throws \nre\exceptions\DatamodelException
* @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
* @param string $action Current Action
* @param \nre\core\Agent $agent Corresponding Agent
*/
public static function factory($controllerName, $layoutName, $action, $agent)
{
// Determine full classname
$className = self::getClassName($controllerName);
// Construct and return Controller
return new $className($layoutName, $action, $agent);
}
// Construct and return Controller
return new $className($layoutName, $action, $agent);
}
/**
* Determine the Controller-classname for the given Questtype-name.
*
* @static
* @param string $questtypeName Questtype-name to get Controller-classname of
* @return string Classname for the Questtype-name
*/
private static function getClassName($questtypeName)
{
$className = \nre\core\ClassLoader::concatClassNames($questtypeName, \nre\core\ClassLoader::stripClassType(\nre\core\ClassLoader::stripNamespace(get_class())), 'controller');
/**
* Determine the Controller-classname for the given Questtype-name.
*
* @static
* @param string $questtypeName Questtype-name to get Controller-classname of
* @return string Classname for the Questtype-name
*/
private static function getClassName($questtypeName)
{
$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";
}
return \nre\configs\AppConfig::$app['namespace']."questtypes\\$className";
}
/**
* Load the class of a QuesttypeController
*
* @static
* @throws \nre\exceptions\ClassNotFoundException
* @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
$className = explode('\\', $fullClassName);
$className = array_pop($className);
/**
* Load the class of a QuesttypeController
*
* @static
* @throws \nre\exceptions\ClassNotFoundException
* @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
$className = explode('\\', $fullClassName);
$className = array_pop($className);
// Determine filename
$fileName = ROOT.DS.\nre\configs\AppConfig::$dirs['questtypes'].DS.strtolower($questtypeName).DS.$className.\nre\configs\CoreConfig::getFileExt('includes');
// Determine filename
$fileName = ROOT.DS.\nre\configs\AppConfig::$dirs['questtypes'].DS.strtolower($questtypeName).DS.$className.\nre\configs\CoreConfig::getFileExt('includes');
// Check file
if(!file_exists($fileName))
{
throw new \nre\exceptions\ClassNotFoundException(
$fullClassName
);
}
// Check file
if(!file_exists($fileName))
{
throw new \nre\exceptions\ClassNotFoundException(
$fullClassName
);
}
// Include file
include_once($fileName);
}
// Include file
include_once($fileName);
}
/**
* Check inheritance of the QuesttypeController-class.
*
* @static
* @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)
{
// Check if class is subclass of parent class
if(!is_subclass_of($className, $parentClassName)) {
throw new \nre\exceptions\ClassNotValidException(
$className
);
}
}
/**
* Check inheritance of the QuesttypeController-class.
*
* @static
* @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)
{
// Check if class is subclass of parent class
if(!is_subclass_of($className, $parentClassName)) {
throw new \nre\exceptions\ClassNotValidException(
$className
);
}
}
/**
* 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);
}
/**
* 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 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 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 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);
// Load class
\hhu\z\models\QuesttypeModel::load($model);
// Construct Model
$modelName = ucfirst(strtolower($model));
$this->$modelName = \hhu\z\models\QuesttypeModel::factory($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;
}
/**
* 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)));
// 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);
}
// Load view
$this->view = \hhu\z\views\QuesttypeView::loadAndFactory($layoutName, $controllerName, $action);
}
}
}
?>

View file

@ -1,328 +1,328 @@
<?php
/**
* The Legend of Z
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
* @license http://www.gnu.org/licenses/gpl.html
* @link https://bitbucket.org/coderkun/the-legend-of-z
*/
/**
* The Legend of Z
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
* @license http://www.gnu.org/licenses/gpl.html
* @link https://bitbucket.org/coderkun/the-legend-of-z
*/
namespace hhu\z\controllers;
namespace hhu\z\controllers;
/**
* Abstract class for implementing a Controller for a Seminary and its
* concepts.
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
*/
abstract class SeminaryController extends \hhu\z\controllers\IntermediateController
{
/**
* Required components
*
* @var array
*/
public $components = array('achievement', 'auth', 'notification');
/**
* Required models
*
* @var array
*/
public $models = array('seminaries', 'characters', 'characterroles', 'xplevels', 'avatars', 'achievements');
/**
* Current Seminary
*
* var array
*/
public static $seminary = null;
/**
* Character of current user and Seminary
*
* @var array
*/
public static $character = null;
/**
* Abstract class for implementing a Controller for a Seminary and its
* concepts.
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
*/
abstract class SeminaryController extends \hhu\z\controllers\IntermediateController
{
/**
* Required components
*
* @var array
*/
public $components = array('achievement', 'auth', 'notification');
/**
* Required models
*
* @var array
*/
public $models = array('seminaries', 'characters', 'characterroles', 'xplevels', 'avatars', 'achievements');
/**
* Current Seminary
*
* var array
*/
public static $seminary = null;
/**
* Character of current user and Seminary
*
* @var array
*/
public static $character = null;
/**
* Construct a new Seminary Controller.
*
* @throws \nre\exceptions\DriverNotFoundException
* @throws \nre\exceptions\DriverNotValidException
* @throws \nre\exceptions\ModelNotValidException
* @throws \nre\exceptions\ModelNotFoundException
* @throws \nre\exceptions\ViewNotFoundException
* @param string $layoutName Name of the current Layout
* @param string $action Current Action
* @param \nre\core\Agent $agent Corresponding Agent
*/
public function __construct($layoutName, $action, $agent)
{
parent::__construct($layoutName, $action, $agent);
}
/**
* Construct a new Seminary Controller.
*
* @throws \nre\exceptions\DriverNotFoundException
* @throws \nre\exceptions\DriverNotValidException
* @throws \nre\exceptions\ModelNotValidException
* @throws \nre\exceptions\ModelNotFoundException
* @throws \nre\exceptions\ViewNotFoundException
* @param string $layoutName Name of the current Layout
* @param string $action Current Action
* @param \nre\core\Agent $agent Corresponding Agent
*/
public function __construct($layoutName, $action, $agent)
{
parent::__construct($layoutName, $action, $agent);
}
/**
* Prefilter that is executed before running the Controller.
*
* @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);
/**
* Prefilter that is executed before running the Controller.
*
* @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);
// Get Seminary and Character data
try {
self::$seminary = $this->Seminaries->getSeminaryByUrl($this->request->getParam(3));
if(!is_null(self::$user))
{
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']));
try {
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']);
}
catch(\nre\exceptions\IdNotFoundException $e) {
// No Avatar available
}
}
}
catch(\nre\exceptions\IdNotFoundException $e) {
}
// Get Seminary and Character data
try {
self::$seminary = $this->Seminaries->getSeminaryByUrl($this->request->getParam(3));
if(!is_null(self::$user))
{
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']));
try {
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']);
}
catch(\nre\exceptions\IdNotFoundException $e) {
// No Avatar available
}
}
}
catch(\nre\exceptions\IdNotFoundException $e) {
}
// Check permissions
$this->checkPermission($request, $response);
// Check permissions
$this->checkPermission($request, $response);
// Check achievements
$this->checkAchievements($request, $response, 'date');
$this->checkAchievements($request, $response, 'achievement');
// Check achievements
$this->checkAchievements($request, $response, 'date');
$this->checkAchievements($request, $response, 'achievement');
// Set Seminary and Character data
$this->set('loggedSeminary', self::$seminary);
$this->set('loggedCharacter', self::$character);
}
// Set Seminary and Character data
$this->set('loggedSeminary', self::$seminary);
$this->set('loggedCharacter', self::$character);
}
/**
* Postfilter that is executed after running the Controller.
*
* @param \nre\core\Request $request Current request
* @param \nre\core\Response $response Current response
*/
public function postFilter(\nre\core\Request $request, \nre\core\Response $response)
{
parent::postFilter($request, $response);
}
/**
* Postfilter that is executed after running the Controller.
*
* @param \nre\core\Request $request Current request
* @param \nre\core\Response $response Current response
*/
public function postFilter(\nre\core\Request $request, \nre\core\Response $response)
{
parent::postFilter($request, $response);
}
/**
* Check user permissions.
*
* @throws AccessDeniedException
* @param \nre\core\Request $request Current request
* @param \nre\core\Response $response Current response
*/
private function checkPermission(\nre\core\Request $request, \nre\core\Response $response)
{
// Do not check index page
if(is_null($request->getParam(3))) {
return;
}
/**
* Check user permissions.
*
* @throws AccessDeniedException
* @param \nre\core\Request $request Current request
* @param \nre\core\Response $response Current response
*/
private function checkPermission(\nre\core\Request $request, \nre\core\Response $response)
{
// Do not check index page
if(is_null($request->getParam(3))) {
return;
}
// Determine permissions for current action
$action = $this->request->getParam(2, 'action');
if(!property_exists($this, 'seminaryPermissions')) {
return; // Allow if nothing is specified
}
if(!array_key_exists($action, $this->seminaryPermissions)) {
return; // Allow if Action is not specified
}
$permissions = $this->seminaryPermissions[$action];
// Determine permissions for current action
$action = $this->request->getParam(2, 'action');
if(!property_exists($this, 'seminaryPermissions')) {
return; // Allow if nothing is specified
}
if(!array_key_exists($action, $this->seminaryPermissions)) {
return; // Allow if Action is not specified
}
$permissions = $this->seminaryPermissions[$action];
// Check permissions
if(is_null(self::$character) || !array_key_exists('characterroles', self::$character) || count(array_intersect(self::$character['characterroles'], $permissions)) == 0) {
throw new \nre\exceptions\AccessDeniedException();
}
}
// Check permissions
if(is_null(self::$character) || !array_key_exists('characterroles', self::$character) || count(array_intersect(self::$character['characterroles'], $permissions)) == 0) {
throw new \nre\exceptions\AccessDeniedException();
}
}
/**
* Check for newly achieved Achievements.
*
* @param \nre\core\Request $request Current request
* @param \nre\core\Response $response Current response
* @param array $checkConditions Conditions to check
*/
protected function checkAchievements(\nre\core\Request $request, \nre\core\Response $response, $checkConditions=null)
{
// Do not check MediaController
if($this->request->getParam(0, 'toplevel') != \nre\configs\AppConfig::$defaults['toplevel']) {
return;
}
/**
* Check for newly achieved Achievements.
*
* @param \nre\core\Request $request Current request
* @param \nre\core\Response $response Current response
* @param array $checkConditions Conditions to check
*/
protected function checkAchievements(\nre\core\Request $request, \nre\core\Response $response, $checkConditions=null)
{
// Do not check MediaController
if($this->request->getParam(0, 'toplevel') != \nre\configs\AppConfig::$defaults['toplevel']) {
return;
}
// Check if Character is present
if(is_null(self::$character)) {
return;
}
// Check if Character is present
if(is_null(self::$character)) {
return;
}
// Set conditions to check
if(!is_null($checkConditions) && !is_array($checkConditions)) {
$checkConditions = array($checkConditions);
}
// Set conditions to check
if(!is_null($checkConditions) && !is_array($checkConditions)) {
$checkConditions = array($checkConditions);
}
// Get unachieved Achievments
$achievements = $this->Achievements->getUnachhievedAchievementsForCharacter(self::$seminary['id'], self::$character['id']);
if(in_array('user', self::$character['characterroles'])) {
$achievements = array_merge($achievements, $this->Achievements->getUnachievedOnlyOnceAchievementsForSeminary(self::$seminary['id']));
}
// Get unachieved Achievments
$achievements = $this->Achievements->getUnachhievedAchievementsForCharacter(self::$seminary['id'], self::$character['id']);
if(in_array('user', self::$character['characterroles'])) {
$achievements = array_merge($achievements, $this->Achievements->getUnachievedOnlyOnceAchievementsForSeminary(self::$seminary['id']));
}
// Check conditions
foreach($achievements as &$achievement)
{
// Check condition to test
if(!is_null($checkConditions) && !in_array($achievement['condition'], $checkConditions)) {
continue;
}
// Check conditions
foreach($achievements as &$achievement)
{
// Check condition to test
if(!is_null($checkConditions) && !in_array($achievement['condition'], $checkConditions)) {
continue;
}
// Check deadline
if(!is_null($achievement['deadline']) && $achievement['deadline'] < date('Y-m-d H:i:s')) {
continue;
}
// Check deadline
if(!is_null($achievement['deadline']) && $achievement['deadline'] < date('Y-m-d H:i:s')) {
continue;
}
// Get conditions
$conditions = array();
$progress = 0;
switch($achievement['condition'])
{
// Date conditions
case 'date':
$conditionsDate = $this->Achievements->getAchievementConditionsDate($achievement['id']);
foreach($conditionsDate as &$condition)
{
$conditions[] = array(
'func' => 'checkAchievementConditionDate',
'params' => array(
$condition['select']
)
);
}
break;
// Character conditions
case 'character':
$conditionsCharacter = $this->Achievements->getAchievementConditionsCharacter($achievement['id']);
foreach($conditionsCharacter as &$condition)
{
$conditions[] = array(
'func' => 'checkAchievementConditionCharacter',
'params' => array(
$condition['field'],
$condition['value'],
self::$character['id']
)
);
}
break;
// Quest conditions
case 'quest':
$conditionsQuest = $this->Achievements->getAchievementConditionsQuest($achievement['id']);
foreach($conditionsQuest as &$condition)
{
$conditions[] = array(
'func' => 'checkAchievementConditionQuest',
'params' => array(
$condition['field'],
$condition['count'],
$condition['value'],
$condition['status'],
$condition['groupby'],
$condition['quest_id'],
self::$character['id']
)
);
}
break;
// Achievement conditions
case 'achievement':
$conditionsAchievement = $this->Achievements->getAchievementConditionsAchievement($achievement['id']);
foreach($conditionsAchievement as &$condition)
{
$conditions[] = array(
'func' => 'checkAchievementConditionAchievement',
'params' => array(
$condition['field'],
$condition['count'],
$condition['value'],
$condition['groupby'],
$condition['meta_achievement_id'],
self::$character['id']
)
);
}
break;
}
// Get conditions
$conditions = array();
$progress = 0;
switch($achievement['condition'])
{
// Date conditions
case 'date':
$conditionsDate = $this->Achievements->getAchievementConditionsDate($achievement['id']);
foreach($conditionsDate as &$condition)
{
$conditions[] = array(
'func' => 'checkAchievementConditionDate',
'params' => array(
$condition['select']
)
);
}
break;
// Character conditions
case 'character':
$conditionsCharacter = $this->Achievements->getAchievementConditionsCharacter($achievement['id']);
foreach($conditionsCharacter as &$condition)
{
$conditions[] = array(
'func' => 'checkAchievementConditionCharacter',
'params' => array(
$condition['field'],
$condition['value'],
self::$character['id']
)
);
}
break;
// Quest conditions
case 'quest':
$conditionsQuest = $this->Achievements->getAchievementConditionsQuest($achievement['id']);
foreach($conditionsQuest as &$condition)
{
$conditions[] = array(
'func' => 'checkAchievementConditionQuest',
'params' => array(
$condition['field'],
$condition['count'],
$condition['value'],
$condition['status'],
$condition['groupby'],
$condition['quest_id'],
self::$character['id']
)
);
}
break;
// Achievement conditions
case 'achievement':
$conditionsAchievement = $this->Achievements->getAchievementConditionsAchievement($achievement['id']);
foreach($conditionsAchievement as &$condition)
{
$conditions[] = array(
'func' => 'checkAchievementConditionAchievement',
'params' => array(
$condition['field'],
$condition['count'],
$condition['value'],
$condition['groupby'],
$condition['meta_achievement_id'],
self::$character['id']
)
);
}
break;
}
// Do not achieve Achievements without conditions
if(empty($conditions)) {
continue;
}
// Do not achieve Achievements without conditions
if(empty($conditions)) {
continue;
}
// Check conditions
$achieved = ($achievement['all_conditions'] == 1);
foreach($conditions as &$condition)
{
// Calculate result of condition
$result = call_user_func_array(
array(
$this->Achievements,
$condition['func']
),
$condition['params']
);
// Check conditions
$achieved = ($achievement['all_conditions'] == 1);
foreach($conditions as &$condition)
{
// Calculate result of condition
$result = call_user_func_array(
array(
$this->Achievements,
$condition['func']
),
$condition['params']
);
// The overall result and abort if possible
if($achievement['all_conditions'])
{
if(!$result) {
$achieved = false;
break;
}
}
else
{
if($result) {
$achieved = true;
break;
}
}
// The overall result and abort if possible
if($achievement['all_conditions'])
{
if(!$result) {
$achieved = false;
break;
}
}
else
{
if($result) {
$achieved = true;
break;
}
}
}
}
// Achievement achieved
if($achieved)
{
// Set status
$this->Achievements->setAchievementAchieved($achievement['id'], self::$character['id']);
// Achievement achieved
if($achieved)
{
// Set status
$this->Achievements->setAchievementAchieved($achievement['id'], self::$character['id']);
// Add notification
$this->Notification->addNotification(
\hhu\z\controllers\components\NotificationComponent::TYPE_ACHIEVEMENT,
$achievement['title'],
$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)
);
}
}
}
// Add notification
$this->Notification->addNotification(
\hhu\z\controllers\components\NotificationComponent::TYPE_ACHIEVEMENT,
$achievement['title'],
$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)
);
}
}
}
}
}
?>

View file

@ -1,79 +1,79 @@
<?php
/**
* The Legend of Z
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
* @license http://www.gnu.org/licenses/gpl.html
* @link https://bitbucket.org/coderkun/the-legend-of-z
*/
/**
* The Legend of Z
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
* @license http://www.gnu.org/licenses/gpl.html
* @link https://bitbucket.org/coderkun/the-legend-of-z
*/
namespace hhu\z\exceptions;
namespace hhu\z\exceptions;
/**
* Exception: File copy went wrong
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
*/
class FileCopyException extends \nre\core\Exception
{
/**
* Error code
*
* @var int
*/
const CODE = 204;
/**
* Error message
*
* @var string
*/
const MESSAGE = 'File copy went wrong';
/**
* Exception: File copy went wrong
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
*/
class FileCopyException extends \nre\core\Exception
{
/**
* Error code
*
* @var int
*/
const CODE = 204;
/**
* Error message
*
* @var string
*/
const MESSAGE = 'File copy went wrong';
/**
* Nested error
*
* @var array
*/
private $nestedError;
/**
* Nested error
*
* @var array
*/
private $nestedError;
/**
* Construct a new exception.
*
* @param array $nestedError Nested error
* @param string $message Error message
* @param int $code Error code
*/
function __construct($nestedError, $message=self::MESSAGE, $code=self::CODE)
{
parent::__construct(
$message,
/**
* Construct a new exception.
*
* @param array $nestedError Nested error
* @param string $message Error message
* @param int $code Error code
*/
function __construct($nestedError, $message=self::MESSAGE, $code=self::CODE)
{
parent::__construct(
$message,
$code,
$nestedError['message']
);
);
// Store values
$this->nestedError = $nestedError;
}
// Store values
$this->nestedError = $nestedError;
}
/**
* Get nested error.
*
* @return Nested error
*/
public function getNestedError()
{
return $this->nestedError;
}
/**
* Get nested error.
*
* @return Nested error
*/
public function getNestedError()
{
return $this->nestedError;
}
}
}
?>

View file

@ -1,79 +1,79 @@
<?php
/**
* The Legend of Z
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
* @license http://www.gnu.org/licenses/gpl.html
* @link https://bitbucket.org/coderkun/the-legend-of-z
*/
/**
* The Legend of Z
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
* @license http://www.gnu.org/licenses/gpl.html
* @link https://bitbucket.org/coderkun/the-legend-of-z
*/
namespace hhu\z\exceptions;
namespace hhu\z\exceptions;
/**
* Exception: File upload went wrong
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
*/
class FileUploadException extends \nre\core\Exception
{
/**
* Error code
*
* @var int
*/
const CODE = 203;
/**
* Error message
*
* @var string
*/
const MESSAGE = 'File upload went wrong';
/**
* Exception: File upload went wrong
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
*/
class FileUploadException extends \nre\core\Exception
{
/**
* Error code
*
* @var int
*/
const CODE = 203;
/**
* Error message
*
* @var string
*/
const MESSAGE = 'File upload went wrong';
/**
* Nested message
*
* @var string
*/
private $nestedMessage;
/**
* Nested message
*
* @var string
*/
private $nestedMessage;
/**
* Construct a new exception.
*
* @param string $nestedMessage Nested message
* @param string $message Error message
* @param int $code Error code
*/
function __construct($nestedMessage=null, $message=self::MESSAGE, $code=self::CODE)
{
parent::__construct(
$message,
$code,
$nestedMessage
);
/**
* Construct a new exception.
*
* @param string $nestedMessage Nested message
* @param string $message Error message
* @param int $code Error code
*/
function __construct($nestedMessage=null, $message=self::MESSAGE, $code=self::CODE)
{
parent::__construct(
$message,
$code,
$nestedMessage
);
// Store values
$this->nestedMessage = $nestedMessage;
}
// Store values
$this->nestedMessage = $nestedMessage;
}
/**
* Get nested message.
*
* @return Nested message
*/
public function getNestedMessage()
{
return $this->nestedMessage;
}
/**
* Get nested message.
*
* @return Nested message
*/
public function getNestedMessage()
{
return $this->nestedMessage;
}
}
}
?>

View file

@ -1,79 +1,79 @@
<?php
/**
* The Legend of Z
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
* @license http://www.gnu.org/licenses/gpl.html
* @link https://bitbucket.org/coderkun/the-legend-of-z
*/
/**
* The Legend of Z
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
* @license http://www.gnu.org/licenses/gpl.html
* @link https://bitbucket.org/coderkun/the-legend-of-z
*/
namespace hhu\z\exceptions;
namespace hhu\z\exceptions;
/**
* Exception during sending of an email.
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
*/
class MailingException extends \nre\core\Exception
{
/**
* Error code
*
* @var int
*/
const CODE = 300;
/**
* Error message
*
* @var string
*/
const MESSAGE = 'Error sending email';
/**
* Exception during sending of an email.
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
*/
class MailingException extends \nre\core\Exception
{
/**
* Error code
*
* @var int
*/
const CODE = 300;
/**
* Error message
*
* @var string
*/
const MESSAGE = 'Error sending email';
/**
* Nested error message
*
* @var string
*/
private $error;
/**
* Nested error message
*
* @var string
*/
private $error;
/**
* Construct a new exception.
*
* @param int $error Nested error message
* @param string $message Error message
* @param int $code Error code
*/
function __construct($error, $message=self::MESSAGE, $code=self::CODE)
{
parent::__construct(
$message,
$code,
$error
);
/**
* Construct a new exception.
*
* @param int $error Nested error message
* @param string $message Error message
* @param int $code Error code
*/
function __construct($error, $message=self::MESSAGE, $code=self::CODE)
{
parent::__construct(
$message,
$code,
$error
);
// Store values
$this->error = $error;
}
// Store values
$this->error = $error;
}
/**
* Get nested error message.
*
* @return string Nested error message
*/
public function getError()
{
return $this->error;
}
/**
* Get nested error message.
*
* @return string Nested error message
*/
public function getError()
{
return $this->error;
}
}
}
?>

View file

@ -1,54 +1,54 @@
<?php
/**
* The Legend of Z
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
* @license http://www.gnu.org/licenses/gpl.html
* @link https://bitbucket.org/coderkun/the-legend-of-z
*/
/**
* The Legend of Z
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
* @license http://www.gnu.org/licenses/gpl.html
* @link https://bitbucket.org/coderkun/the-legend-of-z
*/
namespace hhu\z\exceptions;
namespace hhu\z\exceptions;
/**
* Exception: File exceeds size maximum.
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
*/
class MaxFilesizeException extends \nre\core\Exception
{
/**
* Error code
*
* @var int
*/
const CODE = 202;
/**
* Error message
*
* @var string
*/
const MESSAGE = 'File exceeds size maximum';
/**
* Exception: File exceeds size maximum.
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
*/
class MaxFilesizeException extends \nre\core\Exception
{
/**
* Error code
*
* @var int
*/
const CODE = 202;
/**
* Error message
*
* @var string
*/
const MESSAGE = 'File exceeds size maximum';
/**
* Construct a new exception.
*
* @param string $message Error message
* @param int $code Error code
*/
function __construct($message=self::MESSAGE, $code=self::CODE)
{
parent::__construct(
$message,
$code
);
}
/**
* Construct a new exception.
*
* @param string $message Error message
* @param int $code Error code
*/
function __construct($message=self::MESSAGE, $code=self::CODE)
{
parent::__construct(
$message,
$code
);
}
}
}
?>

View file

@ -1,79 +1,79 @@
<?php
/**
* The Legend of Z
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
* @license http://www.gnu.org/licenses/gpl.html
* @link https://bitbucket.org/coderkun/the-legend-of-z
*/
/**
* The Legend of Z
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
* @license http://www.gnu.org/licenses/gpl.html
* @link https://bitbucket.org/coderkun/the-legend-of-z
*/
namespace hhu\z\exceptions;
namespace hhu\z\exceptions;
/**
* Exception: QuesttypeAgent not found.
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
*/
class QuesttypeAgentNotFoundException extends \nre\core\Exception
{
/**
* Error code
*
* @var int
*/
const CODE = 101;
/**
* Error message
*
* @var string
*/
const MESSAGE = 'QuesttypeAgent not found';
/**
* Exception: QuesttypeAgent not found.
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
*/
class QuesttypeAgentNotFoundException extends \nre\core\Exception
{
/**
* Error code
*
* @var int
*/
const CODE = 101;
/**
* Error message
*
* @var string
*/
const MESSAGE = 'QuesttypeAgent not found';
/**
* Name of the class that was not found
*
* @var string
*/
private $questtypeName;
/**
* Name of the class that was not found
*
* @var string
*/
private $questtypeName;
/**
* Construct a new exception.
*
* @param string $questtypeName Name of the QuesttypeAgent that was not found
* @param string $message Error message
* @param int $code Error code
*/
function __construct($questtypeName, $message=self::MESSAGE, $code=self::CODE)
{
parent::__construct(
$message,
$code,
$questtypeName
);
/**
* Construct a new exception.
*
* @param string $questtypeName Name of the QuesttypeAgent that was not found
* @param string $message Error message
* @param int $code Error code
*/
function __construct($questtypeName, $message=self::MESSAGE, $code=self::CODE)
{
parent::__construct(
$message,
$code,
$questtypeName
);
// Store values
$this->questtypeName = $questtypeName;
}
// Store values
$this->questtypeName = $questtypeName;
}
/**
* Get the name of the QuesttypeAgent that was not found.
*
* @return string Name of the QuesttypeAgent that was not found
*/
public function getClassName()
{
return $this->questtypeName;
}
/**
* Get the name of the QuesttypeAgent that was not found.
*
* @return string Name of the QuesttypeAgent that was not found
*/
public function getClassName()
{
return $this->questtypeName;
}
}
}
?>

View file

@ -1,79 +1,79 @@
<?php
/**
* The Legend of Z
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
* @license http://www.gnu.org/licenses/gpl.html
* @link https://bitbucket.org/coderkun/the-legend-of-z
*/
/**
* The Legend of Z
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
* @license http://www.gnu.org/licenses/gpl.html
* @link https://bitbucket.org/coderkun/the-legend-of-z
*/
namespace hhu\z\exceptions;
namespace hhu\z\exceptions;
/**
* Exception: QuesttypeAgent not valid.
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
*/
class QuesttypeAgentNotValidException extends \nre\core\Exception
{
/**
* Error code
*
* @var int
*/
const CODE = 102;
/**
* Error message
*
* @var string
*/
const MESSAGE = 'QuesttypeAgent not valid';
/**
* Exception: QuesttypeAgent not valid.
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
*/
class QuesttypeAgentNotValidException extends \nre\core\Exception
{
/**
* Error code
*
* @var int
*/
const CODE = 102;
/**
* Error message
*
* @var string
*/
const MESSAGE = 'QuesttypeAgent not valid';
/**
* Name of the invalid class
*
* @var string
*/
private $questtypeName;
/**
* Name of the invalid class
*
* @var string
*/
private $questtypeName;
/**
* Construct a new exception.
*
* @param string $questtypeName Name of the invalid QuesttypeAgent
* @param string $message Error message
* @param int $code Error code
*/
function __construct($questtypeName, $message=self::MESSAGE, $code=self::CODE)
{
parent::__construct(
$message,
$code,
$questtypeName
);
/**
* Construct a new exception.
*
* @param string $questtypeName Name of the invalid QuesttypeAgent
* @param string $message Error message
* @param int $code Error code
*/
function __construct($questtypeName, $message=self::MESSAGE, $code=self::CODE)
{
parent::__construct(
$message,
$code,
$questtypeName
);
// Store value
$this->questtypeName = $questtypeName;
}
// Store value
$this->questtypeName = $questtypeName;
}
/**
* Get the name of the invalid QuesttypeAgent.
*
* @return string Name of the invalid QuesttypeAgent
*/
public function getClassName()
{
return $this->questtypeName;
}
/**
* Get the name of the invalid QuesttypeAgent.
*
* @return string Name of the invalid QuesttypeAgent
*/
public function getClassName()
{
return $this->questtypeName;
}
}
}
?>

View file

@ -1,79 +1,79 @@
<?php
/**
* The Legend of Z
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
* @license http://www.gnu.org/licenses/gpl.html
* @link https://bitbucket.org/coderkun/the-legend-of-z
*/
/**
* The Legend of Z
*
* @author Hanraths <oliver.hanraths@uni-duesseldorf.de>
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
* @license http://www.gnu.org/licenses/gpl.html
* @link https://bitbucket.org/coderkun/the-legend-of-z
*/
namespace hhu\z\exceptions;
namespace hhu\z\exceptions;
/**
* Exception: QuesttypeController not found.
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
*/
class QuesttypeControllerNotFoundException extends \nre\core\Exception
{
/**
* Error code
*
* @var int
*/
const CODE = 103;
/**
* Error message
*
* @var string
*/
const MESSAGE = 'QuesttypeController not found';
/**
* Exception: QuesttypeController not found.
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
*/
class QuesttypeControllerNotFoundException extends \nre\core\Exception
{
/**
* Error code
*
* @var int
*/
const CODE = 103;
/**
* Error message
*
* @var string
*/
const MESSAGE = 'QuesttypeController not found';
/**
* Name of the class that was not found
*
* @var string
*/
private $questtypeName;
/**
* Name of the class that was not found
*
* @var string
*/
private $questtypeName;
/**
* Construct a new exception.
*
* @param string $questtypeName Name of the QuesttypeController that was not found
* @param string $message Error message
* @param int $code Error code
*/
function __construct($questtypeName, $message=self::MESSAGE, $code=self::CODE)
{
parent::__construct(
$message,
$code,
$questtypeName
);
/**
* Construct a new exception.
*
* @param string $questtypeName Name of the QuesttypeController that was not found
* @param string $message Error message
* @param int $code Error code
*/
function __construct($questtypeName, $message=self::MESSAGE, $code=self::CODE)
{
parent::__construct(
$message,
$code,
$questtypeName
);
// Store values
$this->questtypeName = $questtypeName;
}
// Store values
$this->questtypeName = $questtypeName;
}
/**
* Get the name of the QuesttypeController that was not found.
*
* @return string Name of the QuesttypeController that was not found
*/
public function getClassName()
{
return $this->questtypeName;
}
/**
* Get the name of the QuesttypeController that was not found.
*
* @return string Name of the QuesttypeController that was not found
*/
public function getClassName()
{
return $this->questtypeName;
}
}
}
?>

View file

@ -1,79 +1,79 @@
<?php
/**
* The Legend of Z
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
* @license http://www.gnu.org/licenses/gpl.html
* @link https://bitbucket.org/coderkun/the-legend-of-z
*/
/**
* The Legend of Z
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
* @license http://www.gnu.org/licenses/gpl.html
* @link https://bitbucket.org/coderkun/the-legend-of-z
*/
namespace hhu\z\exceptions;
namespace hhu\z\exceptions;
/**
* Exception: QuesttypeController not valid.
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
*/
class QuesttypeControllerNotValidException extends \nre\core\Exception
{
/**
* Error code
*
* @var int
*/
const CODE = 104;
/**
* Error message
*
* @var string
*/
const MESSAGE = 'QuesttypeController not valid';
/**
* Exception: QuesttypeController not valid.
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
*/
class QuesttypeControllerNotValidException extends \nre\core\Exception
{
/**
* Error code
*
* @var int
*/
const CODE = 104;
/**
* Error message
*
* @var string
*/
const MESSAGE = 'QuesttypeController not valid';
/**
* Name of the invalid class
*
* @var string
*/
private $questtypeName;
/**
* Name of the invalid class
*
* @var string
*/
private $questtypeName;
/**
* Construct a new exception.
*
* @param string $questtypeName Name of the invalid QuesttypeController
* @param string $message Error message
* @param int $code Error code
*/
function __construct($questtypeName, $message=self::MESSAGE, $code=self::CODE)
{
parent::__construct(
$message,
$code,
$questtypeName
);
/**
* Construct a new exception.
*
* @param string $questtypeName Name of the invalid QuesttypeController
* @param string $message Error message
* @param int $code Error code
*/
function __construct($questtypeName, $message=self::MESSAGE, $code=self::CODE)
{
parent::__construct(
$message,
$code,
$questtypeName
);
// Store value
$this->questtypeName = $questtypeName;
}
// Store value
$this->questtypeName = $questtypeName;
}
/**
* Get the name of the invalid QuesttypeController.
*
* @return string Name of the invalid QuesttypeController
*/
public function getClassName()
{
return $this->questtypeName;
}
/**
* Get the name of the invalid QuesttypeController.
*
* @return string Name of the invalid QuesttypeController
*/
public function getClassName()
{
return $this->questtypeName;
}
}
}
?>

View file

@ -1,79 +1,79 @@
<?php
/**
* The Legend of Z
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
* @license http://www.gnu.org/licenses/gpl.html
* @link https://bitbucket.org/coderkun/the-legend-of-z
*/
/**
* The Legend of Z
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
* @license http://www.gnu.org/licenses/gpl.html
* @link https://bitbucket.org/coderkun/the-legend-of-z
*/
namespace hhu\z\exceptions;
namespace hhu\z\exceptions;
/**
* Exception: QuesttypeModel not found.
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
*/
class QuesttypeModelNotFoundException extends \nre\core\Exception
{
/**
* Error code
*
* @var int
*/
const CODE = 105;
/**
* Error message
*
* @var string
*/
const MESSAGE = 'QuesttypeModel not found';
/**
* Exception: QuesttypeModel not found.
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
*/
class QuesttypeModelNotFoundException extends \nre\core\Exception
{
/**
* Error code
*
* @var int
*/
const CODE = 105;
/**
* Error message
*
* @var string
*/
const MESSAGE = 'QuesttypeModel not found';
/**
* Name of the class that was not found
*
* @var string
*/
private $questtypeName;
/**
* Name of the class that was not found
*
* @var string
*/
private $questtypeName;
/**
* Construct a new exception.
*
* @param string $questtypeName Name of the QuesttypeModel that was not found
* @param string $message Error message
* @param int $code Error code
*/
function __construct($questtypeName, $message=self::MESSAGE, $code=self::CODE)
{
parent::__construct(
$message,
$code,
$questtypeName
);
/**
* Construct a new exception.
*
* @param string $questtypeName Name of the QuesttypeModel that was not found
* @param string $message Error message
* @param int $code Error code
*/
function __construct($questtypeName, $message=self::MESSAGE, $code=self::CODE)
{
parent::__construct(
$message,
$code,
$questtypeName
);
// Store values
$this->questtypeName = $questtypeName;
}
// Store values
$this->questtypeName = $questtypeName;
}
/**
* Get the name of the QuesttypeModel that was not found.
*
* @return string Name of the QuesttypeModel that was not found
*/
public function getClassName()
{
return $this->questtypeName;
}
/**
* Get the name of the QuesttypeModel that was not found.
*
* @return string Name of the QuesttypeModel that was not found
*/
public function getClassName()
{
return $this->questtypeName;
}
}
}
?>

View file

@ -1,79 +1,79 @@
<?php
/**
* The Legend of Z
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
* @license http://www.gnu.org/licenses/gpl.html
* @link https://bitbucket.org/coderkun/the-legend-of-z
*/
/**
* The Legend of Z
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
* @license http://www.gnu.org/licenses/gpl.html
* @link https://bitbucket.org/coderkun/the-legend-of-z
*/
namespace hhu\z\exceptions;
namespace hhu\z\exceptions;
/**
* Exception: QuesttypeModel not valid.
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
*/
class QuesttypeModelNotValidException extends \nre\core\Exception
{
/**
* Error code
*
* @var int
*/
const CODE = 106;
/**
* Error message
*
* @var string
*/
const MESSAGE = 'QuesttypeModel not valid';
/**
* Exception: QuesttypeModel not valid.
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
*/
class QuesttypeModelNotValidException extends \nre\core\Exception
{
/**
* Error code
*
* @var int
*/
const CODE = 106;
/**
* Error message
*
* @var string
*/
const MESSAGE = 'QuesttypeModel not valid';
/**
* Name of the invalid class
*
* @var string
*/
private $questtypeName;
/**
* Name of the invalid class
*
* @var string
*/
private $questtypeName;
/**
* Construct a new exception.
*
* @param string $questtypeName Name of the invalid QuesttypeModel
* @param string $message Error message
* @param int $code Error code
*/
function __construct($questtypeName, $message=self::MESSAGE, $code=self::CODE)
{
parent::__construct(
$message,
$code,
$questtypeName
);
/**
* Construct a new exception.
*
* @param string $questtypeName Name of the invalid QuesttypeModel
* @param string $message Error message
* @param int $code Error code
*/
function __construct($questtypeName, $message=self::MESSAGE, $code=self::CODE)
{
parent::__construct(
$message,
$code,
$questtypeName
);
// Store value
$this->questtypeName = $questtypeName;
}
// Store value
$this->questtypeName = $questtypeName;
}
/**
* Get the name of the invalid QuesttypeModel.
*
* @return string Name of the invalid QuesttypeModel
*/
public function getClassName()
{
return $this->questtypeName;
}
/**
* Get the name of the invalid QuesttypeModel.
*
* @return string Name of the invalid QuesttypeModel
*/
public function getClassName()
{
return $this->questtypeName;
}
}
}
?>

View file

@ -1,79 +1,79 @@
<?php
/**
* The Legend of Z
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
* @license http://www.gnu.org/licenses/gpl.html
* @link https://bitbucket.org/coderkun/the-legend-of-z
*/
/**
* The Legend of Z
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
* @license http://www.gnu.org/licenses/gpl.html
* @link https://bitbucket.org/coderkun/the-legend-of-z
*/
namespace hhu\z\exceptions;
namespace hhu\z\exceptions;
/**
* Exception: Character submission not valid.
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
*/
class SubmissionNotValidException extends \nre\core\Exception
{
/**
* Error code
*
* @var int
*/
const CODE = 200;
/**
* Error message
*
* @var string
*/
const MESSAGE = 'Character submission not valid';
/**
* Exception: Character submission not valid.
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
*/
class SubmissionNotValidException extends \nre\core\Exception
{
/**
* Error code
*
* @var int
*/
const CODE = 200;
/**
* Error message
*
* @var string
*/
const MESSAGE = 'Character submission not valid';
/**
* Nested exception
*
* @var Exception
*/
private $nestedException;
/**
* Nested exception
*
* @var Exception
*/
private $nestedException;
/**
* Construct a new exception.
*
* @param string $nestedException Nested exception
* @param string $message Error message
* @param int $code Error code
*/
function __construct($nestedException, $message=self::MESSAGE, $code=self::CODE)
{
parent::__construct(
$message,
$code,
$nestedException
);
/**
* Construct a new exception.
*
* @param string $nestedException Nested exception
* @param string $message Error message
* @param int $code Error code
*/
function __construct($nestedException, $message=self::MESSAGE, $code=self::CODE)
{
parent::__construct(
$message,
$code,
$nestedException
);
// Store value
$this->nestedException = $nestedException;
}
// Store value
$this->nestedException = $nestedException;
}
/**
* Get Nested exception.
*
* @return string Nested exception
*/
public function getNestedException()
{
return $this->nestedException;
}
/**
* Get Nested exception.
*
* @return string Nested exception
*/
public function getNestedException()
{
return $this->nestedException;
}
}
}
?>

View file

@ -1,79 +1,79 @@
<?php
/**
* The Legend of Z
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
* @license http://www.gnu.org/licenses/gpl.html
* @link https://bitbucket.org/coderkun/the-legend-of-z
*/
/**
* The Legend of Z
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
* @license http://www.gnu.org/licenses/gpl.html
* @link https://bitbucket.org/coderkun/the-legend-of-z
*/
namespace hhu\z\exceptions;
namespace hhu\z\exceptions;
/**
* Exception: File has wrong filetype.
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
*/
class WrongFiletypeException extends \nre\core\Exception
{
/**
* Error code
*
* @var int
*/
const CODE = 201;
/**
* Error message
*
* @var string
*/
const MESSAGE = 'File has wrong type “%s”';
/**
* Exception: File has wrong filetype.
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
*/
class WrongFiletypeException extends \nre\core\Exception
{
/**
* Error code
*
* @var int
*/
const CODE = 201;
/**
* Error message
*
* @var string
*/
const MESSAGE = 'File has wrong type “%s”';
/**
* Type of file
*
* @var string
*/
private $type;
/**
* Type of file
*
* @var string
*/
private $type;
/**
* Construct a new exception.
*
* @param string $type Type of file
* @param string $message Error message
* @param int $code Error code
*/
function __construct($type, $message=self::MESSAGE, $code=self::CODE)
{
parent::__construct(
$message,
$code,
$type
);
/**
* Construct a new exception.
*
* @param string $type Type of file
* @param string $message Error message
* @param int $code Error code
*/
function __construct($type, $message=self::MESSAGE, $code=self::CODE)
{
parent::__construct(
$message,
$code,
$type
);
// Store values
$this->type = $type;
}
// Store values
$this->type = $type;
}
/**
* Get type of file.
*
* @return Type of file
*/
public function getType()
{
return $this->type;
}
/**
* Get type of file.
*
* @return Type of file
*/
public function getType()
{
return $this->type;
}
}
}
?>

View file

@ -1,38 +1,38 @@
<?php
/**
* The Legend of Z
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
* @license http://www.gnu.org/licenses/gpl.html
* @link https://bitbucket.org/coderkun/the-legend-of-z
*/
/**
* The Legend of Z
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
* @license http://www.gnu.org/licenses/gpl.html
* @link https://bitbucket.org/coderkun/the-legend-of-z
*/
namespace hhu\z\lib
{
namespace hhu\z\lib
{
/**
* Class to ensure that Compatibility library below is loaded.
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
*/
class PHPMailer
{
/**
* Class to ensure that Compatibility library below is loaded.
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
*/
class PHPMailer
{
/**
* Call this function to ensure this file is loaded.
*/
public static function load()
{
}
/**
* Call this function to ensure this file is loaded.
*/
public static function load()
{
}
}
}
}
}
namespace {
namespace {
/**
* PHPMailer - PHP email creation and transport class.

View file

@ -1,38 +1,38 @@
<?php
/**
* The Legend of Z
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
* @license http://www.gnu.org/licenses/gpl.html
* @link https://bitbucket.org/coderkun/the-legend-of-z
*/
/**
* The Legend of Z
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
* @license http://www.gnu.org/licenses/gpl.html
* @link https://bitbucket.org/coderkun/the-legend-of-z
*/
namespace hhu\z\lib
{
namespace hhu\z\lib
{
/**
* Class to ensure that Compatibility library below is loaded.
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
*/
class PHPMailerAutoload
{
/**
* Class to ensure that Compatibility library below is loaded.
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
*/
class PHPMailerAutoload
{
/**
* Call this function to ensure this file is loaded.
*/
public static function load()
{
}
/**
* Call this function to ensure this file is loaded.
*/
public static function load()
{
}
}
}
}
}
namespace {
namespace {
/**
* PHPMailer SPL autoloader.

View file

@ -1,37 +1,37 @@
<?php
/**
* The Legend of Z
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
* @license http://www.gnu.org/licenses/gpl.html
* @link https://bitbucket.org/coderkun/the-legend-of-z
*/
/**
* The Legend of Z
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
* @license http://www.gnu.org/licenses/gpl.html
* @link https://bitbucket.org/coderkun/the-legend-of-z
*/
namespace hhu\z\lib
{
namespace hhu\z\lib
{
/**
* Class to ensure that Compatibility library below is loaded.
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
*/
class Password
{
/**
* Class to ensure that Compatibility library below is loaded.
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
*/
class Password
{
/**
* Call this function to ensure this file is loaded.
*/
public static function load()
{
}
/**
* Call this function to ensure this file is loaded.
*/
public static function load()
{
}
}
}
}
}

View file

@ -1,38 +1,38 @@
<?php
/**
* The Legend of Z
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
* @license http://www.gnu.org/licenses/gpl.html
* @link https://bitbucket.org/coderkun/the-legend-of-z
*/
/**
* The Legend of Z
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
* @license http://www.gnu.org/licenses/gpl.html
* @link https://bitbucket.org/coderkun/the-legend-of-z
*/
namespace hhu\z\lib
{
namespace hhu\z\lib
{
/**
* Class to ensure that Compatibility library below is loaded.
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
*/
class SMTP
{
/**
* Class to ensure that Compatibility library below is loaded.
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
*/
class SMTP
{
/**
* Call this function to ensure this file is loaded.
*/
public static function load()
{
}
/**
* Call this function to ensure this file is loaded.
*/
public static function load()
{
}
}
}
}
}
namespace {
namespace {
/**
* PHPMailer RFC821 SMTP email transport class.

View file

@ -1,24 +1,24 @@
<?php
/**
* The Legend of Z
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
* @license http://www.gnu.org/licenses/gpl.html
* @link https://bitbucket.org/coderkun/the-legend-of-z
*/
/**
* The Legend of Z
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
* @license http://www.gnu.org/licenses/gpl.html
* @link https://bitbucket.org/coderkun/the-legend-of-z
*/
namespace hhu\z\models;
namespace hhu\z\models;
/**
* Abstract class for implementing a QuesttypeModel.
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
*/
abstract class QuesttypeModel extends \hhu\z\Model
{
/**
* Abstract class for implementing a QuesttypeModel.
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
*/
abstract class QuesttypeModel extends \hhu\z\Model
{
@ -34,132 +34,132 @@
public abstract function copyQuest($userId, $sourceQuestId, $targetQuestId, $seminaryMediaIds);
/**
* Load a Model.
*
* @static
* @throws \hhu\z\exceptions\QuesttypeModelNotFoundException
* @throws \hhu\z\exceptions\QuesttypeModelNotValidException
* @param string $modelName Name of the QuesttypeModel to load
*/
public static function load($modelName)
{
// Determine full classname
$className = self::getClassName($modelName);
/**
* Load a Model.
*
* @static
* @throws \hhu\z\exceptions\QuesttypeModelNotFoundException
* @throws \hhu\z\exceptions\QuesttypeModelNotValidException
* @param string $modelName Name of the QuesttypeModel to load
*/
public static function load($modelName)
{
// Determine full classname
$className = self::getClassName($modelName);
try {
// Load class
static::loadClass($modelName, $className);
try {
// Load class
static::loadClass($modelName, $className);
// Validate class
static::checkClass($className, get_class());
}
catch(\nre\exceptions\ClassNotValidException $e) {
throw new \hhu\z\exceptions\QuesttypeModelNotValidException($e->getClassName());
}
catch(\nre\exceptions\ClassNotFoundException $e) {
throw new \hhu\z\exceptions\QuesttypeModelNotFoundException($e->getClassName());
}
}
// Validate class
static::checkClass($className, get_class());
}
catch(\nre\exceptions\ClassNotValidException $e) {
throw new \hhu\z\exceptions\QuesttypeModelNotValidException($e->getClassName());
}
catch(\nre\exceptions\ClassNotFoundException $e) {
throw new \hhu\z\exceptions\QuesttypeModelNotFoundException($e->getClassName());
}
}
/**
* Instantiate a QuesttypeModel (Factory Pattern).
*
* @static
* @param string $questtypeName Name of the QuesttypeModel to instantiate
*/
public static function factory($questtypeName)
{
// Determine full classname
$className = self::getClassName($questtypeName);
/**
* Instantiate a QuesttypeModel (Factory Pattern).
*
* @static
* @param string $questtypeName Name of the QuesttypeModel to instantiate
*/
public static function factory($questtypeName)
{
// Determine full classname
$className = self::getClassName($questtypeName);
// Construct and return Model
return new $className();
}
// Construct and return Model
return new $className();
}
/**
* Determine the Model-classname for the given Questtype-name.
*
* @static
* @param string $questtypeName Questtype-name to get Model-classname of
* @return string Classname for the Questtype-name
*/
private static function getClassName($questtypeName)
{
$className = \nre\core\ClassLoader::concatClassNames($questtypeName, \nre\core\ClassLoader::stripClassType(\nre\core\ClassLoader::stripNamespace(get_class())), 'model');
/**
* Determine the Model-classname for the given Questtype-name.
*
* @static
* @param string $questtypeName Questtype-name to get Model-classname of
* @return string Classname for the Questtype-name
*/
private static function getClassName($questtypeName)
{
$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.
*
* @static
* @throws \nre\exceptions\ClassNotFoundException
* @param string $questtypeName Name of the QuesttypeModel to load
* @param string $fullClassName Name of the class to load
*/
private static function loadClass($questtypeName, $fullClassName)
{
// Determine folder to look in
$className = explode('\\', $fullClassName);
$className = array_pop($className);
/**
* Load the class of a QuesttypeModel.
*
* @static
* @throws \nre\exceptions\ClassNotFoundException
* @param string $questtypeName Name of the QuesttypeModel to load
* @param string $fullClassName Name of the class to load
*/
private static function loadClass($questtypeName, $fullClassName)
{
// Determine folder to look in
$className = explode('\\', $fullClassName);
$className = array_pop($className);
// Determine filename
$fileName = ROOT.DS.\nre\configs\AppConfig::$dirs['questtypes'].DS.strtolower($questtypeName).DS.$className.\nre\configs\CoreConfig::getFileExt('includes');
// Determine filename
$fileName = ROOT.DS.\nre\configs\AppConfig::$dirs['questtypes'].DS.strtolower($questtypeName).DS.$className.\nre\configs\CoreConfig::getFileExt('includes');
// Check file
if(!file_exists($fileName))
{
throw new \nre\exceptions\ClassNotFoundException(
$fullClassName
);
}
// Check file
if(!file_exists($fileName))
{
throw new \nre\exceptions\ClassNotFoundException(
$fullClassName
);
}
// Include file
include_once($fileName);
}
// Include file
include_once($fileName);
}
/**
* Check inheritance of the QuesttypeModel-class.
*
* @static
* @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)
{
// Check if class is subclass of parent class
if(!is_subclass_of($className, $parentClassName)) {
throw new \nre\exceptions\ClassNotValidException(
$className
);
}
}
/**
* Check inheritance of the QuesttypeModel-class.
*
* @static
* @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)
{
// Check if class is subclass of parent class
if(!is_subclass_of($className, $parentClassName)) {
throw new \nre\exceptions\ClassNotValidException(
$className
);
}
}
/**
* Construct a new QuesttypeModel.
*
* @throws \nre\exceptions\DatamodelException
* @throws \nre\exceptions\DriverNotFoundException
* @throws \nre\exceptions\DriverNotValidException
* @throws \hhu\z\exceptions\QuesttypeModelNotValidException
* @throws \hhu\z\exceptions\QuesttypeModelNotFoundException
*/
public function __construct()
{
parent::__construct();
}
/**
* Construct a new QuesttypeModel.
*
* @throws \nre\exceptions\DatamodelException
* @throws \nre\exceptions\DriverNotFoundException
* @throws \nre\exceptions\DriverNotValidException
* @throws \hhu\z\exceptions\QuesttypeModelNotValidException
* @throws \hhu\z\exceptions\QuesttypeModelNotFoundException
*/
public function __construct()
{
parent::__construct();
}
}
}
?>

View file

@ -1,92 +1,92 @@
<?php
/**
* The Legend of Z
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
* @license http://www.gnu.org/licenses/gpl.html
* @link https://bitbucket.org/coderkun/the-legend-of-z
*/
/**
* The Legend of Z
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
* @license http://www.gnu.org/licenses/gpl.html
* @link https://bitbucket.org/coderkun/the-legend-of-z
*/
namespace hhu\z\requests;
namespace hhu\z\requests;
/**
* Representation of a mail-request.
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
*/
class MailRequest extends \nre\core\Request
{
/**
* Linker
*
* @var \nre\core\Linker
*/
private $linker = null;
/**
* Representation of a mail-request.
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
*/
class MailRequest extends \nre\core\Request
{
/**
* Linker
*
* @var \nre\core\Linker
*/
private $linker = null;
/**
* Add a parameter.
*
* @param mixed $value Value of parameter
*/
public function addParam($value)
{
$this->params[] = $value;
}
/**
* Add a parameter.
*
* @param mixed $value Value of parameter
*/
public function addParam($value)
{
$this->params[] = $value;
}
/**
* Add multiple parameters.
*
* @param mixed $value1 Value of first parameter
* @param mixed Values of further parameters
*/
public function addParams($value1)
{
$this->params = array_merge(
$this->params,
func_get_args()
);
}
/**
* Add multiple parameters.
*
* @param mixed $value1 Value of first parameter
* @param mixed Values of further parameters
*/
public function addParams($value1)
{
$this->params = array_merge(
$this->params,
func_get_args()
);
}
/**
* Delete all stored parameters (from offset on).
*
* @param int $offset Offset-index
*/
public function clearParams($offset=0)
{
$this->params = array_slice($this->params, 0, $offset);
}
/**
* Delete all stored parameters (from offset on).
*
* @param int $offset Offset-index
*/
public function clearParams($offset=0)
{
$this->params = array_slice($this->params, 0, $offset);
}
/**
* Set linker instance for creating links.
*
* @param Linker $linker Linker instance for creating links
*/
public function setLinker(\nre\core\Linker $linker)
{
$this->linker = $linker;
}
/**
* Set linker instance for creating links.
*
* @param Linker $linker Linker instance for creating links
*/
public function setLinker(\nre\core\Linker $linker)
{
$this->linker = $linker;
}
/**
* Get linker instance for creating links.
*
* @return \nre\core\Linker Linker instance for creating links
*/
public function getLinker()
{
return $this->linker;
}
/**
* Get linker instance for creating links.
*
* @return \nre\core\Linker Linker instance for creating links
*/
public function getLinker()
{
return $this->linker;
}
}
}
?>

View file

@ -1,55 +1,55 @@
<?php
/**
* The Legend of Z
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
* @license http://www.gnu.org/licenses/gpl.html
* @link https://bitbucket.org/coderkun/the-legend-of-z
*/
/**
* The Legend of Z
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
* @license http://www.gnu.org/licenses/gpl.html
* @link https://bitbucket.org/coderkun/the-legend-of-z
*/
namespace hhu\z\responses;
namespace hhu\z\responses;
/**
* Representation of a mail-response.
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
*/
class MailResponse extends \nre\core\Response
{
/**
* Mail subject
*
* @var string
*/
private $subject = null;
/**
* Representation of a mail-response.
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
*/
class MailResponse extends \nre\core\Response
{
/**
* Mail subject
*
* @var string
*/
private $subject = null;
/**
* Set subject.
*
* @param string $subject Subject to set
*/
public function setSubject($subject)
{
$this->subject = $subject;
}
/**
* Set subject.
*
* @param string $subject Subject to set
*/
public function setSubject($subject)
{
$this->subject = $subject;
}
/**
* Get subject.
*
* @return string Subject
*/
public function getSubject()
{
return $this->subject;
}
/**
* Get subject.
*
* @return string Subject
*/
public function getSubject()
{
return $this->subject;
}
}
}
?>

View file

@ -1,76 +1,76 @@
<?php
/**
* The Legend of Z
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
* @license http://www.gnu.org/licenses/gpl.html
* @link https://bitbucket.org/coderkun/the-legend-of-z
*/
/**
* The Legend of Z
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
* @license http://www.gnu.org/licenses/gpl.html
* @link https://bitbucket.org/coderkun/the-legend-of-z
*/
namespace hhu\z\views;
namespace hhu\z\views;
/**
* Abstract class for implementing a QuesttypeView.
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
*/
class QuesttypeView extends \nre\core\View
{
/**
* Abstract class for implementing a QuesttypeView.
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
*/
class QuesttypeView extends \nre\core\View
{
/**
* Load and instantiate the QuesttypeView of a QuesttypeAgent.
*
* @throws \nre\exceptions\ViewNotFoundException
* @param string $layoutName Name of Layout in use
* @param string $agentName Name of the Agent
* @param string $action Current Action
* @param bool $isToplevel Agent is a ToplevelAgent
*/
public static function loadAndFactory($layoutName, $agentName=null, $action=null, $isToplevel=false)
{
return new QuesttypeView($layoutName, $agentName, $action, $isToplevel);
}
/**
* Load and instantiate the QuesttypeView of a QuesttypeAgent.
*
* @throws \nre\exceptions\ViewNotFoundException
* @param string $layoutName Name of Layout in use
* @param string $agentName Name of the Agent
* @param string $action Current Action
* @param bool $isToplevel Agent is a ToplevelAgent
*/
public static function loadAndFactory($layoutName, $agentName=null, $action=null, $isToplevel=false)
{
return new QuesttypeView($layoutName, $agentName, $action, $isToplevel);
}
/**
* Construct a new QuesttypeView.
*
* @throws \nre\exceptions\ViewNotFoundException
* @param string $layoutName Name of Layout in use
* @param string $agentName Name of the Agent
* @param string $action Current Action
* @param bool $isToplevel Agent is a ToplevelAgent
*/
protected function __construct($layoutName, $agentName=null, $action=null, $isToplevel=false)
{
// Create template filename
// LayoutName
$fileName = ROOT.DS.\nre\configs\AppConfig::$dirs['questtypes'].DS.strtolower($agentName).DS.strtolower($layoutName).DS;
/**
* Construct a new QuesttypeView.
*
* @throws \nre\exceptions\ViewNotFoundException
* @param string $layoutName Name of Layout in use
* @param string $agentName Name of the Agent
* @param string $action Current Action
* @param bool $isToplevel Agent is a ToplevelAgent
*/
protected function __construct($layoutName, $agentName=null, $action=null, $isToplevel=false)
{
// Create template filename
// LayoutName
$fileName = ROOT.DS.\nre\configs\AppConfig::$dirs['questtypes'].DS.strtolower($agentName).DS.strtolower($layoutName).DS;
// Action
$fileName .= strtolower($action);
// Action
$fileName .= strtolower($action);
// File extension
$fileName .= \nre\configs\CoreConfig::getFileExt('views');
// File extension
$fileName .= \nre\configs\CoreConfig::getFileExt('views');
// Check template file
if(!file_exists($fileName)) {
throw new \nre\exceptions\ViewNotFoundException($fileName);
}
// Check template file
if(!file_exists($fileName)) {
throw new \nre\exceptions\ViewNotFoundException($fileName);
}
// Save filename
$this->templateFilename = $fileName;
}
// Save filename
$this->templateFilename = $fileName;
}
}
}
?>

File diff suppressed because it is too large Load diff

View file

@ -1,52 +1,52 @@
<?php
/**
* The Legend of Z
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
* @license http://www.gnu.org/licenses/gpl.html
* @link https://bitbucket.org/coderkun/the-legend-of-z
*/
/**
* The Legend of Z
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
* @license http://www.gnu.org/licenses/gpl.html
* @link https://bitbucket.org/coderkun/the-legend-of-z
*/
namespace hhu\z\controllers;
namespace hhu\z\controllers;
/**
* Controller of the AjaxAgent to return a JSON-string used by AJAX.
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
*/
class AjaxController extends \hhu\z\Controller
{
/**
* Controller of the AjaxAgent to return a JSON-string used by AJAX.
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
*/
class AjaxController extends \hhu\z\Controller
{
/**
* Prefilter.
*
* @param \nre\core\Request $request Current request
* @param \nre\core\Response $response Current response
*/
public function preFilter(\nre\core\Request $request, \nre\core\Response $response)
{
parent::preFilter($request, $response);
/**
* Prefilter.
*
* @param \nre\core\Request $request Current request
* @param \nre\core\Response $response Current response
*/
public function preFilter(\nre\core\Request $request, \nre\core\Response $response)
{
parent::preFilter($request, $response);
// Set content-type
$this->response->addHeader("Content-type: application/json; charset=utf-8");
}
// Set content-type
$this->response->addHeader("Content-type: application/json; charset=utf-8");
}
/**
* Action: index.
*
* Create the JSON-string.
*/
public function index()
{
}
/**
* Action: index.
*
* Create the JSON-string.
*/
public function index()
{
}
}
}
?>

View file

@ -1,37 +1,37 @@
<?php
/**
* The Legend of Z
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
* @license http://www.gnu.org/licenses/gpl.html
* @link https://bitbucket.org/coderkun/the-legend-of-z
*/
/**
* The Legend of Z
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
* @license http://www.gnu.org/licenses/gpl.html
* @link https://bitbucket.org/coderkun/the-legend-of-z
*/
namespace hhu\z\controllers;
namespace hhu\z\controllers;
/**
* Controller of the BinaryAgent to show binary data.
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
*/
class BinaryController extends \hhu\z\controllers\IntermediateController
{
/**
* Controller of the BinaryAgent to show binary data.
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
*/
class BinaryController extends \hhu\z\controllers\IntermediateController
{
/**
* Action: index.
*
* Create binary data.
*/
public function index()
{
}
/**
* Action: index.
*
* Create binary data.
*/
public function index()
{
}
}
}
?>

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -1,406 +1,406 @@
<?php
/**
* The Legend of Z
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
* @license http://www.gnu.org/licenses/gpl.html
* @link https://bitbucket.org/coderkun/the-legend-of-z
*/
/**
* The Legend of Z
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
* @license http://www.gnu.org/licenses/gpl.html
* @link https://bitbucket.org/coderkun/the-legend-of-z
*/
namespace hhu\z\controllers;
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')
);
/**
* 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);
/**
* Action: index.
*
* List Character types.
*
* @throws \nre\exceptions\IdNotFoundException
* @param string $seminaryUrl URL-Title of a Seminary
*/
public function index($seminaryUrl)
{
// Get seminary
$seminary = $this->Seminaries->getSeminaryByUrl($seminaryUrl);
// Check permissions
if(
(is_null(self::$character) && count(array_intersect(array('admin', 'moderator'), \hhu\z\controllers\IntermediateController::$user['roles'])) == 0) &&
$seminary['created_user_id'] != self::$user['id']
) {
throw new \nre\exceptions\AccessDeniedException();
}
// 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 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
}
}
}
// 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');
$this->addTitle($seminary['title']);
// Set titile
$this->addTitleLocalized('Charactertypes');
$this->addTitle($seminary['title']);
// Pass data to view
$this->set('seminary', $seminary);
$this->set('xplevels', $xplevels);
$this->set('charactertypes', $charactertypes);
}
// Pass data to view
$this->set('seminary', $seminary);
$this->set('xplevels', $xplevels);
$this->set('charactertypes', $charactertypes);
}
/**
* 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);
/**
* 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();
}
// 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();
// 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($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);
// 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));
}
}
// 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];
}
// Get validation settings
$validationSettings = array();
foreach($fields as &$field) {
$validationSettings[$field] = \nre\configs\AppConfig::$validation[$field];
}
// Set titile
$this->addTitleLocalized('Create new Charactertype');
$this->addTitle($seminary['title']);
// Set titile
$this->addTitleLocalized('Create new Charactertype');
$this->addTitle($seminary['title']);
// Pass data to view
$this->set('seminary', $seminary);
$this->set('name', $name);
$this->set('validation', $validation);
$this->set('validationSettings', $validationSettings);
}
// Pass data to view
$this->set('seminary', $seminary);
$this->set('name', $name);
$this->set('validation', $validation);
$this->set('validationSettings', $validationSettings);
}
/**
* Action: edit.
*
* Edit Character type for a Seminary.
*
* @throws \nre\exceptions\IdNotFoundException
* @param string $seminaryUrl URL-title of a Seminary
* @param string $charactertypeUrl URL-title of Character type
*/
public function edit($seminaryUrl, $charactertypeUrl)
{
// Get seminary
$seminary = $this->Seminaries->getSeminaryByUrl($seminaryUrl);
/**
* Action: edit.
*
* Edit Character type for a Seminary.
*
* @throws \nre\exceptions\IdNotFoundException
* @param string $seminaryUrl URL-title of a Seminary
* @param string $charactertypeUrl URL-title of Character type
*/
public function edit($seminaryUrl, $charactertypeUrl)
{
// Get seminary
$seminary = $this->Seminaries->getSeminaryByUrl($seminaryUrl);
// Check permissions
if(
$seminary['created_user_id'] != self::$user['id'] &&
(is_null(self::$character) && count(array_intersect(array('admin', 'moderator'), \hhu\z\controllers\IntermediateController::$user['roles'])) == 0)
) {
throw new \nre\exceptions\AccessDeniedException();
}
// 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);
// 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
}
}
// 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'];
// Get allowed mimetypes
$mimetypes = \nre\configs\AppConfig::$mimetypes['moodpics'];
// Values
$name = $charactertype['name'];
$fields = array('charactertypename');
$validation = array();
$avatarVariants = array('portrait', 'avatar');
$avatarsValidation = true;
// 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);
}
// 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;
// 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 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']);
}
// 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;
}
// 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']
);
// 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']
);
}
}
}
}
}
}
}
// 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']);
// 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));
}
}
// 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];
}
// 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']);
// 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);
}
// 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);
/**
* 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();
}
// 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);
// 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']);
}
// 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));
}
// Redirect to overview
$this->redirect($this->linker->link(array('index', $seminary['url']), 1));
}
// Set titile
$this->addTitleLocalized('Delete Charactertype');
$this->addTitle($seminary['title']);
// Set titile
$this->addTitleLocalized('Delete Charactertype');
$this->addTitle($seminary['title']);
// Pass data to view
$this->set('seminary', $seminary);
$this->set('charactertype', $charactertype);
}
// Pass data to view
$this->set('seminary', $seminary);
$this->set('charactertype', $charactertype);
}
}
}
?>

View file

@ -1,51 +1,51 @@
<?php
/**
* The Legend of Z
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
* @license http://www.gnu.org/licenses/gpl.html
* @link https://bitbucket.org/coderkun/the-legend-of-z
*/
/**
* The Legend of Z
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
* @license http://www.gnu.org/licenses/gpl.html
* @link https://bitbucket.org/coderkun/the-legend-of-z
*/
namespace hhu\z\controllers;
namespace hhu\z\controllers;
/**
* Controller of the Agent to show an error page.
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
*/
class ErrorController extends \hhu\z\Controller
{
/**
* Controller of the Agent to show an error page.
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
*/
class ErrorController extends \hhu\z\Controller
{
/**
* Action: index.
*
* Set HTTP-header and print an error message.
*
* @param int $httpStatusCode HTTP-statuscode of the error that occurred
*/
public function index($httpStatusCode)
{
// Set HTTP-header
if(!array_key_exists($httpStatusCode, \nre\core\WebUtils::$httpStrings)) {
$httpStatusCode = 200;
}
$this->response->addHeader(\nre\core\WebUtils::getHttpHeader($httpStatusCode));
/**
* Action: index.
*
* Set HTTP-header and print an error message.
*
* @param int $httpStatusCode HTTP-statuscode of the error that occurred
*/
public function index($httpStatusCode)
{
// Set HTTP-header
if(!array_key_exists($httpStatusCode, \nre\core\WebUtils::$httpStrings)) {
$httpStatusCode = 200;
}
$this->response->addHeader(\nre\core\WebUtils::getHttpHeader($httpStatusCode));
// Display statuscode and message
$this->set('code', $httpStatusCode);
$this->set('string', \nre\core\WebUtils::$httpStrings[$httpStatusCode]);
$this->set('userId', $this->Auth->getUserId());
}
// Display statuscode and message
$this->set('code', $httpStatusCode);
$this->set('string', \nre\core\WebUtils::$httpStrings[$httpStatusCode]);
$this->set('userId', $this->Auth->getUserId());
}
}
}
?>

View file

@ -1,37 +1,37 @@
<?php
/**
* The Legend of Z
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
* @license http://www.gnu.org/licenses/gpl.html
* @link https://bitbucket.org/coderkun/the-legend-of-z
*/
/**
* The Legend of Z
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
* @license http://www.gnu.org/licenses/gpl.html
* @link https://bitbucket.org/coderkun/the-legend-of-z
*/
namespace hhu\z\controllers;
namespace hhu\z\controllers;
/**
* Controller of the Agent to display a toplevel error page.
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
*/
class FaultController extends \nre\core\Controller
{
/**
* Controller of the Agent to display a toplevel error page.
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
*/
class FaultController extends \nre\core\Controller
{
/**
* Action: index.
*
* Show the error message.
*/
public function index()
{
}
/**
* Action: index.
*
* Show the error message.
*/
public function index()
{
}
}
}
?>

View file

@ -1,114 +1,114 @@
<?php
/**
* The Legend of Z
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
* @license http://www.gnu.org/licenses/gpl.html
* @link https://bitbucket.org/coderkun/the-legend-of-z
*/
/**
* The Legend of Z
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
* @license http://www.gnu.org/licenses/gpl.html
* @link https://bitbucket.org/coderkun/the-legend-of-z
*/
namespace hhu\z\controllers;
namespace hhu\z\controllers;
/**
* Controller of the HtmlAgent to display a HTML-page.
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
*/
class HtmlController extends \hhu\z\Controller
{
/**
* Required components
*
* @var array
*/
public $components = array('notification');
/**
* Controller of the HtmlAgent to display a HTML-page.
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
*/
class HtmlController extends \hhu\z\Controller
{
/**
* Required components
*
* @var array
*/
public $components = array('notification');
/**
* Prefilter.
*
* @param \nre\core\Request $request Current request
* @param \nre\core\Response $response Current response
*/
public function preFilter(\nre\core\Request $request, \nre\core\Response $response)
{
parent::preFilter($request, $response);
/**
* Prefilter.
*
* @param \nre\core\Request $request Current request
* @param \nre\core\Response $response Current response
*/
public function preFilter(\nre\core\Request $request, \nre\core\Response $response)
{
parent::preFilter($request, $response);
// Set content-type
$this->response->addHeader("Content-type: text/html; charset=utf-8");
}
// Set content-type
$this->response->addHeader("Content-type: text/html; charset=utf-8");
}
/**
* Postfilter that is executed after running the Controller.
*
* @param \nre\core\Request $request Current request
* @param \nre\core\Response $response Current response
*/
public function postFilter(\nre\core\Request $request, \nre\core\Response $response)
{
// Get title
$this->set('title', $this->getTitle());
}
/**
* Postfilter that is executed after running the Controller.
*
* @param \nre\core\Request $request Current request
* @param \nre\core\Response $response Current response
*/
public function postFilter(\nre\core\Request $request, \nre\core\Response $response)
{
// Get title
$this->set('title', $this->getTitle());
}
/**
* Action: index.
*
* Create the HTML-structure.
*/
public function index()
{
// Set the name of the current IntermediateAgent as page title
$this->set('title', $this->request->getParam(1, 'intermediate'));
/**
* Action: index.
*
* Create the HTML-structure.
*/
public function index()
{
// Set the name of the current IntermediateAgent as page title
$this->set('title', $this->request->getParam(1, 'intermediate'));
// Set userdata
$this->set('loggedUser', IntermediateController::$user);
$this->set('loggedSeminary', SeminaryController::$seminary);
$this->set('loggedCharacter', SeminaryController::$character);
// Set userdata
$this->set('loggedUser', IntermediateController::$user);
$this->set('loggedSeminary', SeminaryController::$seminary);
$this->set('loggedCharacter', SeminaryController::$character);
// Set notifications
$this->set('notifications', $this->Notification->getNotifications());
// Set notifications
$this->set('notifications', $this->Notification->getNotifications());
// Set some application data
$this->set('mailcontact', \nre\configs\AppConfig::$app['mailcontact']);
}
}
/**
* Get title information from IntermediateController if possible
* and create a title.
*
* @return string Title for the current page
*/
private function getTitle()
{
$title = array();
/**
* Get title information from IntermediateController if possible
* and create a title.
*
* @return string Title for the current page
*/
private function getTitle()
{
$title = array();
// Get title of IntermediateController
$intermediateController = $this->agent->getIntermediateAgent()->controller;
if($intermediateController instanceof \hhu\z\controllers\IntermediateController) {
$title = $intermediateController->getTitle();
}
if(!is_array($title)) {
$title = array($title);
}
// Get title of IntermediateController
$intermediateController = $this->agent->getIntermediateAgent()->controller;
if($intermediateController instanceof \hhu\z\controllers\IntermediateController) {
$title = $intermediateController->getTitle();
}
if(!is_array($title)) {
$title = array($title);
}
// Add application name
$title[] = \nre\configs\AppConfig::$app['name'];
// Add application name
$title[] = \nre\configs\AppConfig::$app['name'];
// Return title with delimiter
return implode(\nre\configs\AppConfig::$misc['title_delimiter'], $title);
}
// Return title with delimiter
return implode(\nre\configs\AppConfig::$misc['title_delimiter'], $title);
}
}
}
?>

View file

@ -1,54 +1,54 @@
<?php
/**
* The Legend of Z
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
* @license http://www.gnu.org/licenses/gpl.html
* @link https://bitbucket.org/coderkun/the-legend-of-z
*/
/**
* The Legend of Z
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
* @license http://www.gnu.org/licenses/gpl.html
* @link https://bitbucket.org/coderkun/the-legend-of-z
*/
namespace hhu\z\controllers;
namespace hhu\z\controllers;
/**
* Controller of the HtmlmailAgent for generating a HTML-mail message.
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
*/
class HtmlmailController extends \nre\core\Controller
{
/**
* Controller of the HtmlmailAgent for generating a HTML-mail message.
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
*/
class HtmlmailController extends \nre\core\Controller
{
/**
* Prefilter.
*
* @param \nre\core\Request $request Current request
* @param \nre\core\Response $response Current response
*/
public function preFilter(\nre\core\Request $request, \nre\core\Response $response)
{
parent::preFilter($request, $response);
/**
* Prefilter.
*
* @param \nre\core\Request $request Current request
* @param \nre\core\Response $response Current response
*/
public function preFilter(\nre\core\Request $request, \nre\core\Response $response)
{
parent::preFilter($request, $response);
// Set linker
$this->set('linker', ($request instanceof \hhu\z\requests\MailRequest && !is_null($request->getLinker())) ? $request->getLinker() : null);
}
// Set linker
$this->set('linker', ($request instanceof \hhu\z\requests\MailRequest && !is_null($request->getLinker())) ? $request->getLinker() : null);
}
/**
* Action: index.
*
* Create HTML-structure of mail message.
*/
public function index()
{
$this->set('appname', \nre\configs\AppConfig::$app['name']);
}
/**
* Action: index.
*
* Create HTML-structure of mail message.
*/
public function index()
{
$this->set('appname', \nre\configs\AppConfig::$app['name']);
}
}
}
?>

View file

@ -1,37 +1,37 @@
<?php
/**
* The Legend of Z
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
* @license http://www.gnu.org/licenses/gpl.html
* @link https://bitbucket.org/coderkun/the-legend-of-z
*/
/**
* The Legend of Z
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
* @license http://www.gnu.org/licenses/gpl.html
* @link https://bitbucket.org/coderkun/the-legend-of-z
*/
namespace hhu\z\controllers;
namespace hhu\z\controllers;
/**
* Controller of the Agent to show an introduction page.
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
*/
class IntroductionController extends \hhu\z\controllers\IntermediateController
{
/**
* Controller of the Agent to show an introduction page.
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
*/
class IntroductionController extends \hhu\z\controllers\IntermediateController
{
/**
* Action: index.
*/
public function index()
{
// Pass data to view
$this->set('userId', $this->Auth->getUserId());
}
/**
* Action: index.
*/
public function index()
{
// Pass data to view
$this->set('userId', $this->Auth->getUserId());
}
}
}
?>

File diff suppressed because it is too large Load diff

View file

@ -1,136 +1,136 @@
<?php
/**
* The Legend of Z
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
* @license http://www.gnu.org/licenses/gpl.html
* @link https://bitbucket.org/coderkun/the-legend-of-z
*/
/**
* The Legend of Z
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
* @license http://www.gnu.org/licenses/gpl.html
* @link https://bitbucket.org/coderkun/the-legend-of-z
*/
namespace hhu\z\controllers;
namespace hhu\z\controllers;
/**
* Controller of the MailAgent to generate a mail message.
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
*/
class MailController extends \nre\core\Controller
{
/**
* Controller of the MailAgent to generate a mail message.
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
*/
class MailController extends \nre\core\Controller
{
/**
* Prefilter.
*
* @param \nre\core\Request $request Current request
* @param \nre\core\Response $response Current response
*/
public function preFilter(\nre\core\Request $request, \nre\core\Response $response)
{
parent::preFilter($request, $response);
/**
* Prefilter.
*
* @param \nre\core\Request $request Current request
* @param \nre\core\Response $response Current response
*/
public function preFilter(\nre\core\Request $request, \nre\core\Response $response)
{
parent::preFilter($request, $response);
// Set linker
$this->set('linker', ($request instanceof \hhu\z\requests\MailRequest && !is_null($request->getLinker())) ? $request->getLinker() : null);
}
// Set linker
$this->set('linker', ($request instanceof \hhu\z\requests\MailRequest && !is_null($request->getLinker())) ? $request->getLinker() : null);
}
/**
* Action: userregistration.
*
* Generate a mail message to notify of a new user registration.
*
* @param array $receiver User that the message will be send to
* @param array $neUser Newly registered user
*/
public function userregistration($receiver, $newUser)
{
// Set subject
$this->response->setSubject(_('New user registration'));
/**
* Action: userregistration.
*
* Generate a mail message to notify of a new user registration.
*
* @param array $receiver User that the message will be send to
* @param array $neUser Newly registered user
*/
public function userregistration($receiver, $newUser)
{
// Set subject
$this->response->setSubject(_('New user registration'));
// Pass data to view
$this->set('user', $newUser);
}
// Pass data to view
$this->set('user', $newUser);
}
/**
* Action: characterregistration.
*
* Generate a mail message to notify of a new Character
* registration.
*
* @param array $receiver User that the message will be send to
* @param array $seminary Seminary which the Character was created for
* @param arary $user User of the newly registered Character
* @param array $newCharacter Newly registered Character
*/
public function characterregistration($receiver, $seminary, $user, $newCharacter)
{
// Set subject
$this->response->setSubject(_('New Character registration'));
/**
* Action: characterregistration.
*
* Generate a mail message to notify of a new Character
* registration.
*
* @param array $receiver User that the message will be send to
* @param array $seminary Seminary which the Character was created for
* @param arary $user User of the newly registered Character
* @param array $newCharacter Newly registered Character
*/
public function characterregistration($receiver, $seminary, $user, $newCharacter)
{
// Set subject
$this->response->setSubject(_('New Character registration'));
// Pass data to view
$this->set('seminary', $seminary);
$this->set('user', $user);
$this->set('character', $newCharacter);
}
// Pass data to view
$this->set('seminary', $seminary);
$this->set('user', $user);
$this->set('character', $newCharacter);
}
/**
* Action: charactersubmission.
*
* Generate a mail message to notify of a new Character
* submission for a Quest that needs to be valuated.
*
* @param array $receiver User that the message will be send to
* @param array $seminary Seminary which the Quest belongs to
* @param array $questgroup Questgroup of Quest
* @param array $quest Quest the answer has been submitted for
* @param array $character Character that send the submission
*/
public function charactersubmission($receiver, $seminary, $questgroup, $quest, $character)
{
// Set subject
$this->response->setSubject(_('New Character submission'));
/**
* Action: charactersubmission.
*
* Generate a mail message to notify of a new Character
* submission for a Quest that needs to be valuated.
*
* @param array $receiver User that the message will be send to
* @param array $seminary Seminary which the Quest belongs to
* @param array $questgroup Questgroup of Quest
* @param array $quest Quest the answer has been submitted for
* @param array $character Character that send the submission
*/
public function charactersubmission($receiver, $seminary, $questgroup, $quest, $character)
{
// Set subject
$this->response->setSubject(_('New Character submission'));
// Pass data to view
$this->set('seminary', $seminary);
$this->set('questgroup', $questgroup);
$this->set('quest', $quest);
$this->set('character', $character);
}
// Pass data to view
$this->set('seminary', $seminary);
$this->set('questgroup', $questgroup);
$this->set('quest', $quest);
$this->set('character', $character);
}
/**
* Action: charactersubmissionapproved.
*
* Generate a mail message to notify a Character that its
* submission has been approved.
*
* @param array $receiver User that the message will be send to
* @param array $seminary Seminary which the Quest belongs to
* @param array $questgroup Questgroup of Quest
* @param array $quest Quest the answer has been submitted for
*/
public function charactersubmissionapproved($receiver, $seminary, $questgroup, $quest)
{
// Set subject
$this->response->setSubject(_('Character submission approved'));
/**
* Action: charactersubmissionapproved.
*
* Generate a mail message to notify a Character that its
* submission has been approved.
*
* @param array $receiver User that the message will be send to
* @param array $seminary Seminary which the Quest belongs to
* @param array $questgroup Questgroup of Quest
* @param array $quest Quest the answer has been submitted for
*/
public function charactersubmissionapproved($receiver, $seminary, $questgroup, $quest)
{
// Set subject
$this->response->setSubject(_('Character submission approved'));
// Pass data to view
$this->set('seminary', $seminary);
$this->set('questgroup', $questgroup);
$this->set('quest', $quest);
}
// Pass data to view
$this->set('seminary', $seminary);
$this->set('questgroup', $questgroup);
$this->set('quest', $quest);
}
}
}
?>

View file

@ -1,39 +1,39 @@
<?php
/**
* The Legend of Z
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
* @license http://www.gnu.org/licenses/gpl.html
* @link https://bitbucket.org/coderkun/the-legend-of-z
*/
/**
* The Legend of Z
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
* @license http://www.gnu.org/licenses/gpl.html
* @link https://bitbucket.org/coderkun/the-legend-of-z
*/
namespace hhu\z\controllers;
namespace hhu\z\controllers;
/**
* Controller of the MailreceiverAgent to generate a mail receiver
* salutation.
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
*/
class MailreceiverController extends \nre\core\Controller
{
/**
* Controller of the MailreceiverAgent to generate a mail receiver
* salutation.
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
*/
class MailreceiverController extends \nre\core\Controller
{
/**
* Action: index.
*
* @param $array $user User receiving mail
*/
public function index($user)
{
$this->set('user', $user);
}
/**
* Action: index.
*
* @param $array $user User receiving mail
*/
public function index($user)
{
$this->set('user', $user);
}
}
}
?>

View file

@ -1,62 +1,62 @@
<?php
/**
* The Legend of Z
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
* @license http://www.gnu.org/licenses/gpl.html
* @link https://bitbucket.org/coderkun/the-legend-of-z
*/
/**
* The Legend of Z
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
* @license http://www.gnu.org/licenses/gpl.html
* @link https://bitbucket.org/coderkun/the-legend-of-z
*/
namespace hhu\z\controllers;
namespace hhu\z\controllers;
/**
* Controller of the MapAgent to display a map.
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
*/
class MapController extends \hhu\z\controllers\SeminaryController
{
/**
* Required models
*
* @var array
*/
public $models = array('seminaries', 'map');
/**
* User permissions
*
* @var array
*/
public $permissions = array(
'index' => array('admin', 'moderator', 'user')
);
/**
* User seminary permissions
*
* @var array
*/
public $seminaryPermissions = array(
'index' => array('admin', 'moderator', 'user')
);
/**
* Controller of the MapAgent to display a map.
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
*/
class MapController extends \hhu\z\controllers\SeminaryController
{
/**
* Required models
*
* @var array
*/
public $models = array('seminaries', 'map');
/**
* User permissions
*
* @var array
*/
public $permissions = array(
'index' => array('admin', 'moderator', 'user')
);
/**
* User seminary permissions
*
* @var array
*/
public $seminaryPermissions = array(
'index' => array('admin', 'moderator', 'user')
);
/**
* Action: index.
*
* Draw the map.
*
* @throws \nre\exceptions\IdNotFoundException
* @param string $seminaryUrl URL-Title of Seminary
*/
public function index($seminaryUrl)
{
/**
* Action: index.
*
* Draw the map.
*
* @throws \nre\exceptions\IdNotFoundException
* @param string $seminaryUrl URL-Title of Seminary
*/
public function index($seminaryUrl)
{
// Get Seminary
$seminary = $this->Seminaries->getSeminaryByUrl($seminaryUrl);
$seminary = $this->Seminaries->getSeminaryByUrl($seminaryUrl);
// Get map
$map = $this->Map->getMapOfSeminary($seminary['id']);
@ -65,8 +65,8 @@
// Pass data to view
$this->set('seminary', $seminary);
$this->set('map', $map);
}
}
}
}
?>

File diff suppressed because it is too large Load diff

View file

@ -1,52 +1,52 @@
<?php
/**
* The Legend of Z
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
* @license http://www.gnu.org/licenses/gpl.html
* @link https://bitbucket.org/coderkun/the-legend-of-z
*/
/**
* The Legend of Z
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
* @license http://www.gnu.org/licenses/gpl.html
* @link https://bitbucket.org/coderkun/the-legend-of-z
*/
namespace hhu\z\controllers;
namespace hhu\z\controllers;
/**
* Controller of the Agent to display a menu.
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
*/
class MenuController extends \hhu\z\Controller
{
/**
* Controller of the Agent to display a menu.
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
*/
class MenuController extends \hhu\z\Controller
{
/**
* Prefilter.
*
* @param \nre\core\Request $request Current request
* @param \nre\core\Response $response Current response
*/
public function preFilter(\nre\core\Request $request, \nre\core\Response $response)
{
parent::preFilter($request, $response);
/**
* Prefilter.
*
* @param \nre\core\Request $request Current request
* @param \nre\core\Response $response Current response
*/
public function preFilter(\nre\core\Request $request, \nre\core\Response $response)
{
parent::preFilter($request, $response);
// Set userdata
$this->set('loggedUser', IntermediateController::$user);
$this->set('loggedCharacter', SeminaryController::$character);
$this->set('loggedSeminary', SeminaryController::$seminary);
}
// Set userdata
$this->set('loggedUser', IntermediateController::$user);
$this->set('loggedCharacter', SeminaryController::$character);
$this->set('loggedSeminary', SeminaryController::$seminary);
}
/**
* Action: index.
*/
public function index()
{
}
/**
* Action: index.
*/
public function index()
{
}
}
}
?>

File diff suppressed because it is too large Load diff

View file

@ -1,346 +1,346 @@
<?php
/**
* The Legend of Z
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
* @license http://www.gnu.org/licenses/gpl.html
* @link https://bitbucket.org/coderkun/the-legend-of-z
*/
/**
* The Legend of Z
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
* @license http://www.gnu.org/licenses/gpl.html
* @link https://bitbucket.org/coderkun/the-legend-of-z
*/
namespace hhu\z\controllers;
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')
);
/**
* 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);
/**
* 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']);
// Get parent Questgroupshierarchy
$parentQuestgroupshierarchy = $this->Questgroupshierarchy->getHierarchyOfSeminary($seminary['id']);
// Values
$titleSingular = '';
$titlePlural = '';
$validation = array();
// 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);
}
// 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;
}
}
// 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);
// 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'])));
}
}
// Redirect
$this->redirect($this->linker->link(array('seminaries', 'seminary', $seminary['url'])));
}
}
// Get validation settings
$validationSettings = array(
'title' => \nre\configs\AppConfig::$validation['title']
);
// Get validation settings
$validationSettings = array(
'title' => \nre\configs\AppConfig::$validation['title']
);
// Set titile
$this->addTitleLocalized('Create Questgroupshierarchy');
$this->addTitle($seminary['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);
}
// 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);
/**
* 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);
// Get Questgroupshierarchy
$questgroupshierarchy = $this->Questgroupshierarchy->getHierarchyByUrl($seminary['id'], $questgroupshierarchyUrl);
// Values
$titleSingular = $questgroupshierarchy['title_singular'];
$titlePlural = $questgroupshierarchy['title_plural'];
$validation = array();
// 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);
}
// 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']);
// 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'])));
}
}
// 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']
);
// Get validation settings
$validationSettings = array(
'title' => \nre\configs\AppConfig::$validation['title']
);
// Set titile
$this->addTitleLocalized('Edit Questgroupshierarchy');
$this->addTitle($seminary['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);
}
// 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);
/**
* 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);
// Get Questgroupshierarchy
$questgroupshierarchy = $this->Questgroupshierarchy->getHierarchyByUrl($seminary['id'], $questgroupshierarchyUrl);
// Set position
$this->Questgroupshierarchy->moveQuestgroupshierarchy($questgroupshierarchy, true);
// 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'])));
}
// 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);
/**
* 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);
// Get Questgroupshierarchy
$questgroupshierarchy = $this->Questgroupshierarchy->getHierarchyByUrl($seminary['id'], $questgroupshierarchyUrl);
// Set position
$this->Questgroupshierarchy->moveQuestgroupshierarchy($questgroupshierarchy, false);
// 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'])));
}
// 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);
/**
* 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);
// 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']);
}
// 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'])));
}
// Redirect to Seminary page
$this->redirect($this->linker->link(array('seminaries', 'seminary', $seminary['url'])));
}
// Set titile
$this->addTitleLocalized('Delete Questgroupshierarchy');
// Set titile
$this->addTitleLocalized('Delete Questgroupshierarchy');
// Show confirmation
$this->set('seminary', $seminary);
$this->set('questgroupshierarchy', $questgroupshierarchy);
}
// Show confirmation
$this->set('seminary', $seminary);
$this->set('questgroupshierarchy', $questgroupshierarchy);
}
}
}
?>

View file

@ -1,91 +1,91 @@
<?php
/**
* The Legend of Z
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
* @license http://www.gnu.org/licenses/gpl.html
* @link https://bitbucket.org/coderkun/the-legend-of-z
*/
/**
* The Legend of Z
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
* @license http://www.gnu.org/licenses/gpl.html
* @link https://bitbucket.org/coderkun/the-legend-of-z
*/
namespace hhu\z\controllers;
namespace hhu\z\controllers;
/**
* Controller of QuestgroupshierarchypathAgent to display the
* Questgroups hierarchy path.
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
*/
class QuestgroupshierarchypathController extends \hhu\z\Controller
{
/**
* Required models
*
* @var array
*/
public $models = array('seminaries', 'questgroups', 'questgroupshierarchy', 'quests', 'questtexts');
/**
* Controller of QuestgroupshierarchypathAgent to display the
* Questgroups hierarchy path.
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
*/
class QuestgroupshierarchypathController extends \hhu\z\Controller
{
/**
* Required models
*
* @var array
*/
public $models = array('seminaries', 'questgroups', 'questgroupshierarchy', 'quests', 'questtexts');
/**
* Action: index.
*
* Calculate and show the hierarchy path of a Questgroup.
*
* @param string $seminaryUrl URL-Title of a Seminary
* @param string $questgroupUrl URL-Title of a Questgroup
* @param boolean $showGroup Show the current group itself
*/
public function index($seminaryUrl, $questgroupUrl, $showGroup=false)
{
// Get Seminary
$seminary = $this->Seminaries->getSeminaryByUrl($seminaryUrl);
/**
* Action: index.
*
* Calculate and show the hierarchy path of a Questgroup.
*
* @param string $seminaryUrl URL-Title of a Seminary
* @param string $questgroupUrl URL-Title of a Questgroup
* @param boolean $showGroup Show the current group itself
*/
public function index($seminaryUrl, $questgroupUrl, $showGroup=false)
{
// Get Seminary
$seminary = $this->Seminaries->getSeminaryByUrl($seminaryUrl);
// Get Questgroup
$questgroup = $this->Questgroups->getQuestgroupByUrl($seminary['id'], $questgroupUrl);
$questgroup['hierarchy'] = $this->Questgroupshierarchy->getHierarchyForQuestgroup($questgroup['id']);
// Get Questgroup
$questgroup = $this->Questgroups->getQuestgroupByUrl($seminary['id'], $questgroupUrl);
$questgroup['hierarchy'] = $this->Questgroupshierarchy->getHierarchyForQuestgroup($questgroup['id']);
// Get parent Questgrouphierarchy
$currentQuestgroup = $questgroup;
$parentQuestgroupshierarchy = array();
if($showGroup) {
array_unshift($parentQuestgroupshierarchy, $currentQuestgroup);
}
if(is_null($questgroup['hierarchy']))
{
// Get related Questgroup
$questtexts = $this->Questtexts->getRelatedQuesttextsForQuestgroup($currentQuestgroup['id']);
$questtext = $this->Questtexts->pickQuesttextLastEnteredByCharacter(\hhu\z\controllers\SeminaryController::$character['id'], $questtexts);
$quest = $this->Quests->getQuestById($questtext['quest_id']);
$currentQuestgroup = $this->Questgroups->getQuestgroupById($quest['questgroup_id']);
$currentQuestgroup['hierarchy'] = $this->Questgroupshierarchy->getHierarchyForQuestgroup($currentQuestgroup['id']);
$quest['questgroup'] = $currentQuestgroup;
// Get parent Questgrouphierarchy
$currentQuestgroup = $questgroup;
$parentQuestgroupshierarchy = array();
if($showGroup) {
array_unshift($parentQuestgroupshierarchy, $currentQuestgroup);
}
if(is_null($questgroup['hierarchy']))
{
// Get related Questgroup
$questtexts = $this->Questtexts->getRelatedQuesttextsForQuestgroup($currentQuestgroup['id']);
$questtext = $this->Questtexts->pickQuesttextLastEnteredByCharacter(\hhu\z\controllers\SeminaryController::$character['id'], $questtexts);
$quest = $this->Quests->getQuestById($questtext['quest_id']);
$currentQuestgroup = $this->Questgroups->getQuestgroupById($quest['questgroup_id']);
$currentQuestgroup['hierarchy'] = $this->Questgroupshierarchy->getHierarchyForQuestgroup($currentQuestgroup['id']);
$quest['questgroup'] = $currentQuestgroup;
// Use Hierarchy name for optional Questgroup
if(!empty($parentQuestgroupshierarchy)) {
$parentQuestgroupshierarchy[0]['hierarchy'] = $currentQuestgroup['hierarchy'];
unset($parentQuestgroupshierarchy[0]['hierarchy']['questgroup_pos']);
}
// Use Hierarchy name for optional Questgroup
if(!empty($parentQuestgroupshierarchy)) {
$parentQuestgroupshierarchy[0]['hierarchy'] = $currentQuestgroup['hierarchy'];
unset($parentQuestgroupshierarchy[0]['hierarchy']['questgroup_pos']);
}
array_unshift($parentQuestgroupshierarchy, $quest);
array_unshift($parentQuestgroupshierarchy, $currentQuestgroup);
}
while(!empty($currentQuestgroup['hierarchy']) && !is_null($currentQuestgroup['hierarchy']['parent_questgroup_id']))
{
$currentQuestgroup = $this->Questgroups->GetQuestgroupById($currentQuestgroup['hierarchy']['parent_questgroup_id']);
$currentQuestgroup['hierarchy'] = $this->Questgroupshierarchy->getHierarchyForQuestgroup($currentQuestgroup['id']);
array_unshift($parentQuestgroupshierarchy, $currentQuestgroup);
}
array_unshift($parentQuestgroupshierarchy, $quest);
array_unshift($parentQuestgroupshierarchy, $currentQuestgroup);
}
while(!empty($currentQuestgroup['hierarchy']) && !is_null($currentQuestgroup['hierarchy']['parent_questgroup_id']))
{
$currentQuestgroup = $this->Questgroups->GetQuestgroupById($currentQuestgroup['hierarchy']['parent_questgroup_id']);
$currentQuestgroup['hierarchy'] = $this->Questgroupshierarchy->getHierarchyForQuestgroup($currentQuestgroup['id']);
array_unshift($parentQuestgroupshierarchy, $currentQuestgroup);
}
// Pass data to view
$this->set('seminary', $seminary);
$this->set('parentquestgroupshierarchy', $parentQuestgroupshierarchy);
}
// Pass data to view
$this->set('seminary', $seminary);
$this->set('parentquestgroupshierarchy', $parentQuestgroupshierarchy);
}
}
}
?>

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -1,89 +1,89 @@
<?php
/**
* The Legend of Z
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
* @license http://www.gnu.org/licenses/gpl.html
* @link https://bitbucket.org/coderkun/the-legend-of-z
*/
/**
* The Legend of Z
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
* @license http://www.gnu.org/licenses/gpl.html
* @link https://bitbucket.org/coderkun/the-legend-of-z
*/
namespace hhu\z\controllers;
namespace hhu\z\controllers;
/**
* Controller of the Agent to display a sidebar with Seminary related
* information.
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
*/
class SeminarybarController extends \hhu\z\Controller
{
/**
* Required models
*
* @var array
*/
public $models = array('characters', 'quests', 'questgroups', 'achievements', 'charactergroups', 'avatars', 'media', 'xplevels');
/**
* Controller of the Agent to display a sidebar with Seminary related
* information.
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
*/
class SeminarybarController extends \hhu\z\Controller
{
/**
* Required models
*
* @var array
*/
public $models = array('characters', 'quests', 'questgroups', 'achievements', 'charactergroups', 'avatars', 'media', 'xplevels');
/**
* Action: index.
*/
public function index()
{
// Do not render at first
$this->set('render', false);
/**
* Action: index.
*/
public function index()
{
// Do not render at first
$this->set('render', false);
// Get Seminary
$seminary = SeminaryController::$seminary;
if(is_null($seminary)) {
return;
}
// Get Seminary
$seminary = SeminaryController::$seminary;
if(is_null($seminary)) {
return;
}
// Get Character
$character = SeminaryController::$character;
if(is_null($character)) {
return;
}
$character['rank'] = $this->Characters->getXPRank($seminary['id'], $character['xps']);
// Get Character
$character = SeminaryController::$character;
if(is_null($character)) {
return;
}
$character['rank'] = $this->Characters->getXPRank($seminary['id'], $character['xps']);
// Get “last” Quest
$lastQuest = $this->Quests->getLastQuestForCharacter($character['id']);
if(!is_null($lastQuest)) {
$lastQuest['questgroup'] = $this->Questgroups->getQuestgroupById($lastQuest['questgroup_id']);
}
// Get “last” Quest
$lastQuest = $this->Quests->getLastQuestForCharacter($character['id']);
if(!is_null($lastQuest)) {
$lastQuest['questgroup'] = $this->Questgroups->getQuestgroupById($lastQuest['questgroup_id']);
}
// Get last achieved Achievement
$achievements = $this->Achievements->getAchievedAchievementsForCharacter($character['id'], false);
$lastAchievement = array_shift($achievements);
// Get last achieved Achievement
$achievements = $this->Achievements->getAchievedAchievementsForCharacter($character['id'], false);
$lastAchievement = array_shift($achievements);
// Get Character group members
$characterGroups = array();
foreach($this->Charactergroups->getGroupsForCharacter($character['id']) as $group)
{
$groupsgroup = $this->Charactergroups->getGroupsgroupById($group['charactergroupsgroup_id']);
if($groupsgroup['preferred'])
{
$group['members'] = $this->Characters->getCharactersForGroup($group['id']);
$characterGroups[] = $group;
}
}
// Get Character group members
$characterGroups = array();
foreach($this->Charactergroups->getGroupsForCharacter($character['id']) as $group)
{
$groupsgroup = $this->Charactergroups->getGroupsgroupById($group['charactergroupsgroup_id']);
if($groupsgroup['preferred'])
{
$group['members'] = $this->Characters->getCharactersForGroup($group['id']);
$characterGroups[] = $group;
}
}
// Pass data to view
$this->set('seminary', $seminary);
$this->set('character', $character);
$this->set('lastQuest', $lastQuest);
$this->set('lastAchievement', $lastAchievement);
$this->set('characterGroups', $characterGroups);
// Render now
$this->set('render', true);
}
// Pass data to view
$this->set('seminary', $seminary);
$this->set('character', $character);
$this->set('lastQuest', $lastQuest);
$this->set('lastAchievement', $lastAchievement);
$this->set('characterGroups', $characterGroups);
// Render now
$this->set('render', true);
}
}
}
?>

View file

@ -1,53 +1,53 @@
<?php
/**
* The Legend of Z
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
* @license http://www.gnu.org/licenses/gpl.html
* @link https://bitbucket.org/coderkun/the-legend-of-z
*/
/**
* The Legend of Z
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
* @license http://www.gnu.org/licenses/gpl.html
* @link https://bitbucket.org/coderkun/the-legend-of-z
*/
namespace hhu\z\controllers;
namespace hhu\z\controllers;
/**
* Controller of the Agent to display a menu with Seminary related
* links.
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
*/
class SeminarymenuController extends \hhu\z\Controller
{
/**
* Controller of the Agent to display a menu with Seminary related
* links.
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
*/
class SeminarymenuController extends \hhu\z\Controller
{
/**
* Prefilter.
*
* @param \nre\core\Request $request Current request
* @param \nre\core\Response $response Current response
*/
public function preFilter(\nre\core\Request $request, \nre\core\Response $response)
{
parent::preFilter($request, $response);
/**
* Prefilter.
*
* @param \nre\core\Request $request Current request
* @param \nre\core\Response $response Current response
*/
public function preFilter(\nre\core\Request $request, \nre\core\Response $response)
{
parent::preFilter($request, $response);
// Set userdata
$this->set('loggedUser', \hhu\z\controllers\IntermediateController::$user);
$this->set('loggedSeminary', \hhu\z\controllers\SeminaryController::$seminary);
$this->set('loggedCharacter', \hhu\z\controllers\SeminaryController::$character);
}
// Set userdata
$this->set('loggedUser', \hhu\z\controllers\IntermediateController::$user);
$this->set('loggedSeminary', \hhu\z\controllers\SeminaryController::$seminary);
$this->set('loggedCharacter', \hhu\z\controllers\SeminaryController::$character);
}
/**
* Action: index.
*/
public function index()
{
}
/**
* Action: index.
*/
public function index()
{
}
}
}
?>

View file

@ -1,55 +1,55 @@
<?php
/**
* The Legend of Z
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
* @license http://www.gnu.org/licenses/gpl.html
* @link https://bitbucket.org/coderkun/the-legend-of-z
*/
/**
* The Legend of Z
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
* @license http://www.gnu.org/licenses/gpl.html
* @link https://bitbucket.org/coderkun/the-legend-of-z
*/
namespace hhu\z\controllers;
namespace hhu\z\controllers;
/**
* Controller of the TextmailAgent for generating a simple text-mail
* message.
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
*/
class TextmailController extends \nre\core\Controller
{
/**
* Controller of the TextmailAgent for generating a simple text-mail
* message.
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
*/
class TextmailController extends \nre\core\Controller
{
/**
* Prefilter.
*
* @param \nre\core\Request $request Current request
* @param \nre\core\Response $response Current response
*/
public function preFilter(\nre\core\Request $request, \nre\core\Response $response)
{
parent::preFilter($request, $response);
/**
* Prefilter.
*
* @param \nre\core\Request $request Current request
* @param \nre\core\Response $response Current response
*/
public function preFilter(\nre\core\Request $request, \nre\core\Response $response)
{
parent::preFilter($request, $response);
// Set linker
$this->set('linker', ($request instanceof \hhu\z\requests\MailRequest && !is_null($request->getLinker())) ? $request->getLinker() : null);
}
// Set linker
$this->set('linker', ($request instanceof \hhu\z\requests\MailRequest && !is_null($request->getLinker())) ? $request->getLinker() : null);
}
/**
* Action: index.
*
* Create simple text-mail message.
*/
public function index()
{
$this->set('appname', \nre\configs\AppConfig::$app['name']);
}
/**
* Action: index.
*
* Create simple text-mail message.
*/
public function index()
{
$this->set('appname', \nre\configs\AppConfig::$app['name']);
}
}
}
?>

View file

@ -1,318 +1,318 @@
<?php
/**
* The Legend of Z
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
* @license http://www.gnu.org/licenses/gpl.html
* @link https://bitbucket.org/coderkun/the-legend-of-z
*/
/**
* The Legend of Z
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
* @license http://www.gnu.org/licenses/gpl.html
* @link https://bitbucket.org/coderkun/the-legend-of-z
*/
namespace hhu\z\controllers;
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')
);
/**
* 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);
/**
* 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));
}
// 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);
/**
* 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);
// 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']));
// 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();
}
}
}
}
// 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;
}
// 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);
}
// 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);
/**
* 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 groups-group
$groupsgroup = $this->Charactergroups->getGroupsgroupByUrl($seminary['id'], $groupsgroupUrl);
// Get Character group
$group = $this->Charactergroups->getGroupByUrl($groupsgroup['id'], $groupUrl);
// Get Character group
$group = $this->Charactergroups->getGroupByUrl($groupsgroup['id'], $groupUrl);
// Get Upload
$upload = $this->Uploads->getSeminaryuploadById($group['seminaryupload_id']);
// Get Upload
$upload = $this->Uploads->getSeminaryuploadById($group['seminaryupload_id']);
// Get file
$file = $this->getUploadFile($upload);
if(is_null($file)) {
return;
}
// Get file
$file = $this->getUploadFile($upload);
if(is_null($file)) {
return;
}
// Pass data to view
$this->set('upload', $upload);
$this->set('file', $file);
}
// 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']."");
/**
* 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);
}
// 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;
}
// Cache
if($this->setCacheHeaders($upload['filename'])) {
return null;
}
return file_get_contents($upload['filename']);
}
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'];
/**
* 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");
// Set content-type
$this->response->addHeader("Content-type: image/jpeg");
// Check file
if(!file_exists($upload['filename'])) {
throw new \nre\exceptions\IdNotFoundException($upload['url']);
}
// Check file
if(!file_exists($upload['filename'])) {
throw new \nre\exceptions\IdNotFoundException($upload['url']);
}
// Cache
if($this->setCacheHeaders($upload['filename'])) {
return null;
}
// Cache
if($this->setCacheHeaders($upload['filename'])) {
return null;
}
// Set geometry
$width = 100;
$height = 100;
// 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);
}
}
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']);
// 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'];
}
// 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');
// Process
$im->thumbnailImage($width, $height, true);
$im->contrastImage(1);
$im->setImageFormat('jpeg');
// Save temporary file
$im->writeImage($tempFileName);
// Save temporary file
$im->writeImage($tempFileName);
// Return resized image
return $im;
break;
default:
throw new \nre\exceptions\ParamsNotValidException('thumbnail');
break;
}
// Return resized image
return $im;
break;
default:
throw new \nre\exceptions\ParamsNotValidException('thumbnail');
break;
}
return $this->getUploadFile($upload);
}
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));
/**
* 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);
// 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));
// 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 true;
}
return false;
}
return false;
}
}
}
?>

View file

@ -1,47 +1,47 @@
<?php
/**
* The Legend of Z
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
* @license http://www.gnu.org/licenses/gpl.html
* @link https://bitbucket.org/coderkun/the-legend-of-z
*/
/**
* The Legend of Z
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
* @license http://www.gnu.org/licenses/gpl.html
* @link https://bitbucket.org/coderkun/the-legend-of-z
*/
namespace hhu\z\controllers;
namespace hhu\z\controllers;
/**
* Controller of the Agent to display and manage userroles.
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
*/
class UserrolesController extends \hhu\z\Controller
{
/**
* Controller of the Agent to display and manage userroles.
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
*/
class UserrolesController extends \hhu\z\Controller
{
/**
* Action: user.
*
* Show a user and its details.
*
* @throws \nre\exceptions\IdNotFoundException
* @param string $userUrl URL-Username of an user
*/
public function user($userUrl)
{
// Get userroles
$roles = $this->Userroles->getUserrolesForUserByUrl($userUrl);
/**
* Action: user.
*
* Show a user and its details.
*
* @throws \nre\exceptions\IdNotFoundException
* @param string $userUrl URL-Username of an user
*/
public function user($userUrl)
{
// Get userroles
$roles = $this->Userroles->getUserrolesForUserByUrl($userUrl);
// Pass data to view
$this->set('roles', $roles);
}
// Pass data to view
$this->set('roles', $roles);
}
}
}
?>

File diff suppressed because it is too large Load diff

View file

@ -1,188 +1,188 @@
<?php
/**
* The Legend of Z
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
* @license http://www.gnu.org/licenses/gpl.html
* @link https://bitbucket.org/coderkun/the-legend-of-z
*/
/**
* The Legend of Z
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
* @license http://www.gnu.org/licenses/gpl.html
* @link https://bitbucket.org/coderkun/the-legend-of-z
*/
namespace hhu\z\controllers;
namespace hhu\z\controllers;
/**
* Controller of the XplevelsAgent to handle XP-levels of a
* Seminary.
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
*/
class XplevelsController extends \hhu\z\controllers\SeminaryController
{
/**
* Required components
*
* @var array
*/
public $components = array('validation');
/**
* Required models
*
* @var array
*/
public $models = array('xplevels');
/**
* User permissions
*
* @var array
*/
public $permissions = array(
'manage' => array('admin', 'moderator', 'user')
);
/**
* Controller of the XplevelsAgent to handle XP-levels of a
* Seminary.
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
*/
class XplevelsController extends \hhu\z\controllers\SeminaryController
{
/**
* Required components
*
* @var array
*/
public $components = array('validation');
/**
* Required models
*
* @var array
*/
public $models = array('xplevels');
/**
* User permissions
*
* @var array
*/
public $permissions = array(
'manage' => array('admin', 'moderator', 'user')
);
/**
* Action: manage.
*
* Manage XP-levels.
*
* @throws \nre\exceptions\IdNotFoundException
* @param string $seminaryUrl URL-Title of a Seminary
*/
public function manage($seminaryUrl)
{
// Get seminary
$seminary = $this->Seminaries->getSeminaryByUrl($seminaryUrl);
/**
* Action: manage.
*
* Manage XP-levels.
*
* @throws \nre\exceptions\IdNotFoundException
* @param string $seminaryUrl URL-Title of a Seminary
*/
public function manage($seminaryUrl)
{
// Get seminary
$seminary = $this->Seminaries->getSeminaryByUrl($seminaryUrl);
// Check permissions
if(
(is_null(self::$character) && count(array_intersect(array('admin', 'moderator'), \hhu\z\controllers\IntermediateController::$user['roles'])) == 0) &&
$seminary['created_user_id'] != self::$user['id']
) {
throw new \nre\exceptions\AccessDeniedException();
}
// Check permissions
if(
(is_null(self::$character) && count(array_intersect(array('admin', 'moderator'), \hhu\z\controllers\IntermediateController::$user['roles'])) == 0) &&
$seminary['created_user_id'] != self::$user['id']
) {
throw new \nre\exceptions\AccessDeniedException();
}
// Get XP-levels
$xplevels = $this->Xplevels->getXPLevelsForSeminary($seminary['id']);
// Get XP-levels
$xplevels = $this->Xplevels->getXPLevelsForSeminary($seminary['id']);
// Values
$xplevelsValues = array();
foreach($xplevels as &$xplevel) {
$xplevelsValues[$xplevel['id']] = $xplevel;
}
$deletes = array();
$validations = array(
'edit' => true,
'create' => true
);
// Values
$xplevelsValues = array();
foreach($xplevels as &$xplevel) {
$xplevelsValues[$xplevel['id']] = $xplevel;
}
$deletes = array();
$validations = array(
'edit' => true,
'create' => true
);
// Edit
$action = null;
if($this->request->getRequestMethod() == 'POST')
{
// Edit and delete XP-levels
if(!is_null($this->request->getPostParam('edit')))
{
$action = 'edit';
// Edit
$action = null;
if($this->request->getRequestMethod() == 'POST')
{
// Edit and delete XP-levels
if(!is_null($this->request->getPostParam('edit')))
{
$action = 'edit';
// Get params
$xplevelsValues = $this->request->getPostParam('xplevels');
$deletes = $this->request->getPostParam('deletes');
// Validate params
if(!is_array($deletes)) {
$deletes = array();
}
foreach($xplevels as &$xplevel)
{
if(array_key_exists($xplevel['id'], $deletes)) {
continue;
}
// 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);
}
}
$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']
);
}
}
// 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));
}
}
// Redirect
$this->redirect($this->linker->link(null, 3));
}
}
// Create XP-level
if(!is_null($this->request->getPostParam('create')))
{
$action = 'create';
// Create XP-level
if(!is_null($this->request->getPostParam('create')))
{
$action = 'create';
// Get params and validate them
// Get params and validate them
$xplevelnew = $this->request->getPostParam('xplevelnew');
$validations[$action] = $this->Validation->validateParams($xplevelnew, array('xps'));
$validations[$action] = $this->Validation->validateParams($xplevelnew, array('xps'));
// Create
if($validations[$action] === true)
{
$this->Xplevels->createXPLevel(
$this->Auth->getUserId(),
$seminary['id'],
$xplevelnew['xps']
);
// Create
if($validations[$action] === true)
{
$this->Xplevels->createXPLevel(
$this->Auth->getUserId(),
$seminary['id'],
$xplevelnew['xps']
);
// Redirect
$this->redirect($this->linker->link(null, 3));
}
}
}
// Redirect
$this->redirect($this->linker->link(null, 3));
}
}
}
// Get validation settings
$validationSettings = array(
'xps' => \nre\configs\AppConfig::$validation['xps']
);
// Get validation settings
$validationSettings = array(
'xps' => \nre\configs\AppConfig::$validation['xps']
);
// Set titile
$this->addTitleLocalized('Manage XP-levels');
$this->addTitle($seminary['title']);
// 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);
}
// 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);
}
}
}
?>

View file

@ -1,41 +1,41 @@
<?php
/**
* The Legend of Z
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
* @license http://www.gnu.org/licenses/gpl.html
* @link https://bitbucket.org/coderkun/the-legend-of-z
*/
/**
* The Legend of Z
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
* @license http://www.gnu.org/licenses/gpl.html
* @link https://bitbucket.org/coderkun/the-legend-of-z
*/
namespace hhu\z\controllers\components;
namespace hhu\z\controllers\components;
/**
* Component to handle achievements.
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
*/
class AchievementComponent extends \nre\core\Component
{
/**
* Required models
*
* @var array
*/
public $models = array('achievements');
/**
* Component to handle achievements.
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
*/
class AchievementComponent extends \nre\core\Component
{
/**
* Required models
*
* @var array
*/
public $models = array('achievements');
/**
* Construct a new Achievements-component.
*/
public function __construct()
{
}
/**
* Construct a new Achievements-component.
*/
public function __construct()
{
}
}
}
?>

View file

@ -1,79 +1,79 @@
<?php
/**
* The Legend of Z
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
* @license http://www.gnu.org/licenses/gpl.html
* @link https://bitbucket.org/coderkun/the-legend-of-z
*/
/**
* The Legend of Z
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
* @license http://www.gnu.org/licenses/gpl.html
* @link https://bitbucket.org/coderkun/the-legend-of-z
*/
namespace hhu\z\controllers\components;
namespace hhu\z\controllers\components;
/**
* Component to handle authentication and authorization.
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
*/
class AuthComponent extends \nre\core\Component
{
/**
* Key to save a user-ID as
*
* @var string
*/
const KEY_USER_ID = 'user_id';
/**
* Component to handle authentication and authorization.
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
*/
class AuthComponent extends \nre\core\Component
{
/**
* Key to save a user-ID as
*
* @var string
*/
const KEY_USER_ID = 'user_id';
/**
* Construct a new Auth-component.
*/
public function __construct()
{
// Start session
if(session_id() === '') {
session_start();
}
}
/**
* Construct a new Auth-component.
*/
public function __construct()
{
// Start session
if(session_id() === '') {
session_start();
}
}
/**
* Set the ID of the user that is currently logged in.
*
* @param int $userId ID of the currently logged in user
*/
public function setUserId($userId)
{
if(is_null($userId)) {
unset($_SESSION[self::KEY_USER_ID]);
}
else {
$_SESSION[self::KEY_USER_ID] = $userId;
}
}
/**
* Set the ID of the user that is currently logged in.
*
* @param int $userId ID of the currently logged in user
*/
public function setUserId($userId)
{
if(is_null($userId)) {
unset($_SESSION[self::KEY_USER_ID]);
}
else {
$_SESSION[self::KEY_USER_ID] = $userId;
}
}
/**
* Get the ID of the user that is currently logged in.
*
* @return int ID of the currently logged in user
*/
public function getUserId()
{
if(array_key_exists(self::KEY_USER_ID, $_SESSION)) {
return $_SESSION[self::KEY_USER_ID];
}
/**
* Get the ID of the user that is currently logged in.
*
* @return int ID of the currently logged in user
*/
public function getUserId()
{
if(array_key_exists(self::KEY_USER_ID, $_SESSION)) {
return $_SESSION[self::KEY_USER_ID];
}
return null;
}
return null;
}
}
}
?>

View file

@ -1,108 +1,108 @@
<?php
/**
* The Legend of Z
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
* @license http://www.gnu.org/licenses/gpl.html
* @link https://bitbucket.org/coderkun/the-legend-of-z
*/
/**
* The Legend of Z
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
* @license http://www.gnu.org/licenses/gpl.html
* @link https://bitbucket.org/coderkun/the-legend-of-z
*/
namespace hhu\z\controllers\components;
namespace hhu\z\controllers\components;
/**
* Component to handle user notifications
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
*/
class NotificationComponent extends \nre\core\Component
{
/**
* Type: Achievement
*
* @var string
*/
const TYPE_ACHIEVEMENT = 'achievement';
/**
* Type: Level-up
*
* @var string
*/
const TYPE_LEVELUP = 'levelup';
/**
* Key for Session-Array to store notifications in
*
* @var string
*/
const SESSION_KEY = 'notifications';
/**
* Component to handle user notifications
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
*/
class NotificationComponent extends \nre\core\Component
{
/**
* Type: Achievement
*
* @var string
*/
const TYPE_ACHIEVEMENT = 'achievement';
/**
* Type: Level-up
*
* @var string
*/
const TYPE_LEVELUP = 'levelup';
/**
* Key for Session-Array to store notifications in
*
* @var string
*/
const SESSION_KEY = 'notifications';
/**
* Construct a new Notification-component.
*/
public function __construct()
{
// Start session
if(session_id() === '') {
session_start();
}
/**
* Construct a new Notification-component.
*/
public function __construct()
{
// Start session
if(session_id() === '') {
session_start();
}
// Prepare array
if(!array_key_exists(self::SESSION_KEY, $_SESSION)) {
$_SESSION[self::SESSION_KEY] = array();
}
}
// Prepare array
if(!array_key_exists(self::SESSION_KEY, $_SESSION)) {
$_SESSION[self::SESSION_KEY] = array();
}
}
/**
* Add a notification.
*
* @param string $type Type of notification
* @param string $message Message to display
* @param string $link Optional URL to link to
* @param string $image Optional URL of image to display
*/
public function addNotification($type, $message, $link=null, $image=null)
{
$_SESSION[self::SESSION_KEY][] = array(
'type' => $type,
'message' => $message,
'link' => $link,
'image' => $image
);
}
/**
* Add a notification.
*
* @param string $type Type of notification
* @param string $message Message to display
* @param string $link Optional URL to link to
* @param string $image Optional URL of image to display
*/
public function addNotification($type, $message, $link=null, $image=null)
{
$_SESSION[self::SESSION_KEY][] = array(
'type' => $type,
'message' => $message,
'link' => $link,
'image' => $image
);
}
/**
* Get all registered notifiactions and clear them.
*
* @return array List of existing notifications
*/
public function getNotifications()
{
$notifications = $_SESSION[self::SESSION_KEY];
$this->clearNotifications();
/**
* Get all registered notifiactions and clear them.
*
* @return array List of existing notifications
*/
public function getNotifications()
{
$notifications = $_SESSION[self::SESSION_KEY];
$this->clearNotifications();
return $notifications;
}
return $notifications;
}
/**
* Clear all notifications currently registered
*/
public function clearNotifications()
{
unset($_SESSION[self::SESSION_KEY]);
$_SESSION[self::SESSION_KEY] = array();
}
/**
* Clear all notifications currently registered
*/
public function clearNotifications()
{
unset($_SESSION[self::SESSION_KEY]);
$_SESSION[self::SESSION_KEY] = array();
}
}
}
?>

View file

@ -3,10 +3,10 @@
/**
* The Legend of Z
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
* @license http://www.gnu.org/licenses/gpl.html
* @link https://bitbucket.org/coderkun/the-legend-of-z
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
* @license http://www.gnu.org/licenses/gpl.html
* @link https://bitbucket.org/coderkun/the-legend-of-z
*/
namespace hhu\z\controllers\components;
@ -15,7 +15,7 @@
/**
* 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
{

View file

@ -1,183 +1,183 @@
<?php
/**
* The Legend of Z
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
* @license http://www.gnu.org/licenses/gpl.html
* @link https://bitbucket.org/coderkun/the-legend-of-z
*/
/**
* The Legend of Z
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
* @license http://www.gnu.org/licenses/gpl.html
* @link https://bitbucket.org/coderkun/the-legend-of-z
*/
namespace hhu\z\controllers\components;
namespace hhu\z\controllers\components;
/**
* Component to validate user input.
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
*/
class ValidationComponent extends \nre\core\Component
{
/**
* Validation settings
*
* @var array
*/
private $config;
/**
* Component to validate user input.
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
*/
class ValidationComponent extends \nre\core\Component
{
/**
* Validation settings
*
* @var array
*/
private $config;
/**
* Construct a new Validation-component.
*/
public function __construct()
{
// Get validation settings from configuration
$this->config = \nre\configs\AppConfig::$validation;
}
/**
* Construct a new Validation-component.
*/
public function __construct()
{
// Get validation settings from configuration
$this->config = \nre\configs\AppConfig::$validation;
}
/**
* Validate an user input.
*
* @param mixed $input User input to validate
* @param array $settings Validation setting
* @return mixed True or the settings the validation fails on
*/
public function validate($input, $settings)
{
$validation = array();
/**
* Validate an user input.
*
* @param mixed $input User input to validate
* @param array $settings Validation setting
* @return mixed True or the settings the validation fails on
*/
public function validate($input, $settings)
{
$validation = array();
// Min string length
if(array_key_exists('minlength', $settings) && strlen($input) < $settings['minlength']) {
$validation['minlength'] = $settings['minlength'];
}
// Max string length
if(array_key_exists('maxlength', $settings) && strlen($input) > $settings['maxlength']) {
$validation['maxlength'] = $settings['maxlength'];
}
// Min string length
if(array_key_exists('minlength', $settings) && strlen($input) < $settings['minlength']) {
$validation['minlength'] = $settings['minlength'];
}
// Max string length
if(array_key_exists('maxlength', $settings) && strlen($input) > $settings['maxlength']) {
$validation['maxlength'] = $settings['maxlength'];
}
// Regex
if(array_key_exists('regex', $settings) && !preg_match($settings['regex'], $input)) {
$validation['regex'] = $settings['regex'];
}
// Regex
if(array_key_exists('regex', $settings) && !preg_match($settings['regex'], $input)) {
$validation['regex'] = $settings['regex'];
}
// Return true or the failed fields
if(empty($validation)) {
return true;
}
return $validation;
}
// Return true or the failed fields
if(empty($validation)) {
return true;
}
return $validation;
}
/**
* Validate an user input parameter.
*
* @param array $params User input parameters
* @param array $index Names of parameter to validate and to validate against
* @return mixed True or the parameter with settings the validation failed on
*/
public function validateParam($params, $index)
{
// Check parameter
if(!array_key_exists($index, $params)) {
throw new \nre\exceptions\ParamsNotValidException($index);
}
// Check settings
if(!array_key_exists($index, $this->config)) {
return true;
}
/**
* Validate an user input parameter.
*
* @param array $params User input parameters
* @param array $index Names of parameter to validate and to validate against
* @return mixed True or the parameter with settings the validation failed on
*/
public function validateParam($params, $index)
{
// Check parameter
if(!array_key_exists($index, $params)) {
throw new \nre\exceptions\ParamsNotValidException($index);
}
// Check settings
if(!array_key_exists($index, $this->config)) {
return true;
}
// Validate parameter and return result
return $this->validate($params[$index], $this->config[$index]);
}
// Validate parameter and return result
return $this->validate($params[$index], $this->config[$index]);
}
/**
* Validate user input parameters.
*
* @param array $params User input parameters
* @param array $indices Names of parameters to validate and to validate against
* @return mixed True or the parameters with settings the validation failed on
*/
public function validateParams($params, $indices)
{
// Validate parameters
$validation = true;
foreach($indices as $index) {
$validation = $this->addValidationResults($validation, $index, $this->validateParam($params, $index));
}
/**
* Validate user input parameters.
*
* @param array $params User input parameters
* @param array $indices Names of parameters to validate and to validate against
* @return mixed True or the parameters with settings the validation failed on
*/
public function validateParams($params, $indices)
{
// Validate parameters
$validation = true;
foreach($indices as $index) {
$validation = $this->addValidationResults($validation, $index, $this->validateParam($params, $index));
}
// Return validation results
return $validation;
}
// Return validation results
return $validation;
}
/**
* Add a custom determined validation result to a validation
* array.
*
* @param mixed $validation Validation array to add result to
* @param string $index Name of parameter of the custom validation result
* @param string $setting Name of setting of the custom validation result
* @param mixed $result Validation result
* @return mixed The altered validation array
*/
public function addValidationResult($validation, $index, $setting, $result)
{
// Create validation array
if(!is_array($validation)) {
$validation = array();
}
/**
* Add a custom determined validation result to a validation
* array.
*
* @param mixed $validation Validation array to add result to
* @param string $index Name of parameter of the custom validation result
* @param string $setting Name of setting of the custom validation result
* @param mixed $result Validation result
* @return mixed The altered validation array
*/
public function addValidationResult($validation, $index, $setting, $result)
{
// Create validation array
if(!is_array($validation)) {
$validation = array();
}
// Add validation results
if(!array_key_exists($index, $validation)) {
$validation[$index] = array();
}
$validation[$index][$setting] = $result;
// Add validation results
if(!array_key_exists($index, $validation)) {
$validation[$index] = array();
}
$validation[$index][$setting] = $result;
// Return new validation result
return $validation;
}
// Return new validation result
return $validation;
}
/**
* Add custom determined validation results to a validation
* arary.
*
* @param mixed $validation Validation array to add result to
* @param string $index Name of parameter of the custom validation result
* @param mixed $result Validation result
* @return mixed The altered validation array
*/
public function addValidationResults($validation, $index, $results)
{
// Create validation array
if(!is_array($validation)) {
$validation = array();
}
/**
* Add custom determined validation results to a validation
* arary.
*
* @param mixed $validation Validation array to add result to
* @param string $index Name of parameter of the custom validation result
* @param mixed $result Validation result
* @return mixed The altered validation array
*/
public function addValidationResults($validation, $index, $results)
{
// Create validation array
if(!is_array($validation)) {
$validation = array();
}
// Add validation results
if($results !== true) {
$validation[$index] = $results;
}
// Add validation results
if($results !== true) {
$validation[$index] = $results;
}
// Return new validation result
if(empty($validation)) {
return true;
}
return $validation;
}
// Return new validation result
if(empty($validation)) {
return true;
}
return $validation;
}
}
}
?>

File diff suppressed because it is too large Load diff

View file

@ -1,177 +1,177 @@
<?php
/**
* The Legend of Z
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
* @license http://www.gnu.org/licenses/gpl.html
* @link https://bitbucket.org/coderkun/the-legend-of-z
*/
/**
* The Legend of Z
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
* @license http://www.gnu.org/licenses/gpl.html
* @link https://bitbucket.org/coderkun/the-legend-of-z
*/
namespace hhu\z\models;
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');
/**
* 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();
}
/**
* 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];
}
/**
* 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;
}
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);
}
/**
* 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];
}
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);
}
/**
* 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];
}
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 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
);
}
/**
* 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
);
}
/**
@ -218,6 +218,6 @@
}
}
}
}
?>

View file

@ -1,181 +1,181 @@
<?php
/**
* The Legend of Z
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
* @license http://www.gnu.org/licenses/gpl.html
* @link https://bitbucket.org/coderkun/the-legend-of-z
*/
/**
* The Legend of Z
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
* @license http://www.gnu.org/licenses/gpl.html
* @link https://bitbucket.org/coderkun/the-legend-of-z
*/
namespace hhu\z\models;
namespace hhu\z\models;
/**
* Model of the CharactergroupsAgent to interact with
* Charactergroups-table.
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
*/
class CharactergroupsModel extends \hhu\z\Model
{
/**
* Model of the CharactergroupsAgent to interact with
* Charactergroups-table.
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
*/
class CharactergroupsModel extends \hhu\z\Model
{
/**
* Construct a new CharactergroupsModel.
*/
public function __construct()
{
parent::__construct();
}
/**
* Construct a new CharactergroupsModel.
*/
public function __construct()
{
parent::__construct();
}
/**
* Get Character groups-groups of a Seminary.
*
* @param int $seminaryId ID of the corresponding Seminary
* @return array Character groups-groups data
*/
public function getGroupsroupsForSeminary($seminaryId)
{
return $this->db->query(
'SELECT id, name, url, preferred '.
'FROM charactergroupsgroups '.
'WHERE seminary_id = ?',
'i',
$seminaryId
);
}
/**
* Get Character groups-groups of a Seminary.
*
* @param int $seminaryId ID of the corresponding Seminary
* @return array Character groups-groups data
*/
public function getGroupsroupsForSeminary($seminaryId)
{
return $this->db->query(
'SELECT id, name, url, preferred '.
'FROM charactergroupsgroups '.
'WHERE seminary_id = ?',
'i',
$seminaryId
);
}
/**
* Get a Character groups-group by its URL.
*
* @throws \nre\exceptions\IdNotFoundException
* @param int $seminaryId ID of the corresponding Seminary
* @param string $groupsgroupUrl URL-name of the Character groups-group
* @return array Character groups-group data
*/
public function getGroupsgroupByUrl($seminaryId, $groupsgroupUrl)
{
$data = $this->db->query(
'SELECT id, name, url, preferred '.
'FROM charactergroupsgroups '.
'WHERE seminary_id = ? AND url = ?',
'is',
$seminaryId, $groupsgroupUrl
);
if(empty($data)) {
throw new \nre\exceptions\IdNotFoundException($groupsgroupUrl);
}
/**
* Get a Character groups-group by its URL.
*
* @throws \nre\exceptions\IdNotFoundException
* @param int $seminaryId ID of the corresponding Seminary
* @param string $groupsgroupUrl URL-name of the Character groups-group
* @return array Character groups-group data
*/
public function getGroupsgroupByUrl($seminaryId, $groupsgroupUrl)
{
$data = $this->db->query(
'SELECT id, name, url, preferred '.
'FROM charactergroupsgroups '.
'WHERE seminary_id = ? AND url = ?',
'is',
$seminaryId, $groupsgroupUrl
);
if(empty($data)) {
throw new \nre\exceptions\IdNotFoundException($groupsgroupUrl);
}
return $data[0];
}
return $data[0];
}
/**
* Get a Character groups-group by its ID.
*
* @throws \nre\exceptions\IdNotFoundException
* @param string $groupsgroupId ID of the Character groups-group
* @return array Character groups-group data
*/
public function getGroupsgroupById($groupsgroupId)
{
$data = $this->db->query(
'SELECT id, name, url, preferred '.
'FROM charactergroupsgroups '.
'WHERE id = ?',
'i',
$groupsgroupId
);
if(empty($data)) {
throw new \nre\exceptions\IdNotFoundException($groupsgroupId);
}
/**
* Get a Character groups-group by its ID.
*
* @throws \nre\exceptions\IdNotFoundException
* @param string $groupsgroupId ID of the Character groups-group
* @return array Character groups-group data
*/
public function getGroupsgroupById($groupsgroupId)
{
$data = $this->db->query(
'SELECT id, name, url, preferred '.
'FROM charactergroupsgroups '.
'WHERE id = ?',
'i',
$groupsgroupId
);
if(empty($data)) {
throw new \nre\exceptions\IdNotFoundException($groupsgroupId);
}
return $data[0];
}
return $data[0];
}
/**
* Check if a Character groups-group name already exists.
*
* @param string $name Name to check
* @param int $groupsgroupId Do not check this ID (for editing)
* @return boolean Whether name exists or not
*/
public function characterGroupsgroupNameExists($name, $groupsgroupId=null)
{
$data = $this->db->query(
'SELECT id '.
'FROM charactergroupsgroups '.
'WHERE name = ? OR url = ?',
'ss',
$name,
\nre\core\Linker::createLinkParam($name)
);
/**
* Check if a Character groups-group name already exists.
*
* @param string $name Name to check
* @param int $groupsgroupId Do not check this ID (for editing)
* @return boolean Whether name exists or not
*/
public function characterGroupsgroupNameExists($name, $groupsgroupId=null)
{
$data = $this->db->query(
'SELECT id '.
'FROM charactergroupsgroups '.
'WHERE name = ? OR url = ?',
'ss',
$name,
\nre\core\Linker::createLinkParam($name)
);
return (!empty($data) && (is_null($groupsgroupId) || $groupsgroupId != $data[0]['id']));
}
return (!empty($data) && (is_null($groupsgroupId) || $groupsgroupId != $data[0]['id']));
}
/**
* Create a new Character groups-group.
*
* @param int $userId ID of user
* @param int $seminaryId ID of Seminary
* @param string $name Name of new groups-group
* @param boolean $preferred Whether groups-group is preferred or not
* @return int ID of newly created groups-group
*/
public function createGroupsgroup($userId, $seminaryId, $name, $preferred)
{
$this->db->query(
'INSERT INTO charactergroupsgroups '.
'(created_user_id, seminary_id, name, url, preferred) '.
'VALUES '.
'(?, ?, ?, ?, ?)',
'iissd',
$userId,
$seminaryId,
$name,
\nre\core\Linker::createLinkParam($name),
$preferred
);
/**
* Create a new Character groups-group.
*
* @param int $userId ID of user
* @param int $seminaryId ID of Seminary
* @param string $name Name of new groups-group
* @param boolean $preferred Whether groups-group is preferred or not
* @return int ID of newly created groups-group
*/
public function createGroupsgroup($userId, $seminaryId, $name, $preferred)
{
$this->db->query(
'INSERT INTO charactergroupsgroups '.
'(created_user_id, seminary_id, name, url, preferred) '.
'VALUES '.
'(?, ?, ?, ?, ?)',
'iissd',
$userId,
$seminaryId,
$name,
\nre\core\Linker::createLinkParam($name),
$preferred
);
return $this->db->getInsertId();
}
return $this->db->getInsertId();
}
/**
* Edit a Character groups-group.
*
* @param int $groupsgroupId ID of groups-group to edit
* @param string $name New name of groups-group
* @param boolean $preferred Whether groups-group is preferred or not
*/
public function editGroupsgroup($groupsgroupId, $name, $preferred)
{
$this->db->query(
'UPDATE charactergroupsgroups '.
'SET name = ?, url = ?, preferred = ? '.
'WHERE id = ?',
'ssdi',
$name,
\nre\core\Linker::createLinkParam($name),
$preferred,
$groupsgroupId
);
}
/**
* Edit a Character groups-group.
*
* @param int $groupsgroupId ID of groups-group to edit
* @param string $name New name of groups-group
* @param boolean $preferred Whether groups-group is preferred or not
*/
public function editGroupsgroup($groupsgroupId, $name, $preferred)
{
$this->db->query(
'UPDATE charactergroupsgroups '.
'SET name = ?, url = ?, preferred = ? '.
'WHERE id = ?',
'ssdi',
$name,
\nre\core\Linker::createLinkParam($name),
$preferred,
$groupsgroupId
);
}
/**
@ -214,328 +214,328 @@
}
/**
* Delete a Character groups-group.
*
* @param int $groupsgroupId ID of groups-group to delete
*/
public function deleteGroupsgroup($groupsgroupId)
{
$this->db->query('DELETE FROM charactergroupsgroups WHERE id = ?', 'i', $groupsgroupId);
}
/**
* Delete a Character groups-group.
*
* @param int $groupsgroupId ID of groups-group to delete
*/
public function deleteGroupsgroup($groupsgroupId)
{
$this->db->query('DELETE FROM charactergroupsgroups WHERE id = ?', 'i', $groupsgroupId);
}
/**
* Get Character groups for a Character groups-group.
*
* @param int $groupsgroupId ID of the Character groups-group
* @param string $sortorder Field to sort by (optional)
* @return array Character groups
*/
public function getGroupsForGroupsgroup($groupsgroupId, $sortorder='name')
{
// Set sort order
switch($sortorder)
{
case 'xps':
$sortorder = 'xps DESC';
break;
case 'name':
default:
$sortorder = 'name ASC';
break;
}
/**
* Get Character groups for a Character groups-group.
*
* @param int $groupsgroupId ID of the Character groups-group
* @param string $sortorder Field to sort by (optional)
* @return array Character groups
*/
public function getGroupsForGroupsgroup($groupsgroupId, $sortorder='name')
{
// Set sort order
switch($sortorder)
{
case 'xps':
$sortorder = 'xps DESC';
break;
case 'name':
default:
$sortorder = 'name ASC';
break;
}
// Get and return Character groups
return $this->db->query(
'SELECT '.
'charactergroups.id, charactergroups.name, charactergroups.url, charactergroups.motto, charactergroups.charactergroupsmedia_id, '.
'cache_charactergroups.xps '.
'FROM charactergroups '.
'LEFT JOIN cache_charactergroups ON cache_charactergroups.charactergroup_id = charactergroups.id '.
'WHERE charactergroups.charactergroupsgroup_id = ? '.
"ORDER BY $sortorder",
'i',
$groupsgroupId
);
}
// Get and return Character groups
return $this->db->query(
'SELECT '.
'charactergroups.id, charactergroups.name, charactergroups.url, charactergroups.motto, charactergroups.charactergroupsmedia_id, '.
'cache_charactergroups.xps '.
'FROM charactergroups '.
'LEFT JOIN cache_charactergroups ON cache_charactergroups.charactergroup_id = charactergroups.id '.
'WHERE charactergroups.charactergroupsgroup_id = ? '.
"ORDER BY $sortorder",
'i',
$groupsgroupId
);
}
/**
* Get Character groups for a Character.
*
* @param int $characterId ID of the Character
* @return array Character groups
*/
public function getGroupsForCharacter($characterId)
{
return $this->db->query(
'SELECT '.
'charactergroups.id, charactergroups.charactergroupsgroup_id, charactergroups.name, charactergroups.url, charactergroups.charactergroupsmedia_id, '.
'cache_charactergroups.xps, '.
'charactergroupsgroups.id AS charactergroupsgroup_id, charactergroupsgroups.name AS charactergroupsgroup_name, charactergroupsgroups.url AS charactergroupsgroup_url '.
'FROM characters_charactergroups '.
'LEFT JOIN charactergroups ON charactergroups.id = characters_charactergroups.charactergroup_id '.
'LEFT JOIN cache_charactergroups ON cache_charactergroups.charactergroup_id = charactergroups.id '.
'LEFT JOIN charactergroupsgroups ON charactergroupsgroups.id = charactergroups.charactergroupsgroup_id '.
'WHERE characters_charactergroups.character_id = ?',
'i',
$characterId
);
}
/**
* Get Character groups for a Character.
*
* @param int $characterId ID of the Character
* @return array Character groups
*/
public function getGroupsForCharacter($characterId)
{
return $this->db->query(
'SELECT '.
'charactergroups.id, charactergroups.charactergroupsgroup_id, charactergroups.name, charactergroups.url, charactergroups.charactergroupsmedia_id, '.
'cache_charactergroups.xps, '.
'charactergroupsgroups.id AS charactergroupsgroup_id, charactergroupsgroups.name AS charactergroupsgroup_name, charactergroupsgroups.url AS charactergroupsgroup_url '.
'FROM characters_charactergroups '.
'LEFT JOIN charactergroups ON charactergroups.id = characters_charactergroups.charactergroup_id '.
'LEFT JOIN cache_charactergroups ON cache_charactergroups.charactergroup_id = charactergroups.id '.
'LEFT JOIN charactergroupsgroups ON charactergroupsgroups.id = charactergroups.charactergroupsgroup_id '.
'WHERE characters_charactergroups.character_id = ?',
'i',
$characterId
);
}
/**
* Get a Character group by its URL.
*
* @throws \nre\exceptions\IdNotFoundException
* @param int $groupsgroupId ID of the Character groups-group
* @param string $groupUrl URL-name of the Character group
* @return array Character group data
*/
public function getGroupByUrl($groupsgroupId, $groupUrl)
{
$data = $this->db->query(
'SELECT '.
'charactergroups.id, charactergroups.name, charactergroups.url, charactergroups.motto, charactergroups.charactergroupsmedia_id, '.
'cache_charactergroups.xps '.
'FROM charactergroups '.
'LEFT JOIN cache_charactergroups ON cache_charactergroups.charactergroup_id = charactergroups.id '.
'WHERE charactergroups.charactergroupsgroup_id = ? AND url = ?',
'is',
$groupsgroupId, $groupUrl
);
if(empty($data)) {
throw new \nre\exceptions\IdNotFoundException($groupUrl);
}
/**
* Get a Character group by its URL.
*
* @throws \nre\exceptions\IdNotFoundException
* @param int $groupsgroupId ID of the Character groups-group
* @param string $groupUrl URL-name of the Character group
* @return array Character group data
*/
public function getGroupByUrl($groupsgroupId, $groupUrl)
{
$data = $this->db->query(
'SELECT '.
'charactergroups.id, charactergroups.name, charactergroups.url, charactergroups.motto, charactergroups.charactergroupsmedia_id, '.
'cache_charactergroups.xps '.
'FROM charactergroups '.
'LEFT JOIN cache_charactergroups ON cache_charactergroups.charactergroup_id = charactergroups.id '.
'WHERE charactergroups.charactergroupsgroup_id = ? AND url = ?',
'is',
$groupsgroupId, $groupUrl
);
if(empty($data)) {
throw new \nre\exceptions\IdNotFoundException($groupUrl);
}
return $data[0];
}
return $data[0];
}
/**
* Get a Character group by its ID.
*
* @throws \nre\exceptions\IdNotFoundException
* @param int $groupsgroupId ID of the Character group
* @return array Character group data
*/
public function getGroupById($groupId)
{
$data = $this->db->query(
'SELECT '.
'charactergroups.id, charactergroups.name, charactergroups.url, charactergroups.motto, charactergroups.charactergroupsmedia_id, '.
'cache_charactergroups.xps '.
'FROM charactergroups '.
'LEFT JOIN cache_charactergroups ON cache_charactergroups.charactergroup_id = charactergroups.id '.
'WHERE charactergroups.id = ?',
'i',
$groupId
);
if(empty($data)) {
throw new \nre\exceptions\IdNotFoundException($groupId);
}
/**
* Get a Character group by its ID.
*
* @throws \nre\exceptions\IdNotFoundException
* @param int $groupsgroupId ID of the Character group
* @return array Character group data
*/
public function getGroupById($groupId)
{
$data = $this->db->query(
'SELECT '.
'charactergroups.id, charactergroups.name, charactergroups.url, charactergroups.motto, charactergroups.charactergroupsmedia_id, '.
'cache_charactergroups.xps '.
'FROM charactergroups '.
'LEFT JOIN cache_charactergroups ON cache_charactergroups.charactergroup_id = charactergroups.id '.
'WHERE charactergroups.id = ?',
'i',
$groupId
);
if(empty($data)) {
throw new \nre\exceptions\IdNotFoundException($groupId);
}
return $data[0];
}
return $data[0];
}
/**
* Get the Character groups for a Quest.
*
* @param int $questId ID of the Character groups Quest
* @return array Character groups
*/
public function getGroupsForQuest($questId)
{
$groups = $this->db->query(
'SELECT charactergroups.id, charactergroups.name, charactergroups.url, charactergroupsquests_groups.created, charactergroupsquests_groups.xps_factor, charactergroupsquests.xps '.
'FROM charactergroupsquests_groups '.
'LEFT JOIN charactergroups ON charactergroups.id = charactergroupsquests_groups.charactergroup_id '.
'LEFT JOIN charactergroupsquests ON charactergroupsquests.id = charactergroupsquests_groups.charactergroupsquest_id '.
'WHERE charactergroupsquests_groups.charactergroupsquest_id = ? '.
'ORDER BY xps_factor DESC',
'i',
$questId
);
foreach($groups as &$group) {
$group['xps'] = round($group['xps'] * $group['xps_factor'], 1);
}
/**
* Get the Character groups for a Quest.
*
* @param int $questId ID of the Character groups Quest
* @return array Character groups
*/
public function getGroupsForQuest($questId)
{
$groups = $this->db->query(
'SELECT charactergroups.id, charactergroups.name, charactergroups.url, charactergroupsquests_groups.created, charactergroupsquests_groups.xps_factor, charactergroupsquests.xps '.
'FROM charactergroupsquests_groups '.
'LEFT JOIN charactergroups ON charactergroups.id = charactergroupsquests_groups.charactergroup_id '.
'LEFT JOIN charactergroupsquests ON charactergroupsquests.id = charactergroupsquests_groups.charactergroupsquest_id '.
'WHERE charactergroupsquests_groups.charactergroupsquest_id = ? '.
'ORDER BY xps_factor DESC',
'i',
$questId
);
foreach($groups as &$group) {
$group['xps'] = round($group['xps'] * $group['xps_factor'], 1);
}
return $groups;
}
return $groups;
}
/**
* Check if a Character group name already exists.
*
* @param string $name Name to check
* @param int $groupsgroupId Do not check this ID (for editing)
* @return boolean Whether name exists or not
*/
public function characterGroupNameExists($name, $groupId=null)
{
$data = $this->db->query(
'SELECT id '.
'FROM charactergroups '.
'WHERE name = ? OR url = ?',
'ss',
$name,
\nre\core\Linker::createLinkParam($name)
);
/**
* Check if a Character group name already exists.
*
* @param string $name Name to check
* @param int $groupsgroupId Do not check this ID (for editing)
* @return boolean Whether name exists or not
*/
public function characterGroupNameExists($name, $groupId=null)
{
$data = $this->db->query(
'SELECT id '.
'FROM charactergroups '.
'WHERE name = ? OR url = ?',
'ss',
$name,
\nre\core\Linker::createLinkParam($name)
);
return (!empty($data) && (is_null($groupId) || $groupId != $data[0]['id']));
}
return (!empty($data) && (is_null($groupId) || $groupId != $data[0]['id']));
}
/**
* Create a new Character group.
*
* @param int $userId ID of user
* @param int $groupsgroupId ID of Character groups-group
* @param string $name Name of new group
* @param string $motto Motto of new group
* @return int ID of newly created group
*/
public function createGroup($userId, $groupsgroupId, $name, $motto)
{
$this->db->query(
'INSERT INTO charactergroups '.
'(created_user_id, charactergroupsgroup_id, name, url, motto) '.
'VALUES '.
'(?, ?, ?, ?, ?)',
'iisss',
$userId,
$groupsgroupId,
$name,
\nre\core\Linker::createLinkParam($name),
$motto
);
/**
* Create a new Character group.
*
* @param int $userId ID of user
* @param int $groupsgroupId ID of Character groups-group
* @param string $name Name of new group
* @param string $motto Motto of new group
* @return int ID of newly created group
*/
public function createGroup($userId, $groupsgroupId, $name, $motto)
{
$this->db->query(
'INSERT INTO charactergroups '.
'(created_user_id, charactergroupsgroup_id, name, url, motto) '.
'VALUES '.
'(?, ?, ?, ?, ?)',
'iisss',
$userId,
$groupsgroupId,
$name,
\nre\core\Linker::createLinkParam($name),
$motto
);
return $this->db->getInsertId();
}
return $this->db->getInsertId();
}
/**
* Set the media for a Character group.
*
* @param int $groupId ID of Character group to set media for
* @param int $mediaId ID of Character groups media
*/
public function setMediaForGroup($groupId, $mediaId)
{
$this->db->query(
'UPDATE charactergroups '.
'SET charactergroupsmedia_id = ? '.
'WHERE id = ?',
'ii',
$mediaId,
$groupId
);
}
/**
* Set the media for a Character group.
*
* @param int $groupId ID of Character group to set media for
* @param int $mediaId ID of Character groups media
*/
public function setMediaForGroup($groupId, $mediaId)
{
$this->db->query(
'UPDATE charactergroups '.
'SET charactergroupsmedia_id = ? '.
'WHERE id = ?',
'ii',
$mediaId,
$groupId
);
}
/**
* Edit a Character group.
*
* @param int $groupId ID of Character group to edit
* @param string $name New name of group
* @param string $motto New motto of group
*/
public function editGroup($groupId, $name, $motto)
{
$this->db->query(
'UPDATE charactergroups '.
'SET name = ?, url = ?, motto = ? '.
'WHERE id = ?',
'sssi',
$name,
\nre\core\Linker::createLinkParam($name),
$motto,
$groupId
);
}
/**
* Edit a Character group.
*
* @param int $groupId ID of Character group to edit
* @param string $name New name of group
* @param string $motto New motto of group
*/
public function editGroup($groupId, $name, $motto)
{
$this->db->query(
'UPDATE charactergroups '.
'SET name = ?, url = ?, motto = ? '.
'WHERE id = ?',
'sssi',
$name,
\nre\core\Linker::createLinkParam($name),
$motto,
$groupId
);
}
/**
* Delete a Character group.
*
* @param int $groupId ID of Character group to delete
*/
public function deleteGroup($groupId)
{
$this->db->query('DELETE FROM charactergroups WHERE id = ?', 'i', $groupId);
}
/**
* Delete a Character group.
*
* @param int $groupId ID of Character group to delete
*/
public function deleteGroup($groupId)
{
$this->db->query('DELETE FROM charactergroups WHERE id = ?', 'i', $groupId);
}
/**
* Get the rank of a XP-value of a Character.
*
* @param int $seminaryId ID of Seminary
* @param int $xps XP-value to get rank for
* @return int Rank of XP-value
*/
public function getXPRank($groupsgroupId, $xps)
{
$data = $this->db->query(
'SELECT count(charactergroups.id) AS c '.
'FROM charactergroups '.
'LEFT JOIN cache_charactergroups ON cache_charactergroups.charactergroup_id = charactergroups.id '.
'WHERE charactergroups.charactergroupsgroup_id = ? AND cache_charactergroups.xps > ?',
'id',
$groupsgroupId, $xps
);
if(!empty($data)) {
return $data[0]['c'] + 1;
}
/**
* Get the rank of a XP-value of a Character.
*
* @param int $seminaryId ID of Seminary
* @param int $xps XP-value to get rank for
* @return int Rank of XP-value
*/
public function getXPRank($groupsgroupId, $xps)
{
$data = $this->db->query(
'SELECT count(charactergroups.id) AS c '.
'FROM charactergroups '.
'LEFT JOIN cache_charactergroups ON cache_charactergroups.charactergroup_id = charactergroups.id '.
'WHERE charactergroups.charactergroupsgroup_id = ? AND cache_charactergroups.xps > ?',
'id',
$groupsgroupId, $xps
);
if(!empty($data)) {
return $data[0]['c'] + 1;
}
return 1;
}
return 1;
}
/**
* Add a Character to a Character group.
*
* @param int $groupId ID of Character group
* @param int $characterId ID of Character to add
*/
public function addCharacterToCharactergroup($groupId, $characterId)
{
$this->db->query(
'INSERT INTO characters_charactergroups '.
'(character_id, charactergroup_id) '.
'VALUES '.
'(?, ?)',
'ii',
$characterId,
$groupId
);
}
/**
* Add a Character to a Character group.
*
* @param int $groupId ID of Character group
* @param int $characterId ID of Character to add
*/
public function addCharacterToCharactergroup($groupId, $characterId)
{
$this->db->query(
'INSERT INTO characters_charactergroups '.
'(character_id, charactergroup_id) '.
'VALUES '.
'(?, ?)',
'ii',
$characterId,
$groupId
);
}
/**
* Remove a Character from a Character group.
*
* @param int $groupId ID of Character group
* @param int $characterId ID of Character to remove
*/
public function removeCharacterFromCharactergroup($groupId, $characterId)
{
$this->db->query(
'DELETE FROM characters_charactergroups '.
'WHERE charactergroup_id = ? AND character_id = ?',
'ii',
$groupId,
$characterId
);
}
/**
* Remove a Character from a Character group.
*
* @param int $groupId ID of Character group
* @param int $characterId ID of Character to remove
*/
public function removeCharacterFromCharactergroup($groupId, $characterId)
{
$this->db->query(
'DELETE FROM characters_charactergroups '.
'WHERE charactergroup_id = ? AND character_id = ?',
'ii',
$groupId,
$characterId
);
}
}
}
?>

View file

@ -1,378 +1,378 @@
<?php
/**
* The Legend of Z
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
* @license http://www.gnu.org/licenses/gpl.html
* @link https://bitbucket.org/coderkun/the-legend-of-z
*/
/**
* The Legend of Z
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
* @license http://www.gnu.org/licenses/gpl.html
* @link https://bitbucket.org/coderkun/the-legend-of-z
*/
namespace hhu\z\models;
namespace hhu\z\models;
/**
* Model of the CharactergroupsquestsAgent to interact with
* Charactergroupsquests-table.
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
*/
class CharactergroupsquestsModel extends \hhu\z\Model
{
/**
* Required models
*
* @var array
*/
public $models = array('uploads', 'media');
/**
* Model of the CharactergroupsquestsAgent to interact with
* Charactergroupsquests-table.
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
*/
class CharactergroupsquestsModel extends \hhu\z\Model
{
/**
* Required models
*
* @var array
*/
public $models = array('uploads', 'media');
/**
* Construct a new CharactergroupsquestsModel.
*/
public function __construct()
{
parent::__construct();
}
/**
* Construct a new CharactergroupsquestsModel.
*/
public function __construct()
{
parent::__construct();
}
/**
* Get Character groups Quests of a Character groups-groups.
*
* @param int $groupsgroupId ID of the Character groups-group
* @return array Character groups Quest data
*/
public function getQuestsForCharactergroupsgroup($groupsgroupId)
{
return $this->db->query(
'SELECT id, questgroups_id, title, url, xps, questsmedia_id '.
'FROM charactergroupsquests '.
'WHERE charactergroupsgroup_id = ? '.
'ORDER BY created ASC',
'i',
$groupsgroupId
);
}
/**
* Get Character groups Quests of a Character groups-groups.
*
* @param int $groupsgroupId ID of the Character groups-group
* @return array Character groups Quest data
*/
public function getQuestsForCharactergroupsgroup($groupsgroupId)
{
return $this->db->query(
'SELECT id, questgroups_id, title, url, xps, questsmedia_id '.
'FROM charactergroupsquests '.
'WHERE charactergroupsgroup_id = ? '.
'ORDER BY created ASC',
'i',
$groupsgroupId
);
}
/**
* Get a Character groups Quest by its URL.
*
* @throws \nre\exceptions\IdNotFoundException
* @param int $groupsgroupId ID of the Character groups-group
* @param string $questUrl URL-title of the Character groups Quest
* @return array Character groups Quest data
*/
public function getQuestByUrl($groupsgroupId, $questUrl)
{
$data = $this->db->query(
'SELECT id, questgroups_id, title, url, description, xps, rules, won_text, lost_text, questsmedia_id '.
'FROM charactergroupsquests '.
'WHERE charactergroupsgroup_id = ? AND url = ?',
'is',
$groupsgroupId,
$questUrl
);
if(empty($data)) {
throw new \nre\exceptions\IdNotFoundException($questUrl);
}
/**
* Get a Character groups Quest by its URL.
*
* @throws \nre\exceptions\IdNotFoundException
* @param int $groupsgroupId ID of the Character groups-group
* @param string $questUrl URL-title of the Character groups Quest
* @return array Character groups Quest data
*/
public function getQuestByUrl($groupsgroupId, $questUrl)
{
$data = $this->db->query(
'SELECT id, questgroups_id, title, url, description, xps, rules, won_text, lost_text, questsmedia_id '.
'FROM charactergroupsquests '.
'WHERE charactergroupsgroup_id = ? AND url = ?',
'is',
$groupsgroupId,
$questUrl
);
if(empty($data)) {
throw new \nre\exceptions\IdNotFoundException($questUrl);
}
return $data[0];
}
return $data[0];
}
/**
* Get a Character groups Quest by its ID.
*
* @throws \nre\exceptions\IdNotFoundException
* @param int $questId ID of the Character groups Quest
* @return array Character groups Quest data
*/
public function getQuestById($questId)
{
$data = $this->db->query(
'SELECT id, questgroups_id, title, url, description, xps, rules, won_text, lost_text, questsmedia_id '.
'FROM charactergroupsquests '.
'WHERE id = ?',
'i',
$questId
);
if(empty($data)) {
throw new \nre\exceptions\IdNotFoundException($questUrl);
}
/**
* Get a Character groups Quest by its ID.
*
* @throws \nre\exceptions\IdNotFoundException
* @param int $questId ID of the Character groups Quest
* @return array Character groups Quest data
*/
public function getQuestById($questId)
{
$data = $this->db->query(
'SELECT id, questgroups_id, title, url, description, xps, rules, won_text, lost_text, questsmedia_id '.
'FROM charactergroupsquests '.
'WHERE id = ?',
'i',
$questId
);
if(empty($data)) {
throw new \nre\exceptions\IdNotFoundException($questUrl);
}
return $data[0];
}
return $data[0];
}
/**
* Get Character groups Quests for a Character group.
*
* @param int $groupId ID of the Character group
* @return array Character groups Quests
*/
public function getQuestsForGroup($groupId)
{
$quests = $this->db->query(
'SELECT charactergroupsquests.id, charactergroupsquests_groups.created, charactergroupsquests.title, charactergroupsquests.url, charactergroupsquests.xps, charactergroupsquests_groups.xps_factor '.
'FROM charactergroupsquests_groups '.
'LEFT JOIN charactergroupsquests ON charactergroupsquests.id = charactergroupsquests_groups.charactergroupsquest_id '.
'WHERE charactergroupsquests_groups.charactergroup_id = ? '.
'ORDER BY charactergroupsquests.created ASC',
'i',
$groupId
);
foreach($quests as &$quest) {
$quest['group_xps'] = round($quest['xps'] * $quest['xps_factor'], 1);
}
/**
* Get Character groups Quests for a Character group.
*
* @param int $groupId ID of the Character group
* @return array Character groups Quests
*/
public function getQuestsForGroup($groupId)
{
$quests = $this->db->query(
'SELECT charactergroupsquests.id, charactergroupsquests_groups.created, charactergroupsquests.title, charactergroupsquests.url, charactergroupsquests.xps, charactergroupsquests_groups.xps_factor '.
'FROM charactergroupsquests_groups '.
'LEFT JOIN charactergroupsquests ON charactergroupsquests.id = charactergroupsquests_groups.charactergroupsquest_id '.
'WHERE charactergroupsquests_groups.charactergroup_id = ? '.
'ORDER BY charactergroupsquests.created ASC',
'i',
$groupId
);
foreach($quests as &$quest) {
$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.
*
* @param int $questId ID of Character groups Quest
* @param int $groupId ID of Character group to get XPs of
* @return array XP-record
*/
public function getXPsOfGroupForQuest($questId, $groupId)
{
$data = $this->db->query(
'SELECT charactergroupsquests_groups.created, charactergroupsquests_groups.xps_factor, charactergroupsquests.xps '.
'FROM charactergroupsquests_groups '.
'LEFT JOIN charactergroupsquests ON charactergroupsquests.id = charactergroupsquests_groups.charactergroupsquest_id '.
'WHERE charactergroupsquests_groups.charactergroupsquest_id = ? AND charactergroupsquests_groups.charactergroup_id = ?',
'ii',
$questId,
$groupId
);
if(empty($data)) {
return null;
}
/**
* Get XPs of a Character group for a Character groups Quest.
*
* @param int $questId ID of Character groups Quest
* @param int $groupId ID of Character group to get XPs of
* @return array XP-record
*/
public function getXPsOfGroupForQuest($questId, $groupId)
{
$data = $this->db->query(
'SELECT charactergroupsquests_groups.created, charactergroupsquests_groups.xps_factor, charactergroupsquests.xps '.
'FROM charactergroupsquests_groups '.
'LEFT JOIN charactergroupsquests ON charactergroupsquests.id = charactergroupsquests_groups.charactergroupsquest_id '.
'WHERE charactergroupsquests_groups.charactergroupsquest_id = ? AND charactergroupsquests_groups.charactergroup_id = ?',
'ii',
$questId,
$groupId
);
if(empty($data)) {
return null;
}
$data = $data[0];
$data['xps'] = round($data['xps'] * $data['xps_factor'], 1);
$data = $data[0];
$data['xps'] = round($data['xps'] * $data['xps_factor'], 1);
return $data;
}
return $data;
}
/**
* Set XPs of a Character group for a Character groups Quest.
*
* @param int $questId ID of Character groups Quest
* @param int $groupId ID of Character group to set XPs of
* @param float $xpsFactor XPs-factor
*/
public function setXPsOfGroupForQuest($questId, $groupId, $xpsFactor)
{
$this->db->query(
'INSERT INTO charactergroupsquests_groups '.
'(charactergroupsquest_id, charactergroup_id, xps_factor) '.
'VALUES '.
'(?, ?, ?) '.
'ON DUPLICATE KEY UPDATE '.
'xps_factor = ?',
'iidd',
$questId,
$groupId,
$xpsFactor,
$xpsFactor
);
}
/**
* Set XPs of a Character group for a Character groups Quest.
*
* @param int $questId ID of Character groups Quest
* @param int $groupId ID of Character group to set XPs of
* @param float $xpsFactor XPs-factor
*/
public function setXPsOfGroupForQuest($questId, $groupId, $xpsFactor)
{
$this->db->query(
'INSERT INTO charactergroupsquests_groups '.
'(charactergroupsquest_id, charactergroup_id, xps_factor) '.
'VALUES '.
'(?, ?, ?) '.
'ON DUPLICATE KEY UPDATE '.
'xps_factor = ?',
'iidd',
$questId,
$groupId,
$xpsFactor,
$xpsFactor
);
}
/**
* Remove a Character group from a Character groups Quest.
*
* @param int $questId ID of Character groups Quest
* @param int $groupId ID of Character group to remove
*/
public function deleteGroupForQuest($questId, $groupId)
{
$this->db->query(
'DELETE FROM charactergroupsquests_groups '.
'WHERE charactergroupsquest_id = ? AND charactergroup_id = ?',
'ii',
$questId, $groupId
);
}
/**
* Remove a Character group from a Character groups Quest.
*
* @param int $questId ID of Character groups Quest
* @param int $groupId ID of Character group to remove
*/
public function deleteGroupForQuest($questId, $groupId)
{
$this->db->query(
'DELETE FROM charactergroupsquests_groups '.
'WHERE charactergroupsquest_id = ? AND charactergroup_id = ?',
'ii',
$questId, $groupId
);
}
/**
* Check if a Character groups Quest title already exists.
*
* @param string $name Character groups Quest title to check
* @param int $questId Do not check this ID (for editing)
* @return boolean Whether Character groups Quest title exists or not
*/
public function characterGroupsQuestTitleExists($title, $questId=null)
{
$data = $this->db->query(
'SELECT id '.
'FROM charactergroupsquests '.
'WHERE title = ? OR url = ?',
'ss',
$title,
\nre\core\Linker::createLinkParam($title)
);
/**
* Check if a Character groups Quest title already exists.
*
* @param string $name Character groups Quest title to check
* @param int $questId Do not check this ID (for editing)
* @return boolean Whether Character groups Quest title exists or not
*/
public function characterGroupsQuestTitleExists($title, $questId=null)
{
$data = $this->db->query(
'SELECT id '.
'FROM charactergroupsquests '.
'WHERE title = ? OR url = ?',
'ss',
$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.
*
* @param int $questId ID of Quest to upload media for
* @param int $mediaId ID of Quests media
*/
public function setMediaForQuest($questId, $mediaId)
{
$this->db->query(
'UPDATE charactergroupsquests '.
'SET questsmedia_id = ? '.
'WHERE id = ?',
'ii',
$mediaId,
$questId
);
}
/**
* Set the media for a Character groups Quest.
*
* @param int $questId ID of Quest to upload media for
* @param int $mediaId ID of Quests media
*/
public function setMediaForQuest($questId, $mediaId)
{
$this->db->query(
'UPDATE charactergroupsquests '.
'SET questsmedia_id = ? '.
'WHERE id = ?',
'ii',
$mediaId,
$questId
);
}
/**
* Upload a media for a Character groups Quest.
*
* @param int $userId ID of user that does the upload
* @param int $seminaryId ID of Seminary
* @param int $questId ID of Quest to upload media for
* @param array $file File-array of file to upload
* @param string $filename Filename for media
* @return boolean Whether upload succeeded or not
*/
public function uploadMediaForQuest($userId, $seminaryId, $questId, $file, $filename)
{
// Save file on harddrive
$uploadId = $this->Uploads->uploadSeminaryFile($userId, $seminaryId, $file['name'], $filename, $file['tmp_name'], $file['type']);
if($uploadId === false) {
return false;
}
/**
* Upload a media for a Character groups Quest.
*
* @param int $userId ID of user that does the upload
* @param int $seminaryId ID of Seminary
* @param int $questId ID of Quest to upload media for
* @param array $file File-array of file to upload
* @param string $filename Filename for media
* @return boolean Whether upload succeeded or not
*/
public function uploadMediaForQuest($userId, $seminaryId, $questId, $file, $filename)
{
// Save file on harddrive
$uploadId = $this->Uploads->uploadSeminaryFile($userId, $seminaryId, $file['name'], $filename, $file['tmp_name'], $file['type']);
if($uploadId === false) {
return false;
}
// Create database record
$this->db->query(
'INSERT INTO charactergroupsquests_seminaryuploads '.
'(seminaryupload_id, charactergroupsquest_id, created_user_id) '.
'VALUES '.
'(?, ?, ?) ',
'iii',
$uploadId, $questId, $userId
);
// Create database record
$this->db->query(
'INSERT INTO charactergroupsquests_seminaryuploads '.
'(seminaryupload_id, charactergroupsquest_id, created_user_id) '.
'VALUES '.
'(?, ?, ?) ',
'iii',
$uploadId, $questId, $userId
);
return true;
}
return true;
}
/**
* Get uploaded Medai for a Character groups Quest.
*
* @param int $questId ID of Quest to get media for
* @return array Seminary uploads
*/
public function getMediaForQuest($questId)
{
return $this->db->query(
'SELECT seminaryupload_id, created, created_user_id '.
'FROM charactergroupsquests_seminaryuploads '.
'WHERE charactergroupsquest_id = ?',
'i',
$questId
);
}
/**
* Get uploaded Medai for a Character groups Quest.
*
* @param int $questId ID of Quest to get media for
* @return array Seminary uploads
*/
public function getMediaForQuest($questId)
{
return $this->db->query(
'SELECT seminaryupload_id, created, created_user_id '.
'FROM charactergroupsquests_seminaryuploads '.
'WHERE charactergroupsquest_id = ?',
'i',
$questId
);
}
/**
* Create a new Character groups Quest.
*
* @param int $userId ID of user
* @param int $groupsgroupId ID of Character groups-group
* @param int $questgroupId ID of Quest group
* @param string $title Title of new Quest
* @param string $description Description of new Quset
* @param int $xps Amount of XPs for new Quest
* @param string $rules Rules of new Quest
* @param string $wonText Won-text of new Quset
* @param string $lostText Lost-text of new Quest
* @return int ID of newly created Quest
*/
public function createQuest($userId, $groupsgroupId, $questgroupId, $title, $description, $xps, $rules, $wonText, $lostText)
{
$this->db->query(
'INSERT INTO charactergroupsquests '.
'(created_user_id, charactergroupsgroup_id, questgroups_id, title, url, description, xps, rules, won_text, lost_text) '.
'VALUES '.
'(?, ?, ?, ?, ?, ?, ?, ?, ?, ?)',
'iiisssdsss',
$userId,
$groupsgroupId,
$questgroupId,
$title,
\nre\core\Linker::createLinkParam($title),
$description,
$xps,
$rules,
$wonText,
$lostText
);
/**
* Create a new Character groups Quest.
*
* @param int $userId ID of user
* @param int $groupsgroupId ID of Character groups-group
* @param int $questgroupId ID of Quest group
* @param string $title Title of new Quest
* @param string $description Description of new Quset
* @param int $xps Amount of XPs for new Quest
* @param string $rules Rules of new Quest
* @param string $wonText Won-text of new Quset
* @param string $lostText Lost-text of new Quest
* @return int ID of newly created Quest
*/
public function createQuest($userId, $groupsgroupId, $questgroupId, $title, $description, $xps, $rules, $wonText, $lostText)
{
$this->db->query(
'INSERT INTO charactergroupsquests '.
'(created_user_id, charactergroupsgroup_id, questgroups_id, title, url, description, xps, rules, won_text, lost_text) '.
'VALUES '.
'(?, ?, ?, ?, ?, ?, ?, ?, ?, ?)',
'iiisssdsss',
$userId,
$groupsgroupId,
$questgroupId,
$title,
\nre\core\Linker::createLinkParam($title),
$description,
$xps,
$rules,
$wonText,
$lostText
);
return $this->db->getInsertId();
}
return $this->db->getInsertId();
}
/**
* Edit a Character groups Quest.
*
* @param int $questId ID of Character groups Quest to edit
* @param int $groupsgroupId ID of Character groups-group
* @param int $questgroupId ID of Quest group
* @param string $title Title of new Quest
* @param string $description Description of new Quset
* @param int $xps Amount of XPs for new Quest
* @param string $rules Rules of new Quest
* @param string $wonText Won-text of new Quset
* @param string $lostText Lost-text of new Quest
*/
public function editQuest($questId, $groupsgroupId, $questgroupId, $title, $description, $xps, $rules, $wonText, $lostText)
{
$this->db->query(
'UPDATE charactergroupsquests '.
'SET charactergroupsgroup_id = ?, questgroups_id = ?, title = ?, url = ?, description = ?, xps = ?, rules = ?, won_text = ?, lost_text= ? '.
'WHERE id = ?',
'iisssdsssi',
$groupsgroupId,
$questgroupId,
$title,
\nre\core\Linker::createLinkParam($title),
$description,
$xps,
$rules,
$wonText,
$lostText,
$questId
);
}
/**
* Edit a Character groups Quest.
*
* @param int $questId ID of Character groups Quest to edit
* @param int $groupsgroupId ID of Character groups-group
* @param int $questgroupId ID of Quest group
* @param string $title Title of new Quest
* @param string $description Description of new Quset
* @param int $xps Amount of XPs for new Quest
* @param string $rules Rules of new Quest
* @param string $wonText Won-text of new Quset
* @param string $lostText Lost-text of new Quest
*/
public function editQuest($questId, $groupsgroupId, $questgroupId, $title, $description, $xps, $rules, $wonText, $lostText)
{
$this->db->query(
'UPDATE charactergroupsquests '.
'SET charactergroupsgroup_id = ?, questgroups_id = ?, title = ?, url = ?, description = ?, xps = ?, rules = ?, won_text = ?, lost_text= ? '.
'WHERE id = ?',
'iisssdsssi',
$groupsgroupId,
$questgroupId,
$title,
\nre\core\Linker::createLinkParam($title),
$description,
$xps,
$rules,
$wonText,
$lostText,
$questId
);
}
/**
@ -424,17 +424,17 @@
}
/**
* Delete a Character groups Quest.
*
* @param int $questId ID of Character groups Quest to delete
*/
public function deleteQuest($questId)
{
$this->db->query('DELETE FROM charactergroupsquests WHERE id = ?', 'i', $questId);
}
/**
* Delete a Character groups Quest.
*
* @param int $questId ID of Character groups Quest to delete
*/
public function deleteQuest($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