Пример #1
0
 public function onContentAfterSave($context, $article, $isNew)
 {
     if ($context != 'com_content.form' && $context != 'com_content.article' || !$article->id) {
         return true;
     }
     // delete thumbnail image to avoid wrong thumbnail in listings if article image has changed
     CjBlogHelper::delete_article_thumbnail($article);
     $api = JPATH_ROOT . '/components/com_cjblog/api.php';
     if (file_exists($api)) {
         require_once $api;
         $db = JFactory::getDbo();
         // insert or update tags
         $app = JFactory::getApplication();
         $tags = $app->input->get('tags', array(), 'array');
         $this->insert_tags($article->id, $tags);
         $query = 'select count(*) from #__content where created_by = ' . $article->created_by . ' and state = 1';
         $db->setQuery($query);
         $count = (int) $db->loadResult();
         CjBlogApi::trigger_badge_rule('com_content.num_articles', array('num_articles' => $count, 'ref_id' => $article->created_by), $article->created_by);
         if ($isNew) {
             CjBlogApi::award_points('com_content.newarticle', $article->created_by, 0, $article->id, $article->title);
             $query = 'update #__cjblog_users set num_articles = ' . $count . ' where id = ' . $article->created_by;
             $db->setQuery($query);
             $db->query();
         }
     } else {
         die('CjBlog component is not installed.');
     }
 }