function dashboard_invoke() { $dashboard = array('main:sysconf:Csc' => 'System configurations', 'main:personal:Cp' => 'Personal options', 'main:templates:Ct' => 'Templates', 'main:category:Cc' => 'Categories', 'main:intwiz:Ciw' => 'Integration wizard', 'media:media:Cmm' => 'Media manager', 'main:userman:Cum' => 'Users manager', 'main:group:Cg' => 'Groups', 'main:backup:Cb' => 'Backups', 'main:comments:Com' => 'Comments', 'main:archives:Ca' => 'Archives', 'main:ipban:Cbi' => 'Block IP', 'main:morefields:Caf' => 'Additional fields', 'main:wreplace:Crw' => 'Replace words', 'main:logs:Csl' => 'System logs', 'main:widgets:Cwp' => 'Plugins', 'maint:maint:Cmt' => 'Maintenance', 'main:locale:Clc' => 'Localization', 'main:script:Csr' => 'HTML scripts', 'main:selfchk:Cpc' => 'Permission check'); // Call dashboard extend $dashboard = hook('extend_dashboard', $dashboard); // Exec $mod = REQ('mod', 'GETPOST'); $opt = REQ('opt', 'GETPOST'); // Top level (dashboard) cn_bc_add('Dashboard', cn_url_modify(array('reset'), 'mod=' . $mod)); // Request module foreach ($dashboard as $id => $_t) { list($dl, $do, $acl_module) = explode(':', $id); if (test($acl_module) && $dl == $mod && $do == $opt && function_exists("dashboard_{$opt}")) { cn_bc_add($_t, cn_url_modify(array('reset'), 'mod=' . $mod, 'opt=' . $opt)); die(call_user_func("dashboard_{$opt}")); } } // ----------------- echoheader('-@dashboard/style.css', "Cutenews dashboard"); $images = array('personal' => 'user.gif', 'userman' => 'users.gif', 'sysconf' => 'options.gif', 'category' => 'category.png', 'templates' => 'template.png', 'backup' => 'archives.gif', 'archives' => 'arch.png', 'media' => 'images.gif', 'intwiz' => 'wizard.gif', 'logs' => 'list.png', 'selfchk' => 'check.png', 'ipban' => 'block.png', 'widgets' => 'widgets.png', 'wreplace' => 'replace.png', 'morefields' => 'more.png', 'maint' => 'settings.png', 'group' => 'group.png', 'locale' => 'locale.png', 'script' => 'script.png', 'comments' => 'comments.png'); // More dashboard images $images = hook('extend_dashboard_images', $images); foreach ($dashboard as $id => $name) { list($mod, $opt, $acl) = explode(':', $id, 3); if (!test($acl)) { unset($dashboard[$id]); continue; } $item = array('name' => i18n($name), 'img' => isset($images[$opt]) ? $images[$opt] : 'home.gif', 'mod' => $mod, 'opt' => $opt); $dashboard[$id] = $item; } $member = member_get(); $meta_draft = db_index_meta_load('draft'); $drafts = isset($meta_draft['locs']) ? intval(array_sum($meta_draft['locs'])) : false; if ($drafts && test('Cvn')) { $greeting_message = i18n('News in draft: %1', '<a href="' . cn_url_modify('mod=editnews', 'source=draft') . '"><b>' . $drafts . '</b></a>'); } else { $greeting_message = i18n('Have a nice day!'); } cn_assign('dashboard, username, greeting_message', $dashboard, $member['name'], $greeting_message); echo exec_tpl('dashboard/general'); echofooter(); }
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(); }