From 4d3b90621eafe2c1abe5c7d354c4675e478945b4 Mon Sep 17 00:00:00 2001 From: naomiaro Date: Mon, 13 Sep 2010 14:05:45 -0400 Subject: [PATCH 1/3] CC-1434 && CC-1373 Won't delete a file that's scheduled or contained in a playlist. --- src/modules/storageServer/var/BasicStor.php | 67 +++++++++++++++++--- src/modules/storageServer/var/StoredFile.php | 31 ++++++++- 2 files changed, 87 insertions(+), 11 deletions(-) diff --git a/src/modules/storageServer/var/BasicStor.php b/src/modules/storageServer/var/BasicStor.php index 2c1daad33..f9a54edb5 100644 --- a/src/modules/storageServer/var/BasicStor.php +++ b/src/modules/storageServer/var/BasicStor.php @@ -159,23 +159,55 @@ class BasicStor { $res = BasicStor::RemoveObj($id, $forced); return $res; } + + $storedFile = StoredFile::Recall($id); + + if (is_null($storedFile) || PEAR::isError($storedFile)) { + return $storedFile; + } + if ($storedFile->isAccessed()) { + return PEAR::raiseError( + 'Cannot delete an object that is currently accessed.' + ); + } // move to trash: switch (BasicStor::GetObjType($id)) { + case "audioclip": + $playLists = $storedFile->getPlaylists(); + $item_gunid = $storedFile->getGunid(); + if( $playLists != NULL) { + + foreach($playLists as $key=>$val) { + $playList_id = BasicStor::IdFromGunidBigInt($val["gunid"]); + $playList_titles[] = BasicStor::bsGetMetadataValue($playList_id, "dc:title"); + } + return PEAR::raiseError( + 'Please remove this song from all playlists: ' . join(",", $playList_titles) + ); + } + break; + case "playlist": + if($storedFile->isScheduled()) { + return PEAR::raiseError( + 'Cannot delete an object that is scheduled to play.' + ); + } + break; + case "webstream": - $storedFile = StoredFile::Recall($id); - if (is_null($storedFile) || PEAR::isError($storedFile)) { - return $storedFile; - } - $res = $storedFile->setState('deleted'); - if (PEAR::isError($res)) { - return $res; - } + break; default: } - return TRUE; + + $res = $storedFile->setState('deleted'); + if (PEAR::isError($res)) { + return $res; + } + + return TRUE; } @@ -1491,7 +1523,7 @@ class BasicStor { /** - * Get local id from global id. + * Get local id from global id (in hex). * * @param string $p_gunid * Global id @@ -1504,6 +1536,21 @@ class BasicStor { global $CC_CONFIG; return $CC_DBC->getOne("SELECT id FROM ".$CC_CONFIG['filesTable']." WHERE gunid=x'$p_gunid'::bigint"); } + + /** + * Get local id from global id (big int). + * + * @param string $p_gunid + * Global id + * @return int + * Local id + */ + public static function IdFromGunidBigInt($p_gunid) + { + global $CC_DBC; + global $CC_CONFIG; + return $CC_DBC->getOne("SELECT id FROM ".$CC_CONFIG['filesTable']." WHERE gunid='$p_gunid'"); + } /** diff --git a/src/modules/storageServer/var/StoredFile.php b/src/modules/storageServer/var/StoredFile.php index dffb38987..828201391 100644 --- a/src/modules/storageServer/var/StoredFile.php +++ b/src/modules/storageServer/var/StoredFile.php @@ -331,7 +331,7 @@ class StoredFile { * @var int */ private $currentlyaccessing; - + /** * @var int */ @@ -1086,6 +1086,35 @@ class StoredFile { } return TRUE; } + + /** + * Returns gunIds of the playlists the stored file is in. + */ + public function getPlaylists() { + global $CC_CONFIG, $CC_DBC; + + $_SESSION['delete'] = "gunid: " . $this->gunid; + + $sql = "SELECT gunid " + ." FROM ".$CC_CONFIG['mdataTable'] + ." WHERE object='{$this->gunid}'"; + + $_SESSION['delete'] = $sql; + $playlists = $CC_DBC->getAll($sql); + + return $playlists; + } + + public function isScheduled() { + global $CC_CONFIG, $CC_DBC; + + $sql = "SELECT * " + ." FROM ".$CC_CONFIG['scheduleTable'] + ." WHERE ends > now() and playlist=x'{$this->gunid}'::bigint"; + $scheduled = $CC_DBC->getAll($sql); + + return $scheduled; + } /** From 23a775a66f6491009c6dd84196a63fd51f9053c8 Mon Sep 17 00:00:00 2001 From: naomiaro Date: Mon, 13 Sep 2010 15:06:51 -0400 Subject: [PATCH 2/3] CC-1669 Simple search form uses OR instead of AND. --- src/modules/htmlUI/var/ui_search.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/modules/htmlUI/var/ui_search.class.php b/src/modules/htmlUI/var/ui_search.class.php index 185f597be..dc8dba771 100644 --- a/src/modules/htmlUI/var/ui_search.class.php +++ b/src/modules/htmlUI/var/ui_search.class.php @@ -175,7 +175,7 @@ class uiSearch $this->criteria['counter'] = UI_SIMPLESEARCH_ROWS; // $criteria['form'] is used for retransfer to form - $this->criteria['form']['operator'] = 'OR'; + $this->criteria['form']['operator'] = 'or'; $this->criteria['form']['filetype'] = UI_SIMPLESEARCH_FILETYPE; $this->criteria['form']['limit'] = UI_SIMPLESEARCH_LIMIT; From 17fddfc4e69decf19419944a996f2239cd8e948a Mon Sep 17 00:00:00 2001 From: naomiaro Date: Mon, 13 Sep 2010 17:32:30 -0400 Subject: [PATCH 3/3] CC-1668 if no preference is set, archive server taken from config file. --- src/modules/htmlUI/var/formmask/generic.inc.php | 3 ++- src/modules/htmlUI/var/templates/scratchpad/main.tpl | 6 ++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/modules/htmlUI/var/formmask/generic.inc.php b/src/modules/htmlUI/var/formmask/generic.inc.php index 351f35582..e483ff9dd 100644 --- a/src/modules/htmlUI/var/formmask/generic.inc.php +++ b/src/modules/htmlUI/var/formmask/generic.inc.php @@ -74,7 +74,8 @@ $ui_fmask = array( 'isPref' => TRUE, 'type' => 'text', 'label' => 'Archive server location URL', - 'required' => false, + 'default' => "http://" . $CC_CONFIG['archiveUrlHost'] . ":" . $CC_CONFIG['archiveUrlPort'] . $CC_CONFIG['archiveUrlPath']."/".$CC_CONFIG['archiveXMLRPC'], + 'required' => TRUE, ), array( 'rule' => 'regex', diff --git a/src/modules/htmlUI/var/templates/scratchpad/main.tpl b/src/modules/htmlUI/var/templates/scratchpad/main.tpl index 164e38f85..f948765c7 100644 --- a/src/modules/htmlUI/var/templates/scratchpad/main.tpl +++ b/src/modules/htmlUI/var/templates/scratchpad/main.tpl @@ -86,14 +86,16 @@ duration = duration.split("."); duration = duration[0].split(":"); - if(parseInt(duration[0] !== 0)) { + if(duration[0] == ''){ + duration = "00:00"; + } + else if(parseInt(duration[0]) !== 0) { duration = duration[0] +":"+duration[1]+":"+duration[2]; } else{ duration = duration[1]+":"+duration[2]; } - tool_tip_content.append("Duration: "+duration+""); if(type === "playlist") {