Merge branch 'master' of dev.sourcefabric.org:airtime
This commit is contained in:
commit
299dfdc18a
6 changed files with 129 additions and 12 deletions
|
@ -11,6 +11,9 @@ class Application_Model_Preference
|
|||
private static function setValue($key, $value, $isUserValue = false, $userId = null)
|
||||
{
|
||||
try {
|
||||
$con = Propel::getConnection(CcPrefPeer::DATABASE_NAME);
|
||||
$con->beginTransaction();
|
||||
|
||||
//called from a daemon process
|
||||
if (!class_exists("Zend_Auth", false) || !Zend_Auth::getInstance()->hasIdentity()) {
|
||||
$id = NULL;
|
||||
|
@ -35,10 +38,18 @@ class Application_Model_Preference
|
|||
$paramMap[':id'] = $userId;
|
||||
}
|
||||
|
||||
$result = Application_Common_Database::prepareAndExecute($sql, $paramMap, 'column');
|
||||
$result = Application_Common_Database::prepareAndExecute($sql,
|
||||
$paramMap,
|
||||
'column',
|
||||
PDO::FETCH_ASSOC,
|
||||
$con);
|
||||
|
||||
$paramMap = array();
|
||||
if ($result == 1) {
|
||||
if ($result > 1) {
|
||||
//this case should not happen.
|
||||
throw new Exception("Invalid number of results returned. Should be ".
|
||||
"0 or 1, but is '$result' instead");
|
||||
} elseif ($result == 1) {
|
||||
// result found
|
||||
if (is_null($id) || !$isUserValue) {
|
||||
// system pref
|
||||
|
@ -76,11 +87,17 @@ class Application_Model_Preference
|
|||
$paramMap[':key'] = $key;
|
||||
$paramMap[':value'] = $value;
|
||||
|
||||
Application_Common_Database::prepareAndExecute($sql, $paramMap, 'execute');
|
||||
Application_Common_Database::prepareAndExecute($sql,
|
||||
$paramMap,
|
||||
'execute',
|
||||
PDO::FETCH_ASSOC,
|
||||
$con);
|
||||
|
||||
$con->commit();
|
||||
} catch (Exception $e) {
|
||||
$con->rollback();
|
||||
header('HTTP/1.0 503 Service Unavailable');
|
||||
Logging::info("Could not connect to database: ".$e->getMessage());
|
||||
Logging::info("Database error: ".$e->getMessage());
|
||||
exit;
|
||||
}
|
||||
|
||||
|
|
|
@ -557,6 +557,7 @@ class Application_Model_Scheduler
|
|||
*/
|
||||
$instances = $this->getInstances($schedule["instance"]);
|
||||
foreach($instances as $instance) {
|
||||
$linked = $instance->getCcShow()->isLinked();
|
||||
if ($id !== 0) {
|
||||
$schedItem = CcScheduleQuery::create()->findPK($id, $this->con);
|
||||
/* We use the selected cursor's position to find the same
|
||||
|
@ -609,12 +610,31 @@ class Application_Model_Scheduler
|
|||
$filesToInsert = array_merge($filesToInsert, $this->retrieveMediaFiles($media["id"], $media["type"]));
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($filesToInsert as $file) {
|
||||
//item existed previously and is being moved.
|
||||
//need to keep same id for resources if we want REST.
|
||||
if (isset($file['sched_id'])) {
|
||||
$sched = CcScheduleQuery::create()->findPk($file["sched_id"]);
|
||||
|
||||
/* We need to keep a record of the original positon a track
|
||||
* is being moved from so we can use it to retrieve the correct
|
||||
* items in linked instances
|
||||
*/
|
||||
if (!isset($originalPosition)) {
|
||||
$originalPosition = $sched->getDbPosition();
|
||||
}
|
||||
|
||||
/* If we are moving an item in a linked show we need to get
|
||||
* the relative item to move in each instance. We know what the
|
||||
* relative item is by its position
|
||||
*/
|
||||
if ($linked && $moveAction) {
|
||||
$sched = CcScheduleQuery::create()
|
||||
->filterByDbInstanceId($instance->getDbId())
|
||||
->filterByDbPosition($originalPosition)
|
||||
->findOne();
|
||||
}
|
||||
$excludeIds[] = intval($sched->getDbId());
|
||||
|
||||
$file["cliplength"] = $sched->getDbClipLength();
|
||||
|
@ -694,7 +714,6 @@ class Application_Model_Scheduler
|
|||
//recalculate the start/end times after the inserted items.
|
||||
foreach ($followingSchedItems as $item) {
|
||||
$endTimeDT = $this->findEndTime($nextStartDT, $item->getDbClipLength());
|
||||
|
||||
$item->setDbStarts($nextStartDT);
|
||||
$item->setDbEnds($endTimeDT);
|
||||
$item->setDbPosition($pos);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue