<?php

if (Session::is_group_user('Sustainer Admin')) {
    if (!($advert = Adverts::get_by_id((int) $_REQUEST["advertid"]))) {
        exit(json_encode(array('error' => 'Invalid advert ID.')));
    }
    if ($advert->get_sustainer() == 't') {
        $advert->set_sustainer('f');
    } else {
        $advert->set_sustainer('t');
    }
    $advert->save();
    if (Errors::occured()) {
        http_response_code(400);
        exit(json_encode(array("error" => "Something went wrong. You may have discovered a bug!", "detail" => Errors::report("array"))));
        Errors::clear();
    } else {
        exit(json_encode(array('response' => 'success', 'id' => $playlist->get_id())));
    }
} else {
    http_response_code(403);
    exit(json_encode(array('error' => 'Permission denied.')));
}
Пример #2
0
 public static function get_by_id($id)
 {
     $type = DigiplayDB::select("type FROM audio WHERE id = " . $id);
     if ($type) {
         if ($type == 1) {
             return Tracks::get_by_id($id);
         } else {
             if ($type == 2) {
                 return Jingles::get_by_id($id);
             } else {
                 if ($type == 3) {
                     return Adverts::get_by_id($id);
                 } else {
                     if ($type == 4) {
                         return Prerecs::get_by_id($id);
                     }
                 }
             }
         }
     }
 }