Initial import of tasks application
This initial import is a heavily modified version of the code I had here, as Arse was modified for other purposes in the meantime and the application no longer worked with it. In addition: * I did not import the user management part yet, * task dependencies are supported in-base, but there is no interface for that yet.
This commit is contained in:
commit
9677ad4dd3
36 changed files with 3919 additions and 0 deletions
includes/t-basics
121
includes/t-basics/controllers.inc.php
Normal file
121
includes/t-basics/controllers.inc.php
Normal file
|
@ -0,0 +1,121 @@
|
|||
<?php
|
||||
|
||||
|
||||
class Ctrl_HomePage
|
||||
extends Controller
|
||||
{
|
||||
|
||||
public final function handle( Page $page )
|
||||
{
|
||||
session_start( );
|
||||
if ( array_key_exists( 'uid' , $_SESSION ) ) {
|
||||
return 'items';
|
||||
} else {
|
||||
return 'login';
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
class Ctrl_Logout
|
||||
extends Controller
|
||||
{
|
||||
|
||||
public function handle( Page $page )
|
||||
{
|
||||
session_start( );
|
||||
session_destroy( );
|
||||
return 'home';
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
class Ctrl_CheckSession
|
||||
extends Controller
|
||||
{
|
||||
private $loginURL;
|
||||
private $sessionKey;
|
||||
|
||||
public function __construct( $url = 'login' , $key = 'uid' )
|
||||
{
|
||||
$this->loginURL = $url;
|
||||
$this->sessionKey = $key;
|
||||
}
|
||||
|
||||
|
||||
public function handle( Page $page )
|
||||
{
|
||||
session_start( );
|
||||
if ( array_key_exists( $this->sessionKey , $_SESSION ) ) {
|
||||
return null;
|
||||
}
|
||||
return $this->loginURL;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
class Ctrl_LogInForm
|
||||
extends Controller
|
||||
{
|
||||
|
||||
public function handle( Page $page )
|
||||
{
|
||||
return Loader::Create( 'Form' , 'Log in' , 'login' )
|
||||
->addField( Loader::Create( 'Field' , 'email' , 'text' )
|
||||
->setDescription( 'E-mail address:' ) )
|
||||
->addField( Loader::Create( 'Field' , 'pass' , 'password' )
|
||||
->setDescription( 'Password:' ) )
|
||||
->setSuccessURL( 'home' )
|
||||
->addController( Loader::Ctrl( 'log_in' ) )
|
||||
->controller( );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
class Ctrl_LogIn
|
||||
extends Controller
|
||||
implements FormAware
|
||||
{
|
||||
|
||||
private $form;
|
||||
|
||||
public function setForm( Form $form )
|
||||
{
|
||||
$this->form = $form;
|
||||
}
|
||||
|
||||
public function handle( Page $page )
|
||||
{
|
||||
$email = $this->form->field( 'email' );
|
||||
$pass = $this->form->field( 'pass' );
|
||||
|
||||
$user = Loader::DAO( 'users' )->checkLogin( $email->value( ) , $pass->value( ) );
|
||||
if ( $user == null ) {
|
||||
$email->putError( 'Invalid credentials.' );
|
||||
return null;
|
||||
}
|
||||
|
||||
$_SESSION[ 'uid' ] = $user->user_id;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
class Ctrl_LoggedOut
|
||||
extends Controller
|
||||
{
|
||||
|
||||
public function handle( Page $page )
|
||||
{
|
||||
session_start( );
|
||||
if ( array_key_exists( 'uid' , $_SESSION ) ) {
|
||||
return 'home';
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue