Пример #1
0
    //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");
        }
    }
    $response->redirect($GLOBALS['BASE_URL'] . '/admin/admincp');
});
//admin equipment
respond('/admincp/announcements/[i:id]/edit', function ($request, $response, $app) {
    //when the administrator is trying to edit an existing announcement
    $announcement_id = $request->id;
    $app->tpl->assign('announcement', ReserveDatabaseAPI::get_announcement($announcement_id));
    $app->tpl->display('announcement-edit.tpl');
});
//admin equipment
respond('/admincp/announcements/[i:id]/edit/save', function ($request, $response, $app) {
    //when the edited announcement is saved into the database
    $announcement_id = $request->id;