Example #1
0
 public function testSaveArticle()
 {
     $article = new ArticleDAO();
     $article->save(array("title" => "PHP is Great!", "description" => "Lorem ipsum dolor sit amet", "content" => "Aliquam scelerisque rhoncus porttitor. Nullam eget pulvinar magna. In vel lectus ut diam adipiscing porta vitae id nisi.", "preview_image" => "php.jpg", "section_id" => 1));
     $resultingTable = $this->getConnection()->createQueryTable("articles", "SELECT * FROM articles");
     $expectedTable = $this->createXmlDataSet("expectedArticles.xml")->getTable("articles");
     $this->assertTablesEqual($expectedTable, $resultingTable);
 }
Example #2
0
 function generateProfileArticleRelationship($profilesToCreate)
 {
     if ($profilesToCreate) {
         // chamar serviço de associar palavras do perfil com os artigos
         // deste resultado tratar o xml para
         // gerar registros na tabela de profile_article,
         // associando perfil a PID do artigo
         $trigramaService = new TrigramaService();
         $articleDAO = new ArticleDAO();
         $profileArticleDAO = new ProfileArticleDAO();
         foreach ($profilesToCreate as $newProfile) {
             $subArea = new SubArea();
             $subArea->setID($newProfile->getSubAreaID());
             $subArea->loadSubArea();
             $grandeArea = new GrandeArea();
             $grandeArea->setLang('');
             $grandeArea->setID($newProfile->getGrandeAreaID());
             $grandeArea->loadGrandeArea();
             $trigramaString = "";
             $trigramaString .= $newProfile->getProfileText();
             $trigramaString .= " " . $subArea->getDescricao();
             $trigramaString .= " " . $grandeArea->getDescricao();
             $trigramaService->setParams($trigramaString);
             $articles = $trigramaService->getArticles();
             $profileArticleDAO->setAsDeleted($newProfile->getProfileID());
             foreach ($articles as $article) {
                 $foundArticle = $articleDAO->getArticle($article->getPID());
                 if (!$foundArticle || !$foundArticle->getPID()) {
                     $articleDAO->AddArticle($article);
                 } else {
                     $articleDAO->UpdateArticle($article);
                 }
                 $foundProfileArticle = $profileArticleDAO->getProfileArticle($article->getPID(), $newProfile->getProfileID());
                 $profileArticle = new ProfileArticle();
                 $profileArticle->setPID($article->getPID());
                 $profileArticle->setProfileID($newProfile->getProfileID());
                 $profileArticle->setRelevance($article->getRelevance());
                 if ($foundProfileArticle->getIsNew() == "3") {
                     $profileArticle->setIsNew(0);
                     $profileArticleDAO->UpdateProfileArticle($profileArticle);
                 } else {
                     $profileArticle->setIsNew(1);
                     $profileArticleDAO->AddProfileArticle($profileArticle);
                 }
             }
             $profileArticleDAO->deleteRelationship($newProfile->getProfileID());
         }
     }
 }
 /**
  * Internal function to return a ReviewerSubmission object from a row.
  * @param $row array
  * @return ReviewerSubmission
  */
 function _fromRow($row)
 {
     // Get the ReviewerSubmission object, populated with submission data
     $reviewerSubmission = parent::_fromRow($row);
     // Comments
     $reviewerSubmission->setMostRecentPeerReviewComment($this->submissionCommentDao->getMostRecentSubmissionComment($row['submission_id'], COMMENT_TYPE_PEER_REVIEW, $row['review_id']));
     // Editor Decisions
     $editDecisionDao = DAORegistry::getDAO('EditDecisionDAO');
     $decisions = $editDecisionDao->getEditorDecisions($row['submission_id']);
     $reviewerSubmission->setDecisions($decisions);
     // Review Assignment
     $reviewerSubmission->setReviewId($row['review_id']);
     $reviewerSubmission->setReviewerId($row['reviewer_id']);
     $reviewerSubmission->setReviewerFullName($row['first_name'] . ' ' . $row['last_name']);
     $reviewerSubmission->setCompetingInterests($row['competing_interests']);
     $reviewerSubmission->setRecommendation($row['recommendation']);
     $reviewerSubmission->setDateAssigned($this->datetimeFromDB($row['date_assigned']));
     $reviewerSubmission->setDateNotified($this->datetimeFromDB($row['date_notified']));
     $reviewerSubmission->setDateConfirmed($this->datetimeFromDB($row['date_confirmed']));
     $reviewerSubmission->setDateCompleted($this->datetimeFromDB($row['date_completed']));
     $reviewerSubmission->setDateAcknowledged($this->datetimeFromDB($row['date_acknowledged']));
     $reviewerSubmission->setDateDue($this->datetimeFromDB($row['date_due']));
     $reviewerSubmission->setDateResponseDue($this->datetimeFromDB($row['date_response_due']));
     $reviewerSubmission->setDeclined($row['declined']);
     $reviewerSubmission->setReplaced($row['replaced']);
     $reviewerSubmission->setCancelled((int) $row['cancelled']);
     $reviewerSubmission->setQuality($row['quality']);
     $reviewerSubmission->setRound($row['round']);
     $reviewerSubmission->setStep($row['step']);
     $reviewerSubmission->setStageId($row['stage_id']);
     $reviewerSubmission->setReviewMethod($row['review_method']);
     HookRegistry::call('ReviewerSubmissionDAO::_fromRow', array(&$reviewerSubmission, &$row));
     return $reviewerSubmission;
 }
 /**
  * Run method with main page logic
  * 
  * Read in list of the latest published articles. Pagination enabled.
  * Populate template and display results in the page.
  * @access public
  */
 public function run()
 {
     $PAGINATION_LIMIT = 10;
     $session = Session::getInstance();
     $user = $session->getUser();
     /*
     if ($user == null || !$user->validUser ()) {
         header ("Location: " . BASE_URL);
         return;
     }
     */
     $articleDAO = ArticleDAO::getInstance();
     $tagDAO = ArticleTagDAO::getInstance();
     $page = isset($_GET["page"]) && is_numeric($_GET["page"]) ? intval($_GET["page"]) : 1;
     if ($page < 1) {
         $page = 1;
     }
     $count = $paginator = $paginator_page = null;
     $article = $articletags_array = null;
     $title = "";
     $count = $articleDAO->countPublished(true);
     $paginator = new Paginator($count, $PAGINATION_LIMIT);
     $paginator_page = $paginator->getPage($page);
     $article_array = $articleDAO->allPublished(true, array("order" => "{$articleDAO->getTableName()}.postDate DESC, {$articleDAO->getTableName()}.id DESC", "limit" => $paginator_page, "joins" => true));
     foreach ($article_array as $article) {
         $articletags_array[] = $tagDAO->allArticleTags($article, array("order" => "name"));
     }
     $this->template->render(array("title" => "Latests Articles", "main_page" => "article_list_tpl.php", "session" => $session, "article_array" => $article_array, "articletags_array" => $articletags_array, "paginator_page" => $paginator_page));
 }
 /**
  * Run method with main page logic
  * 
  * Read in the specified article from the database.
  * Populate template and display article in the page
  * @access public
  */
 public function run()
 {
     $session = Session::getInstance();
     $user = $session->getUser();
     /*
     if ($user == null || !$user->validUser ()) {
         header ("Location: " . BASE_URL);
         return;
     }
     */
     $articleDAO = ArticleDAO::getInstance();
     $tagDAO = ArticleTagDAO::getInstance();
     $article = $articletags = null;
     $title = "";
     if (!empty($_GET["id"]) && is_numeric($_GET["id"])) {
         $article_id = intval($_GET["id"]);
         $article = $articleDAO->load($article_id, array("joins" => true));
         if ($article) {
             $title .= "{$article->getTitle()}";
             $articletags = $tagDAO->allArticleTags($article, array("order" => "name"));
         }
     }
     //print_r ($articletags);
     $this->template->render(array("title" => "Article - " . $title, "main_page" => "view_article_tpl.php", "session" => $session, "article" => $article, "articletags" => $articletags));
 }
 /**
  * Run method with main page logic
  * 
  * Populate template and display confirmation for article deletion. For POST request,
  * check user credentials, check if article exists and then delete entry from database.
  * Available to admins only
  * @access public
  */
 public function run()
 {
     $session = Session::getInstance();
     $user = $session->getUser();
     // Check for an admin user
     if (!$user || !$user->isAdmin()) {
         $session->setMessage("Do not have permission to access", Session::MESSAGE_ERROR);
         header("Location: " . BASE_URL);
         return;
     }
     $articleDAO = ArticleDAO::getInstance();
     $delete_article = null;
     $form_errors = array();
     $form_values = array("id" => "");
     if (!empty($_POST)) {
         // Check if a number was passed for the id
         $id = isset($_POST["id"]) && is_numeric($_POST["id"]) ? intval($_POST["id"]) : "";
         if (empty($id)) {
             header("Location: " . BASE_URL);
             return;
         } else {
             $delete_article = $articleDAO->load($id);
             // Article exists. Delete
             if ($delete_article) {
                 if ($articleDAO->delete($delete_article)) {
                     $session->setMessage("Article deleted");
                     //header ("Location: " . BASE_URL);
                     return;
                 } else {
                     $session->setMessage("Could not delete article", Session::MESSAGE_ERROR);
                 }
             }
         }
     } else {
         if (!empty($_GET)) {
             $id = isset($_GET["id"]) ? trim($_GET["id"]) : "";
             if (empty($id)) {
                 header("Location: " . BASE_URL);
                 return;
             } else {
                 if (is_numeric($id)) {
                     $delete_article = $articleDAO->load($id);
                     if ($delete_article) {
                         $form_values["id"] = $delete_article->getId();
                     }
                 }
             }
         } else {
             header("Location: " . BASE_URL);
             return;
         }
     }
     $this->template->render(array("title" => "Delete Article", "main_page" => "delete_article_tpl.php", "user" => $user, "session" => $session, "delete_article" => $delete_article, "form_errors" => $form_errors, "form_values" => $form_values));
 }
 /**
  * Run method with main page logic
  * 
  * Read in articles from the database. Displays an interface to administer article data
  * for allowing bulk deletion of articles, deletion of a single
  * article, links to editing each article entry. Pagination enabled.
  * Available to admins only.
  * @access public
  */
 public function run()
 {
     $PAGINATION_LIMIT = 10;
     $session = Session::getInstance();
     $user = $session->getUser();
     if (!$user || !$user->isAdmin()) {
         $session->setMessage("Do not have permission to access", Session::MESSAGE_ERROR);
         header("Location: " . BASE_URL);
         return;
     }
     $page = isset($_GET["page"]) && is_numeric($_GET["page"]) ? intval($_GET["page"]) : 1;
     if ($page < 1) {
         $page = 1;
     }
     $action = isset($_GET["action"]) ? trim($_GET["action"]) : "";
     $articleDAO = ArticleDAO::getInstance();
     $article_array = $paginator_page = null;
     $content_title = "";
     if (!empty($_POST) && !empty($_POST["ids"]) && !empty($_POST["action"])) {
         $action = isset($_POST["action"]) ? trim($_POST["action"]) : "";
         if (!strcmp($action, "delete") == 0) {
             header("Location: " . BASE_URL);
             return;
         }
         $status = $articleDAO->deleteByIds($_POST["ids"]);
         if ($status) {
             $session->setMessage("Selected pages deleted");
             header("Location: {$_SERVER["PHP_SELF"]}");
             return;
         } else {
             $session->setMessage("Deletion failed", Session::MESSAGE_ERROR);
             header("Location: {$_SERVER["PHP_SELF"]}");
             return;
         }
     } else {
         if (strcmp($action, "delete") == 0 && !empty($_GET["ids"])) {
             $content_title = "Delete Articles";
             $article_array = $articleDAO->allByIds($_GET["ids"]);
         } else {
             if (strcmp($action, "delete") == 0) {
             } else {
                 $count = $articleDAO->count();
                 $paginator = new Paginator($count, $PAGINATION_LIMIT);
                 $paginator_page = $paginator->getPage($page);
                 $article_array = $articleDAO->all(array("limit" => $paginator_page));
             }
         }
     }
     $this->template->render(array("title" => "Admin - Article Options", "main_page" => "article_options_tpl.php", "session" => $session, "article_array" => $article_array, "paginator_page" => $paginator_page, "action" => $action, "content_title" => $content_title));
 }
 public static function getIssuesByJournal($journal)
 {
     $mysql = new Mysql();
     $mysql->connect(Config::$bd_servidor, Config::$bd_esquema, Config::$bd_usuario, Config::$bd_contrasena);
     $query = "select i.issue_id issue_id, i.volume volume, i.number number, i.year year, fojsbus_issuesetting(i.issue_id,'title','es_ES') title\n                from issues i LEFT JOIN custom_issue_orders o ON (o.issue_id = i.issue_id) \n                where i.journal_id=" . $journal->getId() . "\n                and i.published = 1 \n                order by o.seq ASC, i.current DESC, i.date_published DESC;";
     $resultSet = $mysql->query($query);
     $myIssues = array();
     if ($resultSet != false) {
         foreach ($mysql->fetchAll($resultSet) as $issueData) {
             $issue = new Issue($journal, $issueData['issue_id'], $issueData['volume'], $issueData['number'], $issueData['year'], $issueData['title']);
             $issue->setArticles(ArticleDAO::getArticlesByIssue($issue));
             $myIssues[] = $issue;
         }
     }
     if (empty($myIssues)) {
         return null;
     }
     return $myIssues;
 }
Example #9
0
 /**
  * Delete instances of a User entities with the ids specified in the ids array. LEFT JOIN clauses will be added to delete any associated attendance records, pages, articles and events
  *
  * @access public
  * @param array $ids Array containing int ids of User entities to delete
  * @param array $options (Optional) Read documentation on parseOptions for details
  * @return bool Return status of PDOStatement execute method
  */
 public function deleteByIds($ids, $options = null)
 {
     if (!is_array($ids)) {
         throw new InvalidArgumentException("Must pass array of ids as the first parameter");
     }
     // Import associated DAOs
     require_once "Attendance.php";
     require_once "Page.php";
     require_once "Article.php";
     require_once "Event.php";
     $attendDAO = AttendanceDAO::getInstance();
     $pagesDAO = PageDAO::getInstance();
     $articlesDAO = ArticleDAO::getInstance();
     $eventsDAO = EventDAO::getInstance();
     $str = "";
     for ($i = 0; $i < count($ids) - 1; $i++) {
         $str .= "?,";
     }
     $str .= "?";
     // Use LEFT JOIN in case user does not have some entries
     $query = "DELETE FROM {$this->tableName}, {$attendDAO->getTableName()}, {$pagesDAO->getTableName()}, {$articlesDAO->getTableName()}, {$eventsDAO->getTableName()} USING {$this->tableName} LEFT JOIN {$attendDAO->getTableName()} ON {$this->tableName}.id = {$attendDAO->getTableName()}.userId LEFT JOIN {$pagesDAO->getTableName()} ON {$this->tableName}.id = {$pagesDAO->getTableName()}.userId LEFT JOIN {$articlesDAO->getTableName()} ON {$this->tableName}.id = {$articlesDAO->getTableName()}.userId LEFT JOIN {$eventsDAO->getTableName()} ON {$this->tableName}.id = {$eventsDAO->getTableName()}.userId WHERE {$this->tableName}.id IN ({$str})";
     //echo $query;
     $stmt = self::$dbh->prepare($query);
     $params = $ids;
     $status = $stmt->execute($params);
     return $status;
 }
 /**
  * Run method with main page logic
  * 
  * Populate template and display form for editing an article entry. For POST requests,
  * check user credentials, check if article exists and then update entry in database.
  * Available to admins only
  * @access public
  */
 public function run()
 {
     $session = Session::getInstance();
     $user = $session->getUser();
     if (!$user || !$user->isAdmin()) {
         $session->setMessage("Do not have permission to access", Session::MESSAGE_ERROR);
         header("Location: " . BASE_URL);
         return;
     }
     $form_errors = array();
     $form_values = array("id" => "", "title" => "", "content" => "", "postDate" => "", "updateDate" => "", "published" => "", "tags" => "");
     $articleDAO = ArticleDAO::getInstance();
     $tagDAO = ArticleTagDAO::getInstance();
     $article = null;
     if (!empty($_POST)) {
         $form_values["id"] = isset($_POST["id"]) && is_numeric($_POST["id"]) ? intval($_POST["id"]) : "";
         $form_values["title"] = isset($_POST["title"]) ? trim($_POST["title"]) : "";
         $form_values["content"] = isset($_POST["content"]) ? trim($_POST["content"]) : "";
         $form_values["postDate"] = isset($_POST["postDate"]) ? trim($_POST["postDate"]) : "";
         $form_values["updateDate"] = isset($_POST["updateDate"]) ? trim($_POST["updateDate"]) : "";
         $form_values["published"] = isset($_POST["published"]) ? trim($_POST["published"]) : "";
         $form_values["tags"] = isset($_POST["tags"]) ? trim($_POST["tags"]) : "";
         if (empty($form_values["id"])) {
             $form_errors["id"] = "No id specified";
         }
         if (empty($form_values["title"])) {
             $form_errors["title"] = "No title specified";
         }
         if (empty($form_values["content"])) {
             $form_errors["content"] = "No content specified";
         }
         if (empty($form_values["postDate"])) {
             $form_errors["postDate"] = "No post date specified";
         } else {
             if (strtotime($form_values["postDate"]) == 0) {
                 $form_errors["postDate"] = "An invalid post date was specified";
                 $form_values["postDate"] = "";
             }
         }
         if (!empty($form_values["updateDate"]) && strtotime($form_values["updateDate"]) == 0) {
             $form_errors["updateDate"] = "An invalid update date was specified";
             $form_values["updateDate"] = "";
         }
         if ($form_values["published"] != "true" && $form_values["published"] != "false") {
             $form_errors["published"] = "Invalid published choice";
         }
         if (empty($form_errors)) {
             $article = $articleDAO->load($form_values["id"]);
             if ($article && ($user->isAdmin() || $article->userId == $user->id)) {
                 $article->setTitle($form_values["title"]);
                 $article->setContent($form_values["content"]);
                 $article->setPostDate(strtotime($form_values["postDate"]));
                 if (!empty($form_values["updateDate"])) {
                     $article->setUpdateDate(strtotime($form_values["updateDate"]));
                 }
                 //$article->setUpdateDate (time ());
                 $published = $form_values["published"] == "true" ? 1 : 0;
                 $article->setPublished($published);
                 $article->setUserId($user->id);
                 $sorted_tag_array = ArticleTag::tagsFromString($form_values["tags"]);
                 $sorted_tags = implode(" ", $sorted_tag_array);
                 $article->setTags($sorted_tags);
                 //print_r ($article);
                 if ($articleDAO->save($article)) {
                     $tagDAO->updateTags($article);
                     $session->setMessage("Article details saved");
                     header("Location: edit_article.php?id={$article->id}");
                     return;
                 } else {
                     $session->setMessage("Article details could not be saved", Session::MESSAGE_ERROR);
                 }
             } else {
                 $session->setMessage("Do not have permission to edit the article", Session::MESSAGE_ERROR);
                 header("Location: " . BASE_URL);
                 return;
             }
         } else {
             if (empty($form_errors["id"])) {
                 $article = $articleDAO->load($form_values["id"]);
             }
         }
     } else {
         if (!empty($_GET)) {
             $form_values["id"] = isset($_GET["id"]) ? $_GET["id"] : "";
             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));
 }
Example #11
0
 function loadArticle()
 {
     $articleDAO = new ArticleDAO();
     $a = $articleDAO->getArticle($this->getPID());
     $this->setPID($a->getPID());
     $this->setURL($a->getURL());
     $this->setTitle($a->getTitle());
     $this->setSerial($a->getSerial());
     $this->setVolume($a->getVolume());
     $this->setNumber($a->getNumber());
     $this->setSuppl($a->getSuppl());
     $this->setYear($a->getYear());
     $this->setAuthorXML($a->getAuthorXML());
     $this->setKeywordXML($a->getKeywordXML());
     $this->setAbstractXML($a->getAbstractXML());
 }
Example #12
0
 /**
  * creates and returns a published article object from a row
  * @param $row array
  * @param $callHooks boolean Whether or not to call hooks
  * @return PublishedArticle object
  */
 function _fromRow($row, $callHooks = true)
 {
     $publishedArticle = parent::_fromRow($row);
     $publishedArticle->setPublishedArticleId($row['published_submission_id']);
     $publishedArticle->setIssueId($row['issue_id']);
     $publishedArticle->setSequence($row['seq']);
     $publishedArticle->setAccessStatus($row['access_status']);
     $publishedArticle->setGalleys($this->galleyDao->getBySubmissionId($row['submission_id'])->toArray());
     if ($callHooks) {
         HookRegistry::call('PublishedArticleDAO::_returnPublishedArticleFromRow', array(&$publishedArticle, &$row));
     }
     return $publishedArticle;
 }
Example #13
0
 /**
  * Retrieve instance of an ArticleDAO or create one if it does
  * not exist.
  *
  * @access public
  * @static
  * @return ArticleDAO
  */
 public static function getInstance()
 {
     if (!isset(self::$instance)) {
         self::$instance = new self();
     }
     return self::$instance;
 }
 public function testGetArticlesNonHomeNoArticles()
 {
     $articleDAO = new ArticleDAO();
     $articles = $articleDAO->getArticles(2, false);
     $this->assertEquals(array(), $articles);
 }
    /**
     * Update an existing section editor submission.
     * @param $sectionEditorSubmission SectionEditorSubmission
     */
    function updateSectionEditorSubmission(&$sectionEditorSubmission)
    {
        // Update editor decisions
        for ($i = 1; $i <= $sectionEditorSubmission->getCurrentRound(); $i++) {
            $editorDecisions =& $sectionEditorSubmission->getDecisions($i);
            if (is_array($editorDecisions)) {
                foreach ($editorDecisions as $key => $editorDecision) {
                    if ($editorDecision['editDecisionId'] == null) {
                        $this->update(sprintf('INSERT INTO edit_decisions
								(submission_id, round, editor_id, decision, date_decided)
								VALUES (?, ?, ?, ?, %s)', $this->datetimeToDB($editorDecision['dateDecided'])), array($sectionEditorSubmission->getId(), $sectionEditorSubmission->getCurrentRound(), $editorDecision['editorId'], $editorDecision['decision']));
                        $editorDecisions[$key]['editDecisionId'] = $this->_getInsertId('edit_decisions', 'edit_decision_id');
                    }
                }
            }
            unset($editorDecisions);
        }
        // update review assignments
        foreach ($sectionEditorSubmission->getReviewAssignments() as $roundReviewAssignments) {
            foreach ($roundReviewAssignments as $reviewAssignment) {
                if ($reviewAssignment->getId() > 0) {
                    $this->reviewAssignmentDao->updateObject($reviewAssignment);
                } else {
                    $this->reviewAssignmentDao->insertObject($reviewAssignment);
                }
            }
        }
        // Remove deleted review assignments
        $removedReviewAssignments = $sectionEditorSubmission->getRemovedReviewAssignments();
        for ($i = 0, $count = count($removedReviewAssignments); $i < $count; $i++) {
            $this->reviewAssignmentDao->deleteById($removedReviewAssignments[$i]);
        }
        // Update article
        if ($sectionEditorSubmission->getId()) {
            $article = parent::getById($sectionEditorSubmission->getId());
            // Only update fields that can actually be edited.
            $article->setSectionId($sectionEditorSubmission->getSectionId());
            $article->setCurrentRound($sectionEditorSubmission->getCurrentRound());
            $article->setStatus($sectionEditorSubmission->getStatus());
            $article->setDateStatusModified($sectionEditorSubmission->getDateStatusModified());
            $article->setLastModified($sectionEditorSubmission->getLastModified());
            $article->setCommentsStatus($sectionEditorSubmission->getCommentsStatus());
            parent::updateObject($article);
        }
    }
 /**
  * Run method with main page logic
  * 
  * Populate template and display form for creating a new article entry. For POST requests,
  * validate form data and save information to database. Available to admins only
  * @access public
  */
 public function run()
 {
     $session = Session::getInstance();
     $user = $session->getUser();
     if (!$user || !$user->isAdmin()) {
         $session->setMessage("Do not have permission to access", Session::MESSAGE_ERROR);
         header("Location: " . BASE_URL);
         return;
     }
     $form_errors = array();
     $form_values = array("title" => "", "content" => "", "postDate" => "", "published" => "", "tags" => "");
     $articleDAO = ArticleDAO::getInstance();
     $tagDAO = ArticleTagDAO::getInstance();
     if (!empty($_POST)) {
         $form_values["title"] = isset($_POST["title"]) ? trim($_POST["title"]) : "";
         $form_values["content"] = isset($_POST["content"]) ? trim($_POST["content"]) : "";
         $form_values["postDate"] = isset($_POST["postDate"]) ? trim($_POST["postDate"]) : "";
         $form_values["published"] = isset($_POST["published"]) ? trim($_POST["published"]) : "";
         $form_values["tags"] = isset($_POST["tags"]) ? trim($_POST["tags"]) : "";
         if (empty($form_values["title"])) {
             $form_errors["title"] = "No title specified";
         }
         if (empty($form_values["content"])) {
             $form_errors["content"] = "No content specified";
         }
         if (empty($form_values["postDate"])) {
             $form_errors["postDate"] = "No post date specified";
         } else {
             if (strtotime($_POST["postDate"]) == 0) {
                 $form_errors["postDate"] = "An invalid post date was specified";
                 $form_values["postDate"] = "";
             }
         }
         if ($form_values["published"] != "true" && $form_values["published"] != "false") {
             $form_errors["published"] = "Invalid published choice";
         }
         if (empty($form_errors)) {
             $article = new Article();
             $article->setTitle($form_values["title"]);
             $article->setContent($form_values["content"]);
             $article->setPostDate(strtotime($form_values["postDate"]));
             $article->setUpdateDate(0);
             $published = $form_values["published"] == "true" ? 1 : 0;
             $article->setPublished($published);
             $article->setUserId($user->id);
             //$article->setTags ($form_values["tags"]);
             $sorted_tag_array = ArticleTag::tagsFromString($form_values["tags"]);
             $sorted_tags = implode(" ", $sorted_tag_array);
             $article->setTags($sorted_tags);
             if ($articleDAO->insert($article)) {
                 $tagDAO->updateTags($article);
                 $session->setMessage("Article details saved");
                 header("Location: edit_article.php?id={$article->id}");
                 return;
             } else {
                 $session->setMessage("Article details could not be saved", Session::MESSAGE_ERROR);
             }
         }
     }
     $this->template->render(array("title" => "Create Article", "extra_header" => joinPath("headers", "jscal_header_tpl.php"), "main_page" => "create_article_tpl.php", "session" => $session, "form_errors" => $form_errors, "form_values" => $form_values));
 }
 /**
  * Load all instances of ArticleTag entities associated with an Article. Use options array to limit results read.
  *
  * @access public
  * @param Article $article
  * @param array $options (Optional) Read documentation on parseOptions for details
  * @return array
  */
 public function allArticleTags(Article $article, $options = null)
 {
     $articleDAO = ArticleDAO::getInstance();
     $taggedDAO = TaggedArticleDAO::getInstance();
     $this->resetQueryStrings();
     $this->query_reset_lock = true;
     $this->query_joins = " INNER JOIN {$taggedDAO->getTableName()} ON {$taggedDAO->getTableName()}.tagId = {$this->getTableName()}.id INNER JOIN {$articleDAO->getTableName()} ON {$articleDAO->getTableName()}.id = {$taggedDAO->getTableName()}.articleId ";
     $this->query_where = "WHERE {$articleDAO->getTableName()}.id = ?";
     $this->query_params = array($article->getId());
     $result_array = $this->all($options);
     $this->query_reset_lock = false;
     return $result_array;
 }