function dashboard_archives() { list($req_archive_id, $arch_action, $last_only, $period) = GET('archive_id, arch_action, last_only, period'); // Do make archive if (request_type('POST')) { cn_dsi_check(); // Archives actions if ($req_archive_id) { // Delete if ($arch_action == 'rm') { db_archive_meta_update($req_archive_id, 0, 0, 0); $req_archive_id = 0; cn_throw_message("Archive deleted", 'e'); } elseif ($arch_action == 'extr') { if (!db_extract_archive($req_archive_id)) { cn_throw_message("Archive not extracted correctly", 'e'); } else { $req_archive_id = 0; cn_throw_message("Archive extracted"); } } else { cn_throw_message('@SYSINFO: Unrecognized request', 'e'); } } else { if ($last_only) { $date_f = ctime() - $period * 3600 * 24; $date_t = ctime(); } else { list($_fd, $_fm, $_fy) = GET('from_date_day, from_date_month, from_date_year', 'POST'); list($_td, $_tm, $_ty) = GET('to_date_day, to_date_month, to_date_year', 'POST'); $date_f = mktime(0, 0, 0, intval($_fm), intval($_fd), intval($_fy)); $date_t = mktime(23, 59, 59, intval($_tm), intval($_td), intval($_ty)); } $cc = db_make_archive($date_f, $date_t); if ($cc) { cn_throw_message(i18n('Archive created (%1 articles)', $cc)); } else { cn_throw_message('There is nothing to archive', 'e'); } } } // --- archives $arch_list = db_get_archives(); // ---- fetch active --- $ids = db_index_load(); ksort($ids); reset($ids); $st = key($ids); end($ids); $ed = key($ids); list($f_date_d, $f_date_m, $f_date_y) = make_postponed_date($st); list($t_date_d, $t_date_m, $t_date_y) = make_postponed_date($ed); cn_assign('arch_list, archive_id', $arch_list, $req_archive_id); cn_assign('f_date_d, f_date_m, f_date_y, t_date_d, t_date_m, t_date_y', $f_date_d, $f_date_m, $f_date_y, $t_date_d, $t_date_m, $t_date_y); echoheader('-@dashboard/style.css', 'Arhives'); echo exec_tpl('dashboard/archives'); echofooter(); }
$_ds = array('{select=year:from}' => array('from_date_year', $_yf), '{select=mon:from}' => array('from_date_month', $_mf), '{select=day:from}' => array('from_date_day', $_df), '{select=year:to}' => array('to_date_year', $_yt), '{select=mon:to}' => array('to_date_month', $_mt), '{select=day:to}' => array('to_date_day', $_dt)); foreach ($_ds as $id => $opt) { $form = str_replace($id, '<select name="' . $opt[0] . '" class="cn_' . $opt[0] . '">' . $opt[1] . '</select>', $form); } echo $form; // --------------------------------------------------------------------------------------------------------------------- if ($dosearch) { $mc_start = microtime(true); // Remove parameters for go to news from searchbox $_static_qr = 'dosearch,archives,search,from_date_year,from_date_month,from_date_day,to_date_year,to_date_month,to_date_day,search_st,number,archive,template'; $st = -1; $_next_link = FALSE; $_number = $number; $archive_id = 0; // get archive list $_list_archives = db_get_archives(); krsort($_list_archives); reset($_list_archives); $news = db_index_load(''); $c_time = ctime(); $itemid = 0; if (strlen($search) < 3) { echo "<div>Too short request!</div>"; } else { $block = ''; $found = 0; do { reset($news); // repeat, while data exists while ($news) { // pop top element
function edit_news_action_list() { // init list($source, $archive_id, $per_page, $sort, $dir, $YS, $MS, $DS, $page) = GET('source, archive_id, per_page, sort, dir, year, mon, day, page', 'GET,POST'); list($add_category, $add_user, $rm_cat, $rm_user, $cat_filter) = GET('add_category_filter, add_user_filter, rm_category_filter, rm_user_filter, cat_filter', 'GET'); // defaults $has_next = FALSE; $page = intval($page); $ctime = ctime(); $nocat = FALSE; if ($per_page == 0) { $per_page = 25; } if ($sort == '') { $sort = 'date'; } if ($sort == 'date' && !$dir) { $dir = 'd'; } if ($dir == '') { $dir = 'a'; } // --- changes in acp filters --- list($cfilter, $ufilter) = cn_cookie_unpack('filter_cat, filter_user'); if ($add_category) { $sp = spsep($add_category); foreach ($sp as $id) { if (test_cat($id)) { $cfilter[$id] = $id; } } } if ($add_user) { $sp = spsep($add_user); foreach ($sp as $id) { $ufilter[$id] = $id; } } if ($rm_cat) { $sp = spsep($rm_cat); foreach ($sp as $id) { unset($cfilter[$id]); } } if ($rm_user) { $sp = spsep($rm_user); foreach ($sp as $id) { unset($ufilter[$id]); } } // Add concrete filter if ($cat_filter) { if ($cat_filter !== '-') { $filter = intval($cat_filter); if (test_cat($filter)) { $cfilter[$filter] = $filter; } } else { $nocat = TRUE; } } cn_cookie_pack('filter_cat, filter_user', $cfilter, $ufilter); // ---------------------------------------------------- $opts = array('source' => $source, 'archive_id' => $archive_id, 'sort' => $sort, 'dir' => $dir, 'start' => $page, 'per_page' => $per_page + 1, 'cfilter' => $cfilter, 'ufilter' => $ufilter, 'nocat' => $nocat, 'nlpros' => TRUE, 'by_date' => "{$YS}-{$MS}-{$DS}"); list($entries, $rev) = cn_get_news($opts); // Detect next exists if (count($entries) > $per_page) { end($entries); unset($entries[key($entries)]); $has_next = TRUE; } $meta = array(); // Load meta-data (and userlist data) if ($archive_id && $source == 'archive') { $meta = db_index_meta_load("archive-{$archive_id}", TRUE); } else { $meta = db_index_meta_load($source, TRUE); } // Meta-data for draft only $meta_draft = db_index_meta_load('draft'); $ptree = isset($meta['locs']) ? $meta['locs'] : false; $userlist = $meta['uids']; $nprospect = intval($rev['cpostponed']); $ndraft = is_array($meta_draft['locs']) ? intval(array_sum($meta_draft['locs'])) : 0; $found_rows = isset($meta['locs']) && is_array($meta['locs']) ? intval(array_sum($meta['locs'])) : 0; $archives = count(db_get_archives()); // --- // Decode proto tree for list news $tree_years = array(); $tree_mons = array(); $tree_days = array(); // Is draft or active (or prospected) if ($source !== 'archive') { if ($ptree) { foreach ($ptree as $nloc => $c) { list($Y, $M, $D) = explode('-', $nloc); if (isset($tree_years[$Y])) { $tree_years[$Y] += $c; } else { $tree_years[$Y] = $c; } if ($Y == $YS) { if (isset($tree_mons[$M])) { $tree_mons[$M] += $c; } else { $tree_mons[$M] = $c; } if ($M == $MS) { $tree_days[$D] = $c; } } } } } else { $found_rows = 0; $ptree = db_get_archives(); // Archive Id exists if ($archive_id) { $found_rows = $ptree[$archive_id]['c']; } else { foreach ($ptree as $item) { $found_rows += $item['c']; } $entries = array(); } $nprospect = 0; } // ---------------------------------------------------- foreach ($entries as $id => $entry) { $can = FALSE; $nv_user = db_user_by_name($entry['u']); // User not exists, deny, except admins if (!$nv_user && !test('Nva')) { $can = FALSE; } elseif (test('Nvs', $nv_user, TRUE) || test('Nvg', $nv_user) || test('Nva')) { $can = test_cat($entry['c']); } $entries[$id]['user'] = $entry['u']; $entries[$id]['date'] = $YS ? date('M, d H:i', $id) : date('M, d Y H:i', $id); $entries[$id]['date_full'] = date('Y M d, H:i:s', $id); $entries[$id]['user'] = $entry['u']; $entries[$id]['comments'] = count($entry['co']); $entries[$id]['title'] = $entry['t']; $entries[$id]['cats'] = spsep($entry['c']); $entries[$id]['is_pros'] = $id > $ctime ? TRUE : FALSE; $entries[$id]['can'] = $can; } // clear differs for cn_url_* unset($_GET['add_category_filter'], $_GET['add_user_filter'], $_GET['rm_category_filter'], $_GET['rm_user_filter']); // ------ cn_assign('sort, dir, source, per_page, entries_showed, entries_total, entries, page, userlist, category_filters, user_filters, cat_filter', $sort, $dir, $source, $per_page, count($entries), $found_rows, $entries, $page, $userlist, $cfilter, $ufilter, $cat_filter); cn_assign('year_selected, mon_selected, day_selected, TY, TM, TD, ptree', $YS, $MS, $DS, $tree_years, $tree_mons, $tree_days, $ptree); cn_assign('nprospect, ndraft, has_next, archives', $nprospect, $ndraft, $has_next, $archives); echoheader('editnews@editnews/main.css', 'News list'); echo exec_tpl('editnews/list'); echofooter(); }