From 043fbd1dfb2145e87fb0a62a2585be5355fb8ef1 Mon Sep 17 00:00:00 2001 From: denise Date: Wed, 30 Jan 2013 10:55:24 -0500 Subject: [PATCH] CC-4886: Warn if track is part of a playlist when deleting from library. -done --- airtime_mvc/application/models/Block.php | 14 +++++++ airtime_mvc/application/models/Playlist.php | 15 +++++++ airtime_mvc/application/models/StoredFile.php | 11 +++-- .../public/js/airtime/library/library.js | 42 ++++++++++++++++++- 4 files changed, 78 insertions(+), 4 deletions(-) diff --git a/airtime_mvc/application/models/Block.php b/airtime_mvc/application/models/Block.php index 7053e658d..cda10c1a3 100644 --- a/airtime_mvc/application/models/Block.php +++ b/airtime_mvc/application/models/Block.php @@ -1434,6 +1434,20 @@ SQL; return $output; } + public static function getAllBlockContent() + { + $con = Propel::getConnection(); + $sql = <<query($sql)->fetchAll(); + $real_files = array(); + foreach ($files as $f) { + $real_files[] = $f['file_id']; + } + return $real_files; + } // smart block functions end } diff --git a/airtime_mvc/application/models/Playlist.php b/airtime_mvc/application/models/Playlist.php index 1c446f182..ea3bf5b53 100644 --- a/airtime_mvc/application/models/Playlist.php +++ b/airtime_mvc/application/models/Playlist.php @@ -955,6 +955,21 @@ SQL; return $result; } + public static function getAllPlaylistContent() + { + $con = Propel::getConnection(); + $sql = <<query($sql)->fetchAll(); + $real_files = array(); + foreach ($files as $f) { + $real_files[] = $f['file_id']; + } + return $real_files; + } + } // class Playlist class PlaylistNotFoundException extends Exception {} diff --git a/airtime_mvc/application/models/StoredFile.php b/airtime_mvc/application/models/StoredFile.php index fd9c3708a..db7454d6c 100644 --- a/airtime_mvc/application/models/StoredFile.php +++ b/airtime_mvc/application/models/StoredFile.php @@ -773,7 +773,8 @@ SQL; $results = Application_Model_Datatables::findEntries($con, $displayColumns, $fromTable, $datatables); $futureScheduledFiles = Application_Model_Schedule::getAllFutureScheduledFiles(); - + $playlistBlockFiles = array_merge(Application_Model_Playlist::getAllPlaylistContent(), + Application_Model_Block::getAllBlockContent()); //Used by the audio preview functionality in the library. foreach ($results['aaData'] as &$row) { $row['id'] = intval($row['id']); @@ -814,8 +815,12 @@ SQL; if ($type == "au") { $row['audioFile'] = $row['id'].".".pathinfo($row['filepath'], PATHINFO_EXTENSION); $row['image'] = ''; - if (in_array($row['id'], $futureScheduledFiles)) { - $row['checkbox'] .= ''; + if (in_array($row['id'], $futureScheduledFiles) && in_array($row['id'], $playlistBlockFiles)) { + $row['checkbox'] .= ''; + } elseif (in_array($row['id'], $futureScheduledFiles)) { + $row['checkbox'] .= ''; + } elseif (in_array($row['id'], $playlistBlockFiles)) { + $row['checkbox'] .= ''; } } elseif ($type == "pl") { $row['image'] = ''; diff --git a/airtime_mvc/public/js/airtime/library/library.js b/airtime_mvc/public/js/airtime/library/library.js index 4280b3b4c..b73185292 100644 --- a/airtime_mvc/public/js/airtime/library/library.js +++ b/airtime_mvc/public/js/airtime/library/library.js @@ -606,7 +606,7 @@ var AIRTIME = (function(AIRTIME) { return false; }); - $(nRow).find(".track-future").qtip({ + $(nRow).find(".track-scheduled").qtip({ content: { text: $.i18n._("This track is scheduled in the future") }, @@ -626,6 +626,46 @@ var AIRTIME = (function(AIRTIME) { at: "right center" }, }); + $(nRow).find(".track-sched-pl-bl").qtip({ + content: { + text: $.i18n._("This track is scheduled in the future and belongs to a playlist or smart block") + }, + hide: { + delay: 500, + fixed: true + }, + style: { + border: { + width: 0, + radius: 4 + }, + classes: "ui-tooltip-dark ui-tooltip-rounded" + }, + position: { + my: "left bottom", + at: "right center" + }, + }); + $(nRow).find(".track-pl-bl").qtip({ + content: { + text: $.i18n._("This track belongs to a playlist or smart block") + }, + hide: { + delay: 500, + fixed: true + }, + style: { + border: { + width: 0, + radius: 4 + }, + classes: "ui-tooltip-dark ui-tooltip-rounded" + }, + position: { + my: "left bottom", + at: "right center" + }, + }); // add a tool tip to appear when the user clicks on the type // icon.