CC-3174 : showbuilder
refactoring playlist to work with group add/delete by resource id and using transactions.
This commit is contained in:
parent
bdc9707052
commit
46fdf56b70
10 changed files with 471 additions and 409 deletions
|
@ -119,7 +119,11 @@ class Application_Model_Playlist {
|
|||
return $this->pl->getDbDescription();
|
||||
}
|
||||
|
||||
public function getSize() {
|
||||
public function getLastModified($format = null) {
|
||||
return $this->pl->getDbMtime($format);
|
||||
}
|
||||
|
||||
public function getSize() {
|
||||
|
||||
return $this->pl->countCcPlaylistcontentss();
|
||||
}
|
||||
|
@ -274,6 +278,55 @@ class Application_Model_Playlist {
|
|||
|
||||
try {
|
||||
|
||||
$contentsToMove = CcPlaylistcontentsQuery::create()
|
||||
->filterByDbId($p_items, Criteria::IN)
|
||||
->orderByDbPosition()
|
||||
->find($this->con);
|
||||
|
||||
$otherContent = CcPlaylistcontentsQuery::create()
|
||||
->filterByDbId($p_items, Criteria::NOT_IN)
|
||||
->filterByDbPlaylistId($this->id)
|
||||
->orderByDbPosition()
|
||||
->find($this->con);
|
||||
|
||||
$pos = 0;
|
||||
//moving items to beginning of the playlist.
|
||||
if (is_null($p_afterItem)) {
|
||||
Logging::log("moving items to beginning of playlist");
|
||||
|
||||
foreach ($contentsToMove as $item) {
|
||||
Logging::log("item {$item->getDbId()} to pos {$pos}");
|
||||
$item->setDbPosition($pos);
|
||||
$item->save($this->con);
|
||||
$pos = $pos + 1;
|
||||
}
|
||||
foreach ($otherContent as $item) {
|
||||
Logging::log("item {$item->getDbId()} to pos {$pos}");
|
||||
$item->setDbPosition($pos);
|
||||
$item->save($this->con);
|
||||
$pos = $pos + 1;
|
||||
}
|
||||
}
|
||||
else {
|
||||
Logging::log("moving items after {$p_afterItem}");
|
||||
|
||||
foreach ($otherContent as $item) {
|
||||
Logging::log("item {$item->getDbId()} to pos {$pos}");
|
||||
$item->setDbPosition($pos);
|
||||
$item->save($this->con);
|
||||
$pos = $pos + 1;
|
||||
|
||||
if ($item->getDbId() == $p_afterItem) {
|
||||
foreach ($contentsToMove as $move) {
|
||||
Logging::log("item {$move->getDbId()} to pos {$pos}");
|
||||
$move->setDbPosition($pos);
|
||||
$move->save($this->con);
|
||||
$pos = $pos + 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$this->con->commit();
|
||||
}
|
||||
catch (Exception $e) {
|
||||
|
|
|
@ -15,5 +15,66 @@
|
|||
*/
|
||||
class CcPlaylist extends BaseCcPlaylist {
|
||||
|
||||
/**
|
||||
* Get the [optionally formatted] temporal [utime] column value.
|
||||
*
|
||||
*
|
||||
* @param string $format The date/time format string (either date()-style or strftime()-style).
|
||||
* If format is NULL, then the raw DateTime object will be returned.
|
||||
* @return mixed Formatted date/time value as string or DateTime object (if format is NULL), NULL if column is NULL
|
||||
* @throws PropelException - if unable to parse/validate the date/time value.
|
||||
*/
|
||||
public function getDbUtime($format = 'Y-m-d H:i:s')
|
||||
{
|
||||
if ($this->utime === null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
try {
|
||||
$dt = new DateTime($this->utime, new DateTimeZone("UTC"));
|
||||
} catch (Exception $x) {
|
||||
throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->utime, true), $x);
|
||||
}
|
||||
|
||||
if ($format === null) {
|
||||
// Because propel.useDateTimeClass is TRUE, we return a DateTime object.
|
||||
return $dt;
|
||||
} elseif (strpos($format, '%') !== false) {
|
||||
return strftime($format, $dt->format('U'));
|
||||
} else {
|
||||
return $dt->format($format);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the [optionally formatted] temporal [mtime] column value.
|
||||
*
|
||||
*
|
||||
* @param string $format The date/time format string (either date()-style or strftime()-style).
|
||||
* If format is NULL, then the raw DateTime object will be returned.
|
||||
* @return mixed Formatted date/time value as string or DateTime object (if format is NULL), NULL if column is NULL
|
||||
* @throws PropelException - if unable to parse/validate the date/time value.
|
||||
*/
|
||||
public function getDbMtime($format = 'Y-m-d H:i:s')
|
||||
{
|
||||
if ($this->mtime === null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
try {
|
||||
$dt = new DateTime($this->mtime, new DateTimeZone("UTC"));
|
||||
} catch (Exception $x) {
|
||||
throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->mtime, true), $x);
|
||||
}
|
||||
|
||||
if ($format === null) {
|
||||
// Because propel.useDateTimeClass is TRUE, we return a DateTime object.
|
||||
return $dt;
|
||||
} elseif (strpos($format, '%') !== false) {
|
||||
return strftime($format, $dt->format('U'));
|
||||
} else {
|
||||
return $dt->format($format);
|
||||
}
|
||||
}
|
||||
|
||||
} // CcPlaylist
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue