protected function setUp() { // Setup some variables that will be used throughout this method. $title = 'Blog Bug 409 [' . Core::RandomHex(6) . ']'; $this->blog = new BlogModel(); $this->blog->set('title', $title); // Make sure the page model has been loaded into this model too. $page = $this->blog->getLink('Page'); $page->set('title', $title); $this->blog->save(); $bacon = new BaconIpsumGenerator(); // Create an article with an invalid title. $this->article = new BlogArticleModel(); $this->article->setFromArray(['blogid' => $this->blog->get('id'), 'title' => 'Sömé "ḮnvÁlid" & \'Bad\' T¹tle!¡', 'body' => $bacon->getParagraphsAsMarkup(), 'status' => 'published']); $this->article->save(); }
/** * Shortcut for unpublishing an article. */ public function article_unpublish() { $view = $this->getView(); $request = $this->getPageRequest(); $blog = new BlogModel($request->getParameter(0)); if (!$blog->exists()) { return View::ERROR_NOTFOUND; } $manager = \Core\user()->checkAccess('p:/blog/manage_all'); $editor = \Core\user()->checkAccess($blog->get('manage_articles_permission ')) || $manager; if (!$editor) { return View::ERROR_ACCESSDENIED; } $article = new BlogArticleModel($request->getParameter(1)); if (!$article->exists()) { return View::ERROR_NOTFOUND; } if ($article->get('blogid') != $blog->get('id')) { return View::ERROR_NOTFOUND; } if (!$request->isPost()) { return View::ERROR_BADREQUEST; } // Is this article already published? if ($article->get('status') == 'draft') { Core::SetMessage('Article is already in draft mode!', 'error'); \Core\go_back(); } $article->set('status', 'draft'); $article->save(); Core::SetMessage('Unpublished article successfully!', 'success'); \Core\go_back(); }