Beispiel #1
0
/**
 * Delete articles (cron task function).
 *
 * @param vivvo_lite_site	$sm
 */
function auto_delete($sm)
{
    require_once VIVVO_FS_INSTALL_ROOT . 'lib/vivvo/core/Articles.class.php';
    if (VIVVO_ARTICLE_AUTO_DELETE > 0) {
        $al = new Articles_list($sm);
        $al->_query->add_where('created < ( DATE_SUB( \'' . date('Y-m-d H:i:s') . '\', INTERVAL ' . VIVVO_ARTICLE_AUTO_DELETE . ' DAY ))');
        $al->_query->set_from('`' . VIVVO_DB_PREFIX . 'articles`');
        $al->_query->add_fields('*');
        $article_params['search_options']['search_cid'] = VIVVO_ARTICLE_AUTO_DELETE_ITEMS;
        $al->search($article_params['search_options'], '', 'ascending', 0, 0, false);
        require_once VIVVO_FS_FRAMEWORK . 'vivvo_post.php';
        $pm = new vivvo_post_master($sm);
        $al->sql_delete_list($pm, NULL, true);
        if (defined('VIVVO_CRONJOB_MODE')) {
            echo 'auto_delete: Finished.' . PHP_EOL;
        } else {
            admin_log('(Cron task: Auto Delete)', 'Finished.');
        }
    }
}
 /**
  * On sql delte
  *
  * @param vivvo_post_master $post_master
  */
 function on_delete($post_master)
 {
     require_once dirname(__FILE__) . '/Articles.class.php';
     $article_list = new Articles_list();
     $article_list->get_articles_by_category_id($this->id);
     $article_list->sql_delete_list($post_master);
     $sub_keys = array_keys($this->subcategories);
     $sub_count = count($sub_keys);
     for ($i = 0; $i < $sub_count; $i++) {
         $post_master->set_data_object($this->subcategories[$sub_keys[$i]]);
         $post_master->sql_delete();
     }
     $fm = vivvo_lite_site::get_instance()->get_file_manager();
     if ($this->get_image() != '') {
         $fm->delete_fs(VIVVO_FS_ROOT . VIVVO_FS_FILES_DIR . $this->get_image());
     }
     vivvo_cache::get_instance()->delete('categories');
 }
 /**
  * Delete article
  *
  * @param	array	$articles_ids
  * @param	integer	$all_matching
  * @return	boolean	true on success or false on fail
  */
 function delete_article($articles_ids, $all_matching = 0)
 {
     if (!$this->check_token()) {
         return false;
     }
     if (!vivvo_hooks_manager::call('article_delete', array(&$articles_ids, &$all_matching))) {
         return vivvo_hooks_manager::get_status();
     }
     $sm = vivvo_lite_site::get_instance();
     if ($sm->user) {
         $editor_restriction = $sm->user->get_privilege_object_ids('EDITOR', 'Categories');
         if (!empty($editor_restriction)) {
             $article_list = new Articles_list();
             if ($all_matching == 1) {
                 $article_params = Articles_list::get_search_params_from_url($sm);
                 $article_list->search($article_params['search_options'], '', 'ascending', 0, 0);
                 if ($article_list->sql_delete_list($this->_post_master, NULL, true)) {
                     admin_log($sm->user->get_username(), 'Deleted all selected articles');
                     return true;
                 } else {
                     $this->set_error_code(2006);
                     return false;
                 }
             } else {
                 $article_list->get_articles_by_ids($articles_ids, $editor_restriction);
                 if ($article_list->sql_delete_list($this->_post_master)) {
                     admin_log($sm->user->get_username(), 'Deleted articles #' . trim(implode(',', $articles_ids)));
                     return true;
                 } else {
                     $this->set_error_code(2007);
                     return false;
                 }
             }
         } else {
             $this->set_error_code(2008);
             return false;
         }
     } else {
         $this->set_error_code(2009);
         return false;
     }
 }