/**
  * Returns the data model based on the primary key given in the GET variable.
  * If the data model is not found, an HTTP exception will be raised.
  * @param integer $id the ID of the model to be loaded
  * @return Playlists the loaded model
  * @throws CHttpException
  */
 public function loadModel($id)
 {
     $model = Playlists::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }
 public function actionAjaxGetChannels()
 {
     $pointId = Yii::app()->request->getPost('pointId');
     $pointDateStr = date('Y-m-d');
     $requestTime = date('H:i:s');
     $pointDatetimeStr = $pointDateStr . " 23:59:59";
     $pointDateTimestamp = strtotime($pointDateStr);
     $weekDay = strtolower(date('D', $pointDateTimestamp));
     $Playlist = new Playlists();
     $pointChannels = Channel::model()->findAll('id_point=:id_point AND window_id IS NOT NULL', array(':id_point' => $pointId));
     $resp = array();
     foreach ($pointChannels as $pointChannel) {
         $pointChannelId = $pointChannel->internalId;
         $windowId = $pointChannel->window_id;
         if (!is_null($windowId)) {
             $bg = $Playlist->GetBGContentArr($pointId, $pointChannelId, $pointDatetimeStr, $weekDay);
             $adv = $Playlist->GetAdvContentArr($pointId, $pointChannelId, $pointDatetimeStr, $weekDay);
             $blockStructedContent = $Playlist->BuildBlockStructedContent($bg, $adv);
             $straightTimeContent = $Playlist->ConverBlockStructedToStraightTimeContent($blockStructedContent);
             $straightTimeContentHisToSecs = $this->ConvertHisToSecsInStraightTime($straightTimeContent, $requestTime);
             $url = Yii::app()->request->getBaseUrl(true) . '/spool/points/' . $pointId . '/' . $pointChannelId;
             $straightTimeContentWithURLPath = $this->UpdateContentPathes($straightTimeContentHisToSecs, $url);
             $window = Window::model()->findByPK($windowId);
             $widgetToChannel = WidgetToChannel::model()->find("channel_id = :channel_id", array("channel_id" => $pointChannel->id));
             $widget = '';
             if (count($widgetToChannel) > 0) {
                 $widgetModel = Widget::model()->findByPk($widgetToChannel['widget_id']);
                 $widget = $widgetModel['content'];
             }
             $resp[] = array('width' => $window->width, 'height' => $window->height, 'top' => $window->top, 'left' => $window->left, 'content' => $straightTimeContentWithURLPath, 'widget' => $widget);
         }
     }
     echo json_encode($resp);
     exit;
 }
Exemple #3
0
function sidebar()
{
    foreach (Playlists::get_all(false) as $playlist) {
        foreach ($playlist->get_tracks() as $track) {
            $tracks++;
            $total_length += $track->get_length();
        }
    }
    $return .= "\r\n\t<h4>Sustainer Service</h4>\r\n\t<dl>\r\n\t\t<dt>Tracks on Sustainer</dt>\r\n\t\t<dd>" . Sustainer::get_total_tracks() . "</dd>\r\n\t\t<dt>Length of Sustainer Playlist</dt>\r\n\t\t<dd>" . Sustainer::get_total_length_formatted() . "</dd>\r\n\t</dl>";
    return $return;
}
Exemple #4
0
        $track = Tracks::get($track_id);
        echo "\r\n\t\t<tr id=\"" . $track->get_id() . "\">\r\n\t\t\t<td class=\"icon\">\r\n\t\t\t\t<a href=\"" . LINK_ABS . "music/detail/" . $track->get_id() . "\" class=\"track-info\">\r\n\t\t\t\t\t" . Bootstrap::glyphicon("info-sign") . "\r\n\t\t\t\t</a>\r\n\t\t\t\t<div class=\"hover-info\">\r\n\t\t\t\t\t<strong>Artist:</strong> " . $track->get_artists_str() . "<br />\r\n\t\t\t\t\t<strong>Album:</strong> " . $track->get_album()->get_name() . "<br />\r\n\t\t\t\t\t<strong>Year:</strong> " . $track->get_year() . "<br />\r\n\t\t\t\t\t<strong>Length:</strong> " . Time::format_succinct($track->get_length()) . "<br />\r\n\t\t\t\t\t<strong>Origin:</strong> " . $track->get_origin() . "<br />\r\n\t\t\t\t\t" . ($track->get_reclibid() ? "<strong>Reclib ID:</strong> " . $track->get_reclibid() . "<br />" : "") . "\r\n\t\t\t\t\t<strong>Censored:</strong> " . ($track->is_censored() ? "Yes" : "No") . "<br /> \r\n\t\t\t\t</div>\r\n\t\t\t</td>\r\n\t\t\t<td class=\"artist\">" . $track->get_artists_str() . "</td>\r\n\t\t\t<td class=\"title\">" . $track->get_title() . "</td>\r\n\t\t\t<td class=\"album\">" . $track->get_album()->get_name() . "</td>\r\n\t\t\t<td class=\"length nowrap\">" . Time::format_succinct($track->get_length()) . "</td>";
        if (Session::is_group_user("Playlist Admin")) {
            $playlists = array();
            foreach ($track->get_playlists_in() as $playlist) {
                $playlists[] = $playlist->get_id();
            }
            echo "<td class=\"icon\"><a href=\"#\" data-toggle=\"modal\" data-target=\"#playlist-modal\" data-backdrop=\"true\" data-keyboard=\"true\" data-dps-id=\"" . $track->get_id() . "\" data-playlists-in=\"" . implode(",", $playlists) . "\" class=\"playlist-add\" title=\"Add to playlist\" rel=\"twipsy\">" . Bootstrap::glyphicon("plus-sign") . "</a></td>";
        }
        echo (Session::is_group_user("Music Admin") ? "<td class=\"icon\"><a href=\"#\" data-toggle=\"modal\" data-target=\"#delete-modal\" data-backdrop=\"true\" data-keyboard=\"true\" data-dps-id=\"" . $track->get_id() . "\" class=\"track-delete\" title=\"Delete this track\" rel=\"twipsy\">" . Bootstrap::glyphicon("remove-sign") . "</a></td>" : "") . "\r\n\t\t</tr>";
    }
    echo "</table>";
    echo $pages->return;
} else {
    if ($query) {
        echo "<h3>Sorry, no results for " . $query . "</h3>";
        echo "<h4>Try a more generic search term.</h4>";
    }
    echo "<h4>Enter keywords below to search for tracks:</h4>\r\n\t<form action=\"" . LINK_ABS . "music/search\" method=\"GET\" class=\"form-inline\">\r\n\t\t<input type=\"text\" placeholder=\"Search Tracks\" name=\"q\" class=\"col-9\">\r\n       \t<input type=\"submit\" class=\"btn btn-primary\" value=\"Search\" class=\"col-2 col-offset-1\">\r\n    </form>";
}
if (Session::is_group_user("Playlist Admin")) {
    $playlist_modal_content = "<p>Select a playlist to add/remove <span class=\"playlist-track-title\">this track</span> to/from:</p><ul class=\"nav nav-pills nav-stacked\">";
    foreach (Playlists::get_all() as $playlist) {
        $playlist_modal_content .= "<li><a href=\"#\" class=\"playlist-select\" data-playlist-id=\"" . $playlist->get_id() . "\">" . Bootstrap::glyphicon("plus") . $playlist->get_name() . "</a></li>";
    }
    $playlist_modal_content .= "</ul>";
    echo Bootstrap::modal("playlist-modal", $playlist_modal_content, "Add to playlist", "<a href=\"#\" class=\"btn btn-primary\" data-dismiss=\"modal\">Done</a> <a href=\"" . LINK_ABS . "playlists\" class=\"btn btn-default\">Manage playlists</a>");
}
if (Session::is_group_user("Music Admin")) {
    echo Bootstrap::modal("delete-modal", "<p>Are you sure you want to move <span class=\"delete-track-title\">this track</span> to the trash?</p>", "Delete track", "<a href=\"#\" class=\"btn btn-primary yes-definitely-delete\">Yes</a> <a href=\"#\" class=\"btn btn-default\" data-dismiss=\"modal\">No</a>");
}
Exemple #5
0
$timeslots = array('00', '01', '02', '03', '04', '05', '06', '07', '08', '09', '10', '11', '12', '13', '14', '15', '16', '17', '18', '19', '20', '21', '22', '23');
$slots = SustainerSlots::get_all();
$i = 0;
echo "<table class=\"table table-striped table-bordered\">\r\n\t<thead>\r\n\t<tr>\r\n\t<th></th>\r\n\t<th>Monday</th>\r\n\t<th>Tuesday</th>\r\n\t<th>Wednesday</th>\r\n\t<th>Thursday</th>\r\n\t<th>Friday</th>\r\n\t<th>Saturday</th>\r\n\t<th>Sunday</th>\r\n\t</tr>\r\n\t</thead>\r\n\t<tbody>";
$i = 0;
foreach ($slots as $slot) {
    if ($i < 1) {
        echo "<tr>\r\n\t\t\t<td>" . $slot->get_time() . ":00</td>";
    }
    $thisPlaylist = Playlists::get_by_id($slot->get_playlist_id());
    $thisPlaylistColour = $thisPlaylist->get_colour() == "" ? 'FFFFFF' : $thisPlaylist->get_colour();
    echo "<td class='timeslot' id='slot-" . $slot->get_day() . "-" . $slot->get_time() . "' style='background-color: #" . $thisPlaylistColour . ";'>";
    echo $slot->get_audio_id() == NULL ? '' : "<span class=\"glyphicon glyphicon-time\" aria-hidden=\"true\"></span>";
    echo "</td>";
    $i++;
    if ($i > 6) {
        echo "</tr>";
        $i = 0;
    }
}
echo "</tbody>\r\n\t</table>";
echo "<form>";
foreach ($slots as $slot) {
    echo "<input type=\"hidden\" class=\"field-slots\" id=\"field-slot-" . $slot->get_day() . "-" . $slot->get_time() . "\" name=\"field-slot-" . $slot->get_day() . "-" . $slot->get_time() . "\" value=\"" . $slot->get_playlist_id() . "\">";
}
echo "</form>";
$playlistOptions = "";
foreach (Playlists::get_sustainer() as $playlist) {
    $playlistOptions .= "<option value=\"" . $playlist->get_id() . "\">" . $playlist->get_name() . "</option>";
}
echo Bootstrap::modal("update-modal", "\r\n\t\t<p id=\"slot-info\">Current slot information is unavailable.</p>\r\n\t\t<hr>\r\n\t\t<form class=\"form-horizontal\" action=\"?\" method=\"POST\">\r\n\t\t\t<fieldset>\r\n\t\t\t\t<div class=\"control-group\">\r\n\t\t\t\t\t<label class=\"control-label\" for=\"playlist-id\">New Playlist</label>\r\n\t\t\t\t\t<div class=\"controls\">\r\n\t\t\t\t\t\t<select id=\"playlist-id\" name=\"playlist-id\" data-width=\"100%\">\r\n\t\t\t\t\t\t\t" . $playlistOptions . "\r\n\t\t\t\t\t\t</select>\r\n\t\t\t\t\t\t<p class=\"help-block\">Select the playlist to be scheduled for <hh>.</p>\r\n\t\t\t\t\t</div>\r\n\t\t\t\t</div>\r\n\t\t\t</fieldset>\r\n\t\t\t<fieldset>\r\n\t\t\t\t<div class=\"control-group\">\r\n\t\t\t\t\t<label class=\"control-label\" for=\"prerecord-id\">Prerecorded File</label>\r\n\t\t\t\t\t<div class=\"controls\">\r\n\t\t\t\t\t\t<select id=\"prerecord-id\" name=\"prerecord-id\" data-width=\"100%\">\r\n\t\t\t\t\t\t</select>\r\n\t\t\t\t\t\t<p class=\"help-block\">Select the prerecorded content to be played out at <hh>.</p>\r\n\t\t\t\t\t</div>\r\n\t\t\t\t</div>\r\n\t\t\t</fieldset>\r\n\t\t\t<input type=\"hidden\"class=\"update-id\" name=\"updateid\">\r\n\t\t</form>\r\n\t", "Schedule Prerecorded Content", "<a class=\"btn btn-success\" id=\"update-playlist\" href=\"#\">Update Playlist</a><a class=\"btn btn-primary\" id=\"save-prerecord\" href=\"#\">Schedule Prerecord</a><a class=\"btn btn-danger\" id=\"delete-prerecord\" href=\"#\">Unschedule Prerecord</a><a class=\"btn btn-default\" data-dismiss=\"modal\">Cancel</a>") . "<script type=\"text/javascript\">\r\n\t\tboxes = \$('.timeslot');\r\n\t\tboxes.dblclick(function(){\r\n\t\t\t\$('#update-modal').modal('show');\r\n\t\t\t\$('.update-id').val(\$(this).attr('id'));\r\n\t\t\t\$.ajax({\r\n\t\t\t\turl: '" . LINK_ABS . "ajax/get-slot-status.php',\r\n\t\t\t\tdata: { updateid: \$('.update-id').val() },\r\n\t\t\t\ttype: 'POST',\r\n\t\t\t\tdataType: 'json',\r\n\t\t\t\terror: function(xhr,text,error) {\r\n\t\t\t\t\tvalue = \$.parseJSON(xhr.responseText);\r\n\t\t\t\t\talert(value.error);\r\n\t\t\t\t},\r\n\t\t\t\tsuccess: function(data,text,xhr) {\r\n\t\t\t\t\t\$('#slot-info').html(data.status);\r\n\t\t\t\t}\r\n\t\t\t});\r\n\t\t});\r\n</script>";
<!-- Modal -->
<div id="dialog" title="Add playlist on channel">
  <p>
  <?php 
$userName = Yii::app()->user->name;
$pls = Playlists::model()->findAll(array("condition" => "author = '{$userName}'", "order" => "id"));
$attributeLabels = Playlists::model()->attributeLabels();
if (count($pls) > 0) {
    echo '<table class="table table-hover">';
    echo '<tr>';
    echo '<td></td>';
    echo '<td>' . $attributeLabels['name'] . '</td>';
    echo '<td>' . $attributeLabels['fromDatetime'] . '</td>';
    echo '<td>' . $attributeLabels['toDatetime'] . '</td>';
    echo '<td>' . $attributeLabels['fromTime'] . '</td>';
    echo '<td>' . $attributeLabels['toTime'] . '</td>';
    echo '<td>' . $attributeLabels['weekDays'] . '</td>';
    echo '</tr>';
    foreach ($pls as $pl) {
        $weedDays = "";
        if ($pl['sun']) {
            $weedDays .= 'Sun ';
        }
        if ($pl['mon']) {
            $weedDays .= 'Mon ';
        }
        if ($pl['tue']) {
            $weedDays .= 'Tue ';
        }
        if ($pl['wed']) {
            $weedDays .= 'Wed ';
<?php

if (Session::is_group_user('Playlist Admin')) {
    if ($_REQUEST["id"]) {
        $playlist = Playlists::get_by_id($_REQUEST["id"]);
        $playlist->delete();
        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')));
        }
    }
} else {
    http_response_code(403);
    exit(json_encode(array('error' => 'Permission denied.')));
}
Exemple #8
0
 case "messages":
     $emails = Emails::get(NULL, NULL, NULL, 25, NULL);
     $return = "<table class=\"table table-striped table-hover\">\r\n\t\t\t<thead>\r\n\t\t\t\t<tr>\r\n\t\t\t\t\t<th class=\"icon\"></th>\r\n\t\t\t\t\t<th class=\"from\">From</th>\r\n\t\t\t\t\t<th class=\"subject\">Subject</th>\r\n\t\t\t\t\t<th class=\"datetime\">Date/Time</th>\r\n\t\t\t\t</tr>\r\n\t\t\t</thead>\r\n\t\t\t<tbody>";
     foreach ($emails as $email) {
         $return .= "<tr data-message-id=\"" . $email->get_id() . "\">\r\n\t\t\t\t<td class=\"icon\">" . ($email->get_new_flag() ? Bootstrap::glyphicon("envelope") : "") . "</td>\r\n\t\t\t\t<td class=\"from nowrap\">" . $email->get_sender() . "</td>\r\n\t\t\t\t<td class=\"subject nowrap\">" . $email->get_subject() . "</td>\r\n\t\t\t\t<td class=\"datetime nowrap\">" . date("d/m/y H:i", $email->get_datetime()) . "</td>\r\n\t\t\t</tr>";
     }
     $return .= "</tbody></table>";
     echo $return;
     break;
 case "message":
     $message = Emails::get_by_id($_REQUEST['id']);
     echo $message->get_body_formatted();
     $message->mark_as_read();
     break;
 case "playlists":
     $playlists = Playlists::get_all(false);
     $return = "";
     foreach ($playlists as $playlist) {
         $return .= "\r\n\t\t\t\t<div class=\"panel panel-default\">\r\n\t\t\t\t\t<div class=\"panel-heading\" data-toggle=\"collapse\" href=\"#playlist-" . $playlist->get_id() . "\">\r\n\t\t\t\t\t\t<h4 class=\"panel-title\">" . Bootstrap::glyphicon("play-circle") . $playlist->get_name() . "</h4>\r\n\t\t\t\t\t</div>\r\n\t\t\t\t\t<div id=\"playlist-" . $playlist->get_id() . "\" class=\"panel-collapse collapse\">\r\n\t\t\t\t\t\t<table class=\"table table-striped table-hover\">\r\n\t\t\t\t\t\t\t<thead>\r\n\t\t\t\t\t\t\t\t<tr>\r\n\t\t\t\t\t\t\t\t\t<th class=\"icon\"></th>\r\n\t\t\t\t\t\t\t\t\t<th class=\"artist\">Artist</th>\r\n\t\t\t\t\t\t\t\t\t<th class=\"title\">Title</th>\r\n\t\t\t\t\t\t\t\t\t<th class=\"album\">Album</th>\r\n\t\t\t\t\t\t\t\t\t<th class=\"length\">Length</th>\r\n\t\t\t\t\t\t\t\t</tr>\r\n\t\t\t\t\t\t\t</thead>\r\n\t\t\t\t\t\t\t<tbody>";
         foreach ($playlist->get_tracks() as $track) {
             $lastLogged = LogItems::get_by_audioid($track->get_id());
             $trackHotness = "";
             // default at 0
             if (isset($lastLogged)) {
                 $lastPlay = $lastLogged->get_datetime();
                 if ($lastPlay > time() - 604800) {
                     $trackHotness = "active";
                 }
                 // 1 week
                 if ($lastPlay > time() - 86400) {
                     $trackHotness = "info";
<?php

if (Session::is_group_user('Sustainer Admin')) {
    $slots = SustainerSlots::get_all();
    foreach ($slots as $slot) {
        $compareValue = "slot-" . $slot->get_day() . "-" . $slot->get_time();
        if ($compareValue == $_REQUEST["updateid"]) {
            if (!($playlist = Playlists::get_by_id((int) $_REQUEST["playlistid"]))) {
                exit(json_encode(array('error' => 'Invalid playlist ID.')));
            }
            if ((int) $_REQUEST["playlistid"] != $slot->get_playlist_id()) {
                //var_dump((int) $_REQUEST["playlistid"]);
                $slot->set_playlist_id((int) $_REQUEST["playlistid"]);
                $slot->save();
            }
            break;
        }
    }
    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.')));
}
Exemple #10
0
 public function get_playlists_in()
 {
     return Playlists::get_by_track($this);
 }
<?php

if (Session::is_group_user('Playlist Editor')) {
    $track = Tracks::get($_REQUEST['trackid']);
    $playlist = Playlists::get($_REQUEST['playlistid']);
    $result = false;
    switch ($_REQUEST['action']) {
        case "add":
            $result = $playlist->add_track($track);
            break;
        case "del":
            $result = $playlist->del_track($track);
            break;
    }
    if ($result) {
        $new_playlists = $track->get_playlists_in();
        $playlists_arr = array();
        foreach ($new_playlists as $playlist) {
            $playlists_arr[] = $playlist->get_id();
        }
        exit(json_encode(array('result' => 'success', 'playlists' => $playlists_arr)));
    } else {
        http_response_code(400);
        exit(json_encode(array('error' => 'Unable to add track to playlist.')));
    }
} else {
    http_response_code(403);
}
Exemple #12
0
 public static function get($id)
 {
     return Playlists::get_by_id($id);
 }
        if (!is_null($_REQUEST['name'])) {
            $playlist = new Playlist();
            $playlist->set_name($_REQUEST['name']);
            $playlist->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 {
            exit(json_encode(array('error' => 'No name specified for playlist.')));
        }
    } else {
        if (!($playlist = Playlists::get_by_id($_REQUEST['id']))) {
            exit(json_encode(array('error' => 'Invalid playlist ID.')));
        }
        $playlist->set_name($_REQUEST['name']);
        $playlist->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.')));
Exemple #14
0
<?php

if (isset($_REQUEST['refer']) && Session::is_user()) {
    $refer = preg_replace('/\\&/', '?', $_REQUEST["refer"], 1);
    header("Location: " . LINK_ABS . $refer);
}
MainTemplate::set_feature_image(LINK_ABS . "img/homepage.png");
echo "\n\t\t<script type=\"text/javascript\">\n\t\t\$(function () {\n\t\t\t\$('#username').focus();\n\t\t\t\$('.form-signin').submit(function(event) {\n\t\t\t\tevent.preventDefault();\n\t\t\t\t\$('#submit').button('loading');\n\t\t\t\t\$('.help-inline').remove();\n\t\t\t\t\$.post('ajax/login.php', \$(this).serialize(), function(data) {\n\t\t\t\t\tif(data == \"success\") { \n\t\t\t\t\t\tlocation.reload()\n\t\t\t\t\t} else {\n\t\t\t\t\t\t\$('#submit').after('<span class=\"help-inline\">'+data+'</span>');\n\t\t\t\t\t\t\$('#submit').button('reset');\n\t\t\t\t\t}\n\t\t\t\t})\n\t\t\t});\n\t\t});\n\t\t</script>";
$feature = "\n\t\t\t<div class=\"row\">\n\t\t\t\t<div class=\"col-sm-8\">\n\t\t\t\t\t<h1>Digiplay <small>by Radio Warwick</small></h1>\n\t\t\t\t\t<p>A magical software suite run by miniature elves, which is amazing because elves are already very small by their nature.</p>\n\t\t\t\t</div>\n\t\t\t\t<div class=\"col-sm-4\">\n\t\t\t\t" . (Session::is_user() ? "\n\t\t\t\t\t<h2>Common Tasks</h2>\n\t\t\t\t\t<a href=\"music/upload/\" class=\"btn btn-primary btn-large btn-block\">Upload Audio &raquo;</a>\n\t\t\t\t\t<a href=\"playlists/\" class=\"btn btn-primary btn-large btn-block\">Edit Playlists &raquo;</a>\n\t\t\t\t\t<a href=\"sustainer/\" class=\"btn btn-primary btn-large btn-block\">Schedule Prerecorded Content &raquo;</a>\n\t\t\t\t\t<a href=\"faults/\" class=\"btn btn-primary btn-large btn-block\">Report a Fault &raquo;</a>\n\t\t\t\t\t" . (Session::is_group_user("Studio Admin") ? "<a href=\"reset.php\" class=\"btn btn-primary btn-large btn-block\">Reset Playout Systems &raquo;</a>" : "") . "\n\t\t\t\t" : "\n\t\t\t\t\t<form class=\"form-signin\" action=\"ajax/login.php\" method=\"post\">\n\t\t\t\t\t\t<div class=\"form-group" . (isset($_REQUEST['refer']) ? " has-error" : "") . "\">\n\t\t\t\t\t\t\t<input id=\"username\" name=\"username\" type=\"text\" class=\"form-control input-lg\" placeholder=\"Username\">\n\t\t\t\t\t\t</div>\n\t\t\t\t\t\t<div class=\"form-group" . (isset($_REQUEST['refer']) ? " has-error" : "") . "\">\n\t\t\t\t\t\t\t<input id=\"password\" name=\"password\" type=\"password\" class=\"form-control input-lg\" placeholder=\"Password\">\n\t\t\t\t\t\t</div>\n\t\t\t\t\t\t<div class=\"form-group\">\n\t\t\t\t\t\t\t<input type=\"submit\" class=\"btn btn-lg " . (isset($_REQUEST['refer']) ? "btn-danger" : "btn-primary") . " btn-block\" id=\"submit\" name=\"submit\" value=\"Log In\">\n\t\t\t\t\t\t</div>\n\t\t\t\t\t</form>\n\t\t\t\t") . "\n\t\t\t\t</div>\n\t\t\t</div>\n\t\t";
MainTemplate::set_feature_html($feature);
echo "<div class=\"row\">\n\t\t\t<div class=\"col-sm-4\">\n\t\t\t\t<h2>Music Library</h2>\n\t\t\t\t<dl>\n\t\t\t\t\t<dt>Tracks Stored</dt>\n\t\t\t\t\t<dd>" . number_format(Tracks::get_total_tracks()) . "</dd>\n\t\t\t\t\t<dt>Length of Tracks</dt>\n\t\t\t\t\t<dd>" . Time::format_pretty(Tracks::get_total_length()) . "</dd>\n\t\t\t\t\t<dt>Playlisted Tracks</dt>\n\t\t\t\t\t<dd>" . (count(Tracks::get_playlisted()) - count(Tracks::get_playlisted(Playlists::get(0)))) . "</dd>\n\t\t\t\t</dl>\n\t\t\t</div>\n\t\t\t<div class=\"col-sm-4\">\n\t\t\t\t<h2>Sustainer Service</h2>\n\t\t\t\t<dl>\n\t\t\t\t\t<dt>Tracks on Sustainer</dt>\n\t\t\t\t\t<dd>" . Sustainer::get_total_tracks() . "</dd>\n\t\t\t\t\t<dt>Length of Sustainer Playlist</dt>\n\t\t\t\t\t<dd>" . Sustainer::get_total_length_formatted() . "</dd>\n\t\t\t\t</dl>\n\t\t\t\t<a class=\"btn btn-primary btn-block\" href=\"" . LINK_ABS . "sustainer/\">" . Bootstrap::glyphicon("headphones") . "Now playing</a>\n\t\t\t\t<a class=\"btn btn-primary btn-block\" href=\"" . LINK_ABS . "playlists/detail/0\">" . Bootstrap::glyphicon("list") . "View playlist</a>\n\t\t\t</div>\n\t\t\t<div class=\"col-sm-4\">\n\t\t\t\t<h2>Newest Tracks</h2>";
$tracks = Tracks::get_newest(4);
echo "<table class=\"table table-striped table-hover table-condensed\" cellspacing=\"0\">";
foreach ($tracks as $track) {
    echo "\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<td class=\"icon\">\n\t\t\t\t\t\t\t<a href=\"" . LINK_ABS . "music/detail/" . $track->get_id() . "\" class=\"track-info\">\n\t\t\t\t\t\t\t\t" . Bootstrap::glyphicon("info-sign") . "\n\t\t\t\t\t\t\t</a>\n\t\t\t\t\t\t</td>\n\t\t\t\t\t\t<td class=\"title\">" . $track->get_title() . " by " . $track->get_artists_str() . "</td>\n\t\t\t\t\t</tr>";
}
echo "\n\t\t\t\t</table>\n\t\t\t\t<a class=\"btn btn-primary btn-block\" href=\"" . LINK_ABS . "music/\">" . Bootstrap::glyphicon("chevron-right") . "More</a>\n\t\t\t</div>\n\t\t</div>";
if (Session::is_user()) {
    $lastlogin = Session::get_lastlogin();
    if ($lastlogin) {
        echo "<p class=\"text-success\">You last logged in: " . strftime("%A %e %B %G %H:%M", $lastlogin) . "</p>";
    } else {
        echo "<p class=\"text-success\">You've never logged in before! Welcome to the Digiplay Web Management System.</p>";
    }
    echo "<h4>Tracks of the Day:</h4><ul>";
    $tracks = Tracks::get_tracks_of_the_day(3);
    foreach ($tracks as $track) {
        echo "<li><a href=\"music/detail/" . $track->get_id() . "\">" . $track->get_artists_str() . " - " . $track->get_title() . "</a></li>";
    }
    echo "</ul>";
}
Exemple #15
0
<?php

Output::set_title("Playlist Detail");
$playlist = Playlists::get_by_id($_REQUEST['q']);
$limit = isset($_GET['n']) ? $_REQUEST['n'] : 10;
$page = isset($_REQUEST['p']) ? $_REQUEST['p'] : 1;
MainTemplate::set_subtitle("List tracks on a playlist, remove tracks");
$tracks = $playlist->get_tracks($limit, ($page - 1) * $limit);
if ($tracks) {
    $pages = new Paginator();
    $pages->items_per_page = $limit;
    $pages->querystring = $playlist->get_id();
    $pages->mid_range = 5;
    $pages->items_total = $playlist->count_tracks();
    $pages->paginate();
    $low = ($page - 1) * $limit + 1;
    $high = $low + $limit - 1 > $pages->items_total ? $pages->items_total : $low + $limit - 1;
    echo "<script>\r\n\t\t\$(function () {\r\n\t\t\t\$('.track-info').popover({\r\n\t\t\t\t'html': true, \r\n\t\t\t\t'trigger': 'hover',\r\n\t\t\t\t'title': function() { \r\n\t\t\t\t\treturn(\$(this).parent().parent().find('.title').html())\r\n\t\t\t\t},\r\n\t\t\t\t'content': function() {\r\n\t\t\t\t\treturn(\$(this).parent().find('.hover-info').html());\r\n\t\t\t\t}\r\n\t\t\t});\r\n" . (Session::is_group_user("Playlist Editor") ? "\r\n\t\t\t\$('.track-remove').click(function() {\r\n\t\t\t\ttrackid = \$(this).attr('data-dps-track-id');\r\n\t\t\t\tplaylistid = \$(this).attr('data-dps-playlist-id');\r\n\t\t\t\t\$.ajax({\r\n\t\t\t\t\turl: '" . LINK_ABS . "ajax/track-playlist-update.php',\r\n\t\t\t\t\tdata: 'playlistid='+playlistid+'&trackid='+trackid+'&action=del',\r\n\t\t\t\t\ttype: 'POST',\r\n\t\t\t\t\terror: function(xhr,text,error) {\r\n\t\t\t\t\t\tvalue = \$.parseJSON(xhr.responseText);\r\n\t\t\t\t\t\talert(value.error);\r\n\t\t\t\t\t},\r\n\t\t\t\t\tsuccess: function(data,text,xhr) {\r\n\t\t\t\t\t\twindow.location.reload(true); \r\n\t\t\t\t\t}\r\n\t\t\t\t});\r\n\t\t\t});\r\n" : "") . "\t\t});\r\n\t</script>";
    echo "<h3>Tracks on playlist '" . $playlist->get_name() . "'</h3>";
    echo "<div class=\"row\"><div class=\"col-lg-5\"><h5>Showing results " . $low . " to " . $high . "</h5></div><div class=\"pull-right\">" . $pages->display_jump_menu() . $pages->display_items_per_page() . "</div></div>";
    echo "<table class=\"table table-striped\" cellspacing=\"0\">\r\n\t<thead>\r\n\t\t<tr>\r\n\t\t\t<th class=\"icon\"> </th>\r\n\t\t\t<th class=\"artist\">Artist</th>\r\n\t\t\t<th class=\"title\">Title</th>\r\n\t\t\t<th class=\"album\">Album</th>\r\n\t\t\t<th class=\"length nowrap\">Length</th> \r\n\t\t\t" . (Session::is_group_user("Playlist Editor") ? "<th class=\"icon\"></th>" : "") . "\r\n\t\t</tr>\r\n\t</thead>";
    foreach ($tracks as $track) {
        echo "\r\n\t\t<tr id=\"" . $track->get_id() . "\">\r\n\t\t\t<td class=\"icon\">\r\n\t\t\t\t<a href=\"" . LINK_ABS . "music/detail/" . $track->get_id() . "\" class=\"track-info\">\r\n\t\t\t\t\t" . Bootstrap::glyphicon("info-sign") . "\r\n\t\t\t\t</a>\r\n\t\t\t\t<div class=\"hover-info\">\r\n\t\t\t\t\t<strong>Artist:</strong> " . $track->get_artists_str() . "<br />\r\n\t\t\t\t\t<strong>Album:</strong> " . $track->get_album()->get_name() . "<br />\r\n\t\t\t\t\t<strong>Year:</strong> " . $track->get_year() . "<br />\r\n\t\t\t\t\t<strong>Length:</strong> " . Time::format_succinct($track->get_length()) . "<br />\r\n\t\t\t\t\t<strong>Origin:</strong> " . $track->get_origin() . "<br />\r\n\t\t\t\t\t" . ($track->get_reclibid() ? "<strong>Reclib ID:</strong> " . $track->get_reclibid() . "<br />" : "") . "\r\n\t\t\t\t\t<strong>Censored:</strong> " . ($track->is_censored() ? "Yes" : "No") . "<br /> \r\n\t\t\t\t</div>\r\n\t\t\t</td>\r\n\t\t\t<td class=\"artist\">" . $track->get_artists_str() . "</td>\r\n\t\t\t<td class=\"title\">" . $track->get_title() . "</td>\r\n\t\t\t<td class=\"album\">" . $track->get_album()->get_name() . "</td>\r\n\t\t\t<td class=\"length nowrap\">" . Time::format_succinct($track->get_length()) . "</td>";
        echo (Session::is_group_user("Playlist Editor") ? "<td class=\"icon\"><a href=\"#\" data-dps-track-id=\"" . $track->get_id() . "\" data-dps-playlist-id=\"" . $playlist->get_id() . "\" class=\"track-remove\" title=\"Remove this track\" rel=\"twipsy\">" . Bootstrap::glyphicon("remove-sign") . "</a></td>" : "") . "\r\n\t\t</tr>";
    }
    echo "</table>";
    echo $pages->return;
} else {
    if ($playlist) {
        echo "<h3>Sorry, no tracks are on the playlist '" . $playlist->get_name() . "'</h3>";
        if (Session::is_group_user("Playlist Editor")) {
?>
    </div>

    <div class="row">
    <?php 
if (!$model->isNewRecord) {
    echo $form->labelEx($model, 'channels');
    printf("<div id='channelsList'>");
    $playlistsToPoint = $model->playlistToPoint;
    for ($ii = 1; $ii <= 3; $ii++) {
        printf("<div class='ChannelsContainer btn-toolbar' data-channelid='%s' role='toolbar' aria-label=''>", $ii);
        printf("<div class='btn-group' role='group' aria-label=''>" . "<button type='button' class='btn btn-default ChannelButt'>" . "Channel %s </button>" . "<button type='button' class='AddPlaylistsBut btn btn-info' data-channelid='%s'>" . "<span class='glyphicon glyphicon-plus'></span> Add playlists" . "</button></div>", $ii, $ii);
        $channelPlaylists = [];
        foreach ($playlistsToPoint as $pl) {
            if ($pl->channel_type == $ii) {
                $channelPlaylists[] = Playlists::model()->findByPk($pl->id_playlist);
            }
        }
        if (count($playlistsToPoint) > 0) {
            echo "<div class='btn-group' role='group' aria-label=''>";
        }
        foreach ($channelPlaylists as $pl) {
            printf("<button type='button' class='PlaylistLinks btn btn-default' " . "data-plid='%s'>%s</button>", $pl['id'], CHtml::link($pl['name'], array('playlists/' . $pl['id'])));
            printf("<button type='button' class='RemovePlaylist btn btn-danger' " . "data-plidtoremove='%s' " . "data-channelidpltoremove='%s' " . ">x</button>", $pl['id'], $ii);
        }
        if (count($playlistsToPoint) > 0) {
            echo "</div>";
        }
        echo "</div>";
    }
    printf("</div>");
<?php

if (Session::is_group_user('Playlist Admin')) {
    foreach ($_POST["id"] as $key => $id) {
        $playlist = Playlists::get_by_id($id);
        $playlist->set_sortorder(++$key);
        $playlist->save();
    }
    exit("success");
} else {
    exit("You do not have permission to modify this.");
}
<?php

if (Session::is_group_user('Sustainer Admin')) {
    $slots = SustainerSlots::get_all();
    foreach ($slots as $slot) {
        $compareValue = "slot-" . $slot->get_day() . "-" . $slot->get_time();
        if ($compareValue == $_REQUEST["updateid"]) {
            $prerecordText = "Currently this hour is scheduled with the <b>" . Playlists::get_by_id($slot->get_playlist_id())->get_name() . "</b> playlist";
            if ($slot->get_audio_id() != NULL) {
                $prerecordText .= " <i>AND</i> the prerecord <b>" . Prerecs::get_by_id($slot->get_audio_id())->get_title() . "</b> is scheduled.";
            } else {
                $prerecordText .= " <b>AND</b> there is no prerecord scheduled.";
            }
            break;
        }
    }
    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', 'status' => $prerecordText)));
    }
} else {
    http_response_code(403);
    exit(json_encode(array('error' => 'Permission denied.')));
}
Exemple #19
0
<?php

Output::set_title("Sustainer Playlists");
Output::add_script(LINK_ABS . "js/jquery-ui-1.10.3.custom.min.js");
MainTemplate::set_subtitle("View and edit music playlists");
echo "<script type=\"text/javascript\">\n\$(function() {\n\t\$('.table-striped tbody').sortable({ \n\t\taxis: 'y',\n\t\thandle: '.move',\n\t\thelper: function(e, tr){\n\t\t\tvar originals = tr.children();\n\t\t\tvar helper = tr.clone();\n\t\t\thelper.children().each(function(index) {\n\t\t\t\t\$(this).width(originals.eq(index).width())\n\t\t\t});\n\t\t\treturn helper;\n\t\t},\n\t\tupdate : function () { \n\t\t\t\$('.move').removeClass('.glyphicon-move').addClass('.glyphicon-refresh');\n            \$.ajax({\n                type: 'POST',\n                url: '" . LINK_ABS . "/ajax/update-playlist-sortorder.php',\n                data: \$('.sortorder').serialize(),\n                success: function(data) {\n                \tif(data != 'success') {\n                \t\t\$('.sortorder').before('" . Bootstrap::alert_message_basic("error", "'+data+'", "Error!") . "');\n                \t\t\$('.alert-message').alert();\n                \t}\n                \t\$('.move').removeClass('.glyphicon-refresh').addClass('.glyphicon-move');\n                }\n            });\n        }\n\t}).disableSelection();\n\n\t\$('.info').popover({\n\t\t'html': true, \n\t\t'trigger': 'hover',\n\t\t'title': function() { \n\t\t\treturn(\$(this).parent().parent().find('.title').html()+' tracks')\n\t\t},\n\t\t'content': function() {\n\t\t\treturn(\$(this).parent().find('.hover-info').html());\n\t\t}\n\t});\n\tif(window.location.hash == '#add') {\n\t\t\$('#add').click();\n\t}\n\t\$('a[href=\"" . LINK_ABS . "playlists/index.php#add\"]').click(function() {\n\t\tevent.preventDefault();\n\t\t\$('#add').click();\n\t});\n" . (Session::is_group_user("Playlist Admin") ? "\n\t\tvar playlist_id;\n\t\t\$('.delete-playlist').click(function() {\n\t\t\t\$('.delete-playlist-title').html(\$(this).parent().parent().find('.title').html());\n\t\t\tplaylist_id = \$(this).attr('data-dps-id');\n\t\t});\n\n\t\t\$('.edit-playlist').click(function() {\n\t\t\t\$('.playlist-edit-name').val(\$(this).parent().parent().find('.title').html());\n\t\t\t\$('.update-id').val(\$(this).attr('data-dps-id'));\n\t\t});\n\n\t\t\$('.yes-definitely-delete').click(function() {\n\t\t\t\$.ajax({\n\t\t\t\turl: '" . LINK_ABS . "ajax/delete-playlist.php',\n\t\t\t\tdata: 'id='+playlist_id,\n\t\t\t\ttype: 'POST',\n\t\t\t\terror: function(xhr,text,error) {\n\t\t\t\t\tvalue = \$.parseJSON(xhr.responseText);\n\t\t\t\t\talert(value.error);\n\t\t\t\t},\n\t\t\t\tsuccess: function(data,text,xhr) {\n\t\t\t\t\twindow.location.reload(true); \n\t\t\t\t}\n\t\t\t});\n\t\t});\n\n\t\t\$('.add-playlist').click(function() {\n\t\t\t\$.ajax({\n\t\t\t\turl: '" . LINK_ABS . "ajax/add-update-playlist.php',\n\t\t\t\tdata: 'name='+\$('.playlist-name').val(),\n\t\t\t\ttype: 'POST',\n\t\t\t\terror: function(xhr,text,error) {\n\t\t\t\t\tvalue = \$.parseJSON(xhr.responseText);\n\t\t\t\t\talert(value.error);\n\t\t\t\t},\n\t\t\t\tsuccess: function(data,text,xhr) {\n\t\t\t\t\twindow.location.reload(true); \n\t\t\t\t}\n\t\t\t});\n\t\t});\n\n\t\t\$('.playlist-name').keypress(function(e) { if(e.keyCode == 13) { e.preventDefault(); \$('.add-playlist').click(); }});\n\n\n\n\t\t\$('.update-playlist').click(function() {\n\t\t\t\$.ajax({\n\t\t\t\turl: '" . LINK_ABS . "ajax/add-update-playlist.php',\n\t\t\t\tdata: 'id='+\$('.update-id').val()+'&name='+\$('.playlist-edit-name').val(),\n\t\t\t\ttype: 'POST',\n\t\t\t\terror: function(xhr,text,error) {\n\t\t\t\t\tvalue = \$.parseJSON(xhr.responseText);\n\t\t\t\t\talert(value.error);\n\t\t\t\t},\n\t\t\t\tsuccess: function(data,text,xhr) {\n\t\t\t\t\twindow.location.reload(true); \n\t\t\t\t}\n\t\t\t});\n\t\t});\n\n\t\t\$('.playlist-edit-name').keypress(function(e) { if(e.keyCode == 13) { e.preventDefault(); \$('.update-playlist').click(); }});\n" : "") . "});\n</script>";
echo "<h3>Current playlists:</h3>";
echo "\n<form class=\"sortorder\">\n<div class=\"table-responsive\">\n<table class=\"table table-striped\">\n\t<thead>\n\t\t<tr>\n\t\t\t<th class=\"icon\"></th>\n\t\t\t<th>Title</th>\n\t\t\t<th class=\"icon\">Items</th>\n\t\t\t";
if (Session::is_group_user("Playlist Admin")) {
    echo "\n\t\t\t<th class=\"icon\"></th>\n\t\t\t<th class=\"icon\"></th>\n\t\t\t<th class=\"icon\"></th>\n\t";
}
echo "\n\t\t</tr>\n\t</thead>\n\t<tbody>\n";
foreach (Playlists::get_all(false) as $playlist) {
    echo "\n\t\t<tr>\n\t\t\t<td>\n\t\t\t\t<a href=\"" . LINK_ABS . "playlists/detail/" . $playlist->get_id() . "\" class=\"info\">\n\t\t\t\t\t" . Bootstrap::glyphicon("info-sign") . "\n\t\t\t\t\t<input type=\"hidden\" name=\"id[]\" value=\"" . $playlist->get_id() . "\">\n\t\t\t\t</a>\n\t\t\t\t<div class=\"hover-info\">\n\t\t\t\t";
    $count = $playlist->count_tracks();
    foreach ($playlist->get_tracks(10) as $track) {
        echo "<strong>" . $track->get_title() . "</strong> by " . $track->get_artists_str() . "<br />";
    }
    if ($count > 10) {
        echo "<br />and <strong>" . ($count - 10) . " more...<br />";
    }
    echo "\n\t\t\t\t</div>\n\t\t\t</td>\n\t\t\t<td class=\"title\">" . $playlist->get_name() . "</td>\n\t\t\t<td>" . count($playlist->get_tracks()) . "</td>\n\t";
    if (Session::is_group_user("Playlist Admin")) {
        echo "\n\t\t\t<td>\n\t\t\t\t<a href=\"#\" data-toggle=\"modal\" data-target=\"#update-modal\" data-dps-id=\"" . $playlist->get_id() . "\" class=\"edit-playlist\" title=\"Edit playlist name\" rel=\"twipsy\">\n\t\t\t\t\t" . Bootstrap::glyphicon("pencil") . "\n\t\t\t\t</a>\n\t\t\t</td>\n\t\t\t<td>\n\t\t\t\t<a href=\"#\" data-toggle=\"modal\" data-target=\"#delete-modal\" data-dps-id=\"" . $playlist->get_id() . "\" class=\"delete-playlist\" title=\"Delete this playlist\" rel=\"twipsy\">\n\t\t\t\t\t" . Bootstrap::glyphicon("remove-sign") . "\n\t\t\t\t</a>\n\t\t\t</td>\n\t\t\t<td>\n\t\t\t\t<a href=\"#\" class=\"move\">\n\t\t\t\t\t" . Bootstrap::glyphicon("move move") . "\n\t\t\t\t</a>\n\t\t\t</td>\n\t\t";
    }
    echo "\n\t\t</tr>";
}
echo "\n\t</tbody>\n</table>\n</div>\n</form>\n";
if (Session::is_group_user("Playlist Admin")) {
    echo "<a href=\"#\" data-toggle=\"modal\" data-target=\"#addnew-modal\" id=\"add\">Add a new playlist &raquo;</a>" . Bootstrap::modal("addnew-modal", "\n\t\t<form class=\"form-horizontal\" action=\"" . LINK_ABS . "/ajax/add-update-playlist.php\" method=\"POST\">\n\t\t\t<fieldset>\n\t\t\t\t<div class=\"control-group\">\n\t\t\t\t\t<label class=\"control-label\" for=\"name\">Name</label>\n\t\t\t\t\t<div class=\"controls\">\n\t\t\t\t\t\t<input type=\"text\" class=\"form-control playlist-name\" id=\"name\">\n\t\t\t\t\t\t<p class=\"help-block\">Enter a name for the new playlist.</p>\n\t\t\t\t\t</div>\n\t\t\t\t</div>\n\t\t\t</fieldset>\n\t\t</form>\n\t", "Add new playlist", "<a class=\"btn btn-primary add-playlist\" href=\"#\">Save</a><a class=\"btn btn-default\" data-dismiss=\"modal\">Cancel</a>") . "</div>\n</div>" . Bootstrap::modal("update-modal", "\n\t\t<form class=\"form-horizontal\" action=\"" . LINK_ABS . "/ajax/add-update-playlist.php\" method=\"POST\">\n\t\t\t<fieldset>\n\t\t\t\t<div class=\"control-group\">\n\t\t\t\t\t<label class=\"control-label\" for=\"name\">Name</label>\n\t\t\t\t\t<div class=\"controls\">\n\t\t\t\t\t\t<input type=\"hidden\"class=\"update-id\">\n\t\t\t\t\t\t<input type=\"text\" class=\"form-control playlist-edit-name\">\n\t\t\t\t\t\t<p class=\"help-block\">Enter a name for the playlist.</p>\n\t\t\t\t\t</div>\n\t\t\t\t</div>\n\t\t\t</fieldset>\n\t\t</form>\n\t", "Edit playlist name", "<a class=\"btn btn-primary update-playlist\" href=\"#\">Save</a><a class=\"btn btn-default\" data-dismiss=\"modal\">Cancel</a>") . "</div>\n</div>" . Bootstrap::modal("delete-modal", "<p>Are you sure you want to permanently delete <span class=\"delete-playlist-title\">this playlist</span>? </p><p>(this does not delete any of the tracks on it)</p>", "Delete playlist", "<a href=\"#\" class=\"btn btn-primary yes-definitely-delete\">Yes</a> <a href=\"#\" class=\"btn btn-default\" data-dismiss=\"modal\">No</a>");
}