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
<Files ~ "\.inc$">
Require all denied
</Files>
<Files ~ "\.tpl$">
Require all denied
</Files>
<Files ~ "\.log$">
Require all denied
</Files>
Require all granted
<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>
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
RewriteBase /
RewriteRule ^(.*)$ www/$1 [L]
RewriteEngine On
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
*/
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
{
/**
* 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)
{
}
}
/**
* 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;
/**
* 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)
{
}
}
?>

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
*/
namespace hhu\z\agents\bottomlevel;
/**
* 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');
}
}
/**
* 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;
/**
* 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');
}
}
?>

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
*/
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
{
/**
* 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)
{
}
}
/**
* 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;
/**
* 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)
{
}
}
?>

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
*/
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
{
/**
* 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)
{
}
}
/**
* 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;
/**
* 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)
{
}
}
?>

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
*/
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
{
/**
* 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)
{
}
}
/**
* 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;
/**
* 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)
{
}
}
?>

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
*/
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
{
/**
* 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)
{
}
}
/**
* 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;
/**
* 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)
{
}
}
?>

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
*/
namespace hhu\z\agents\intermediate;
/**
* 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
*/
/**
* 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)
{
}
}
namespace hhu\z\agents\intermediate;
/**
* 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)
{
}
}
?>

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
*/
namespace hhu\z\agents\intermediate;
/**
* 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
*/
/**
* 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)
{
}
}
namespace hhu\z\agents\intermediate;
/**
* 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)
{
}
}
?>

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
*/
namespace hhu\z\agents\intermediate;
/**
* 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
*/
/**
* 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)
{
}
}
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
{
/**
* 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
*/
namespace hhu\z\agents\intermediate;
/**
* 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
*/
/**
* 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: 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)
{
}
}
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
{
/**
* 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)
{
}
}
?>

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
*/
namespace hhu\z\agents\intermediate;
/**
* 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
*/
/**
* 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)
{
}
}
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
{
/**
* 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
*/
namespace hhu\z\agents\intermediate;
/**
* 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
*/
/**
* 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)
{
}
}
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
{
/**
* 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
*/
namespace hhu\z\agents\intermediate;
/**
* 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
*/
/**
* 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)
{
}
}
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
{
/**
* 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
*/
namespace hhu\z\agents\intermediate;
/**
* 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
*/
/**
* 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)
{
}
}
namespace hhu\z\agents\intermediate;
/**
* 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)
{
}
}
?>

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
*/
namespace hhu\z\agents\intermediate;
/**
* 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
*/
/**
* 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)
{
}
}
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
{
/**
* 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
*/
namespace hhu\z\agents\intermediate;
/**
* 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
*/
/**
* 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)
{
}
}
namespace hhu\z\agents\intermediate;
/**
* 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)
{
}
}
?>

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
*/
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
{
/**
* 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)
{
}
}
/**
* 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;
/**
* 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)
{
}
}
?>

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
*/
namespace hhu\z\agents\intermediate;
/**
* 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
*/
/**
* Agent to display Questgroups.
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
*/
class QuestgroupsAgent extends \nre\agents\IntermediateAgent
{
/**
* Action: questgroup.
*
* @param \nre\core\Request $request Current request
* @param \nre\core\Response $response Current response
*/
public function questgroup(\nre\core\Request $request, \nre\core\Response $response)
{
$this->addSubAgent('Questgroupshierarchypath', 'index', $request->getParam(3), $request->getParam(4));
}
/**
* Action: edit.
*
* @param \nre\core\Request $request Current request
* @param \nre\core\Response $response Current response
*/
public function edit(\nre\core\Request $request, \nre\core\Response $response)
{
$this->addSubAgent('Questgroupshierarchypath', 'index', $request->getParam(3), $request->getParam(4));
}
namespace hhu\z\agents\intermediate;
/**
* 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));
}
/**
* Agent to display Questgroups.
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
*/
class QuestgroupsAgent extends \nre\agents\IntermediateAgent
{
/**
* 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: questgroup.
*
* @param \nre\core\Request $request Current request
* @param \nre\core\Response $response Current response
*/
public function questgroup(\nre\core\Request $request, \nre\core\Response $response)
{
$this->addSubAgent('Questgroupshierarchypath', 'index', $request->getParam(3), $request->getParam(4));
}
/**
* Action: edit.
*
* @param \nre\core\Request $request Current request
* @param \nre\core\Response $response Current response
*/
public function edit(\nre\core\Request $request, \nre\core\Response $response)
{
$this->addSubAgent('Questgroupshierarchypath', 'index', $request->getParam(3), $request->getParam(4));
}
/**
* Action: edittexts.
*
* @param \nre\core\Request $request Current request
* @param \nre\core\Response $response Current response
*/
public function edittexts(\nre\core\Request $request, \nre\core\Response $response)
{
$this->addSubAgent('Questgroupshierarchypath', 'index', $request->getParam(3), $request->getParam(4));
}
/**
* Action: moveup.
*
* @param \nre\core\Request $request Current request
* @param \nre\core\Response $response Current response
*/
public function moveup(\nre\core\Request $request, \nre\core\Response $response)
{
$this->addSubAgent('Questgroupshierarchypath', 'index', $request->getParam(3), $request->getParam(4));
}
/**
* Action: movedown.
*
* @param \nre\core\Request $request Current request
* @param \nre\core\Response $response Current response
*/
public function movedown(\nre\core\Request $request, \nre\core\Response $response)
{
$this->addSubAgent('Questgroupshierarchypath', 'index', $request->getParam(3), $request->getParam(4));
}
/**
* Action: delete.
*
* @param \nre\core\Request $request Current request
* @param \nre\core\Response $response Current response
*/
public function delete(\nre\core\Request $request, \nre\core\Response $response)
{
$this->addSubAgent('Questgroupshierarchypath', 'index', $request->getParam(3), $request->getParam(4));
}
}
?>

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
*/
namespace hhu\z\agents\intermediate;
/**
* 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
*/
/**
* Agent to manage Questgroupshierarchy.
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
*/
class QuestgroupshierarchyAgent extends \nre\agents\IntermediateAgent
{
}
namespace hhu\z\agents\intermediate;
/**
* 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
*/
namespace hhu\z\agents\intermediate;
/**
* 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
*/
/**
* Agent to display Quests.
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
*/
class QuestsAgent extends \nre\agents\IntermediateAgent
{
/**
* Action: quest.
*
* @param \nre\core\Request $request Current request
* @param \nre\core\Response $response Current response
*/
public function quest(\nre\core\Request $request, \nre\core\Response $response)
{
$this->addSubAgent('Questgroupshierarchypath', 'index', $request->getParam(3), $request->getParam(4), true);
}
/**
* Action: submissions.
*
* @param \nre\core\Request $request Current request
* @param \nre\core\Response $response Current response
*/
public function submissions(\nre\core\Request $request, \nre\core\Response $response)
{
$this->addSubAgent('Questgroupshierarchypath', 'index', $request->getParam(3), $request->getParam(4), true);
}
/**
* Action: submission.
*
* @param \nre\core\Request $request Current request
* @param \nre\core\Response $response Current response
*/
public function submission(\nre\core\Request $request, \nre\core\Response $response)
{
$this->addSubAgent('Questgroupshierarchypath', 'index', $request->getParam(3), $request->getParam(4), true);
}
namespace hhu\z\agents\intermediate;
/**
* 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);
}
/**
* Agent to display Quests.
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
*/
class QuestsAgent extends \nre\agents\IntermediateAgent
{
/**
* 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: 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: 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: 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: 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: 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: edit.
*
* @param \nre\core\Request $request Current request
* @param \nre\core\Response $response Current response
*/
public function edit(\nre\core\Request $request, \nre\core\Response $response)
{
$this->addSubAgent('Questgroupshierarchypath', 'index', $request->getParam(3), $request->getParam(4), true);
}
/**
* Action: edittask.
*
* @param \nre\core\Request $request Current request
* @param \nre\core\Response $response Current response
*/
public function edittask(\nre\core\Request $request, \nre\core\Response $response)
{
$this->addSubAgent('Questgroupshierarchypath', 'index', $request->getParam(3), $request->getParam(4), true);
}
/**
* Action: edittexts.
*
* @param \nre\core\Request $request Current request
* @param \nre\core\Response $response Current response
*/
public function edittexts(\nre\core\Request $request, \nre\core\Response $response)
{
$this->addSubAgent('Questgroupshierarchypath', 'index', $request->getParam(3), $request->getParam(4), true);
}
/**
* Action: delete.
*
* @param \nre\core\Request $request Current request
* @param \nre\core\Response $response Current response
*/
public function delete(\nre\core\Request $request, \nre\core\Response $response)
{
$this->addSubAgent('Questgroupshierarchypath', 'index', $request->getParam(3), $request->getParam(4), true);
}
}
?>

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
*/
namespace hhu\z\agents\intermediate;
/**
* 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
*/
/**
* 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)
{
}
}
namespace hhu\z\agents\intermediate;
/**
* 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)
{
}
}
?>

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
*/
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
{
/**
* 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)
{
}
}
/**
* 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;
/**
* 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)
{
}
}
?>

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
*/
namespace hhu\z\agents\intermediate;
/**
* 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
*/
/**
* 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: 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');
}
}
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
{
/**
* 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');
}
}
?>

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
*/
namespace hhu\z\agents\intermediate;
/**
* 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
*/
/**
* 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)
{
}
}
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
{
/**
* 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
*/
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
{
/**
* 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);
}
/**
* 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'];
// 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);
}
}
/**
* 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;
/**
* 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);
$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)
{
}
/**
* 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;
}
// 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
*/
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
{
/**
* 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)
{
}
}
/**
* 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;
/**
* 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);
}
/**
* 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
*/
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
{
/**
* 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)
{
}
}
/**
* 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;
/**
* 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)
{
}
}
?>

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
*/
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
{
/**
* 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);
}
/**
* 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');
}
/**
* 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;
/**
* 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);
$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');
// 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
*/
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
{
/**
* 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));
}
}
/**
* 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;
/**
* 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);
}
/**
* 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
*/
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
{
/**
* 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));
}
}
/**
* 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;
/**
* 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);
}
/**
* 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
*/
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');
/**
* 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);
// 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);
// 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 date and time and number formatter
$this->set('dateFormatter', new \IntlDateFormatter(
//\nre\core\Config::getDefault('locale'),
/**
* 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;
/**
* 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;
/**
* 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();
}
/**
* 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 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'),
\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
));
}
/**
* 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);
}
}
\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);
}
/**
* 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
*/
namespace hhu\z;
/**
* 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);
}
}
/**
* 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;
/**
* 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);
}
}
?>

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
*/
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;
/**
* 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);
// 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 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) {
}
}
$seminarymedia[$seminarymediaId] = $replacement;
}
foreach($seminarymedia as $seminarymediaId => $replacement) {
$string = str_replace("[seminarymedia:$seminarymediaId]", $replacement, $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;
}
try {
// Load class
Model::load('media');
// Construct Model
self::$Media = Model::factory('media');
}
catch(\Exception $e) {
}
// Return whether Media-Model has been loaded or not
return !is_null(self::$Media);
}
}
/**
* 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;
/**
* 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;
}
/**
* 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);
// 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);
// 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);
}
// 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;
}
try {
// Load class
Model::load('media');
// Construct Model
self::$Media = Model::factory('media');
}
catch(\Exception $e) {
}
// 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
*/
namespace hhu\z;
/**
* 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));
}
/**
* 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));
// 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);
}
/**
* 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();
// 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'];
// 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();
}
// 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);
// 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);
}
}
/**
* 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;
}
}
/**
* 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;
/**
* 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));
}
/**
* 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));
// 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);
}
/**
* 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();
// 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'];
// 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();
}
// 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);
// 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);
}
}
/**
* 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;
}
}
?>

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
*/
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;
/**
* 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);
// 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);
// 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');
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);
// 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
);
}
// 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
);
}
}
/**
* 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);
}
/**
* 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);
}
/**
* 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 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);
// Construct Controller
$this->controller = \hhu\z\controllers\QuesttypeController::factory($controllerName, $toplevelAgentName, $action, $this);
}
}
/**
* 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;
/**
* 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);
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());
}
}
/**
* 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);
}
/**
* 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";
}
/**
* 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');
// Check file
if(!file_exists($fileName))
{
throw new \nre\exceptions\ClassNotFoundException(
$fullClassName
);
}
// 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
);
}
}
/**
* 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);
}
/**
* 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);
}
/**
* 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 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);
// 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
*/
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
{
/**
* 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']);
}
}
/**
* 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;
/**
* 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);
// 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
*/
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
{
/**
* 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 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);
// 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);
}
}
/**
* 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);
// 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 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();
}
/**
* 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();
return $exception;
}
catch(\nre\Exception $e) {
return $e;
}
}
/**
* Render output.
*
* @return string Rendered output
*/
public function render()
{
// Generate output
parent::render();
// 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
);
}
}
/**
* 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;
/**
* 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()
);
// 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);
}
/**
* 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']);
}
// 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 messageAgent
$this->request->clearParams(2);
$this->request->addParam($messageAgent);
// 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 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();
}
/**
* 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();
return $exception;
}
catch(\nre\Exception $e) {
return $e;
}
}
/**
* Render output.
*
* @return string Rendered output
*/
public function render()
{
// Generate output
parent::render();
// 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
);
}
}
?>

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
*/
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();
/**
* 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);
// 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);
// 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);
}
/**
* 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 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)
)
);
}
$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'];
}
// 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];
// Check permissions
if(count(array_intersect($userRoles, $permissions)) == 0) {
throw new \nre\exceptions\AccessDeniedException();
}
}
}
/**
* 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;
/**
* 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);
}
/**
* 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) {
}
// Check permissions
$this->checkPermission($request, $response);
// 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);
}
/**
* 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 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)
)
);
}
$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'];
}
// 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];
// 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
*/
namespace hhu\z\controllers;
/**
* Abstract class for implementing a QuesttypeController.
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
*/
abstract class QuesttypeController extends \hhu\z\Controller
{
/**
* Required models
*
* @var array
*/
public $models = array('seminaries', 'questgroups', 'quests', 'characters');
/**
* Save the answers of a Character for a Quest.
*
* @param array $seminary Current Seminary data
* @param array $questgroup Current Questgroup data
* @param array $quest Current Quest data
* @param array $character Current Character data
* @param array $answers Character answers for the Quest
*/
public abstract function saveAnswersOfCharacter($seminary, $questgroup, $quest, $character, $answers);
/**
* Save additional data for the answers of a Character for a Quest.
*
* @param array $seminary Current Seminary data
* @param array $questgroup Current Questgroup data
* @param array $quest Current Quest data
* @param array $character Current Character data
* @param array $data Additional (POST-) data
*/
public abstract function saveDataForCharacterAnswers($seminary, $questgroup, $quest, $character, $data);
/**
* Check if answers of a Character for a Quest match the correct ones.
*
* @param array $seminary Current Seminary data
* @param array $questgroup Current Questgroup data
* @param array $quest Current Quest data
* @param array $character Current Character data
* @param array $answers Character answers for the Quest
* @return boolean True/false for a right/wrong answer or null for moderator evaluation
*/
public abstract function matchAnswersOfCharacter($seminary, $questgroup, $quest, $character, $answers);
/**
* Action: quest.
*
* Show the task of a Quest.
*
* @param array $seminary Current Seminary data
* @param array $questgroup Current Questgroup data
* @param array $quest Current Quest data
* @param array $character Current Character data
* @param \Exception $exception Character submission exception
*/
public abstract function quest($seminary, $questgroup, $quest, $character, $exception);
/**
* Action: submission.
*
* Show the submission of a Character for a Quest.
*
* @param array $seminary Current Seminary data
* @param array $questgroup Current Questgroup data
* @param array $quest Current Quest data
* @param array $character Current Character data
*/
public abstract function submission($seminary, $questgroup, $quest, $character);
/**
* 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;
/**
* 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);
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());
}
}
/**
* 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);
}
/**
* 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";
}
/**
* 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');
// Check file
if(!file_exists($fileName))
{
throw new \nre\exceptions\ClassNotFoundException(
$fullClassName
);
}
// 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
);
}
}
/**
* Construct a new application Controller.
*
* @throws \nre\exceptions\DriverNotFoundException
* @throws \nre\exceptions\DriverNotValidException
* @throws \nre\exceptions\ModelNotValidException
* @throws \nre\exceptions\ModelNotFoundException
* @throws \nre\exceptions\ViewNotFoundException
* @throws \hhu\z\exceptions\QuesttypeModelNotValidException
* @throws \hhu\z\exceptions\QuesttypeModelNotFoundException
* @param string $layoutName Name of the current Layout
* @param string $action Current Action
* @param Agent $agent Corresponding Agent
*/
public function __construct($layoutName, $action, $agent)
{
parent::__construct($layoutName, $action, $agent);
}
/**
* Load the Models of this Controller.
*
* @throws \nre\exceptions\DatamodelException
* @throws \nre\exceptions\DriverNotFoundException
* @throws \nre\exceptions\DriverNotValidException
* @throws \nre\exceptions\ModelNotValidException
* @throws \nre\exceptions\ModelNotFoundException
* @throws \hhu\z\exceptions\QuesttypeModelNotValidException
* @throws \hhu\z\exceptions\QuesttypeModelNotFoundException
*/
protected function loadModels()
{
// Load default models
parent::loadModels();
// Load QuesttypeModel
$this->loadModel();
}
/**
* Load the Model of the Questtype.
*
* @throws \hhu\z\exceptions\QuesttypeModelNotValidException
* @throws \hhu\z\exceptions\QuesttypeModelNotFoundException
*/
private function loadModel()
{
// Determine Model
$model = \nre\core\ClassLoader::stripClassType(\nre\core\ClassLoader::stripClassType(\nre\core\ClassLoader::stripNamespace(get_class($this))));
// Load class
\hhu\z\models\QuesttypeModel::load($model);
// Construct Model
$modelName = ucfirst(strtolower($model));
$this->$modelName = \hhu\z\models\QuesttypeModel::factory($model);
}
/**
* Load the View of this QuesttypeController.
*
* @throws \nre\exceptions\ViewNotFoundException
* @param string $layoutName Name of the current Layout
* @param string $action Current Action
*/
protected function loadView($layoutName, $action)
{
// Check Layout name
if(is_null($layoutName)) {
return;
}
// Determine controller name
$controllerName = \nre\core\ClassLoader::stripClassType(\nre\core\ClassLoader::getClassName(get_class($this)));
// Load view
$this->view = \hhu\z\views\QuesttypeView::loadAndFactory($layoutName, $controllerName, $action);
}
}
/**
* Abstract class for implementing a QuesttypeController.
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
*/
abstract class QuesttypeController extends \hhu\z\Controller
{
/**
* Required models
*
* @var array
*/
public $models = array('seminaries', 'questgroups', 'quests', 'characters');
/**
* Save the answers of a Character for a Quest.
*
* @param array $seminary Current Seminary data
* @param array $questgroup Current Questgroup data
* @param array $quest Current Quest data
* @param array $character Current Character data
* @param array $answers Character answers for the Quest
*/
public abstract function saveAnswersOfCharacter($seminary, $questgroup, $quest, $character, $answers);
/**
* Save additional data for the answers of a Character for a Quest.
*
* @param array $seminary Current Seminary data
* @param array $questgroup Current Questgroup data
* @param array $quest Current Quest data
* @param array $character Current Character data
* @param array $data Additional (POST-) data
*/
public abstract function saveDataForCharacterAnswers($seminary, $questgroup, $quest, $character, $data);
/**
* Check if answers of a Character for a Quest match the correct ones.
*
* @param array $seminary Current Seminary data
* @param array $questgroup Current Questgroup data
* @param array $quest Current Quest data
* @param array $character Current Character data
* @param array $answers Character answers for the Quest
* @return boolean True/false for a right/wrong answer or null for moderator evaluation
*/
public abstract function matchAnswersOfCharacter($seminary, $questgroup, $quest, $character, $answers);
/**
* Action: quest.
*
* Show the task of a Quest.
*
* @param array $seminary Current Seminary data
* @param array $questgroup Current Questgroup data
* @param array $quest Current Quest data
* @param array $character Current Character data
* @param \Exception $exception Character submission exception
*/
public abstract function quest($seminary, $questgroup, $quest, $character, $exception);
/**
* Action: submission.
*
* Show the submission of a Character for a Quest.
*
* @param array $seminary Current Seminary data
* @param array $questgroup Current Questgroup data
* @param array $quest Current Quest data
* @param array $character Current Character data
*/
public abstract function submission($seminary, $questgroup, $quest, $character);
/**
* Action: edittask.
*
* 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);
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());
}
}
/**
* 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);
}
/**
* 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";
}
/**
* 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');
// Check file
if(!file_exists($fileName))
{
throw new \nre\exceptions\ClassNotFoundException(
$fullClassName
);
}
// 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
);
}
}
/**
* Construct a new application Controller.
*
* @throws \nre\exceptions\DriverNotFoundException
* @throws \nre\exceptions\DriverNotValidException
* @throws \nre\exceptions\ModelNotValidException
* @throws \nre\exceptions\ModelNotFoundException
* @throws \nre\exceptions\ViewNotFoundException
* @throws \hhu\z\exceptions\QuesttypeModelNotValidException
* @throws \hhu\z\exceptions\QuesttypeModelNotFoundException
* @param string $layoutName Name of the current Layout
* @param string $action Current Action
* @param Agent $agent Corresponding Agent
*/
public function __construct($layoutName, $action, $agent)
{
parent::__construct($layoutName, $action, $agent);
}
/**
* Load the Models of this Controller.
*
* @throws \nre\exceptions\DatamodelException
* @throws \nre\exceptions\DriverNotFoundException
* @throws \nre\exceptions\DriverNotValidException
* @throws \nre\exceptions\ModelNotValidException
* @throws \nre\exceptions\ModelNotFoundException
* @throws \hhu\z\exceptions\QuesttypeModelNotValidException
* @throws \hhu\z\exceptions\QuesttypeModelNotFoundException
*/
protected function loadModels()
{
// Load default models
parent::loadModels();
// Load QuesttypeModel
$this->loadModel();
}
/**
* Load the Model of the Questtype.
*
* @throws \hhu\z\exceptions\QuesttypeModelNotValidException
* @throws \hhu\z\exceptions\QuesttypeModelNotFoundException
*/
private function loadModel()
{
// Determine Model
$model = \nre\core\ClassLoader::stripClassType(\nre\core\ClassLoader::stripClassType(\nre\core\ClassLoader::stripNamespace(get_class($this))));
// Load class
\hhu\z\models\QuesttypeModel::load($model);
// Construct Model
$modelName = ucfirst(strtolower($model));
$this->$modelName = \hhu\z\models\QuesttypeModel::factory($model);
}
/**
* Load the View of this QuesttypeController.
*
* @throws \nre\exceptions\ViewNotFoundException
* @param string $layoutName Name of the current Layout
* @param string $action Current Action
*/
protected function loadView($layoutName, $action)
{
// Check Layout name
if(is_null($layoutName)) {
return;
}
// Determine controller name
$controllerName = \nre\core\ClassLoader::stripClassType(\nre\core\ClassLoader::getClassName(get_class($this)));
// Load view
$this->view = \hhu\z\views\QuesttypeView::loadAndFactory($layoutName, $controllerName, $action);
}
}
?>

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
*/
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;
/**
* 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);
// 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 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);
}
/**
* 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;
}
// 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 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;
}
// 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']));
}
// 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;
}
// 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;
}
// 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;
}
}
}
// 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)
);
}
}
}
}
/**
* 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;
/**
* 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);
}
/**
* 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) {
}
// Check permissions
$this->checkPermission($request, $response);
// 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);
}
/**
* 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;
}
// 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 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;
}
// 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']));
}
// 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;
}
// 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;
}
// 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;
}
}
}
// 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)
);
}
}
}
}
?>

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
*/
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';
/**
* 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,
/**
* 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;
/**
* 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;
/**
* 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;
}
/**
* Get nested error.
*
* @return Nested error
*/
public function getNestedError()
{
return $this->nestedError;
}
}
);
// Store values
$this->nestedError = $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
*/
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';
/**
* 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
);
// Store values
$this->nestedMessage = $nestedMessage;
}
/**
* Get nested message.
*
* @return Nested message
*/
public function getNestedMessage()
{
return $this->nestedMessage;
}
}
/**
* 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;
/**
* 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;
/**
* 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;
}
/**
* 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
*/
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';
/**
* 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
);
// Store values
$this->error = $error;
}
/**
* Get nested error message.
*
* @return string Nested error message
*/
public function getError()
{
return $this->error;
}
}
/**
* 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;
/**
* 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;
/**
* 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;
}
/**
* 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
*/
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';
/**
* 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
);
}
}
/**
* 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;
/**
* 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
);
}
}
?>

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
*/
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';
/**
* 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
);
// 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;
}
}
/**
* 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;
/**
* 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;
/**
* 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;
}
/**
* 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
*/
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';
/**
* 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
);
// 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;
}
}
/**
* 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;
/**
* 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;
/**
* 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;
}
/**
* 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
*/
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';
/**
* 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
);
// 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;
}
}
/**
* 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;
/**
* 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;
/**
* 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;
}
/**
* 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
*/
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';
/**
* 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
);
// 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;
}
}
/**
* 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;
/**
* 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;
/**
* 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;
}
/**
* 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
*/
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';
/**
* 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
);
// 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;
}
}
/**
* 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;
/**
* 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;
/**
* 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;
}
/**
* 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
*/
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';
/**
* 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
);
// 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;
}
}
/**
* 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;
/**
* 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;
/**
* 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;
}
/**
* 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
*/
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';
/**
* 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
);
// Store value
$this->nestedException = $nestedException;
}
/**
* Get Nested exception.
*
* @return string Nested exception
*/
public function getNestedException()
{
return $this->nestedException;
}
}
/**
* 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;
/**
* 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;
/**
* 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;
}
/**
* 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
*/
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”';
/**
* 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
);
// Store values
$this->type = $type;
}
/**
* Get type of file.
*
* @return Type of file
*/
public function getType()
{
return $this->type;
}
}
/**
* 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;
/**
* 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;
/**
* 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;
}
/**
* 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
*/
namespace hhu\z\lib
{
/**
* 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()
{
}
}
}
namespace {
/**
* 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
{
/**
* 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()
{
}
}
}
namespace {
/**
* PHPMailer - PHP email creation and transport class.

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
*/
namespace hhu\z\lib
{
/**
* 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()
{
}
}
}
namespace {
/**
* 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
{
/**
* 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()
{
}
}
}
namespace {
/**
* PHPMailer SPL autoloader.
* PHP Version 5

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
*/
namespace hhu\z\lib
{
/**
* 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()
{
}
}
}
/**
* 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
{
/**
* 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()
{
}
}
}

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
*/
namespace hhu\z\lib
{
/**
* 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()
{
}
}
}
namespace {
/**
* 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
{
/**
* 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()
{
}
}
}
namespace {
/**
* PHPMailer RFC821 SMTP email transport class.

View file

@ -1,31 +1,31 @@
<?php
/**
* The Legend of Z
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
* @license http://www.gnu.org/licenses/gpl.html
* @link https://bitbucket.org/coderkun/the-legend-of-z
*/
namespace hhu\z\models;
/**
* Abstract class for implementing a QuesttypeModel.
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
*/
abstract class QuesttypeModel extends \hhu\z\Model
{
/**
* 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;
/**
* Abstract class for implementing a QuesttypeModel.
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
*/
abstract class QuesttypeModel extends \hhu\z\Model
{
/**
* Copy a Quest.
*
*
* @param int $userId ID of creating user
* @param int $sourceQuestId ID of Quest to copy from
* @param int $targetQuestId ID of Quest to copy to
@ -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);
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());
}
}
/**
* 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();
}
/**
* 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";
}
/**
* 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');
// Check file
if(!file_exists($fileName))
{
throw new \nre\exceptions\ClassNotFoundException(
$fullClassName
);
}
// 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
);
}
}
/**
* 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();
}
}
/**
* 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);
// 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);
// 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');
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);
// 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
);
}
// 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
);
}
}
/**
* 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
*/
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;
/**
* 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()
);
}
/**
* 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;
}
/**
* Get linker instance for creating links.
*
* @return \nre\core\Linker Linker instance for creating links
*/
public function getLinker()
{
return $this->linker;
}
}
/**
* 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;
/**
* 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 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);
}
/**
* 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;
}
}
?>

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
*/
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;
/**
* 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;
}
}
/**
* 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;
/**
* 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;
}
/**
* 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
*/
namespace hhu\z\views;
/**
* 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);
}
/**
* 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);
// File extension
$fileName .= \nre\configs\CoreConfig::getFileExt('views');
// Check template file
if(!file_exists($fileName)) {
throw new \nre\exceptions\ViewNotFoundException($fileName);
}
// Save filename
$this->templateFilename = $fileName;
}
}
/**
* 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;
/**
* 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);
}
/**
* 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);
// File extension
$fileName .= \nre\configs\CoreConfig::getFileExt('views');
// Check template file
if(!file_exists($fileName)) {
throw new \nre\exceptions\ViewNotFoundException($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
*/
namespace hhu\z\controllers;
/**
* Controller of the AjaxAgent to return a JSON-string used by AJAX.
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
*/
class AjaxController extends \hhu\z\Controller
{
/**
* Prefilter.
*
* @param \nre\core\Request $request Current request
* @param \nre\core\Response $response Current response
*/
public function preFilter(\nre\core\Request $request, \nre\core\Response $response)
{
parent::preFilter($request, $response);
// Set content-type
$this->response->addHeader("Content-type: application/json; charset=utf-8");
}
/**
* Action: index.
*
* Create the JSON-string.
*/
public function index()
{
}
}
/**
* The Legend of Z
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
* @license http://www.gnu.org/licenses/gpl.html
* @link https://bitbucket.org/coderkun/the-legend-of-z
*/
namespace hhu\z\controllers;
/**
* Controller of the AjaxAgent to return a JSON-string used by AJAX.
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
*/
class AjaxController extends \hhu\z\Controller
{
/**
* Prefilter.
*
* @param \nre\core\Request $request Current request
* @param \nre\core\Response $response Current response
*/
public function preFilter(\nre\core\Request $request, \nre\core\Response $response)
{
parent::preFilter($request, $response);
// Set content-type
$this->response->addHeader("Content-type: application/json; charset=utf-8");
}
/**
* Action: index.
*
* Create the JSON-string.
*/
public function index()
{
}
}
?>

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

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

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
*/
namespace hhu\z\controllers;
/**
* Controller of the CharactertypesAgent to handle Charactertyes of a
* Seminary.
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
*/
class CharactertypesController extends \hhu\z\controllers\SeminaryController
{
/**
* Required components
*
* @var array
*/
public $components = array('validation');
/**
* Required models
*
* @var array
*/
public $models = array('charactertypes', 'xplevels', 'avatars', 'media');
/**
* User permissions
*
* @var array
*/
public $permissions = array(
'index' => array('admin', 'moderator', 'user'),
'create' => array('admin', 'moderator', 'user'),
'edit' => array('admin', 'moderator', 'user'),
'delete' => array('admin', 'moderator', 'user')
);
/**
* Action: index.
*
* List Character types.
*
* @throws \nre\exceptions\IdNotFoundException
* @param string $seminaryUrl URL-Title of a Seminary
*/
public function index($seminaryUrl)
{
// Get seminary
$seminary = $this->Seminaries->getSeminaryByUrl($seminaryUrl);
/**
* The Legend of Z
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
* @license http://www.gnu.org/licenses/gpl.html
* @link https://bitbucket.org/coderkun/the-legend-of-z
*/
// Check permissions
if(
(is_null(self::$character) && count(array_intersect(array('admin', 'moderator'), \hhu\z\controllers\IntermediateController::$user['roles'])) == 0) &&
$seminary['created_user_id'] != self::$user['id']
) {
throw new \nre\exceptions\AccessDeniedException();
}
// Get Character types
$charactertypes = $this->Charactertypes->getCharacterTypesForSeminary($seminary['id']);
// Get Avatars
$xplevels = $this->Xplevels->getXPLevelsForSeminary($seminary['id']);
if(count($xplevels) > 0)
{
foreach($charactertypes as &$type)
{
try {
$type['avatar'] = $this->Avatars->getAvatarByTypeAndLevel($seminary['id'], $type['url'], $xplevels[0]['level']);
}
catch(\nre\exceptions\IdNotFoundException $e) {
// No Avatar available
}
}
}
namespace hhu\z\controllers;
// Set titile
$this->addTitleLocalized('Charactertypes');
$this->addTitle($seminary['title']);
// Pass data to view
$this->set('seminary', $seminary);
$this->set('xplevels', $xplevels);
$this->set('charactertypes', $charactertypes);
}
/**
* Controller of the CharactertypesAgent to handle Charactertyes of a
* Seminary.
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
*/
class CharactertypesController extends \hhu\z\controllers\SeminaryController
{
/**
* Required components
*
* @var array
*/
public $components = array('validation');
/**
* Required models
*
* @var array
*/
public $models = array('charactertypes', 'xplevels', 'avatars', 'media');
/**
* User permissions
*
* @var array
*/
public $permissions = array(
'index' => array('admin', 'moderator', 'user'),
'create' => array('admin', 'moderator', 'user'),
'edit' => array('admin', 'moderator', 'user'),
'delete' => array('admin', 'moderator', 'user')
);
/**
* Action: create.
*
* Create new Character type for a Seminary.
*
* @throws \nre\exceptions\IdNotFoundException
* @param string $seminaryUrl URL-Title of a Seminary
*/
public function create($seminaryUrl)
{
// Get seminary
$seminary = $this->Seminaries->getSeminaryByUrl($seminaryUrl);
// Check permissions
if(
$seminary['created_user_id'] != self::$user['id'] &&
(is_null(self::$character) && count(array_intersect(array('admin'), \hhu\z\controllers\IntermediateController::$user['roles'])) == 0)
) {
throw new \nre\exceptions\AccessDeniedException();
}
// Values
$name = '';
$fields = array('charactertypename');
$validation = array();
// Create new Charactertype
if($this->request->getRequestMethod() == 'POST' && !is_null($this->request->getPostParam('create')))
{
// Get params and validate them
$validation = $this->Validation->validateParams($this->request->getPostParams(), $fields);
$name = $this->request->getPostParam('charactertypename');
if($this->Charactertypes->charactertypeNameExists($seminary['id'], $name)) {
$validation = $this->Validation->addValidationResult($validation, 'charactertypename', 'exist', true);
}
// Create new Charactertype
if($validation === true)
{
$charactertypeId = $this->Charactertypes->createCharactertype(
$this->Auth->getUserId(),
$seminary['id'],
$name
);
$charactertype = $this->Charactertypes->getCharactertypeById($charactertypeId);
// Redirect to editing
$this->redirect($this->linker->link(array('edit', $seminary['url'], $charactertype['url']), 1));
}
}
// Get validation settings
$validationSettings = array();
foreach($fields as &$field) {
$validationSettings[$field] = \nre\configs\AppConfig::$validation[$field];
}
// Set titile
$this->addTitleLocalized('Create new Charactertype');
$this->addTitle($seminary['title']);
// Pass data to view
$this->set('seminary', $seminary);
$this->set('name', $name);
$this->set('validation', $validation);
$this->set('validationSettings', $validationSettings);
}
/**
* Action: index.
*
* List Character types.
*
* @throws \nre\exceptions\IdNotFoundException
* @param string $seminaryUrl URL-Title of a Seminary
*/
public function index($seminaryUrl)
{
// Get seminary
$seminary = $this->Seminaries->getSeminaryByUrl($seminaryUrl);
// Check permissions
if(
(is_null(self::$character) && count(array_intersect(array('admin', 'moderator'), \hhu\z\controllers\IntermediateController::$user['roles'])) == 0) &&
$seminary['created_user_id'] != self::$user['id']
) {
throw new \nre\exceptions\AccessDeniedException();
}
// Get Character types
$charactertypes = $this->Charactertypes->getCharacterTypesForSeminary($seminary['id']);
// Get Avatars
$xplevels = $this->Xplevels->getXPLevelsForSeminary($seminary['id']);
if(count($xplevels) > 0)
{
foreach($charactertypes as &$type)
{
try {
$type['avatar'] = $this->Avatars->getAvatarByTypeAndLevel($seminary['id'], $type['url'], $xplevels[0]['level']);
}
catch(\nre\exceptions\IdNotFoundException $e) {
// No Avatar available
}
}
}
/**
* Action: edit.
*
* Edit Character type for a Seminary.
*
* @throws \nre\exceptions\IdNotFoundException
* @param string $seminaryUrl URL-title of a Seminary
* @param string $charactertypeUrl URL-title of Character type
*/
public function edit($seminaryUrl, $charactertypeUrl)
{
// Get seminary
$seminary = $this->Seminaries->getSeminaryByUrl($seminaryUrl);
// Set titile
$this->addTitleLocalized('Charactertypes');
$this->addTitle($seminary['title']);
// Check permissions
if(
$seminary['created_user_id'] != self::$user['id'] &&
(is_null(self::$character) && count(array_intersect(array('admin', 'moderator'), \hhu\z\controllers\IntermediateController::$user['roles'])) == 0)
) {
throw new \nre\exceptions\AccessDeniedException();
}
// Get Character type
$charactertype = $this->Charactertypes->getCharactertypeByUrl($seminary['id'], $charactertypeUrl);
// XP-levels
$xplevels = $this->Xplevels->getXPLevelsForSeminary($seminary['id']);
foreach($xplevels as &$xplevel)
{
try {
$xplevel['avatar'] = $this->Avatars->getAvatarByTypeAndLevel($seminary['id'], $charactertype['url'], $xplevel['level']);
}
catch(\nre\exceptions\IdNotFoundException $e) {
// No Avatar available
}
}
// Get allowed mimetypes
$mimetypes = \nre\configs\AppConfig::$mimetypes['moodpics'];
// Values
$name = $charactertype['name'];
$fields = array('charactertypename');
$validation = array();
$avatarVariants = array('portrait', 'avatar');
$avatarsValidation = true;
// Check request method
if($this->request->getRequestMethod() == 'POST' && !is_null($this->request->getPostParam('edit')))
{
// Get params and validate them
$validation = $this->Validation->validateParams($this->request->getPostParams(), $fields);
$name = $this->request->getPostParam('charactertypename');
if($this->Charactertypes->charactertypeNameExists($seminary['id'], $name, $charactertype['id'])) {
$validation = $this->Validation->addValidationResult($validation, 'charactertypename', 'exist', true);
}
// Validate and upload avatars
if(array_key_exists('avatars', $_FILES))
{
foreach($xplevels as &$xplevel)
{
if(array_key_exists($xplevel['id'], $_FILES['avatars']['error']))
{
foreach($avatarVariants as &$variant)
{
if(array_key_exists($variant, $_FILES['avatars']['error'][$xplevel['id']]) && $_FILES['avatars']['error'][$xplevel['id']][$variant] !== UPLOAD_ERR_NO_FILE)
{
$avatar = array(
'name' => $_FILES['avatars']['name'][$xplevel['id']][$variant],
'type' => $_FILES['avatars']['type'][$xplevel['id']][$variant],
'tmp_name' => $_FILES['avatars']['tmp_name'][$xplevel['id']][$variant],
'error' => $_FILES['avatars']['error'][$xplevel['id']][$variant],
'size' => $_FILES['avatars']['size'][$xplevel['id']][$variant]
);
$avatarValidation = true;
// Check error
if($avatar['error'] !== UPLOAD_ERR_OK) {
$avatarValidation = $this->Validation->addValidationResult($avatarValidation, 'avatar', 'error', $avatar['error']);
}
// Check mimetype
$avatarMimetype = null;
$avatar['mimetype'] = \hhu\z\Utils::getMimetype($avatar['tmp_name'], $avatar['type']);
foreach($mimetypes as &$mimetype) {
if($mimetype['mimetype'] == $avatar['mimetype']) {
$avatarMimetype = $mimetype;
break;
}
}
if(is_null($avatarMimetype)) {
$avatarValidation = $this->Validation->addValidationResult($avatarValidation, 'avatar', 'mimetype', $avatar['mimetype']);
}
elseif($avatar['size'] > $avatarMimetype['size']) {
$avatarValidation = $this->Validation->addValidationResult($avatarValidation, 'avatar', 'size', $avatarMimetype['size']);
}
// Add validation result
if(!$avatarValidation !== true)
{
if(!is_array($avatarsValidation)) {
$avatarsValidation = array();
}
if(!array_key_exists($xplevel['id'], $avatarsValidation)) {
$avatarsValidation[$xplevel['id']] = array();
}
$avatarsValidation[$xplevel['id']][$variant] = $avatarValidation;
}
// Upload avatar
if($avatarValidation === true)
{
$avatar['media_id'] = $this->Media->createAvatarPicture(
$this->Auth->getUserId(),
$seminary['id'],
sprintf('avatar-%d-%d-%s', $charactertype['id'], $xplevel['id'], $variant),
'',
$avatar['mimetype'],
$avatar['tmp_name']
);
// Set avatar
if($variant == 'portrait') {
$this->Avatars->setAvatarPortraitForTypeAndLevel(
$this->Auth->getUserId(),
$charactertype['id'],
$xplevel['id'],
$avatar['media_id']
);
}
else {
$this->Avatars->setAvatarForTypeAndLevel(
$this->Auth->getUserId(),
$charactertype['id'],
$xplevel['id'],
$avatar['media_id']
);
}
}
}
}
}
}
}
// Edit Charactertype
if($validation === true && $avatarsValidation === true)
{
$this->Charactertypes->editCharactertype(
$charactertype['id'],
$name
);
$charactertype = $this->Charactertypes->getCharactertypeById($charactertype['id']);
// Redirect to overview
$this->redirect($this->linker->link(array('index', $seminary['url']), 1));
}
}
// Get validation settings
$validationSettings = array();
foreach($fields as &$field) {
$validationSettings[$field] = \nre\configs\AppConfig::$validation[$field];
}
// Pass data to view
$this->set('seminary', $seminary);
$this->set('xplevels', $xplevels);
$this->set('charactertypes', $charactertypes);
}
// Set titile
$this->addTitleLocalized('Edit Charactertype');
$this->addTitle($seminary['title']);
// Pass data to view
$this->set('seminary', $seminary);
$this->set('charactertype', $charactertype);
$this->set('xplevels', $xplevels);
$this->set('name', $name);
$this->set('mimetypes', $mimetypes);
$this->set('validation', $validation);
$this->set('avatarsValidation', $avatarsValidation);
$this->set('avatarVariants', $avatarVariants);
$this->set('validationSettings', $validationSettings);
}
/**
* Action: create.
*
* Create new Character type for a Seminary.
*
* @throws \nre\exceptions\IdNotFoundException
* @param string $seminaryUrl URL-Title of a Seminary
*/
public function create($seminaryUrl)
{
// Get seminary
$seminary = $this->Seminaries->getSeminaryByUrl($seminaryUrl);
// Check permissions
if(
$seminary['created_user_id'] != self::$user['id'] &&
(is_null(self::$character) && count(array_intersect(array('admin'), \hhu\z\controllers\IntermediateController::$user['roles'])) == 0)
) {
throw new \nre\exceptions\AccessDeniedException();
}
// Values
$name = '';
$fields = array('charactertypename');
$validation = array();
// Create new Charactertype
if($this->request->getRequestMethod() == 'POST' && !is_null($this->request->getPostParam('create')))
{
// Get params and validate them
$validation = $this->Validation->validateParams($this->request->getPostParams(), $fields);
$name = $this->request->getPostParam('charactertypename');
if($this->Charactertypes->charactertypeNameExists($seminary['id'], $name)) {
$validation = $this->Validation->addValidationResult($validation, 'charactertypename', 'exist', true);
}
// Create new Charactertype
if($validation === true)
{
$charactertypeId = $this->Charactertypes->createCharactertype(
$this->Auth->getUserId(),
$seminary['id'],
$name
);
$charactertype = $this->Charactertypes->getCharactertypeById($charactertypeId);
// Redirect to editing
$this->redirect($this->linker->link(array('edit', $seminary['url'], $charactertype['url']), 1));
}
}
// Get validation settings
$validationSettings = array();
foreach($fields as &$field) {
$validationSettings[$field] = \nre\configs\AppConfig::$validation[$field];
}
/**
* Action: delete.
*
* Delete Character type for a Seminary.
*
* @throws \nre\exceptions\IdNotFoundException
* @param string $seminaryUrl URL-title of a Seminary
* @param string $charactertypeUrl URL-title of Character type
*/
public function delete($seminaryUrl, $charactertypeUrl)
{
// Get seminary
$seminary = $this->Seminaries->getSeminaryByUrl($seminaryUrl);
// Set titile
$this->addTitleLocalized('Create new Charactertype');
$this->addTitle($seminary['title']);
// Check permissions
if(
$seminary['created_user_id'] != self::$user['id'] &&
(is_null(self::$character) && count(array_intersect(array('admin'), \hhu\z\controllers\IntermediateController::$user['roles'])) == 0)
) {
throw new \nre\exceptions\AccessDeniedException();
}
// Get Character type
$charactertype = $this->Charactertypes->getCharactertypeByUrl($seminary['id'], $charactertypeUrl);
// Check request method
if($this->request->getRequestMethod() == 'POST')
{
// Check confirmation
if(!is_null($this->request->getPostParam('delete')))
{
// Delete Character type
$this->Charactertypes->deleteCharactertype($charactertype['id']);
}
// Redirect to overview
$this->redirect($this->linker->link(array('index', $seminary['url']), 1));
}
// Pass data to view
$this->set('seminary', $seminary);
$this->set('name', $name);
$this->set('validation', $validation);
$this->set('validationSettings', $validationSettings);
}
// Set titile
$this->addTitleLocalized('Delete Charactertype');
$this->addTitle($seminary['title']);
// Pass data to view
$this->set('seminary', $seminary);
$this->set('charactertype', $charactertype);
}
}
/**
* Action: edit.
*
* Edit Character type for a Seminary.
*
* @throws \nre\exceptions\IdNotFoundException
* @param string $seminaryUrl URL-title of a Seminary
* @param string $charactertypeUrl URL-title of Character type
*/
public function edit($seminaryUrl, $charactertypeUrl)
{
// Get seminary
$seminary = $this->Seminaries->getSeminaryByUrl($seminaryUrl);
// Check permissions
if(
$seminary['created_user_id'] != self::$user['id'] &&
(is_null(self::$character) && count(array_intersect(array('admin', 'moderator'), \hhu\z\controllers\IntermediateController::$user['roles'])) == 0)
) {
throw new \nre\exceptions\AccessDeniedException();
}
// Get Character type
$charactertype = $this->Charactertypes->getCharactertypeByUrl($seminary['id'], $charactertypeUrl);
// XP-levels
$xplevels = $this->Xplevels->getXPLevelsForSeminary($seminary['id']);
foreach($xplevels as &$xplevel)
{
try {
$xplevel['avatar'] = $this->Avatars->getAvatarByTypeAndLevel($seminary['id'], $charactertype['url'], $xplevel['level']);
}
catch(\nre\exceptions\IdNotFoundException $e) {
// No Avatar available
}
}
// Get allowed mimetypes
$mimetypes = \nre\configs\AppConfig::$mimetypes['moodpics'];
// Values
$name = $charactertype['name'];
$fields = array('charactertypename');
$validation = array();
$avatarVariants = array('portrait', 'avatar');
$avatarsValidation = true;
// Check request method
if($this->request->getRequestMethod() == 'POST' && !is_null($this->request->getPostParam('edit')))
{
// Get params and validate them
$validation = $this->Validation->validateParams($this->request->getPostParams(), $fields);
$name = $this->request->getPostParam('charactertypename');
if($this->Charactertypes->charactertypeNameExists($seminary['id'], $name, $charactertype['id'])) {
$validation = $this->Validation->addValidationResult($validation, 'charactertypename', 'exist', true);
}
// Validate and upload avatars
if(array_key_exists('avatars', $_FILES))
{
foreach($xplevels as &$xplevel)
{
if(array_key_exists($xplevel['id'], $_FILES['avatars']['error']))
{
foreach($avatarVariants as &$variant)
{
if(array_key_exists($variant, $_FILES['avatars']['error'][$xplevel['id']]) && $_FILES['avatars']['error'][$xplevel['id']][$variant] !== UPLOAD_ERR_NO_FILE)
{
$avatar = array(
'name' => $_FILES['avatars']['name'][$xplevel['id']][$variant],
'type' => $_FILES['avatars']['type'][$xplevel['id']][$variant],
'tmp_name' => $_FILES['avatars']['tmp_name'][$xplevel['id']][$variant],
'error' => $_FILES['avatars']['error'][$xplevel['id']][$variant],
'size' => $_FILES['avatars']['size'][$xplevel['id']][$variant]
);
$avatarValidation = true;
// Check error
if($avatar['error'] !== UPLOAD_ERR_OK) {
$avatarValidation = $this->Validation->addValidationResult($avatarValidation, 'avatar', 'error', $avatar['error']);
}
// Check mimetype
$avatarMimetype = null;
$avatar['mimetype'] = \hhu\z\Utils::getMimetype($avatar['tmp_name'], $avatar['type']);
foreach($mimetypes as &$mimetype) {
if($mimetype['mimetype'] == $avatar['mimetype']) {
$avatarMimetype = $mimetype;
break;
}
}
if(is_null($avatarMimetype)) {
$avatarValidation = $this->Validation->addValidationResult($avatarValidation, 'avatar', 'mimetype', $avatar['mimetype']);
}
elseif($avatar['size'] > $avatarMimetype['size']) {
$avatarValidation = $this->Validation->addValidationResult($avatarValidation, 'avatar', 'size', $avatarMimetype['size']);
}
// Add validation result
if(!$avatarValidation !== true)
{
if(!is_array($avatarsValidation)) {
$avatarsValidation = array();
}
if(!array_key_exists($xplevel['id'], $avatarsValidation)) {
$avatarsValidation[$xplevel['id']] = array();
}
$avatarsValidation[$xplevel['id']][$variant] = $avatarValidation;
}
// Upload avatar
if($avatarValidation === true)
{
$avatar['media_id'] = $this->Media->createAvatarPicture(
$this->Auth->getUserId(),
$seminary['id'],
sprintf('avatar-%d-%d-%s', $charactertype['id'], $xplevel['id'], $variant),
'',
$avatar['mimetype'],
$avatar['tmp_name']
);
// Set avatar
if($variant == 'portrait') {
$this->Avatars->setAvatarPortraitForTypeAndLevel(
$this->Auth->getUserId(),
$charactertype['id'],
$xplevel['id'],
$avatar['media_id']
);
}
else {
$this->Avatars->setAvatarForTypeAndLevel(
$this->Auth->getUserId(),
$charactertype['id'],
$xplevel['id'],
$avatar['media_id']
);
}
}
}
}
}
}
}
// Edit Charactertype
if($validation === true && $avatarsValidation === true)
{
$this->Charactertypes->editCharactertype(
$charactertype['id'],
$name
);
$charactertype = $this->Charactertypes->getCharactertypeById($charactertype['id']);
// Redirect to overview
$this->redirect($this->linker->link(array('index', $seminary['url']), 1));
}
}
// Get validation settings
$validationSettings = array();
foreach($fields as &$field) {
$validationSettings[$field] = \nre\configs\AppConfig::$validation[$field];
}
// Set titile
$this->addTitleLocalized('Edit Charactertype');
$this->addTitle($seminary['title']);
// Pass data to view
$this->set('seminary', $seminary);
$this->set('charactertype', $charactertype);
$this->set('xplevels', $xplevels);
$this->set('name', $name);
$this->set('mimetypes', $mimetypes);
$this->set('validation', $validation);
$this->set('avatarsValidation', $avatarsValidation);
$this->set('avatarVariants', $avatarVariants);
$this->set('validationSettings', $validationSettings);
}
/**
* Action: delete.
*
* Delete Character type for a Seminary.
*
* @throws \nre\exceptions\IdNotFoundException
* @param string $seminaryUrl URL-title of a Seminary
* @param string $charactertypeUrl URL-title of Character type
*/
public function delete($seminaryUrl, $charactertypeUrl)
{
// Get seminary
$seminary = $this->Seminaries->getSeminaryByUrl($seminaryUrl);
// Check permissions
if(
$seminary['created_user_id'] != self::$user['id'] &&
(is_null(self::$character) && count(array_intersect(array('admin'), \hhu\z\controllers\IntermediateController::$user['roles'])) == 0)
) {
throw new \nre\exceptions\AccessDeniedException();
}
// Get Character type
$charactertype = $this->Charactertypes->getCharactertypeByUrl($seminary['id'], $charactertypeUrl);
// Check request method
if($this->request->getRequestMethod() == 'POST')
{
// Check confirmation
if(!is_null($this->request->getPostParam('delete')))
{
// Delete Character type
$this->Charactertypes->deleteCharactertype($charactertype['id']);
}
// Redirect to overview
$this->redirect($this->linker->link(array('index', $seminary['url']), 1));
}
// Set titile
$this->addTitleLocalized('Delete Charactertype');
$this->addTitle($seminary['title']);
// Pass data to view
$this->set('seminary', $seminary);
$this->set('charactertype', $charactertype);
}
}
?>

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

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

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

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

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

File diff suppressed because it is too large Load diff

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

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

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

File diff suppressed because it is too large Load diff

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

File diff suppressed because it is too large Load diff

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
*/
namespace hhu\z\controllers;
/**
* Controller of the QuestgroupsAgent to display Questgroups.
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
*/
class QuestgroupshierarchyController extends \hhu\z\controllers\SeminaryController
{
/**
* Required components
*
* @var array
*/
public $components = array('validation');
/**
* Required models
*
* @var array
*/
public $models = array('seminaries', 'questgroupshierarchy', 'questgroups');
/**
* User permissions
*
* @var array
*/
public $permissions = array(
'create' => array('admin', 'moderator', 'user'),
'edit' => array('admin', 'moderator', 'user'),
'moveup' => array('admin', 'moderator', 'user'),
'movedown' => array('admin', 'moderator', 'user'),
'delete' => array('admin', 'moderator', 'user')
);
/**
* User seminary permissions
*
* @var array
*/
public $seminaryPermissions = array(
'create' => array('admin'),
'edit' => array('admin'),
'moveup' => array('admin'),
'movedown' => array('admin'),
'delete' => array('admin')
);
/**
* Action: create.
*
* Create a new Questgroupshierarchy.
*
* @param string $seminaryUrl URL-title of a Seminary
*/
public function create($seminaryUrl)
{
// Get seminary
$seminary = $this->Seminaries->getSeminaryByUrl($seminaryUrl);
// Get parent Questgroupshierarchy
$parentQuestgroupshierarchy = $this->Questgroupshierarchy->getHierarchyOfSeminary($seminary['id']);
// Values
$titleSingular = '';
$titlePlural = '';
$validation = array();
// Create Questgroupshierarchy
if($this->request->getRequestMethod() == 'POST' && !is_null($this->request->getPostParam('create')))
{
// Get params and validate them
$titleSingular = $this->request->getPostParam('title_singular');
$validation = $this->Validation->addValidationResults(
$validation,
'titleSingular',
$this->Validation->validate($titleSingular, \nre\configs\AppConfig::$validation['questgroupshierarchytitle'])
);
if($this->Questgroupshierarchy->questgroupshierarchyTitleSingularExists($titleSingular, $seminary['id'])) {
$validation = $this->Validation->addValidationResult($validation, 'titleSingular', 'exist', true);
}
$titlePlural = $this->request->getPostParam('title_plural');
$validation = $this->Validation->addValidationResults(
$validation,
'titlePlural',
$this->Validation->validate($titlePlural, \nre\configs\AppConfig::$validation['questgroupshierarchytitle'])
);
if($this->Questgroupshierarchy->questgroupshierarchyTitleSingularExists($titlePlural, $seminary['id'])) {
$validation = $this->Validation->addValidationResult($validation, 'titlePlural', 'exist', true);
}
// Validate parent Questgroupshierarchy
$parentQuestgroupshierarchyIndex = null;
foreach($parentQuestgroupshierarchy as $index => &$parentHierarchy)
{
$parentHierarchy['selected'] = ($parentHierarchy['url'] == $this->request->getPostParam('parent'));
if($parentHierarchy['selected']) {
$parentQuestgroupshierarchyIndex = $index;
}
}
// Create new Questgroupshierarchy
if($validation === true)
{
$questgroupshierarchyId = $this->Questgroupshierarchy->createQuestgroupshierarchy(
$this->Auth->getUserId(),
$seminary['id'],
(!is_null($parentQuestgroupshierarchyIndex) ? $parentQuestgroupshierarchy[$parentQuestgroupshierarchyIndex]['id'] : null),
$titleSingular,
$titlePlural
);
$questgroupshierarchy = $this->Questgroupshierarchy->getHierarchyById($questgroupshierarchyId);
// Redirect
$this->redirect($this->linker->link(array('seminaries', 'seminary', $seminary['url'])));
}
}
// Get validation settings
$validationSettings = array(
'title' => \nre\configs\AppConfig::$validation['title']
);
// Set titile
$this->addTitleLocalized('Create Questgroupshierarchy');
$this->addTitle($seminary['title']);
// Pass data to view
$this->set('seminary', $seminary);
$this->set('titleSingular', $titleSingular);
$this->set('titlePlural', $titlePlural);
$this->set('parentQuestgroupshierarchy', $parentQuestgroupshierarchy);
$this->set('validation', $validation);
$this->set('validationSettings', $validationSettings);
}
/**
* Action: edit.
*
* Edit a Questgroupshierarchy.
*
* @throws \nre\exceptions\IdNotFoundException
* @param string $seminaryUrl URL-title of Seminary
* @param string $questgroupshierarchyUrl URL-title of Questgroupshierarchy
*/
public function edit($seminaryUrl, $questgroupshierarchyUrl)
{
// Get seminary
$seminary = $this->Seminaries->getSeminaryByUrl($seminaryUrl);
// Get Questgroupshierarchy
$questgroupshierarchy = $this->Questgroupshierarchy->getHierarchyByUrl($seminary['id'], $questgroupshierarchyUrl);
// Values
$titleSingular = $questgroupshierarchy['title_singular'];
$titlePlural = $questgroupshierarchy['title_plural'];
$validation = array();
// Check request method
if($this->request->getRequestMethod() == 'POST' && !is_null($this->request->getPostParam('edit')))
{
// Get params and validate them
$titleSingular = $this->request->getPostParam('title_singular');
$validation = $this->Validation->addValidationResults(
$validation,
'titleSingular',
$this->Validation->validate($titleSingular, \nre\configs\AppConfig::$validation['questgroupshierarchytitle'])
);
if($this->Questgroupshierarchy->questgroupshierarchyTitleSingularExists($titleSingular, $seminary['id'], $questgroupshierarchy['id'])) {
$validation = $this->Validation->addValidationResult($validation, 'titleSingular', 'exist', true);
}
$titlePlural = $this->request->getPostParam('title_plural');
$validation = $this->Validation->addValidationResults(
$validation,
'titlePlural',
$this->Validation->validate($titlePlural, \nre\configs\AppConfig::$validation['questgroupshierarchytitle'])
);
if($this->Questgroupshierarchy->questgroupshierarchyTitleSingularExists($titlePlural, $seminary['id'], $questgroupshierarchy['id'])) {
$validation = $this->Validation->addValidationResult($validation, 'titlePlural', 'exist', true);
}
/**
* The Legend of Z
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
* @license http://www.gnu.org/licenses/gpl.html
* @link https://bitbucket.org/coderkun/the-legend-of-z
*/
// Edit Questgroup
if($validation === true)
{
$this->Questgroupshierarchy->editQuestgroupshierarchy(
$questgroupshierarchy['id'],
$titleSingular,
$titlePlural
);
$questgroupshierarchy = $this->Questgroupshierarchy->getHierarchyById($questgroupshierarchy['id']);
// Redirect to Seminary page
$this->redirect($this->linker->link(array('seminaries', 'seminary', $seminary['url'])));
}
}
// Get validation settings
$validationSettings = array(
'title' => \nre\configs\AppConfig::$validation['title']
);
// Set titile
$this->addTitleLocalized('Edit Questgroupshierarchy');
$this->addTitle($seminary['title']);
// Pass data to view
$this->set('seminary', $seminary);
$this->set('titleSingular', $titleSingular);
$this->set('titlePlural', $titlePlural);
$this->set('validation', $validation);
$this->set('validationSettings', $validationSettings);
}
/**
* Action: moveup.
*
* Move a Questgroupshierarchy up (decrement position).
*
* @throws \nre\exceptions\IdNotFoundException
* @param string $seminaryUrl URL-title of Seminary
* @param string $questgroupshierarchyUrl URL-title of Questgroupshierarchy
*/
public function moveup($seminaryUrl, $questgroupshierarchyUrl)
{
// Get seminary
$seminary = $this->Seminaries->getSeminaryByUrl($seminaryUrl);
// Get Questgroupshierarchy
$questgroupshierarchy = $this->Questgroupshierarchy->getHierarchyByUrl($seminary['id'], $questgroupshierarchyUrl);
// Set position
$this->Questgroupshierarchy->moveQuestgroupshierarchy($questgroupshierarchy, true);
// Redirect
$referer = $this->request->getGetParam('referer');
if(!is_null($referer))
{
try {
$questgroup = $this->Questgroups->getQuestgroupById($referer);
$this->redirect($this->linker->link(array('questgroups', 'questgroup', $seminary['url'], $questgroup['url'])));
}
catch(IdNotFoundException $e) {
}
}
$this->redirect($this->linker->link(array('seminaries', 'seminary', $seminary['url'])));
}
/**
* Action: movedown.
*
* Move a Questgroupshierarchy down (increment position).
*
* @throws \nre\exceptions\IdNotFoundException
* @param string $seminaryUrl URL-title of Seminary
* @param string $questgroupshierarchyUrl URL-title of Questgroupshierarchy
*/
public function movedown($seminaryUrl, $questgroupshierarchyUrl)
{
// Get seminary
$seminary = $this->Seminaries->getSeminaryByUrl($seminaryUrl);
// Get Questgroupshierarchy
$questgroupshierarchy = $this->Questgroupshierarchy->getHierarchyByUrl($seminary['id'], $questgroupshierarchyUrl);
// Set position
$this->Questgroupshierarchy->moveQuestgroupshierarchy($questgroupshierarchy, false);
// Redirect
$referer = $this->request->getGetParam('referer');
if(!is_null($referer))
{
try {
$questgroup = $this->Questgroups->getQuestgroupById($referer);
$this->redirect($this->linker->link(array('questgroups', 'questgroup', $seminary['url'], $questgroup['url'])));
}
catch(IdNotFoundException $e) {
}
}
$this->redirect($this->linker->link(array('seminaries', 'seminary', $seminary['url'])));
}
/**
* Action: delete.
*
* Delete a Questgroupshierarchy.
*
* @throws \nre\exceptions\IdNotFoundException
* @param string $seminaryUrl URL-title of Seminary
* @param string $questgroupshierarchyUrl URL-title of Questgroupshierarchy
*/
public function delete($seminaryUrl, $questgroupshierarchyUrl)
{
// Get seminary
$seminary = $this->Seminaries->getSeminaryByUrl($seminaryUrl);
// Get Questgroupshierarchy
$questgroupshierarchy = $this->Questgroupshierarchy->getHierarchyByUrl($seminary['id'], $questgroupshierarchyUrl);
// Check request method
if($this->request->getRequestMethod() == 'POST')
{
// Check confirmation
if(!is_null($this->request->getPostParam('delete')))
{
// Delete Questgroupshierarchy
$this->Questgroupshierarchy->deleteQuestgroupshierarchy($questgroupshierarchy['id']);
}
// Redirect to Seminary page
$this->redirect($this->linker->link(array('seminaries', 'seminary', $seminary['url'])));
}
// Set titile
$this->addTitleLocalized('Delete Questgroupshierarchy');
// Show confirmation
$this->set('seminary', $seminary);
$this->set('questgroupshierarchy', $questgroupshierarchy);
}
}
namespace hhu\z\controllers;
/**
* Controller of the QuestgroupsAgent to display Questgroups.
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
*/
class QuestgroupshierarchyController extends \hhu\z\controllers\SeminaryController
{
/**
* Required components
*
* @var array
*/
public $components = array('validation');
/**
* Required models
*
* @var array
*/
public $models = array('seminaries', 'questgroupshierarchy', 'questgroups');
/**
* User permissions
*
* @var array
*/
public $permissions = array(
'create' => array('admin', 'moderator', 'user'),
'edit' => array('admin', 'moderator', 'user'),
'moveup' => array('admin', 'moderator', 'user'),
'movedown' => array('admin', 'moderator', 'user'),
'delete' => array('admin', 'moderator', 'user')
);
/**
* User seminary permissions
*
* @var array
*/
public $seminaryPermissions = array(
'create' => array('admin'),
'edit' => array('admin'),
'moveup' => array('admin'),
'movedown' => array('admin'),
'delete' => array('admin')
);
/**
* Action: create.
*
* Create a new Questgroupshierarchy.
*
* @param string $seminaryUrl URL-title of a Seminary
*/
public function create($seminaryUrl)
{
// Get seminary
$seminary = $this->Seminaries->getSeminaryByUrl($seminaryUrl);
// Get parent Questgroupshierarchy
$parentQuestgroupshierarchy = $this->Questgroupshierarchy->getHierarchyOfSeminary($seminary['id']);
// Values
$titleSingular = '';
$titlePlural = '';
$validation = array();
// Create Questgroupshierarchy
if($this->request->getRequestMethod() == 'POST' && !is_null($this->request->getPostParam('create')))
{
// Get params and validate them
$titleSingular = $this->request->getPostParam('title_singular');
$validation = $this->Validation->addValidationResults(
$validation,
'titleSingular',
$this->Validation->validate($titleSingular, \nre\configs\AppConfig::$validation['questgroupshierarchytitle'])
);
if($this->Questgroupshierarchy->questgroupshierarchyTitleSingularExists($titleSingular, $seminary['id'])) {
$validation = $this->Validation->addValidationResult($validation, 'titleSingular', 'exist', true);
}
$titlePlural = $this->request->getPostParam('title_plural');
$validation = $this->Validation->addValidationResults(
$validation,
'titlePlural',
$this->Validation->validate($titlePlural, \nre\configs\AppConfig::$validation['questgroupshierarchytitle'])
);
if($this->Questgroupshierarchy->questgroupshierarchyTitleSingularExists($titlePlural, $seminary['id'])) {
$validation = $this->Validation->addValidationResult($validation, 'titlePlural', 'exist', true);
}
// Validate parent Questgroupshierarchy
$parentQuestgroupshierarchyIndex = null;
foreach($parentQuestgroupshierarchy as $index => &$parentHierarchy)
{
$parentHierarchy['selected'] = ($parentHierarchy['url'] == $this->request->getPostParam('parent'));
if($parentHierarchy['selected']) {
$parentQuestgroupshierarchyIndex = $index;
}
}
// Create new Questgroupshierarchy
if($validation === true)
{
$questgroupshierarchyId = $this->Questgroupshierarchy->createQuestgroupshierarchy(
$this->Auth->getUserId(),
$seminary['id'],
(!is_null($parentQuestgroupshierarchyIndex) ? $parentQuestgroupshierarchy[$parentQuestgroupshierarchyIndex]['id'] : null),
$titleSingular,
$titlePlural
);
$questgroupshierarchy = $this->Questgroupshierarchy->getHierarchyById($questgroupshierarchyId);
// Redirect
$this->redirect($this->linker->link(array('seminaries', 'seminary', $seminary['url'])));
}
}
// Get validation settings
$validationSettings = array(
'title' => \nre\configs\AppConfig::$validation['title']
);
// Set titile
$this->addTitleLocalized('Create Questgroupshierarchy');
$this->addTitle($seminary['title']);
// Pass data to view
$this->set('seminary', $seminary);
$this->set('titleSingular', $titleSingular);
$this->set('titlePlural', $titlePlural);
$this->set('parentQuestgroupshierarchy', $parentQuestgroupshierarchy);
$this->set('validation', $validation);
$this->set('validationSettings', $validationSettings);
}
/**
* Action: edit.
*
* Edit a Questgroupshierarchy.
*
* @throws \nre\exceptions\IdNotFoundException
* @param string $seminaryUrl URL-title of Seminary
* @param string $questgroupshierarchyUrl URL-title of Questgroupshierarchy
*/
public function edit($seminaryUrl, $questgroupshierarchyUrl)
{
// Get seminary
$seminary = $this->Seminaries->getSeminaryByUrl($seminaryUrl);
// Get Questgroupshierarchy
$questgroupshierarchy = $this->Questgroupshierarchy->getHierarchyByUrl($seminary['id'], $questgroupshierarchyUrl);
// Values
$titleSingular = $questgroupshierarchy['title_singular'];
$titlePlural = $questgroupshierarchy['title_plural'];
$validation = array();
// Check request method
if($this->request->getRequestMethod() == 'POST' && !is_null($this->request->getPostParam('edit')))
{
// Get params and validate them
$titleSingular = $this->request->getPostParam('title_singular');
$validation = $this->Validation->addValidationResults(
$validation,
'titleSingular',
$this->Validation->validate($titleSingular, \nre\configs\AppConfig::$validation['questgroupshierarchytitle'])
);
if($this->Questgroupshierarchy->questgroupshierarchyTitleSingularExists($titleSingular, $seminary['id'], $questgroupshierarchy['id'])) {
$validation = $this->Validation->addValidationResult($validation, 'titleSingular', 'exist', true);
}
$titlePlural = $this->request->getPostParam('title_plural');
$validation = $this->Validation->addValidationResults(
$validation,
'titlePlural',
$this->Validation->validate($titlePlural, \nre\configs\AppConfig::$validation['questgroupshierarchytitle'])
);
if($this->Questgroupshierarchy->questgroupshierarchyTitleSingularExists($titlePlural, $seminary['id'], $questgroupshierarchy['id'])) {
$validation = $this->Validation->addValidationResult($validation, 'titlePlural', 'exist', true);
}
// Edit Questgroup
if($validation === true)
{
$this->Questgroupshierarchy->editQuestgroupshierarchy(
$questgroupshierarchy['id'],
$titleSingular,
$titlePlural
);
$questgroupshierarchy = $this->Questgroupshierarchy->getHierarchyById($questgroupshierarchy['id']);
// Redirect to Seminary page
$this->redirect($this->linker->link(array('seminaries', 'seminary', $seminary['url'])));
}
}
// Get validation settings
$validationSettings = array(
'title' => \nre\configs\AppConfig::$validation['title']
);
// Set titile
$this->addTitleLocalized('Edit Questgroupshierarchy');
$this->addTitle($seminary['title']);
// Pass data to view
$this->set('seminary', $seminary);
$this->set('titleSingular', $titleSingular);
$this->set('titlePlural', $titlePlural);
$this->set('validation', $validation);
$this->set('validationSettings', $validationSettings);
}
/**
* Action: moveup.
*
* Move a Questgroupshierarchy up (decrement position).
*
* @throws \nre\exceptions\IdNotFoundException
* @param string $seminaryUrl URL-title of Seminary
* @param string $questgroupshierarchyUrl URL-title of Questgroupshierarchy
*/
public function moveup($seminaryUrl, $questgroupshierarchyUrl)
{
// Get seminary
$seminary = $this->Seminaries->getSeminaryByUrl($seminaryUrl);
// Get Questgroupshierarchy
$questgroupshierarchy = $this->Questgroupshierarchy->getHierarchyByUrl($seminary['id'], $questgroupshierarchyUrl);
// Set position
$this->Questgroupshierarchy->moveQuestgroupshierarchy($questgroupshierarchy, true);
// Redirect
$referer = $this->request->getGetParam('referer');
if(!is_null($referer))
{
try {
$questgroup = $this->Questgroups->getQuestgroupById($referer);
$this->redirect($this->linker->link(array('questgroups', 'questgroup', $seminary['url'], $questgroup['url'])));
}
catch(IdNotFoundException $e) {
}
}
$this->redirect($this->linker->link(array('seminaries', 'seminary', $seminary['url'])));
}
/**
* Action: movedown.
*
* Move a Questgroupshierarchy down (increment position).
*
* @throws \nre\exceptions\IdNotFoundException
* @param string $seminaryUrl URL-title of Seminary
* @param string $questgroupshierarchyUrl URL-title of Questgroupshierarchy
*/
public function movedown($seminaryUrl, $questgroupshierarchyUrl)
{
// Get seminary
$seminary = $this->Seminaries->getSeminaryByUrl($seminaryUrl);
// Get Questgroupshierarchy
$questgroupshierarchy = $this->Questgroupshierarchy->getHierarchyByUrl($seminary['id'], $questgroupshierarchyUrl);
// Set position
$this->Questgroupshierarchy->moveQuestgroupshierarchy($questgroupshierarchy, false);
// Redirect
$referer = $this->request->getGetParam('referer');
if(!is_null($referer))
{
try {
$questgroup = $this->Questgroups->getQuestgroupById($referer);
$this->redirect($this->linker->link(array('questgroups', 'questgroup', $seminary['url'], $questgroup['url'])));
}
catch(IdNotFoundException $e) {
}
}
$this->redirect($this->linker->link(array('seminaries', 'seminary', $seminary['url'])));
}
/**
* Action: delete.
*
* Delete a Questgroupshierarchy.
*
* @throws \nre\exceptions\IdNotFoundException
* @param string $seminaryUrl URL-title of Seminary
* @param string $questgroupshierarchyUrl URL-title of Questgroupshierarchy
*/
public function delete($seminaryUrl, $questgroupshierarchyUrl)
{
// Get seminary
$seminary = $this->Seminaries->getSeminaryByUrl($seminaryUrl);
// Get Questgroupshierarchy
$questgroupshierarchy = $this->Questgroupshierarchy->getHierarchyByUrl($seminary['id'], $questgroupshierarchyUrl);
// Check request method
if($this->request->getRequestMethod() == 'POST')
{
// Check confirmation
if(!is_null($this->request->getPostParam('delete')))
{
// Delete Questgroupshierarchy
$this->Questgroupshierarchy->deleteQuestgroupshierarchy($questgroupshierarchy['id']);
}
// Redirect to Seminary page
$this->redirect($this->linker->link(array('seminaries', 'seminary', $seminary['url'])));
}
// Set titile
$this->addTitleLocalized('Delete Questgroupshierarchy');
// Show confirmation
$this->set('seminary', $seminary);
$this->set('questgroupshierarchy', $questgroupshierarchy);
}
}
?>

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

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

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

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

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

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
*/
namespace hhu\z\controllers;
/**
* Controller of the UploadsAgent to process and show user uploads.
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
*/
class UploadsController extends \hhu\z\controllers\SeminaryController
{
/**
* Required models
*
* @var array
*/
public $models = array('uploads', 'users', 'userroles', 'characterroles', 'seminaries', 'charactergroups');
/**
* User permissions
*
* @var array
*/
public $permissions = array(
'seminary' => array('admin', 'moderator', 'user', 'guest'),
'charactergroup' => array('admin', 'moderator', 'user', 'guest')
);
/**
* User seminary permissions
*
* @var array
*/
public $seminaryPermissions = array(
'seminary' => array('admin', 'moderator', 'user', 'guest'),
'charactergroup' => array('admin', 'moderator', 'user')
);
/**
* Prefilter.
*
* @param \nre\core\Request $request Current request
* @param \nre\core\Response $response Current response
*/
public function preFilter(\nre\core\Request $request, \nre\core\Response $response)
{
parent::preFilter($request, $response);
// Set headers for caching control
$response->addHeader("Pragma: public");
$response->addHeader("Cache-control: public, max-age=".(60*60*24));
$response->addHeader("Expires: ".gmdate('r', time()+(60*60*24)));
$response->addHeader("Date: ".gmdate(\DateTime::RFC822));
}
/**
* Action: seminary.
*
* Display a Seminary upload.
*
* @throws \nre\exceptions\AccessDeniedException
* @throws \nre\exceptions\IdNotFoundException
* @param string $seminaryUrl URL-title of Seminary
* @param string $uploadUrl URL-name of the upload
* @param string $action Current action (optional)
*/
public function seminary($seminaryUrl, $uploadUrl, $action=null)
{
// Get Seminary
$seminary = $this->Seminaries->getSeminaryByUrl($seminaryUrl);
// Get Upload
$upload = $this->Uploads->getSeminaryuploadByUrl($seminary['id'], $uploadUrl);
// Check permissions
if(!$upload['public'])
{
$user = $this->Users->getUserById($this->Auth->getUserId());
$user['roles'] = array_map(function($r) { return $r['name']; }, $this->Userroles->getUserrolesForUserById($user['id']));
// System roles
if(count(array_intersect(array('admin', 'moderator'), $user['roles'])) == 0)
{
// Owner of file
if($upload['created_user_id'] != $user['id'])
{
// Seminary permissions
$characterRoles = array_map(function($r) { return $r['name']; }, $this->Characterroles->getCharacterrolesForCharacterById($character['id']));
if(count(array_intersect(array('admin', 'moderator'), $characterRoles)) == 0) {
throw new \nre\exceptions\AccessDeniedException();
}
}
}
}
// Get file
switch($action)
{
case null:
$file = $this->getUploadFile($upload);
break;
case 'thumbnail':
$file = $this->createThumbnail($upload);
break;
default:
throw new \nre\exceptions\ParamsNotValidException($action);
break;
}
if(is_null($file)) {
return;
}
// Pass data to view
$this->set('upload', $upload);
$this->set('file', $file);
}
/**
* Action: charactergroup.
*
* Display the icon of a Character group.
*
* @throws \nre\exceptions\IdNotFoundException
* @param string $seminaryUrl URL-Title of a Seminary
* @param string $groupsgroupUrl URL-Title of a Character groups-group
* @param string $groupUrl URL-Title of a Character group
*/
public function charactergroup($seminaryUrl, $groupsgroupUrl, $groupUrl)
{
// Get seminary
$seminary = $this->Seminaries->getSeminaryByUrl($seminaryUrl);
// Get Character groups-group
$groupsgroup = $this->Charactergroups->getGroupsgroupByUrl($seminary['id'], $groupsgroupUrl);
// Get Character group
$group = $this->Charactergroups->getGroupByUrl($groupsgroup['id'], $groupUrl);
// Get Upload
$upload = $this->Uploads->getSeminaryuploadById($group['seminaryupload_id']);
// Get file
$file = $this->getUploadFile($upload);
if(is_null($file)) {
return;
}
// Pass data to view
$this->set('upload', $upload);
$this->set('file', $file);
}
/**
* Determine the file for an upload.
*
* @throws \nre\exceptions\IdNotFoundException
* @param array $upload Upload to get file for
* @return object File for the upload (or null if upload is cached)
*/
private function getUploadFile($upload)
{
// Set content-type
$this->response->addHeader("Content-type: ".$upload['mimetype']."");
// Set filename
$upload['filename'] = ROOT.DS.\nre\configs\AppConfig::$dirs['seminaryuploads'].DS.$upload['url'];
if(!file_exists($upload['filename'])) {
throw new \nre\exceptions\IdNotFoundException($uploadUrl);
}
// Cache
if($this->setCacheHeaders($upload['filename'])) {
return null;
}
return file_get_contents($upload['filename']);
}
/**
* Create a thumbnail from an upload.
*
* @param array $upload Upload to create thumbnail for
* @return object Thumbnail for the upload (or null if thumbnail is cached)
*/
private function createThumbnail($upload)
{
// Set filename
$upload['filename'] = ROOT.DS.\nre\configs\AppConfig::$dirs['seminaryuploads'].DS.$upload['url'];
// Set content-type
$this->response->addHeader("Content-type: image/jpeg");
/**
* The Legend of Z
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
* @license http://www.gnu.org/licenses/gpl.html
* @link https://bitbucket.org/coderkun/the-legend-of-z
*/
// Check file
if(!file_exists($upload['filename'])) {
throw new \nre\exceptions\IdNotFoundException($upload['url']);
}
// Cache
if($this->setCacheHeaders($upload['filename'])) {
return null;
}
// Set geometry
$width = 100;
$height = 100;
switch($upload['mimetype'])
{
case 'image/jpeg':
case 'image/png':
// Read image from cache
$tempFileName = ROOT.DS.\nre\configs\AppConfig::$dirs['temporary'].DS.$upload['url'].'-'.$width.'x'.$height;
if(file_exists($tempFileName))
{
// Check age of file
if(date('r', filemtime($tempFileName)+(60*60*24)) > date('r', time())) {
// Too old, delete
unlink($tempFileName);
}
else {
// Valid, read and return
return file_get_contents($tempFileName);
}
}
// ImageMagick
$im = new \Imagick($upload['filename']);
// Calculate new size
$geometry = $im->getImageGeometry();
if($geometry['width'] < $width) {
$width = $geometry['width'];
}
if($geometry['height'] < $height) {
$height = $geometry['width'];
}
// Process
$im->thumbnailImage($width, $height, true);
$im->contrastImage(1);
$im->setImageFormat('jpeg');
// Save temporary file
$im->writeImage($tempFileName);
// Return resized image
return $im;
break;
default:
throw new \nre\exceptions\ParamsNotValidException('thumbnail');
break;
}
return $this->getUploadFile($upload);
}
/**
* Determine file information and set the HTTP-header for
* caching accordingly.
*
* @param string $fileName Filename
* @return boolean HTTP-status 304 was set (in cache)
*/
private function setCacheHeaders($fileName)
{
// Determine last change of file
$fileLastModified = gmdate('r', filemtime($fileName));
// Generate E-Tag
$fileEtag = hash('sha256', $fileLastModified.$fileName);
// Set header
$this->response->addHeader("Last-Modified: ".$fileLastModified);
$this->response->addHeader("Etag: ".$fileEtag);
// HTTP-status
$headerModifiedSince = $this->request->getServerParam('HTTP_IF_MODIFIED_SINCE');
$headerNoneMatch = $this->request->getServerParam('HTTP_IF_NONE_MATCH');
if(
!is_null($headerModifiedSince) && $fileLastModified < strtotime($headerModifiedSince) &&
!is_null($headerNoneMatch) && $headerNoneMatch == $fileEtag
) {
$this->response->setExit(true);
$this->response->addHeader(\nre\core\WebUtils::getHttpHeader(304));
return true;
}
return false;
}
}
namespace hhu\z\controllers;
/**
* Controller of the UploadsAgent to process and show user uploads.
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
*/
class UploadsController extends \hhu\z\controllers\SeminaryController
{
/**
* Required models
*
* @var array
*/
public $models = array('uploads', 'users', 'userroles', 'characterroles', 'seminaries', 'charactergroups');
/**
* User permissions
*
* @var array
*/
public $permissions = array(
'seminary' => array('admin', 'moderator', 'user', 'guest'),
'charactergroup' => array('admin', 'moderator', 'user', 'guest')
);
/**
* User seminary permissions
*
* @var array
*/
public $seminaryPermissions = array(
'seminary' => array('admin', 'moderator', 'user', 'guest'),
'charactergroup' => array('admin', 'moderator', 'user')
);
/**
* Prefilter.
*
* @param \nre\core\Request $request Current request
* @param \nre\core\Response $response Current response
*/
public function preFilter(\nre\core\Request $request, \nre\core\Response $response)
{
parent::preFilter($request, $response);
// Set headers for caching control
$response->addHeader("Pragma: public");
$response->addHeader("Cache-control: public, max-age=".(60*60*24));
$response->addHeader("Expires: ".gmdate('r', time()+(60*60*24)));
$response->addHeader("Date: ".gmdate(\DateTime::RFC822));
}
/**
* Action: seminary.
*
* Display a Seminary upload.
*
* @throws \nre\exceptions\AccessDeniedException
* @throws \nre\exceptions\IdNotFoundException
* @param string $seminaryUrl URL-title of Seminary
* @param string $uploadUrl URL-name of the upload
* @param string $action Current action (optional)
*/
public function seminary($seminaryUrl, $uploadUrl, $action=null)
{
// Get Seminary
$seminary = $this->Seminaries->getSeminaryByUrl($seminaryUrl);
// Get Upload
$upload = $this->Uploads->getSeminaryuploadByUrl($seminary['id'], $uploadUrl);
// Check permissions
if(!$upload['public'])
{
$user = $this->Users->getUserById($this->Auth->getUserId());
$user['roles'] = array_map(function($r) { return $r['name']; }, $this->Userroles->getUserrolesForUserById($user['id']));
// System roles
if(count(array_intersect(array('admin', 'moderator'), $user['roles'])) == 0)
{
// Owner of file
if($upload['created_user_id'] != $user['id'])
{
// Seminary permissions
$characterRoles = array_map(function($r) { return $r['name']; }, $this->Characterroles->getCharacterrolesForCharacterById($character['id']));
if(count(array_intersect(array('admin', 'moderator'), $characterRoles)) == 0) {
throw new \nre\exceptions\AccessDeniedException();
}
}
}
}
// Get file
switch($action)
{
case null:
$file = $this->getUploadFile($upload);
break;
case 'thumbnail':
$file = $this->createThumbnail($upload);
break;
default:
throw new \nre\exceptions\ParamsNotValidException($action);
break;
}
if(is_null($file)) {
return;
}
// Pass data to view
$this->set('upload', $upload);
$this->set('file', $file);
}
/**
* Action: charactergroup.
*
* Display the icon of a Character group.
*
* @throws \nre\exceptions\IdNotFoundException
* @param string $seminaryUrl URL-Title of a Seminary
* @param string $groupsgroupUrl URL-Title of a Character groups-group
* @param string $groupUrl URL-Title of a Character group
*/
public function charactergroup($seminaryUrl, $groupsgroupUrl, $groupUrl)
{
// Get seminary
$seminary = $this->Seminaries->getSeminaryByUrl($seminaryUrl);
// Get Character groups-group
$groupsgroup = $this->Charactergroups->getGroupsgroupByUrl($seminary['id'], $groupsgroupUrl);
// Get Character group
$group = $this->Charactergroups->getGroupByUrl($groupsgroup['id'], $groupUrl);
// Get Upload
$upload = $this->Uploads->getSeminaryuploadById($group['seminaryupload_id']);
// Get file
$file = $this->getUploadFile($upload);
if(is_null($file)) {
return;
}
// Pass data to view
$this->set('upload', $upload);
$this->set('file', $file);
}
/**
* Determine the file for an upload.
*
* @throws \nre\exceptions\IdNotFoundException
* @param array $upload Upload to get file for
* @return object File for the upload (or null if upload is cached)
*/
private function getUploadFile($upload)
{
// Set content-type
$this->response->addHeader("Content-type: ".$upload['mimetype']."");
// Set filename
$upload['filename'] = ROOT.DS.\nre\configs\AppConfig::$dirs['seminaryuploads'].DS.$upload['url'];
if(!file_exists($upload['filename'])) {
throw new \nre\exceptions\IdNotFoundException($uploadUrl);
}
// Cache
if($this->setCacheHeaders($upload['filename'])) {
return null;
}
return file_get_contents($upload['filename']);
}
/**
* Create a thumbnail from an upload.
*
* @param array $upload Upload to create thumbnail for
* @return object Thumbnail for the upload (or null if thumbnail is cached)
*/
private function createThumbnail($upload)
{
// Set filename
$upload['filename'] = ROOT.DS.\nre\configs\AppConfig::$dirs['seminaryuploads'].DS.$upload['url'];
// Set content-type
$this->response->addHeader("Content-type: image/jpeg");
// Check file
if(!file_exists($upload['filename'])) {
throw new \nre\exceptions\IdNotFoundException($upload['url']);
}
// Cache
if($this->setCacheHeaders($upload['filename'])) {
return null;
}
// Set geometry
$width = 100;
$height = 100;
switch($upload['mimetype'])
{
case 'image/jpeg':
case 'image/png':
// Read image from cache
$tempFileName = ROOT.DS.\nre\configs\AppConfig::$dirs['temporary'].DS.$upload['url'].'-'.$width.'x'.$height;
if(file_exists($tempFileName))
{
// Check age of file
if(date('r', filemtime($tempFileName)+(60*60*24)) > date('r', time())) {
// Too old, delete
unlink($tempFileName);
}
else {
// Valid, read and return
return file_get_contents($tempFileName);
}
}
// ImageMagick
$im = new \Imagick($upload['filename']);
// Calculate new size
$geometry = $im->getImageGeometry();
if($geometry['width'] < $width) {
$width = $geometry['width'];
}
if($geometry['height'] < $height) {
$height = $geometry['width'];
}
// Process
$im->thumbnailImage($width, $height, true);
$im->contrastImage(1);
$im->setImageFormat('jpeg');
// Save temporary file
$im->writeImage($tempFileName);
// Return resized image
return $im;
break;
default:
throw new \nre\exceptions\ParamsNotValidException('thumbnail');
break;
}
return $this->getUploadFile($upload);
}
/**
* Determine file information and set the HTTP-header for
* caching accordingly.
*
* @param string $fileName Filename
* @return boolean HTTP-status 304 was set (in cache)
*/
private function setCacheHeaders($fileName)
{
// Determine last change of file
$fileLastModified = gmdate('r', filemtime($fileName));
// Generate E-Tag
$fileEtag = hash('sha256', $fileLastModified.$fileName);
// Set header
$this->response->addHeader("Last-Modified: ".$fileLastModified);
$this->response->addHeader("Etag: ".$fileEtag);
// HTTP-status
$headerModifiedSince = $this->request->getServerParam('HTTP_IF_MODIFIED_SINCE');
$headerNoneMatch = $this->request->getServerParam('HTTP_IF_NONE_MATCH');
if(
!is_null($headerModifiedSince) && $fileLastModified < strtotime($headerModifiedSince) &&
!is_null($headerNoneMatch) && $headerNoneMatch == $fileEtag
) {
$this->response->setExit(true);
$this->response->addHeader(\nre\core\WebUtils::getHttpHeader(304));
return true;
}
return false;
}
}
?>

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

File diff suppressed because it is too large Load diff

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

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

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

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

View file

@ -3,25 +3,25 @@
/**
* The Legend of Z
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
* @license http://www.gnu.org/licenses/gpl.html
* @link https://bitbucket.org/coderkun/the-legend-of-z
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
* @license http://www.gnu.org/licenses/gpl.html
* @link https://bitbucket.org/coderkun/the-legend-of-z
*/
namespace hhu\z\controllers\components;
/**
* Component to handle data for Questtypes between different Quest states.
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
*/
class QuesttypedataComponent extends \nre\core\Component
{
/**
* Session key
*
*
* @var string
*/
const SESSION_KEY = 'questtypes';
@ -45,7 +45,7 @@
/**
* Set data with a key-value pair.
*
*
* @param int $questId ID of Quest to set data for
* @param mixed $key Key
* @param mixed $value Value
@ -64,7 +64,7 @@
/**
* Get data by a key.
*
*
* @param int $questId ID of Quest to set data for
* @param mixed $key Key
* @return mixed Value
@ -86,4 +86,4 @@
}
?>
?>

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

File diff suppressed because it is too large Load diff

View file

@ -1,182 +1,182 @@
<?php
/**
* The Legend of Z
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
* @license http://www.gnu.org/licenses/gpl.html
* @link https://bitbucket.org/coderkun/the-legend-of-z
*/
namespace hhu\z\models;
/**
* Model to interact with Avatars-tables.
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
*/
class AvatarsModel extends \hhu\z\Model
{
/**
* Required models
*
* @var array
*/
public $models = array('media');
/**
* Construct a new AvatarsModel.
*/
public function __construct()
{
parent::__construct();
}
/**
* Get an Avatar by its ID
*
* @param int $avatarId ID of Avatar
* @return array Avatar data
*/
public function getAvatarById($avatarId)
{
$data = $this->db->query(
'SELECT id, charactertype_id, xplevel_id, avatarpicture_id, small_avatarpicture_id '.
'FROM avatars '.
'WHERE id = ?',
'i',
$avatarId
);
if(!empty($data)) {
return $data[0];
}
return null;
}
/**
* Get an Avatar by its Character type and XP-level.
*
* @param int $seminaryId ID of Seminary
* @param string $charactertypeUrl URL-title of Character type
* @param int $xplevel XP-level
* @return array Avatar data
*/
public function getAvatarByTypeAndLevel($seminaryId, $charactertypeUrl, $xplevel)
{
$data = $this->db->query(
'SELECT avatars.id, charactertype_id, xplevel_id, avatarpicture_id, small_avatarpicture_id '.
'FROM avatars '.
'INNER JOIN charactertypes ON charactertypes.id = avatars.charactertype_id '.
'INNER JOIN xplevels ON xplevels.id = avatars.xplevel_id AND xplevels.seminary_id = charactertypes.seminary_id '.
'WHERE charactertypes.seminary_id = ? AND charactertypes.url = ? AND xplevels.level = ?',
'isi',
$seminaryId,
$charactertypeUrl,
$xplevel
);
if(empty($data)) {
throw new \nre\exceptions\IdNotFoundException($charactertypeUrl);
}
return $data[0];
}
/**
* 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;
/**
* 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];
}
/**
* 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');
/**
* 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
);
}
/**
* Construct a new AvatarsModel.
*/
public function __construct()
{
parent::__construct();
}
/**
* Get an Avatar by its ID
*
* @param int $avatarId ID of Avatar
* @return array Avatar data
*/
public function getAvatarById($avatarId)
{
$data = $this->db->query(
'SELECT id, charactertype_id, xplevel_id, avatarpicture_id, small_avatarpicture_id '.
'FROM avatars '.
'WHERE id = ?',
'i',
$avatarId
);
if(!empty($data)) {
return $data[0];
}
return null;
}
/**
* Get an Avatar by its Character type and XP-level.
*
* @param int $seminaryId ID of Seminary
* @param string $charactertypeUrl URL-title of Character type
* @param int $xplevel XP-level
* @return array Avatar data
*/
public function getAvatarByTypeAndLevel($seminaryId, $charactertypeUrl, $xplevel)
{
$data = $this->db->query(
'SELECT avatars.id, charactertype_id, xplevel_id, avatarpicture_id, small_avatarpicture_id '.
'FROM avatars '.
'INNER JOIN charactertypes ON charactertypes.id = avatars.charactertype_id '.
'INNER JOIN xplevels ON xplevels.id = avatars.xplevel_id AND xplevels.seminary_id = charactertypes.seminary_id '.
'WHERE charactertypes.seminary_id = ? AND charactertypes.url = ? AND xplevels.level = ?',
'isi',
$seminaryId,
$charactertypeUrl,
$xplevel
);
if(empty($data)) {
throw new \nre\exceptions\IdNotFoundException($charactertypeUrl);
}
return $data[0];
}
/**
* Get an Avatar by its Character type and XP-level.
*
* @param int $charactertypeId ID of Character type
* @param int $xplevelId ID of XP-level
* @return array Avatar data
*/
public function getAvatarByTypeAndLevelId($charactertypeId, $xplevelId)
{
$data = $this->db->query(
'SELECT id, charactertype_id, xplevel_id, avatarpicture_id, small_avatarpicture_id '.
'FROM avatars '.
'WHERE charactertype_id = ? AND xplevel_id = ?',
'ii',
$charactertypeId,
$xplevelId
);
if(empty($data)) {
throw new \nre\exceptions\IdNotFoundException($charactertypeId.'-'.$xplevelId);
}
return $data[0];
}
/**
* Set the picture for an Avatar.
*
* @param int $userId ID of creating user
* @param int $charactertypeId ID of Charactertype of Avatar
* @param int $xplevelId ID of XP-level of Avatar
* @param int $avatarpictureId ID of Avatar picture to set
*/
public function setAvatarForTypeAndLevel($userId, $charactertypeId, $xplevelId, $avatarpictureId)
{
$this->db->query(
'INSERT INTO avatars '.
'(created_user_id, charactertype_id, xplevel_id, avatarpicture_id) '.
'VALUES '.
'(?, ?, ?, ?) '.
'ON DUPLICATE KEY UPDATE '.
'avatarpicture_id = ?',
'iiiii',
$userId,
$charactertypeId,
$xplevelId,
$avatarpictureId,
$avatarpictureId
);
}
/**
* Set the portrait picture for an Avatar.
*
* @param int $userId ID of creating user
* @param int $charactertypeId ID of Charactertype of Avatar
* @param int $xplevelId ID of XP-level of Avatar
* @param int $avatarpictureId ID of Avatar portrait picture to set
*/
public function setAvatarPortraitForTypeAndLevel($userId, $charactertypeId, $xplevelId, $avatarpictureId)
{
$this->db->query(
'INSERT INTO avatars '.
'(created_user_id, charactertype_id, xplevel_id, small_avatarpicture_id) '.
'VALUES '.
'(?, ?, ?, ?) '.
'ON DUPLICATE KEY UPDATE '.
'small_avatarpicture_id = ?',
'iiiii',
$userId,
$charactertypeId,
$xplevelId,
$avatarpictureId,
$avatarpictureId
);
}
/**
* Copy all Avatars from a Seminary.
*
*
* @param int $userId ID of copying user
* @param array $charactertypeIds Mapping of Charactertype-IDs from source Seminary to target Seminary
* @param array $xplevelIds Mapping of XP-level-IDs from source Seminary to targetSeminary
@ -217,7 +217,7 @@
}
}
}
}
}
?>

File diff suppressed because it is too large Load diff

View file

@ -1,383 +1,383 @@
<?php
/**
* The Legend of Z
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
* @license http://www.gnu.org/licenses/gpl.html
* @link https://bitbucket.org/coderkun/the-legend-of-z
*/
namespace hhu\z\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');
/**
* 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 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];
}
/**
* 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];
}
/**
* 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;
}
/**
* 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);
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
);
}
/**
* 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)
);
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
);
}
/**
* 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
);
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
);
}
/**
* 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();
}
/**
* 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
);
}
/**
* 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;
/**
* 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();
}
/**
* 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);
}
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);
}
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);
}
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;
}
$data = $data[0];
$data['xps'] = round($data['xps'] * $data['xps_factor'], 1);
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
);
}
/**
* 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)
);
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
);
}
/**
* 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
);
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
);
}
/**
* 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();
}
/**
* 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
);
}
/**
* Copy all Character groups Quests from a Seminary.
*
*
* @param int $userId ID of copying user
* @param array $groupsgroupIds Mapping of Character groups-group-IDs from source Seminary to target Seminary
* @param array $questgroupIds Mapping of Questgroup-IDs from source Seminary to target Seminary
@ -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