/** * Save the login. * Set a new cryptic, save the DB user and save it in session. * * @param boolean $cookieStayConnected Indicats if the stay connected cookie should be set */ protected function saveLogin($cookieStayConnected = false) { $crypticKey = $this->cfg->getInArray('fields', 'cryptic'); $cryptic = $this->cryptPass(uniqid(), 'Cryptic'); $this->user->set($crypticKey, $cryptic); $this->user->save(); $this->logFromCryptic($cryptic, $cookieStayConnected); }
protected function addEditForm($action, $id = null) { $uAction = ucfirst($action); $this->row = $id ? $this->table->find($id) : $this->table->getRow(); if (!$this->row) response::getInstance()->redirect($this->indexPage); if ($action == 'duplic') { $tmp = $this->row; $this->row = $this->table->getRow(); $this->row->setValues($tmp->getValues()); $this->row->setValues($tmp->getValues('flat')); $action = 'add'; } $this->hook($action); $this->form = $this->row->getForm($this->getFields($action), array_merge(array('sectionName'=>tr::__('scaffold_'.$action)), $this->cfg->formOpts)); $this->hook('formInit'); $this->hook('formInit'.$uAction); if (request::isPost()) { $this->form->refill(); $this->hook('formPost'.$uAction); if ($this->form->isValid()) { $this->row->setValues($this->form->getValues()); $this->hook('before'.$uAction); if ($this->row->save()) { $this->hook('after'.$uAction); response::getInstance()->redirect($this->indexPage); } } else $this->setViewVar('errors', $this->form->getErrors()); } $this->form->setSubmitText(tr::__('scaffold_'.$action)); $this->form->setSubmitplus('<a href="'.$this->indexPage.'">'.tr::__('scaffold_back').'</a>'); $this->hook('form'.$uAction); $this->setViewVars(array( 'row'=>$this->row, 'form'=>$this->form )); }