Merge commit 'bfb90eefd10226ca32cc4e3c39cbb34ab88178d8' into 1.8.1

This commit is contained in:
Paul Baranowski 2011-04-25 17:58:34 -04:00
commit 78ed3e2822
15 changed files with 260 additions and 171 deletions

View file

@ -113,6 +113,12 @@ class Playlist {
return TRUE;
}
public static function deleteAll()
{
global $CC_CONFIG, $CC_DBC;
$sql = 'DELETE FROM '.$CC_CONFIG["playListTable"];
$CC_DBC->query($sql);
}
/**
* Delete the file from all playlists.

View file

@ -60,10 +60,10 @@ class ScheduleGroup {
if (empty($length)) {
return new PEAR_Error("Length is empty.");
}
// Insert into the table
$this->groupId = $CC_DBC->GetOne("SELECT nextval('schedule_group_id_seq')");
$sql = "INSERT INTO ".$CC_CONFIG["scheduleTable"]
." (instance_id, starts, ends, clip_length, group_id, file_id, cue_out)"
." VALUES ($p_showInstance, TIMESTAMP '$p_datetime', "
@ -76,7 +76,7 @@ class ScheduleGroup {
return $result;
}
}
}
elseif (!is_null($p_playlistId)){
// Schedule a whole playlist
@ -606,7 +606,7 @@ class Schedule {
} else {
$range_end = Schedule::PypoTimeToAirtimeTime($p_toDateTime);
}
// Scheduler wants everything in a playlist
$data = Schedule::GetItems($range_start, $range_end, true);
$playlists = array();
@ -681,5 +681,11 @@ class Schedule {
return $result;
}
public static function deleteAll()
{
global $CC_CONFIG, $CC_DBC;
$CC_DBC->query("TRUNCATE TABLE ".$CC_CONFIG["scheduleTable"]);
}
}

View file

@ -1,6 +1,6 @@
<?php
require_once("Playlist.php");
require_once(dirname(__FILE__)."/../../library/getid3/var/getid3.php");
require_once("getid3/var/getid3.php");
require_once("Schedule.php");
class Metadata {
@ -431,16 +431,20 @@ class StoredFile {
*
* @param string $p_gunid
* globally unique id of file
* @param boolean $p_autoload
* if TRUE, automatically load the row from the DB
*/
public function __construct($p_gunid=NULL)
public function __construct($p_gunid=NULL, $p_autoload=TRUE)
{
$this->gunid = $p_gunid;
if (empty($this->gunid)) {
$this->gunid = StoredFile::generateGunid();
}
else {
$this->loadMetadata();
$this->exists = is_file($this->filepath) && is_readable($this->filepath);
if ($p_autoload) {
$this->loadMetadata();
$this->exists = is_file($this->filepath) && is_readable($this->filepath);
}
}
}
@ -730,7 +734,6 @@ class StoredFile {
return $storedFile;
}
/**
* Create instance of StoreFile object and recall existing file
* by gunid.
@ -757,6 +760,14 @@ class StoredFile {
}
public static function GetAll()
{
global $CC_CONFIG, $CC_DBC;
$sql = "SELECT * FROM ".$CC_CONFIG["filesTable"];
$rows = $CC_DBC->GetAll($sql);
return $rows;
}
/**
* Generate the location to store the file.
* It creates the subdirectory if needed.
@ -1205,6 +1216,31 @@ class StoredFile {
}
public static function deleteById($p_id)
{
global $CC_CONFIG, $CC_DBC;
if (!is_numeric($p_id)) {
return FALSE;
}
$sql = "DELETE FROM ".$CC_CONFIG["filesTable"]." WHERE id=$p_id";
$res = $CC_DBC->query($sql);
if (PEAR::isError($res)) {
return $res;
}
return TRUE;
}
public static function deleteAll()
{
global $CC_CONFIG, $CC_DBC;
$files = StoredFile::getAll();
foreach ($files as $file) {
$media = StoredFile::Recall($file["id"]);
$media->delete();
}
}
/**
* Returns an array of playlist objects that this file is a part of.
* @return array
@ -1555,7 +1591,7 @@ class StoredFile {
}
public static function searchPlaylistsForSchedule($datatables)
public static function searchPlaylistsForSchedule($datatables)
{
$fromTable = "cc_playlist AS pl LEFT JOIN cc_playlisttimes AS plt USING(id) LEFT JOIN cc_subjs AS sub ON pl.editedby = sub.id";
//$datatables["optWhere"][] = "INTERVAL '{$time_remaining}' > INTERVAL '00:00:00'";