function make_navigation() { global $p, $privileges; $menu = array(); $pages = array("news" => news_title(), "user_meetings" => meetings_title(), "user_shifts" => shifts_title(), "angeltypes" => angeltypes_title(), "user_questions" => questions_title()); foreach ($pages as $page => $title) { if (in_array($page, $privileges)) { $menu[] = toolbar_item_link(page_link_to($page), '', $title, $page == $p); } } $admin_menu = array(); $admin_pages = array("admin_arrive" => admin_arrive_title(), "admin_active" => admin_active_title(), "admin_user" => admin_user_title(), "admin_free" => admin_free_title(), "admin_questions" => admin_questions_title(), "shifttypes" => shifttypes_title(), "admin_shifts" => admin_shifts_title(), "admin_rooms" => admin_rooms_title(), "admin_groups" => admin_groups_title(), "admin_import" => admin_import_title(), "admin_log" => admin_log_title()); foreach ($admin_pages as $page => $title) { if (in_array($page, $privileges)) { $admin_menu[] = toolbar_item_link(page_link_to($page), '', $title, $page == $p); } } if (count($admin_menu) > 0) { $menu[] = toolbar_dropdown('', _("Admin"), $admin_menu); } return toolbar($menu); }
$title = user_password_recovery_title(); $content = user_password_recovery_controller(); } elseif ($p == "angeltypes") { list($title, $content) = angeltypes_controller(); } elseif ($p == "shifts") { list($title, $content) = shifts_controller(); } elseif ($p == "users") { list($title, $content) = users_controller(); } elseif ($p == "user_angeltypes") { list($title, $content) = user_angeltypes_controller(); } elseif ($p == "user_driver_licenses") { list($title, $content) = user_driver_licenses_controller(); } elseif ($p == "shifttypes") { list($title, $content) = shifttypes_controller(); } elseif ($p == "news") { $title = news_title(); $content = user_news(); } elseif ($p == "news_comments") { require_once realpath(__DIR__ . '/../includes/pages/user_news.php'); $title = user_news_comments_title(); $content = user_news_comments(); } elseif ($p == "user_meetings") { $title = meetings_title(); $content = user_meetings(); } elseif ($p == "user_myshifts") { $title = myshifts_title(); $content = user_myshifts(); } elseif ($p == "user_shifts") { $title = shifts_title(); $content = user_shifts(); } elseif ($p == "user_messages") {
function user_news() { global $DISPLAY_NEWS, $privileges, $user; $html = '<div class="col-md-12"><h1>' . news_title() . '</h1>' . msg(); if (isset($_POST["text"]) && isset($_POST["betreff"]) && in_array("admin_news", $privileges)) { if (!isset($_POST["treffen"]) || !in_array("admin_news", $privileges)) { $_POST["treffen"] = 0; } sql_query("INSERT INTO `News` (`Datum`, `Betreff`, `Text`, `UID`, `Treffen`) " . "VALUES ('" . sql_escape(time()) . "', '" . sql_escape($_POST["betreff"]) . "', '" . sql_escape($_POST["text"]) . "', '" . sql_escape($user['UID']) . "', '" . sql_escape($_POST["treffen"]) . "');"); engelsystem_log("Created news: " . $_POST["betreff"] . ", treffen: " . $_POST["treffen"]); success(_("Entry saved.")); redirect(page_link_to('news')); } if (isset($_REQUEST['page']) && preg_match("/^[0-9]{1,}\$/", $_REQUEST['page'])) { $page = $_REQUEST['page']; } else { $page = 0; } $news = sql_select("SELECT * FROM `News` ORDER BY `Datum` DESC LIMIT " . sql_escape($page * $DISPLAY_NEWS) . ", " . sql_escape($DISPLAY_NEWS)); foreach ($news as $entry) { $html .= display_news($entry); } $dis_rows = ceil(sql_num_query("SELECT * FROM `News`") / $DISPLAY_NEWS); $html .= '<div class="text-center">' . '<ul class="pagination">'; for ($i = 0; $i < $dis_rows; $i++) { if (isset($_REQUEST['page']) && $i == $_REQUEST['page']) { $html .= '<li class="active">'; } elseif (!isset($_REQUEST['page']) && $i == 0) { $html .= '<li class="active">'; } else { $html .= '<li>'; } $html .= '<a href="' . page_link_to("news") . '&page=' . $i . '">' . ($i + 1) . '</a></li>'; } $html .= '</ul></div>'; if (in_array("admin_news", $privileges)) { $html .= '<hr />'; $html .= '<h2>' . _("Create news:") . '</h2>'; $html .= form(array(form_text('betreff', _("Subject"), ''), form_textarea('text', _("Message"), ''), form_checkbox('treffen', _("Meeting"), false, 1), form_submit('submit', _("Save")))); } return $html . '</div>'; }