add basic Users- and SeminariesAgent

This commit is contained in:
coderkun 2014-01-17 16:26:49 +01:00
commit 150aa2d1b5
13 changed files with 470 additions and 5 deletions

View file

@ -0,0 +1,75 @@
<?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 list registered seminaries.
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
*/
class SeminariesController extends \hhu\z\Controller
{
/**
* Required models
*
* @var array
*/
public $models = array('seminaries', 'users');
/**
* Action: index.
*
* List registered seminaries.
*/
public function index()
{
// Get seminaries
$seminaries = $this->Seminaries->getSeminaries();
// Get additional data
foreach($seminaries as &$seminary)
{
// Created user
$seminary['creator'] = $this->Users->getUserById($seminary['created_user_id']);
}
// Pass data to view
$this->set('seminaries', $seminaries);
}
/**
* Action: seminary.
*
* Show a seminary and its details.
*
* @throws IdNotFoundException
* @param string $seminaryUrl URL-Title of a seminary
*/
public function seminary($seminaryUrl)
{
// Get seminary
$seminary = $this->Seminaries->getSeminaryByUrl($seminaryUrl);
// Pass data to view
$this->set('seminary', $seminary);
}
}
?>

View file

@ -0,0 +1,61 @@
<?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 list registered users and their data.
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
*/
class UsersController extends \hhu\z\Controller
{
/**
* Action: index.
*/
public function index()
{
// Get registered users
$users = $this->Users->getUsers();
// Pass data to view
$this->set('users', $users);
}
/**
* Action: user.
*
* Show a user and its details.
*
* @throws IdNotFoundException
* @param string $userUrl URL-Username of an user
*/
public function user($userUrl)
{
// Get user
$user = $this->Users->getUserByUrl($userUrl);
// Pass data to view
$this->set('user', $user);
}
}
?>