Beispiel #1
0
    $app->tpl->display('announcements.tpl');
});
//admin announcements
respond('/admincp/announcements/add', function ($request, $response, $app) {
    //when the administrator is trying to add a new announcement to the list of avilable
    $message = $request->param('message');
    $message = PSU::makeClean($message);
    $message = stripslashes($message);
    ReserveDatabaseAPI::insert_announcement($message);
    $response->redirect($GLOBALS['BASE_URL'] . '/admin/admincp/announcements');
});
//admin accouncements/add
respond('/admincp/announcements/[i:id]/delete', function ($request, $response, $app) {
    //when the administrator is trying to delete an announcement
    $announcement_id = $request->id;
    ReserveDatabaseAPI::delete_announcement($announcement_id);
    $response->redirect($GLOBALS['BASE_URL'] . '/admin/admincp/announcements');
});
//admin equipment
respond('/admincp/announcements/save', function ($request, $response, $app) {
    //when the administrator is trying to save which announcements are going to be displayed
    $announcements = ReserveDatabaseAPI::get_announcements();
    foreach ($announcements as $key => $announcement) {
        //iterate through all of the announcements
        //if the announcement is found in the post array than set the change variable to yes, otherwise change it to no
        if ($_POST[$key]) {
            ReserveDatabaseAPI::change_announcement($key, "yes");
        } else {
            ReserveDatabaseAPI::change_announcement($key, "no");
        }
    }