CC-4904: Library -> Sort by status doesn't work
- added 2 columns to cc_files (is_scheduled, is_playlist) - split library status column into two columns (scheduled, playlist) - is_scheduled gets updated when a track plays out, or when a file gets added/removed from/to a show - is_playlist gets updated when a file gets added/removed from/to a playlist/block, when a playlist/block gets deleted, or when a playlist/block's contents is cleared
This commit is contained in:
parent
384298f680
commit
8309593a0f
14 changed files with 376 additions and 59 deletions
|
@ -466,6 +466,12 @@ SQL;
|
|||
|
||||
foreach ($p_items as $ac) {
|
||||
$res = $this->insertPlaylistElement($this->buildEntry($ac, $pos));
|
||||
|
||||
// update is_playlist flag in cc_files to indicate the
|
||||
// file belongs to a playlist or block (in this case a playlist)
|
||||
$db_file = CcFilesQuery::create()->findPk($ac[0], $this->con);
|
||||
$db_file->setDbIsPlaylist(true)->save($this->con);
|
||||
|
||||
$pos = $pos + 1;
|
||||
Logging::info("Adding $ac[1] $ac[0]");
|
||||
|
||||
|
@ -574,10 +580,21 @@ SQL;
|
|||
|
||||
try {
|
||||
|
||||
// we need to get the file id of the item we are deleting
|
||||
// before the item gets deleted from the playlist
|
||||
$itemsToDelete = CcPlaylistcontentsQuery::create()
|
||||
->filterByPrimaryKeys($p_items)
|
||||
->filterByDbFileId(null, Criteria::NOT_EQUAL)
|
||||
->find($this->con);
|
||||
|
||||
CcPlaylistcontentsQuery::create()
|
||||
->findPKs($p_items)
|
||||
->delete($this->con);
|
||||
|
||||
// now that the items have been deleted we can update the
|
||||
// is_playlist flag in cc_files
|
||||
Application_Model_StoredFile::setIsPlaylist($itemsToDelete, 'playlist', false);
|
||||
|
||||
$contents = CcPlaylistcontentsQuery::create()
|
||||
->filterByDbPlaylistId($this->id)
|
||||
->orderByDbPosition()
|
||||
|
@ -894,15 +911,36 @@ SQL;
|
|||
$user = new Application_Model_User($userInfo->id);
|
||||
$isAdminOrPM = $user->isUserType(array(UTYPE_ADMIN, UTYPE_PROGRAM_MANAGER));
|
||||
|
||||
// get only the files from the playlists
|
||||
// we are about to delete
|
||||
$itemsToDelete = CcPlaylistcontentsQuery::create()
|
||||
->filterByDbPlaylistId($p_ids)
|
||||
->filterByDbFileId(null, Criteria::NOT_EQUAL)
|
||||
->find();
|
||||
|
||||
$updateIsPlaylistFlag = false;
|
||||
|
||||
if (!$isAdminOrPM) {
|
||||
$leftOver = self::playlistsNotOwnedByUser($p_ids, $p_userId);
|
||||
if (count($leftOver) == 0) {
|
||||
CcPlaylistQuery::create()->findPKs($p_ids)->delete();
|
||||
$updateIsPlaylistFlag = true;
|
||||
|
||||
} else {
|
||||
throw new PlaylistNoPermissionException;
|
||||
}
|
||||
} else {
|
||||
CcPlaylistQuery::create()->findPKs($p_ids)->delete();
|
||||
$updateIsPlaylistFlag = true;
|
||||
}
|
||||
|
||||
if ($updateIsPlaylistFlag) {
|
||||
// update is_playlist flag in cc_files
|
||||
Application_Model_StoredFile::setIsPlaylist(
|
||||
$itemsToDelete,
|
||||
'playlist',
|
||||
false
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -929,8 +967,22 @@ SQL;
|
|||
*/
|
||||
public function deleteAllFilesFromPlaylist()
|
||||
{
|
||||
// get only the files from the playlist
|
||||
// we are about to clear out
|
||||
$itemsToDelete = CcPlaylistcontentsQuery::create()
|
||||
->filterByDbPlaylistId($this->id)
|
||||
->filterByDbFileId(null, Criteria::NOT_EQUAL)
|
||||
->find();
|
||||
|
||||
CcPlaylistcontentsQuery::create()->findByDbPlaylistId($this->id)->delete();
|
||||
|
||||
// update is_playlist flag in cc_files
|
||||
Application_Model_StoredFile::setIsPlaylist(
|
||||
$itemsToDelete,
|
||||
'playlist',
|
||||
false
|
||||
);
|
||||
|
||||
$this->pl->setDbMtime(new DateTime("now", new DateTimeZone("UTC")));
|
||||
$this->pl->save($this->con);
|
||||
$this->con->commit();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue