function open($save_path, $session_name) { //echo "open($save_path, $session_name)<br />"; someloader('some.database.row'); $this->row = SomeRow::getRow('session'); return true; }
/** * @return true if user is created, false if not. */ public function create() { $user = SomeFactory::getUser(); if ($user->getUserrole() === SomeUser::ROLE_HEADTEACHER) { someloader('some.user.user'); $someuser = new SomeUser(); $this->userdata = array('username' => SomeRequest::getVar('tunnus', ''), 'fname' => SomeRequest::getVar('etunimi', ''), 'lname' => SomeRequest::getVar('sukunimi', ''), 'unit' => SomeRequest::getVar('yksikko', ''), 'email' => SomeRequest::getVar('sposti', ''), 'phone' => SomeRequest::getVar('puh', ''), 'password' => SomeRequest::getVar('salasana', '')); $someuser->setUsername($this->userdata['username']); // DO THE PASSWORD HASHING HERE $someuser->setPassword($this->userdata['password']); $someuser->setUserrole('teacher'); $this->userdata['userrole'] = $someuser->getUserrole(); $someuser->create(); //Yritetään lisäksi tehdä uusi tuutori $db = SomeFactory::getDBO(); $stmt = $db->prepare("INSERT INTO tuutori VALUES(?, ?, ?, ?, ?, ?, 'Tuutori')"); $ok = $stmt->execute(array($this->userdata['username'], $this->userdata['fname'], $this->userdata['lname'], $this->userdata['email'], $this->userdata['phone'], $this->userdata['unit'])); if ($someuser->getId() > 0 && $ok > 0) { $this->userdata['id'] = $someuser->getId(); return true; } else { return false; } } }
<?php someloader('some.application.view'); class SomeViewInfo extends SomeView { public function display($tmpl = null) { $model = $this->getModel(); $this->confwritable = $model->isConfigurationWriteable(); $this->dpengineselected = $model->isDbSelected(); $conf_array = $model->getConfiguration(); $this->databasedriver = $conf_array['database']['databasedriver']; $this->databasehost = $conf_array['database']['databasehost']; $this->database = $conf_array['database']['database']; $this->dbuser = $conf_array['database']['dbuser']; $this->dbpass = $conf_array['database']['dbpass']; $this->connected = $model->getConnected(); $this->errors = $model->getErrors(); $this->issomeuserinstalled = $model->getSomeuserStatus(); if ($this->issomeuserinstalled) { $this->someuserstatus = 'SomeUser table is installed'; $this->someuseraction = '<span class="greenok">No action required.</span>'; } else { $this->someuserstatus = 'SomeUser table is NOT installed'; $this->someuseraction = '<a href="index.php?app=configuration&cntr=install&view=install&table=someuser"><span class="redfail">INSTALL</span></a>'; } $this->issomesessioninstalled = $model->getSomesessionStatus(); if ($this->issomesessioninstalled) { $this->somesessionstatus = 'Somesession table is installed'; $this->somesessionaction = '<span class="greenok">No action required.</span>'; } else {
<?php /** * @package content * @subpackage account */ someloader('some.application.model'); /** * @package content * @subpackage account */ class SomeModelTest extends SomeModel { public $results; public function __construct(array $options = array()) { parent::__construct($options); } public function prepare() { //if run test, run test $runtest = SomeRequest::getVar('runtest', 0); if ($runtest) { $this->runtest(); } } public function runtest() { //create someuser just to test, so do not get from factory //create $someuser = new SomeUser();
<?php /** * This is controller file. * @package content * @subpackage account */ someloader('some.application.controller'); /** * This is controller file. * @package content * @subpackage account */ class SomeControllerDefault extends SomeController { /** * default flow function. * if no view is set, register form is shown. If the user is not logged in. * */ function display() { // if the user is logged in, then it is sort of wrong to show register form... $user = SomeFactory::getUser(); if (!$user->getId()) { $view = SomeRequest::getVar('view', 'register'); $model = $this->getModel($view); $view = $this->getView($view); $tmpl = SomeRequest::getVar('tmpl', 'default'); $view->setModel($model); $view->display($tmpl);
<?php someloader("some.application.controller"); class SomeControllerStudentHops extends SomeController { public function display() { $model = $this->getModel('default'); $view = $this->getView('default'); $view->setModel($model); $view->display(); } public function listHops() { //Listataan hopsit jotka on taytetty ja linkki mahdolliseen uuteen lomakepohjaan. $model = $this->getModel('hops'); $model->listHops(); $view = $this->getView('hops'); $view->setModel($model); $view->display('list'); } public function fillHops() { //Hopsin täyttäminen $model = $this->getModel('hops'); $model->doHopsForm(); $view = $this->getView('hops'); $view->setModel($model); $view->display('fill'); } public function showFilled()
* @access public * @param format The format string * @param mixed Mixed number of arguments for the sprintf function */ public static function printf($string) { $lang = SomeFactory::getLanguage(); $args = func_get_args(); if (count($args) > 0) { $args[0] = $lang->_($args[0]); return call_user_func_array('printf', $args); } return ''; } } someloader('some.rbac.rbac'); /** * class SomeAuth to authenticate users and action */ class SomeAuth { public static function _($user, $action = 'none') { $rbac = SomeRbac::getInstance(); $role = $user->getUserrole(); return $rbac->hasAccess($role, $action); } } class SomeUri { public static function getScheme()
public function delete() { //echo "delete()<br />"; //var_dump($this); someloader('some.database.row'); $userrow = SomeRow::getRow('user'); $userrow->id = $this->id; $userrow->delete(); //var_dump($userrow); }
/** * SOME_PATH */ define('SOME_PATH', dirname(__FILE__)); /** */ require_once SOME_PATH . DIRECTORY_SEPARATOR . 'includes' . DIRECTORY_SEPARATOR . 'defines.php'; /** */ require_once SOME_PATH . DS . 'includes' . DS . 'someexception.php'; #/** */ #require_once( SOME_PATH.DS.'includes'.DS.'errorhandler.php' ); try { /** * initialize someloader() */ require_once SOME_LIBRARY . DS . 'loader.php'; someloader('some.csrf.csrf'); /** * more initializing, library classes that are always loaded. * trying to get framework. Failing to do so means that there is bugs or something broken at the server. */ require_once SOME_LIBRARY . DS . 'some' . DS . 'common.php'; $framework = SomeFactory::getApplication(); $debug = $framework->getDebug(); } catch (SomeException $e) { //get error template from root and exit, can not even build require SOME_PATH . DS . 'error.php'; exit; } catch (Exception $e) { require SOME_PATH . DS . 'error.php'; exit; }
public static function getDocument() { someloader('some.document.documenthtml'); if (!class_exists('SomeDocumentHTML')) { throw new SomeFrameworkException('Can not create instance from non-existing class SomeDocumentHTML.'); } return SomeDocumentHTML::getInstance(); }