public function index() { if (!empty(AuthenticationHandler::$data)) { Go::to('a'); } $f = new Form('search'); $this->addForm('search', $f); $this->setTitle('Savely.co'); $this->addScript('Dabox'); $this->addScript('Request'); $this->addScript('StageChart'); $form_register = new Form('register'); if ($form_register->isValid()) { $values = $form_register->getValues(); } $this->addForm('register', $form_register); $form = new Form('login'); if ($form->isValid()) { $values = $form->getValues(); if (AuthenticationHandler::setUserSession($values['login'], $values['password'])) { Go::to('a'); } else { $this->addContent('login_error', Dictionary::term('login.error.unknown_user')); } } $m = new ModelLink(); $all = $m->retrieveLinksHome(); $this->addContent('products', $all); $this->addForm('login', $form); }
public function index() { $this->addScript('Dabox'); $this->addScript('Request'); $this->addScript('M4Tween'); $this->addScript('StageChart'); $this->setTitle('feed - Savely.co'); $f = new Form('addEntry'); if ($f->isValid()) { $values = $f->getValues(); $url = $values['url']; $this->model_link->addState($url, AuthenticationHandler::$data['id_user']); } $this->addContent('user_links', $this->model_link->retrieveLinksByUser(AuthenticationHandler::$data['id_user'])); }
public function password() { $this->setTitle('Change your password - Savely.co'); $f = new Form('password'); if ($f->isValid()) { $v = $f->getValues(); if (ModelAuthentication::getInstance()->changePassword($v['currentPassword'], $v['newPassword'])) { AuthenticationHandler::unsetUserSession(); AuthenticationHandler::setUserSession(ModelAuthentication::getInstance()->getLogin(), $v['newPassword']); $this->addContent('confirmation', 'New Password Saved'); } else { $this->addContent('error', 'You current password does not match'); } } else { $this->addContent('error', $f->getError()); } $this->addForm('password', $f); }
public function share() { Autoload::addComponent("Achilles.share"); $this->setTitle("Submit a link"); /** @var AuthenticationHandler $auth */ $auth = Application::getInstance()->authenticationHandler; if (!$auth::is(AuthenticationHandler::USER)) { Go::to404(); } $m = new ModelPost(); $form = new Form("post_share"); if ($form->isValid()) { $v = $form->getValues(); $insertedPermalink = $m->share($v); Header::location('post/' . $insertedPermalink); } else { $this->addContent("error", $form->getError()); } $this->addForm("share", $form); }
public function sign_in() { $this->setTitle("Sign in"); //todo redirect if logged $authHandler = Application::getInstance()->authenticationHandler; $f = new Form('signin'); if ($f->isValid()) { $data = $f->getValues(); $authHandlerInst = call_user_func_array(array($authHandler, 'getInstance'), array()); if ($authHandlerInst->setUserSession($data["login_user"], $data["password_user"])) { Go::to(); } else { Logs::write("Tentative de connexion au front <" . $data["login_user"] . ":" . $data["password_user"] . ">", Logs::WARNING); $this->addContent("error", "Le login ou le mot de passe est incorrect"); } } else { trace("aaaah"); trace($f->getError()); $this->addContent('error', $f->getError()); } $this->addForm('sign_in', $f); }
/** * Méthode de modification d'une entrée * Récupère les données via le model et les injecte dans le formulaire * @return boolean */ public function edit() { if (!$this->actions->isEnabled('edit')) { Go::to404(); } $this->setTitle($this->titles->get('edit')); try { $form = new Form($this->formName); } catch (Exception $e) { $form = new Form($this->formName, false); $inputs = $this->model->generateInputsFromDescribe(); foreach ($inputs as $nam => $inp) { $form->setInput($nam, $inp); } } $data = $this->model->getTupleById($_GET["id"]); if (!$data) { Go::to($this->className); } $form->injectValues($data); if ($form->isValid()) { if ($this->model->updateById($_GET["id"], $form->getValues())) { $this->addContent("confirmation", Dictionary::term("backoffice.forms.editDone")); $this->dispatchEvent(new Event(self::EVENT_SUCCESSFUL_EDIT)); } else { $this->addContent("error", Dictionary::term("backoffice.forms.errorSQL")); $this->dispatchEvent(new Event(self::EVENT_FAILED_EDIT)); } $id = $_GET["id"]; $form->setUploadFileName($id); } else { $this->addContent("error", $form->getError()); } $this->setTemplate("default", "form"); $this->addContent("id", $this->model->id); $this->addForm("instance", $form); $this->addContent("h1", $this->h1->get('edit')); }