Ejemplo n.º 1
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);
                     }
                 }
             }
         }
     }
 }
Ejemplo n.º 2
0
        $jingles = array();
        foreach ($package->get_jingles() as $jingle) {
            $jingles[] = array('id' => $jingle->get_id(), 'title' => $jingle->get_title());
        }
        $jsonrpc->output(array('package' => array('id' => $package->get_id(), 'name' => $package->get_name(), 'description' => $package->get_description()), 'jingles' => $jingles));
        break;
    case 'delete_from':
        if (!isset($jsonrpc->params['package_id']) || !isset($jsonrpc->params['jingle_id'])) {
            $jsonrpc->error('invalid jingle or package');
        }
        $package = JinglePackages::get_by_id($jsonrpc->params['package_id']);
        $jingle = Jingles::get_by_id($jsonrpc->params['jingle_id']);
        $result = $package->delete_jingle($jingle);
        if ($result == true) {
            $jsonrpc->output('ok');
        } else {
            $jsonrpc->output('error');
        }
        break;
    case 'search':
        if (!isset($jsonrpc->params['q'])) {
            $jsonrpc->error('invalid search query');
        }
        $results = Search::jingles($jsonrpc->params['q']);
        $jingles = array();
        foreach ($results['results'] as $result) {
            $jingles[] = array('id' => $result, 'label' => Jingles::get_by_id($result)->get_title());
        }
        $jsonrpc->output($jingles);
        break;
}