Пример #1
0
 public function remove()
 {
     $articles = $this->getArticles();
     // Change the author of each article to be able to keep it
     foreach ($articles as $article) {
         $article->prop('author', null);
         Model_Articles::update($article);
     }
     $this->deleteById($this->getId());
 }
Пример #2
0
 protected function setPublishStatus($id, $published)
 {
     $article = Model_Articles::getById($id);
     if (empty($article)) {
         $this->response->status(404)->redirectToFullErrorPage(false)->set(\Eliya\Tpl::get('admin/articles/edit/not_found'));
         return;
     }
     $author_is_current_user = $article->load('author')->equals($this->_currentUser);
     $can_publish_other_articles = $this->_currentUser->hasPermission(Model_Groups::PERM_PUBLISH_OTHER_ARTICLES);
     if (!$author_is_current_user && !$can_publish_other_articles) {
         $this->response->error('Vous ne pouvez pas modifier la publication de cet article.', 403);
         return;
     }
     $date_publication = $article->prop('date_publication');
     if ($published && empty($date_publication)) {
         $article->prop('date_publication', $_SERVER['REQUEST_TIME']);
     }
     $article->prop('is_published', $published);
     // Don't forget to load category to not erase it!
     $article->load('category');
     Model_Articles::update($article);
     $this->response->redirect($this->request->getBaseURL() . 'articles?id_article=' . $id, 200);
 }