/** * Resets number of today's reads (cron task function). * * @param vivvo_lite_site $sm */ function auto_reset_today_read($sm) { require_once VIVVO_FS_INSTALL_ROOT . 'lib/vivvo/core/Articles.class.php'; $article_list = new Articles_list($sm); $article_list->search(array(), '', 'ascending', 0, 0, false); require_once VIVVO_FS_FRAMEWORK . 'vivvo_post.php'; $pm = new vivvo_post_master($sm); $article_list->sql_update_list($pm, array('today_read' => '0'), NULL, true); if (defined('VIVVO_CRONJOB_MODE')) { echo 'auto_reset_today_read: Finished.' . PHP_EOL; } }
/** * Archive articles (cron task function). * * @param vivvo_lite_site $sm */ function auto_archive($sm) { require_once VIVVO_FS_INSTALL_ROOT . 'lib/vivvo/core/Articles.class.php'; if (VIVVO_ARTICLE_AUTO_ARCHIVE > 0) { $article_list = new Articles_list(); $search_params = array('search_cid' => VIVVO_ARTICLE_AUTO_ARCHIVE_ITEMS, 'search_before_after' => 0, 'search_search_date' => VIVVO_ARTICLE_AUTO_ARCHIVE); $article_list->search($search_params, '', 'ascending', 0, 0, false); require_once VIVVO_FS_FRAMEWORK . 'vivvo_post.php'; $article_list->sql_update_list(new vivvo_post_master(), array('status' => '-1'), null, true); if (defined('VIVVO_CRONJOB_MODE')) { echo 'auto_archive: Finished.' . PHP_EOL; } else { admin_log('(Cron task: Auto Archive)', 'Finished.'); } } }
/** * 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.'); } } }
/** * Reorder article * * @param array $article_ids * @return boolean true on success or false on fail */ function reorder_article($article_ids) { if (!$this->check_token()) { return false; } if (!vivvo_hooks_manager::call('article_reorderArticle', array(&$article_ids))) { 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_ids = $article_ids; $article_list = new Articles_list(); $article_list->search(array('search_id' => $article_ids), 'order_num', 'descending'); $order_nums = $article_list->get_property_list('order_num'); foreach ($article_list_ids as $k) { $new_order = array_shift($order_nums); $article_list->list[$k]->set_order_num($new_order); $this->_post_master->set_data_object($article_list->list[$k]); if (!$this->_post_master->sql_update()) { $this->set_error_code(2019); return false; } } admin_log($sm->user->get_username(), 'Reordered articles #' . trim(implode(',', $article_list_ids))); return true; } else { $this->set_error_code(2020); return false; } } else { $this->set_error_code(2021); return false; } }
function generate_output($params) { $this->set_template($params); $sm = vivvo_lite_site::get_instance(); $um = $sm->get_url_manager(); $lang = vivvo_lang::get_instance(); if (!isset($params['search_by_year']) && !$um->isset_param('search_by_year')) { $year = date('Y', VIVVO_START_TIME); $params['search_by_year'] = $year; } else { if (isset($params['search_by_year'])) { $year = (int) $params['search_by_year']; } else { $year = (int) $um->get_param('search_by_year'); $params['search_by_year'] = $year; } } if (!isset($params['search_by_month']) && !$um->isset_param('search_by_month')) { $month = date('n', VIVVO_START_TIME); $params['search_by_month'] = $month; } else { if (isset($params['search_by_month'])) { $month = (int) $params['search_by_month']; } else { $month = (int) $um->get_param('search_by_month'); $params['search_by_month'] = $month; } } //Articles per day if ($month > 0 && $year > 1900) { if (!isset($params['search_do_advanced'])) { $params['search_status'] = -1; } require_once VIVVO_FS_INSTALL_ROOT . 'lib/vivvo/core/Articles.class.php'; $article_params = Articles_list::get_search_params(null, $params); $article_list = new Articles_list(); $article_list->search($article_params['search_options'], '', 'ascending', 0, 0, false); $article_list->_query->_fields = array(); $article_list->_query->add_fields('DAYOFMONTH( created ) AS day'); $article_list->_query->add_fields('count( * ) AS count'); $article_list->_query->add_group_by('TO_DAYS( created )'); $query = $article_list->_query->get_query(); $num_of_days = date('t', mktime(0, 0, 0, $month, 1, $year)); $day_of_week = date('w', mktime(0, 0, 0, $month, 1, $year)); $prev_month = $month - 1; if ($prev_month == 0) { $prev_month = 12; $prev_year = $year - 1; } else { $prev_year = $year; } $next_month = $month + 1; if ($next_month == 13) { $next_month = 1; $next_year = $year + 1; } else { $next_year = $year; } $prev_num_of_days = date('t', mktime(0, 0, 0, $prev_month, 1, $prev_year)); if ($day_of_week != 0) { for ($i = 1 - $day_of_week; $i <= 0; $i++) { $this->data[$i] = array(); $this->data[$i]['label'] = ''; $this->data[$i]['count'] = 0; $this->data[$i]['url'] = ''; } } for ($i = 1; $i <= $num_of_days; $i++) { $this->data[$i] = array(); $this->data[$i]['label'] = $i; $this->data[$i]['count'] = 0; $this->data[$i]['url'] = ''; } $next_day_of_week = date('w', mktime(0, 0, 0, $month, $num_of_days, $year)); if ($next_day_of_week != 6) { for ($i = $num_of_days + 1; $i < $num_of_days + 6 - $next_day_of_week + 1; $i++) { $this->data[$i] = array(); $this->data[$i]['label'] = ''; $this->data[$i]['count'] = 0; $this->data[$i]['url'] = ''; } } $count_sum = 0; $res = $sm->get_db()->query($query); if (!is_a($res, 'mdb2_error')) { while ($row = $res->fetchRow(MDB2_FETCHMODE_ASSOC)) { if ($row['count'] > 0) { $count_sum += $row['count']; $this->data[$row['day']]['count'] += $row['count']; if (isset($params['search_status']) && $params['search_status'] == -1) { $this->data[$row['day']]['url'] = make_proxied_url('archive/' . $year . '/' . $month . '/' . $row['day']); } else { $day_params = $article_params; $day_params['search_do_advanced'] = true; $day_params['search_by_day'] = $row['day']; $search_option = base64_encode(serialize($day_params)); $this->data[$row['day']]['url'] = make_absolute_url('index.php?search_options=' . $search_option); } } } } $res->free(); } if ($count_sum) { $month_params = $article_params; if (isset($params['search_status']) && $params['search_status'] == -1) { $this->_template->assign('month_url', make_proxied_url('archive/' . $year . '/' . $month . '/')); } else { $month_params['search_do_advanced'] = true; $search_option = base64_encode(serialize($month_params)); $this->_template->assign('month_url', make_absolute_url('index.php?search_options=' . $search_option)); } } $this->_template->assign('count_list', $this->data); $this->_template->assign('year', $year); $this->_template->assign('month', strval($lang->get_value('LNG_MONTH_' . $month))); $this->_template->assign('prev_year', intval($year - 1)); $this->_template->assign('prev_month_year', $prev_year); $this->_template->assign('prev_month', $prev_month); $this->_template->assign('next_year', intval($year + 1)); $this->_template->assign('next_month_year', $next_year); $this->_template->assign('next_month', $next_month); }