예제 #1
0
 public static function get_by_wall($wall)
 {
     $return = array();
     foreach (DigiplayDB::select("* FROM aw_items WHERE wall_id = :wall_id ORDER BY item ASC;", "AudiowallItem", true, array(":wall_id" => $wall->get_id())) as $item) {
         $return[$item->get_item()] = $item;
     }
     return $return;
 }
예제 #2
0
 public function get_status_info()
 {
     $thisStatus = DigiplayDB::select("* FROM info_status_statuses WHERE id = " . $this->status, "StatusInfo");
     $statusInfo = array();
     $statusInfo['status'] = $thisStatus->get_status();
     $statusInfo['colour'] = $thisStatus->get_colour();
     return $statusInfo;
 }
예제 #3
0
 public function del_from_track($track)
 {
     $result = DigiplayDB::delete("audiokeywords", "audioid = " . $track->get_id() . " AND keywordid = " . $this->id);
     $remaining = DigiplayDB::select("* FROM audiokeywords WHERE keywordid = " . $this->id);
     if (!$remaining) {
         DigiplayDB::delete("keywords", "id = " . $this->id);
     }
     return $result;
 }
예제 #4
0
 public function del_from_track($track)
 {
     $result = DigiplayDB::delete("audioartists", "audioid = " . $track->get_id() . " AND artistid = " . $this->id);
     $remaining = DigiplayDB::select("* FROM audioartists WHERE artistid = " . $this->id . ";");
     if (!$remaining) {
         $result = DigiplayDB::delete("artists", "id = " . $this->id);
     }
     return (bool) $result;
 }
예제 #5
0
 public static function get_tracks_of_the_day($count = 1)
 {
     $today = mktime(0, 0, 0, (int) date("n"), (int) date("j"), (int) date("Y"));
     srand($today / pi());
     $trackcount = DigiplayDB::select("count(*) FROM audio INNER JOIN audiodir ON audio.id=audiodir.audioid WHERE audio.import_date < " . $today . " AND audio.type = 1 AND audiodir.dirid = 2;");
     $tracks = array();
     for ($i = 1; $i <= $count; $i++) {
         $track = rand(0, $trackcount);
         $sql = $tracks[] = self::get_by_id(DigiplayDB::select("audio.id FROM audio INNER JOIN audiodir ON audio.id=audiodir.audioid WHERE audio.import_date < " . $today . " AND audio.type = 1 AND audiodir.dirid = 2 ORDER BY audio.id LIMIT 1 OFFSET " . $track . ";"));
     }
     return $tracks;
 }
예제 #6
0
 public static function get_by_id($id)
 {
     return DigiplayDB::select("* FROM info_status WHERE id = " . $id, "Status");
 }
예제 #7
0
 public function delete()
 {
     $query = "DELETE FROM aw_items WHERE wall_id = '" . $this->id . "'";
     $result = DigiplayDB::query($query);
     $query = "DELETE FROM aw_walls WHERE id = '" . $this->id . "'";
     $result = DigiplayDB::query($query);
     $wallsInSet = DigiplayDB::select("* FROM aw_walls WHERE set_id = " . $this->get_set_id() . " ORDER BY page ASC", "Audiowall", true);
     foreach ($wallsInSet as $aw) {
         if ($aw->get_page() > $this->page) {
             $newValue = $aw->get_page() - 1;
             $newPage = array("page" => $newValue);
             DigiplayDB::update("aw_walls", $newPage, "set_id = " . $aw->get_set_id() . " AND id =" . $aw->get_id());
         }
     }
 }
예제 #8
0
 public static function get_by_audioid($id)
 {
     return DigiplayDB::select("* FROM log WHERE audioid = " . $id . " AND location = 1 ORDER BY datetime DESC LIMIT 1", "LogItem");
 }
예제 #9
0
 public static function prerecords($query, $limit = 0, $offset = 0)
 {
     $query_str = "id, count(*) OVER() AS full_count FROM v_audio_prerec WHERE to_tsvector(title)::tsvector @@ plainto_tsquery(:query)::tsquery ORDER BY id DESC";
     if ($limit > 0) {
         $query_str .= " LIMIT " . $limit;
     }
     if ($offset > 0) {
         $query_str .= " OFFSET " . $offset;
     }
     $result = DigiplayDB::select($query_str, NULL, true, array(":query" => $query));
     if ($result === false) {
         throw new UserError("Query failed: {$query_str}");
     }
     $results = array();
     $total = 0;
     if (count($result) > 0) {
         foreach ($result as $res) {
             $results[] = $res["id"];
             $total = $res["full_count"];
         }
     }
     $return = array("results" => $results, "total" => $total);
     return count($results) > 0 ? $return : NULL;
 }
예제 #10
0
 public static function login($username, $password)
 {
     if (Configs::get_system_param("auth_method") != "LDAP") {
         $local_user = DigiplayDB::select("* FROM users WHERE username = '******' AND password = '******';", "User");
         if ($local_user) {
             self::$data["user"] = true;
             self::$user_object = $local_user;
         } else {
             return false;
         }
     } else {
         $ldap_instance = new LDAP();
         if (!$ldap_instance->login($username, $password)) {
             return false;
         }
         if (is_object($ldap_instance) && get_class($ldap_instance) == "LDAP") {
             if ($ldap_instance->login_status()) {
                 self::$data = $ldap_instance->userdetails();
                 self::$data["user"] = true;
                 # Get the user's info, or insert them as a new user if there isn't any
                 self::$user_object = Users::get_by_username(self::$data["username"]);
                 if (!self::$user_object) {
                     $id = DigiplayDB::insert("users", array("username" => self::$data["username"], "password" => NULL), "id");
                     self::$user_object = Users::get_by_id($id);
                 }
             } else {
                 return false;
             }
         }
     }
     if (self::$user_object) {
         $result = self::$user_object->get_config_var("user_curlogin");
         if ($result) {
             self::$data["lastlogin"] = $result;
             DigiplayDB::query("UPDATE usersconfigs SET val = '" . time() . "' WHERE userid = " . self::$user_object->get_id() . " AND configid = 3;");
         } else {
             DigiplayDB::query("INSERT INTO usersconfigs (userid,configid,val) VALUES (" . self::$user_object->get_id() . ",3,'" . time() . "');");
             DigiplayDB::query("INSERT INTO usersconfigs (userid,configid,val) VALUES (" . self::$user_object->get_id() . ",1,'');");
         }
         return true;
     } else {
         return false;
     }
 }
예제 #11
0
<?php

$session = Session::get_user();
$aw = AudiowallSets::get_by_id(pg_escape_string($_REQUEST['setid']));
$sessionpermissions = $aw->get_user_permissions($session->get_id());
if ($sessionpermissions[2] == '1' || Session::is_group_user('Audiowalls Admin')) {
    $ownerid = DigiplayDB::select("user_id FROM aw_sets_owner WHERE set_id = '" . $aw->get_id() . "'");
    if (isset($ownerid)) {
        $user = Users::get_by_id($ownerid);
        $username = $user->get_display_name();
    } else {
        $username = "";
    }
    require_once 'pre.php';
    Output::add_script("../aw.js");
    Output::set_title("Audiowall Users");
    MainTemplate::set_subtitle("<span style=\"margin-right:20px;\">Set: " . $aw->get_name() . "</span><span style=\"margin-right:20px;\">Owner: " . $username . "</span><span id=\"editor_edit_buttons\"><a href=\"#\" class=\"btn btn-success\">Add Viewer</a></span>");
    echo "<style type=\"text/css\">\n\ttable { font-size:1.2em; }\n\tthead { display:none; }\n\t.description { font-size:0.8em; font-style:italic; }\n\t.hover-info { display:none; }\n\t.table tbody tr.success td { background-color: #DFF0D8; }\n\t</style>";
    echo "<table class=\"table table-striped\" cellspacing=\"0\">\n\t\t\t\t<thead>\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<th></th>\n\t\t\t\t\t\t<th style=\"width:65px\"></th>\n\t\t\t\t\t</tr>\n\t\t\t\t</thead><tbody>";
    $aw_set = AudiowallSets::get_by_id($_REQUEST['setid']);
    $users = $aw_set->get_users_with_permissions();
    if (!is_null($users) && count($users) > 1) {
        foreach ($users as $user) {
            $userclass = Users::get_by_id($user->get_id());
            $username = $userclass->get_username();
            $permissions = $aw_set->get_user_permissions($user->get_id());
            if ($permissions[0] == "1" && $permissions[1] == '0') {
                echo "<tr><td><strong>" . $username . "</strong></td>";
                echo "<td class=\"delete-aw-btn\" style=\"width:65px\"><a href=\"#\" class=\"btn btn-danger\">Delete</a></td>";
                echo "</td></tr>";
            }
예제 #12
0
 public function get_config_var($param)
 {
     return DigiplayDB::select("val FROM usersconfigs INNER JOIN configs ON configs.id = usersconfigs.configid WHERE userid = " . $this->id . " AND configs.name = '" . $param . "'");
 }
예제 #13
0
 public static function get_newest($num = 10)
 {
     return DigiplayDB::select("* FROM audio WHERE type = " . AudioTypes::get("Jingle")->get_id() . " ORDER BY id DESC LIMIT " . $num . ";", "Track", true);
 }
예제 #14
0
 public static function get_by_id($id)
 {
     return DigiplayDB::select("* FROM scripts WHERE id = " . $id, "Script");
 }
예제 #15
0
<?php

Output::set_title("Music Uploads");
$index = isset($_REQUEST["i"]) ? explode(",", $_REQUEST["i"]) : array("title", "artist", "album");
$limit = isset($_GET["n"]) && is_numeric($_REQUEST["n"]) ? $_GET["n"] : 10;
$page = isset($_REQUEST["p"]) && is_numeric($_REQUEST["p"]) ? $_REQUEST["p"] : 1;
MainTemplate::set_subtitle("See who has been uploading tracks");
$uploadStats = DigiplayDB::select("origin, count(origin) FROM audio GROUP BY origin ORDER BY count(origin) DESC", NULL, false);
echo "\n\t\t<table class=\"table table-striped table-bordered\">\n\t\t<thead>\n\t\t<tr>\n\t\t<th></th>\n\t\t<th>Member</th>\n\t\t<th>Songs Uploaded</th>\n\t\t</tr>\n\t\t</thead>\n\t\t<tbody>\n\t\t";
$i = 0;
foreach ($uploadStats as $uploadStat) {
    $uploader = $uploadStat['origin'];
    $count = $uploadStat['count'];
    // Filter out old entries
    //if (preg_match('/^Web -/', $uploader)) continue;
    //if (preg_match('/^Dropbox -/', $uploader)) continue;
    //if (preg_match('/^Mp3/', $uploader)) continue;
    //if ($uploader == "") continue;
    // Print row
    $i++;
    echo "\n\t\t<tr>\n\t\t\t<td>" . $i . "</td>\n\t\t\t<td>" . $uploader . "</td>\n\t\t\t<td>" . $count . "</td>\n\t\t</tr>\n\t";
}
echo "</tbody>\n\t\t</table>\n\t";
예제 #16
0
 public static function count()
 {
     return DigiplayDB::select("COUNT(id) FROM showplans", NULL, false);
 }
예제 #17
0
 public static function get_all()
 {
     return DigiplayDB::select("* FROM archives;", "Archive", true);
 }
예제 #18
0
 public static function get_total_comments()
 {
     return DigiplayDB::select("COUNT(*) FROM info_fault_comments");
 }
예제 #19
0
 public static function get_by_md5($md5)
 {
     $type = DigiplayDB::select("type FROM audio WHERE md5 = '" . $md5 . "'");
     if ($type) {
         if ($type == 1) {
             return Tracks::get_by_md5($md5);
         } else {
             if ($type == 2) {
                 return Jingles::get_by_md5($md5);
             } else {
                 if ($type == 3) {
                     return Adverts::get_by_md5($md5);
                 } else {
                     if ($type == 4) {
                         return Prerecs::get_by_md5($md5);
                     }
                 }
             }
         }
     }
 }
예제 #20
0
 public static function get_by_md5($md5)
 {
     return DigiplayDB::select("* FROM audio WHERE md5 = '" . $md5 . "'", "Prerec");
 }
예제 #21
0
 public static function count()
 {
     return DigiplayDB::select("COUNT(id) FROM users WHERE id > 4", NULL, false);
 }
예제 #22
0
<?php

if (Session::is_user()) {
    $a = AudiowallSets::get_by_id(pg_escape_string($_REQUEST['setid']));
    if ($a->user_can_delete() || Session::is_group_user('Audiowalls Admin')) {
        $user = Users::get_by_username(pg_escape_string($_REQUEST['username']));
        if (!is_null($user)) {
            $query = "permissions FROM aw_sets_permissions WHERE set_id = :set_id AND user_id = :user_id";
            $data = array('set_id' => $a->get_id(), 'user_id' => $user->get_id());
            $current = DigiplayDB::select($query, NULL, false, $data);
            if (!is_null($current)) {
                if ($_REQUEST['val'] == 'editor') {
                    if ($current[2] == '1') {
                        $new = '111';
                    } else {
                        $new = '110';
                    }
                } elseif ($_REQUEST['val'] == 'viewer') {
                    if ($current[2] == '1') {
                        $new = '111';
                    } else {
                        if ($current[1] == '1') {
                            $new = '110';
                        } else {
                            $new = '100';
                        }
                    }
                } elseif ($_REQUEST['val'] == 'admin') {
                    $new = '111';
                }
                $data = array('permissions' => $new);
예제 #23
0
 public static function count()
 {
     return DigiplayDB::select("count(id) from aw_sets", null, false);
 }
예제 #24
0
 public static function get_all()
 {
     return DigiplayDB::select("aw_styles.id, aw_styles.name, aw_styles.description, aw_styles_props.value AS background FROM aw_styles, aw_styles_props WHERE aw_styles_props.style_id = aw_styles.id AND aw_styles_props.prop_id = 2;", "AudiowallStyle", true);
 }
예제 #25
0
 public static function get_by_parent($parent)
 {
     return DigiplayDB::select("* FROM groups WHERE parentid " . ($parent ? "= " . $parent->get_id() : "IS NULL"), "Group", true);
 }
예제 #26
0
 public static function get_by_name($name)
 {
     return DigiplayDB::select("* FROM audiotypes WHERE name = :name", "AudioType", false, $name);
 }
예제 #27
0
.description { font-size:0.8em; font-style:italic; }
.hover-info { display:none; }
.table tbody tr.success td { background-color: #DFF0D8; }
</style>
<?php 
echo "\t<div class=\"row\"><div class=\"col-md-3\"><div class=\"well\"><p><a href=\"#\" class=\"btn btn-success\" id=\"create\">Create New Audiowall</a></p><p>An Audiowall is a 3x4 grid of buttons in Digiplay which play audio when pressed. They are displayed on the right hand side of the touchscreen in the studio. The top audiowall is set for everyone and contains core station imaging, promos and beds. The bottom audiowall can be set on this page, and may contain jingles and other audio specific to your show.</p></div></div><div class=\"col-md-9\">\t<table class=\"table table-striped\" cellspacing=\"0\">\n\t\t\t<thead>\n\t\t\t\t<tr>\n\t\t\t\t\t<th></th>\n\t\t\t\t\t<th>Name</th>\n\t\t\t\t\t<th style=\"width:65px\"></th>\n\t\t\t\t\t<th style=\"width:185px\"></th>\n\t\t\t\t</tr>\n\t\t\t</thead><tbody>";
foreach ($sets as $set) {
    if (!$set->user_can_view() && !Session::is_group_user('Audiowalls Admin')) {
        continue;
    }
    echo "<tr" . ($set->get_id() == $active ? ' class="success"' : '') . "><td class=\"wall-info\" >";
    if ($set->user_can_delete()) {
        echo "<a href=\"users/users-viewers.php?setid=" . $set->get_id() . "\">" . Bootstrap::glyphicon("info-sign") . "</a>";
    }
    echo "</td><td><strong>" . $set->get_name() . "</strong><br /><span class=\"description\">" . $set->get_description() . "</span></td>";
    $station_aw = DigiplayDB::select("val FROM configuration WHERE parameter = 'station_aw_set' AND location = '1'");
    if (!($set->get_id() == (int) $station_aw)) {
        if ($set->user_can_delete() || Session::is_group_user('Audiowalls Admin')) {
            echo "<td class=\"delete-aw-btn\" data-aw-name=\"" . $set->get_name() . "\" data-dps-set-id=\"" . $set->get_id() . "\" style=\"width:65px\"><a href=\"#\" class=\"btn btn-danger\">Delete</a></td>";
        } else {
            echo "<td style=\"width:65px\"></td>";
        }
    } else {
        echo "<td style=\"width:65px\"></td>";
    }
    if ($set->user_can_edit() || Session::is_group_user('Audiowalls Admin')) {
        echo "<td style=\"width:65px\"><a href=\"edit.php?id=" . $set->get_id() . "\" class=\"btn btn-primary\">Edit</a></td>";
    } else {
        echo "<td style=\"width:65px\"></td>";
    }
    echo "<td style=\"width:185px\">";
예제 #28
0
 public static function get_by_audio($audio)
 {
     return DigiplayDB::select("keywords.* FROM keywords INNER JOIN audiokeywords ON (keywords.id = audiokeywords.keywordid) WHERE audiokeywords.audioid = " . $audio->get_id(), "Keyword", true);
 }
예제 #29
0
 public static function count()
 {
     return DigiplayDB::select("COUNT(id) FROM requests");
 }
예제 #30
0
 public static function find_in_dir($dir, $name)
 {
     return DigiplayDB::select("* FROM v_tree_dir WHERE parent = :parent AND name = :name", "File", false, array(":parent" => $dir->get_id(), ":name" => $name));
 }