if (empty($form_values["id"])) { header("Location: " . BASE_URL); return; } else { $article = $articleDAO->load($form_values["id"]); // Article does not exist. Pass null to template if (!$article) { } else { if (!$user->isAdmin() && $article->userId != $user->id) { $session->setMessage("Do not have permission to edit article", Session::MESSAGE_ERROR); header("Location: " . BASE_URL); return; } else { $form_values["id"] = $article->getId(); $form_values["title"] = $article->getTitle(); $form_values["content"] = $article->getContent(); $form_values["published"] = $article->getPublished() == true ? "true" : "false"; $form_values["postDate"] = strftime("%d %B %Y", $article->getPostDate()); $form_values["updateDate"] = $article->getUpdateDate() > 0 ? strftime("%d %B %Y", $article->getUpdateDate()) : ""; $form_values["tags"] = $article->getTags(); } } } } } $this->template->render(array("title" => "Edit Article", "extra_header" => joinPath("headers", "jscal_header_tpl.php"), "main_page" => "edit_article_tpl.php", "session" => $session, "article" => $article, "form_errors" => $form_errors, "form_values" => $form_values)); } } $controller = new EditArticleController(); $controller->run();