Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- class Page extends Controller
- {
- public function __construct()
- {
- //Load predefined objects that will be used
- //throughout the controller
- $this->captcha = self::loadLibrary('captcha');
- $this->image = self::loadLibrary('image');
- $this->session = self::loadLibrary('session');
- //We have our session object now check if a user is logged in
- //and call up the member control
- if( $this->session->isPresent('userSession') )
- {
- $this->user = Modal::Load('user');
- }
- }
- public function login()
- {
- $username = $this->request->username;
- $password = $this->request->password;
- $user = Modal::Load(
- 'user',
- array(
- 'username' => $username,
- 'password' => $password
- )
- );
- //UserModal is easy discernable as all loaded modals follow the same convention
- if( $user instanceof UserModal )
- {
- $this->session->storeObject(
- 'userSession',
- $user
- );
- }
- }
- public function register($user, $password, $email)
- {
- $register = Modal::Load('register');
- //The modal has required properties which must be filled
- $register->username = $user;
- $register->password = $password;
- $register->email = $email;
- //here we define properties which are completely unique and determined only by the programmer
- $register->totalluniqueproperty = 'foo';
- $register->anotheruniqueone = 'doothis';
- //We must save
- if( !$register->save() )
- {
- //Do your error handling here
- $errors = $register->getErrors();
- return;
- }
- //Go about success
- }
- public function randomPage()
- {
- $genericData = Modal::Load('generic');
- $genericData->datapeice1 = 'foo';
- $genericData->datapeice2 = 'foof';
- $genericData->name = 'fofof';
- $genericData->save();
- $genricCopy = Modal::Load(
- 'generic',
- array(
- 'datapeice2' => 'foof'
- )
- );
- //We now have an exact copy of the object above because it was saved
- }
- }
Add Comment
Please, Sign In to add comment