/** * * Edit an answer * * @param string $pagekey selects the array with the page-id. * @param $id selects the answer to edit. * */ public function editAction($id, $redirect = '') { $formundo = new \Anax\HTMLForm\CFormCommentUndo($redirect); $formundo->setDI($this->di); $formundo->check(); $undourl = $formundo->getHTML(); $answers = new \Anax\Answer\Answer(); $controller = 'answer'; $answers->setDI($this->di); $answer = $answers->findAnswer(null, $id); $answer = is_object($answer[0]) ? get_object_vars($answer[0]) : $answer; if ($_SESSION['user']->name != ($answer['name'] || 'Administratör')) { header('Location: ' . $this->url->create('users/message/wronguser')); die("Du har inte tillstånd att gå in på den här sidan!"); } $form = new \Anax\HTMLForm\CFormAnswerEdit($id, $answer['content'], $answer['name'], $answer['web'], $answer['mail'], $answer['pagekey'], $redirect); $form->setDI($this->di); $form->check(); $this->theme->setTitle("Redigera svar"); $this->di->views->add('default/page', ['title' => "Redigera svar", 'content' => '<h4>Svar #' . $id . '</h4>' . $form->getHTML() . $undourl], 'main'); }
/** * * Edit an answer * * @param string $pagekey selects the array with the page-id. * @param $id selects the answer to edit. * */ public function editAction($id, $redirect = '') { //$redirect = '/view/'.$redirect; $formundo = new \Anax\HTMLForm\CFormCommentUndo($redirect); $formundo->setDI($this->di); $formundo->check(); $undourl = $formundo->getHTML(); $answers = new \Anax\Answer\Answer(); $controller = 'answer'; $answers->setDI($this->di); $answer = $answers->findAnswer(null, $id); $answer = is_object($answer[0]) ? get_object_vars($answer[0]) : $answer; if ($_SESSION['user']->acronym != ($answer['acronym'] || 'admin')) { header('Location: ' . $this->url->create('users/message/wronguser')); die("You don't have permission to enter this page!"); } $form = new \Anax\HTMLForm\CFormAnswerEdit($id, $answer['content'], $answer['acronym'], $answer['web'], $answer['mail'], $answer['pagekey'], $redirect); $form->setDI($this->di); $form->check(); $this->theme->setTitle("Edit answer"); $this->di->views->add('default/page', ['title' => "Edit answer", 'content' => '<h4>Answer #' . $id . '</h4>' . $form->getHTML() . $undourl], 'main'); }