vaktliste - first commit

This commit is contained in:
h-alstad committed 2010-07-09 21:39:07 +02:00
1 parent 1c189d84fa
commit 5836bc0341
57 files changed
+3340

No files matched your search

@@ -0,0 +1,73 @@
<?php
class App_Base_ApplicationRegistry extends App_Base_Registry {
private static $instance;
//private $freezedir = "data";
private $values = array();
//private $mtimes = array();
private function __construct() {}
static function instance() {
if (!isset(self::$instance)) {
self::$instance = new self();
}
return self::$instance;
}
protected function get($key) {
// more get logic here ...
if (isset($this->values[$key])) {
return $this->values[$key];
}
return null;
}
protected function set($key, $val) {
$this->values[$key] = $val;
// storage ...
return $this->values[$key];
}
static function getDSN() {
return self::instance()->get('dsn');
}
static function setDSN( $dsn ) {
return self::instance()->set('dsn', $dsn);
}
static function getControllerMap() {
return self::instance()->get('controllerMap');
}
static function setControllerMap(App_Controller_ControllerMap $map ) {
return self::instance()->set('controllerMap', $map);
}
static function getApplicationController() {
return self::instance()->get('applicationController');
}
static function setApplicationController(App_Controller_AppController $appCtrl) {
return self::instance()->set('applicationController', $appCtrl);
}
static function getAccessManager() {
return self::instance()->get('accessManager');
}
static function setAccessManager(App_Controller_AccessManager $manager) {
return self::instance()->set('accessManager', $manager);
}
static function getPageTitle() {
return self::instance()->get('pagetitle');
}
static function setPageTitle( $pagetitle ) {
return self::instance()->set('pagetitle', $pagetitle);
}
}
+8
View File
@@ -0,0 +1,8 @@
<?php
abstract class App_Base_Registry {
abstract protected function get($key);
abstract protected function set($key, $val);
}
?>
+40
View File
@@ -0,0 +1,40 @@
<?php
/**
* Request registry class
*
*/
class App_Base_RequestRegistry extends App_Base_Registry {
private $values = array();
private static $instance;
private function __construct() {}
static function instance() {
if (!isset(self::$instance)) {
self::$instance = new self();
}
return self::$instance;
}
protected function get($key) {
if (isset($this->values[$key])) {
return $this->values[$key];
}
return null;
}
protected function set($key, $value) {
$this->values[$key] = $value;
}
static function getRequest() {
return self::instance()->get('request');
}
static function setRequest(App_Controller_Request $request) {
return self::instance()->set('request', $request);
}
}
?>
+56
View File
@@ -0,0 +1,56 @@
<?php
/**
* Session registry
*
*/
class App_Base_SessionRegistry extends App_Base_Registry {
private static $instance;
private function __construct() {
session_start();
}
static function instance() {
if (!isset(self::$instance)) {
self::$instance = new self();
}
return self::$instance;
}
protected function get($key) {
if (isset($_SESSION[__CLASS__][$key])) {
return $_SESSION[__CLASS__][$key];
}
return null;
}
protected function set($key, $val) {
$_SESSION[__CLASS__][$key] = $val;
}
static function getUserId() {
if (!is_null(self::instance()->get('userid'))) {
//return self::instance()->get('userid');
}
// check session from old inside
if (isset($_SESSION['valid-user'])) {
self::instance()->set('userid', $_SESSION['valid-user']);
}
return self::instance()->get('userid');
}
static function setUserId($userid) {
if (is_null($userid)) {
unset($_SESSION['valid-user']);
self::instance()->set('userid', null);
} else {
// update old inside as well
$_SESSION['valid-user'] = $userid;
self::instance()->set('userid', $userid);
}
}
}
?>
+42
View File
@@ -0,0 +1,42 @@
<?php
/**
* Add shift command class
*/
class App_Command_AddShift extends App_Command_Command {
function doExecute(App_Controller_Request $request) {
$title = $request->getProperty("title");
$starts = $request->getProperty("starts");
$ends = $request->getProperty("ends");
$numworkers = $request->getProperty("numworkers");
$location = $request->getProperty("location");
$group = 97; // CNS bar
$salaryType = 3; // CNS bar
if (empty($title)) {
$request->addFeedback("Tittel må oppgis.");
return self::statuses('CMD_INSUFFICIENT_DATA');
}
if (empty($starts)) {
$request->addFeedback("Starttid må oppgis.");
return self::statuses('CMD_INSUFFICIENT_DATA');
}
if (empty($ends)) {
$request->addFeedback("Sluttid må oppgis.");
return self::statuses('CMD_INSUFFICIENT_DATA');
}
if (empty($numworkers)) {
$request->addFeedback("Antall må oppgis.");
return self::statuses('CMD_INSUFFICIENT_DATA');
}
return self::statuses('CMD_OK');
}
}
?>
+41
View File
@@ -0,0 +1,41 @@
<?php
abstract class App_Command_Command {
private static $STATUS_STRINGS = array (
'CMD_DEFAULT' => 0,
'CMD_OK' => 1,
'CMD_ERROR' => 2,
'CMD_INSUFFICIENT_DATA' => 3
);
private $status = 0;
//private $currentUser = null;
final function __construct() {}
function execute(App_Controller_Request $request) {
// check if visitor is logged in
//$this->currentUser = App_Base_SessionRegistry::getCurrentUser();
// execute command
$this->status = $this->doExecute($request);
$request->setCommand($this);
}
function getStatus() {
return $this->status;
}
static function statuses ($str = 'CMD_DEFAULT') {
if (empty($str)) $str = 'CMD_DEFAULT';
// convert string into a status number
return self::$STATUS_STRINGS[$str];
}
//abstract protected function validate(App_Controller_Request $request);
abstract function doExecute(App_Controller_Request $request);
}
?>
+12
View File
@@ -0,0 +1,12 @@
<?php
class App_Command_CommandHelper {
static function getCurrentUser() {
if (!is_null(App_Base_SessionRegistry::getUserId())) {
return App_Domain_DomainObject::getFinder("App_Domain_User")->find(App_Base_SessionRegistry::getUserId());
}
return null;
}
}
?>
+24
View File
@@ -0,0 +1,24 @@
<?php
/**
* Default command class is used if no command class is found
*/
class App_Command_DefaultCommand extends App_Command_Command {
//protected function validate(App_Controller_Request $request) {
//}
function doExecute(App_Controller_Request $request) {
// check if user is logged in
$user = App_Command_CommandHelper::getCurrentUser();
if (!is_null($user)) {
$request->setObject('currentUser', $user);
return self::statuses('CMD_OK');
}
// if ($request->getProperty("p") == "login") {
// $request->addFeedback( "you are logged in" );
// return self::statuses('CMD_OK');
// }
return self::statuses('CMD_DEFAULT');
}
}
+27
View File
@@ -0,0 +1,27 @@
<?php
/**
* Default command class is used if no command class is found
*/
class App_Command_Login extends App_Command_Command {
function doExecute(App_Controller_Request $request) {
$username = $request->getProperty("username");
$password = $request->getProperty("password");
if (empty($username) || empty($password)) {
$request->addFeedback("Både brukernavn og passord må oppgis.");
return self::statuses('CMD_INSUFFICIENT_DATA');
}
$manager = App_Base_ApplicationRegistry::getAccessManager();
$user = $manager->login($username, $password);
if (is_null($user)) {
$request->addFeedback("Ugyldig brukernavn eller passord.");
return self::statuses('CMD_ERROR');
}
App_Base_SessionRegistry::setUserId($user->getId());
return self::statuses('CMD_OK');
}
}
?>
+15
View File
@@ -0,0 +1,15 @@
<?php
/**
* Default command class is used if no command class is found
*/
class App_Command_Logout extends App_Command_Command {
function doExecute(App_Controller_Request $request) {
$request->addFeedback("Du er logget ut");
App_Base_SessionRegistry::setUserId(null);
return self::statuses('CMD_DEFAULT');
}
}
?>
@@ -0,0 +1,35 @@
<?php
/**
* Manage user access to commands and handle login
*/
class App_Controller_AccessManager {
private $error;
function getError() {
return $this->error;
}
function setError($msg) {
$this->error = $msg;
}
function login($username, $password) {
return App_Domain_DomainObject::getFinder(App_Domain_HelperFactory::USER)->findByLogin($username, $password);
}
function logout() {
if (!is_null(App_Base_SessionRegistry::getUserId())) {
// do something, i.e. logging ?
}
return true;
}
function getCommandAccess($cmd) {
if (!is_null(App_Base_SessionRegistry::getUserId())) {
return true;
}
return false;
}
}
+116
View File
@@ -0,0 +1,116 @@
<?php
class App_Controller_AppController {
private static $base_cmd;
private static $default_cmd;
private $controllerMap;
private $invoked = array();
function __construct(App_Controller_ControllerMap $map) {
$this->controllerMap = $map;
if (!self::$base_cmd) {
self::$base_cmd = new ReflectionClass("App_Command_Command");
self::$default_cmd = new App_Command_DefaultCommand();
}
}
function getView(App_Controller_Request $request) {
$view = $this->getResource($request, "View");
return $view;
}
function getForward(App_Controller_Request $request) {
$forward = $this->getResource($request, "Forward");
if ($forward) {
$request->setProperty("cmd", $forward);
}
return $forward;
}
private function getResource(App_Controller_Request $request, $res) {
// get the previous command and its execution status
$cmd_str = $request->getProperty("cmd");
$previous = $request->getLastCommand();
$status = $previous->getStatus();
if (!$status) {
$status = 0;
}
$acquire = "get$res";
// find resource for previous command and its status
$resource = $this->controllerMap->$acquire($cmd_str, $status);
// alternatively find resource for command and status 0
if (!$resource) {
$resource = $this->controllerMap->$acquire($cmd_str, 0);
}
// or command 'default' and command status
if (!$resource) {
$resource = $this->controllerMap->$acquire('default', $status);
}
// all else has failed get resource for 'default', status 0
if (!$resource) {
$resource = $this->controllerMap->$acquire('default', 0);
}
return $resource;
}
function getCommand(App_Controller_Request $request) {
$previous = $request->getLastCommand();
if (!$previous) {
// this is first command for this request
$cmd = $request->getProperty("cmd");
if (!$cmd) {
// no command property - using default
$request->setProperty("cmd", "default");
return self::$default_cmd;
}
} else {
// a command has been run already in this request
$cmd = $this->getForward($request);
if (!$cmd) {
return null;
}
}
// we now have a command name in $cmd - turn it into a Command object
$cmd_obj = $this->resolveCommand($cmd);
if (!$cmd_obj) {
throw new Exception("Couldn't resolve '$cmd'");
}
// Count the number of times the class has been accessed and check for circular forwarding
$cmd_class = get_class($cmd_obj);
if (isset($this->invoked[$cmd_class])) {
$this->invoked[$cmd_class]++;
} else {
$this->invoked[$cmd_class] = 1;
}
if ($this->invoked[$cmd_class] > 1) {
throw new Exception("Circular forwarding");
}
// return the Command object
return $cmd_obj;
}
function resolveCommand($cmd) {
$sep = "/";
$cmd = str_replace(array(".", $sep), "", $cmd);
$classroot = $this->controllerMap->getClassroot($cmd);
$filepath = "App{$sep}Command{$sep}{$classroot}.php";
$classname = "App_Command_{$classroot}";
if (file_exists($filepath)) {
@require_once("$filepath");
if (class_exists($classname)) {
$cmd_class = new ReflectionClass($classname);
if ($cmd_class->isSubClassOf( self::$base_cmd )) {
return $cmd_class->newInstance();
}
}
}
return null;
}
}
?>
@@ -0,0 +1,110 @@
<?php
class App_Controller_ApplicationHelper {
private static $instance;
//private $config = "options.xml";
private function __construct() {}
static function instance() {
if (!self::$instance) {
self::$instance = new self;
}
return self::$instance;
}
function init() {
$dsn = App_Base_ApplicationRegistry::getDSN();
if (!is_null($dsn)) {
return;
}
$this->getOptions();
App_Base_SessionRegistry::instance();
}
private function getOptions() {
// $this->ensure( file_exists( $this->config ), "Could not find options file" );
// $options = @SimpleXml_load_file( $this->config );
// $this->ensure( $options instanceof SimpleXMLElement, "Could not resolve options file" );
// $dsn = (string)$options->dsn;
include("../inside/credentials.php");
$dsn = getDSN("PDO");
$this->ensure($dsn, "No DSN found");
App_Base_ApplicationRegistry::setDSN($dsn);
$map = new App_Controller_ControllerMap();
//foreach ($options->control->view as $default_view) {
// $stat_str = trim($default_view['status']);
// $status = App_Command_Command::statuses($stat_str);
// $map->addView('default', $status, (string)$default_view);
//}
//foreach ( $options->control->command as $command_view ) {
// $command = trim((string)$command_view['name'] );
// if ( $command_view->classalias ) {
// $classroot = trim((string)$command_view->classalias['name']);
// $map->addClassroot( $command, $classroot );
// }
// if ( $command_view->view ) {
// $view = trim((string)$command_view->view);
// $forward = trim((string)$command_view->forward);
// $map->addView( $command, 0, $view );
// if ( $forward ) {
// $map->addForward( $command, 0, $forward );
// }
// foreach( $command_view->status as $command_view_status ) {
// $view = trim((string)$command_view_status->view);
// $forward = trim((string)$command_view_status->forward);
// $stat_str = trim($command_view_status['value']);
// $status = App_Command_Command::statuses( $stat_str );
// if ( $view ) {
// $map->addView( $command, $status, $view );
// }
// if ( $forward ) {
// $map->addForward( $command, $status, $forward );
// }
// }
// }
//}
// Default view
$status = App_Command_Command::statuses();
$map->addView("default", $status, "login");
$status = App_Command_Command::statuses("CMD_OK");
$map->addView("default", $status, "calendar");
$status = App_Command_Command::statuses("CMD_ERROR");
$map->addView("default", $status, "error");
$map->addClassroot("login", "Login");
$status = App_Command_Command::statuses();
$map->addView("login", $status, "login");
$status = App_Command_Command::statuses("CMD_OK");
$map->addView("login", $status, "calendar");
$map->addClassroot("logout", "Logout");
//$map->addClassroot("logout", "Logout");
App_Base_ApplicationRegistry::setControllerMap($map);
$appCtrl = new App_Controller_AppController(App_Base_ApplicationRegistry::getControllerMap());
App_Base_ApplicationRegistry::setApplicationController($appCtrl);
$manager = new App_Controller_AccessManager();
App_Base_ApplicationRegistry::setAccessManager($manager);
$pageTitle = "Det Norske Studentersamfund - vaktliste";
App_Base_ApplicationRegistry::setPageTitle($pageTitle);
}
private function ensure ($expr, $message) {
if (!$expr) {
throw new Exception($message);
}
}
}
?>
+34
View File
@@ -0,0 +1,34 @@
<?php
class App_Controller_Controller {
private $applicationHelper;
private function __construct() {}
public static function run() {
$instance = new self();
$instance->init();
$instance->handleRequest();
}
public function init() {
$this->applicationHelper = App_Controller_ApplicationHelper::instance();
$this->applicationHelper->init();
}
public function handleRequest() {
$request = new App_Controller_Request();
$app_c = App_Base_ApplicationRegistry::getApplicationController();
while ($cmd = $app_c->getCommand($request)) {
$cmd->execute($request);
}
$this->invokeView($app_c->getView($request));
}
function invokeView($target) {
include("App/View/$target.php");
exit;
}
}
?>
@@ -0,0 +1,42 @@
<?php
class App_Controller_ControllerMap {
private $viewMap = array();
private $forwardMap = array();
private $classrootMap = array();
function addClassroot ($command, $classroot) {
$this->classrootMap[$command] = $classroot;
}
function getClassroot ($command) {
if (isset ($this->classrootMap[$command])) {
return $this->classrootMap[$command];
}
return $command;
}
function addView ($command = "default", $status = 0, $view) {
$this->viewMap[$command][$status] = $view;
}
function getView ($command, $status) {
if (isset ($this->viewMap[$command][$status])) {
return $this->viewMap[$command][$status];
}
return null;
}
function addForward ($command, $status = 0, $newCommand) {
$this->forwardMap[$command][$status] = $newCommand;
}
function getForward ($command, $status) {
if (isset ($this->forwardMap[$command][$status])) {
return $this->forwardMap[$command][$status];
}
return null;
}
}
?>
+75
View File
@@ -0,0 +1,75 @@
<?php
/**
* Retrieves HTTP requests
*
*/
class App_Controller_Request {
private $properties;
private $feedback = array ();
private $command = null;
function __construct() {
$this->init();
App_Base_RequestRegistry::setRequest($this);
}
function init() {
if (isset($_SERVER['REQUEST_METHOD'])) {
if ($_SERVER['REQUEST_METHOD']) {
$this->properties = $_REQUEST;
return;
}
}
foreach($_SERVER['argv'] as $arg) {
if (strpos($arg, '=')) {
list($key, $val) = explode("=", $arg);
$this->setProperty($key, $val);
}
}
}
function getProperty($key) {
if (isset ($this->properties[$key])) {
return $this->properties[$key];
}
return null;
}
function setProperty($key, $val) {
$this->properties[$key] = $val;
}
function addFeedback($msg) {
array_push($this->feedback, $msg);
}
function getFeedback() {
return $this->feedback;
}
function getFeedbackString ($separator="\n") {
return implode($separator, $this->feedback);
}
function setObject( $name, $object ) {
$this->objects[$name] = $object;
}
function getObject( $name ) {
if ( isset( $this->objects[$name] ) ) {
return $this->objects[$name];
}
return null;
}
function setCommand (App_Command_Command $cmd) {
return $this->command = $cmd;
}
function getLastCommand () {
return $this->command;
}
}
?>
+47
View File
@@ -0,0 +1,47 @@
<?php
/**
* Domain Division model class
*
* @version 0.1
*/
class App_Domain_Division extends App_Domain_DomainObject {
private $name;
private $nicename;
private $hidden;
function __construct($id = null) {
parent::__construct($id);
}
function setName($name) {
$this->name = $name;
$this->markDirty();
}
function getName() {
return $this->name;
}
function setNiceName($niceName) {
$this->niceName = $niceName;
$this->markDirty();
}
function getNiceName() {
return $this->niceName;
}
function setHidden($hidden) {
$this->hidden = $hidden;
$this->markDirty();
}
function getHidden() {
return $this->hidden;
}
}
?>
+63
View File
@@ -0,0 +1,63 @@
<?php
/**
* Domain Object parent class
*
* @version 0.1
*/
abstract class App_Domain_DomainObject {
private $id = -1;
function __construct($id = null) {
if (is_null($id)) {
$this->markNew();
} else {
$this->id = $id;
}
}
function markNew() {
App_Domain_ObjectWatcher::addNew($this);
}
function markDeleted() {
App_Domain_ObjectWatcher::addDelete($this);
}
function markDirty() {
App_Domain_ObjectWatcher::addDirty($this);
}
function markClean() {
App_Domain_ObjectWatcher::addClean($this);
}
function setId($id) {
$this->id = $id;
}
function getId() {
return $this->id;
}
function collection() {
return self::getCollection(get_class($this));
}
static function getCollection($type) {
return App_Domain_HelperFactory::getCollection($type);
}
function finder() {
return self::getFinder(get_class($this));
}
static function getFinder($type) {
return App_Domain_HelperFactory::getFinder($type);
}
}
?>
+67
View File
@@ -0,0 +1,67 @@
<?php
/**
* Domain Group model class
*
* @version 0.1
*/
class App_Domain_Group extends App_Domain_DomainObject {
private $name;
private $text;
private $division;
private $admin;
private $mailinglist;
function __construct($id = null) {
parent::__construct($id);
}
function setName($name) {
$this->name = $name;
$this->markDirty();
}
function getName() {
return $this->name;
}
function setText($text) {
$this->text = $text;
$this->markDirty();
}
function getText() {
return $this->text;
}
function setDivision(App_Domain_Division $division) {
$this->division = $division;
$this->markDirty();
}
function getDivision() {
return $this->division;
}
function setAdmin($admin) {
$this->admin = $admin;
$this->markDirty();
}
function getAdmin() {
return $this->admin;
}
function setMailinglist($mailinglist) {
$this->mailinglist = $mailinglist;
$this->markDirty();
}
function getMailinglist() {
return $this->mailinglist;
}
}
?>
+66
View File
@@ -0,0 +1,66 @@
<?php
/**
* Helper factory for fetching collections from the database mapper
*
* @version 0.1
*/
class App_Domain_HelperFactory {
const DIVISION = "App_Domain_Division";
const LOCATION = "App_Domain_Location";
const USER = "App_Domain_User";
const USER_PHONE = "App_Domain_UserPhone";
const WORK_SALARY_TYPE = "App_Domain_WorkSalaryType";
const WORK_SHIFT = "App_Domain_WorkShift";
const WORK_SHIFT_UPDATE = "App_Domain_WorkShiftUpdate";
const WORK_SHIFT_WORKER = "App_Domain_WorkShiftWorker";
function getCollection($type) {
switch ($type) {
case (self::DIVISION):
return new App_Mapper_DivisionCollection();
case (self::LOCATION):
return new App_Mapper_LocationCollection();
case (self::USER):
return new App_Mapper_UserCollection();
case (self::USER_PHONE):
return new App_Mapper_UserPhoneCollection();
case (self::WORK_SALARY_TYPE):
return new App_Mapper_WorkSalaryTypeCollection();
case (self::WORK_SHIFT):
return new App_Mapper_WorkShiftCollection();
case (self::WORK_SHIFT_UPDATE):
return new App_Mapper_WorkShiftUpdateCollection();
case (self::WORK_SHIFT_WORKER):
return new App_Mapper_WorkShiftWorkerCollection();
default:
throw new Exception("Unknown collection type $type");
}
}
function getFinder($type) {
switch ($type) {
case (self::DIVISION):
return new App_Mapper_DivisionMapper();
case (self::LOCATION):
return new App_Mapper_LocationMapper();
case (self::USER):
return new App_Mapper_UserMapper();
case (self::USER_PHONE):
return new App_Mapper_UserPhoneMapper();
case (self::WORK_SALARY_TYPE):
return new App_Mapper_WorkSalaryTypeMapper();
case (self::WORK_SHIFT):
return new App_Mapper_WorkShiftMapper();
case (self::WORK_SHIFT_UPDATE):
return new App_Mapper_WorkShiftUpdateMapper();
case (self::WORK_SHIFT_WORKER):
return new App_Mapper_WorkShiftWorkerMapper();
default:
throw new Exception("Unknown finder type $type");
}
}
}
?>
+27
View File
@@ -0,0 +1,27 @@
<?php
/**
* Domain Location model class
*
* @version 0.1
*/
class App_Domain_Location extends App_Domain_DomainObject {
private $name;
function __construct($id = null) {
parent::__construct($id);
}
function setName($name) {
$this->name = $name;
$this->markDirty();
}
function getName() {
return $this->name;
}
}
?>
+112
View File
@@ -0,0 +1,112 @@
<?php
/**
* Identity map for ensuring that one object doesnt become two
*
* @version 0.1
*/
class App_Domain_ObjectWatcher {
private $all = array();
private $dirty = array();
private $new = array();
private $delete = array(); // not implemented
private static $instance;
private function __construct() { }
static function instance() {
if (!isset(self::$instance)) {
self::$instance = new App_Domain_ObjectWatcher();
}
return self::$instance;
}
function globalKey(App_Domain_DomainObject $obj) {
$key = get_class($obj) . "." . $obj->getId();
return $key;
}
static function add(App_Domain_DomainObject $obj) {
$inst = self::instance();
$inst->all[$inst->globalKey($obj)] = $obj;
}
static function exists($classname, $id) {
$inst = self::instance();
$key = "$classname.$id";
if (isset($inst->all[$key])) {
return $inst->all[$key];
}
return null;
}
static function addDirty(App_Domain_DomainObject $obj) {
$inst = self::instance();
// verify that the updated object is an object allready in the database
if (!in_array($obj, $inst->new, true)) {
$inst->dirty[$inst->globalKey($obj)] = $obj;
}
}
static function addNew(App_Domain_DomainObject $obj) {
$inst = self::instance();
// we don't yet have an id
$inst->new[] = $obj;
}
/*
* Mark object as clean, changes will not be stored to database
*/
static function addClean(App_Domain_DomainObject $obj) {
$inst = self::instance();
unset($inst->dirty[$inst->globalKey($obj)]);
// check if the object is in the new array, and remove it from it
if (in_array($obj, $inst->new, true)) {
$pruned=array();
foreach ($inst->new as $newobj) {
if (!($newobj === $obj)) {
$pruned[] = $newobj;
}
}
$inst->new = $pruned;
}
}
static function addDelete(App_Domain_DomainObject $obj) {
$inst = self::instance();
unset($inst->dirty[$inst->globalKey($obj)]);
if (in_array($obj, $inst->new, true)) {
$pruned=array();
foreach ($inst->new as $newobj) {
if (!($newobj === $obj)) {
$pruned[] = $newobj;
}
}
$inst->new = $pruned;
}
$inst->delete[] = $obj;
}
function performOperations() {
foreach ($this->dirty as $key=>$obj) {
$obj->finder()->update($obj);
}
foreach ($this->new as $key=>$obj) {
$obj->finder()->insert($obj);
}
foreach ($this->delete as $key=>$obj) {
//$obj->finder()->delete($obj);
}
$this->dirty = array();
$this->new = array();
$this->delete = array();
}
}
?>
+170
View File
@@ -0,0 +1,170 @@
<?php
/**
* Domain User Model class
*
* @version 0.1
*/
class App_Domain_User extends App_Domain_DomainObject {
private $username;
private $firstname;
private $lastname;
private $password;
private $validaddress;
private $email;
private $birthdate;
private $placeOfStudy;
private $passwordreset;
private $divisionIdRequest;
private $updates;
private $memberships;
private $address;
private $cards;
private $workShifts;
private $groups;
function __construct($id = null) {
parent::__construct($id);
}
function setUsername($username_s) {
$this->username = $username_s;
$this->markDirty();
}
function getUsername() {
return $this->username;
}
function setPassword($password_s) {
$this->password = $password_s;
$this->markDirty();
}
function getPassword() {
return $this->password;
}
function setFirstname($firstname_s) {
$this->firstname = $firstname_s;
$this->markDirty();
}
function getFirstname() {
return $this->firstname;
}
function setLastname($lastname_s) {
$this->lastname = $lastname_s;
$this->markDirty();
}
function getLastname() {
return $this->lastname;
}
function getName($separator = " ") {
return $this->getFirstname() . $separator . $this->getLastname();
}
function setValidaddress($validaddress_i) {
$this->validaddress = $validaddress_i;
$this->markDirty();
}
function getValidaddress() {
return $this->validaddress;
}
function setEmail($email_s) {
$this->email = $email_s;
$this->markDirty();
}
function getEmail() {
return $this->email;
}
function setBirthdate($birthdate_d) {
$this->birthdate = $birthdate_d;
$this->markDirty();
}
function getBirthdate() {
return $this->birthdate;
}
function setPlaceOfStudy($placeofstudy_i) {
$this->placeOfStudy = $placeofstudy_i;
$this->markDirty();
}
function getPlaceOfStudy() {
return $this->placeOfStudy;
}
function setPasswordreset($passwordreset_i) {
$this->passwordreset = $passwordreset_i;
$this->markDirty();
}
function getPasswordreset() {
return $this->passwordreset;
}
function setDivisionIdRequest($divisionidrequest_i) {
$this->divisionIdRequest = $divisionidrequest_i;
$this->markDirty();
}
function getDivisionIdRequest() {
return $this->divisionIdRequest;
}
function getUpdates() {
if (is_null($this->updates)) {
$this->updates = self::getFinder("App_Domain_UserUpdate")->findByUserId($this->getId());
}
return $this->updates;
}
function getAddress() {
if (is_null($this->address)) {
$this->address = self::getFinder("App_Domain_UserAddress")->findByUserId($this->getId());
}
return $this->address;
}
function getMemberships() {
if (is_null($this->memberships)) {
$this->memberships = self::getFinder("App_Domain_Membership")->findByUserId($this->getId());
}
return $this->memberships;
}
function getCards() {
if (is_null($this->cards)) {
$this->cards = self::getFinder("App_Domain_MembershipCard")->findByUserId($this->getId());
}
return $this->cards;
}
function getWorkShifts() {
if (is_null($this->workShifts)) {
$this->workShifts = self::getFinder("App_Domain_WorkShiftWorkers")->findByUserId($this->getId());
}
return $this->workShifts;
}
function getGroups() {
if (is_null($this->groups)) {
$this->groups = self::getFinder("App_Domain_Groups")->findByUserId($this->getId());
}
return $this->groups;
}
}
?>
+38
View File
@@ -0,0 +1,38 @@
<?php
/**
* Domain UserPhone model class
*
* @version 0.1
*/
class App_Domain_UserPhone extends App_Domain_DomainObject {
private $user;
private $phone;
function __construct($id = null) {
parent::__construct($id);
}
function setUser(domain_User $user) {
$this->user = $user;
$this->markDirty();
}
function getUser() {
return $this->user;
}
function setPhone($phone) {
$this->phone = $phone;
$this->markDirty();
}
function getPhone() {
return $this->phone;
}
}
?>
+37
View File
@@ -0,0 +1,37 @@
<?php
/**
* Domain WorkSalaryType model class
*
* @version 0.1
*/
class App_Domain_WorkSalaryType extends App_Domain_DomainObject {
private $title;
private $hourlyRate;
function __construct($id = null) {
parent::__construct($id);
}
function setTitle($title) {
$this->title = $title;
$this->markDirty();
}
function getTitle() {
return $this->title;
}
function setHourlyRate($hourlyRate) {
$this->hourlyRate = $hourlyRate;
$this->markDirty();
}
function getHourlyRate() {
return $this->hourlyRate;
}
}
?>
+142
View File
@@ -0,0 +1,142 @@
<?php
/**
* Domain WorkShift model class
*
* @version 0.1
*/
class App_Domain_WorkShift extends App_Domain_DomainObject {
private $starts;
private $ends;
private $group;
private $location;
private $active;
private $title;
private $comment;
private $numWorkers;
private $locked;
private $autoassignWorkers;
private $salaryType;
private $workers;
private $updates;
function __construct($id = null) {
parent::__construct($id);
}
function setStarts(DateTime $starts) {
$this->starts = $starts;
$this->markDirty();
}
function getStarts() {
return $this->starts;
}
function setEnds(DateTime $ends) {
$this->ends = $ends;
$this->markDirty();
}
function getEnds() {
return $this->ends;
}
function setGroup(App_Domain_Group $group) {
$this->group = $group;
$this->markDirty();
}
function getGroup() {
return $this->group;
}
function setLocation(App_Domain_Location $location) {
$this->location = $location;
$this->markDirty();
}
function getLocation() {
return $this->location;
}
function setActive($active) {
$this->active = $active;
$this->markDirty();
}
function getActive() {
return $this->active;
}
function setTitle($title) {
$this->title = $title;
$this->markDirty();
}
function getTitle() {
return $this->title;
}
function setComment($comment) {
$this->comment = $comment;
$this->markDirty();
}
function getComment() {
return $this->comment;
}
function setNumWorkers($numWorkers) {
$this->numWorkers = $numWorkers;
$this->markDirty();
}
function getNumWorkers() {
return $this->numWorkers;
}
function setLocked($locked) {
$this->locked = $locked;
$this->markDirty();
}
function getLocked() {
return $this->locked;
}
function setAutoassignWorkers($autoassignWorkers) {
$this->autoassignWorkers = $autoassignWorkers;
$this->markDirty();
}
function getAutoassignWorkers() {
return $this->autoassignWorkers;
}
function setSalaryType(App_Domain_WorkSalaryType $salaryType) {
$this->salaryType = $salaryType;
$this->markDirty();
}
function getSalaryType() {
return $this->salaryType;
}
function getWorkers() {
if (is_null($this->workers)) {
$this->workers = self::getFinder("App_Domain_WorkShiftWorkers")->findByShiftId($this->getId());
}
return $this->workers;
}
function getUpdates() {
if (is_null($this->updates)) {
$this->updates = self::getFinder("App_Domain_WorkShiftUpdates")->findByShiftId($this->getId());
}
return $this->updates;
}
}
+57
View File
@@ -0,0 +1,57 @@
<?php
/**
* Domain WorkShiftUpdate model class
*
* @version 0.1
*/
class App_Domain_WorkShiftUpdate extends App_Domain_DomainObject {
private $shift;
private $updateTime;
private $user;
private $updateText;
function __construct($id = null) {
parent::__construct($id);
}
function setShift(App_Domain_WorkShift $shift) {
$this->shift = $shift;
$this->markDirty();
}
function getShift() {
return $this->shift;
}
function setUpdateTime(DateTime $time) {
$this->updateTime = $time;
$this->markDirty();
}
function getUpdateTime() {
return $this->updateTime;
}
function setUser(App_Domain_User $user) {
$this->user = $user;
$this->markDirty();
}
function getUser() {
return $this->user;
}
function setUpdateText($updateText) {
$this->updateText = $updateText;
$this->markDirty();
}
function getUpdateText() {
return $this->updateText;
}
}
?>
+76
View File
@@ -0,0 +1,76 @@
<?php
/**
* Domain WorkShiftWorker model class
*
* @version 0.1
*/
class App_Domain_WorkShiftWorker extends App_Domain_DomainObject {
private $shift;
private $user;
private $assigned;
private $noShow;
private $userComment;
private $employerComment;
function __construct($id = null) {
parent::__construct($id);
}
function setShift(App_Domain_WorkShift $shift) {
$this->shift = $shift;
$this->markDirty();
}
function getShift() {
return $this->shift;
}
function setUser(App_Domain_User $user) {
$this->user = $user;
$this->markDirty();
}
function getUser() {
return $this->user;
}
function setAssigned($assigned) {
$this->assigned = $assigned;
$this->markDirty();
}
function getAssigned () {
return $this->assigned;
}
function setNoShow($noShow) {
$this->noShow = $noShow;
$this->markDirty();
}
function getNoShow() {
return $this->noShow;
}
function setUserComment($comment) {
$this->userComment = $comment;
$this->markDirty();
}
function getUserComment() {
return $this->userComment;
}
function setEmployerComment($comment) {
$this->employerComment = $comment;
$this->markDirty();
}
function getEmployerComment() {
return $this->employerComment;
}
}
?>
+87
View File
@@ -0,0 +1,87 @@
<?php
/**
* Collection object for handling multiple rows and creating objects from database results
*
* @version 0.1
*/
abstract class App_Mapper_Collection implements Iterator {
protected $mapper;
protected $total = 0;
protected $raw = array();
private $result;
private $pointer;
private $objects = array();
function __construct(array $raw = null, mapper_Mapper $mapper = null) {
if (!is_null($raw) && !is_null($mapper)) {
$this->rewind();
$this->raw = $raw;
$this->total = count($raw);
}
$this->mapper = $mapper;
}
/**
* Add an object to the collection
**/
function add(App_Domain_DomainObject $object) {
$class = $this->targetClass();
if (!($object instanceof $class)) {
throw new Exception("This is a {$class} collection");
}
$this->notifyAccess();
$this->objects[$this->total] = $object;
$this->total++;
}
abstract function targetClass();
protected function notifyAccess() {
// something is coming here..
}
private function getRow($num) {
$this->notifyAccess();
if ($num >= $this->total || $num < 0) {
return null;
}
if (isset($this->objects[$num])) {
return $this->objects[$num];
}
if (isset($this->raw[$num])) {
// object has not been created yet
$this->objects[$num]=$this->mapper->createObject($this->raw[$num]);
return $this->objects[$num];
}
}
public function rewind() {
$this->pointer = 0;
}
public function current() {
return $this->getRow($this->pointer);
}
public function key() {
return $this->pointer;
}
public function next() {
$row = $this->getRow($this->pointer);
if ($row) {
$this->pointer++;
}
return $row;
}
public function valid() {
return (!is_null($this->current()));
}
}
?>
@@ -0,0 +1,15 @@
<?php
/**
* Division collection - collection of elements in the din_division database table
*
* @version 0.1
*/
class App_Mapper_DivisionCollection extends App_Mapper_Collection {
function targetClass() {
return "App_Domain_Division";
}
}
?>
+93
View File
@@ -0,0 +1,93 @@
<?php
/**
* Division object mapper to database table
*
* @version 0.1
*/
class App_Mapper_DivisionMapper extends App_Mapper_Mapper {
function __construct() {
// initialize database connection and common setup
parent::__construct();
// prepare SQL statements
$this->selectStmt = self::$PDO->prepare(
"SELECT * FROM din_group WHERE id=?");
$this->findByGroupIdStmt = self::$PDO->prepare(
"SELECT * FROM din_division INNER JOIN din_group ON din_division.id = din_group.division_id WHERE din_group.id=?");
$this->selectAllStmt = self::$PDO->prepare(
"SELECT * FROM din_division");
$this->insertStmt = self::$PDO->prepare(
"INSERT INTO din_division (
name,
nicename,
hidden
) values (?)");
$this->updateStmt = self::$PDO->prepare(
"UPDATE din_division SET
name=?,
nicename=?,
hidden=?
WHERE id=?");
$this->deleteStmt = self::$PDO->prepare(
"DELETE FROM din_division WHERE id=?");
}
protected function doCreateObject(array $array) {
$obj = new App_Domain_Division($array["id"]);
$obj->setName($array["name"]);
$obj->setNiceName($array["nicename"]);
$obj->setHidden($array["hidden"]);
return $obj;
}
protected function doInsert(App_Domain_DomainObject $object) {
$this->insertStmt->bindValue(1, $object->getName());
$this->insertStmt->bindValue(2, $object->getNiceName());
$this->insertStmt->bindValue(3, $object->getHidden());
$this->insertStmt->execute();
$id = self::$PDO->lastInsertId();
$this->setId($id);
}
function update(App_Domain_DomainObject $object) {
$this->insertStmt->bindValue(1, $object->getName());
$this->insertStmt->bindValue(2, $object->getNiceName());
$this->insertStmt->bindValue(3, $object->getHidden());
$this->updateStmt->bindValue(4, $object->getId());
$this->updateStmt->execute();
}
protected function doDelete(App_Domain_DomainObject $object) {
$values = array($object->getId());
$this->deleteStmt->execute($values);
}
function selectStmt() {
return $this->selectStmt;
}
function selectAllStmt() {
return $this->selectAllStmt;
}
function deleteStmt() {
return $this->deleteStmt;
}
function getCollection(array $raw) {
return new App_Mapper_DivsionCollection($raw, $this);
}
protected function targetClass() {
return "App_Domain_Division";
}
}
?>
@@ -0,0 +1,7 @@
<?php
abstract class App_Mapper_DomainObjectFactory {
abstract function createObject(array $array);
}
?>
+15
View File
@@ -0,0 +1,15 @@
<?php
/**
* Group collection - collection of elements in the din_group database table
*
* @version 0.1
*/
class App_Mapper_GroupCollection extends App_Mapper_Collection {
function targetClass() {
return "App_Domain_Group";
}
}
?>
+119
View File
@@ -0,0 +1,119 @@
<?php
/**
* Group object mapper to database table
*
* @version 0.1
*/
class App_Mapper_GroupMapper extends App_Mapper_Mapper {
function __construct() {
// initialize database connection and common setup
parent::__construct();
// prepare SQL statements
$this->selectStmt = self::$PDO->prepare(
"SELECT * FROM din_group WHERE id=?");
$this->findByDivisionIdStmt = self::$PDO->prepare(
"SELECT * FROM din_group WHERE division_id=?");
$this->findByUserIdStmt = self::$PDO->prepare(
"SELECT * FROM din_group INNER JOIN din_usergrouprelationship ON din_group.id = din_usergrouprelationship.group_id WHERE din_usergrouprelationship.user_id=?");
$this->selectAllStmt = self::$PDO->prepare(
"SELECT * FROM din_group");
$this->insertStmt = self::$PDO->prepare(
"INSERT INTO din_group (
name,
text,
division_id,
admin,
mailinglist
) values (?)");
$this->updateStmt = self::$PDO->prepare(
"UPDATE din_group SET
name=?,
text=?,
division_id=?,
admin=?,
mailinglist=?
WHERE id=?");
$this->deleteStmt = self::$PDO->prepare(
"DELETE FROM din_group WHERE id=?");
}
protected function doCreateObject(array $array) {
$obj = new App_Domain_Group($array["id"]);
$obj->setName($array["name"]);
$obj->setText($array["text"]);
$obj->setAdmin($array["admin"]);
$obj->setMailinglist($array["mailinglist"]);
// find division and create division object
$division_mapper = new App_Domain_DivisionMapper();
$division = $division_mapper->find($array["division_id"]);
$obj->setDivision($division);
return $obj;
}
protected function doInsert(App_Domain_DomainObject $object) {
$this->insertStmt->bindValue(1, $object->getName());
$this->insertStmt->bindValue(2, $object->getText());
$this->insertStmt->bindValue(3, $object->getDivision()->getId());
$this->insertStmt->bindValue(4, $object->getAdmin());
$this->insertStmt->bindValue(5, $object->getMailinglist());
$this->insertStmt->execute();
$id = self::$PDO->lastInsertId();
$this->setId($id);
}
function update(App_Domain_DomainObject $object) {
$this->insertStmt->bindValue(1, $object->getName());
$this->insertStmt->bindValue(2, $object->getText());
$this->insertStmt->bindValue(3, $object->getDivision()->getId());
$this->insertStmt->bindValue(4, $object->getAdmin());
$this->insertStmt->bindValue(5, $object->getMailinglist());
$this->updateStmt->bindValue(6, $object->getId());
$this->updateStmt->execute();
}
protected function doDelete(App_Domain_DomainObject $object) {
$values = array($object->getId());
$this->deleteStmt->execute($values);
}
function selectStmt() {
return $this->selectStmt;
}
function selectAllStmt() {
return $this->selectAllStmt;
}
function deleteStmt() {
return $this->deleteStmt;
}
function findByDivisionId($division_id) {
$this->findByDivisionIdStmt->execute(array($division_id));
return new App_Mapper_WorkShiftCollection($this->findByDivisionIdStmt->fetchAll(), $this);
}
function findByUserId($user_id) {
$this->findByUserIdStmt->execute(array($user_id));
return new App_Mapper_GroupCollection($this->findByUserIdStmt->fetchAll(), $this);
}
function getCollection(array $raw) {
return new App_Mapper_GroupCollection($raw, $this);
}
protected function targetClass() {
return "App_Domain_Group";
}
}
?>
@@ -0,0 +1,15 @@
<?php
/**
* Location collection - collection of elements in the work_salarytype database table
*
* @version 0.1
*/
class App_Mapper_Location extends App_Mapper_Collection {
function targetClass() {
return "App_Domain_Location";
}
}
?>
+81
View File
@@ -0,0 +1,81 @@
<?php
/**
* Location object mapper to database table
*
* @version 0.1
*/
class App_Mapper_LocationMapper extends App_Mapper_Mapper {
function __construct() {
// initialize database connection and common setup
parent::__construct();
// prepare SQL statements
$this->selectStmt = self::$PDO->prepare(
"SELECT * FROM lokaler WHERE id=?");
$this->selectAllStmt = self::$PDO->prepare(
"SELECT * FROM lokaler");
$this->insertStmt = self::$PDO->prepare(
"INSERT INTO lokaler (
navn
) values (?)");
$this->updateStmt = self::$PDO->prepare(
"UPDATE lokaler SET
navn=?
WHERE id=?");
$this->deleteStmt = self::$PDO->prepare(
"DELETE FROM lokaler WHERE id=?");
}
protected function doCreateObject(array $array) {
$obj = new App_Domain_Location($array["id"]);
$obj->setName($array["navn"]);
return $obj;
}
protected function doInsert(App_Domain_DomainObject $object) {
$this->insertStmt->bindValue(1, $object->getName());
$this->insertStmt->execute();
$id = self::$PDO->lastInsertId();
$this->setId($id);
}
function update(App_Domain_DomainObject $object) {
$this->insertStmt->bindValue(1, $object->getName());
$this->updateStmt->bindValue(2, $object->getId());
$this->updateStmt->execute();
}
protected function doDelete(App_Domain_DomainObject $object) {
$values = array($object->getId());
$this->deleteStmt->execute($values);
}
function selectStmt() {
return $this->selectStmt;
}
function selectAllStmt() {
return $this->selectAllStmt;
}
function deleteStmt() {
return $this->deleteStmt;
}
function getCollection(array $raw) {
return new App_Mapper_LocationCollection($raw, $this);
}
protected function targetClass() {
return "App_Domain_Location";
}
}
?>
+99
View File
@@ -0,0 +1,99 @@
<?php
/**
* Abstract mapper class for database mapping from domain
*
* @version 0.1
*/
abstract class App_Mapper_Mapper {
protected static $PDO;
const DATETIME_FORMAT = "Y-m-d H:i:s"; // mysql datetime format for DateTime class formatting
function __construct() {
if (!isset(self::$PDO)) {
$dsn = App_Base_ApplicationRegistry::instance()->getDSN("PDO");
if (is_null($dsn)) {
throw new Exception("No DSN");
}
try {
self::$PDO = new PDO($dsn["dsn"], $dsn["username"], $dsn["password"]);
self::$PDO->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
} catch (Exception $e) {
throw new Exception("Database connection error: ". getDSN());
}
}
}
private function getFromMap($id) {
return App_Domain_ObjectWatcher::exists($this->targetClass(), $id);
}
private function addToMap(App_Domain_DomainObject $obj) {
return App_Domain_ObjectWatcher::add($obj);
}
function find($id) {
// check if object allready has been fetch from database
$old = $this->getFromMap($id);
if ($old) {
return $old;
}
// get object from database
$this->selectStmt()->execute(array($id));
$array = $this->selectStmt()->fetch();
$this->selectStmt()->closeCursor();
if (!is_array($array)) {
return null;
}
if (!isset($array['id'])) {
return null;
}
$object = $this->createObject($array);
$object->markClean();
return $object;
}
function findAll() {
$this->selectAllStmt()->execute(array());
return $this->getCollection( $this->selectAllStmt()->fetchAll( PDO::FETCH_ASSOC ) );
}
function createObject($array) {
$old = $this->getFromMap($array['id']);
if ($old) { return $old; }
// construct object
$obj = $this->doCreateObject($array);
// add object to object watcher map
$this->addToMap($obj);
$obj->markClean();
return $obj;
}
function insert(App_Domain_DomainObject $obj) {
$this->doInsert($obj);
$this->addToMap($obj);
$obj->markClean();
}
function delete(App_Domain_DomainObject $obj) {
$this->doDelete($obj);
//$this->removeFromMap($obj);
}
abstract function update(App_Domain_DomainObject $object);
protected abstract function doCreateObject(array $array);
protected abstract function doInsert(App_Domain_DomainObject $object);
protected abstract function doDelete(App_Domain_DomainObject $object);
protected abstract function targetClass();
protected abstract function selectStmt();
protected abstract function selectAllStmt();
protected abstract function deleteStmt();
abstract function getCollection(array $raw);
}
?>
+14
View File
@@ -0,0 +1,14 @@
<?php
/**
* User collection - collection of elements in the user database
*
* @version 0.1
*/
class App_Mapper_UserCollection extends App_Mapper_Collection {
function targetClass() {
return "App_Domain_User";
}
}
?>
+126
View File
@@ -0,0 +1,126 @@
<?php
/**
* User object mapper to database
*
* @version 0.1
*/
class App_Mapper_UserMapper extends App_Mapper_Mapper {
function __construct() {
// initialize database connection and common setup
parent::__construct();
// prepare SQL statements
$this->selectStmt = self::$PDO->prepare(
"SELECT * FROM din_user WHERE id=?");
$this->selectAllStmt = self::$PDO->prepare(
"SELECT * FROM din_user");
//$this->updateStmt = self::$PDO->prepare(
// "UPDATE din_user SET
// username=?,
// password=?,
// firstname=?,
// lastname=?,
// addresstype='no',
// valid_address=?,
// email=?,
// birthdate=?,
// placeOfStudy=?,
// passwordReset=?,
// division_id_request=?
// WHERE id=?");
//$this->insertStmt = self::$PDO->prepare(
// "INSERT INTO din_user (
// cardno, username, password, firstname, lastname, addresstype, valid_address, email, birthdate, placeOfStudy, passwordReset, division_id_request
// ) values (?)");
//$this->deleteStmt = self::$PDO->prepare(
// "DELETE FROM din_user WHERE id=?");
$this->findByLoginStmt = self::$PDO->prepare(
"SELECT * FROM din_user WHERE username=? AND ( password=PASSWORD(?) or password=OLD_PASSWORD(?) )");
}
protected function doCreateObject(array $array) {
$obj = new App_Domain_User($array["id"]);
$obj->setUsername($array["username"]);
$obj->setPassword($array["password"]);
$obj->setFirstname($array["firstname"]);
$obj->setLastname($array["lastname"]);
$obj->setValidaddress($array["valid_address"]);
$obj->setEmail($array["email"]);
$obj->setBirthdate($array["birthdate"]);
$obj->setPlaceOfStudy($array["placeOfStudy"]);
$obj->setPasswordreset($array["passwordReset"]);
$obj->setDivisionIdRequest($array["division_id_request"]);
return $obj;
}
protected function doInsert(App_Domain_DomainObject $object) {
$values = array($object->getUsername());
throw new Excepetion("UserMapper::doInsert() failure: UserMapper is read only!");
//$this->insertStmt->execute($values);
//$id = self::$PDO->lastInsertId();
//$object->setId($id);
}
function update(App_Domain_DomainObject $object) {
$values = array(
$object->getUsername(),
$object->getPassword(),
$object->getFirstname(),
$object->getLastname(),
$object->getValidAddress(),
$object->getEmail(),
$object->getBirthdate(),
$object->getPlaceOfStudy(),
$object->getPasswordreset(),
$object->getDivisionIdRequest(),
$object->getId()
);
throw new Excepetion("UserMapper:update() failure: UserMapper is read only!");
//$this->updateStmt->execute($values);
}
protected function doDelete(App_Domain_DomainObject $object) {
$values = array($object->getId());
throw new Excepetion("UserMapper::doDelete() failure: UserMapper is read only!");
//$this->deleteStmt->execute($values);
}
function selectStmt() {
return $this->selectStmt;
}
function selectAllStmt() {
return $this->selectAllStmt;
}
function deleteStmt() {
throw new Excepetion("UserMapper::deleteStmt() failure: UserMapper is read only!");
//return $this->deleteStmt;
}
function findByLogin($username, $password) {
$this->findByLoginStmt->execute(array($username, $password, $password));
$array = $this->findByLoginStmt->fetch();
$this->findByLoginStmt->closeCursor();
if (!is_array($array)) {
return null;
}
if (!isset($array['id'])) {
return null;
}
return $this->createObject($array);
}
function getCollection(array $raw) {
return new App_Mapper_UserCollection($raw, $this);
}
protected function targetClass() {
return "App_Domain_User";
}
}
?>
@@ -0,0 +1,15 @@
<?php
/**
* Work salary type collection - collection of elements in the work_salarytype database table
*
* @version 0.1
*/
class App_Mapper_WorkSalaryTypeCollection extends App_Mapper_Collection {
function targetClass() {
return "App_Domain_WorkSalaryType";
}
}
?>
@@ -0,0 +1,85 @@
<?php
/**
* Work salary type object mapper to database table
*
* @version 0.1
*/
class App_Mapper_WorkSalaryTyperMapper extends App_Mapper_Mapper {
function __construct() {
// initialize database connection and common setup
parent::__construct();
// prepare SQL statements
$this->selectStmt = self::$PDO->prepare(
"SELECT * FROM work_salarytype WHERE id=?");
$this->selectAllStmt = self::$PDO->prepare(
"SELECT * FROM work_salarytype");
$this->insertStmt = self::$PDO->prepare(
"INSERT INTO work_salarytype (
title, hourly_rate
) values (?, ?)");
$this->updateStmt = self::$PDO->prepare(
"UPDATE work_salarytype SET
title=?,
hourly_rate=?
WHERE id=?");
$this->deleteStmt = self::$PDO->prepare(
"DELETE FROM work_salarytype WHERE id=?");
}
protected function doCreateObject(array $array) {
$obj = new App_Domain_WorkSalaryType($array["id"]);
$obj->setTitle($array["title"]);
$obj->setHourlyRate($array["hourly_rate"]);
return $obj;
}
protected function doInsert(App_Domain_DomainObject $object) {
$this->insertStmt->bindValue(1, $object->getTitle());
$this->insertStmt->bindValue(2, $object->getHourlyRate());
$this->insertStmt->execute();
$id = self::$PDO->lastInsertId();
$this->setId($id);
}
function update(App_Domain_DomainObject $object) {
$this->insertStmt->bindValue(1, $object->getTitle());
$this->insertStmt->bindValue(2, $object->getHourlyRate());
$this->updateStmt->bindValue(3, $object->getId());
$this->updateStmt->execute();
}
protected function doDelete(App_Domain_DomainObject $object) {
$values = array($object->getId());
$this->deleteStmt->execute($values);
}
function selectStmt() {
return $this->selectStmt;
}
function selectAllStmt() {
return $this->selectAllStmt;
}
function deleteStmt() {
return $this->deleteStmt;
}
function getCollection(array $raw) {
return new App_Mapper_WorkSalaryTypeCollection($raw, $this);
}
protected function targetClass() {
return "App_Domain_WorkSalaryType";
}
}
?>
@@ -0,0 +1,15 @@
<?php
/**
* Work shift collection - collection of elements in the work_shift database table
*
* @version 0.1
*/
class App_Mapper_WorkShiftCollection extends App_Mapper_Collection {
function targetClass() {
return "App_Domain_WorkShift";
}
}
?>
+140
View File
@@ -0,0 +1,140 @@
<?php
/**
* Work shift object mapper to database table
*
* @version 0.1
*/
class App_Mapper_WorkShiftMapper extends App_Mapper_Mapper {
function __construct() {
// initialize database connection and common setup
parent::__construct();
// prepare SQL statements
$this->selectStmt = self::$PDO->prepare(
"SELECT * FROM work_shift WHERE id=?");
$this->selectAllStmt = self::$PDO->prepare(
"SELECT * FROM work_shift");
$this->findByGroupIdStmt = self::$PDO->prepare(
"SELECT * FROM work_shift WHERE group_id=?");
$this->updateStmt = self::$PDO->prepare(
"UPDATE work_shift SET
starts=?,
ends=?,
group_id=?,
location_id=?,
active=?,
title=?,
comment=?,
num_workers=?,
locked=?,
autoassign_workers=?,
salarytype_id=?
WHERE id=?");
$this->insertStmt = self::$PDO->prepare(
"INSERT INTO work_shift (
starts, ends, group_id, location_id, active, title, comment, num_workers, locked, autoassign_workers, salarytype_id
) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)");
$this->deleteStmt = self::$PDO->prepare(
"DELETE FROM work_shift WHERE id=?");
}
protected function doCreateObject(array $array) {
$obj = new App_Domain_WorkShift($array["id"]);
$obj->setStarts(new DateTime($array["starts"]));
$obj->setEnds(new DateTime($array["ends"]));
$obj->setActive($array["active"]);
$obj->setTitle($array["title"]);
$obj->setComment($array["comment"]);
$obj->setNumWorkers($array["num_workers"]);
$obj->setLocked($array["locked"]);
$obj->setAutoAssignWorkers($array["autoassign_workers"]);
// find group and create division object
$group_mapper = new App_Domain_GroupMapper();
$group = $group_mapper->find($array["group_id"]);
$obj->setGroup($group);
// find location and create location object
$location_mapper = new App_Domain_LocationMapper();
$location = $location_mapper->find($array["location_id"]);
$obj->setLocation($location);
// find salary type and create salary type object
$salarytype_mapper = new App_Domain_WorkSalaryTypeMapper();
$salarytype = $salarytype_mapper->find($array["slarytype_id"]);
$obj->setSalaryType($salarytype);
return $obj;
}
protected function doInsert(App_Domain_DomainObject $object) {
$this->insertStmt->bindValue(1, $object->getStarts()->format(self::DATETIME_FORMAT));
$this->insertStmt->bindValue(2, $object->getEnds()->format(self::DATETIME_FORMAT));
$this->insertStmt->bindValue(3, $object->getGroup()->getId());
$this->insertStmt->bindValue(4, $object->getLocation()->getId());
$this->insertStmt->bindValue(5, $object->getActive());
$this->insertStmt->bindValue(6, $object->getTitle());
$this->insertStmt->bindValue(7, $object->getComment());
$this->insertStmt->bindValue(8, $object->getNumWorkers());
$this->insertStmt->bindValue(9, $object->getLocked());
$this->insertStmt->bindValue(10, $object->getAutoAssignWorkers());
$this->insertStmt->bindValue(11, $object->getSalaryType()->getId());
$this->insertStmt->execute();
$id = self::$PDO->lastInsertId();
$this->setId($id);
}
function update(App_Domain_DomainObject $object) {
$this->updateStmt->bindValue(1, $object->getStarts()->format(self::DATETIME_FORMAT));
$this->updateStmt->bindValue(2, $object->getEnds()->format(self::DATETIME_FORMAT));
$this->updateStmt->bindValue(3, $object->getGroup()->getId());
$this->updateStmt->bindValue(4, $object->getLocation()->getId());
$this->updateStmt->bindValue(5, $object->getActive());
$this->updateStmt->bindValue(6, $object->getTitle());
$this->updateStmt->bindValue(7, $object->getComment());
$this->updateStmt->bindValue(8, $object->getNumWorkers());
$this->updateStmt->bindValue(9, $object->getLocked());
$this->updateStmt->bindValue(10, $object->getAutoAssignWorkers());
$this->updateStmt->bindValue(11, $object->getSalaryType()->getId());
$this->updateStmt->bindValue(12, $object->getId());
$this->updateStmt->execute();
}
protected function doDelete(App_Domain_DomainObject $object) {
$values = array($object->getId());
$this->deleteStmt->execute($values);
}
function selectStmt() {
return $this->selectStmt;
}
function selectAllStmt() {
return $this->selectAllStmt;
}
function deleteStmt() {
return $this->deleteStmt;
}
function findByGroupId($group_id) {
$this->findByGroupIdStmt->execute(array($group_id));
return new App_Mapper_WorkShiftCollection($this->findByGroupIdStmt->fetchAll(), $this);
}
function getCollection(array $raw) {
return new App_Mapper_WorkShiftCollection($raw, $this);
}
protected function targetClass() {
return "App_Domain_WorkShift";
}
}
?>
@@ -0,0 +1,14 @@
<?php
/**
* Work shift update collection - collection of elements in the work_shiftupdate database table
*
* @version 0.1
*/
class App_Mapper_WorkShiftUpdateCollection extends App_Mapper_Collection {
function targetClass() {
return "App_Domain_WorkShiftUpdate";
}
}
?>
@@ -0,0 +1,109 @@
<?php
/**
* Work shift update object mapper to database table
*
* @version 0.1
*/
class App_Mapper_WorkShiftUpdateMapper extends App_Mapper_Mapper {
function __construct() {
// initialize database connection and common setup
parent::__construct();
// prepare SQL statements
$this->selectStmt = self::$PDO->prepare(
"SELECT * FROM work_shiftupdate WHERE id=?");
$this->selectAllStmt = self::$PDO->prepare(
"SELECT * FROM work_shiftupdate");
$this->findByShiftIdStmt = self::$PDO->prepare(
"SELECT * FROM work_shiftupdate WHERE shift_id=?");
$this->updateStmt = self::$PDO->prepare(
"UPDATE work_shiftupdate SET
shift_id=?,
update_time=?,
user_id=?,
update_text=?
WHERE id=?");
$this->insertStmt = self::$PDO->prepare(
"INSERT INTO work_shiftupdate (
shift_id, update_time, user_id, update_text
) values (?, ?, ?, ?)");
$this->deleteStmt = self::$PDO->prepare(
"DELETE FROM work_shiftupdate WHERE id=?");
}
protected function doCreateObject(array $array) {
$obj = new App_Domain_WorkShiftUpdate($array["id"]);
// find shift and create workshift object
$shift_mapper = new App_Mapper_WorkShiftMapper();
$shift = $shift_mapper->find($array["shift_id"]);
$obj->setShift($shift);
$obj->setUpdateTime(new DateTime($array["update_time"]));
// find user and create user object
$user_mapper = new App_Domain_User();
$user = $user_mapper->find($array["user_id"]);
$obj->setUser($user);
$obj->setUpdateText($array["text"]);
return $obj;
}
protected function doInsert(App_Domain_DomainObject $object) {
$this->insertStmt->bindValue(1, $object->getShift()->getId());
$this->insertStmt->bindValue(2, $object->getUpdateTime()->format(self::DATETIME_FORMAT));
$this->insertStmt->bindValue(3, $object->getUser()->getId());
$this->insertStmt->bindValue(4, $object->getUpdateText());
$this->insertStmt->execute();
$id = self::$PDO->lastInsertId();
$this->setId($id);
}
function update(App_Domain_DomainObject $object) {
$this->insertStmt->bindValue(1, $object->getShift()->getId());
$this->insertStmt->bindValue(2, $object->getUpdateTime()->format(self::DATETIME_FORMAT));
$this->insertStmt->bindValue(3, $object->getUser()->getId());
$this->insertStmt->bindValue(4, $object->getUpdateText());
$this->updateStmt->bindValue(5, $object->getId());
$this->updateStmt->execute();
}
protected function doDelete(App_Domain_DomainObject $object) {
$values = array($object->getId());
$this->deleteStmt->execute($values);
}
function selectStmt() {
return $this->selectStmt;
}
function selectAllStmt() {
return $this->selectAllStmt;
}
function deleteStmt() {
return $this->deleteStmt;
}
function findByShiftId($shift_id) {
$this->findByShiftIdStmt->execute(array($shift_id));
return new App_Mapper_WorkShiftUpdateCollection($this->findByShiftIdStmt->fetchAll(), $this);
}
function getCollection(array $raw) {
return new App_Mapper_WorkShiftUpdateCollection($raw, $this);
}
protected function targetClass() {
return "App_Domain_WorkShiftUpdate";
}
}
?>
@@ -0,0 +1,15 @@
<?php
/**
* Work shift worker collection - collection of elements in the work_shiftworker database table
*
* @version 0.1
*/
class App_Mapper_WorkShiftWorkerCollection extends App_Mapper_Collection {
function targetClass() {
return "App_Domain_WorkShiftWorker";
}
}
?>
@@ -0,0 +1,123 @@
<?php
/**
* Work shift worker object mapper to database table
*
* @version 0.1
*/
class App_Mapper_WorkShiftWorkerMapper extends App_Mapper_Mapper {
function __construct() {
// initialize database connection and common setup
parent::__construct();
// prepare SQL statements
$this->selectStmt = self::$PDO->prepare(
"SELECT * FROM work_shiftworker WHERE id=?");
$this->selectAllStmt = self::$PDO->prepare(
"SELECT * FROM work_shiftworker");
$this->findByShiftIdStmt = self::$PDO->prepare(
"SELECT * FROM work_shiftworker WHERE shift_id=?");
$this->findByUserIdStmt = self::$PDO->prepare(
"SELECT * FROM work_shiftworker WHERE user_id=?");
$this->insertStmt = self::$PDO->prepare(
"INSERT INTO work_shiftworker (
shift_id, user_id, assigned, no_show, user_comment, employer_comment
) values (?, ?, ?, ?, ?, ?)");
$this->updateStmt = self::$PDO->prepare(
"UPDATE work_shiftworker SET
shift_id=?,
user_id=?,
assigned=?,
no_show=?,
user_comment=?,
employer_comment=?
WHERE id=?");
$this->deleteStmt = self::$PDO->prepare(
"DELETE FROM work_shiftworker WHERE id=?");
}
protected function doCreateObject(array $array) {
$obj = new App_Domain_WorkShiftWorker($array["id"]);
// find shift and create workshift object
$shift_mapper = new App_Mapper_WorkShiftMapper();
$shift = $shift_mapper->find($array["shift_id"]);
$obj->setShift($shift);
// find user and create user object
$user_mapper = new App_Domain_User();
$user = $user_mapper->find($array["user_id"]);
$obj->setUser($user);
$obj->setAssigned($array["assigned"]);
$obj->setNoShow($array["no_show"]);
$obj->setUserComment($array["user_comment"]);
$obj->setEmployerComment($array["employer_comment"]);
return $obj;
}
protected function doInsert(App_Domain_DomainObject $object) {
$this->insertStmt->bindValue(1, $object->getShift()->getId());
$this->insertStmt->bindValue(2, $object->getUser()->getId());
$this->insertStmt->bindValue(3, $object->getAssigned());
$this->insertStmt->bindValue(4, $object->getNoShow());
$this->insertStmt->bindValue(5, $object->getUserComment());
$this->insertStmt->bindValue(6, $object->getEmployerComment());
$this->insertStmt->execute();
$id = self::$PDO->lastInsertId();
$this->setId($id);
}
function update(App_Domain_DomainObject $object) {
$this->insertStmt->bindValue(1, $object->getShift()->getId());
$this->insertStmt->bindValue(2, $object->getUser()->getId());
$this->insertStmt->bindValue(3, $object->getAssigned());
$this->insertStmt->bindValue(4, $object->getNoShow());
$this->insertStmt->bindValue(5, $object->getUserComment());
$this->insertStmt->bindValue(6, $object->getEmployerComment());
$this->updateStmt->bindValue(7, $object->getId());
$this->updateStmt->execute();
}
protected function doDelete(App_Domain_DomainObject $object) {
$values = array($object->getId());
$this->deleteStmt->execute($values);
}
function selectStmt() {
return $this->selectStmt;
}
function selectAllStmt() {
return $this->selectAllStmt;
}
function deleteStmt() {
return $this->deleteStmt;
}
function findByShiftId($shift_id) {
$this->findByShiftIdStmt->execute(array($shift_id));
return new App_Mapper_WorkShiftWorkerCollection($this->findByShiftIdStmt->fetchAll(), $this);
}
function findByUserId($user_id) {
$this->findByUserIdStmt->execute(array($user_id));
return new App_Mapper_WorkShiftWorkerCollection($this->findByUserIdStmt->fetchAll(), $this);
}
function getCollection(array $raw) {
return new App_Mapper_WorkShiftWorkerCollection($raw, $this);
}
protected function targetClass() {
return "App_Domain_WorkShiftWorker";
}
}
?>
+7
View File
@@ -0,0 +1,7 @@
</div>
</div> <!-- #content-wrap -->
</div>
</body>
</html>
+98
View File
@@ -0,0 +1,98 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="no" lang="no">
<head>
<meta http-equiv="content-type" content="text/html;charset=iso-8859-1" />
<link rel="stylesheet" title="default" type="text/css" href="https://www.studentersamfundet.no/inside/screen.css" />
<title><?php print App_Base_ApplicationRegistry::getPageTitle(); ?></title>
</head>
<body class="dns section-inside">
<div id="container">
<div id="header">
<span class="site-title"><a href="http://studentersamfundet.no/"><?php print App_Base_ApplicationRegistry::getPageTitle(); ?></a></span>
<div id="quick-menu">
Om Studentersamfundet | <a href="http://studentersamfundet.no/kart.php">Kart</a> | <a href="http://studentersamfundet.no/kontakt.php">Kontakt</a>
</div>
<div class="aapningstider">
<table>
<tr><td>Mandag-onsdag</td><td>13-01</td></tr>
<tr><td>Torsdag-fredag</td><td>13-03</td></tr>
<tr><td>L&oslash;rdag</td><td>16-03</td></tr>
<tr><td>Kjøkkenet</td><td>Til 19</td></tr>
</table>
</div>
<div id="menu">
<ul>
<li id="forside-meny"><a href="http://studentersamfundet.no/">Forside</a>
<div class="sub-menu">
<ul>
<li><a href="http://studentersamfundet.no/lokaler.php">Lokaler</a></li>
<li><a href="http://studentersamfundet.no/historie.php">Historie</a></li>
<li><a href="http://studentersamfundet.no/billetter.php">Billetter</a></li>
<li><a href="http://studentersamfundet.no/medlemmer.php">Bli medlem</a></li>
<li><a href="http://studentersamfundet.no/medlem/index.php">Registrere medlemskort</a></li>
</ul>
</div>
</li>
<li id="program-meny"><a href="http://studentersamfundet.no/prog.php">Program</a>
<div class="sub-menu">
<ul>
<li><a href="http://studentersamfundet.no/prog.php">Alle</a></li>
<li><a href="http://studentersamfundet.no/prog.php?type=konsert">Konsert</a></li>
<li><a href="http://studentersamfundet.no/prog.php?type=debatt">Debatt</a></li>
<li><a href="http://studentersamfundet.no/prog.php?type=film">Film</a></li>
<li><a href="http://studentersamfundet.no/prog.php?type=fest">Fest</a></li>
<li><a href="http://studentersamfundet.no/prog.php?type=teater">Teater</a></li>
<li><a href="http://studentersamfundet.no/prog.php?type=annet">Annet</a></li>
<li><a href="http://studentersamfundet.no/konsepter.php">Konsepter</a></li>
<li><a href="http://studentersamfundet.no/booking.php">Booking</a></li>
</ul>
</div>
</li>
<li id="foreninger-meny"><a href="http://studentersamfundet.no/foreninger.php">Foreninger</a>
<div class="sub-menu">
<ul>
<li><a href="http://studentersamfundet.no/foreninger.php">Foreninger</a></li>
</ul>
</div>
</li>
<li id="forum-meny"><a href="http://studentersamfundet.no/forum/index.php">Forum</a>
<div class="sub-menu">
<ul>
<li><a href="http://studentersamfundet.no/forum/viewforum.php?f=68">Musikk</a></li>
<li><a href="http://studentersamfundet.no/forum/viewforum.php?f=69">Debatt</a></li>
<li><a href="http://studentersamfundet.no/forum/viewforum.php?f=70">Fritt forum</a></li>
</ul>
</div>
</li>
<li id="inside-meny" class="current"><a href="https://www.studentersamfundet.no/inside">For medlemmer</a>
<div class="sub-menu">
<ul>
<li><a href="https://www.studentersamfundet.no/inside/">Inside</a></li>
<li><a href="http://studentersamfundet.no/viteboka/?page_id=3">Viteboka</a></li>
<li><a href="https://www.studentersamfundet.no/inside/index.php?page=display-barshifts-calendar">Tappet&aring;rnets vaktliste</a>
<li><a href="http://studentersamfundet.no/aktive.php">Andre ressurser</a></li>
</ul>
</div>
</li>
<li id="nyheter-meny"><a href="http://studentersamfundet.no/nyheter.php">Nyheter</a>
<div class="sub-menu">
<ul>
</ul>
</div>
</li>
</ul>
</div> <!-- #menu -->
</div> <!-- #header -->
<div id="content-wrap">
<?php
include("menu.php");
?>
<div id="content" class="clearfix">
+38
View File
@@ -0,0 +1,38 @@
<?php
// get access manager
$manager = App_Base_ApplicationRegistry::getAccessManager();
?>
<div id="nav">
<a class="skip-nav" href="#content">hopp til innhold</a>
<ul id="navList">
<?php
if ($manager->getCommandAccess("view-shifts")) {
?>
<li class="menulist">
<a href="#" id="quickSwitch" class="switch">vaktliste</a>
<ul id="quickMenu" class="menu">
<li><a href="<?=$_SERVER["PHP_SELF"]?>?cmd=view-shifts">vis mine vakter</a></li>
<li><a href="<?=$_SERVER["PHP_SELF"]?>?cmd=view-calendar">vis kalender</a></li>
<?php
if ($manager->getCommandAccess("add-shift")) {
?>
<li><a href="<?=$_SERVER["PHP_SELF"]?>?cmd=add-shift">legg til nye vakter</a></li>
<?php
}
?>
</ul>
</li>
<?php
}
?>
</ul>
<?php
if ($manager->getCommandAccess("logout")) {
?>
<a href="<?=$_SERVER["PHP_SELF"]?>?cmd=logout">logg ut</a>
<?php
}
?>
</div>
+10
View File
@@ -0,0 +1,10 @@
<?php
//require_once( "App/Base/Registry.php" );
class App_View_ViewHelper {
static function getRequest() {
return App_Base_RequestRegistry::getRequest();
}
}
?>
+37
View File
@@ -0,0 +1,37 @@
<?php
$request = App_View_ViewHelper::getRequest();
$currentUser = $request->getObject('currentUser');
//$venue = $request->getObject('venue');
include_once("Calendar.php");
$calendar = new Calendar("barshifts");
//$month = scriptParam("month");
if (!empty($month)){
$year = substr($month, 0, 4);
$month = substr($month, 4, 2);
}else {
$year = date("Y");
$month = date("m");
}
include("Common/header.php");
?>
<div>
<?php
print "<h1>Vaktliste for " . $month . " " . $year . "</h1>\n";
print $request->getFeedbackString("<br />");
$calendar->display($year, $month);
?>
</div>
<?php
include("Common/footer.php");
?>
+49
View File
@@ -0,0 +1,49 @@
<?php
$request = App_View_ViewHelper::getRequest();
include("Common/header.php");
?>
<div>
<h1>Velkommen til vaktlisten!</h1>
<p>Du må være logget inn for å kunne gjøre noe her.</p>
<?php
if (count($request->getFeedback()) > 0) {
print "<div class=\"messages\">\n";
print " <h3>Beskjeder</h3>\n";
print " <ul>\n";
print " <li>" . $request->getFeedbackString("</li>\n <li>") . "</li>\n";
print " </ul>\n";
print "</div>\n";
}
?>
<div class="contentElem">
<form method="post" action="<?=$_SERVER['PHP_SELF']?>?cmd=login">
<table>
<tr>
<td class="label"><label for="username">brukernavn</label></td>
<td><input type="text" name="username" id="username" size="12" maxlength="12" /></td>
</tr>
<tr>
<td class="label"><label for="password">passord</label></td>
<td><input type="password" name="password" id="password" size="12" maxlength="50" /></td>
</tr>
<tr>
<td>&nbsp;</td>
<td><input type="submit" value="logg inn" class="submit" /></td>
</tr>
</table>
</form>
</div>
<p>Mangler du brukernavn eller passord? <a href="https://www.studentersamfundet.no/inside/">Få tilsendt brukernavn og passord hvis du er registrert fra før</a>, eller <a href="https://www.studentersamfundet.no/inside/index.php?page=register-user">registrér deg</a>!</p>
</div>
<?php
include("Common/footer.php");
?>
+14
View File
@@ -0,0 +1,14 @@
<html>
<head>
<title>Apptest</title>
</head>
<body>
<h1>Welcome</h1>
<?php
foreach (App_Base_RequestRegistry::getRequest()->getFeedback() as $feedback) {
print $feedback . "<br>";
}
?>
</body>
</html>
+21
View File
@@ -0,0 +1,21 @@
<?php
$request = App_View_ViewHelper::getRequest();
$currentUser = $request->getObject('currentUser');
//$venue = $request->getObject('venue');
include("Common/header.php");
?>
<div>
<h1>Velkommen til vaktlisten!</h1>
<?php
print "<p>Du er logget inn som " . $currentUser->getName() . ".</p>\n";
print $request->getFeedbackString("</td></tr><tr><td>");
?>
</div>
<?php
include("Common/footer.php");
?>
+189
View File
@@ -0,0 +1,189 @@
<?php
Class Calendar {
var $type;
function Calendar($type){
$this->__construct($type);
}
public function __construct($type){
$this->type = $type;
}
public function display($year, $month){
$previousYear = $year -1 . $month;
$previousMonth = date("Ym", strtotime("-1 month", strtotime("$year-$month-01")));
$nextMonth = date("Ym", strtotime("+1 month", strtotime("$year-$month-01")));
$nextYear = $year +1 . $month;
$fDate = "$year-$month-01";
$dayOfWeek = date("w", strtotime("$year-$month-01"));
if ($dayOfWeek == "0"){
$dayOfWeek = 7;
}
$lastDayOfMonth = date("t", strtotime("$year-$month-01"));
$weekNumber = date("W", strtotime("$year-$month-01"));
?>
<div id="calHeader">
<div id="previous">
<a href="index.php?section=<?php print $this->type; ?>&amp;page=display-<?php print $this->type; ?>-calendar&amp;month=<?php print $previousYear; ?>">
&lt;&lt;</a>
<a href="index.php?section=<?php print $this->type; ?>&amp;page=display-<?php print $this->type; ?>-calendar&amp;month=<?php print $previousMonth; ?>">
&lt;</a>
</div>
<div id="next">
<a href="index.php?section=<?php print $this->type; ?>&amp;page=display-<?php print $this->type; ?>-calendar&amp;month=<?php print $nextMonth; ?>">
&gt;</a>
<a href="index.php?section=<?php print $this->type; ?>&amp;page=display-<?php print $this->type; ?>-calendar&amp;month=<?php print $nextYear; ?>">
&gt;&gt;</a>
</div>
<h2><?php print(strftime("%B - %Y", strtotime($fDate))); ?></h2>
</div>
<?php $this->_displayCalendarOptions(); ?>
<table class="calendar">
<tr>
<th>Uke</th>
<th>Mandag</th>
<th>Tirsdag</th>
<th>Onsdag</th>
<th>Torsdag</th>
<th>Fredag</th>
<th>Lørdag</th>
<th>Søndag</th>
</tr>
<tr>
<td class="weekNumber"><?php print $weekNumber; ?></td>
<?php
$i = 1;
$date = 1;
$diff = $dayOfWeek;
while ($i++ < $dayOfWeek){
$offset = --$diff;
$this->printPassiveDay(date("d", strtotime("$year-$month-01 -$offset days")));
}
// $row = $list->fetchRow(DB_FETCHMODE_ORDERED);
while ($date <= $lastDayOfMonth) {
$this->printOpenActiveDay($date);
/* while ($row != NULL && $row[2] == $date){
switch ($this->type){
case 'events':
?>
<div>
<a href="index.php?section=<?php print $this->type; ?>&amp;page=display-event&amp;eventid=<?php print $row[0]; ?>">
<?php print $row[1]; ?>
</a>
<!--<?php $this-<displayOptionsMenuCalendar($row[0], EVENT, "event", "view-edit-options-event", "$year$month"); ?>-->
</div>
<?php
break;
case 'concerts':
?>
<div>
<a href="index.php?section=<?php print $this->type; ?>&amp;page=display-concert&amp;concertid=<?php print $row[0]; ?>">
<?php print $row[1]; ?>
</a>
<!--<?php $this->displayOptionsMenuCalendar($row[0], CONCERT, "concert", "view-edit-options-concert", "$year$month"); ?>-->
</div>
<?php
break;
case 'all':
?>
<div class="calendar-<?php print $row[3]; ?>">
<a href="index.php?section=<?php print $this->type; ?>&amp;page=display-<?php print $row[3]."&amp;".$row[3]."id=".$row[0]; ?>">
<?php print $row[1]; ?>
</a>
</div>
<?php
break;
case 'barshifts':
$barshift = new BarShift($row[0]);
$barshift->displayCalendar($year, $month);
break;
}
//$row = $list->fetchRow(DB_FETCHMODE_ORDERED);
}
*/
$this->printCloseActiveDay();
$date++;
if ($i++ % 7 == 1){
$weekNumber = date("W", strtotime("$year-$month-$date"));
print("</tr><tr><td class=\"weekNumber\">".$weekNumber."</td>");
}
}
$date = 1;
while ($i++ % 7 != 1){
$this->printPassiveDay($date++);
}
$this->printPassiveDay($date++);
?>
</tr>
</table>
<?php
}
public
function _displayCalendarOptions(){
switch ($this->type){
case 'events':
break;
case 'concerts':
break;
case 'all':
?>
<div>
<label class="calendar-event button" ><input type="checkbox" id="calendar-toggle-events"
onclick="toggleElements('div', 'calendar-event', this);"
checked="checked" />
interne arrangementer</label><br />
<label class="calendar-concert button"><input type="checkbox" id="calendar-toggle-concerts"
onclick="toggleElements('div', 'calendar-concert', this);"
checked="checked" />
åpne arrangementer</label>
</div>
<?php
break;
case 'barshifts':
?>
<div>
<label class="calendar-barshifworker button" ><input type="checkbox" id="calendar-toggle-barshiftworkers"
onchange="toggleElements('ul', 'barshift-workers', this);"
checked="checked" />
vis personell</label><br />
</div>
<?php
break;
default:
return;
}
}
function printPassiveDay($day) {
print ("<td class=\"passive\"><h4>$day</h4></td>");
}
function printOpenActiveDay($day) {
print ("<td class=\"active\"><h4>$day</h4>");
}
function printCloseActiveDay() {
print ("</td>");
}
}
?>
+38
View File
@@ -0,0 +1,38 @@
<?php
error_reporting(E_ALL);
ini_set('display_errors', 1);
set_include_path(get_include_path() . PATH_SEPARATOR . "./");
//require("App/Support/autoloader.php");
require("App/Base/Registry.php");
require("App/Base/ApplicationRegistry.php");
require("App/Base/RequestRegistry.php");
require("App/Base/SessionRegistry.php");
require("App/Command/Command.php");
require("App/Command/CommandHelper.php");
require("App/Command/DefaultCommand.php");
require("App/Controller/AccessManager.php");
require("App/Controller/AppController.php");
require("App/Controller/ApplicationHelper.php");
require("App/Controller/Controller.php");
require("App/Controller/ControllerMap.php");
require("App/Controller/Request.php");
require("App/Domain/DomainObject.php");
require("App/Domain/HelperFactory.php");
require("App/Domain/ObjectWatcher.php");
require("App/Mapper/Collection.php");
require("App/Mapper/DomainObjectFactory.php");
require("App/Mapper/Mapper.php");
require("App/View/ViewHelper.php");
require("App/Domain/User.php");
require("App/Mapper/UserCollection.php");
require("App/Mapper/UserMapper.php");
require("App/Mapper/UserObjectFactory.php");
//$app = new App_Controller_Controller();
App_Controller_Controller::run();
?>