CC-3174 : showbuilder

throwing an exception if playlist doesn't exist.
This commit is contained in:
Naomi Aro 2012-02-03 18:28:35 +01:00
parent 0afa904ffe
commit 1deebedf11
1 changed files with 7 additions and 3 deletions
airtime_mvc/application/models

View File

@ -54,6 +54,10 @@ class Application_Model_Playlist {
{ {
if (isset($id)) { if (isset($id)) {
$this->pl = CcPlaylistQuery::create()->findPK($id); $this->pl = CcPlaylistQuery::create()->findPK($id);
if (is_null($this->_pl)){
throw new Exception();
}
} }
else { else {
$this->pl = new CcPlaylist(); $this->pl = new CcPlaylist();
@ -206,7 +210,7 @@ class Application_Model_Playlist {
$contentsToUpdate = CcPlaylistcontentsQuery::create() $contentsToUpdate = CcPlaylistcontentsQuery::create()
->filterByDbPlaylistId($this->id) ->filterByDbPlaylistId($this->id)
->orderByDbPosition() ->orderByDbPosition()
->find(); ->find($this->con);
$pos = $afterItem->getDbPosition() + 1; $pos = $afterItem->getDbPosition() + 1;
} }
@ -279,12 +283,12 @@ class Application_Model_Playlist {
CcPlaylistcontentsQuery::create() CcPlaylistcontentsQuery::create()
->findPKs($p_items) ->findPKs($p_items)
->delete(); ->delete($this->con);
$contents = CcPlaylistcontentsQuery::create() $contents = CcPlaylistcontentsQuery::create()
->filterByDbPlaylistId($this->id) ->filterByDbPlaylistId($this->id)
->orderByDbPosition() ->orderByDbPosition()
->find(); ->find($this->con);
//reset the positions of the remaining items. //reset the positions of the remaining items.
for ($i = 0; $i < count($contents); $i++) { for ($i = 0; $i < count($contents); $i++) {