CC-1927: Remove PEAR DB
First pass through the model classes to remove use of $CC_DBC. Web application is working. There are still other parts of the app that use PEAR DB.
This commit is contained in:
parent
f69a172ee1
commit
7f78a7f663
13 changed files with 630 additions and 565 deletions
|
@ -10,7 +10,7 @@ require_once 'propel/runtime/lib/Propel.php';
|
||||||
Propel::init(__DIR__."/configs/airtime-conf-production.php");
|
Propel::init(__DIR__."/configs/airtime-conf-production.php");
|
||||||
|
|
||||||
require_once __DIR__."/configs/constants.php";
|
require_once __DIR__."/configs/constants.php";
|
||||||
require_once 'DB.php';
|
// require_once 'DB.php';
|
||||||
|
|
||||||
require_once 'Preference.php';
|
require_once 'Preference.php';
|
||||||
require_once "DateHelper.php";
|
require_once "DateHelper.php";
|
||||||
|
@ -20,12 +20,34 @@ require_once __DIR__.'/controllers/plugins/RabbitMqPlugin.php';
|
||||||
global $CC_CONFIG, $CC_DBC;
|
global $CC_CONFIG, $CC_DBC;
|
||||||
$dsn = $CC_CONFIG['dsn'];
|
$dsn = $CC_CONFIG['dsn'];
|
||||||
|
|
||||||
$CC_DBC = DB::connect($dsn, FALSE);
|
// ******************************************************************
|
||||||
if (PEAR::isError($CC_DBC)) {
|
// Differences between PEAR DB & Propel/PDO:
|
||||||
echo "ERROR: ".$CC_DBC->getMessage()." ".$CC_DBC->getUserInfo()."\n";
|
// When selecting a single value from a null return set,
|
||||||
exit(1);
|
// PEAR returns NULL
|
||||||
}
|
// PDO returns false
|
||||||
$CC_DBC->setFetchMode(DB_FETCHMODE_ASSOC);
|
// ******************************************************************
|
||||||
|
|
||||||
|
// $CC_DBC = DB::connect($dsn, FALSE);
|
||||||
|
// if (PEAR::isError($CC_DBC)) {
|
||||||
|
// echo "ERROR: ".$CC_DBC->getMessage()." ".$CC_DBC->getUserInfo()."\n";
|
||||||
|
// exit(1);
|
||||||
|
// }
|
||||||
|
// $CC_DBC->setFetchMode(DB_FETCHMODE_ASSOC);
|
||||||
|
|
||||||
|
// $sql = "SELECT column_name, character_maximum_length FROM information_schema.columns"
|
||||||
|
// ." WHERE table_name = 'cc_show' AND character_maximum_length > 0 and table_name=''";
|
||||||
|
// // $sql = "SELECT * FROM cc_files WHERE id=1";
|
||||||
|
// // $result = $CC_DBC->GetAll($sql);
|
||||||
|
// $result = $CC_DBC->GetOne($sql);
|
||||||
|
// var_dump($result);
|
||||||
|
|
||||||
|
// $con = Propel::getConnection();
|
||||||
|
// $q = $con->query($sql);
|
||||||
|
// //var_dump($q);
|
||||||
|
// //var_dump($q->fetchAll());
|
||||||
|
// var_dump($q->fetchColumn(0));
|
||||||
|
|
||||||
|
// exit;
|
||||||
|
|
||||||
$CC_CONFIG['airtime_version'] = Application_Model_Preference::GetAirtimeVersion();
|
$CC_CONFIG['airtime_version'] = Application_Model_Preference::GetAirtimeVersion();
|
||||||
|
|
||||||
|
|
|
@ -342,7 +342,7 @@ class ApiController extends Zend_Controller_Action
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
PEAR::setErrorHandling(PEAR_ERROR_RETURN);
|
//PEAR::setErrorHandling(PEAR_ERROR_RETURN);
|
||||||
|
|
||||||
$data = Application_Model_Schedule::GetScheduledPlaylists();
|
$data = Application_Model_Schedule::GetScheduledPlaylists();
|
||||||
echo json_encode($data, JSON_FORCE_OBJECT);
|
echo json_encode($data, JSON_FORCE_OBJECT);
|
||||||
|
|
|
@ -1,45 +1,36 @@
|
||||||
<?php
|
<?php
|
||||||
class Application_Model_LoginAttempts {
|
class Application_Model_LoginAttempts {
|
||||||
public function __construct(){
|
public function __construct(){
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function increaseAttempts($ip){
|
public static function increaseAttempts($ip){
|
||||||
global $CC_DBC;
|
$con = Propel::getConnection();
|
||||||
$sql = "select count(*) from cc_login_attempts WHERE ip='$ip'";
|
$sql = "select count(*) from cc_login_attempts WHERE ip='$ip'";
|
||||||
$res = $CC_DBC->GetOne($sql);
|
$res = $con->query($sql)->fetchColumn(0);
|
||||||
if($res){
|
if ($res) {
|
||||||
$sql = "UPDATE cc_login_attempts SET attempts=attempts+1 WHERE ip='$ip'";
|
$sql = "UPDATE cc_login_attempts SET attempts=attempts+1 WHERE ip='$ip'";
|
||||||
$res = $CC_DBC->query($sql);
|
$con->exec($sql);
|
||||||
if (PEAR::isError($res)) {
|
} else {
|
||||||
return $res;
|
|
||||||
}
|
|
||||||
}else{
|
|
||||||
$sql = "INSERT INTO cc_login_attempts (ip, attempts) values ('$ip', '1')";
|
$sql = "INSERT INTO cc_login_attempts (ip, attempts) values ('$ip', '1')";
|
||||||
$res = $CC_DBC->query($sql);
|
$con->exec($sql);
|
||||||
if (PEAR::isError($res)) {
|
|
||||||
return $res;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function getAttempts($ip){
|
public static function getAttempts($ip){
|
||||||
global $CC_DBC;
|
$con = Propel::getConnection();
|
||||||
$sql = "select attempts from cc_login_attempts WHERE ip='$ip'";
|
$sql = "select attempts from cc_login_attempts WHERE ip='$ip'";
|
||||||
$res = $CC_DBC->GetOne($sql);
|
$res = $con->query($sql)->fetchColumn(0);
|
||||||
return $res;
|
return $res ? $res : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function resetAttempts($ip){
|
public static function resetAttempts($ip){
|
||||||
global $CC_DBC;
|
$con = Propel::getConnection();
|
||||||
$sql = "select count(*) from cc_login_attempts WHERE ip='$ip'";
|
$sql = "select count(*) from cc_login_attempts WHERE ip='$ip'";
|
||||||
$res = $CC_DBC->GetOne($sql);
|
$res = $con->query($sql)->fetchColumn(0);
|
||||||
if($res){
|
if ($res > 0) {
|
||||||
$sql = "DELETE FROM cc_login_attempts WHERE ip='$ip'";
|
$sql = "DELETE FROM cc_login_attempts WHERE ip='$ip'";
|
||||||
$res = $CC_DBC->query($sql);
|
$con->exec($sql);
|
||||||
if (PEAR::isError($res)) {
|
|
||||||
return $res;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -58,7 +58,8 @@ class Application_Model_MusicDir {
|
||||||
return $this->_dir->getExists();
|
return $this->_dir->getExists();
|
||||||
}
|
}
|
||||||
|
|
||||||
/** There are 2 cases where this function can be called.
|
/**
|
||||||
|
* There are 2 cases where this function can be called.
|
||||||
* 1. When watched dir was removed
|
* 1. When watched dir was removed
|
||||||
* 2. When some dir was watched, but it was unmounted
|
* 2. When some dir was watched, but it was unmounted
|
||||||
*
|
*
|
||||||
|
@ -67,24 +68,26 @@ class Application_Model_MusicDir {
|
||||||
*
|
*
|
||||||
* When $userAddedWatchedDir is true, it will set "Watched" flag to false
|
* When $userAddedWatchedDir is true, it will set "Watched" flag to false
|
||||||
* otherwise, it will set "Exists" flag to true
|
* otherwise, it will set "Exists" flag to true
|
||||||
**/
|
*/
|
||||||
public function remove($userAddedWatchedDir=true)
|
public function remove($userAddedWatchedDir=true)
|
||||||
{
|
{
|
||||||
global $CC_DBC;
|
$con = Propel::getConnection();
|
||||||
|
|
||||||
$music_dir_id = $this->getId();
|
$music_dir_id = $this->getId();
|
||||||
|
|
||||||
$sql = "SELECT DISTINCT s.instance_id from cc_music_dirs as md LEFT JOIN cc_files as f on f.directory = md.id
|
$sql = "SELECT DISTINCT s.instance_id from cc_music_dirs as md "
|
||||||
RIGHT JOIN cc_schedule as s on s.file_id = f.id WHERE md.id = $music_dir_id";
|
." LEFT JOIN cc_files as f on f.directory = md.id"
|
||||||
|
." RIGHT JOIN cc_schedule as s on s.file_id = f.id WHERE md.id = $music_dir_id";
|
||||||
|
|
||||||
$show_instances = $CC_DBC->GetAll($sql);
|
$show_instances = $con->query($sql)->fetchAll();
|
||||||
|
|
||||||
// get all the files on this dir
|
// get all the files on this dir
|
||||||
$sql = "SELECT f.id FROM cc_music_dirs as md LEFT JOIN cc_files as f on f.directory = md.id WHERE md.id = $music_dir_id";
|
$sql = "SELECT f.id FROM cc_music_dirs as md "
|
||||||
$files = $CC_DBC->GetAll($sql);
|
." LEFT JOIN cc_files as f on f.directory = md.id WHERE md.id = $music_dir_id";
|
||||||
|
$files = $con->query($sql)->fetchAll();
|
||||||
|
|
||||||
// set file_exist flag to false
|
// set file_exist flag to false
|
||||||
foreach( $files as $file_row ){
|
foreach ($files as $file_row) {
|
||||||
$temp_file = Application_Model_StoredFile::Recall($file_row['id']);
|
$temp_file = Application_Model_StoredFile::Recall($file_row['id']);
|
||||||
if($temp_file != null){
|
if($temp_file != null){
|
||||||
$temp_file->setFileExistsFlag(false);
|
$temp_file->setFileExistsFlag(false);
|
||||||
|
@ -92,9 +95,9 @@ class Application_Model_MusicDir {
|
||||||
}
|
}
|
||||||
|
|
||||||
// set RemovedFlag to true
|
// set RemovedFlag to true
|
||||||
if($userAddedWatchedDir){
|
if ($userAddedWatchedDir) {
|
||||||
self::setWatchedFlag(false);
|
self::setWatchedFlag(false);
|
||||||
}else{
|
} else {
|
||||||
self::setExistsFlag(false);
|
self::setExistsFlag(false);
|
||||||
}
|
}
|
||||||
//$res = $this->_dir->delete();
|
//$res = $this->_dir->delete();
|
||||||
|
|
|
@ -541,7 +541,7 @@ class Application_Model_Playlist {
|
||||||
->filterByDbPlaylistId($this->id)
|
->filterByDbPlaylistId($this->id)
|
||||||
->filterByDbPosition($this->getSize()-1)
|
->filterByDbPosition($this->getSize()-1)
|
||||||
->findOne($this->con);
|
->findOne($this->con);
|
||||||
|
|
||||||
$this->changeFadeInfo($row->getDbId(), null, $fadeout);
|
$this->changeFadeInfo($row->getDbId(), null, $fadeout);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -769,10 +769,12 @@ class Application_Model_Playlist {
|
||||||
return $res;
|
return $res;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function getPlaylistCount(){
|
public static function getPlaylistCount()
|
||||||
global $CC_CONFIG, $CC_DBC;
|
{
|
||||||
|
global $CC_CONFIG;
|
||||||
|
$con = Propel::getConnection();
|
||||||
$sql = 'SELECT count(*) as cnt FROM '.$CC_CONFIG["playListTable"];
|
$sql = 'SELECT count(*) as cnt FROM '.$CC_CONFIG["playListTable"];
|
||||||
return $CC_DBC->GetOne($sql);
|
return $con->query($sql)->fetchColumn(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -4,7 +4,8 @@ class Application_Model_Preference
|
||||||
{
|
{
|
||||||
|
|
||||||
public static function SetValue($key, $value, $isUserValue = false){
|
public static function SetValue($key, $value, $isUserValue = false){
|
||||||
global $CC_CONFIG, $CC_DBC;
|
global $CC_CONFIG;
|
||||||
|
$con = Propel::getConnection();
|
||||||
|
|
||||||
//called from a daemon process
|
//called from a daemon process
|
||||||
if(!class_exists("Zend_Auth", false) || !Zend_Auth::getInstance()->hasIdentity()) {
|
if(!class_exists("Zend_Auth", false) || !Zend_Auth::getInstance()->hasIdentity()) {
|
||||||
|
@ -21,13 +22,13 @@ class Application_Model_Preference
|
||||||
//Check if key already exists
|
//Check if key already exists
|
||||||
$sql = "SELECT COUNT(*) FROM cc_pref"
|
$sql = "SELECT COUNT(*) FROM cc_pref"
|
||||||
." WHERE keystr = '$key'";
|
." WHERE keystr = '$key'";
|
||||||
|
|
||||||
//For user specific preference, check if id matches as well
|
//For user specific preference, check if id matches as well
|
||||||
if($isUserValue) {
|
if($isUserValue) {
|
||||||
$sql .= " AND subjid = '$id'";
|
$sql .= " AND subjid = '$id'";
|
||||||
}
|
}
|
||||||
|
|
||||||
$result = $CC_DBC->GetOne($sql);
|
$result = $con->query($sql)->fetchColumn(0);
|
||||||
|
|
||||||
if($result == 1) {
|
if($result == 1) {
|
||||||
// result found
|
// result found
|
||||||
|
@ -38,8 +39,8 @@ class Application_Model_Preference
|
||||||
." WHERE keystr = '$key'";
|
." WHERE keystr = '$key'";
|
||||||
} else {
|
} else {
|
||||||
// user pref
|
// user pref
|
||||||
$sql = "UPDATE cc_pref"
|
$sql = "UPDATE cc_pref"
|
||||||
. " SET valstr = '$value'"
|
. " SET valstr = '$value'"
|
||||||
. " WHERE keystr = '$key' AND subjid = $id";
|
. " WHERE keystr = '$key' AND subjid = $id";
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -54,39 +55,39 @@ class Application_Model_Preference
|
||||||
." VALUES ($id, '$key', '$value')";
|
." VALUES ($id, '$key', '$value')";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $CC_DBC->query($sql);
|
return $con->exec($sql);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function GetValue($key, $isUserValue = false){
|
public static function GetValue($key, $isUserValue = false){
|
||||||
global $CC_CONFIG, $CC_DBC;
|
global $CC_CONFIG;
|
||||||
|
$con = Propel::getConnection();
|
||||||
|
|
||||||
//Check if key already exists
|
//Check if key already exists
|
||||||
$sql = "SELECT COUNT(*) FROM cc_pref"
|
$sql = "SELECT COUNT(*) FROM cc_pref"
|
||||||
." WHERE keystr = '$key'";
|
." WHERE keystr = '$key'";
|
||||||
//For user specific preference, check if id matches as well
|
//For user specific preference, check if id matches as well
|
||||||
if($isUserValue) {
|
if ($isUserValue) {
|
||||||
$auth = Zend_Auth::getInstance();
|
$auth = Zend_Auth::getInstance();
|
||||||
if($auth->hasIdentity()) {
|
if($auth->hasIdentity()) {
|
||||||
$id = $auth->getIdentity()->id;
|
$id = $auth->getIdentity()->id;
|
||||||
$sql .= " AND subjid = '$id'";
|
$sql .= " AND subjid = '$id'";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$result = $CC_DBC->GetOne($sql);
|
$result = $con->query($sql)->fetchColumn(0);
|
||||||
|
|
||||||
if ($result == 0)
|
if ($result == 0)
|
||||||
return "";
|
return "";
|
||||||
else {
|
else {
|
||||||
$sql = "SELECT valstr FROM cc_pref"
|
$sql = "SELECT valstr FROM cc_pref"
|
||||||
." WHERE keystr = '$key'";
|
." WHERE keystr = '$key'";
|
||||||
|
|
||||||
//For user specific preference, check if id matches as well
|
//For user specific preference, check if id matches as well
|
||||||
if($isUserValue && $auth->hasIdentity()) {
|
if($isUserValue && $auth->hasIdentity()) {
|
||||||
$sql .= " AND subjid = '$id'";
|
$sql .= " AND subjid = '$id'";
|
||||||
}
|
}
|
||||||
|
|
||||||
$result = $CC_DBC->GetOne($sql);
|
$result = $con->query($sql)->fetchColumn(0);
|
||||||
return $result;
|
return $result ? $result : "";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -109,36 +110,36 @@ class Application_Model_Preference
|
||||||
$view->headTitle()->exchangeArray(array()); //clear headTitle ArrayObject
|
$view->headTitle()->exchangeArray(array()); //clear headTitle ArrayObject
|
||||||
$view->headTitle(self::GetHeadTitle());
|
$view->headTitle(self::GetHeadTitle());
|
||||||
}
|
}
|
||||||
|
|
||||||
$eventType = "update_station_name";
|
$eventType = "update_station_name";
|
||||||
$md = array("station_name"=>$title);
|
$md = array("station_name"=>$title);
|
||||||
|
|
||||||
Application_Model_RabbitMq::SendMessageToPypo($eventType, $md);
|
Application_Model_RabbitMq::SendMessageToPypo($eventType, $md);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the furthest date that a never-ending show
|
* Set the furthest date that a never-ending show
|
||||||
* should be populated until.
|
* should be populated until.
|
||||||
*
|
*
|
||||||
* @param DateTime $dateTime
|
* @param DateTime $dateTime
|
||||||
* A row from cc_show_days table
|
* A row from cc_show_days table
|
||||||
*/
|
*/
|
||||||
public static function SetShowsPopulatedUntil($dateTime) {
|
public static function SetShowsPopulatedUntil($dateTime) {
|
||||||
self::SetValue("shows_populated_until", $dateTime->format("Y-m-d H:i:s"));
|
self::SetValue("shows_populated_until", $dateTime->format("Y-m-d H:i:s"));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the furthest date that a never-ending show
|
* Get the furthest date that a never-ending show
|
||||||
* should be populated until.
|
* should be populated until.
|
||||||
*
|
*
|
||||||
* Returns null if the value hasn't been set, otherwise returns
|
* Returns null if the value hasn't been set, otherwise returns
|
||||||
* a DateTime object representing the date.
|
* a DateTime object representing the date.
|
||||||
*
|
*
|
||||||
* @return DateTime (in UTC Timezone)
|
* @return DateTime (in UTC Timezone)
|
||||||
*/
|
*/
|
||||||
public static function GetShowsPopulatedUntil() {
|
public static function GetShowsPopulatedUntil() {
|
||||||
$date = self::GetValue("shows_populated_until");
|
$date = self::GetValue("shows_populated_until");
|
||||||
|
|
||||||
if ($date == ""){
|
if ($date == ""){
|
||||||
return null;
|
return null;
|
||||||
} else {
|
} else {
|
||||||
|
@ -163,15 +164,15 @@ class Application_Model_Preference
|
||||||
$fade = str_pad($fade, 9, "0", STR_PAD_LEFT);
|
$fade = str_pad($fade, 9, "0", STR_PAD_LEFT);
|
||||||
return $fade;
|
return $fade;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function SetDefaultTransitionFade($fade) {
|
public static function SetDefaultTransitionFade($fade) {
|
||||||
self::SetValue("default_transition_fade", $fade);
|
self::SetValue("default_transition_fade", $fade);
|
||||||
|
|
||||||
$eventType = "update_transition_fade";
|
$eventType = "update_transition_fade";
|
||||||
$md = array("transition_fade"=>$fade);
|
$md = array("transition_fade"=>$fade);
|
||||||
Application_Model_RabbitMq::SendMessageToPypo($eventType, $md);
|
Application_Model_RabbitMq::SendMessageToPypo($eventType, $md);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function GetDefaultTransitionFade() {
|
public static function GetDefaultTransitionFade() {
|
||||||
$transition_fade = self::GetValue("default_transition_fade");
|
$transition_fade = self::GetValue("default_transition_fade");
|
||||||
if($transition_fade == ""){
|
if($transition_fade == ""){
|
||||||
|
@ -182,10 +183,10 @@ class Application_Model_Preference
|
||||||
|
|
||||||
public static function SetStreamLabelFormat($type){
|
public static function SetStreamLabelFormat($type){
|
||||||
self::SetValue("stream_label_format", $type);
|
self::SetValue("stream_label_format", $type);
|
||||||
|
|
||||||
$eventType = "update_stream_format";
|
$eventType = "update_stream_format";
|
||||||
$md = array("stream_format"=>$type);
|
$md = array("stream_format"=>$type);
|
||||||
|
|
||||||
Application_Model_RabbitMq::SendMessageToPypo($eventType, $md);
|
Application_Model_RabbitMq::SendMessageToPypo($eventType, $md);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -365,10 +366,11 @@ class Application_Model_Preference
|
||||||
return self::GetValue("uniqueId");
|
return self::GetValue("uniqueId");
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function GetCountryList(){
|
public static function GetCountryList()
|
||||||
global $CC_DBC;
|
{
|
||||||
|
$con = Propel::getConnection();
|
||||||
$sql = "SELECT * FROM cc_country";
|
$sql = "SELECT * FROM cc_country";
|
||||||
$res = $CC_DBC->GetAll($sql);
|
$res = $con->query($sql)->fetchAll();
|
||||||
$out = array();
|
$out = array();
|
||||||
$out[""] = "Select Country";
|
$out[""] = "Select Country";
|
||||||
foreach($res as $r){
|
foreach($res as $r){
|
||||||
|
@ -401,7 +403,7 @@ class Application_Model_Preference
|
||||||
$outputArray['STATION_COUNTRY'] = self::GetStationCountry();
|
$outputArray['STATION_COUNTRY'] = self::GetStationCountry();
|
||||||
$outputArray['STATION_CITY'] = self::GetStationCity();
|
$outputArray['STATION_CITY'] = self::GetStationCity();
|
||||||
$outputArray['STATION_DESCRIPTION'] = self::GetStationDescription();
|
$outputArray['STATION_DESCRIPTION'] = self::GetStationDescription();
|
||||||
|
|
||||||
|
|
||||||
// get web server info
|
// get web server info
|
||||||
if(isset($systemInfoArray["AIRTIME_VERSION_URL"])){
|
if(isset($systemInfoArray["AIRTIME_VERSION_URL"])){
|
||||||
|
@ -438,7 +440,7 @@ class Application_Model_Preference
|
||||||
foreach($s_info as $k => $v){
|
foreach($s_info as $k => $v){
|
||||||
$outputString .= "\t".strtoupper($k)." : ".$v."\n";
|
$outputString .= "\t".strtoupper($k)." : ".$v."\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
$outputString .= $key.' : '.$out."\n";
|
$outputString .= $key.' : '.$out."\n";
|
||||||
}
|
}
|
||||||
|
@ -452,7 +454,7 @@ class Application_Model_Preference
|
||||||
return $outputString;
|
return $outputString;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function GetInstallMethod(){
|
public static function GetInstallMethod(){
|
||||||
$easy_install = file_exists('/usr/bin/airtime-easy-setup');
|
$easy_install = file_exists('/usr/bin/airtime-easy-setup');
|
||||||
$debian_install = file_exists('/var/lib/dpkg/info/airtime.config');
|
$debian_install = file_exists('/var/lib/dpkg/info/airtime.config');
|
||||||
|
@ -559,7 +561,7 @@ class Application_Model_Preference
|
||||||
return self::GetValue("system_version");
|
return self::GetValue("system_version");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function GetLatestVersion(){
|
public static function GetLatestVersion(){
|
||||||
$latest = self::GetValue("latest_version");
|
$latest = self::GetValue("latest_version");
|
||||||
if($latest == null || strlen($latest) == 0) {
|
if($latest == null || strlen($latest) == 0) {
|
||||||
|
@ -568,14 +570,14 @@ class Application_Model_Preference
|
||||||
return $latest;
|
return $latest;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function SetLatestVersion($version){
|
public static function SetLatestVersion($version){
|
||||||
$pattern = "/^[0-9]+\.[0-9]+\.[0-9]+/";
|
$pattern = "/^[0-9]+\.[0-9]+\.[0-9]+/";
|
||||||
if(preg_match($pattern, $version)) {
|
if(preg_match($pattern, $version)) {
|
||||||
self::SetValue("latest_version", $version);
|
self::SetValue("latest_version", $version);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function GetLatestLink(){
|
public static function GetLatestLink(){
|
||||||
$link = self::GetValue("latest_link");
|
$link = self::GetValue("latest_link");
|
||||||
if($link == null || strlen($link) == 0) {
|
if($link == null || strlen($link) == 0) {
|
||||||
|
@ -584,7 +586,7 @@ class Application_Model_Preference
|
||||||
return $link;
|
return $link;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function SetLatestLink($link){
|
public static function SetLatestLink($link){
|
||||||
$pattern = "#^(http|https|ftp)://" .
|
$pattern = "#^(http|https|ftp)://" .
|
||||||
"([a-zA-Z0-9]+\.)*[a-zA-Z0-9]+" .
|
"([a-zA-Z0-9]+\.)*[a-zA-Z0-9]+" .
|
||||||
|
@ -609,7 +611,7 @@ class Application_Model_Preference
|
||||||
public static function GetSoundCloudDownloadbleOption() {
|
public static function GetSoundCloudDownloadbleOption() {
|
||||||
return self::GetValue("soundcloud_downloadable");
|
return self::GetValue("soundcloud_downloadable");
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function SetWeekStartDay($day) {
|
public static function SetWeekStartDay($day) {
|
||||||
self::SetValue("week_start_day", $day);
|
self::SetValue("week_start_day", $day);
|
||||||
}
|
}
|
||||||
|
@ -622,7 +624,7 @@ class Application_Model_Preference
|
||||||
return $val;
|
return $val;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Stores the last timestamp of user updating stream setting
|
* Stores the last timestamp of user updating stream setting
|
||||||
*/
|
*/
|
||||||
|
@ -630,7 +632,7 @@ class Application_Model_Preference
|
||||||
$now = time();
|
$now = time();
|
||||||
self::SetValue("stream_update_timestamp", $now);
|
self::SetValue("stream_update_timestamp", $now);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the last timestamp of user updating stream setting
|
* Gets the last timestamp of user updating stream setting
|
||||||
*/
|
*/
|
||||||
|
@ -641,22 +643,22 @@ class Application_Model_Preference
|
||||||
}
|
}
|
||||||
return $update_time;
|
return $update_time;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function GetClientId() {
|
public static function GetClientId() {
|
||||||
return self::GetValue("client_id");
|
return self::GetValue("client_id");
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function SetClientId($id) {
|
public static function SetClientId($id) {
|
||||||
if (is_numeric($id)) {
|
if (is_numeric($id)) {
|
||||||
self::SetValue("client_id", $id);
|
self::SetValue("client_id", $id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* User specific preferences start */
|
/* User specific preferences start */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the time scale preference (agendaDay/agendaWeek/month) in Calendar.
|
* Sets the time scale preference (agendaDay/agendaWeek/month) in Calendar.
|
||||||
*
|
*
|
||||||
* @param $timeScale new time scale
|
* @param $timeScale new time scale
|
||||||
*/
|
*/
|
||||||
public static function SetCalendarTimeScale($timeScale) {
|
public static function SetCalendarTimeScale($timeScale) {
|
||||||
|
@ -674,16 +676,16 @@ class Application_Model_Preference
|
||||||
}
|
}
|
||||||
return $val;
|
return $val;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the number of entries to show preference in library under Playlist Builder.
|
* Sets the number of entries to show preference in library under Playlist Builder.
|
||||||
*
|
*
|
||||||
* @param $numEntries new number of entries to show
|
* @param $numEntries new number of entries to show
|
||||||
*/
|
*/
|
||||||
public static function SetLibraryNumEntries($numEntries) {
|
public static function SetLibraryNumEntries($numEntries) {
|
||||||
self::SetValue("library_num_entries", $numEntries, true /* user specific */);
|
self::SetValue("library_num_entries", $numEntries, true /* user specific */);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieves the number of entries to show preference in library under Playlist Builder.
|
* Retrieves the number of entries to show preference in library under Playlist Builder.
|
||||||
* Defaults to 10 if no entry exists
|
* Defaults to 10 if no entry exists
|
||||||
|
@ -695,10 +697,10 @@ class Application_Model_Preference
|
||||||
}
|
}
|
||||||
return $val;
|
return $val;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the time interval preference in Calendar.
|
* Sets the time interval preference in Calendar.
|
||||||
*
|
*
|
||||||
* @param $timeInterval new time interval
|
* @param $timeInterval new time interval
|
||||||
*/
|
*/
|
||||||
public static function SetCalendarTimeInterval($timeInterval) {
|
public static function SetCalendarTimeInterval($timeInterval) {
|
||||||
|
@ -716,11 +718,11 @@ class Application_Model_Preference
|
||||||
}
|
}
|
||||||
return $val;
|
return $val;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function SetDiskQuota($value){
|
public static function SetDiskQuota($value){
|
||||||
self::SetValue("disk_quota", $value, false);
|
self::SetValue("disk_quota", $value, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function GetDiskQuota(){
|
public static function GetDiskQuota(){
|
||||||
$val = self::GetValue("disk_quota");
|
$val = self::GetValue("disk_quota");
|
||||||
if(strlen($val) == 0) {
|
if(strlen($val) == 0) {
|
||||||
|
@ -728,27 +730,27 @@ class Application_Model_Preference
|
||||||
}
|
}
|
||||||
return $val;
|
return $val;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function SetLiveSteamMasterUsername($value){
|
public static function SetLiveSteamMasterUsername($value){
|
||||||
self::SetValue("live_stream_master_username", $value, false);
|
self::SetValue("live_stream_master_username", $value, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function GetLiveSteamMasterUsername(){
|
public static function GetLiveSteamMasterUsername(){
|
||||||
return self::GetValue("live_stream_master_username");
|
return self::GetValue("live_stream_master_username");
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function SetLiveSteamMasterPassword($value){
|
public static function SetLiveSteamMasterPassword($value){
|
||||||
self::SetValue("live_stream_master_password", $value, false);
|
self::SetValue("live_stream_master_password", $value, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function GetLiveSteamMasterPassword(){
|
public static function GetLiveSteamMasterPassword(){
|
||||||
return self::GetValue("live_stream_master_password");
|
return self::GetValue("live_stream_master_password");
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function SetSourceStatus($sourcename, $status){
|
public static function SetSourceStatus($sourcename, $status){
|
||||||
self::SetValue($sourcename, $status, false);
|
self::SetValue($sourcename, $status, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function GetSourceStatus($sourcename){
|
public static function GetSourceStatus($sourcename){
|
||||||
$value = self::GetValue($sourcename);
|
$value = self::GetValue($sourcename);
|
||||||
if($value == null || $value == "false"){
|
if($value == null || $value == "false"){
|
||||||
|
@ -757,11 +759,11 @@ class Application_Model_Preference
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function SetSourceSwitchStatus($sourcename, $status){
|
public static function SetSourceSwitchStatus($sourcename, $status){
|
||||||
self::SetValue($sourcename."_switch", $status, false);
|
self::SetValue($sourcename."_switch", $status, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function GetSourceSwitchStatus($sourcename){
|
public static function GetSourceSwitchStatus($sourcename){
|
||||||
$value = self::GetValue($sourcename."_switch");
|
$value = self::GetValue($sourcename."_switch");
|
||||||
if($value == null || $value == "off"){
|
if($value == null || $value == "off"){
|
||||||
|
@ -770,19 +772,19 @@ class Application_Model_Preference
|
||||||
return "on";
|
return "on";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function SetMasterDJSourceConnectionURL($value){
|
public static function SetMasterDJSourceConnectionURL($value){
|
||||||
self::SetValue("master_dj_source_connection_url", $value, false);
|
self::SetValue("master_dj_source_connection_url", $value, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function GetMasterDJSourceConnectionURL(){
|
public static function GetMasterDJSourceConnectionURL(){
|
||||||
return self::GetValue("master_dj_source_connection_url");
|
return self::GetValue("master_dj_source_connection_url");
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function SetLiveDJSourceConnectionURL($value){
|
public static function SetLiveDJSourceConnectionURL($value){
|
||||||
self::SetValue("live_dj_source_connection_url", $value, false);
|
self::SetValue("live_dj_source_connection_url", $value, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function GetLiveDJSourceConnectionURL(){
|
public static function GetLiveDJSourceConnectionURL(){
|
||||||
return self::GetValue("live_dj_source_connection_url");
|
return self::GetValue("live_dj_source_connection_url");
|
||||||
}
|
}
|
||||||
|
@ -795,7 +797,7 @@ class Application_Model_Preference
|
||||||
return self::GetValue("system_email");
|
return self::GetValue("system_email");
|
||||||
}
|
}
|
||||||
/* User specific preferences end */
|
/* User specific preferences end */
|
||||||
|
|
||||||
public static function ShouldShowPopUp(){
|
public static function ShouldShowPopUp(){
|
||||||
$today = mktime(0, 0, 0, gmdate("m"), gmdate("d"), gmdate("Y"));
|
$today = mktime(0, 0, 0, gmdate("m"), gmdate("d"), gmdate("Y"));
|
||||||
$remindDate = Application_Model_Preference::GetRemindMeDate();
|
$remindDate = Application_Model_Preference::GetRemindMeDate();
|
||||||
|
|
|
@ -9,10 +9,11 @@ class Application_Model_Schedule {
|
||||||
*/
|
*/
|
||||||
public function IsFileScheduledInTheFuture($p_fileId)
|
public function IsFileScheduledInTheFuture($p_fileId)
|
||||||
{
|
{
|
||||||
global $CC_CONFIG, $CC_DBC;
|
global $CC_CONFIG;
|
||||||
|
$con = Propel::getConnection();
|
||||||
$sql = "SELECT COUNT(*) FROM ".$CC_CONFIG["scheduleTable"]
|
$sql = "SELECT COUNT(*) FROM ".$CC_CONFIG["scheduleTable"]
|
||||||
." WHERE file_id = {$p_fileId} AND starts > NOW()";
|
." WHERE file_id = {$p_fileId} AND starts > NOW()";
|
||||||
$count = $CC_DBC->GetOne($sql);
|
$count = $con->query($sql)->fetchColumn(0);
|
||||||
if (is_numeric($count) && ($count != '0')) {
|
if (is_numeric($count) && ($count != '0')) {
|
||||||
return TRUE;
|
return TRUE;
|
||||||
} else {
|
} else {
|
||||||
|
@ -37,13 +38,13 @@ class Application_Model_Schedule {
|
||||||
$date = new Application_Common_DateHelper;
|
$date = new Application_Common_DateHelper;
|
||||||
$timeNow = $date->getTimestamp();
|
$timeNow = $date->getTimestamp();
|
||||||
$utcTimeNow = $date->getUtcTimestamp();
|
$utcTimeNow = $date->getUtcTimestamp();
|
||||||
|
|
||||||
$shows = Application_Model_Show::getPrevCurrentNext($utcTimeNow);
|
$shows = Application_Model_Show::getPrevCurrentNext($utcTimeNow);
|
||||||
$previousShowID = count($shows['previousShow'])>0?$shows['previousShow'][0]['instance_id']:null;
|
$previousShowID = count($shows['previousShow'])>0?$shows['previousShow'][0]['instance_id']:null;
|
||||||
$currentShowID = count($shows['currentShow'])>0?$shows['currentShow'][0]['instance_id']:null;
|
$currentShowID = count($shows['currentShow'])>0?$shows['currentShow'][0]['instance_id']:null;
|
||||||
$nextShowID = count($shows['nextShow'])>0?$shows['nextShow'][0]['instance_id']:null;
|
$nextShowID = count($shows['nextShow'])>0?$shows['nextShow'][0]['instance_id']:null;
|
||||||
$results = Application_Model_Schedule::GetPrevCurrentNext($previousShowID, $currentShowID, $nextShowID, $utcTimeNow);
|
$results = Application_Model_Schedule::GetPrevCurrentNext($previousShowID, $currentShowID, $nextShowID, $utcTimeNow);
|
||||||
|
|
||||||
$range = array("env"=>APPLICATION_ENV,
|
$range = array("env"=>APPLICATION_ENV,
|
||||||
"schedulerTime"=>$timeNow,
|
"schedulerTime"=>$timeNow,
|
||||||
"previous"=>$results['previous'] !=null?$results['previous']:(count($shows['previousShow'])>0?$shows['previousShow'][0]:null),
|
"previous"=>$results['previous'] !=null?$results['previous']:(count($shows['previousShow'])>0?$shows['previousShow'][0]:null),
|
||||||
|
@ -53,10 +54,10 @@ class Application_Model_Schedule {
|
||||||
"nextShow"=>$shows['nextShow'],
|
"nextShow"=>$shows['nextShow'],
|
||||||
"timezone"=> date("T"),
|
"timezone"=> date("T"),
|
||||||
"timezoneOffset"=> date("Z"));
|
"timezoneOffset"=> date("Z"));
|
||||||
|
|
||||||
return $range;
|
return $range;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Queries the database for the set of schedules one hour before and after the given time.
|
* Queries the database for the set of schedules one hour before and after the given time.
|
||||||
* If a show starts and ends within that time that is considered the current show. Then the
|
* If a show starts and ends within that time that is considered the current show. Then the
|
||||||
|
@ -69,19 +70,20 @@ class Application_Model_Schedule {
|
||||||
{
|
{
|
||||||
if ($p_previousShowID == null && $p_currentShowID == null && $p_nextShowID == null)
|
if ($p_previousShowID == null && $p_currentShowID == null && $p_nextShowID == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
global $CC_CONFIG, $CC_DBC;
|
|
||||||
$sql = 'Select ft.artist_name,
|
global $CC_CONFIG;
|
||||||
ft.track_title,
|
$con = Propel::getConnection();
|
||||||
st.starts as starts,
|
$sql = 'Select ft.artist_name, ft.track_title, st.starts as starts, st.ends as ends, st.media_item_played as media_item_played, si.ends as show_ends
|
||||||
st.ends as ends,
|
FROM cc_schedule st LEFT JOIN cc_files ft ON st.file_id = ft.id LEFT JOIN cc_show_instances si on st.instance_id = si.id
|
||||||
st.media_item_played as media_item_played,
|
|
||||||
si.ends as show_ends
|
|
||||||
FROM cc_schedule st
|
|
||||||
LEFT JOIN cc_files ft ON st.file_id = ft.id
|
|
||||||
LEFT JOIN cc_show_instances si on st.instance_id = si.id
|
|
||||||
WHERE ';
|
WHERE ';
|
||||||
|
|
||||||
|
/* Alternate SQL...merge conflict and I'm not sure which on is right.... -MK
|
||||||
|
$sql = 'Select ft.artist_name, ft.track_title, st.starts as starts, st.ends as ends, st.media_item_played as media_item_played, si.ends as show_ends
|
||||||
|
FROM cc_schedule st LEFT JOIN cc_files ft ON st.file_id = ft.id
|
||||||
|
WHERE ';
|
||||||
|
*/
|
||||||
|
|
||||||
if (isset($p_previousShowID)){
|
if (isset($p_previousShowID)){
|
||||||
if (isset($p_nextShowID) || isset($p_currentShowID))
|
if (isset($p_nextShowID) || isset($p_currentShowID))
|
||||||
$sql .= '(';
|
$sql .= '(';
|
||||||
|
@ -102,17 +104,17 @@ class Application_Model_Schedule {
|
||||||
$sql .= ')';
|
$sql .= ')';
|
||||||
} else if($p_previousShowID != null && $p_currentShowID != null)
|
} else if($p_previousShowID != null && $p_currentShowID != null)
|
||||||
$sql .= ')';
|
$sql .= ')';
|
||||||
|
|
||||||
$sql .= ' AND st.playout_status > 0 ORDER BY st.starts';
|
$sql .= ' AND st.playout_status > 0 ORDER BY st.starts';
|
||||||
|
|
||||||
$rows = $CC_DBC->GetAll($sql);
|
|
||||||
|
$rows = $con->query($sql)->fetchAll();
|
||||||
$numberOfRows = count($rows);
|
$numberOfRows = count($rows);
|
||||||
|
|
||||||
$results['previous'] = null;
|
$results['previous'] = null;
|
||||||
$results['current'] = null;
|
$results['current'] = null;
|
||||||
$results['next'] = null;
|
$results['next'] = null;
|
||||||
|
|
||||||
$timeNowAsMillis = strtotime($p_timeNow);
|
$timeNowAsMillis = strtotime($p_timeNow);
|
||||||
for( $i = 0; $i < $numberOfRows; ++$i ){
|
for( $i = 0; $i < $numberOfRows; ++$i ){
|
||||||
// if the show is overbooked, then update the track end time to the end of the show time.
|
// if the show is overbooked, then update the track end time to the end of the show time.
|
||||||
|
@ -130,7 +132,6 @@ class Application_Model_Schedule {
|
||||||
"ends"=> (($rows[$i]["ends"] > $rows[$i]["show_ends"]) ? $rows[$i]["show_ends"]: $rows[$i]["ends"]),
|
"ends"=> (($rows[$i]["ends"] > $rows[$i]["show_ends"]) ? $rows[$i]["show_ends"]: $rows[$i]["ends"]),
|
||||||
"media_item_played"=>$rows[$i]["media_item_played"],
|
"media_item_played"=>$rows[$i]["media_item_played"],
|
||||||
"record"=>0);
|
"record"=>0);
|
||||||
|
|
||||||
if ( isset($rows[$i+1])){
|
if ( isset($rows[$i+1])){
|
||||||
$results['next'] = array("name"=>$rows[$i+1]["artist_name"]." - ".$rows[$i+1]["track_title"],
|
$results['next'] = array("name"=>$rows[$i+1]["artist_name"]." - ".$rows[$i+1]["track_title"],
|
||||||
"starts"=>$rows[$i+1]["starts"],
|
"starts"=>$rows[$i+1]["starts"],
|
||||||
|
@ -157,10 +158,10 @@ class Application_Model_Schedule {
|
||||||
}
|
}
|
||||||
return $results;
|
return $results;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function GetLastScheduleItem($p_timeNow){
|
|
||||||
global $CC_CONFIG, $CC_DBC;
|
|
||||||
|
|
||||||
|
public static function GetLastScheduleItem($p_timeNow){
|
||||||
|
global $CC_CONFIG;
|
||||||
|
$con = Propel::getConnection();
|
||||||
$sql = "SELECT"
|
$sql = "SELECT"
|
||||||
." ft.artist_name, ft.track_title,"
|
." ft.artist_name, ft.track_title,"
|
||||||
." st.starts as starts, st.ends as ends"
|
." st.starts as starts, st.ends as ends"
|
||||||
|
@ -175,14 +176,14 @@ class Application_Model_Schedule {
|
||||||
." ORDER BY st.ends DESC"
|
." ORDER BY st.ends DESC"
|
||||||
." LIMIT 1";
|
." LIMIT 1";
|
||||||
|
|
||||||
$row = $CC_DBC->GetAll($sql);
|
$row = $con->query($sql)->fetchAll();
|
||||||
return $row;
|
return $row;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static function GetCurrentScheduleItem($p_timeNow, $p_instanceId){
|
public static function GetCurrentScheduleItem($p_timeNow, $p_instanceId){
|
||||||
global $CC_CONFIG, $CC_DBC;
|
global $CC_CONFIG;
|
||||||
|
$con = Propel::getConnection();
|
||||||
/* Note that usually there will be one result returned. In some
|
/* Note that usually there will be one result returned. In some
|
||||||
* rare cases two songs are returned. This happens when a track
|
* rare cases two songs are returned. This happens when a track
|
||||||
* that was overbooked from a previous show appears as if it
|
* that was overbooked from a previous show appears as if it
|
||||||
|
@ -200,13 +201,13 @@ class Application_Model_Schedule {
|
||||||
." ORDER BY st.starts DESC"
|
." ORDER BY st.starts DESC"
|
||||||
." LIMIT 1";
|
." LIMIT 1";
|
||||||
|
|
||||||
$row = $CC_DBC->GetAll($sql);
|
$row = $con->query($sql)->fetchAll();
|
||||||
return $row;
|
return $row;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function GetNextScheduleItem($p_timeNow){
|
public static function GetNextScheduleItem($p_timeNow){
|
||||||
global $CC_CONFIG, $CC_DBC;
|
global $CC_CONFIG;
|
||||||
|
$con = Propel::getConnection();
|
||||||
$sql = "SELECT"
|
$sql = "SELECT"
|
||||||
." ft.artist_name, ft.track_title,"
|
." ft.artist_name, ft.track_title,"
|
||||||
." st.starts as starts, st.ends as ends"
|
." st.starts as starts, st.ends as ends"
|
||||||
|
@ -221,7 +222,7 @@ class Application_Model_Schedule {
|
||||||
." ORDER BY st.starts"
|
." ORDER BY st.starts"
|
||||||
." LIMIT 1";
|
." LIMIT 1";
|
||||||
|
|
||||||
$row = $CC_DBC->GetAll($sql);
|
$row = $con->query($sql)->fetchAll();
|
||||||
return $row;
|
return $row;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -236,8 +237,8 @@ class Application_Model_Schedule {
|
||||||
*/
|
*/
|
||||||
public static function GetScheduleDetailItems($p_start, $p_end, $p_shows)
|
public static function GetScheduleDetailItems($p_start, $p_end, $p_shows)
|
||||||
{
|
{
|
||||||
global $CC_CONFIG, $CC_DBC;
|
global $CC_CONFIG;
|
||||||
|
$con = Propel::getConnection();
|
||||||
$sql = "SELECT DISTINCT
|
$sql = "SELECT DISTINCT
|
||||||
|
|
||||||
showt.name AS show_name, showt.color AS show_color,
|
showt.name AS show_name, showt.color AS show_color,
|
||||||
|
@ -265,32 +266,35 @@ class Application_Model_Schedule {
|
||||||
((si.starts >= '{$p_start}' AND si.starts < '{$p_end}')
|
((si.starts >= '{$p_start}' AND si.starts < '{$p_end}')
|
||||||
OR (si.ends > '{$p_start}' AND si.ends <= '{$p_end}')
|
OR (si.ends > '{$p_start}' AND si.ends <= '{$p_end}')
|
||||||
OR (si.starts <= '{$p_start}' AND si.ends >= '{$p_end}'))";
|
OR (si.starts <= '{$p_start}' AND si.ends >= '{$p_end}'))";
|
||||||
|
|
||||||
|
|
||||||
if (count($p_shows) > 0) {
|
if (count($p_shows) > 0) {
|
||||||
$sql .= " AND show_id IN (".implode(",", $p_shows).")";
|
$sql .= " AND show_id IN (".implode(",", $p_shows).")";
|
||||||
}
|
}
|
||||||
|
|
||||||
$sql .= " ORDER BY si.starts, sched.starts;";
|
$sql .= " ORDER BY si.starts, sched.starts;";
|
||||||
|
|
||||||
$rows = $CC_DBC->GetAll($sql);
|
$rows = $con->query($sql)->fetchAll();
|
||||||
return $rows;
|
return $rows;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function UpdateMediaPlayedStatus($p_id)
|
public static function UpdateMediaPlayedStatus($p_id)
|
||||||
{
|
{
|
||||||
global $CC_CONFIG, $CC_DBC;
|
global $CC_CONFIG;
|
||||||
|
$con = Propel::getConnection();
|
||||||
$sql = "UPDATE ".$CC_CONFIG['scheduleTable']
|
$sql = "UPDATE ".$CC_CONFIG['scheduleTable']
|
||||||
." SET media_item_played=TRUE"
|
." SET media_item_played=TRUE"
|
||||||
." WHERE id=$p_id";
|
." WHERE id=$p_id";
|
||||||
$retVal = $CC_DBC->query($sql);
|
$retVal = $con->exec($sql);
|
||||||
return $retVal;
|
return $retVal;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function getSchduledPlaylistCount(){
|
public static function getSchduledPlaylistCount()
|
||||||
global $CC_CONFIG, $CC_DBC;
|
{
|
||||||
|
global $CC_CONFIG;
|
||||||
|
$con = Propel::getConnection();
|
||||||
$sql = "SELECT count(*) as cnt FROM ".$CC_CONFIG['scheduleTable'];
|
$sql = "SELECT count(*) as cnt FROM ".$CC_CONFIG['scheduleTable'];
|
||||||
return $CC_DBC->GetOne($sql);
|
return $con->query($sql)->fetchColumn(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -398,7 +402,7 @@ class Application_Model_Schedule {
|
||||||
* $p_startTime and $p_endTime specify the range. Schedule items returned
|
* $p_startTime and $p_endTime specify the range. Schedule items returned
|
||||||
* do not have to be entirely within this range. It is enough that the end
|
* do not have to be entirely within this range. It is enough that the end
|
||||||
* or beginning of the scheduled item is in the range.
|
* or beginning of the scheduled item is in the range.
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
* @param string $p_startTime
|
* @param string $p_startTime
|
||||||
* In the format YYYY-MM-DD HH:MM:SS.nnnnnn
|
* In the format YYYY-MM-DD HH:MM:SS.nnnnnn
|
||||||
|
@ -409,8 +413,9 @@ class Application_Model_Schedule {
|
||||||
* arrays representing each row.
|
* arrays representing each row.
|
||||||
*/
|
*/
|
||||||
public static function GetItems($p_startTime, $p_endTime) {
|
public static function GetItems($p_startTime, $p_endTime) {
|
||||||
global $CC_CONFIG, $CC_DBC;
|
global $CC_CONFIG;
|
||||||
|
$con = Propel::getConnection();
|
||||||
|
|
||||||
$baseQuery = "SELECT st.file_id AS file_id,"
|
$baseQuery = "SELECT st.file_id AS file_id,"
|
||||||
." st.id as id,"
|
." st.id as id,"
|
||||||
." st.instance_id as instance_id,"
|
." st.instance_id as instance_id,"
|
||||||
|
@ -425,48 +430,42 @@ class Application_Model_Schedule {
|
||||||
." FROM $CC_CONFIG[scheduleTable] as st"
|
." FROM $CC_CONFIG[scheduleTable] as st"
|
||||||
." LEFT JOIN $CC_CONFIG[showInstances] as si"
|
." LEFT JOIN $CC_CONFIG[showInstances] as si"
|
||||||
." ON st.instance_id = si.id";
|
." ON st.instance_id = si.id";
|
||||||
|
|
||||||
|
|
||||||
$predicates = " WHERE st.ends > '$p_startTime'"
|
$predicates = " WHERE st.ends > '$p_startTime'"
|
||||||
." AND st.starts < '$p_endTime'"
|
." AND st.starts < '$p_endTime'"
|
||||||
." AND st.playout_status > 0"
|
." AND st.playout_status > 0"
|
||||||
." AND si.ends > '$p_startTime'"
|
." AND si.ends > '$p_startTime'"
|
||||||
." ORDER BY st.starts";
|
." ORDER BY st.starts";
|
||||||
|
|
||||||
$sql = $baseQuery.$predicates;
|
$sql = $baseQuery.$predicates;
|
||||||
|
|
||||||
$rows = $CC_DBC->GetAll($sql);
|
$rows = $con->query($sql)->fetchAll();
|
||||||
if (PEAR::isError($rows)) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (count($rows) < 3){
|
if (count($rows) < 3){
|
||||||
Logging::debug("Get Schedule: Less than 3 results returned. Do another query in an attempt to get 3.");
|
Logging::debug("Get Schedule: Less than 3 results returned. Doing another query since we need a minimum of 3 results.");
|
||||||
|
|
||||||
$dt = new DateTime("@".time());
|
$dt = new DateTime("@".time());
|
||||||
$dt->add(new DateInterval("PT24H"));
|
$dt->add(new DateInterval("PT24H"));
|
||||||
$range_end = $dt->format("Y-m-d H:i:s");
|
$range_end = $dt->format("Y-m-d H:i:s");
|
||||||
|
|
||||||
$predicates = " WHERE st.ends > '$p_startTime'"
|
$predicates = " WHERE st.ends > '$p_startTime'"
|
||||||
." AND st.starts < '$range_end'"
|
." AND st.starts < '$range_end'"
|
||||||
." AND st.playout_status > 0"
|
." AND st.playout_status > 0"
|
||||||
." AND si.ends > '$p_startTime'"
|
." AND si.ends > '$p_startTime'"
|
||||||
." ORDER BY st.starts"
|
." ORDER BY st.starts"
|
||||||
." LIMIT 3";
|
." LIMIT 3";
|
||||||
|
|
||||||
$sql = $baseQuery.$predicates;
|
$sql = $baseQuery.$predicates;
|
||||||
$rows = $CC_DBC->GetAll($sql);
|
$rows = $con->query($sql)->fetchAll();
|
||||||
if (PEAR::isError($rows)) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return $rows;
|
return $rows;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function GetScheduledPlaylists($p_fromDateTime = null, $p_toDateTime = null){
|
public static function GetScheduledPlaylists($p_fromDateTime = null, $p_toDateTime = null){
|
||||||
|
|
||||||
global $CC_CONFIG, $CC_DBC;
|
global $CC_CONFIG;
|
||||||
|
|
||||||
/* if $p_fromDateTime and $p_toDateTime function parameters are null, then set range
|
/* if $p_fromDateTime and $p_toDateTime function parameters are null, then set range
|
||||||
* from "now" to "now + 24 hours". */
|
* from "now" to "now + 24 hours". */
|
||||||
|
@ -478,16 +477,16 @@ class Application_Model_Schedule {
|
||||||
}
|
}
|
||||||
if (is_null($p_fromDateTime)) {
|
if (is_null($p_fromDateTime)) {
|
||||||
$t2 = new DateTime("@".time());
|
$t2 = new DateTime("@".time());
|
||||||
|
|
||||||
$cache_ahead_hours = $CC_CONFIG["cache_ahead_hours"];
|
$cache_ahead_hours = $CC_CONFIG["cache_ahead_hours"];
|
||||||
|
|
||||||
if (is_numeric($cache_ahead_hours)){
|
if (is_numeric($cache_ahead_hours)){
|
||||||
//make sure we are not dealing with a float
|
//make sure we are not dealing with a float
|
||||||
$cache_ahead_hours = intval($cache_ahead_hours);
|
$cache_ahead_hours = intval($cache_ahead_hours);
|
||||||
} else {
|
} else {
|
||||||
$cache_ahead_hours = 1;
|
$cache_ahead_hours = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
$t2->add(new DateInterval("PT".$cache_ahead_hours."H"));
|
$t2->add(new DateInterval("PT".$cache_ahead_hours."H"));
|
||||||
$range_end = $t2->format("Y-m-d H:i:s");
|
$range_end = $t2->format("Y-m-d H:i:s");
|
||||||
} else {
|
} else {
|
||||||
|
@ -502,7 +501,7 @@ class Application_Model_Schedule {
|
||||||
|
|
||||||
$data["status"] = array();
|
$data["status"] = array();
|
||||||
$data["media"] = array();
|
$data["media"] = array();
|
||||||
|
|
||||||
$kick_times = Application_Model_ShowInstance::GetEndTimeOfNextShowWithLiveDJ($range_start, $range_end);
|
$kick_times = Application_Model_ShowInstance::GetEndTimeOfNextShowWithLiveDJ($range_start, $range_end);
|
||||||
foreach($kick_times as $kick_time_info){
|
foreach($kick_times as $kick_time_info){
|
||||||
$kick_time = $kick_time_info['ends'];
|
$kick_time = $kick_time_info['ends'];
|
||||||
|
@ -513,13 +512,13 @@ class Application_Model_Schedule {
|
||||||
$switchOffDataTime = new DateTime($kick_time, $utcTimeZone);
|
$switchOffDataTime = new DateTime($kick_time, $utcTimeZone);
|
||||||
$switch_off_time = $switchOffDataTime->sub(new DateInterval('PT'.$transition_time.'S'));
|
$switch_off_time = $switchOffDataTime->sub(new DateInterval('PT'.$transition_time.'S'));
|
||||||
$switch_off_time = $switch_off_time->format("Y-m-d H:i:s");
|
$switch_off_time = $switch_off_time->format("Y-m-d H:i:s");
|
||||||
|
|
||||||
$kick_start = Application_Model_Schedule::AirtimeTimeToPypoTime($kick_time);
|
$kick_start = Application_Model_Schedule::AirtimeTimeToPypoTime($kick_time);
|
||||||
$data["media"][$kick_start]['start'] = $kick_start;
|
$data["media"][$kick_start]['start'] = $kick_start;
|
||||||
$data["media"][$kick_start]['end'] = $kick_start;
|
$data["media"][$kick_start]['end'] = $kick_start;
|
||||||
$data["media"][$kick_start]['event_type'] = "kick_out";
|
$data["media"][$kick_start]['event_type'] = "kick_out";
|
||||||
$data["media"][$kick_start]['type'] = "event";
|
$data["media"][$kick_start]['type'] = "event";
|
||||||
|
|
||||||
if($kick_time !== $switch_off_time){
|
if($kick_time !== $switch_off_time){
|
||||||
$data["media"][$switch_start]['start'] = Application_Model_Schedule::AirtimeTimeToPypoTime($switch_off_time);
|
$data["media"][$switch_start]['start'] = Application_Model_Schedule::AirtimeTimeToPypoTime($switch_off_time);
|
||||||
$data["media"][$switch_start]['end'] = Application_Model_Schedule::AirtimeTimeToPypoTime($switch_off_time);
|
$data["media"][$switch_start]['end'] = Application_Model_Schedule::AirtimeTimeToPypoTime($switch_off_time);
|
||||||
|
@ -547,7 +546,7 @@ class Application_Model_Schedule {
|
||||||
/* TODO: Not all tracks will have "show_end" */
|
/* TODO: Not all tracks will have "show_end" */
|
||||||
if ($trackEndDateTime->getTimestamp() > $showEndDateTime->getTimestamp()){
|
if ($trackEndDateTime->getTimestamp() > $showEndDateTime->getTimestamp()){
|
||||||
$di = $trackStartDateTime->diff($showEndDateTime);
|
$di = $trackStartDateTime->diff($showEndDateTime);
|
||||||
|
|
||||||
$item["cue_out"] = $di->format("%H:%i:%s").".000";
|
$item["cue_out"] = $di->format("%H:%i:%s").".000";
|
||||||
$item["end"] = $showEndDateTime->format("Y-m-d H:i:s");
|
$item["end"] = $showEndDateTime->format("Y-m-d H:i:s");
|
||||||
}
|
}
|
||||||
|
@ -576,8 +575,9 @@ class Application_Model_Schedule {
|
||||||
|
|
||||||
public static function deleteAll()
|
public static function deleteAll()
|
||||||
{
|
{
|
||||||
global $CC_CONFIG, $CC_DBC;
|
global $CC_CONFIG;
|
||||||
$CC_DBC->query("TRUNCATE TABLE ".$CC_CONFIG["scheduleTable"]);
|
$con = Propel::getConnection();
|
||||||
|
$con->exec("TRUNCATE TABLE ".$CC_CONFIG["scheduleTable"]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function deleteWithFileId($fileId){
|
public static function deleteWithFileId($fileId){
|
||||||
|
|
|
@ -113,36 +113,38 @@ class Application_Model_Show {
|
||||||
|
|
||||||
public function getHosts()
|
public function getHosts()
|
||||||
{
|
{
|
||||||
global $CC_DBC;
|
$con = Propel::getConnection();
|
||||||
|
|
||||||
$sql = "SELECT first_name, last_name
|
$sql = "SELECT first_name, last_name
|
||||||
FROM cc_show_hosts LEFT JOIN cc_subjs ON cc_show_hosts.subjs_id = cc_subjs.id
|
FROM cc_show_hosts LEFT JOIN cc_subjs ON cc_show_hosts.subjs_id = cc_subjs.id
|
||||||
WHERE show_id = {$this->_showId}";
|
WHERE show_id = {$this->_showId}";
|
||||||
|
|
||||||
$hosts = $CC_DBC->GetAll($sql);
|
$hosts = $con->query($sql)->fetchAll();
|
||||||
|
|
||||||
$res = array();
|
$res = array();
|
||||||
foreach($hosts as $host) {
|
foreach ($hosts as $host) {
|
||||||
$res[] = $host['first_name']." ".$host['last_name'];
|
$res[] = $host['first_name']." ".$host['last_name'];
|
||||||
}
|
}
|
||||||
|
|
||||||
return $res;
|
return $res;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getHostsIds()
|
public function getHostsIds()
|
||||||
{
|
{
|
||||||
global $CC_DBC;
|
$con = Propel::getConnection();
|
||||||
|
|
||||||
$sql = "SELECT subjs_id
|
$sql = "SELECT subjs_id
|
||||||
FROM cc_show_hosts
|
FROM cc_show_hosts
|
||||||
WHERE show_id = {$this->_showId}";
|
WHERE show_id = {$this->_showId}";
|
||||||
|
|
||||||
$hosts = $CC_DBC->GetAll($sql);
|
$hosts = $con->query($sql)->fetchAll();
|
||||||
|
|
||||||
return $hosts;
|
return $hosts;
|
||||||
}
|
}
|
||||||
|
|
||||||
//remove everything about this show.
|
/**
|
||||||
|
* remove everything about this show.
|
||||||
|
*/
|
||||||
public function delete()
|
public function delete()
|
||||||
{
|
{
|
||||||
//usually we hide the show-instance, but in this case we are deleting the show template
|
//usually we hide the show-instance, but in this case we are deleting the show template
|
||||||
|
@ -155,7 +157,7 @@ class Application_Model_Show {
|
||||||
|
|
||||||
public function resizeShow($deltaDay, $deltaMin)
|
public function resizeShow($deltaDay, $deltaMin)
|
||||||
{
|
{
|
||||||
global $CC_DBC;
|
$con = Propel::getConnection();
|
||||||
|
|
||||||
if ($deltaDay > 0) {
|
if ($deltaDay > 0) {
|
||||||
return "Shows can have a max length of 24 hours.";
|
return "Shows can have a max length of 24 hours.";
|
||||||
|
@ -186,7 +188,7 @@ class Application_Model_Show {
|
||||||
AND ((CAST(duration AS interval) + interval '{$deltaDay} days' + interval '{$hours}:{$mins}') <= interval '24:00')";
|
AND ((CAST(duration AS interval) + interval '{$deltaDay} days' + interval '{$hours}:{$mins}') <= interval '24:00')";
|
||||||
|
|
||||||
//do both the queries at once.
|
//do both the queries at once.
|
||||||
$CC_DBC->query($sql);
|
$con->exec($sql);
|
||||||
|
|
||||||
$con = Propel::getConnection(CcSchedulePeer::DATABASE_NAME);
|
$con = Propel::getConnection(CcSchedulePeer::DATABASE_NAME);
|
||||||
$con->beginTransaction();
|
$con->beginTransaction();
|
||||||
|
@ -215,7 +217,7 @@ class Application_Model_Show {
|
||||||
|
|
||||||
public function cancelShow($day_timestamp)
|
public function cancelShow($day_timestamp)
|
||||||
{
|
{
|
||||||
global $CC_DBC;
|
$con = Propel::getConnection();
|
||||||
|
|
||||||
$timeinfo = explode(" ", $day_timestamp);
|
$timeinfo = explode(" ", $day_timestamp);
|
||||||
|
|
||||||
|
@ -227,7 +229,7 @@ class Application_Model_Show {
|
||||||
SET modified_instance = TRUE
|
SET modified_instance = TRUE
|
||||||
WHERE starts >= '{$day_timestamp}' AND show_id = {$this->_showId}";
|
WHERE starts >= '{$day_timestamp}' AND show_id = {$this->_showId}";
|
||||||
|
|
||||||
$CC_DBC->query($sql);
|
$con->exec($sql);
|
||||||
|
|
||||||
// check if we can safely delete the show
|
// check if we can safely delete the show
|
||||||
$showInstancesRow = CcShowInstancesQuery::create()
|
$showInstancesRow = CcShowInstancesQuery::create()
|
||||||
|
@ -237,7 +239,7 @@ class Application_Model_Show {
|
||||||
|
|
||||||
if(is_null($showInstancesRow)){
|
if(is_null($showInstancesRow)){
|
||||||
$sql = "DELETE FROM cc_show WHERE id = {$this->_showId}";
|
$sql = "DELETE FROM cc_show WHERE id = {$this->_showId}";
|
||||||
$CC_DBC->query($sql);
|
$con->exec($sql);
|
||||||
}
|
}
|
||||||
|
|
||||||
Application_Model_RabbitMq::PushSchedule();
|
Application_Model_RabbitMq::PushSchedule();
|
||||||
|
@ -258,7 +260,7 @@ class Application_Model_Show {
|
||||||
*/
|
*/
|
||||||
public function removeUncheckedDaysInstances($p_uncheckedDays)
|
public function removeUncheckedDaysInstances($p_uncheckedDays)
|
||||||
{
|
{
|
||||||
global $CC_DBC;
|
$con = Propel::getConnection();
|
||||||
|
|
||||||
//need to convert local doftw to UTC doftw (change made for 2.0 since shows are stored in UTC)
|
//need to convert local doftw to UTC doftw (change made for 2.0 since shows are stored in UTC)
|
||||||
$daysRemovedUTC = array();
|
$daysRemovedUTC = array();
|
||||||
|
@ -303,7 +305,7 @@ class Application_Model_Show {
|
||||||
|
|
||||||
//Logging::log($sql);
|
//Logging::log($sql);
|
||||||
|
|
||||||
$CC_DBC->query($sql);
|
$con->exec($sql);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -315,10 +317,10 @@ class Application_Model_Show {
|
||||||
*/
|
*/
|
||||||
public function isRecorded(){
|
public function isRecorded(){
|
||||||
$showInstancesRow = CcShowInstancesQuery::create()
|
$showInstancesRow = CcShowInstancesQuery::create()
|
||||||
->filterByDbShowId($this->getId())
|
->filterByDbShowId($this->getId())
|
||||||
->filterByDbRecord(1)
|
->filterByDbRecord(1)
|
||||||
->filterByDbModifiedInstance(false)
|
->filterByDbModifiedInstance(false)
|
||||||
->findOne();
|
->findOne();
|
||||||
|
|
||||||
return !is_null($showInstancesRow);
|
return !is_null($showInstancesRow);
|
||||||
}
|
}
|
||||||
|
@ -351,7 +353,7 @@ class Application_Model_Show {
|
||||||
*/
|
*/
|
||||||
public function getRebroadcastsAbsolute()
|
public function getRebroadcastsAbsolute()
|
||||||
{
|
{
|
||||||
global $CC_DBC;
|
$con = Propel::getConnection();
|
||||||
|
|
||||||
$showId = $this->getId();
|
$showId = $this->getId();
|
||||||
|
|
||||||
|
@ -361,7 +363,7 @@ class Application_Model_Show {
|
||||||
|
|
||||||
//Logging::log($sql);
|
//Logging::log($sql);
|
||||||
|
|
||||||
$rebroadcasts = $CC_DBC->GetAll($sql);
|
$rebroadcasts = $con->query($sql)->fetchAll();
|
||||||
|
|
||||||
$rebroadcastsLocal = array();
|
$rebroadcastsLocal = array();
|
||||||
//get each rebroadcast show in cc_show_instances, convert to current timezone to get start date/time.
|
//get each rebroadcast show in cc_show_instances, convert to current timezone to get start date/time.
|
||||||
|
@ -389,14 +391,14 @@ class Application_Model_Show {
|
||||||
*/
|
*/
|
||||||
public function getRebroadcastsRelative()
|
public function getRebroadcastsRelative()
|
||||||
{
|
{
|
||||||
global $CC_DBC;
|
$con = Propel::getConnection();
|
||||||
|
|
||||||
$showId = $this->getId();
|
$showId = $this->getId();
|
||||||
$sql = "SELECT day_offset, start_time FROM cc_show_rebroadcast "
|
$sql = "SELECT day_offset, start_time FROM cc_show_rebroadcast "
|
||||||
."WHERE show_id = $showId "
|
."WHERE show_id = $showId "
|
||||||
."ORDER BY day_offset";
|
."ORDER BY day_offset";
|
||||||
|
|
||||||
return $CC_DBC->GetAll($sql);
|
return $con->query($sql)->fetchAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -431,8 +433,8 @@ class Application_Model_Show {
|
||||||
public function getRepeatType()
|
public function getRepeatType()
|
||||||
{
|
{
|
||||||
$showDaysRow = CcShowDaysQuery::create()
|
$showDaysRow = CcShowDaysQuery::create()
|
||||||
->filterByDbShowId($this->_showId)
|
->filterByDbShowId($this->_showId)
|
||||||
->findOne();
|
->findOne();
|
||||||
|
|
||||||
if (!is_null($showDaysRow)){
|
if (!is_null($showDaysRow)){
|
||||||
return $showDaysRow->getDbRepeatType();
|
return $showDaysRow->getDbRepeatType();
|
||||||
|
@ -447,21 +449,17 @@ class Application_Model_Show {
|
||||||
* Return the end date for the repeating show or the empty
|
* Return the end date for the repeating show or the empty
|
||||||
* string if there is no end.
|
* string if there is no end.
|
||||||
*/
|
*/
|
||||||
public function getRepeatingEndDate(){
|
public function getRepeatingEndDate()
|
||||||
global $CC_DBC;
|
{
|
||||||
|
$con = Propel::getConnection();
|
||||||
|
|
||||||
$showId = $this->getId();
|
$showId = $this->getId();
|
||||||
$sql = "SELECT last_show FROM cc_show_days"
|
$sql = "SELECT last_show FROM cc_show_days"
|
||||||
." WHERE show_id = $showId"
|
." WHERE show_id = $showId"
|
||||||
." ORDER BY last_show DESC";
|
." ORDER BY last_show DESC";
|
||||||
|
|
||||||
$endDate = $CC_DBC->GetOne($sql);
|
$query = $con->query($sql)->fetchColumn(0);
|
||||||
|
return $query ? $query : "";
|
||||||
if (is_null($endDate)){
|
|
||||||
return "";
|
|
||||||
} else {
|
|
||||||
return $endDate;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -475,7 +473,7 @@ class Application_Model_Show {
|
||||||
* be gone for good.
|
* be gone for good.
|
||||||
*/
|
*/
|
||||||
public function deleteAllInstances(){
|
public function deleteAllInstances(){
|
||||||
global $CC_DBC;
|
$con = Propel::getConnection();
|
||||||
|
|
||||||
$timestamp = gmdate("Y-m-d H:i:s");
|
$timestamp = gmdate("Y-m-d H:i:s");
|
||||||
|
|
||||||
|
@ -484,7 +482,7 @@ class Application_Model_Show {
|
||||||
." WHERE starts > TIMESTAMP '$timestamp'"
|
." WHERE starts > TIMESTAMP '$timestamp'"
|
||||||
." AND show_id = $showId";
|
." AND show_id = $showId";
|
||||||
|
|
||||||
$CC_DBC->query($sql);
|
$con->exec($sql);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -492,7 +490,7 @@ class Application_Model_Show {
|
||||||
* show object from the show_instances table.
|
* show object from the show_instances table.
|
||||||
*/
|
*/
|
||||||
public function deleteAllRebroadcasts(){
|
public function deleteAllRebroadcasts(){
|
||||||
global $CC_DBC;
|
$con = Propel::getConnection();
|
||||||
|
|
||||||
$timestamp = gmdate("Y-m-d H:i:s");
|
$timestamp = gmdate("Y-m-d H:i:s");
|
||||||
|
|
||||||
|
@ -502,7 +500,7 @@ class Application_Model_Show {
|
||||||
." AND show_id = $showId"
|
." AND show_id = $showId"
|
||||||
." AND rebroadcast = 1";
|
." AND rebroadcast = 1";
|
||||||
|
|
||||||
$CC_DBC->query($sql);
|
$con->exec($sql);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -515,7 +513,7 @@ class Application_Model_Show {
|
||||||
* The date which to delete after, if null deletes from the current timestamp.
|
* The date which to delete after, if null deletes from the current timestamp.
|
||||||
*/
|
*/
|
||||||
public function removeAllInstancesFromDate($p_date=null){
|
public function removeAllInstancesFromDate($p_date=null){
|
||||||
global $CC_DBC;
|
$con = Propel::getConnection();
|
||||||
|
|
||||||
$timestamp = gmdate("Y-m-d H:i:s");
|
$timestamp = gmdate("Y-m-d H:i:s");
|
||||||
|
|
||||||
|
@ -530,7 +528,7 @@ class Application_Model_Show {
|
||||||
." AND starts > TIMESTAMP '$timestamp'"
|
." AND starts > TIMESTAMP '$timestamp'"
|
||||||
." AND show_id = $showId";
|
." AND show_id = $showId";
|
||||||
|
|
||||||
$CC_DBC->query($sql);
|
$con->exec($sql);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -547,7 +545,7 @@ class Application_Model_Show {
|
||||||
* The date which to delete before
|
* The date which to delete before
|
||||||
*/
|
*/
|
||||||
public function removeAllInstancesBeforeDate($p_date){
|
public function removeAllInstancesBeforeDate($p_date){
|
||||||
global $CC_DBC;
|
$con = Propel::getConnection();
|
||||||
|
|
||||||
$timestamp = gmdate("Y-m-d H:i:s");
|
$timestamp = gmdate("Y-m-d H:i:s");
|
||||||
|
|
||||||
|
@ -557,7 +555,7 @@ class Application_Model_Show {
|
||||||
." AND starts > TIMESTAMP '$timestamp'"
|
." AND starts > TIMESTAMP '$timestamp'"
|
||||||
." AND show_id = $showId";
|
." AND show_id = $showId";
|
||||||
|
|
||||||
$CC_DBC->query($sql);
|
$con->exec($sql);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -567,7 +565,7 @@ class Application_Model_Show {
|
||||||
* The start date in the format YYYY-MM-DD
|
* The start date in the format YYYY-MM-DD
|
||||||
*/
|
*/
|
||||||
public function getStartDate(){
|
public function getStartDate(){
|
||||||
global $CC_DBC;
|
$con = Propel::getConnection();
|
||||||
|
|
||||||
$showId = $this->getId();
|
$showId = $this->getId();
|
||||||
$sql = "SELECT first_show, start_time, timezone FROM cc_show_days"
|
$sql = "SELECT first_show, start_time, timezone FROM cc_show_days"
|
||||||
|
@ -575,11 +573,12 @@ class Application_Model_Show {
|
||||||
." ORDER BY first_show"
|
." ORDER BY first_show"
|
||||||
." LIMIT 1";
|
." LIMIT 1";
|
||||||
|
|
||||||
$rows = $CC_DBC->GetAll($sql);
|
$query = $con->query($sql);
|
||||||
|
|
||||||
if (count($rows) == 0){
|
if ($query->rowCount() == 0){
|
||||||
return "";
|
return "";
|
||||||
} else {
|
} else {
|
||||||
|
$rows = $query->fetchAll();
|
||||||
$row = $rows[0];
|
$row = $rows[0];
|
||||||
|
|
||||||
$dt = new DateTime($row["first_show"]." ".$row["start_time"], new DateTimeZone($row["timezone"]));
|
$dt = new DateTime($row["first_show"]." ".$row["start_time"], new DateTimeZone($row["timezone"]));
|
||||||
|
@ -596,7 +595,7 @@ class Application_Model_Show {
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public function getStartTime(){
|
public function getStartTime(){
|
||||||
global $CC_DBC;
|
$con = Propel::getConnection();
|
||||||
|
|
||||||
$showId = $this->getId();
|
$showId = $this->getId();
|
||||||
$sql = "SELECT first_show, start_time, timezone FROM cc_show_days"
|
$sql = "SELECT first_show, start_time, timezone FROM cc_show_days"
|
||||||
|
@ -604,11 +603,12 @@ class Application_Model_Show {
|
||||||
." ORDER BY first_show"
|
." ORDER BY first_show"
|
||||||
." LIMIT 1";
|
." LIMIT 1";
|
||||||
|
|
||||||
$rows = $CC_DBC->GetAll($sql);
|
$query = $con->query($sql);
|
||||||
|
|
||||||
if (count($rows) == 0){
|
if ($query->rowCount() == 0){
|
||||||
return "";
|
return "";
|
||||||
} else {
|
} else {
|
||||||
|
$rows = $query->fetchAll();
|
||||||
$row = $rows[0];
|
$row = $rows[0];
|
||||||
$dt = new DateTime($row["first_show"]." ".$row["start_time"], new DateTimeZone($row["timezone"]));
|
$dt = new DateTime($row["first_show"]." ".$row["start_time"], new DateTimeZone($row["timezone"]));
|
||||||
$dt->setTimezone(new DateTimeZone("UTC"));
|
$dt->setTimezone(new DateTimeZone("UTC"));
|
||||||
|
@ -676,7 +676,7 @@ class Application_Model_Show {
|
||||||
* scheduled in the future.
|
* scheduled in the future.
|
||||||
*/
|
*/
|
||||||
public function getAllFutureInstanceIds(){
|
public function getAllFutureInstanceIds(){
|
||||||
global $CC_DBC;
|
$con = Propel::getConnection();
|
||||||
|
|
||||||
$date = new Application_Common_DateHelper;
|
$date = new Application_Common_DateHelper;
|
||||||
$timestamp = $date->getTimestamp();
|
$timestamp = $date->getTimestamp();
|
||||||
|
@ -687,10 +687,10 @@ class Application_Model_Show {
|
||||||
." AND starts > TIMESTAMP '$timestamp'"
|
." AND starts > TIMESTAMP '$timestamp'"
|
||||||
." AND modified_instance != TRUE";
|
." AND modified_instance != TRUE";
|
||||||
|
|
||||||
$rows = $CC_DBC->GetAll($sql);
|
$rows = $con->query($sql)->fetchAll();
|
||||||
|
|
||||||
$instance_ids = array();
|
$instance_ids = array();
|
||||||
foreach ($rows as $row){
|
foreach ($rows as $row) {
|
||||||
$instance_ids[] = $row["id"];
|
$instance_ids[] = $row["id"];
|
||||||
}
|
}
|
||||||
return $instance_ids;
|
return $instance_ids;
|
||||||
|
@ -705,8 +705,7 @@ class Application_Model_Show {
|
||||||
*/
|
*/
|
||||||
private function updateDurationTime($p_data){
|
private function updateDurationTime($p_data){
|
||||||
//need to update cc_show_instances, cc_show_days
|
//need to update cc_show_instances, cc_show_days
|
||||||
|
$con = Propel::getConnection();
|
||||||
global $CC_DBC;
|
|
||||||
|
|
||||||
$date = new Application_Common_DateHelper;
|
$date = new Application_Common_DateHelper;
|
||||||
$timestamp = $date->getUtcTimestamp();
|
$timestamp = $date->getUtcTimestamp();
|
||||||
|
@ -714,20 +713,20 @@ class Application_Model_Show {
|
||||||
$sql = "UPDATE cc_show_days "
|
$sql = "UPDATE cc_show_days "
|
||||||
."SET duration = '$p_data[add_show_duration]' "
|
."SET duration = '$p_data[add_show_duration]' "
|
||||||
."WHERE show_id = $p_data[add_show_id]";
|
."WHERE show_id = $p_data[add_show_id]";
|
||||||
$CC_DBC->query($sql);
|
$con->exec($sql);
|
||||||
|
|
||||||
$sql = "UPDATE cc_show_instances "
|
$sql = "UPDATE cc_show_instances "
|
||||||
."SET ends = starts + INTERVAL '$p_data[add_show_duration]' "
|
."SET ends = starts + INTERVAL '$p_data[add_show_duration]' "
|
||||||
."WHERE show_id = $p_data[add_show_id] "
|
."WHERE show_id = $p_data[add_show_id] "
|
||||||
."AND ends > TIMESTAMP '$timestamp'";
|
."AND ends > TIMESTAMP '$timestamp'";
|
||||||
$CC_DBC->query($sql);
|
$con->exec($sql);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private function updateStartDateTime($p_data, $p_endDate){
|
private function updateStartDateTime($p_data, $p_endDate){
|
||||||
//need to update cc_schedule, cc_show_instances, cc_show_days
|
//need to update cc_schedule, cc_show_instances, cc_show_days
|
||||||
|
$con = Propel::getConnection();
|
||||||
global $CC_DBC;
|
|
||||||
|
|
||||||
$date = new Application_Common_DateHelper;
|
$date = new Application_Common_DateHelper;
|
||||||
$timestamp = $date->getTimestamp();
|
$timestamp = $date->getTimestamp();
|
||||||
|
@ -742,7 +741,7 @@ class Application_Model_Show {
|
||||||
$sql .= "last_show = DATE '$p_endDate' ";
|
$sql .= "last_show = DATE '$p_endDate' ";
|
||||||
}
|
}
|
||||||
$sql .= "WHERE show_id = $p_data[add_show_id]";
|
$sql .= "WHERE show_id = $p_data[add_show_id]";
|
||||||
$CC_DBC->query($sql);
|
$con->exec($sql);
|
||||||
|
|
||||||
$dtOld = new DateTime($this->getStartDate()." ".$this->getStartTime(), new DateTimeZone("UTC"));
|
$dtOld = new DateTime($this->getStartDate()." ".$this->getStartTime(), new DateTimeZone("UTC"));
|
||||||
$dtNew = new DateTime($p_data['add_show_start_date']." ".$p_data['add_show_start_time'], new DateTimeZone(date_default_timezone_get()));
|
$dtNew = new DateTime($p_data['add_show_start_date']." ".$p_data['add_show_start_time'], new DateTimeZone(date_default_timezone_get()));
|
||||||
|
@ -753,7 +752,7 @@ class Application_Model_Show {
|
||||||
."ends = ends + INTERVAL '$diff sec' "
|
."ends = ends + INTERVAL '$diff sec' "
|
||||||
."WHERE show_id = $p_data[add_show_id] "
|
."WHERE show_id = $p_data[add_show_id] "
|
||||||
."AND starts > TIMESTAMP '$timestamp'";
|
."AND starts > TIMESTAMP '$timestamp'";
|
||||||
$CC_DBC->query($sql);
|
$con->exec($sql);
|
||||||
|
|
||||||
$showInstanceIds = $this->getAllFutureInstanceIds();
|
$showInstanceIds = $this->getAllFutureInstanceIds();
|
||||||
if (count($showInstanceIds) > 0 && $diff != 0){
|
if (count($showInstanceIds) > 0 && $diff != 0){
|
||||||
|
@ -762,7 +761,7 @@ class Application_Model_Show {
|
||||||
."SET starts = starts + INTERVAL '$diff sec', "
|
."SET starts = starts + INTERVAL '$diff sec', "
|
||||||
."ends = ends + INTERVAL '$diff sec' "
|
."ends = ends + INTERVAL '$diff sec' "
|
||||||
."WHERE instance_id IN ($showIdsImploded)";
|
."WHERE instance_id IN ($showIdsImploded)";
|
||||||
$CC_DBC->query($sql);
|
$con->exec($sql);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -805,7 +804,7 @@ class Application_Model_Show {
|
||||||
|
|
||||||
return $showInstance;
|
return $showInstance;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* returns info about live stream override info
|
* returns info about live stream override info
|
||||||
*/
|
*/
|
||||||
|
@ -848,7 +847,8 @@ class Application_Model_Show {
|
||||||
* @return CcShowInstancesQuery: An propel object representing a
|
* @return CcShowInstancesQuery: An propel object representing a
|
||||||
* row in the cc_show_instances table. */
|
* row in the cc_show_instances table. */
|
||||||
public function getInstanceOnDate($p_dateTime){
|
public function getInstanceOnDate($p_dateTime){
|
||||||
global $CC_DBC;
|
$con = Propel::getConnection();
|
||||||
|
|
||||||
$timestamp = $p_dateTime->format("Y-m-d H:i:s");
|
$timestamp = $p_dateTime->format("Y-m-d H:i:s");
|
||||||
|
|
||||||
$showId = $this->getId();
|
$showId = $this->getId();
|
||||||
|
@ -856,7 +856,8 @@ class Application_Model_Show {
|
||||||
." WHERE date(starts) = date(TIMESTAMP '$timestamp') "
|
." WHERE date(starts) = date(TIMESTAMP '$timestamp') "
|
||||||
." AND show_id = $showId";
|
." AND show_id = $showId";
|
||||||
|
|
||||||
$row = $CC_DBC->GetOne($sql);
|
$query = $con->query();
|
||||||
|
$row = $query ? $query->fetchColumn(0) : null;
|
||||||
return CcShowInstancesQuery::create()
|
return CcShowInstancesQuery::create()
|
||||||
->findPk($row);
|
->findPk($row);
|
||||||
}
|
}
|
||||||
|
@ -1164,8 +1165,15 @@ class Application_Model_Show {
|
||||||
*/
|
*/
|
||||||
public static function populateShowUntil($p_showId)
|
public static function populateShowUntil($p_showId)
|
||||||
{
|
{
|
||||||
|
<<<<<<< HEAD
|
||||||
global $CC_DBC;
|
global $CC_DBC;
|
||||||
$date = Application_Model_Preference::GetShowsPopulatedUntil();
|
$date = Application_Model_Preference::GetShowsPopulatedUntil();
|
||||||
|
=======
|
||||||
|
$con = Propel::getConnection();
|
||||||
|
|
||||||
|
if (is_null($p_dateTime)) {
|
||||||
|
$date = Application_Model_Preference::GetShowsPopulatedUntil();
|
||||||
|
>>>>>>> CC-1927: Remove PEAR DB
|
||||||
|
|
||||||
if (is_null($date)) {
|
if (is_null($date)) {
|
||||||
$p_populateUntilDateTime = new DateTime("now", new DateTimeZone('UTC'));
|
$p_populateUntilDateTime = new DateTime("now", new DateTimeZone('UTC'));
|
||||||
|
@ -1175,7 +1183,7 @@ class Application_Model_Show {
|
||||||
}
|
}
|
||||||
|
|
||||||
$sql = "SELECT * FROM cc_show_days WHERE show_id = $p_showId";
|
$sql = "SELECT * FROM cc_show_days WHERE show_id = $p_showId";
|
||||||
$res = $CC_DBC->GetAll($sql);
|
$res = $con->query($sql)->fetchAll();
|
||||||
|
|
||||||
foreach ($res as $showRow) {
|
foreach ($res as $showRow) {
|
||||||
Application_Model_Show::populateShow($showRow, $p_populateUntilDateTime);
|
Application_Model_Show::populateShow($showRow, $p_populateUntilDateTime);
|
||||||
|
@ -1220,8 +1228,13 @@ class Application_Model_Show {
|
||||||
*/
|
*/
|
||||||
private static function populateNonRepeatingShow($p_showRow, $p_populateUntilDateTime)
|
private static function populateNonRepeatingShow($p_showRow, $p_populateUntilDateTime)
|
||||||
{
|
{
|
||||||
|
<<<<<<< HEAD
|
||||||
global $CC_DBC;
|
global $CC_DBC;
|
||||||
|
|
||||||
|
=======
|
||||||
|
$con = Propel::getConnection();
|
||||||
|
|
||||||
|
>>>>>>> CC-1927: Remove PEAR DB
|
||||||
$show_id = $p_showRow["show_id"];
|
$show_id = $p_showRow["show_id"];
|
||||||
$first_show = $p_showRow["first_show"]; //non-UTC
|
$first_show = $p_showRow["first_show"]; //non-UTC
|
||||||
$start_time = $p_showRow["start_time"]; //non-UTC
|
$start_time = $p_showRow["start_time"]; //non-UTC
|
||||||
|
@ -1261,11 +1274,17 @@ class Application_Model_Show {
|
||||||
}
|
}
|
||||||
|
|
||||||
$sql = "SELECT * FROM cc_show_rebroadcast WHERE show_id={$show_id}";
|
$sql = "SELECT * FROM cc_show_rebroadcast WHERE show_id={$show_id}";
|
||||||
$rebroadcasts = $CC_DBC->GetAll($sql);
|
$rebroadcasts = $con->query($sql)->fetchAll();
|
||||||
|
|
||||||
//Logging::log('$start time of non repeating record '.$start);
|
//Logging::log('$start time of non repeating record '.$start);
|
||||||
|
|
||||||
|
<<<<<<< HEAD
|
||||||
self::createRebroadcastInstances($rebroadcasts, $currentUtcTimestamp, $show_id, $show_instance_id, $start, $duration, $timezone);
|
self::createRebroadcastInstances($rebroadcasts, $currentUtcTimestamp, $show_id, $show_instance_id, $start, $duration, $timezone);
|
||||||
|
=======
|
||||||
|
if ($newInstance) {
|
||||||
|
self::createRebroadcastInstances($rebroadcasts, $currentUtcTimestamp, $show_id, $show_instance_id, $start, $duration, $timezone);
|
||||||
|
}
|
||||||
|
>>>>>>> CC-1927: Remove PEAR DB
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1283,7 +1302,7 @@ class Application_Model_Show {
|
||||||
*/
|
*/
|
||||||
private static function populateRepeatingShow($p_showRow, $p_populateUntilDateTime, $p_interval)
|
private static function populateRepeatingShow($p_showRow, $p_populateUntilDateTime, $p_interval)
|
||||||
{
|
{
|
||||||
global $CC_DBC;
|
$con = Propel::getConnection();
|
||||||
|
|
||||||
$show_id = $p_showRow["show_id"];
|
$show_id = $p_showRow["show_id"];
|
||||||
$next_pop_date = $p_showRow["next_pop_date"];
|
$next_pop_date = $p_showRow["next_pop_date"];
|
||||||
|
@ -1308,11 +1327,15 @@ class Application_Model_Show {
|
||||||
$utcLastShowDateTime = $last_show ? Application_Common_DateHelper::ConvertToUtcDateTime($last_show, $timezone) : null;
|
$utcLastShowDateTime = $last_show ? Application_Common_DateHelper::ConvertToUtcDateTime($last_show, $timezone) : null;
|
||||||
|
|
||||||
$sql = "SELECT * FROM cc_show_rebroadcast WHERE show_id={$show_id}";
|
$sql = "SELECT * FROM cc_show_rebroadcast WHERE show_id={$show_id}";
|
||||||
$rebroadcasts = $CC_DBC->GetAll($sql);
|
$rebroadcasts = $con->query($sql)->fetchAll();
|
||||||
|
|
||||||
$show = new Application_Model_Show($show_id);
|
$show = new Application_Model_Show($show_id);
|
||||||
|
|
||||||
|
<<<<<<< HEAD
|
||||||
while($utcStartDateTime->getTimestamp() <= $p_populateUntilDateTime->getTimestamp()
|
while($utcStartDateTime->getTimestamp() <= $p_populateUntilDateTime->getTimestamp()
|
||||||
|
=======
|
||||||
|
while ($utcStartDateTime->getTimestamp() <= $p_dateTime->getTimestamp()
|
||||||
|
>>>>>>> CC-1927: Remove PEAR DB
|
||||||
&& (is_null($utcLastShowDateTime) || $utcStartDateTime->getTimestamp() < $utcLastShowDateTime->getTimestamp())){
|
&& (is_null($utcLastShowDateTime) || $utcStartDateTime->getTimestamp() < $utcLastShowDateTime->getTimestamp())){
|
||||||
|
|
||||||
list($utcStartDateTime, $utcEndDateTime) = Application_Model_Show::createUTCStartEndDateTime($start, $duration, $timezone);
|
list($utcStartDateTime, $utcEndDateTime) = Application_Model_Show::createUTCStartEndDateTime($start, $duration, $timezone);
|
||||||
|
@ -1481,7 +1504,7 @@ class Application_Model_Show {
|
||||||
*/
|
*/
|
||||||
public static function getShows($start_timestamp, $end_timestamp, $excludeInstance=NULL, $onlyRecord=FALSE)
|
public static function getShows($start_timestamp, $end_timestamp, $excludeInstance=NULL, $onlyRecord=FALSE)
|
||||||
{
|
{
|
||||||
global $CC_DBC;
|
$con = Propel::getConnection();
|
||||||
|
|
||||||
//UTC DateTime object
|
//UTC DateTime object
|
||||||
$showsPopUntil = Application_Model_Preference::GetShowsPopulatedUntil();
|
$showsPopUntil = Application_Model_Preference::GetShowsPopulatedUntil();
|
||||||
|
@ -1527,8 +1550,8 @@ class Application_Model_Show {
|
||||||
|
|
||||||
//Logging::log("getShows");
|
//Logging::log("getShows");
|
||||||
//Logging::log($sql);
|
//Logging::log($sql);
|
||||||
|
$result = $con->query($sql)->fetchAll();
|
||||||
return $CC_DBC->GetAll($sql);
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static function setNextPop($next_date, $show_id, $day)
|
private static function setNextPop($next_date, $show_id, $day)
|
||||||
|
@ -1554,7 +1577,7 @@ class Application_Model_Show {
|
||||||
*/
|
*/
|
||||||
public static function populateAllShowsInRange($p_startTimestamp, $p_endTimestamp)
|
public static function populateAllShowsInRange($p_startTimestamp, $p_endTimestamp)
|
||||||
{
|
{
|
||||||
global $CC_DBC;
|
$con = Propel::getConnection();
|
||||||
|
|
||||||
$endTimeString = $p_endTimestamp->format("Y-m-d H:i:s");
|
$endTimeString = $p_endTimestamp->format("Y-m-d H:i:s");
|
||||||
if (!is_null($p_startTimestamp)) {
|
if (!is_null($p_startTimestamp)) {
|
||||||
|
@ -1570,8 +1593,7 @@ class Application_Model_Show {
|
||||||
OR first_show < '{$endTimeString}' AND last_show > '{$startTimeString}'";
|
OR first_show < '{$endTimeString}' AND last_show > '{$startTimeString}'";
|
||||||
|
|
||||||
//Logging::log($sql);
|
//Logging::log($sql);
|
||||||
|
$res = $con->query($sql)->fetchAll();
|
||||||
$res = $CC_DBC->GetAll($sql);
|
|
||||||
|
|
||||||
foreach ($res as $row) {
|
foreach ($res as $row) {
|
||||||
Application_Model_Show::populateShow($row, $p_endTimestamp);
|
Application_Model_Show::populateShow($row, $p_endTimestamp);
|
||||||
|
@ -1588,22 +1610,18 @@ class Application_Model_Show {
|
||||||
*/
|
*/
|
||||||
public static function getFullCalendarEvents($p_start, $p_end, $p_editable=false)
|
public static function getFullCalendarEvents($p_start, $p_end, $p_editable=false)
|
||||||
{
|
{
|
||||||
|
|
||||||
$events = array();
|
$events = array();
|
||||||
|
|
||||||
$interval = $p_start->diff($p_end);
|
$interval = $p_start->diff($p_end);
|
||||||
$days = $interval->format('%a');
|
$days = $interval->format('%a');
|
||||||
|
|
||||||
$shows = Application_Model_Show::getShows($p_start, $p_end);
|
$shows = Application_Model_Show::getShows($p_start, $p_end);
|
||||||
|
|
||||||
$today_timestamp = gmdate("Y-m-d H:i:s");
|
$today_timestamp = gmdate("Y-m-d H:i:s");
|
||||||
|
|
||||||
foreach ($shows as $show) {
|
foreach ($shows as $show) {
|
||||||
$options = array();
|
$options = array();
|
||||||
|
|
||||||
//only bother calculating percent for week or day view.
|
//only bother calculating percent for week or day view.
|
||||||
|
|
||||||
if(intval($days) <= 7) {
|
if (intval($days) <= 7) {
|
||||||
$options["percent"] = Application_Model_Show::getPercentScheduled($show["starts"], $show["ends"], $show["time_filled"]);
|
$options["percent"] = Application_Model_Show::getPercentScheduled($show["starts"], $show["ends"], $show["time_filled"]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1612,19 +1630,19 @@ class Application_Model_Show {
|
||||||
}
|
}
|
||||||
$events[] = Application_Model_Show::makeFullCalendarEvent($show, $options);
|
$events[] = Application_Model_Show::makeFullCalendarEvent($show, $options);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $events;
|
return $events;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Calculates the percentage of a show scheduled given the start and end times in date/time format
|
* Calculates the percentage of a show scheduled given the start and end times in date/time format
|
||||||
* and the time_filled as the total time the schow is scheduled for in time format.
|
* and the time_filled as the total time the schow is scheduled for in time format.
|
||||||
**/
|
**/
|
||||||
private static function getPercentScheduled($p_starts, $p_ends, $p_time_filled){
|
private static function getPercentScheduled($p_starts, $p_ends, $p_time_filled){
|
||||||
$durationSeconds = (strtotime($p_ends) - strtotime($p_starts));
|
$durationSeconds = (strtotime($p_ends) - strtotime($p_starts));
|
||||||
$time_filled = Application_Model_Schedule::WallTimeToMillisecs($p_time_filled) / 1000;
|
$time_filled = Application_Model_Schedule::WallTimeToMillisecs($p_time_filled) / 1000;
|
||||||
$percent = ceil(( $time_filled / $durationSeconds) * 100);
|
$percent = ceil(( $time_filled / $durationSeconds) * 100);
|
||||||
|
|
||||||
return $percent;
|
return $percent;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1722,10 +1740,16 @@ class Application_Model_Show {
|
||||||
*/
|
*/
|
||||||
public static function GetCurrentShow($timeNow=null)
|
public static function GetCurrentShow($timeNow=null)
|
||||||
{
|
{
|
||||||
global $CC_CONFIG, $CC_DBC;
|
global $CC_CONFIG;
|
||||||
|
$con = Propel::getConnection();
|
||||||
if($timeNow == null){
|
if($timeNow == null){
|
||||||
|
<<<<<<< HEAD
|
||||||
$date = new Application_Common_DateHelper;
|
$date = new Application_Common_DateHelper;
|
||||||
$timeNow = $date->getUtcTimestamp();
|
$timeNow = $date->getUtcTimestamp();
|
||||||
|
=======
|
||||||
|
$date = new Application_Model_DateHelper;
|
||||||
|
$timeNow = $date->getUtcTimestamp();
|
||||||
|
>>>>>>> CC-1927: Remove PEAR DB
|
||||||
}
|
}
|
||||||
//TODO, returning starts + ends twice (once with an alias). Unify this after the 2.0 release. --Martin
|
//TODO, returning starts + ends twice (once with an alias). Unify this after the 2.0 release. --Martin
|
||||||
$sql = "SELECT si.starts as start_timestamp, si.ends as end_timestamp, s.name, s.id, si.id as instance_id, si.record, s.url, starts, ends"
|
$sql = "SELECT si.starts as start_timestamp, si.ends as end_timestamp, s.name, s.id, si.id as instance_id, si.record, s.url, starts, ends"
|
||||||
|
@ -1736,8 +1760,7 @@ class Application_Model_Show {
|
||||||
." AND modified_instance != TRUE";
|
." AND modified_instance != TRUE";
|
||||||
|
|
||||||
// Convert back to local timezone
|
// Convert back to local timezone
|
||||||
$rows = $CC_DBC->GetAll($sql);
|
$rows = $con->query($sql)->fetchAll();
|
||||||
|
|
||||||
return $rows;
|
return $rows;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1746,7 +1769,8 @@ class Application_Model_Show {
|
||||||
*/
|
*/
|
||||||
public static function getPrevCurrentNext($p_timeNow)
|
public static function getPrevCurrentNext($p_timeNow)
|
||||||
{
|
{
|
||||||
global $CC_CONFIG, $CC_DBC;
|
global $CC_CONFIG;
|
||||||
|
$con = Propel::getConnection();
|
||||||
//TODO, returning starts + ends twice (once with an alias). Unify this after the 2.0 release. --Martin
|
//TODO, returning starts + ends twice (once with an alias). Unify this after the 2.0 release. --Martin
|
||||||
$sql = "SELECT si.starts as start_timestamp, si.ends as end_timestamp, s.name, s.id, si.id as instance_id, si.record, s.url, starts, ends"
|
$sql = "SELECT si.starts as start_timestamp, si.ends as end_timestamp, s.name, s.id, si.id as instance_id, si.record, s.url, starts, ends"
|
||||||
." FROM $CC_CONFIG[showInstances] si, $CC_CONFIG[showTable] s"
|
." FROM $CC_CONFIG[showInstances] si, $CC_CONFIG[showTable] s"
|
||||||
|
@ -1757,15 +1781,15 @@ class Application_Model_Show {
|
||||||
." ORDER BY si.starts";
|
." ORDER BY si.starts";
|
||||||
|
|
||||||
// Convert back to local timezone
|
// Convert back to local timezone
|
||||||
$rows = $CC_DBC->GetAll($sql);
|
$rows = $con->query($sql)->fetchAll();
|
||||||
$numberOfRows = count($rows);
|
$numberOfRows = count($rows);
|
||||||
|
|
||||||
$results['previousShow'] = array();
|
$results['previousShow'] = array();
|
||||||
$results['currentShow'] = array();
|
$results['currentShow'] = array();
|
||||||
$results['nextShow'] = array();
|
$results['nextShow'] = array();
|
||||||
|
|
||||||
$timeNowAsMillis = strtotime($p_timeNow);
|
$timeNowAsMillis = strtotime($p_timeNow);
|
||||||
|
|
||||||
for( $i = 0; $i < $numberOfRows; ++$i ){
|
for( $i = 0; $i < $numberOfRows; ++$i ){
|
||||||
//Find the show that is within the current time.
|
//Find the show that is within the current time.
|
||||||
if ((strtotime($rows[$i]['starts']) <= $timeNowAsMillis) && (strtotime($rows[$i]['ends']) >= $timeNowAsMillis)){
|
if ((strtotime($rows[$i]['starts']) <= $timeNowAsMillis) && (strtotime($rows[$i]['ends']) >= $timeNowAsMillis)){
|
||||||
|
@ -1779,9 +1803,9 @@ class Application_Model_Show {
|
||||||
"starts"=>$rows[$i-1]['starts'],
|
"starts"=>$rows[$i-1]['starts'],
|
||||||
"ends"=>$rows[$i-1]['ends']);
|
"ends"=>$rows[$i-1]['ends']);
|
||||||
}
|
}
|
||||||
|
|
||||||
$results['currentShow'][0] = $rows[$i];
|
$results['currentShow'][0] = $rows[$i];
|
||||||
|
|
||||||
if ( isset($rows[$i+1])){
|
if ( isset($rows[$i+1])){
|
||||||
$results['nextShow'][0] = array(
|
$results['nextShow'][0] = array(
|
||||||
"id"=>$rows[$i+1]['id'],
|
"id"=>$rows[$i+1]['id'],
|
||||||
|
@ -1791,7 +1815,7 @@ class Application_Model_Show {
|
||||||
"end_timestamp"=>$rows[$i+1]['end_timestamp'],
|
"end_timestamp"=>$rows[$i+1]['end_timestamp'],
|
||||||
"starts"=>$rows[$i+1]['starts'],
|
"starts"=>$rows[$i+1]['starts'],
|
||||||
"ends"=>$rows[$i+1]['ends']);
|
"ends"=>$rows[$i+1]['ends']);
|
||||||
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -1826,6 +1850,7 @@ class Application_Model_Show {
|
||||||
}
|
}
|
||||||
return $results;
|
return $results;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Given a start time $timeStart and end time $timeEnd, returns the next $limit
|
* Given a start time $timeStart and end time $timeEnd, returns the next $limit
|
||||||
* number of shows within the time interval;
|
* number of shows within the time interval;
|
||||||
|
@ -1840,11 +1865,12 @@ class Application_Model_Show {
|
||||||
*/
|
*/
|
||||||
public static function GetNextShows($timeStart, $limit = "0", $timeEnd = "")
|
public static function GetNextShows($timeStart, $limit = "0", $timeEnd = "")
|
||||||
{
|
{
|
||||||
global $CC_CONFIG, $CC_DBC;
|
global $CC_CONFIG;
|
||||||
|
$con = Propel::getConnection();
|
||||||
|
|
||||||
// defaults to retrieving shows from next 2 days if no end time has
|
// defaults to retrieving shows from next 2 days if no end time has
|
||||||
// been specified
|
// been specified
|
||||||
if($timeEnd == "") {
|
if ($timeEnd == "") {
|
||||||
$timeEnd = "'$timeStart' + INTERVAL '2 days'";
|
$timeEnd = "'$timeStart' + INTERVAL '2 days'";
|
||||||
} else {
|
} else {
|
||||||
$timeEnd = "'$timeEnd'";
|
$timeEnd = "'$timeEnd'";
|
||||||
|
@ -1864,8 +1890,7 @@ class Application_Model_Show {
|
||||||
$sql = $sql . " LIMIT $limit";
|
$sql = $sql . " LIMIT $limit";
|
||||||
}
|
}
|
||||||
|
|
||||||
$rows = $CC_DBC->GetAll($sql);
|
$rows = $con->query($sql)->fetchAll();
|
||||||
|
|
||||||
return $rows;
|
return $rows;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1890,14 +1915,16 @@ class Application_Model_Show {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function GetMaxLengths() {
|
public static function GetMaxLengths() {
|
||||||
global $CC_CONFIG, $CC_DBC;
|
global $CC_CONFIG;
|
||||||
|
$con = Propel::getConnection();
|
||||||
|
|
||||||
$sql = "SELECT column_name, character_maximum_length FROM information_schema.columns"
|
$sql = "SELECT column_name, character_maximum_length FROM information_schema.columns"
|
||||||
." WHERE table_name = 'cc_show' AND character_maximum_length > 0";
|
." WHERE table_name = 'cc_show' AND character_maximum_length > 0";
|
||||||
$result = $CC_DBC->GetAll($sql);
|
$result = $con->query($sql)->fetchAll();
|
||||||
|
|
||||||
// store result into assoc array
|
// store result into assoc array
|
||||||
$assocArray = array();
|
$assocArray = array();
|
||||||
foreach($result as $row) {
|
foreach ($result as $row) {
|
||||||
$assocArray[$row['column_name']] = $row['character_maximum_length'];
|
$assocArray[$row['column_name']] = $row['character_maximum_length'];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -146,8 +146,9 @@ class Application_Model_ShowInstance {
|
||||||
$this->_showInstance->getDbModifiedInstance();
|
$this->_showInstance->getDbModifiedInstance();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function correctScheduleStartTimes(){
|
public function correctScheduleStartTimes()
|
||||||
global $CC_DBC;
|
{
|
||||||
|
$con = Propel::getConnection();
|
||||||
|
|
||||||
$instance_id = $this->getShowInstanceId();
|
$instance_id = $this->getShowInstanceId();
|
||||||
$sql = "SELECT starts from cc_schedule"
|
$sql = "SELECT starts from cc_schedule"
|
||||||
|
@ -155,9 +156,9 @@ class Application_Model_ShowInstance {
|
||||||
." ORDER BY starts"
|
." ORDER BY starts"
|
||||||
." LIMIT 1";
|
." LIMIT 1";
|
||||||
|
|
||||||
$scheduleStarts = $CC_DBC->GetOne($sql);
|
$scheduleStarts = $con->query($sql)->fetchColumn(0);
|
||||||
|
|
||||||
if (!is_null($scheduleStarts)){
|
if ($scheduleStarts) {
|
||||||
$scheduleStartsEpoch = strtotime($scheduleStarts);
|
$scheduleStartsEpoch = strtotime($scheduleStarts);
|
||||||
$showStartsEpoch = strtotime($this->getShowInstanceStart());
|
$showStartsEpoch = strtotime($this->getShowInstanceStart());
|
||||||
|
|
||||||
|
@ -169,7 +170,7 @@ class Application_Model_ShowInstance {
|
||||||
." ends = ends + INTERVAL '$diff' second"
|
." ends = ends + INTERVAL '$diff' second"
|
||||||
." WHERE instance_id = $instance_id";
|
." WHERE instance_id = $instance_id";
|
||||||
|
|
||||||
$CC_DBC->query($sql);
|
$con->exec($sql);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Application_Model_RabbitMq::PushSchedule();
|
Application_Model_RabbitMq::PushSchedule();
|
||||||
|
@ -300,7 +301,7 @@ class Application_Model_ShowInstance {
|
||||||
*/
|
*/
|
||||||
public function resizeShow($deltaDay, $deltaMin)
|
public function resizeShow($deltaDay, $deltaMin)
|
||||||
{
|
{
|
||||||
global $CC_DBC;
|
$con = Propel::getConnection();
|
||||||
|
|
||||||
$hours = $deltaMin/60;
|
$hours = $deltaMin/60;
|
||||||
if($hours > 0)
|
if($hours > 0)
|
||||||
|
@ -319,10 +320,10 @@ class Application_Model_ShowInstance {
|
||||||
}
|
}
|
||||||
|
|
||||||
$sql = "SELECT timestamp '{$ends}' + interval '{$deltaDay} days' + interval '{$hours}:{$mins}'";
|
$sql = "SELECT timestamp '{$ends}' + interval '{$deltaDay} days' + interval '{$hours}:{$mins}'";
|
||||||
$new_ends = $CC_DBC->GetOne($sql);
|
$new_ends = $con->query($sql)->fetchColumn(0);
|
||||||
|
|
||||||
//only need to check overlap if show increased in size.
|
//only need to check overlap if show increased in size.
|
||||||
if(strtotime($new_ends) > strtotime($ends)) {
|
if (strtotime($new_ends) > strtotime($ends)) {
|
||||||
|
|
||||||
$utcStartDateTime = new DateTime($ends, new DateTimeZone("UTC"));
|
$utcStartDateTime = new DateTime($ends, new DateTimeZone("UTC"));
|
||||||
$utcEndDateTime = new DateTime($new_ends, new DateTimeZone("UTC"));
|
$utcEndDateTime = new DateTime($new_ends, new DateTimeZone("UTC"));
|
||||||
|
@ -339,7 +340,7 @@ class Application_Model_ShowInstance {
|
||||||
if($this->isRecorded()) {
|
if($this->isRecorded()) {
|
||||||
$sql = "UPDATE cc_show_instances SET ends = (ends + interval '{$deltaDay} days' + interval '{$hours}:{$mins}')
|
$sql = "UPDATE cc_show_instances SET ends = (ends + interval '{$deltaDay} days' + interval '{$hours}:{$mins}')
|
||||||
WHERE rebroadcast = 1 AND instance_id = {$this->_instanceId}";
|
WHERE rebroadcast = 1 AND instance_id = {$this->_instanceId}";
|
||||||
$CC_DBC->query($sql);
|
$con->exec($sql);
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->setShowEnd($new_ends);
|
$this->setShowEnd($new_ends);
|
||||||
|
@ -481,8 +482,6 @@ class Application_Model_ShowInstance {
|
||||||
|
|
||||||
public function delete()
|
public function delete()
|
||||||
{
|
{
|
||||||
global $CC_DBC;
|
|
||||||
|
|
||||||
// see if it was recording show
|
// see if it was recording show
|
||||||
$recording = $this->isRecorded();
|
$recording = $this->isRecorded();
|
||||||
// get show id
|
// get show id
|
||||||
|
@ -631,7 +630,7 @@ class Application_Model_ShowInstance {
|
||||||
|
|
||||||
public function getShowListContent()
|
public function getShowListContent()
|
||||||
{
|
{
|
||||||
global $CC_DBC;
|
$con = Propel::getConnection();
|
||||||
|
|
||||||
$sql = "SELECT *
|
$sql = "SELECT *
|
||||||
FROM (cc_schedule AS s LEFT JOIN cc_files AS f ON f.id = s.file_id)
|
FROM (cc_schedule AS s LEFT JOIN cc_files AS f ON f.id = s.file_id)
|
||||||
|
@ -640,7 +639,7 @@ class Application_Model_ShowInstance {
|
||||||
|
|
||||||
//Logging::log($sql);
|
//Logging::log($sql);
|
||||||
|
|
||||||
$results = $CC_DBC->GetAll($sql);
|
$results = $con->query($sql)->fetchAll();
|
||||||
|
|
||||||
foreach ($results as &$row) {
|
foreach ($results as &$row) {
|
||||||
|
|
||||||
|
@ -655,16 +654,18 @@ class Application_Model_ShowInstance {
|
||||||
|
|
||||||
return $results;
|
return $results;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getLastAudioItemEnd(){
|
public function getLastAudioItemEnd()
|
||||||
global $CC_DBC;
|
{
|
||||||
|
$con = Propel::getConnection();
|
||||||
|
|
||||||
$sql = "SELECT ends FROM cc_schedule "
|
$sql = "SELECT ends FROM cc_schedule "
|
||||||
."WHERE instance_id = {$this->_instanceId} "
|
."WHERE instance_id = {$this->_instanceId} "
|
||||||
."ORDER BY ends DESC "
|
."ORDER BY ends DESC "
|
||||||
."LIMIT 1";
|
."LIMIT 1";
|
||||||
|
|
||||||
return $CC_DBC->GetOne($sql);
|
$query = $con->query($sql)->fetchColumn(0);
|
||||||
|
return $query ? $query : NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getShowEndGapTime(){
|
public function getShowEndGapTime(){
|
||||||
|
@ -682,25 +683,28 @@ class Application_Model_ShowInstance {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function GetLastShowInstance($p_timeNow){
|
public static function GetLastShowInstance($p_timeNow){
|
||||||
global $CC_CONFIG, $CC_DBC;
|
global $CC_CONFIG;
|
||||||
|
$con = Propel::getConnection();
|
||||||
|
|
||||||
$sql = "SELECT si.id"
|
$sql = "SELECT si.id"
|
||||||
." FROM $CC_CONFIG[showInstances] si"
|
." FROM $CC_CONFIG[showInstances] si"
|
||||||
." WHERE si.ends < TIMESTAMP '$p_timeNow'"
|
." WHERE si.ends < TIMESTAMP '$p_timeNow'"
|
||||||
." AND si.modified_instance = 'f'"
|
." AND si.modified_instance = 'f'"
|
||||||
." ORDER BY si.ends DESC"
|
." ORDER BY si.ends DESC"
|
||||||
." LIMIT 1";
|
." LIMIT 1";
|
||||||
|
|
||||||
$id = $CC_DBC->GetOne($sql);
|
$id = $con->query($sql)->fetchColumn(0);
|
||||||
if (is_null($id)){
|
if ($id) {
|
||||||
return null;
|
|
||||||
} else {
|
|
||||||
return new Application_Model_ShowInstance($id);
|
return new Application_Model_ShowInstance($id);
|
||||||
|
} else {
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function GetCurrentShowInstance($p_timeNow){
|
public static function GetCurrentShowInstance($p_timeNow)
|
||||||
global $CC_CONFIG, $CC_DBC;
|
{
|
||||||
|
global $CC_CONFIG;
|
||||||
|
$con = Propel::getConnection();
|
||||||
|
|
||||||
/* Orderby si.starts descending, because in some cases
|
/* Orderby si.starts descending, because in some cases
|
||||||
* we can have multiple shows overlapping each other. In
|
* we can have multiple shows overlapping each other. In
|
||||||
|
@ -709,57 +713,63 @@ class Application_Model_ShowInstance {
|
||||||
*/
|
*/
|
||||||
|
|
||||||
$sql = "SELECT si.id"
|
$sql = "SELECT si.id"
|
||||||
." FROM $CC_CONFIG[showInstances] si"
|
." FROM $CC_CONFIG[showInstances] si"
|
||||||
." WHERE si.starts <= TIMESTAMP '$p_timeNow'"
|
." WHERE si.starts <= TIMESTAMP '$p_timeNow'"
|
||||||
." AND si.ends > TIMESTAMP '$p_timeNow'"
|
." AND si.ends > TIMESTAMP '$p_timeNow'"
|
||||||
." AND si.modified_instance = 'f'"
|
." AND si.modified_instance = 'f'"
|
||||||
." ORDER BY si.starts DESC"
|
." ORDER BY si.starts DESC"
|
||||||
." LIMIT 1";
|
." LIMIT 1";
|
||||||
|
|
||||||
$id = $CC_DBC->GetOne($sql);
|
$id = $con->query($sql)->fetchColumn(0);
|
||||||
if (is_null($id)){
|
if ($id) {
|
||||||
return null;
|
|
||||||
} else {
|
|
||||||
return new Application_Model_ShowInstance($id);
|
return new Application_Model_ShowInstance($id);
|
||||||
|
} else {
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function GetNextShowInstance($p_timeNow){
|
public static function GetNextShowInstance($p_timeNow)
|
||||||
global $CC_CONFIG, $CC_DBC;
|
{
|
||||||
|
global $CC_CONFIG;
|
||||||
|
$con = Propel::getConnection();
|
||||||
|
|
||||||
$sql = "SELECT si.id"
|
$sql = "SELECT si.id"
|
||||||
." FROM $CC_CONFIG[showInstances] si"
|
." FROM $CC_CONFIG[showInstances] si"
|
||||||
." WHERE si.starts > TIMESTAMP '$p_timeNow'"
|
." WHERE si.starts > TIMESTAMP '$p_timeNow'"
|
||||||
." AND si.modified_instance = 'f'"
|
." AND si.modified_instance = 'f'"
|
||||||
." ORDER BY si.starts"
|
." ORDER BY si.starts"
|
||||||
." LIMIT 1";
|
." LIMIT 1";
|
||||||
|
|
||||||
$id = $CC_DBC->GetOne($sql);
|
$id = $con->query($sql)->fetchColumn(0);
|
||||||
if (is_null($id)){
|
if ($id) {
|
||||||
return null;
|
|
||||||
} else {
|
|
||||||
return new Application_Model_ShowInstance($id);
|
return new Application_Model_ShowInstance($id);
|
||||||
|
} else {
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// returns number of show instances that ends later than $day
|
// returns number of show instances that ends later than $day
|
||||||
public static function GetShowInstanceCount($day){
|
public static function GetShowInstanceCount($day)
|
||||||
global $CC_CONFIG, $CC_DBC;
|
{
|
||||||
|
global $CC_CONFIG;
|
||||||
|
$con = Propel::getConnection();
|
||||||
$sql = "SELECT count(*) as cnt FROM $CC_CONFIG[showInstances] WHERE ends < '$day'";
|
$sql = "SELECT count(*) as cnt FROM $CC_CONFIG[showInstances] WHERE ends < '$day'";
|
||||||
return $CC_DBC->GetOne($sql);
|
return $con->query($sql)->fetchColumn(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
// this returns end timestamp of all shows that are in the range and has live DJ set up
|
// this returns end timestamp of all shows that are in the range and has live DJ set up
|
||||||
public static function GetEndTimeOfNextShowWithLiveDJ($p_startTime, $p_endTime){
|
public static function GetEndTimeOfNextShowWithLiveDJ($p_startTime, $p_endTime)
|
||||||
global $CC_CONFIG, $CC_DBC;
|
{
|
||||||
|
global $CC_CONFIG;
|
||||||
|
$con = Propel::getConnection();
|
||||||
|
|
||||||
$sql = "SELECT ends
|
$sql = "SELECT ends
|
||||||
FROM cc_show_instances as si
|
FROM cc_show_instances as si
|
||||||
JOIN cc_show as sh ON si.show_id = sh.id
|
JOIN cc_show as sh ON si.show_id = sh.id
|
||||||
WHERE si.ends > '$p_startTime' and si.ends < '$p_endTime' and (sh.live_stream_using_airtime_auth or live_stream_using_custom_auth)
|
WHERE si.ends > '$p_startTime' and si.ends < '$p_endTime' and (sh.live_stream_using_airtime_auth or live_stream_using_custom_auth)
|
||||||
ORDER BY si.ends";
|
ORDER BY si.ends";
|
||||||
|
|
||||||
return $CC_DBC->GetAll($sql);
|
return $con->query($sql)->fetchAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
function isRepeating(){
|
function isRepeating(){
|
||||||
|
|
|
@ -242,16 +242,14 @@ class Application_Model_StoredFile {
|
||||||
*/
|
*/
|
||||||
public function setState($p_state, $p_editedby=NULL)
|
public function setState($p_state, $p_editedby=NULL)
|
||||||
{
|
{
|
||||||
global $CC_CONFIG, $CC_DBC;
|
global $CC_CONFIG;
|
||||||
|
$con = Propel::getConnection();
|
||||||
$escapedState = pg_escape_string($p_state);
|
$escapedState = pg_escape_string($p_state);
|
||||||
$eb = (!is_null($p_editedby) ? ", editedBy=$p_editedby" : '');
|
$eb = (!is_null($p_editedby) ? ", editedBy=$p_editedby" : '');
|
||||||
$sql = "UPDATE ".$CC_CONFIG['filesTable']
|
$sql = "UPDATE ".$CC_CONFIG['filesTable']
|
||||||
." SET state='$escapedState'$eb, mtime=now()"
|
." SET state='$escapedState'$eb, mtime=now()"
|
||||||
." WHERE gunid='{$this->gunid}'";
|
." WHERE gunid='{$this->gunid}'";
|
||||||
$res = $CC_DBC->query($sql);
|
$res = $con->exec($sql);
|
||||||
if (PEAR::isError($res)) {
|
|
||||||
return $res;
|
|
||||||
}
|
|
||||||
$this->state = $p_state;
|
$this->state = $p_state;
|
||||||
$this->editedby = $p_editedby;
|
$this->editedby = $p_editedby;
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
@ -262,11 +260,12 @@ class Application_Model_StoredFile {
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
public function getPlaylists() {
|
public function getPlaylists() {
|
||||||
global $CC_CONFIG, $CC_DBC;
|
global $CC_CONFIG;
|
||||||
|
$con = Propel::getConnection();
|
||||||
$sql = "SELECT playlist_id "
|
$sql = "SELECT playlist_id "
|
||||||
." FROM ".$CC_CONFIG['playistTable']
|
." FROM ".$CC_CONFIG['playistTable']
|
||||||
." WHERE file_id='{$this->id}'";
|
." WHERE file_id='{$this->id}'";
|
||||||
$ids = $CC_DBC->getAll($sql);
|
$ids = $con->query($sql)->fetchAll();
|
||||||
$playlists = array();
|
$playlists = array();
|
||||||
if (is_array($ids) && count($ids) > 0) {
|
if (is_array($ids) && count($ids) > 0) {
|
||||||
foreach ($ids as $id) {
|
foreach ($ids as $id) {
|
||||||
|
@ -583,7 +582,7 @@ Logging::log("getting media! - 2");
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function searchLibraryFiles($datatables) {
|
public static function searchLibraryFiles($datatables) {
|
||||||
|
|
||||||
$con = Propel::getConnection(CcFilesPeer::DATABASE_NAME);
|
$con = Propel::getConnection(CcFilesPeer::DATABASE_NAME);
|
||||||
|
|
||||||
$displayColumns = array("id", "track_title", "artist_name", "album_title", "genre", "length",
|
$displayColumns = array("id", "track_title", "artist_name", "album_title", "genre", "length",
|
||||||
|
@ -656,7 +655,7 @@ Logging::log("getting media! - 2");
|
||||||
default:
|
default:
|
||||||
$fromTable = $unionTable;
|
$fromTable = $unionTable;
|
||||||
}
|
}
|
||||||
|
|
||||||
$results = Application_Model_Datatables::findEntries($con, $displayColumns, $fromTable, $datatables);
|
$results = Application_Model_Datatables::findEntries($con, $displayColumns, $fromTable, $datatables);
|
||||||
|
|
||||||
//Used by the audio preview functionality in the library.
|
//Used by the audio preview functionality in the library.
|
||||||
|
@ -803,7 +802,7 @@ Logging::log("getting media! - 2");
|
||||||
//check to see if we have enough space in the /organize directory to copy the file
|
//check to see if we have enough space in the /organize directory to copy the file
|
||||||
$freeSpace = disk_free_space($destination_folder);
|
$freeSpace = disk_free_space($destination_folder);
|
||||||
$fileSize = filesize($audio_file);
|
$fileSize = filesize($audio_file);
|
||||||
|
|
||||||
if ( $freeSpace < $fileSize){
|
if ( $freeSpace < $fileSize){
|
||||||
$freeSpace = ceil($freeSpace/1024/1024);
|
$freeSpace = ceil($freeSpace/1024/1024);
|
||||||
$fileSize = ceil($fileSize/1024/1024);
|
$fileSize = ceil($fileSize/1024/1024);
|
||||||
|
@ -820,6 +819,7 @@ Logging::log("getting media! - 2");
|
||||||
$md5 = md5_file($audio_file);
|
$md5 = md5_file($audio_file);
|
||||||
$duplicate = Application_Model_StoredFile::RecallByMd5($md5, true);
|
$duplicate = Application_Model_StoredFile::RecallByMd5($md5, true);
|
||||||
|
|
||||||
|
|
||||||
$result = null;
|
$result = null;
|
||||||
if ($duplicate) {
|
if ($duplicate) {
|
||||||
if (PEAR::isError($duplicate)) {
|
if (PEAR::isError($duplicate)) {
|
||||||
|
@ -865,9 +865,11 @@ Logging::log("getting media! - 2");
|
||||||
|
|
||||||
public static function getFileCount()
|
public static function getFileCount()
|
||||||
{
|
{
|
||||||
global $CC_CONFIG, $CC_DBC;
|
global $CC_CONFIG;
|
||||||
|
$con = Propel::getConnection();
|
||||||
|
|
||||||
$sql = "SELECT count(*) as cnt FROM ".$CC_CONFIG["filesTable"]." WHERE file_exists";
|
$sql = "SELECT count(*) as cnt FROM ".$CC_CONFIG["filesTable"]." WHERE file_exists";
|
||||||
return $CC_DBC->GetOne($sql);
|
return $con->query($sql)->fetchColumn(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -876,26 +878,27 @@ Logging::log("getting media! - 2");
|
||||||
* @param $dir_id - if this is not provided, it returns all files with full path constructed.
|
* @param $dir_id - if this is not provided, it returns all files with full path constructed.
|
||||||
* @param $propelObj - if this is true, it returns array of proepl obj
|
* @param $propelObj - if this is true, it returns array of proepl obj
|
||||||
*/
|
*/
|
||||||
public static function listAllFiles($dir_id=null, $propelObj=false){
|
public static function listAllFiles($dir_id=null, $propelObj=false)
|
||||||
global $CC_DBC;
|
{
|
||||||
|
$con = Propel::getConnection();
|
||||||
|
|
||||||
if($propelObj){
|
if ($propelObj) {
|
||||||
$sql = "SELECT m.directory || f.filepath as fp"
|
$sql = "SELECT m.directory || f.filepath as fp"
|
||||||
." FROM CC_MUSIC_DIRS m"
|
." FROM CC_MUSIC_DIRS m"
|
||||||
." LEFT JOIN CC_FILES f"
|
." LEFT JOIN CC_FILES f"
|
||||||
." ON m.id = f.directory WHERE m.id = $dir_id and f.file_exists = 'TRUE'";
|
." ON m.id = f.directory WHERE m.id = $dir_id and f.file_exists = 'TRUE'";
|
||||||
}else{
|
} else {
|
||||||
$sql = "SELECT filepath as fp"
|
$sql = "SELECT filepath as fp"
|
||||||
." FROM CC_FILES"
|
." FROM CC_FILES"
|
||||||
." WHERE directory = $dir_id and file_exists = 'TRUE'";
|
." WHERE directory = $dir_id and file_exists = 'TRUE'";
|
||||||
}
|
}
|
||||||
$rows = $CC_DBC->getAll($sql);
|
$rows = $con->query($sql)->fetchAll();
|
||||||
|
|
||||||
$results = array();
|
$results = array();
|
||||||
foreach ($rows as $row){
|
foreach ($rows as $row) {
|
||||||
if($propelObj){
|
if ($propelObj) {
|
||||||
$results[] = Application_Model_StoredFile::RecallByFilepath($row["fp"]);
|
$results[] = Application_Model_StoredFile::RecallByFilepath($row["fp"]);
|
||||||
}else{
|
} else {
|
||||||
$results[] = $row["fp"];
|
$results[] = $row["fp"];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,19 +1,21 @@
|
||||||
<?php
|
<?php
|
||||||
class Application_Model_StreamSetting {
|
class Application_Model_StreamSetting {
|
||||||
|
|
||||||
public static function SetValue($key, $value, $type){
|
public static function SetValue($key, $value, $type)
|
||||||
global $CC_CONFIG, $CC_DBC;
|
{
|
||||||
|
global $CC_CONFIG;
|
||||||
|
$con = Propel::getConnection();
|
||||||
|
|
||||||
$key = pg_escape_string($key);
|
$key = pg_escape_string($key);
|
||||||
$value = pg_escape_string($value);
|
$value = pg_escape_string($value);
|
||||||
|
|
||||||
//Check if key already exists
|
// Check if key already exists
|
||||||
$sql = "SELECT COUNT(*) FROM cc_stream_setting"
|
$sql = "SELECT COUNT(*) FROM cc_stream_setting"
|
||||||
." WHERE keyname = '$key'";
|
." WHERE keyname = '$key'";
|
||||||
|
|
||||||
$result = $CC_DBC->GetOne($sql);
|
|
||||||
|
|
||||||
if($result == 1) {
|
$result = $con->query($sql)->fetchColumn(0);
|
||||||
|
|
||||||
|
if ($result == 1) {
|
||||||
$sql = "UPDATE cc_stream_setting"
|
$sql = "UPDATE cc_stream_setting"
|
||||||
." SET value = '$value', type='$type'"
|
." SET value = '$value', type='$type'"
|
||||||
." WHERE keyname = '$key'";
|
." WHERE keyname = '$key'";
|
||||||
|
@ -21,139 +23,146 @@ class Application_Model_StreamSetting {
|
||||||
$sql = "INSERT INTO cc_stream_setting (keyname, value, type)"
|
$sql = "INSERT INTO cc_stream_setting (keyname, value, type)"
|
||||||
." VALUES ('$key', '$value', '$type')";
|
." VALUES ('$key', '$value', '$type')";
|
||||||
}
|
}
|
||||||
|
|
||||||
return $CC_DBC->query($sql);
|
return $con->exec($sql);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function GetValue($key){
|
public static function GetValue($key)
|
||||||
global $CC_CONFIG, $CC_DBC;
|
{
|
||||||
|
global $CC_CONFIG;
|
||||||
|
$con = Propel::getConnection();
|
||||||
|
|
||||||
//Check if key already exists
|
//Check if key already exists
|
||||||
$sql = "SELECT COUNT(*) FROM cc_stream_setting"
|
$sql = "SELECT COUNT(*) FROM cc_stream_setting"
|
||||||
." WHERE keyname = '$key'";
|
." WHERE keyname = '$key'";
|
||||||
$result = $CC_DBC->GetOne($sql);
|
$result = $con->query($sql)->fetchColumn(0);
|
||||||
|
|
||||||
if ($result == 0)
|
if ($result == 0)
|
||||||
return "";
|
return "";
|
||||||
else {
|
else {
|
||||||
$sql = "SELECT value FROM cc_stream_setting"
|
$sql = "SELECT value FROM cc_stream_setting"
|
||||||
." WHERE keyname = '$key'";
|
." WHERE keyname = '$key'";
|
||||||
|
|
||||||
$result = $CC_DBC->GetOne($sql);
|
$result = $con->query($sql)->fetchColumn(0);
|
||||||
return $result;
|
return $result ? $result : NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Returns the id's of all streams that are enabled in an array. An
|
/* Returns the id's of all streams that are enabled in an array. An
|
||||||
* example of the array returned in JSON notation is ["s1", "s2", "s3"] */
|
* example of the array returned in JSON notation is ["s1", "s2", "s3"] */
|
||||||
public static function getEnabledStreamIds(){
|
public static function getEnabledStreamIds()
|
||||||
global $CC_DBC;
|
{
|
||||||
|
$con = Propel::getConnection();
|
||||||
$sql = "SELECT * "
|
$sql = "SELECT * "
|
||||||
."FROM cc_stream_setting "
|
."FROM cc_stream_setting "
|
||||||
."WHERE keyname LIKE '%_enable' "
|
."WHERE keyname LIKE '%_enable' "
|
||||||
."AND value='true'";
|
."AND value='true'";
|
||||||
|
|
||||||
$rows = $CC_DBC->getAll($sql);
|
$rows = $con->query($sql)->fetchAll();
|
||||||
$ids = array();
|
$ids = array();
|
||||||
|
|
||||||
foreach ($rows as $row){
|
foreach ($rows as $row) {
|
||||||
$ids[] = substr($row["keyname"], 0, strpos($row["keyname"], "_"));
|
$ids[] = substr($row["keyname"], 0, strpos($row["keyname"], "_"));
|
||||||
}
|
}
|
||||||
|
|
||||||
//Logging::log(print_r($ids, true));
|
//Logging::log(print_r($ids, true));
|
||||||
|
|
||||||
return $ids;
|
return $ids;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Retruns only global data as array*/
|
|
||||||
public static function getGlobalData(){
|
|
||||||
global $CC_DBC;
|
|
||||||
$sql = "SELECT * "
|
|
||||||
."FROM cc_stream_setting "
|
|
||||||
."WHERE keyname IN ('output_sound_device', 'icecast_vorbis_metadata')";
|
|
||||||
|
|
||||||
$rows = $CC_DBC->getAll($sql);
|
|
||||||
$data = array();
|
|
||||||
|
|
||||||
foreach($rows as $row){
|
|
||||||
$data[$row["keyname"]] = $row["value"];
|
|
||||||
}
|
|
||||||
|
|
||||||
return $data;
|
|
||||||
}
|
|
||||||
/* Returns all information related to a specific stream. An example
|
|
||||||
* of a stream id is 's1' or 's2'. */
|
|
||||||
public static function getStreamData($p_streamId){
|
|
||||||
global $CC_DBC;
|
|
||||||
$sql = "SELECT * "
|
|
||||||
."FROM cc_stream_setting "
|
|
||||||
."WHERE keyname LIKE '${p_streamId}_%'";
|
|
||||||
|
|
||||||
$rows = $CC_DBC->getAll($sql);
|
/* Returns only global data as array*/
|
||||||
|
public static function getGlobalData()
|
||||||
|
{
|
||||||
|
$con = Propel::getConnection();
|
||||||
|
$sql = "SELECT * "
|
||||||
|
."FROM cc_stream_setting "
|
||||||
|
."WHERE keyname IN ('output_sound_device', 'icecast_vorbis_metadata')";
|
||||||
|
|
||||||
|
$rows = $con->query($sql)->fetchAll();
|
||||||
$data = array();
|
$data = array();
|
||||||
|
|
||||||
foreach($rows as $row){
|
foreach ($rows as $row) {
|
||||||
$data[$row["keyname"]] = $row["value"];
|
$data[$row["keyname"]] = $row["value"];
|
||||||
}
|
}
|
||||||
|
|
||||||
return $data;
|
return $data;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function getStreamSetting(){
|
/* Returns all information related to a specific stream. An example
|
||||||
global $CC_DBC;
|
* of a stream id is 's1' or 's2'. */
|
||||||
|
public static function getStreamData($p_streamId)
|
||||||
|
{
|
||||||
|
$con = Propel::getConnection();
|
||||||
|
$sql = "SELECT * "
|
||||||
|
."FROM cc_stream_setting "
|
||||||
|
."WHERE keyname LIKE '${p_streamId}_%'";
|
||||||
|
|
||||||
|
$rows = $con->query($sql)->fetchAll();
|
||||||
|
$data = array();
|
||||||
|
|
||||||
|
foreach ($rows as $row) {
|
||||||
|
$data[$row["keyname"]] = $row["value"];
|
||||||
|
}
|
||||||
|
|
||||||
|
return $data;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function getStreamSetting()
|
||||||
|
{
|
||||||
|
$con = Propel::getConnection();
|
||||||
$sql = "SELECT *"
|
$sql = "SELECT *"
|
||||||
." FROM cc_stream_setting"
|
." FROM cc_stream_setting"
|
||||||
." WHERE keyname not like '%_error'";
|
." WHERE keyname not like '%_error'";
|
||||||
|
|
||||||
$rows = $CC_DBC->getAll($sql);
|
$rows = $con->query($sql)->fetchAll();
|
||||||
|
|
||||||
$exists = array();
|
$exists = array();
|
||||||
|
|
||||||
foreach($rows as $r){
|
foreach ($rows as $r) {
|
||||||
if($r['keyname'] == 'master_live_stream_port'){
|
if ($r['keyname'] == 'master_live_stream_port') {
|
||||||
$exists['master_live_stream_port'] = true;
|
$exists['master_live_stream_port'] = true;
|
||||||
}elseif($r['keyname'] == 'master_live_stream_mp'){
|
} elseif($r['keyname'] == 'master_live_stream_mp') {
|
||||||
$exists['master_live_stream_mp'] = true;
|
$exists['master_live_stream_mp'] = true;
|
||||||
}elseif($r['keyname'] == 'dj_live_stream_port'){
|
} elseif($r['keyname'] == 'dj_live_stream_port') {
|
||||||
$exists['dj_live_stream_port'] = true;
|
$exists['dj_live_stream_port'] = true;
|
||||||
}elseif($r['keyname'] == 'dj_live_stream_mp'){
|
} elseif($r['keyname'] == 'dj_live_stream_mp') {
|
||||||
$exists['dj_live_stream_mp'] = true;
|
$exists['dj_live_stream_mp'] = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!isset($exists["master_live_stream_port"])){
|
if (!isset($exists["master_live_stream_port"])) {
|
||||||
$rows[] = (array("keyname" =>"master_live_stream_port", "value"=>self::GetMasterLiveSteamPort(), "type"=>"integer"));
|
$rows[] = (array("keyname" =>"master_live_stream_port", "value"=>self::GetMasterLiveSteamPort(), "type"=>"integer"));
|
||||||
}
|
}
|
||||||
if(!isset($exists["master_live_stream_mp"])){
|
if (!isset($exists["master_live_stream_mp"])) {
|
||||||
$rows[] = (array("keyname" =>"master_live_stream_mp", "value"=>self::GetMasterLiveSteamMountPoint(), "type"=>"string"));
|
$rows[] = (array("keyname" =>"master_live_stream_mp", "value"=>self::GetMasterLiveSteamMountPoint(), "type"=>"string"));
|
||||||
}
|
}
|
||||||
if(!isset($exists["dj_live_stream_port"])){
|
if (!isset($exists["dj_live_stream_port"])) {
|
||||||
$rows[] = (array("keyname" =>"dj_live_stream_port", "value"=>self::GetDJLiveSteamPort(), "type"=>"integer"));
|
$rows[] = (array("keyname" =>"dj_live_stream_port", "value"=>self::GetDJLiveSteamPort(), "type"=>"integer"));
|
||||||
}
|
}
|
||||||
if(!isset($exists["dj_live_stream_mp"])){
|
if (!isset($exists["dj_live_stream_mp"])) {
|
||||||
$rows[] = (array("keyname" =>"dj_live_stream_mp", "value"=>self::GetDJLiveSteamMountPoint(), "type"=>"string"));
|
$rows[] = (array("keyname" =>"dj_live_stream_mp", "value"=>self::GetDJLiveSteamMountPoint(), "type"=>"string"));
|
||||||
}
|
}
|
||||||
return $rows;
|
return $rows;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* function that take all the information of stream and sets them.
|
* function that take all the information of stream and sets them.
|
||||||
* This is used by stream setting via UI.
|
* This is used by stream setting via UI.
|
||||||
*
|
*
|
||||||
* @param $data - array that contains all the data. $data is [][] which
|
* @param $data - array that contains all the data. $data is [][] which
|
||||||
* contains multiple stream information
|
* contains multiple stream information
|
||||||
*/
|
*/
|
||||||
public static function setStreamSetting($data){
|
public static function setStreamSetting($data)
|
||||||
global $CC_DBC;
|
{
|
||||||
|
$con = Propel::getConnection();
|
||||||
|
|
||||||
foreach ($data as $key=>$d) {
|
foreach ($data as $key=>$d) {
|
||||||
if ($key == "output_sound_device" || $key == "icecast_vorbis_metadata") {
|
if ($key == "output_sound_device" || $key == "icecast_vorbis_metadata") {
|
||||||
$v = $d == 1?"true":"false";
|
$v = $d == 1?"true":"false";
|
||||||
$sql = "UPDATE cc_stream_setting SET value='$v' WHERE keyname='$key'";
|
$sql = "UPDATE cc_stream_setting SET value='$v' WHERE keyname='$key'";
|
||||||
$CC_DBC->query($sql);
|
$con->exec($sql);
|
||||||
} else if ($key == "output_sound_device_type") {
|
} else if ($key == "output_sound_device_type") {
|
||||||
$sql = "UPDATE cc_stream_setting SET value='$d' WHERE keyname='$key'";
|
$sql = "UPDATE cc_stream_setting SET value='$d' WHERE keyname='$key'";
|
||||||
$CC_DBC->query($sql);
|
$con->exec($sql);
|
||||||
} else if (is_array($d)) {
|
} else if (is_array($d)) {
|
||||||
$temp = explode('_', $key);
|
$temp = explode('_', $key);
|
||||||
$prefix = $temp[0];
|
$prefix = $temp[0];
|
||||||
|
@ -164,71 +173,75 @@ class Application_Model_StreamSetting {
|
||||||
}
|
}
|
||||||
$v = trim($v);
|
$v = trim($v);
|
||||||
$sql = "UPDATE cc_stream_setting SET value='$v' WHERE keyname='$keyname'";
|
$sql = "UPDATE cc_stream_setting SET value='$v' WHERE keyname='$keyname'";
|
||||||
$CC_DBC->query($sql);
|
$con->exec($sql);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Logging::log("Warning unexpected value: ".$key);
|
Logging::log("Warning unexpected value: ".$key);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Sets indivisual stream setting.
|
* Sets indivisual stream setting.
|
||||||
*
|
*
|
||||||
* $data - data array. $data is [].
|
* $data - data array. $data is [].
|
||||||
*/
|
*/
|
||||||
public static function setIndivisualStreamSetting($data){
|
public static function setIndivisualStreamSetting($data)
|
||||||
global $CC_DBC;
|
{
|
||||||
|
$con = Propel::getConnection();
|
||||||
foreach($data as $keyname => $v){
|
|
||||||
|
foreach ($data as $keyname => $v) {
|
||||||
$sql = "UPDATE cc_stream_setting SET value='$v' WHERE keyname='$keyname'";
|
$sql = "UPDATE cc_stream_setting SET value='$v' WHERE keyname='$keyname'";
|
||||||
$CC_DBC->query($sql);
|
$con->exec($sql);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Stores liquidsoap status if $boot_time > save time.
|
* Stores liquidsoap status if $boot_time > save time.
|
||||||
* save time is the time that user clicked save on stream setting page
|
* save time is the time that user clicked save on stream setting page
|
||||||
*/
|
*/
|
||||||
public static function setLiquidsoapError($stream_id, $msg, $boot_time=null){
|
public static function setLiquidsoapError($stream_id, $msg, $boot_time=null)
|
||||||
global $CC_DBC;
|
{
|
||||||
|
$con = Propel::getConnection();
|
||||||
|
|
||||||
$update_time = Application_Model_Preference::GetStreamUpdateTimestemp();
|
$update_time = Application_Model_Preference::GetStreamUpdateTimestemp();
|
||||||
if($boot_time == null || $boot_time > $update_time ){
|
if ($boot_time == null || $boot_time > $update_time) {
|
||||||
$keyname = "s".$stream_id."_liquidsoap_error";
|
$keyname = "s".$stream_id."_liquidsoap_error";
|
||||||
$sql = "SELECT COUNT(*) FROM cc_stream_setting"
|
$sql = "SELECT COUNT(*) FROM cc_stream_setting"
|
||||||
." WHERE keyname = '$keyname'";
|
." WHERE keyname = '$keyname'";
|
||||||
$result = $CC_DBC->GetOne($sql);
|
$result = $con->query($sql)->fetchColumn(0);
|
||||||
if ($result == 1){
|
if ($result == 1) {
|
||||||
$sql = "UPDATE cc_stream_setting"
|
$sql = "UPDATE cc_stream_setting"
|
||||||
." SET value = '$msg'"
|
." SET value = '$msg'"
|
||||||
." WHERE keyname = '$keyname'";
|
." WHERE keyname = '$keyname'";
|
||||||
}else{
|
} else {
|
||||||
$sql = "INSERT INTO cc_stream_setting (keyname, value, type)"
|
$sql = "INSERT INTO cc_stream_setting (keyname, value, type)"
|
||||||
." VALUES ('$keyname', '$msg', 'string')";
|
." VALUES ('$keyname', '$msg', 'string')";
|
||||||
}
|
}
|
||||||
$res = $CC_DBC->query($sql);
|
$res = $con->exec($sql);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function getLiquidsoapError($stream_id){
|
public static function getLiquidsoapError($stream_id)
|
||||||
global $CC_DBC;
|
{
|
||||||
|
$con = Propel::getConnection();
|
||||||
|
|
||||||
$keyname = "s".$stream_id."_liquidsoap_error";
|
$keyname = "s".$stream_id."_liquidsoap_error";
|
||||||
$sql = "SELECT value FROM cc_stream_setting"
|
$sql = "SELECT value FROM cc_stream_setting"
|
||||||
." WHERE keyname = '$keyname'";
|
." WHERE keyname = '$keyname'";
|
||||||
$result = $CC_DBC->GetOne($sql);
|
$result = $con->query($sql)->fetchColumn(0);
|
||||||
|
|
||||||
return $result;
|
return $result ? $result : NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function getStreamEnabled($stream_id){
|
public static function getStreamEnabled($stream_id)
|
||||||
global $CC_DBC;
|
{
|
||||||
|
$con = Propel::getConnection();
|
||||||
|
|
||||||
$keyname = "s" . $stream_id . "_enable";
|
$keyname = "s" . $stream_id . "_enable";
|
||||||
$sql = "SELECT value FROM cc_stream_setting"
|
$sql = "SELECT value FROM cc_stream_setting"
|
||||||
." WHERE keyname = '$keyname'";
|
." WHERE keyname = '$keyname'";
|
||||||
$result = $CC_DBC->GetOne($sql);
|
$result = $con->query($sql)->fetchColumn(0);
|
||||||
if ($result == 'false') {
|
if ($result == 'false') {
|
||||||
$result = false;
|
$result = false;
|
||||||
} else {
|
} else {
|
||||||
|
@ -236,62 +249,63 @@ class Application_Model_StreamSetting {
|
||||||
}
|
}
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Only returns info that is needed for data collection
|
* Only returns info that is needed for data collection
|
||||||
* returns array('s1'=>array(keyname=>value))
|
* returns array('s1'=>array(keyname=>value))
|
||||||
*/
|
*/
|
||||||
public static function getStreamInfoForDataCollection(){
|
public static function getStreamInfoForDataCollection()
|
||||||
global $CC_DBC;
|
{
|
||||||
|
$con = Propel::getConnection();
|
||||||
|
|
||||||
$out = array();
|
$out = array();
|
||||||
$enabled_stream = self::getEnabledStreamIds();
|
$enabled_stream = self::getEnabledStreamIds();
|
||||||
|
|
||||||
foreach($enabled_stream as $stream){
|
foreach ($enabled_stream as $stream) {
|
||||||
$keys = "'".$stream."_output', "."'".$stream."_type', "."'".$stream."_bitrate', "."'".$stream."_host'";
|
$keys = "'".$stream."_output', "."'".$stream."_type', "."'".$stream."_bitrate', "."'".$stream."_host'";
|
||||||
|
|
||||||
$sql = "SELECT keyname, value FROM cc_stream_setting"
|
$sql = "SELECT keyname, value FROM cc_stream_setting"
|
||||||
." WHERE keyname IN ($keys)";
|
." WHERE keyname IN ($keys)";
|
||||||
|
|
||||||
$rows = $CC_DBC->getAll($sql);
|
$rows = $con->query($sql)->fetchAll();
|
||||||
$info = array();
|
$info = array();
|
||||||
foreach($rows as $r){
|
foreach ($rows as $r) {
|
||||||
$temp = explode("_", $r['keyname']);
|
$temp = explode("_", $r['keyname']);
|
||||||
$info[$temp[1]] = $r['value'];
|
$info[$temp[1]] = $r['value'];
|
||||||
$out[$stream] = $info;
|
$out[$stream] = $info;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return $out;
|
return $out;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function SetMasterLiveSteamPort($value){
|
public static function SetMasterLiveSteamPort($value){
|
||||||
self::SetValue("master_live_stream_port", $value, "integer");
|
self::SetValue("master_live_stream_port", $value, "integer");
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function GetMasterLiveSteamPort(){
|
public static function GetMasterLiveSteamPort(){
|
||||||
return self::GetValue("master_live_stream_port");
|
return self::GetValue("master_live_stream_port");
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function SetMasterLiveSteamMountPoint($value){
|
public static function SetMasterLiveSteamMountPoint($value){
|
||||||
self::SetValue("master_live_stream_mp", $value, "string");
|
self::SetValue("master_live_stream_mp", $value, "string");
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function GetMasterLiveSteamMountPoint(){
|
public static function GetMasterLiveSteamMountPoint(){
|
||||||
return self::GetValue("master_live_stream_mp");
|
return self::GetValue("master_live_stream_mp");
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function SetDJLiveSteamPort($value){
|
public static function SetDJLiveSteamPort($value){
|
||||||
self::SetValue("dj_live_stream_port", $value, "integer");
|
self::SetValue("dj_live_stream_port", $value, "integer");
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function GetDJLiveSteamPort(){
|
public static function GetDJLiveSteamPort(){
|
||||||
return self::GetValue("dj_live_stream_port");
|
return self::GetValue("dj_live_stream_port");
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function SetDJLiveSteamMountPoint($value){
|
public static function SetDJLiveSteamMountPoint($value){
|
||||||
self::SetValue("dj_live_stream_mp", $value, "string");
|
self::SetValue("dj_live_stream_mp", $value, "string");
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function GetDJLiveSteamMountPoint(){
|
public static function GetDJLiveSteamMountPoint(){
|
||||||
return self::GetValue("dj_live_stream_mp");
|
return self::GetValue("dj_live_stream_mp");
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,16 +28,15 @@ class Application_Model_Subjects {
|
||||||
*/
|
*/
|
||||||
public static function Authenticate($login, $pass='')
|
public static function Authenticate($login, $pass='')
|
||||||
{
|
{
|
||||||
global $CC_CONFIG, $CC_DBC;
|
global $CC_CONFIG;
|
||||||
|
$con = Propel::getConnection();
|
||||||
$cpass = md5($pass);
|
$cpass = md5($pass);
|
||||||
$sql = "SELECT id FROM ".$CC_CONFIG['subjTable']
|
$sql = "SELECT id FROM ".$CC_CONFIG['subjTable']
|
||||||
." WHERE login='$login' AND pass='$cpass' AND type='U'";
|
." WHERE login='$login' AND pass='$cpass' AND type='U'"
|
||||||
$id = $CC_DBC->getOne($sql);
|
." LIMIT 1";
|
||||||
if (PEAR::isError($id)) {
|
$query = $con->query($sql)->fetchColumn(0);
|
||||||
return $id;
|
return $query;
|
||||||
}
|
}
|
||||||
return (is_null($id) ? FALSE : $id);
|
|
||||||
} // fn authenticate
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -54,7 +53,8 @@ class Application_Model_Subjects {
|
||||||
*/
|
*/
|
||||||
public static function Passwd($login, $oldpass=null, $pass='', $passenc=FALSE)
|
public static function Passwd($login, $oldpass=null, $pass='', $passenc=FALSE)
|
||||||
{
|
{
|
||||||
global $CC_CONFIG, $CC_DBC;
|
global $CC_CONFIG;
|
||||||
|
$con = Propel::getConnection();
|
||||||
if (!$passenc) {
|
if (!$passenc) {
|
||||||
$cpass = md5($pass);
|
$cpass = md5($pass);
|
||||||
} else {
|
} else {
|
||||||
|
@ -68,12 +68,9 @@ class Application_Model_Subjects {
|
||||||
}
|
}
|
||||||
$sql = "UPDATE ".$CC_CONFIG['subjTable']." SET pass='$cpass'"
|
$sql = "UPDATE ".$CC_CONFIG['subjTable']." SET pass='$cpass'"
|
||||||
." WHERE login='$login' $oldpCond AND type='U'";
|
." WHERE login='$login' $oldpCond AND type='U'";
|
||||||
$r = $CC_DBC->query($sql);
|
$con->exec($sql);
|
||||||
if (PEAR::isError($r)) {
|
|
||||||
return $r;
|
|
||||||
}
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
} // fn passwd
|
}
|
||||||
|
|
||||||
|
|
||||||
/* --------------------------------------------------------------- groups */
|
/* --------------------------------------------------------------- groups */
|
||||||
|
@ -84,20 +81,21 @@ class Application_Model_Subjects {
|
||||||
* Get subject id from login
|
* Get subject id from login
|
||||||
*
|
*
|
||||||
* @param string $login
|
* @param string $login
|
||||||
* @return int|PEAR_Error
|
* @return int|false
|
||||||
*/
|
*/
|
||||||
public static function GetSubjId($login)
|
public static function GetSubjId($login)
|
||||||
{
|
{
|
||||||
global $CC_CONFIG;
|
global $CC_CONFIG;
|
||||||
global $CC_DBC;
|
$con = Propel::getConnection();
|
||||||
$sql = "SELECT id FROM ".$CC_CONFIG['subjTable']
|
$sql = "SELECT id FROM ".$CC_CONFIG['subjTable']
|
||||||
." WHERE login='$login'";
|
." WHERE login='$login'";
|
||||||
return $CC_DBC->getOne($sql);
|
$query = $con->query($sql)->fetchColumn(0);
|
||||||
} // fn getSubjId
|
return $query ? $query : NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return true if uid is [id]direct member of gid
|
* Return true if uid is direct member of gid
|
||||||
*
|
*
|
||||||
* @param int $uid
|
* @param int $uid
|
||||||
* local user id
|
* local user id
|
||||||
|
@ -107,47 +105,42 @@ class Application_Model_Subjects {
|
||||||
*/
|
*/
|
||||||
public static function IsMemberOf($uid, $gid)
|
public static function IsMemberOf($uid, $gid)
|
||||||
{
|
{
|
||||||
global $CC_CONFIG, $CC_DBC;
|
global $CC_CONFIG;
|
||||||
$sql = "SELECT count(*)as cnt"
|
$con = Propel::getConnection();
|
||||||
|
$sql = "SELECT count(*) as cnt"
|
||||||
." FROM ".$CC_CONFIG['smembTable']
|
." FROM ".$CC_CONFIG['smembTable']
|
||||||
." WHERE uid='$uid' AND gid='$gid'";
|
." WHERE uid='$uid' AND gid='$gid'";
|
||||||
$res = $CC_DBC->getOne($sql);
|
$res = $con->query($sql)->fetchColumn(0);
|
||||||
if (PEAR::isError($res)) {
|
|
||||||
return $res;
|
|
||||||
}
|
|
||||||
return (intval($res) > 0);
|
return (intval($res) > 0);
|
||||||
} // fn isMemberOf
|
}
|
||||||
|
|
||||||
public static function increaseLoginAttempts($login){
|
public static function increaseLoginAttempts($login)
|
||||||
global $CC_CONFIG, $CC_DBC;
|
{
|
||||||
|
global $CC_CONFIG;
|
||||||
|
$con = Propel::getConnection();
|
||||||
$sql = "UPDATE ".$CC_CONFIG['subjTable']." SET login_attempts = login_attempts+1"
|
$sql = "UPDATE ".$CC_CONFIG['subjTable']." SET login_attempts = login_attempts+1"
|
||||||
." WHERE login='$login'";
|
." WHERE login='$login'";
|
||||||
$res = $CC_DBC->query($sql);
|
$res = $con->exec($sql);
|
||||||
if (PEAR::isError($res)) {
|
|
||||||
return $res;
|
|
||||||
}
|
|
||||||
return (intval($res) > 0);
|
return (intval($res) > 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function resetLoginAttempts($login){
|
public static function resetLoginAttempts($login)
|
||||||
global $CC_CONFIG, $CC_DBC;
|
{
|
||||||
|
global $CC_CONFIG;
|
||||||
|
$con = Propel::getConnection();
|
||||||
$sql = "UPDATE ".$CC_CONFIG['subjTable']." SET login_attempts = '0'"
|
$sql = "UPDATE ".$CC_CONFIG['subjTable']." SET login_attempts = '0'"
|
||||||
." WHERE login='$login'";
|
." WHERE login='$login'";
|
||||||
$res = $CC_DBC->query($sql);
|
$res = $con->exec($sql);
|
||||||
if (PEAR::isError($res)) {
|
return TRUE;
|
||||||
return $res;
|
|
||||||
}
|
|
||||||
return (intval($res) > 0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function getLoginAttempts($login){
|
public static function getLoginAttempts($login)
|
||||||
global $CC_CONFIG, $CC_DBC;
|
{
|
||||||
|
global $CC_CONFIG;
|
||||||
|
$con = Propel::getConnection();
|
||||||
$sql = "SELECT login_attempts FROM ".$CC_CONFIG['subjTable']." WHERE login='$login'";
|
$sql = "SELECT login_attempts FROM ".$CC_CONFIG['subjTable']." WHERE login='$login'";
|
||||||
$res = $CC_DBC->getOne($sql);
|
$res = $con->query($sql)->fetchColumn(0);
|
||||||
if (PEAR::isError($res)) {
|
return $res ? $res : 0;
|
||||||
return $res;
|
|
||||||
}
|
|
||||||
return $res;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} // class Subjects
|
} // class Subjects
|
||||||
|
|
|
@ -26,7 +26,7 @@ class Application_Model_User {
|
||||||
public function getId() {
|
public function getId() {
|
||||||
return $this->_userInstance->getDbId();
|
return $this->_userInstance->getDbId();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function isGuest() {
|
public function isGuest() {
|
||||||
return $this->getType() == UTYPE_GUEST;
|
return $this->getType() == UTYPE_GUEST;
|
||||||
}
|
}
|
||||||
|
@ -34,7 +34,7 @@ class Application_Model_User {
|
||||||
public function isHost($showId) {
|
public function isHost($showId) {
|
||||||
return $this->isUserType(UTYPE_HOST, $showId);
|
return $this->isUserType(UTYPE_HOST, $showId);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function isPM() {
|
public function isPM() {
|
||||||
return $this->isUserType(UTYPE_PROGRAM_MANAGER);
|
return $this->isUserType(UTYPE_PROGRAM_MANAGER);
|
||||||
}
|
}
|
||||||
|
@ -185,15 +185,14 @@ class Application_Model_User {
|
||||||
return $user;
|
return $user;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function getUsers($type, $search=NULL) {
|
public static function getUsers($type, $search=NULL)
|
||||||
global $CC_DBC;
|
{
|
||||||
|
$con = Propel::getConnection();
|
||||||
$sql;
|
|
||||||
|
|
||||||
$sql_gen = "SELECT login AS value, login AS label, id as index FROM cc_subjs ";
|
$sql_gen = "SELECT login AS value, login AS label, id as index FROM cc_subjs ";
|
||||||
$sql = $sql_gen;
|
$sql = $sql_gen;
|
||||||
|
|
||||||
if(is_array($type)) {
|
if (is_array($type)) {
|
||||||
for($i=0; $i<count($type); $i++) {
|
for($i=0; $i<count($type); $i++) {
|
||||||
$type[$i] = "type = '{$type[$i]}'";
|
$type[$i] = "type = '{$type[$i]}'";
|
||||||
}
|
}
|
||||||
|
@ -205,7 +204,7 @@ class Application_Model_User {
|
||||||
|
|
||||||
$sql = $sql_gen ." WHERE (". $sql_type.") ";
|
$sql = $sql_gen ." WHERE (". $sql_type.") ";
|
||||||
|
|
||||||
if(!is_null($search)) {
|
if (!is_null($search)) {
|
||||||
$like = "login ILIKE '%{$search}%'";
|
$like = "login ILIKE '%{$search}%'";
|
||||||
|
|
||||||
$sql = $sql . " AND ".$like;
|
$sql = $sql . " AND ".$like;
|
||||||
|
@ -213,22 +212,20 @@ class Application_Model_User {
|
||||||
|
|
||||||
$sql = $sql ." ORDER BY login";
|
$sql = $sql ." ORDER BY login";
|
||||||
|
|
||||||
return $CC_DBC->GetAll($sql);
|
return $con->query($sql)->fetchAll();;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function getUserCount($type=NULL){
|
public static function getUserCount($type=NULL){
|
||||||
global $CC_DBC;
|
$con = Propel::getConnection();
|
||||||
|
$sql = '';
|
||||||
$sql;
|
|
||||||
|
|
||||||
$sql_gen = "SELECT count(*) AS cnt FROM cc_subjs ";
|
$sql_gen = "SELECT count(*) AS cnt FROM cc_subjs ";
|
||||||
|
|
||||||
if(!isset($type)){
|
if (!isset($type)) {
|
||||||
$sql = $sql_gen;
|
$sql = $sql_gen;
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
if(is_array($type)) {
|
if (is_array($type)) {
|
||||||
for($i=0; $i<count($type); $i++) {
|
for ($i=0; $i<count($type); $i++) {
|
||||||
$type[$i] = "type = '{$type[$i]}'";
|
$type[$i] = "type = '{$type[$i]}'";
|
||||||
}
|
}
|
||||||
$sql_type = join(" OR ", $type);
|
$sql_type = join(" OR ", $type);
|
||||||
|
@ -240,7 +237,8 @@ class Application_Model_User {
|
||||||
$sql = $sql_gen ." WHERE (". $sql_type.") ";
|
$sql = $sql_gen ." WHERE (". $sql_type.") ";
|
||||||
}
|
}
|
||||||
|
|
||||||
return $CC_DBC->GetOne($sql);
|
$query = $con->query($sql)->fetchColumn(0);
|
||||||
|
return $query ? $query : NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function getHosts($search=NULL) {
|
public static function getHosts($search=NULL) {
|
||||||
|
@ -248,7 +246,7 @@ class Application_Model_User {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function getUsersDataTablesInfo($datatables) {
|
public static function getUsersDataTablesInfo($datatables) {
|
||||||
|
|
||||||
$con = Propel::getConnection(CcSubjsPeer::DATABASE_NAME);
|
$con = Propel::getConnection(CcSubjsPeer::DATABASE_NAME);
|
||||||
|
|
||||||
$displayColumns = array("id", "login", "first_name", "last_name", "type");
|
$displayColumns = array("id", "login", "first_name", "last_name", "type");
|
||||||
|
@ -263,7 +261,7 @@ class Application_Model_User {
|
||||||
}
|
}
|
||||||
|
|
||||||
$res = Application_Model_Datatables::findEntries($con, $displayColumns, $fromTable, $datatables);
|
$res = Application_Model_Datatables::findEntries($con, $displayColumns, $fromTable, $datatables);
|
||||||
|
|
||||||
// mark record which is for the current user
|
// mark record which is for the current user
|
||||||
foreach($res['aaData'] as &$record){
|
foreach($res['aaData'] as &$record){
|
||||||
if($record['login'] == $username){
|
if($record['login'] == $username){
|
||||||
|
@ -277,13 +275,13 @@ class Application_Model_User {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function getUserData($id){
|
public static function getUserData($id){
|
||||||
global $CC_DBC;
|
$con = Propel::getConnection();
|
||||||
|
|
||||||
$sql = "SELECT login, first_name, last_name, type, id, email, skype_contact, jabber_contact"
|
$sql = "SELECT login, first_name, last_name, type, id, email, skype_contact, jabber_contact"
|
||||||
." FROM cc_subjs"
|
." FROM cc_subjs"
|
||||||
." WHERE id = $id";
|
." WHERE id = $id";
|
||||||
|
|
||||||
return $CC_DBC->GetRow($sql);
|
return $con->query($sql)->fetch();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function GetUserID($login){
|
public static function GetUserID($login){
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue