/** Specify user model */ function setModel($model, $login_field = 'email', $password_field = 'password') { parent::setModel($model); $this->login_field = $login_field; $this->password_field = $password_field; // Load model from session if ($this->info && $this->recall("id")) { if ($this->recall('class', false) == get_class($this->model)) { $this->debug("Loading model from cache"); $this->model->set($this->info); $this->model->dirty = array(); $this->model->id = $this->recall('id', null); } else { // Class changed, re-fetch data from database $this->debug("Class changed, loading from database"); $this->model->tryLoad($this->recall('id')); if (!$this->model->loaded()) { $this->logout(false); } $this->memorizeModel(); } } $t = $this; // If model is saved, update our cache too, but don't store password $this->model->addHook('afterSave', function ($m) use($t) { // after this model is saved, re-cache the info $tmp = $m->get(); unset($tmp[$t->password_field]); $t->memorize('info', $tmp); }); $this->addEncryptionHook($this->model); if (strtolower($this->api->page) == 'logout') { $this->logout(); $this->api->redirect('/'); } return $this->model; }
/** * Allows use of models. Define a model with fields: * - rule * - target * - params (comma separated) * * and content of that model will be used to auto-fill routing */ function setModel($model) { $model = parent::setModel($model); foreach ($model as $rule) { $this->addRule($rule["rule"], $rule["target"], explode(",", $rule["params"])); } return $this; }
function setModel($m) { parent::setModel($m); $this->api->addHook('localizeString', $this); $this->api->translation = $this; }
function setModel($model, $login_field = 'email', $password_field = 'password') { parent::setModel($model); $this->login_field = $login_field; $this->password_field = $password_field; return $this->model; }
/** * Allows use of models. Define a model with fields: * - rule * - target * - params (comma separated). * * and content of that model will be used to auto-fill routing */ public function setModel($model) { /** @type Model $model */ $model = parent::setModel($model); foreach ($model as $rule) { $this->addRule($rule['rule'], $rule['target'], explode(',', $rule['params'])); } // @todo Consider to return $model instead of $this like we do in setModel method of all other classes return $this; }
public function setModel($model) { $m = $this->add($model); //If model is empty, load data from files if (!$m->count()->getOne()) { $m = $this->fillFromFile($m); } parent::setModel($m); }