public static function main() { if (isset($_REQUEST['blog_id'])) { $blog = new Blog((int) $_REQUEST['blog_id']); } elseif (isset($_REQUEST['id'])) { $blog = new Blog((int) $_REQUEST['id']); } else { $blog = new Blog(); } if (!isset($_REQUEST['action'])) { if ($blog->id) { $action = 'view_comments'; } else { $action = 'view'; } } else { $action = $_REQUEST['action']; } switch ($action) { case 'view_comments': Layout::addStyle('blog'); Layout::addPageTitle($blog->title); if (Current_User::allow('blog', 'edit_blog')) { Blog_User::miniAdminList(); } if ($blog->publish_date > time() && !Current_User::allow('blog')) { PHPWS_Core::errorPage('404'); } else { $content = $blog->view(true, false); } break; case 'view': if (isset($_GET['y'])) { $day = 1; $month = 1; $year = $_GET['y']; if (isset($_GET['m'])) { $month = $_GET['m']; if (isset($_GET['d'])) { $day = $_GET['d']; $start_date = mktime(0, 0, 0, $month, $day, $year); $end_date = mktime(23, 59, 59, $month, $day, $year); } else { $start_day = 1; $end_day = (int) date('t', mktime(0, 0, 0, $month, 1, $year)); $start_date = mktime(0, 0, 0, $month, 1, $year); $end_date = mktime(0, 0, 0, $month, $end_day, $year); } } else { $start_date = mktime(0, 0, 0, 1, 1, $year); $end_date = mktime(0, 0, 0, 12, 31, $year); } } else { $start_date = null; $end_date = null; } $content = Blog_User::show($start_date, $end_date); Layout::add($content, 'blog', 'view', true); return; break; case 'submit': if (Current_User::allow('blog', 'edit_blog')) { PHPWS_Core::reroute(PHPWS_Text::linkAddress('blog', array('action' => 'admin', 'tab' => 'new'), 1)); } else { PHPWS_Core::errorPage(403); } break; default: PHPWS_Core::errorPage(404); break; } Layout::add($content); }
<?php /** * @version $Id$ * @author Matthew McNaney <mcnaney at gmail dot com> */ if (PHPWS_Settings::get('blog', 'home_page_display')) { if (!isset($_REQUEST['module'])) { $content = Blog_User::show(); Layout::add($content, 'blog', 'view', TRUE); } } else { Blog_User::showSide(); }