Merged the model classes from /backend to their new home in /application/models.
Copied over the /backend/tests directory and modified the paths to their new locations. Moved the liquidsoap directory to be under the pypo directory.
This commit is contained in:
parent
184ee30775
commit
dd8987cdbc
49 changed files with 3670 additions and 2639 deletions
|
@ -80,8 +80,7 @@ class Prefs {
|
|||
return $subjid;
|
||||
}
|
||||
if (is_null($subjid)) {
|
||||
return PEAR::raiseError("Prefs::savePref: invalid session id",
|
||||
GBERR_SESS);
|
||||
return PEAR::raiseError("Prefs::savePref: invalid session id", GBERR_SESS);
|
||||
}
|
||||
$r = $this->update($subjid, $key, $value);
|
||||
if (PEAR::isError($r)) {
|
||||
|
@ -113,16 +112,14 @@ class Prefs {
|
|||
return $subjid;
|
||||
}
|
||||
if (is_null($subjid)) {
|
||||
return PEAR::raiseError("Prefs::delPref: invalid session id",
|
||||
GBERR_SESS);
|
||||
return PEAR::raiseError("Prefs::delPref: invalid session id", GBERR_SESS);
|
||||
}
|
||||
$r = $this->delete($subjid, $key);
|
||||
if (PEAR::isError($r)) {
|
||||
return $r;
|
||||
}
|
||||
if ($r === FALSE) {
|
||||
return PEAR::raiseError("Prefs::delPref: invalid preference key",
|
||||
GBERR_PREF);
|
||||
return PEAR::raiseError("Prefs::delPref: invalid preference key", GBERR_PREF);
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
|
|
@ -10,6 +10,21 @@ class ScheduleGroup {
|
|||
$this->groupId = $p_groupId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return true if the schedule group exists in the DB.
|
||||
* @return boolean
|
||||
*/
|
||||
public function exists() {
|
||||
global $CC_CONFIG, $CC_DBC;
|
||||
$sql = "SELECT COUNT(*) FROM ".$CC_CONFIG['scheduleTable']
|
||||
." WHERE group_id=".$this->groupId;
|
||||
$result = $CC_DBC->GetOne($sql);
|
||||
if (PEAR::isError($result)) {
|
||||
return $result;
|
||||
}
|
||||
return $result != "0";
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert a date to an ID by stripping out all characters
|
||||
* and padding with zeros.
|
||||
|
@ -93,7 +108,7 @@ class ScheduleGroup {
|
|||
." {$this->groupId}, $p_audioFileId)";
|
||||
$result = $CC_DBC->query($sql);
|
||||
if (PEAR::isError($result)) {
|
||||
var_dump($sql);
|
||||
//var_dump($sql);
|
||||
return $result;
|
||||
}
|
||||
return $this->groupId;
|
||||
|
@ -109,6 +124,7 @@ class ScheduleGroup {
|
|||
|
||||
// Check if there are any conflicts with existing entries
|
||||
$length = trim($playlist->getLength());
|
||||
//var_dump($length);
|
||||
if (empty($length)) {
|
||||
return new PEAR_Error("Length is empty.");
|
||||
}
|
||||
|
@ -122,8 +138,10 @@ class ScheduleGroup {
|
|||
$itemStartTime = $p_datetime;
|
||||
|
||||
$plItems = $playlist->getContents();
|
||||
//var_dump($plItems);
|
||||
foreach ($plItems as $row) {
|
||||
$trackLength = $row["cliplength"];
|
||||
//var_dump($trackLength);
|
||||
$sql = "INSERT INTO ".$CC_CONFIG["scheduleTable"]
|
||||
." (id, playlist_id, starts, ends, group_id, file_id,"
|
||||
." clip_length, cue_in, cue_out, fade_in, fade_out)"
|
||||
|
@ -133,7 +151,7 @@ class ScheduleGroup {
|
|||
." '{$row['cueout']}', '{$row['fadein']}','{$row['fadeout']}')";
|
||||
$result = $CC_DBC->query($sql);
|
||||
if (PEAR::isError($result)) {
|
||||
var_dump($sql);
|
||||
//var_dump($sql);
|
||||
return $result;
|
||||
}
|
||||
$itemStartTime = $CC_DBC->getOne("SELECT TIMESTAMP '$itemStartTime' + INTERVAL '$trackLength'");
|
||||
|
@ -170,7 +188,7 @@ class ScheduleGroup {
|
|||
}
|
||||
$sql = "DELETE FROM ".$CC_CONFIG["scheduleTable"]
|
||||
." WHERE group_id = ".$this->groupId;
|
||||
|
||||
//echo $sql;
|
||||
return $CC_DBC->query($sql);
|
||||
}
|
||||
|
||||
|
@ -201,6 +219,22 @@ class ScheduleGroup {
|
|||
// $sql = "UPDATE ".$CC_CONFIG["scheduleTable"]. " SET id=, starts=,ends="
|
||||
}
|
||||
|
||||
public function notifyGroupStartPlay() {
|
||||
global $CC_CONFIG, $CC_DBC;
|
||||
$sql = "UPDATE ".$CC_CONFIG['scheduleTable']
|
||||
." SET schedule_group_played=TRUE"
|
||||
." WHERE group_id=".$this->groupId;
|
||||
return $CC_DBC->query($sql);
|
||||
}
|
||||
|
||||
public function notifyMediaItemStartPlay($p_fileId) {
|
||||
global $CC_CONFIG, $CC_DBC;
|
||||
$sql = "UPDATE ".$CC_CONFIG['scheduleTable']
|
||||
." SET media_item_played=TRUE"
|
||||
." WHERE group_id=".$this->groupId
|
||||
." AND file_id=".pg_escape_string($p_fileId);
|
||||
return $CC_DBC->query($sql);
|
||||
}
|
||||
}
|
||||
|
||||
class Schedule {
|
||||
|
@ -210,11 +244,13 @@ class Schedule {
|
|||
}
|
||||
|
||||
/**
|
||||
* Return true if there is nothing in the schedule for the given times.
|
||||
* Return true if there is nothing in the schedule for the given start time
|
||||
* up to the length of time after that.
|
||||
*
|
||||
* @param string $p_datetime
|
||||
* In the format YYYY-MM-DD HH:MM:SS.mmmmmm
|
||||
* @param string $p_length
|
||||
*
|
||||
* In the format HH:MM:SS.mmmmmm
|
||||
* @return boolean|PEAR_Error
|
||||
*/
|
||||
public static function isScheduleEmptyInRange($p_datetime, $p_length) {
|
||||
|
@ -226,7 +262,9 @@ class Schedule {
|
|||
." WHERE (starts >= '$p_datetime') "
|
||||
." AND (ends <= (TIMESTAMP '$p_datetime' + INTERVAL '$p_length'))";
|
||||
//$_SESSION["debug"] = $sql;
|
||||
//var_dump($sql);
|
||||
$count = $CC_DBC->GetOne($sql);
|
||||
//var_dump($count);
|
||||
return ($count == '0');
|
||||
}
|
||||
|
||||
|
@ -263,7 +301,8 @@ class Schedule {
|
|||
* "start"/"starts" (aliases to the same thing) as YYYY-MM-DD HH:MM:SS.nnnnnn
|
||||
* "end"/"ends" (aliases to the same thing) as YYYY-MM-DD HH:MM:SS.nnnnnn
|
||||
* "group_id"/"id" (aliases to the same thing)
|
||||
* "clip_length" (for playlists only, this is the length of the entire playlist)
|
||||
* "clip_length" (for audio clips this is the length of the audio clip,
|
||||
* for playlists this is the length of the entire playlist)
|
||||
* "name" (playlist only)
|
||||
* "creator" (playlist only)
|
||||
* "file_id" (audioclip only)
|
||||
|
@ -334,18 +373,85 @@ class Schedule {
|
|||
|
||||
}
|
||||
|
||||
private static function CcTimeToPypoTime($p_time) {
|
||||
/**
|
||||
* Convert a time string in the format "YYYY-MM-DD HH:mm:SS"
|
||||
* to "YYYY-MM-DD-HH-mm-SS".
|
||||
*
|
||||
* @param string $p_time
|
||||
* @return string
|
||||
*/
|
||||
private static function CcTimeToPypoTime($p_time)
|
||||
{
|
||||
$p_time = substr($p_time, 0, 19);
|
||||
$p_time = str_replace(" ", "-", $p_time);
|
||||
$p_time = str_replace(":", "-", $p_time);
|
||||
return $p_time;
|
||||
}
|
||||
|
||||
private static function PypoTimeToCcTime($p_time) {
|
||||
/**
|
||||
* Convert a time string in the format "YYYY-MM-DD-HH-mm-SS" to
|
||||
* "YYYY-MM-DD HH:mm:SS".
|
||||
*
|
||||
* @param string $p_time
|
||||
* @return string
|
||||
*/
|
||||
private static function PypoTimeToCcTime($p_time)
|
||||
{
|
||||
$t = explode("-", $p_time);
|
||||
return $t[0]."-".$t[1]."-".$t[2]." ".$t[3].":".$t[4].":00";
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts a time value as a string (with format HH:MM:SS.mmmmmm) to
|
||||
* millisecs.
|
||||
*
|
||||
* @param string $p_time
|
||||
* @return int
|
||||
*/
|
||||
private static function WallTimeToMillisecs($p_time)
|
||||
{
|
||||
$t = explode(":", $p_time);
|
||||
$millisecs = 0;
|
||||
if (strpos($t[2], ".")) {
|
||||
$secParts = explode(".", $t[2]);
|
||||
$millisecs = $secParts[1];
|
||||
$millisecs = substr($millisecs, 0, 3);
|
||||
$millisecs = intval($millisecs);
|
||||
$seconds = intval($secParts[0]);
|
||||
} else {
|
||||
$seconds = intval($t[2]);
|
||||
}
|
||||
$ret = $millisecs + ($seconds * 1000) + ($t[1] * 60 * 1000) + ($t[0] * 60 * 60 * 1000);
|
||||
return $ret;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Compute the difference between two times in the format "HH:MM:SS.mmmmmm".
|
||||
* Note: currently only supports calculating millisec differences.
|
||||
*
|
||||
* @param string $p_time1
|
||||
* @param string $p_time2
|
||||
* @return double
|
||||
*/
|
||||
private static function TimeDiff($p_time1, $p_time2)
|
||||
{
|
||||
$parts1 = explode(".", $p_time1);
|
||||
$parts2 = explode(".", $p_time2);
|
||||
$diff = 0;
|
||||
if ( (count($parts1) > 1) && (count($parts2) > 1) ) {
|
||||
$millisec1 = substr($parts1[1], 0, 3);
|
||||
$millisec1 = str_pad($millisec1, 3, "0");
|
||||
$millisec1 = intval($millisec1);
|
||||
$millisec2 = substr($parts2[1], 0, 3);
|
||||
$millisec2 = str_pad($millisec2, 3, "0");
|
||||
$millisec2 = intval($millisec2);
|
||||
$diff = abs(millisec1 - millisec2)/1000;
|
||||
}
|
||||
return $diff;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Export the schedule in json formatted for pypo (the liquidsoap scheduler)
|
||||
*
|
||||
|
@ -386,6 +492,10 @@ class Schedule {
|
|||
$playlists[$pkey]['duration'] = $dx['clip_length'];
|
||||
$playlists[$pkey]['played'] = '0';
|
||||
$playlists[$pkey]['schedule_id'] = $dx['group_id'];
|
||||
$playlists[$pkey]['user_id'] = 0;
|
||||
$playlists[$pkey]['id'] = $dx["playlist_id"];
|
||||
$playlists[$pkey]['start'] = Schedule::CcTimeToPypoTime($dx["start"]);
|
||||
$playlists[$pkey]['end'] = Schedule::CcTimeToPypoTime($dx["end"]);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -399,27 +509,52 @@ class Schedule {
|
|||
{
|
||||
$storedFile = StoredFile::Recall($item["file_id"]);
|
||||
$uri = $storedFile->getFileUrl();
|
||||
|
||||
// For pypo, a cueout of zero means no cueout
|
||||
$cueOut = "0";
|
||||
if (Schedule::TimeDiff($item["cue_out"], $item["clip_length"]) > 0.001) {
|
||||
$cueOut = Schedule::WallTimeToMillisecs($item["cue_out"]);
|
||||
}
|
||||
$medias[] = array(
|
||||
'id' => $storedFile->getGunid(), //$item["file_id"],
|
||||
'uri' => $uri,
|
||||
'fade_in' => $item["fade_in"],
|
||||
'fade_out' => $item["fade_out"],
|
||||
'fade_in' => Schedule::WallTimeToMillisecs($item["fade_in"]),
|
||||
'fade_out' => Schedule::WallTimeToMillisecs($item["fade_out"]),
|
||||
'fade_cross' => 0,
|
||||
'cue_in' => $item["cue_in"],
|
||||
'cue_out' => $item["cue_out"],
|
||||
'cue_in' => Schedule::WallTimeToMillisecs($item["cue_in"]),
|
||||
'cue_out' => $cueOut,
|
||||
'export_source' => 'scheduler'
|
||||
);
|
||||
}
|
||||
$playlist['medias'] = $medias;
|
||||
}
|
||||
|
||||
$result = array();
|
||||
$result['status'] = array('range' => $range_dt, 'version' => 0.2);
|
||||
$result['status'] = array('range' => $range_dt, 'version' => "0.2");
|
||||
$result['playlists'] = $playlists;
|
||||
$result['check'] = 1;
|
||||
|
||||
print json_encode($result);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Remove all items from the schedule in the given range.
|
||||
*
|
||||
* @param string $p_start
|
||||
* In the format YYYY-MM-DD HH:MM:SS.nnnnnn
|
||||
* @param string $p_end
|
||||
* In the format YYYY-MM-DD HH:MM:SS.nnnnnn
|
||||
*/
|
||||
public static function RemoveItemsInRange($p_start, $p_end)
|
||||
{
|
||||
$items = Schedule::GetItems($p_start, $p_end);
|
||||
foreach ($items as $item) {
|
||||
$scheduleGroup = new ScheduleGroup($item["group_id"]);
|
||||
$scheduleGroup->remove();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
|
@ -1,11 +1,10 @@
|
|||
<?php
|
||||
require_once("Playlist.php");
|
||||
require_once("getid3/var/getid3.php");
|
||||
require_once(dirname(__FILE__)."/../../library/getid3/var/getid3.php");
|
||||
require_once("BasicStor.php");
|
||||
require_once("Schedule.php");
|
||||
|
||||
global $g_metadata_xml_to_db_mapping;
|
||||
|
||||
$g_metadata_xml_to_db_mapping = array(
|
||||
"dc:format" => "format",
|
||||
"ls:bitrate" => "bit_rate",
|
||||
|
@ -837,6 +836,25 @@ class StoredFile {
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* Find and return the first exact match for the original file name
|
||||
* that was used on import.
|
||||
* @param string $p_name
|
||||
*/
|
||||
public static function findByOriginalName($p_name)
|
||||
{
|
||||
global $CC_CONFIG, $CC_DBC;
|
||||
$sql = "SELECT id FROM ".$CC_CONFIG["filesTable"]
|
||||
." WHERE name='".pg_escape_string($p_name)."'";
|
||||
$id = $CC_DBC->getOne($sql);
|
||||
if (is_numeric($id)) {
|
||||
return StoredFile::Recall($id);
|
||||
} else {
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Delete and insert media file
|
||||
*
|
||||
|
@ -955,7 +973,7 @@ class StoredFile {
|
|||
$values = array(
|
||||
"id" => $p_nid,
|
||||
"filename" => $p_src->name,
|
||||
"filepath" => $p_src->getRealFileName(),
|
||||
"filepath" => $p_src->getRealFilePath(),
|
||||
"filetype" => $p_src->getType()
|
||||
);
|
||||
$storedFile = StoredFile::Insert($values);
|
||||
|
@ -1030,7 +1048,7 @@ class StoredFile {
|
|||
*/
|
||||
public function accessRawMediaData($p_parent='0')
|
||||
{
|
||||
$realFname = $this->getRealFileName();
|
||||
$realFname = $this->getRealFilePath();
|
||||
$ext = $this->getFileExtension();
|
||||
$res = BasicStor::bsAccess($realFname, $ext, $this->gunid, 'access', $p_parent);
|
||||
if (PEAR::isError($res)) {
|
||||
|
@ -1662,32 +1680,12 @@ class StoredFile {
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get and optionally create subdirectory in real filesystem for storing
|
||||
* raw media data.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
// private function _getResDir()
|
||||
// {
|
||||
// global $CC_CONFIG, $CC_DBC;
|
||||
// $resDir = $CC_CONFIG['storageDir']."/".substr($this->gunid, 0, 3);
|
||||
// //$this->gb->debugLog("$resDir");
|
||||
// // see Transport::_getResDir too for resDir name create code
|
||||
// if (!is_dir($resDir)) {
|
||||
// mkdir($resDir, 02775);
|
||||
// chmod($resDir, 02775);
|
||||
// }
|
||||
// return $resDir;
|
||||
// }
|
||||
|
||||
|
||||
/**
|
||||
* Get real filename of raw media data
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getRealFileName()
|
||||
public function getRealFilePath()
|
||||
{
|
||||
return $this->filepath;
|
||||
}
|
||||
|
@ -1699,7 +1697,8 @@ class StoredFile {
|
|||
{
|
||||
global $CC_CONFIG;
|
||||
return "http://".$CC_CONFIG["storageUrlHost"]
|
||||
."api/get_media.php?file_id={$this->gunid}";
|
||||
.$CC_CONFIG["apiPath"]."get_media.php?file="
|
||||
.$this->gunid.".".$this->getFileExtension();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1727,6 +1726,7 @@ class StoredFile {
|
|||
return $CC_CONFIG['accessDir']."/$p_token.$p_ext";
|
||||
}
|
||||
|
||||
|
||||
public static function getFiles($query=NULL)
|
||||
{
|
||||
global $CC_CONFIG, $CC_DBC, $g_metadata_xml_to_db_mapping;
|
||||
|
@ -1783,5 +1783,5 @@ class StoredFile {
|
|||
return $CC_DBC->getAll($sql);
|
||||
}
|
||||
|
||||
} // class StoredFile
|
||||
}
|
||||
?>
|
|
@ -47,6 +47,7 @@ class CcShowTableMap extends TableMap {
|
|||
$this->addColumn('REPEATS', 'DbRepeats', 'TINYINT', true, null, null);
|
||||
$this->addColumn('DAY', 'DbDay', 'TINYINT', true, null, null);
|
||||
$this->addColumn('DESCRIPTION', 'DbDescription', 'VARCHAR', false, 512, null);
|
||||
$this->addColumn('SHOW_ID', 'DbShowId', 'INTEGER', true, null, null);
|
||||
// validators
|
||||
} // initialize()
|
||||
|
||||
|
|
|
@ -35,7 +35,8 @@ class CcSubjsTableMap extends TableMap {
|
|||
$this->setPhpName('CcSubjs');
|
||||
$this->setClassname('CcSubjs');
|
||||
$this->setPackage('campcaster');
|
||||
$this->setUseIdGenerator(false);
|
||||
$this->setUseIdGenerator(true);
|
||||
$this->setPrimaryKeyMethodInfo('cc_subjs_id_seq');
|
||||
// columns
|
||||
$this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null);
|
||||
$this->addColumn('LOGIN', 'Login', 'VARCHAR', true, 255, '');
|
||||
|
|
|
@ -79,6 +79,12 @@ abstract class BaseCcShow extends BaseObject implements Persistent
|
|||
*/
|
||||
protected $description;
|
||||
|
||||
/**
|
||||
* The value for the show_id field.
|
||||
* @var int
|
||||
*/
|
||||
protected $show_id;
|
||||
|
||||
/**
|
||||
* Flag to prevent endless save loop, if this object is referenced
|
||||
* by another object which falls in this transaction.
|
||||
|
@ -296,6 +302,16 @@ abstract class BaseCcShow extends BaseObject implements Persistent
|
|||
return $this->description;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the [show_id] column value.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getDbShowId()
|
||||
{
|
||||
return $this->show_id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the value of [id] column.
|
||||
*
|
||||
|
@ -592,6 +608,26 @@ abstract class BaseCcShow extends BaseObject implements Persistent
|
|||
return $this;
|
||||
} // setDbDescription()
|
||||
|
||||
/**
|
||||
* Set the value of [show_id] column.
|
||||
*
|
||||
* @param int $v new value
|
||||
* @return CcShow The current object (for fluent API support)
|
||||
*/
|
||||
public function setDbShowId($v)
|
||||
{
|
||||
if ($v !== null) {
|
||||
$v = (int) $v;
|
||||
}
|
||||
|
||||
if ($this->show_id !== $v) {
|
||||
$this->show_id = $v;
|
||||
$this->modifiedColumns[] = CcShowPeer::SHOW_ID;
|
||||
}
|
||||
|
||||
return $this;
|
||||
} // setDbShowId()
|
||||
|
||||
/**
|
||||
* Indicates whether the columns in this object are only set to default values.
|
||||
*
|
||||
|
@ -637,6 +673,7 @@ abstract class BaseCcShow extends BaseObject implements Persistent
|
|||
$this->repeats = ($row[$startcol + 6] !== null) ? (int) $row[$startcol + 6] : null;
|
||||
$this->day = ($row[$startcol + 7] !== null) ? (int) $row[$startcol + 7] : null;
|
||||
$this->description = ($row[$startcol + 8] !== null) ? (string) $row[$startcol + 8] : null;
|
||||
$this->show_id = ($row[$startcol + 9] !== null) ? (int) $row[$startcol + 9] : null;
|
||||
$this->resetModified();
|
||||
|
||||
$this->setNew(false);
|
||||
|
@ -645,7 +682,7 @@ abstract class BaseCcShow extends BaseObject implements Persistent
|
|||
$this->ensureConsistency();
|
||||
}
|
||||
|
||||
return $startcol + 9; // 9 = CcShowPeer::NUM_COLUMNS - CcShowPeer::NUM_LAZY_LOAD_COLUMNS).
|
||||
return $startcol + 10; // 10 = CcShowPeer::NUM_COLUMNS - CcShowPeer::NUM_LAZY_LOAD_COLUMNS).
|
||||
|
||||
} catch (Exception $e) {
|
||||
throw new PropelException("Error populating CcShow object", $e);
|
||||
|
@ -971,6 +1008,9 @@ abstract class BaseCcShow extends BaseObject implements Persistent
|
|||
case 8:
|
||||
return $this->getDbDescription();
|
||||
break;
|
||||
case 9:
|
||||
return $this->getDbShowId();
|
||||
break;
|
||||
default:
|
||||
return null;
|
||||
break;
|
||||
|
@ -1003,6 +1043,7 @@ abstract class BaseCcShow extends BaseObject implements Persistent
|
|||
$keys[6] => $this->getDbRepeats(),
|
||||
$keys[7] => $this->getDbDay(),
|
||||
$keys[8] => $this->getDbDescription(),
|
||||
$keys[9] => $this->getDbShowId(),
|
||||
);
|
||||
return $result;
|
||||
}
|
||||
|
@ -1061,6 +1102,9 @@ abstract class BaseCcShow extends BaseObject implements Persistent
|
|||
case 8:
|
||||
$this->setDbDescription($value);
|
||||
break;
|
||||
case 9:
|
||||
$this->setDbShowId($value);
|
||||
break;
|
||||
} // switch()
|
||||
}
|
||||
|
||||
|
@ -1094,6 +1138,7 @@ abstract class BaseCcShow extends BaseObject implements Persistent
|
|||
if (array_key_exists($keys[6], $arr)) $this->setDbRepeats($arr[$keys[6]]);
|
||||
if (array_key_exists($keys[7], $arr)) $this->setDbDay($arr[$keys[7]]);
|
||||
if (array_key_exists($keys[8], $arr)) $this->setDbDescription($arr[$keys[8]]);
|
||||
if (array_key_exists($keys[9], $arr)) $this->setDbShowId($arr[$keys[9]]);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1114,6 +1159,7 @@ abstract class BaseCcShow extends BaseObject implements Persistent
|
|||
if ($this->isColumnModified(CcShowPeer::REPEATS)) $criteria->add(CcShowPeer::REPEATS, $this->repeats);
|
||||
if ($this->isColumnModified(CcShowPeer::DAY)) $criteria->add(CcShowPeer::DAY, $this->day);
|
||||
if ($this->isColumnModified(CcShowPeer::DESCRIPTION)) $criteria->add(CcShowPeer::DESCRIPTION, $this->description);
|
||||
if ($this->isColumnModified(CcShowPeer::SHOW_ID)) $criteria->add(CcShowPeer::SHOW_ID, $this->show_id);
|
||||
|
||||
return $criteria;
|
||||
}
|
||||
|
@ -1183,6 +1229,7 @@ abstract class BaseCcShow extends BaseObject implements Persistent
|
|||
$copyObj->setDbRepeats($this->repeats);
|
||||
$copyObj->setDbDay($this->day);
|
||||
$copyObj->setDbDescription($this->description);
|
||||
$copyObj->setDbShowId($this->show_id);
|
||||
|
||||
$copyObj->setNew(true);
|
||||
$copyObj->setDbId(NULL); // this is a auto-increment column, so set to default value
|
||||
|
@ -1240,6 +1287,7 @@ abstract class BaseCcShow extends BaseObject implements Persistent
|
|||
$this->repeats = null;
|
||||
$this->day = null;
|
||||
$this->description = null;
|
||||
$this->show_id = null;
|
||||
$this->alreadyInSave = false;
|
||||
$this->alreadyInValidation = false;
|
||||
$this->clearAllReferences();
|
||||
|
|
|
@ -26,7 +26,7 @@ abstract class BaseCcShowPeer {
|
|||
const TM_CLASS = 'CcShowTableMap';
|
||||
|
||||
/** The total number of columns. */
|
||||
const NUM_COLUMNS = 9;
|
||||
const NUM_COLUMNS = 10;
|
||||
|
||||
/** The number of lazy-loaded columns. */
|
||||
const NUM_LAZY_LOAD_COLUMNS = 0;
|
||||
|
@ -58,6 +58,9 @@ abstract class BaseCcShowPeer {
|
|||
/** the column name for the DESCRIPTION field */
|
||||
const DESCRIPTION = 'cc_show.DESCRIPTION';
|
||||
|
||||
/** the column name for the SHOW_ID field */
|
||||
const SHOW_ID = 'cc_show.SHOW_ID';
|
||||
|
||||
/**
|
||||
* An identiy map to hold any loaded instances of CcShow objects.
|
||||
* This must be public so that other peer classes can access this when hydrating from JOIN
|
||||
|
@ -74,12 +77,12 @@ abstract class BaseCcShowPeer {
|
|||
* e.g. self::$fieldNames[self::TYPE_PHPNAME][0] = 'Id'
|
||||
*/
|
||||
private static $fieldNames = array (
|
||||
BasePeer::TYPE_PHPNAME => array ('DbId', 'DbName', 'DbFirstShow', 'DbLastShow', 'DbStartTime', 'DbEndTime', 'DbRepeats', 'DbDay', 'DbDescription', ),
|
||||
BasePeer::TYPE_STUDLYPHPNAME => array ('dbId', 'dbName', 'dbFirstShow', 'dbLastShow', 'dbStartTime', 'dbEndTime', 'dbRepeats', 'dbDay', 'dbDescription', ),
|
||||
BasePeer::TYPE_COLNAME => array (self::ID, self::NAME, self::FIRST_SHOW, self::LAST_SHOW, self::START_TIME, self::END_TIME, self::REPEATS, self::DAY, self::DESCRIPTION, ),
|
||||
BasePeer::TYPE_RAW_COLNAME => array ('ID', 'NAME', 'FIRST_SHOW', 'LAST_SHOW', 'START_TIME', 'END_TIME', 'REPEATS', 'DAY', 'DESCRIPTION', ),
|
||||
BasePeer::TYPE_FIELDNAME => array ('id', 'name', 'first_show', 'last_show', 'start_time', 'end_time', 'repeats', 'day', 'description', ),
|
||||
BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, )
|
||||
BasePeer::TYPE_PHPNAME => array ('DbId', 'DbName', 'DbFirstShow', 'DbLastShow', 'DbStartTime', 'DbEndTime', 'DbRepeats', 'DbDay', 'DbDescription', 'DbShowId', ),
|
||||
BasePeer::TYPE_STUDLYPHPNAME => array ('dbId', 'dbName', 'dbFirstShow', 'dbLastShow', 'dbStartTime', 'dbEndTime', 'dbRepeats', 'dbDay', 'dbDescription', 'dbShowId', ),
|
||||
BasePeer::TYPE_COLNAME => array (self::ID, self::NAME, self::FIRST_SHOW, self::LAST_SHOW, self::START_TIME, self::END_TIME, self::REPEATS, self::DAY, self::DESCRIPTION, self::SHOW_ID, ),
|
||||
BasePeer::TYPE_RAW_COLNAME => array ('ID', 'NAME', 'FIRST_SHOW', 'LAST_SHOW', 'START_TIME', 'END_TIME', 'REPEATS', 'DAY', 'DESCRIPTION', 'SHOW_ID', ),
|
||||
BasePeer::TYPE_FIELDNAME => array ('id', 'name', 'first_show', 'last_show', 'start_time', 'end_time', 'repeats', 'day', 'description', 'show_id', ),
|
||||
BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, )
|
||||
);
|
||||
|
||||
/**
|
||||
|
@ -89,12 +92,12 @@ abstract class BaseCcShowPeer {
|
|||
* e.g. self::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0
|
||||
*/
|
||||
private static $fieldKeys = array (
|
||||
BasePeer::TYPE_PHPNAME => array ('DbId' => 0, 'DbName' => 1, 'DbFirstShow' => 2, 'DbLastShow' => 3, 'DbStartTime' => 4, 'DbEndTime' => 5, 'DbRepeats' => 6, 'DbDay' => 7, 'DbDescription' => 8, ),
|
||||
BasePeer::TYPE_STUDLYPHPNAME => array ('dbId' => 0, 'dbName' => 1, 'dbFirstShow' => 2, 'dbLastShow' => 3, 'dbStartTime' => 4, 'dbEndTime' => 5, 'dbRepeats' => 6, 'dbDay' => 7, 'dbDescription' => 8, ),
|
||||
BasePeer::TYPE_COLNAME => array (self::ID => 0, self::NAME => 1, self::FIRST_SHOW => 2, self::LAST_SHOW => 3, self::START_TIME => 4, self::END_TIME => 5, self::REPEATS => 6, self::DAY => 7, self::DESCRIPTION => 8, ),
|
||||
BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'NAME' => 1, 'FIRST_SHOW' => 2, 'LAST_SHOW' => 3, 'START_TIME' => 4, 'END_TIME' => 5, 'REPEATS' => 6, 'DAY' => 7, 'DESCRIPTION' => 8, ),
|
||||
BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'name' => 1, 'first_show' => 2, 'last_show' => 3, 'start_time' => 4, 'end_time' => 5, 'repeats' => 6, 'day' => 7, 'description' => 8, ),
|
||||
BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, )
|
||||
BasePeer::TYPE_PHPNAME => array ('DbId' => 0, 'DbName' => 1, 'DbFirstShow' => 2, 'DbLastShow' => 3, 'DbStartTime' => 4, 'DbEndTime' => 5, 'DbRepeats' => 6, 'DbDay' => 7, 'DbDescription' => 8, 'DbShowId' => 9, ),
|
||||
BasePeer::TYPE_STUDLYPHPNAME => array ('dbId' => 0, 'dbName' => 1, 'dbFirstShow' => 2, 'dbLastShow' => 3, 'dbStartTime' => 4, 'dbEndTime' => 5, 'dbRepeats' => 6, 'dbDay' => 7, 'dbDescription' => 8, 'dbShowId' => 9, ),
|
||||
BasePeer::TYPE_COLNAME => array (self::ID => 0, self::NAME => 1, self::FIRST_SHOW => 2, self::LAST_SHOW => 3, self::START_TIME => 4, self::END_TIME => 5, self::REPEATS => 6, self::DAY => 7, self::DESCRIPTION => 8, self::SHOW_ID => 9, ),
|
||||
BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'NAME' => 1, 'FIRST_SHOW' => 2, 'LAST_SHOW' => 3, 'START_TIME' => 4, 'END_TIME' => 5, 'REPEATS' => 6, 'DAY' => 7, 'DESCRIPTION' => 8, 'SHOW_ID' => 9, ),
|
||||
BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'name' => 1, 'first_show' => 2, 'last_show' => 3, 'start_time' => 4, 'end_time' => 5, 'repeats' => 6, 'day' => 7, 'description' => 8, 'show_id' => 9, ),
|
||||
BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, )
|
||||
);
|
||||
|
||||
/**
|
||||
|
@ -175,6 +178,7 @@ abstract class BaseCcShowPeer {
|
|||
$criteria->addSelectColumn(CcShowPeer::REPEATS);
|
||||
$criteria->addSelectColumn(CcShowPeer::DAY);
|
||||
$criteria->addSelectColumn(CcShowPeer::DESCRIPTION);
|
||||
$criteria->addSelectColumn(CcShowPeer::SHOW_ID);
|
||||
} else {
|
||||
$criteria->addSelectColumn($alias . '.ID');
|
||||
$criteria->addSelectColumn($alias . '.NAME');
|
||||
|
@ -185,6 +189,7 @@ abstract class BaseCcShowPeer {
|
|||
$criteria->addSelectColumn($alias . '.REPEATS');
|
||||
$criteria->addSelectColumn($alias . '.DAY');
|
||||
$criteria->addSelectColumn($alias . '.DESCRIPTION');
|
||||
$criteria->addSelectColumn($alias . '.SHOW_ID');
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
* @method CcShowQuery orderByDbRepeats($order = Criteria::ASC) Order by the repeats column
|
||||
* @method CcShowQuery orderByDbDay($order = Criteria::ASC) Order by the day column
|
||||
* @method CcShowQuery orderByDbDescription($order = Criteria::ASC) Order by the description column
|
||||
* @method CcShowQuery orderByDbShowId($order = Criteria::ASC) Order by the show_id column
|
||||
*
|
||||
* @method CcShowQuery groupByDbId() Group by the id column
|
||||
* @method CcShowQuery groupByDbName() Group by the name column
|
||||
|
@ -25,6 +26,7 @@
|
|||
* @method CcShowQuery groupByDbRepeats() Group by the repeats column
|
||||
* @method CcShowQuery groupByDbDay() Group by the day column
|
||||
* @method CcShowQuery groupByDbDescription() Group by the description column
|
||||
* @method CcShowQuery groupByDbShowId() Group by the show_id column
|
||||
*
|
||||
* @method CcShowQuery leftJoin($relation) Adds a LEFT JOIN clause to the query
|
||||
* @method CcShowQuery rightJoin($relation) Adds a RIGHT JOIN clause to the query
|
||||
|
@ -42,6 +44,7 @@
|
|||
* @method CcShow findOneByDbRepeats(int $repeats) Return the first CcShow filtered by the repeats column
|
||||
* @method CcShow findOneByDbDay(int $day) Return the first CcShow filtered by the day column
|
||||
* @method CcShow findOneByDbDescription(string $description) Return the first CcShow filtered by the description column
|
||||
* @method CcShow findOneByDbShowId(int $show_id) Return the first CcShow filtered by the show_id column
|
||||
*
|
||||
* @method array findByDbId(int $id) Return CcShow objects filtered by the id column
|
||||
* @method array findByDbName(string $name) Return CcShow objects filtered by the name column
|
||||
|
@ -52,6 +55,7 @@
|
|||
* @method array findByDbRepeats(int $repeats) Return CcShow objects filtered by the repeats column
|
||||
* @method array findByDbDay(int $day) Return CcShow objects filtered by the day column
|
||||
* @method array findByDbDescription(string $description) Return CcShow objects filtered by the description column
|
||||
* @method array findByDbShowId(int $show_id) Return CcShow objects filtered by the show_id column
|
||||
*
|
||||
* @package propel.generator.campcaster.om
|
||||
*/
|
||||
|
@ -408,6 +412,37 @@ abstract class BaseCcShowQuery extends ModelCriteria
|
|||
return $this->addUsingAlias(CcShowPeer::DESCRIPTION, $dbDescription, $comparison);
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter the query on the show_id column
|
||||
*
|
||||
* @param int|array $dbShowId The value to use as filter.
|
||||
* Accepts an associative array('min' => $minValue, 'max' => $maxValue)
|
||||
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
|
||||
*
|
||||
* @return CcShowQuery The current query, for fluid interface
|
||||
*/
|
||||
public function filterByDbShowId($dbShowId = null, $comparison = null)
|
||||
{
|
||||
if (is_array($dbShowId)) {
|
||||
$useMinMax = false;
|
||||
if (isset($dbShowId['min'])) {
|
||||
$this->addUsingAlias(CcShowPeer::SHOW_ID, $dbShowId['min'], Criteria::GREATER_EQUAL);
|
||||
$useMinMax = true;
|
||||
}
|
||||
if (isset($dbShowId['max'])) {
|
||||
$this->addUsingAlias(CcShowPeer::SHOW_ID, $dbShowId['max'], Criteria::LESS_EQUAL);
|
||||
$useMinMax = true;
|
||||
}
|
||||
if ($useMinMax) {
|
||||
return $this;
|
||||
}
|
||||
if (null === $comparison) {
|
||||
$comparison = Criteria::IN;
|
||||
}
|
||||
}
|
||||
return $this->addUsingAlias(CcShowPeer::SHOW_ID, $dbShowId, $comparison);
|
||||
}
|
||||
|
||||
/**
|
||||
* Exclude object from result
|
||||
*
|
||||
|
|
|
@ -699,13 +699,21 @@ abstract class BaseCcSubjs extends BaseObject implements Persistent
|
|||
if (!$this->alreadyInSave) {
|
||||
$this->alreadyInSave = true;
|
||||
|
||||
if ($this->isNew() ) {
|
||||
$this->modifiedColumns[] = CcSubjsPeer::ID;
|
||||
}
|
||||
|
||||
// If this object has been modified, then save it to the database.
|
||||
if ($this->isModified()) {
|
||||
if ($this->isNew()) {
|
||||
$criteria = $this->buildCriteria();
|
||||
if ($criteria->keyContainsValue(CcSubjsPeer::ID) ) {
|
||||
throw new PropelException('Cannot insert a value for auto-increment primary key ('.CcSubjsPeer::ID.')');
|
||||
}
|
||||
|
||||
$pk = BasePeer::doInsert($criteria, $con);
|
||||
$affectedRows = 1;
|
||||
$this->setId($pk); //[IMV] update autoincrement primary key
|
||||
$this->setNew(false);
|
||||
} else {
|
||||
$affectedRows = CcSubjsPeer::doUpdate($this, $con);
|
||||
|
@ -1127,7 +1135,6 @@ abstract class BaseCcSubjs extends BaseObject implements Persistent
|
|||
*/
|
||||
public function copyInto($copyObj, $deepCopy = false)
|
||||
{
|
||||
$copyObj->setId($this->id);
|
||||
$copyObj->setLogin($this->login);
|
||||
$copyObj->setPass($this->pass);
|
||||
$copyObj->setType($this->type);
|
||||
|
@ -1180,6 +1187,7 @@ abstract class BaseCcSubjs extends BaseObject implements Persistent
|
|||
|
||||
|
||||
$copyObj->setNew(true);
|
||||
$copyObj->setId(NULL); // this is a auto-increment column, so set to default value
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -529,6 +529,10 @@ abstract class BaseCcSubjsPeer {
|
|||
$criteria = $values->buildCriteria(); // build Criteria from CcSubjs object
|
||||
}
|
||||
|
||||
if ($criteria->containsKey(CcSubjsPeer::ID) && $criteria->keyContainsValue(CcSubjsPeer::ID) ) {
|
||||
throw new PropelException('Cannot insert a value for auto-increment primary key ('.CcSubjsPeer::ID.')');
|
||||
}
|
||||
|
||||
|
||||
// Set the correct dbName
|
||||
$criteria->setDbName(self::DATABASE_NAME);
|
||||
|
|
47
application/models/configure
vendored
47
application/models/configure
vendored
|
@ -1,47 +0,0 @@
|
|||
#!/bin/sh
|
||||
#-------------------------------------------------------------------------------
|
||||
# Copyright (c) 2010 Sourcefabric O.P.S.
|
||||
#
|
||||
# This file is part of the Campcaster project.
|
||||
# http://campcaster.campware.org/
|
||||
#
|
||||
# Campcaster is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 2 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# Campcaster is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with Campcaster; if not, write to the Free Software
|
||||
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
#
|
||||
#-------------------------------------------------------------------------------
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# Run this script to configure the environment.
|
||||
#
|
||||
# This script in effect calls the real automake / autoconf configure script
|
||||
#-------------------------------------------------------------------------------
|
||||
|
||||
# assume we're in $basedir
|
||||
reldir=`dirname $0`
|
||||
basedir=`cd $reldir; pwd;`
|
||||
test -z "$basedir" && basedir=.
|
||||
|
||||
bindir=$basedir/bin
|
||||
tmpdir=$basedir/tmp
|
||||
|
||||
|
||||
autogen=$bindir/autogen.sh
|
||||
configure=$tmpdir/configure
|
||||
|
||||
if [ ! -x $configure ]; then
|
||||
(cd $basedir && $autogen $*)
|
||||
fi
|
||||
|
||||
(cd $tmpdir && $configure $*)
|
||||
|
BIN
application/models/tests/0000000000010001
Normal file
BIN
application/models/tests/0000000000010001
Normal file
Binary file not shown.
BIN
application/models/tests/0000000000010002
Normal file
BIN
application/models/tests/0000000000010002
Normal file
Binary file not shown.
24
application/models/tests/AllTests.php
Normal file
24
application/models/tests/AllTests.php
Normal file
|
@ -0,0 +1,24 @@
|
|||
<?php
|
||||
$path = dirname(__FILE__).'/../../../library/pear';
|
||||
set_include_path(get_include_path() . PATH_SEPARATOR . $path);
|
||||
$WHITE_SCREEN_OF_DEATH = false;
|
||||
|
||||
require_once(dirname(__FILE__).'/../../configs/conf.php');
|
||||
require_once('DB.php');
|
||||
require_once('PHPUnit.php');
|
||||
require_once 'StoredFileTests.php';
|
||||
require_once 'SchedulerTests.php';
|
||||
//require_once 'SchedulerExportTests.php';
|
||||
require_once 'PlaylistTests.php';
|
||||
|
||||
//$suite = new PHPUnit_TestSuite("PlayListTests");
|
||||
//$suite = new PHPUnit_TestSuite("SchedulerTests");
|
||||
$suite = new PHPUnit_TestSuite("StoredFileTest");
|
||||
$suite->addTestSuite("PlaylistTests");
|
||||
$suite->addTestSuite("SchedulerTests");
|
||||
//$suite->addTestSuite("SchedulerExportTests");
|
||||
$result = PHPUnit::run($suite);
|
||||
|
||||
echo $result->toString();
|
||||
|
||||
?>
|
181
application/models/tests/PlaylistTests.php
Normal file
181
application/models/tests/PlaylistTests.php
Normal file
|
@ -0,0 +1,181 @@
|
|||
<?php
|
||||
|
||||
$path = dirname(__FILE__).'/../../library/pear';
|
||||
set_include_path(get_include_path() . PATH_SEPARATOR . $path);
|
||||
|
||||
require_once(dirname(__FILE__).'/../../../library/propel/runtime/lib/Propel.php');
|
||||
// Initialize Propel with the runtime configuration
|
||||
Propel::init(__DIR__."/../../configs/propel-config.php");
|
||||
|
||||
// Add the generated 'classes' directory to the include path
|
||||
set_include_path(dirname(__FILE__)."/../" . PATH_SEPARATOR . get_include_path());
|
||||
|
||||
require_once('DB.php');
|
||||
require_once('PHPUnit.php');
|
||||
|
||||
require_once(dirname(__FILE__).'/../../configs/conf.php');
|
||||
require_once(dirname(__FILE__).'/../GreenBox.php');
|
||||
require_once(dirname(__FILE__).'/../Playlist.php');
|
||||
|
||||
$tz = ini_get('date.timezone') ? ini_get('date.timezone') : 'America/Toronto';
|
||||
date_default_timezone_set($tz);
|
||||
|
||||
//old database connection still needed to get a session instance.
|
||||
$dsn = $CC_CONFIG['dsn'];
|
||||
$CC_DBC = DB::connect($dsn, TRUE);
|
||||
if (PEAR::isError($CC_DBC)) {
|
||||
echo "ERROR: ".$CC_DBC->getMessage()." ".$CC_DBC->getUserInfo()."\n";
|
||||
exit(1);
|
||||
}
|
||||
$CC_DBC->setFetchMode(DB_FETCHMODE_ASSOC);
|
||||
|
||||
class PlaylistTests extends PHPUnit_TestCase {
|
||||
|
||||
private $greenbox;
|
||||
private $storedFile;
|
||||
private $storedFile2;
|
||||
|
||||
function __construct($name) {
|
||||
parent::__construct($name);
|
||||
}
|
||||
|
||||
function setup() {
|
||||
global $CC_CONFIG, $CC_DBC;
|
||||
$this->greenbox = new GreenBox();
|
||||
|
||||
// Add a file
|
||||
$values = array("filepath" => dirname(__FILE__)."/test10001.mp3");
|
||||
$this->storedFile = StoredFile::Insert($values, false);
|
||||
|
||||
// Add a file
|
||||
$values = array("filepath" => dirname(__FILE__)."/test10002.mp3");
|
||||
$this->storedFile2 = StoredFile::Insert($values, false);
|
||||
|
||||
}
|
||||
|
||||
function testGBCreatePlaylist() {
|
||||
|
||||
$pl = new Playlist();
|
||||
$pl_id = $pl->create("Playlist UnitTest: create ".date("g:i a"));
|
||||
|
||||
if (!is_int($pl_id)) {
|
||||
$this->fail("problems creating playlist.");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
function testGBLock() {
|
||||
$pl = new Playlist();
|
||||
$pl_id = $pl->create("Playlist Metadata: lock ".date("g:i a"));
|
||||
|
||||
$sessid = Alib::Login('root', 'q');
|
||||
|
||||
$res = $this->greenbox->lockPlaylistForEdit($pl_id, $sessid);
|
||||
|
||||
if($res !== TRUE) {
|
||||
$this->fail("problems locking playlist for editing.");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
function testGBUnLock() {
|
||||
$pl = new Playlist();
|
||||
$pl_id = $pl->create("Playlist UnitTest: unlock ".date("g:i a"));
|
||||
|
||||
$sessid = Alib::Login('root', 'q');
|
||||
|
||||
$this->greenbox->lockPlaylistForEdit($pl_id, $sessid);
|
||||
$res = $this->greenbox->releaseLockedPlaylist($pl_id, $sessid);
|
||||
|
||||
if($res !== TRUE) {
|
||||
$this->fail("problems unlocking playlist.");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
function testGBSetPLMetaData() {
|
||||
$pl = new Playlist();
|
||||
$pl_id = $pl->create("Playlist UnitTest: Set Metadata ".date("g:i a"));
|
||||
|
||||
$res = $this->greenbox->setPLMetadataValue($pl_id, "dc:title", "Playlist Unit Test: Updated Title ".date("g:i a"));
|
||||
|
||||
if($res !== TRUE) {
|
||||
$this->fail("problems setting playlist metadata.");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
function testGBGetPLMetaData() {
|
||||
$pl = new Playlist();
|
||||
$name = "Playlist UnitTest: GetMetadata ".date("g:i a");
|
||||
$pl_id = $pl->create($name);
|
||||
|
||||
$res = $this->greenbox->getPLMetadataValue($pl_id, "dc:title");
|
||||
|
||||
if($res !== $name) {
|
||||
$this->fail("problems getting playlist metadata.");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
function testAddAudioClip() {
|
||||
|
||||
$pl = new Playlist();
|
||||
$pl_id = $pl->create("Playlist Unit Test ". date("g:i a"));
|
||||
$res = $this->greenbox->addAudioClipToPlaylist($pl_id, $this->storedFile->getId());
|
||||
if($res !== TRUE) {
|
||||
$this->fail("problems adding audioclip to playlist.");
|
||||
return;
|
||||
}
|
||||
|
||||
$res = $this->greenbox->addAudioClipToPlaylist($pl_id, $this->storedFile2->getId());
|
||||
if($res !== TRUE) {
|
||||
$this->fail("problems adding audioclip 2 to playlist.");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
function testMoveAudioClip() {
|
||||
$pl = new Playlist();
|
||||
$pl_id = $pl->create("Playlist Unit Test: Move ". date("g:i a"));
|
||||
|
||||
$this->greenbox->addAudioClipToPlaylist($pl_id, $this->storedFile->getId());
|
||||
$this->greenbox->addAudioClipToPlaylist($pl_id, $this->storedFile2->getId());
|
||||
|
||||
$res = $this->greenbox->moveAudioClipInPlaylist($pl_id, 0, 1);
|
||||
|
||||
if($res !== TRUE) {
|
||||
$this->fail("problems moving audioclip in playlist.");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
function testDeleteAudioClip() {
|
||||
$pl = new Playlist();
|
||||
$pl_id = $pl->create("Playlist UnitTest: Delete ".date("g:i a"));
|
||||
|
||||
$this->greenbox->addAudioClipToPlaylist($pl_id, $this->storedFile->getId());
|
||||
$res = $this->greenbox->delAudioClipFromPlaylist($pl_id, 0);
|
||||
|
||||
if($res !== TRUE) {
|
||||
$this->fail("problems deleting audioclip from playlist.");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
function testFadeInfo() {
|
||||
$pl = new Playlist();
|
||||
$pl_id = $pl->create("Playlist Unit Test: Fade Info " . date("g:i a"));
|
||||
|
||||
$this->greenbox->addAudioClipToPlaylist($pl_id, $this->storedFile2->getId());
|
||||
|
||||
$res = $this->greenbox->changeFadeInfo($pl_id, 0, '00:00:01.14', null);
|
||||
|
||||
if(!is_array($res) && count($res) !== 2) {
|
||||
$this->fail("problems setting fade in playlist.");
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
42
application/models/tests/SchedulerExportTests.php
Normal file
42
application/models/tests/SchedulerExportTests.php
Normal file
|
@ -0,0 +1,42 @@
|
|||
<?php
|
||||
|
||||
require_once(dirname(__FILE__)."/../Schedule.php");
|
||||
|
||||
class SchedulerExportTests extends PHPUnit_TestCase {
|
||||
function setup() {
|
||||
global $CC_CONFIG, $CC_DBC;
|
||||
|
||||
// Clear the files table
|
||||
$sql = "DELETE FROM ".$CC_CONFIG["filesTable"];
|
||||
$CC_DBC->query($sql);
|
||||
|
||||
// Add a file
|
||||
$values = array("filepath" => dirname(__FILE__)."/test10001.mp3");
|
||||
$this->storedFile = StoredFile::Insert($values, false);
|
||||
|
||||
// Add a file
|
||||
$values = array("filepath" => dirname(__FILE__)."/test10002.mp3");
|
||||
$this->storedFile2 = StoredFile::Insert($values, false);
|
||||
|
||||
// Clear the schedule table
|
||||
$sql = "DELETE FROM ".$CC_CONFIG["scheduleTable"];
|
||||
$CC_DBC->query($sql);
|
||||
|
||||
// Create a playlist
|
||||
$playlist = new Playlist();
|
||||
$playlist->create("Scheduler Unit Test");
|
||||
$result = $playlist->addAudioClip($this->storedFile->getId());
|
||||
$result = $playlist->addAudioClip($this->storedFile2->getId());
|
||||
$result = $playlist->addAudioClip($this->storedFile2->getId());
|
||||
|
||||
// Schedule it
|
||||
$i = new ScheduleGroup();
|
||||
$this->groupIdCreated = $i->add('2010-11-11 01:30:23', null, $playlist->getId());
|
||||
}
|
||||
|
||||
public function testExport() {
|
||||
echo Schedule::ExportRangeAsJson("2010-01-01 00:00:00", "2011-01-01 00:00:00");
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
128
application/models/tests/SchedulerTests.php
Normal file
128
application/models/tests/SchedulerTests.php
Normal file
|
@ -0,0 +1,128 @@
|
|||
<?php
|
||||
require_once(dirname(__FILE__)."/../Schedule.php");
|
||||
|
||||
class SchedulerTests extends PHPUnit_TestCase {
|
||||
|
||||
private $groupIdCreated;
|
||||
private $storedFile;
|
||||
private $storedFile2;
|
||||
|
||||
function setup() {
|
||||
global $CC_CONFIG, $CC_DBC;
|
||||
|
||||
// Clear the files table
|
||||
//$sql = "DELETE FROM ".$CC_CONFIG["filesTable"];
|
||||
//$CC_DBC->query($sql);
|
||||
|
||||
// Add a file
|
||||
$values = array("filepath" => dirname(__FILE__)."/test10001.mp3");
|
||||
$this->storedFile = StoredFile::Insert($values, false);
|
||||
|
||||
// Add a file
|
||||
$values = array("filepath" => dirname(__FILE__)."/test10002.mp3");
|
||||
$this->storedFile2 = StoredFile::Insert($values, false);
|
||||
|
||||
// Clear the schedule table
|
||||
//$sql = "DELETE FROM ".$CC_CONFIG["scheduleTable"];
|
||||
//$CC_DBC->query($sql);
|
||||
}
|
||||
|
||||
function testDateToId() {
|
||||
$dateStr = "2006-04-02 10:20:08.123456";
|
||||
$id = ScheduleGroup::dateToId($dateStr);
|
||||
$expected = "20060402102008123";
|
||||
if ($id != $expected) {
|
||||
$this->fail("Did not convert date to ID correctly #1: $id != $expected");
|
||||
}
|
||||
|
||||
$dateStr = "2006-04-02 10:20:08";
|
||||
$id = ScheduleGroup::dateToId($dateStr);
|
||||
$expected = "20060402102008000";
|
||||
if ($id != $expected) {
|
||||
$this->fail("Did not convert date to ID correctly #2: $id != $expected");
|
||||
}
|
||||
}
|
||||
|
||||
function testAddAndRemoveAudioFile() {
|
||||
$i = new ScheduleGroup();
|
||||
$this->groupIdCreated = $i->add('2010-10-10 01:30:23', $this->storedFile->getId());
|
||||
if (PEAR::isError($this->groupIdCreated)) {
|
||||
$this->fail("Failed to create scheduled item: ". $this->groupIdCreated->getMessage());
|
||||
}
|
||||
|
||||
$i = new ScheduleGroup($this->groupIdCreated);
|
||||
$result = $i->remove();
|
||||
if ($result != 1) {
|
||||
$this->fail("Did not remove item.");
|
||||
}
|
||||
}
|
||||
|
||||
function testAddAndRemovePlaylist() {
|
||||
// Create a playlist
|
||||
$playlist = new Playlist();
|
||||
$playlist->create("Scheduler Unit Test ".uniqid());
|
||||
$result = $playlist->addAudioClip($this->storedFile->getId());
|
||||
$result = $playlist->addAudioClip($this->storedFile2->getId());
|
||||
$result = $playlist->addAudioClip($this->storedFile2->getId());
|
||||
|
||||
$i = new ScheduleGroup();
|
||||
$this->groupIdCreated = $i->add('2010-11-11 01:30:23', null, $playlist->getId());
|
||||
if (PEAR::isError($this->groupIdCreated)) {
|
||||
$this->fail("Failed to create scheduled item: ". $this->groupIdCreated->getMessage());
|
||||
}
|
||||
$group = new ScheduleGroup($this->groupIdCreated);
|
||||
if ($group->count() != 3) {
|
||||
$this->fail("Wrong number of items added.");
|
||||
}
|
||||
$items = $group->getItems();
|
||||
if (!is_array($items) || ($items[1]["starts"] != "2010-11-11 01:30:34.231")) {
|
||||
$this->fail("Wrong start time for 2nd item.");
|
||||
}
|
||||
|
||||
$result = $group->remove();
|
||||
if ($result != 1) {
|
||||
$this->fail("Did not remove item.");
|
||||
}
|
||||
|
||||
Playlist::Delete($playlist->getId());
|
||||
}
|
||||
|
||||
function testIsScheduleEmptyInRange() {
|
||||
$i = new ScheduleGroup();
|
||||
$this->groupIdCreated = $i->add('2011-10-10 01:30:23', $this->storedFile->getId());
|
||||
if (PEAR::isError($this->groupIdCreated)) {
|
||||
$this->fail($this->groupIdCreated->getMessage());
|
||||
return;
|
||||
}
|
||||
if (Schedule::isScheduleEmptyInRange('2011-10-10 01:30:23', '00:00:12.555')) {
|
||||
$this->fail("Reporting empty schedule when it isnt.");
|
||||
return;
|
||||
}
|
||||
// echo "groupid: ".$this->groupIdCreated."\n";
|
||||
$success = $i->remove();
|
||||
if ($success === false) {
|
||||
$this->fail("Failed to delete schedule group.");
|
||||
return;
|
||||
}
|
||||
if (!Schedule::isScheduleEmptyInRange('2011-10-10 01:30:23', '00:00:12.555')) {
|
||||
$this->fail("Reporting booked schedule when it isnt.");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
function testGetItems() {
|
||||
$i1 = new ScheduleGroup();
|
||||
$groupId1 = $i1->add('2008-01-01 12:00:00.000', $this->storedFile->getId());
|
||||
$i2 = new ScheduleGroup();
|
||||
$i2->addAfter($groupId1, $this->storedFile->getId());
|
||||
$items = Schedule::GetItems("2008-01-01", "2008-01-02");
|
||||
if (count($items) != 2) {
|
||||
$this->fail("Wrong number of items returned.");
|
||||
return;
|
||||
}
|
||||
$i1->remove();
|
||||
$i2->remove();
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
87
application/models/tests/StoredFileTests.php
Normal file
87
application/models/tests/StoredFileTests.php
Normal file
|
@ -0,0 +1,87 @@
|
|||
<?php
|
||||
require_once(dirname(__FILE__).'/../StoredFile.php');
|
||||
|
||||
$dsn = $CC_CONFIG['dsn'];
|
||||
$CC_DBC = DB::connect($dsn, TRUE);
|
||||
if (PEAR::isError($CC_DBC)) {
|
||||
echo "ERROR: ".$CC_DBC->getMessage()." ".$CC_DBC->getUserInfo()."\n";
|
||||
exit(1);
|
||||
}
|
||||
$CC_DBC->setFetchMode(DB_FETCHMODE_ASSOC);
|
||||
|
||||
class StoredFileTest extends PHPUnit_TestCase {
|
||||
|
||||
function __construct($name) {
|
||||
parent::__construct($name);
|
||||
}
|
||||
|
||||
function setup() {
|
||||
}
|
||||
|
||||
function testGetAudioMetadata() {
|
||||
$filePath = dirname(__FILE__)."/ex1.mp3";
|
||||
$metadata = camp_get_audio_metadata($filePath);
|
||||
if (PEAR::isError($metadata)) {
|
||||
$this->fail($metadata->getMessage());
|
||||
return;
|
||||
}
|
||||
if (($metadata["dc:description"] != "Tmu sem tam videla ...")
|
||||
|| ($metadata["audio"]["dataformat"] != "mp3")
|
||||
|| ($metadata["dc:type"] != "Speech")) {
|
||||
$str = " [dc:description] = " . $metadata["dc:description"] ."\n"
|
||||
. " [audio][dataformat] = " . $metadata["audio"]["dataformat"]."\n"
|
||||
. " [dc:type] = ".$metadata["dc:type"]."\n";
|
||||
$this->fail("Metadata has unexpected values:\n".$str);
|
||||
}
|
||||
//var_dump($metadata);
|
||||
//$this->assertTrue(FALSE);
|
||||
}
|
||||
|
||||
function testDeleteAndPutFile() {
|
||||
$STORAGE_SERVER_PATH = dirname(__FILE__)."/../../";
|
||||
$filePath = dirname(__FILE__)."/ex1.mp3";
|
||||
|
||||
// Delete any old data from previous tests
|
||||
$md5 = md5_file($filePath);
|
||||
$duplicate = StoredFile::RecallByMd5($md5);
|
||||
if ($duplicate) {
|
||||
$duplicate->delete();
|
||||
}
|
||||
|
||||
// Test inserting a file by linking
|
||||
$values = array("filepath" => $filePath,
|
||||
"dc:description" => "Unit test ".time());
|
||||
$storedFile = StoredFile::Insert($values, false);
|
||||
if (PEAR::isError($storedFile)) {
|
||||
$this->fail("Failed to create StoredFile: ".$storedFile->getMessage());
|
||||
return;
|
||||
}
|
||||
//var_dump($storedFile);
|
||||
$id = $storedFile->getId();
|
||||
if (!is_numeric($id)) {
|
||||
$this->fail("StoredFile not created correctly. id = ".$id);
|
||||
return;
|
||||
}
|
||||
|
||||
// Test loading metadata
|
||||
$f = new StoredFile();
|
||||
$f->__setGunid($storedFile->getGunid());
|
||||
$f->loadMetadata();
|
||||
if (!is_array($md = $f->getMetadata())) {
|
||||
$this->fail("Unable to load metadata.");
|
||||
return;
|
||||
}
|
||||
//var_dump($md);
|
||||
|
||||
// Check if the length field has been set.
|
||||
$f2 = StoredFile::RecallByGunid($storedFile->getGunid());
|
||||
$m2 = $f2->getMetadata();
|
||||
if (!isset($m2["length"]) || $m2["length"] == "00:00:00.000000") {
|
||||
$this->fail("Length not reporting correctly in metadata.");
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
25
application/models/tests/analyze.php
Executable file
25
application/models/tests/analyze.php
Executable file
|
@ -0,0 +1,25 @@
|
|||
#!/usr/bin/php -q
|
||||
<?php
|
||||
header("Content-type: text/plain");
|
||||
echo "TEST\n";
|
||||
|
||||
#$gunid = "5716b53127c3761f92fddde3412c7773";
|
||||
$gunid = $argv[1];
|
||||
echo "GUNID: $gunid\n";
|
||||
|
||||
require_once('../../conf.php');
|
||||
require_once('DB.php');
|
||||
require_once('../GreenBox.php');
|
||||
|
||||
$rmd = new StoredFile($gunid, '../stor/'.substr($gunid, 0, 3));
|
||||
$r = $rmd->analyzeFile();
|
||||
|
||||
echo "r=$r (".gettype($r).")\n";
|
||||
if (PEAR::isError($r)) {
|
||||
echo "ERR: ".$r->getMessage()."\n".$r->getUserInfo()."\n";
|
||||
}
|
||||
if (is_array($r)) {
|
||||
print_r($r);
|
||||
}
|
||||
echo"\n";
|
||||
?>
|
BIN
application/models/tests/ex1.mp3
Normal file
BIN
application/models/tests/ex1.mp3
Normal file
Binary file not shown.
BIN
application/models/tests/ex2.ogg
Normal file
BIN
application/models/tests/ex2.ogg
Normal file
Binary file not shown.
BIN
application/models/tests/ex2.wav
Normal file
BIN
application/models/tests/ex2.wav
Normal file
Binary file not shown.
BIN
application/models/tests/ex3.wav
Normal file
BIN
application/models/tests/ex3.wav
Normal file
Binary file not shown.
BIN
application/models/tests/exportedPl_lspl.tar
Normal file
BIN
application/models/tests/exportedPl_lspl.tar
Normal file
Binary file not shown.
4
application/models/tests/index.php
Normal file
4
application/models/tests/index.php
Normal file
|
@ -0,0 +1,4 @@
|
|||
<?php
|
||||
header ("location: ../");
|
||||
exit;
|
||||
?>
|
22
application/models/tests/pdoTest.php
Normal file
22
application/models/tests/pdoTest.php
Normal file
|
@ -0,0 +1,22 @@
|
|||
<?php
|
||||
require_once(__DIR__.'/../../3rd_party/php/propel/runtime/lib/Propel.php');
|
||||
// Initialize Propel with the runtime configuration
|
||||
Propel::init(__DIR__."/../propel-db/build/conf/campcaster-conf.php");
|
||||
// Add the generated 'classes' directory to the include path
|
||||
set_include_path(__DIR__."/../propel-db/build/classes" . PATH_SEPARATOR . get_include_path());
|
||||
$con = Propel::getConnection("campcaster");
|
||||
|
||||
$sql = "SELECT COUNT(*) FROM cc_schedule WHERE (starts >= '2010-01-01 00:00:00.000') "
|
||||
." AND (ends <= (TIMESTAMP '2011-01-01 00:00:00.000' + INTERVAL '01:00:00.123456'))";
|
||||
$rows1 = $con->query($sql);
|
||||
var_dump($rows1->fetchAll());
|
||||
|
||||
$sql2 = "SELECT COUNT(*) FROM cc_playlistcontents";
|
||||
$rows2 = $con->query($sql2);
|
||||
var_dump($rows2->fetchAll());
|
||||
|
||||
$sql3 = "SELECT TIMESTAMP '2011-01-01 00:00:00.000' + INTERVAL '01:00:00.123456'";
|
||||
$result3 = $con->query($sql3);
|
||||
var_dump($result3->fetchAll());
|
||||
|
||||
?>
|
26
application/models/tests/plistEmbedded.xml
Normal file
26
application/models/tests/plistEmbedded.xml
Normal file
|
@ -0,0 +1,26 @@
|
|||
<?xml version="1.0"?>
|
||||
<playlist id="0e22c20310212a51">
|
||||
<playlistElement id="0000000000000103" relativeOffset="00:00:00.000000" >
|
||||
<audioClip id="0000000000010003"
|
||||
playlength="00:00:11.500000"
|
||||
title = "three"
|
||||
uri="file:var/test10003.mp3"
|
||||
/>
|
||||
</playlistElement>
|
||||
<playlistElement id="0000000000000104" relativeOffset="00:00:11.500000">
|
||||
<playlist id="0000000000000001"
|
||||
playlength="01:30:00.000000"
|
||||
title="My First Playlist">
|
||||
</playlist>
|
||||
</playlistElement>
|
||||
<metadata
|
||||
xmlns="http://mdlf.org/campcaster/elements/1.0/"
|
||||
xmlns:ls="http://mdlf.org/campcaster/elements/1.0/"
|
||||
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
||||
xmlns:dcterms="http://purl.org/dc/terms/"
|
||||
>
|
||||
<dc:title>embedded playlist</dc:title>
|
||||
<dcterms:extent>01:30:11.500000</dcterms:extent>
|
||||
</metadata>
|
||||
</playlist>
|
||||
|
85
application/models/tests/pypoTester.php
Normal file
85
application/models/tests/pypoTester.php
Normal file
|
@ -0,0 +1,85 @@
|
|||
<?php
|
||||
require_once '../../conf.php';
|
||||
require_once '../Playlist.php';
|
||||
require_once '../StoredFile.php';
|
||||
require_once(__DIR__.'/../../3rd_party/php/propel/runtime/lib/Propel.php');
|
||||
// Initialize Propel with the runtime configuration
|
||||
Propel::init(__DIR__."/../propel-db/build/conf/campcaster-conf.php");
|
||||
// Add the generated 'classes' directory to the include path
|
||||
set_include_path(__DIR__."/../propel-db/build/classes" . PATH_SEPARATOR . get_include_path());
|
||||
|
||||
$playlistName = "pypo_playlist_test";
|
||||
$minutesFromNow = 1;
|
||||
|
||||
echo " ************************************************************** \n";
|
||||
echo " This script schedules a playlist to play $minutesFromNow minute(s) from now.\n";
|
||||
echo " This is a utility to help you debug the scheduler.\n";
|
||||
echo " ************************************************************** \n";
|
||||
echo "\n";
|
||||
echo "Deleting playlists with the name '$playlistName'...";
|
||||
// Delete any old playlists
|
||||
$pl2 = Playlist::findPlaylistByName($playlistName);
|
||||
foreach ($pl2 as $playlist) {
|
||||
//var_dump($playlist);
|
||||
$playlist->delete();
|
||||
}
|
||||
echo "done.\n";
|
||||
|
||||
// Create a new playlist
|
||||
echo "Creating new playlist '$playlistName'...";
|
||||
$pl = new Playlist();
|
||||
$pl->create($playlistName);
|
||||
|
||||
// Add a media clip
|
||||
$mediaFile = StoredFile::findByOriginalName("Manolo Camp - Morning Coffee.mp3");
|
||||
if (is_null($mediaFile)) {
|
||||
echo "Adding test audio clip to the database.\n";
|
||||
$v = array("filepath" => __DIR__."/../../audio_samples/OpSound/Manolo Camp - Morning Coffee.mp3");
|
||||
$mediaFile = StoredFile::Insert($v);
|
||||
if (PEAR::isError($mediaFile)) {
|
||||
var_dump($mediaFile);
|
||||
exit();
|
||||
}
|
||||
}
|
||||
$pl->addAudioClip($mediaFile->getId());
|
||||
$mediaFile = StoredFile::findByOriginalName("Peter Rudenko - Opening.mp3");
|
||||
if (is_null($mediaFile)) {
|
||||
echo "Adding test audio clip to the database.\n";
|
||||
$v = array("filepath" => __DIR__."/../../audio_samples/OpSound/Peter Rudenko - Opening.mp3");
|
||||
$mediaFile = StoredFile::Insert($v);
|
||||
if (PEAR::isError($mediaFile)) {
|
||||
var_dump($mediaFile);
|
||||
exit();
|
||||
}
|
||||
}
|
||||
$pl->addAudioClip($mediaFile->getId());
|
||||
echo "done.\n";
|
||||
|
||||
//$pl2 = Playlist::findPlaylistByName("pypo_playlist_test");
|
||||
//var_dump($pl2);
|
||||
|
||||
// Get current time
|
||||
// In the format YYYY-MM-DD HH:MM:SS.nnnnnn
|
||||
$startTime = date("Y-m-d H:i:s");
|
||||
$endTime = date("Y-m-d H:i:s", time()+(60*60));
|
||||
|
||||
echo "Removing everything from the scheduler between $startTime and $endTime...";
|
||||
// Scheduler: remove any playlists for the next hour
|
||||
Schedule::RemoveItemsInRange($startTime, $endTime);
|
||||
// Check for succcess
|
||||
$scheduleClear = Schedule::isScheduleEmptyInRange($startTime, "01:00:00");
|
||||
if (!$scheduleClear) {
|
||||
echo "\nERROR: Schedule could not be cleared.\n\n";
|
||||
var_dump(Schedule::GetItems($startTime, $endTime));
|
||||
exit;
|
||||
}
|
||||
echo "done.\n";
|
||||
|
||||
// Schedule the playlist for two minutes from now
|
||||
echo "Scheduling new playlist...\n";
|
||||
$playTime = date("Y-m-d H:i:s", time()+(60*$minutesFromNow));
|
||||
$scheduleGroup = new ScheduleGroup();
|
||||
$scheduleGroup->add($playTime, null, $pl->getId());
|
||||
|
||||
echo " SUCCESS: Playlist scheduled at $playTime\n\n";
|
||||
?>
|
BIN
application/models/tests/question.wav
Normal file
BIN
application/models/tests/question.wav
Normal file
Binary file not shown.
BIN
application/models/tests/silence.wav
Normal file
BIN
application/models/tests/silence.wav
Normal file
Binary file not shown.
BIN
application/models/tests/test10001.mp3
Normal file
BIN
application/models/tests/test10001.mp3
Normal file
Binary file not shown.
BIN
application/models/tests/test10002.mp3
Normal file
BIN
application/models/tests/test10002.mp3
Normal file
Binary file not shown.
BIN
application/models/tests/test10003.mp3
Normal file
BIN
application/models/tests/test10003.mp3
Normal file
Binary file not shown.
143
application/models/tests/transTest.php
Normal file
143
application/models/tests/transTest.php
Normal file
|
@ -0,0 +1,143 @@
|
|||
<?php
|
||||
/*
|
||||
header("Content-type: text/plain");
|
||||
|
||||
require_once('../../conf.php');
|
||||
require_once('DB.php');
|
||||
require_once('../GreenBox.php');
|
||||
require_once('../LocStor.php');
|
||||
|
||||
#PEAR::setErrorHandling(PEAR_ERROR_PRINT, "%s<hr>\n");
|
||||
PEAR::setErrorHandling(PEAR_ERROR_RETURN);
|
||||
$CC_DBC = DB::connect($CC_CONFIG['dsn'], TRUE);
|
||||
$CC_DBC->setFetchMode(DB_FETCHMODE_ASSOC);
|
||||
$gb = new GreenBox();
|
||||
$tr = new Transport($gb);
|
||||
$ls = new LocStor();
|
||||
@unlink($CC_CONFIG['transDir']."/activity.log");
|
||||
@unlink($CC_CONFIG['transDir']."/debug.log");
|
||||
$tr->_cleanUp();
|
||||
|
||||
$gunid = 'a23456789abcdefb';
|
||||
$mediaFile = '../tests/ex1.mp3';
|
||||
$mdataFile = '../tests/mdata1.xml';
|
||||
|
||||
// Test remote search
|
||||
$result = $tr->remoteSearch("");
|
||||
if (PEAR::isError($result)) {
|
||||
echo $result->message."\n";
|
||||
} else {
|
||||
var_dump($result);
|
||||
}
|
||||
|
||||
// ========== STORE ==========
|
||||
|
||||
echo"# Store: ";
|
||||
//$parid = $gb->_getHomeDirIdFromSess($sessid);
|
||||
$values = array(
|
||||
"filename" => "xx1.mp3",
|
||||
"filepath" => $mediaFile,
|
||||
"metadata" => $mdataFile,
|
||||
"gunid" => $gunid,
|
||||
"filetype" => "audioclip"
|
||||
);
|
||||
$storedFile = StoredFile::Insert($values);
|
||||
if (PEAR::isError($storedFile)) {
|
||||
if ($storedFile->getCode()!=GBERR_GUNID) {
|
||||
echo "ERROR: ".$storedFile->getMessage()."\n";
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
$oid = $storedFile->getId();
|
||||
$comm = "ls -l ".$CC_CONFIG['storageDir']."/a23"; echo `$comm`;
|
||||
echo "$oid\n";
|
||||
|
||||
// ========== DELETE FROM HUB ==========
|
||||
echo"# loginToArchive: ";
|
||||
$r = $tr->loginToArchive();
|
||||
if(PEAR::isError($r)){ echo "ERROR: ".$r->getMessage()." / ".$r->getUserInfo()."\n"; exit(1); }
|
||||
echo "{$r['sessid']}\n";
|
||||
$asessid = $r['sessid'];
|
||||
echo"# deleteAudioClip on Hub: ";
|
||||
$r = $tr->xmlrpcCall(
|
||||
'archive.deleteAudioClip',
|
||||
array(
|
||||
'sessid' => $asessid,
|
||||
'gunid' => $gunid,
|
||||
'forced' => TRUE,
|
||||
)
|
||||
);
|
||||
if(PEAR::isError($r)){ echo "ERROR: ".$r->getMessage()." / ".$r->getUserInfo()."\n"; if($r->getCode()!=800+GBERR_FILENEX) exit(1); }
|
||||
else{ echo " {$r['status']}\n"; }
|
||||
echo"# logoutFromArchive: ";
|
||||
$r = $tr->logoutFromArchive($asessid);
|
||||
if(PEAR::isError($r)){ echo "ERROR: ".$r->getMessage()." / ".$r->getUserInfo()."\n"; exit(1); }
|
||||
var_export($r); echo"\n";
|
||||
|
||||
|
||||
// ========== UPLOAD ==========
|
||||
echo "# UPLOAD test:\n";
|
||||
echo"# uploadAudioClip2Hub: ";
|
||||
$r = $gb->upload2Hub($gunid);
|
||||
if(PEAR::isError($r)){ echo "ERROR: ".$r->getMessage()."/".$r->getUserInfo()."\n"; exit(1); }
|
||||
var_export($r); echo"\n";
|
||||
$trtok = $r;
|
||||
|
||||
echo"# logout: "; $r = Alib::Logout($sessid);
|
||||
if(PEAR::isError($r)){ echo "ERROR: ".$r->getMessage()."/".$r->getUserInfo()."\n"; exit(1); }
|
||||
echo "$r\n";
|
||||
#$trtok='280a6f1c18389620';
|
||||
|
||||
for($state='', $nu=1; ($state!='closed' && $state!='failed' && $nu<=12); $nu++, sleep(2)){
|
||||
echo"# getTransportInfo: "; $r = $gb->getTransportInfo($trtok);
|
||||
if(PEAR::isError($r)){ echo "ERROR: ".$r->getMessage()."/".$r->getUserInfo()."\n"; exit(1); }
|
||||
$state = $r['state'];
|
||||
echo "# state=$state, title={$r['title']}\n";
|
||||
}
|
||||
if($state=='failed') exit(1);
|
||||
|
||||
// === DELETE LOCAL ===
|
||||
echo "# Login: ".($sessid = Alib::Login('root', 'q'))."\n";
|
||||
echo "# Delete: "; $r = $ls->deleteAudioClip($sessid, $gunid, TRUE);
|
||||
if (PEAR::isError($r)) {
|
||||
echo "ERROR: ".$r->getMessage()."\n";
|
||||
exit(1);
|
||||
}
|
||||
echo "$r\n";
|
||||
echo "# logout: "; $r = Alib::Logout($sessid);
|
||||
if (PEAR::isError($r)) {
|
||||
echo "ERROR: ".$r->getMessage()."\n";
|
||||
exit(1);
|
||||
}
|
||||
echo "$r\n";
|
||||
$comm = "ls -l ".$CC_CONFIG['storageDir']."/a23";
|
||||
echo `$comm`;
|
||||
|
||||
// === DOWNLOAD ===
|
||||
echo "# DOWNLOAD test:\n";
|
||||
echo"# Login: ".($sessid = Alib::Login('root', 'q'))."\n";
|
||||
|
||||
echo"# downloadAudioClipFromHub: ";
|
||||
$r = $gb->downloadFromHub($sessid, $gunid);
|
||||
if(PEAR::isError($r)){ echo "ERROR: ".$r->getMessage()."/".$r->getUserInfo()."\n"; exit(1); }
|
||||
var_export($r); echo"\n";
|
||||
$trtok = $r;
|
||||
|
||||
echo"# logout: "; $r = Alib::Logout($sessid);
|
||||
if(PEAR::isError($r)){ echo "ERROR: ".$r->getMessage()."\n"; exit(1); }
|
||||
echo "$r\n";
|
||||
|
||||
for($state='', $nu=1; ($state!='closed' && $state!='failed' && $nu<=12); $nu++, sleep(2)){
|
||||
echo"# getTransportInfo: "; $r = $gb->getTransportInfo($trtok);
|
||||
if(PEAR::isError($r)){ echo "ERROR: ".$r->getMessage()."/".$r->getUserInfo()."\n"; exit(1); }
|
||||
$state = $r['state'];
|
||||
echo "# state=$state, title={$r['title']}\n";
|
||||
}
|
||||
if($state=='failed') exit(1);
|
||||
|
||||
$comm = "ls -l ".$CC_CONFIG['storageDir']."/a23"; echo `$comm`;
|
||||
|
||||
if(file_exists("../trans/log")) echo `tail -n 25 ../trans/log`;
|
||||
echo "#Transport test: OK.\n\n";
|
||||
*/
|
||||
?>
|
62
application/models/tests/webstreamTest.php
Normal file
62
application/models/tests/webstreamTest.php
Normal file
|
@ -0,0 +1,62 @@
|
|||
<?php
|
||||
/*
|
||||
header("Content-type: text/plain");
|
||||
echo "\n#StorageServer storeWebstream test:\n";
|
||||
|
||||
require_once('../../conf.php');
|
||||
require_once('DB.php');
|
||||
require_once('../GreenBox.php');
|
||||
|
||||
#PEAR::setErrorHandling(PEAR_ERROR_PRINT, "%s<hr>\n");
|
||||
PEAR::setErrorHandling(PEAR_ERROR_RETURN);
|
||||
$CC_DBC = DB::connect($CC_CONFIG['dsn'], TRUE);
|
||||
$CC_DBC->setFetchMode(DB_FETCHMODE_ASSOC);
|
||||
$gb = new GreenBox();
|
||||
|
||||
#$gunid = "123456789abcdee0";
|
||||
$gunid = "";
|
||||
#$mdataFileLP = '../tests/mdata1.xml';
|
||||
$mdataFileLP = NULL;
|
||||
|
||||
echo "# Login: ".($sessid = Alib::Login('root', 'q'))."\n";
|
||||
$parid = $gb->_getHomeDirId($sessid);
|
||||
|
||||
echo "# storeWebstream: ";
|
||||
$r = $gb->storeWebstream(
|
||||
$parid, 'test stream', $mdataFileLP, $sessid, $gunid, 'http://localhost/y');
|
||||
if (PEAR::isError($r)) {
|
||||
echo "ERROR: ".$r->getMessage()." ".$r->getUserInfo()."\n";
|
||||
exit(1);
|
||||
}
|
||||
echo "";
|
||||
var_dump($r);
|
||||
//$id = BasicStor::IdFromGunid($gunid);
|
||||
$id = $r;
|
||||
|
||||
echo "# getMdata: ";
|
||||
$r = $gb->getMetadata($id, $sessid);
|
||||
if (PEAR::isError($r)) {
|
||||
echo "ERROR: ".$r->getMessage()." ".$r->getUserInfo()."\n";
|
||||
exit(1);
|
||||
}
|
||||
echo "\n$r\n";
|
||||
|
||||
echo "# deleteFile: ";
|
||||
$r = $gb->deleteFile($id, $sessid);
|
||||
if (PEAR::isError($r)) {
|
||||
echo "ERROR: ".$r->getMessage()." ".$r->getUserInfo()."\n";
|
||||
exit(1);
|
||||
}
|
||||
echo "\n$r\n";
|
||||
|
||||
echo "# logout: ";
|
||||
$r = Alib::Logout($sessid);
|
||||
if (PEAR::isError($r)) {
|
||||
echo "ERROR: ".$r->getMessage()."\n";
|
||||
exit(1);
|
||||
}
|
||||
echo "$r\n";
|
||||
|
||||
echo "#storeWebstream test: OK.\n\n"
|
||||
*/
|
||||
?>
|
14
application/models/tests/wstream1.xml
Normal file
14
application/models/tests/wstream1.xml
Normal file
|
@ -0,0 +1,14 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||
<audioClip>
|
||||
<metadata
|
||||
xmlns="http://mdlf.org/campcaster/elements/1.0/"
|
||||
xmlns:ls="http://mdlf.org/campcaster/elements/1.0/"
|
||||
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
||||
xmlns:dcterms="http://purl.org/dc/terms/"
|
||||
xmlns:xml="http://www.w3.org/XML/1998/namespace"
|
||||
>
|
||||
<dc:title>Webstream test 1</dc:title>
|
||||
<dcterms:extent>01:30:00.000000</dcterms:extent>
|
||||
<ls:url>http://localhost/y</ls:url>
|
||||
</metadata>
|
||||
</audioClip>
|
|
@ -169,6 +169,7 @@ CREATE TABLE "cc_show"
|
|||
"repeats" INT2 NOT NULL,
|
||||
"day" INT2 NOT NULL,
|
||||
"description" VARCHAR(512),
|
||||
"show_id" INTEGER NOT NULL,
|
||||
PRIMARY KEY ("id")
|
||||
);
|
||||
|
||||
|
@ -331,7 +332,7 @@ DROP TABLE "cc_subjs" CASCADE;
|
|||
|
||||
CREATE TABLE "cc_subjs"
|
||||
(
|
||||
"id" INTEGER NOT NULL,
|
||||
"id" serial NOT NULL,
|
||||
"login" VARCHAR(255) default '' NOT NULL,
|
||||
"pass" VARCHAR(255) default '' NOT NULL,
|
||||
"type" CHAR(1) default 'U' NOT NULL,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue