CC-4090: Make code style PSR compliant

-User.php
-removed all trailing whitespace
This commit is contained in:
Martin Konecny 2012-07-10 18:51:32 -04:00
parent 3d243468a7
commit ee3447f903
30 changed files with 1057 additions and 1037 deletions

View file

@ -83,7 +83,7 @@ class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
$view->headScript()->appendFile($baseUrl.'/js/airtime/common/common.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
$user = Application_Model_User::GetCurrentUser();
$user = Application_Model_User::getCurrentUser();
if (!is_null($user)){
$userType = $user->getType();
} else {

View file

@ -111,7 +111,7 @@ class LibraryController extends Zend_Controller_Action
//array containing id and type of media to delete.
$mediaItems = $this->_getParam('media', null);
$user = Application_Model_User::GetCurrentUser();
$user = Application_Model_User::getCurrentUser();
$isAdminOrPM = $user->isUserType(array(UTYPE_ADMIN, UTYPE_PROGRAM_MANAGER));
$files = array();
@ -204,7 +204,7 @@ class LibraryController extends Zend_Controller_Action
public function editFileMdAction()
{
$user = Application_Model_User::GetCurrentUser();
$user = Application_Model_User::getCurrentUser();
$isAdminOrPM = $user->isUserType(array(UTYPE_ADMIN, UTYPE_PROGRAM_MANAGER));
if(!$isAdminOrPM){
return;

View file

@ -90,7 +90,7 @@ class ScheduleController extends Zend_Controller_Action
Application_Model_Schedule::createNewFormSections($this->view);
$user = Application_Model_User::GetCurrentUser();
$user = Application_Model_User::getCurrentUser();
if($user->isUserType(array(UTYPE_ADMIN, UTYPE_PROGRAM_MANAGER))){
$this->view->preloadShowForm = true;
@ -689,7 +689,7 @@ class ScheduleController extends Zend_Controller_Action
public function getFormAction() {
$user = Application_Model_User::GetCurrentUser();
$user = Application_Model_User::getCurrentUser();
if($user->isUserType(array(UTYPE_ADMIN, UTYPE_PROGRAM_MANAGER))){
Application_Model_Schedule::createNewFormSections($this->view);
@ -822,7 +822,7 @@ class ScheduleController extends Zend_Controller_Action
public function cancelShowAction()
{
$user = Application_Model_User::GetCurrentUser();
$user = Application_Model_User::getCurrentUser();
if ($user->isUserType(array(UTYPE_ADMIN, UTYPE_PROGRAM_MANAGER))) {
$showInstanceId = $this->_getParam('id');
@ -842,7 +842,7 @@ class ScheduleController extends Zend_Controller_Action
public function cancelCurrentShowAction()
{
$user = Application_Model_User::GetCurrentUser();
$user = Application_Model_User::getCurrentUser();
if ($user->isUserType(array(UTYPE_ADMIN, UTYPE_PROGRAM_MANAGER))) {
$id = $this->_getParam('id');

View file

@ -22,7 +22,7 @@ class ShowbuilderController extends Zend_Controller_Action
$request = $this->getRequest();
$baseUrl = $request->getBaseUrl();
$user = Application_Model_User::GetCurrentUser();
$user = Application_Model_User::getCurrentUser();
$userType = $user->getType();
$this->view->headScript()->appendScript("localStorage.setItem( 'user-type', '$userType' );");
@ -184,7 +184,7 @@ class ShowbuilderController extends Zend_Controller_Action
$baseUrl = $request->getBaseUrl();
$menu = array();
$user = Application_Model_User::GetCurrentUser();
$user = Application_Model_User::getCurrentUser();
$item = CcScheduleQuery::create()->findPK($id);
$instance = $item->getCcShowInstances();

View file

@ -5,7 +5,7 @@ class Application_Form_ShowBuilder extends Zend_Form_SubForm
public function init()
{
$user = Application_Model_User::GetCurrentUser();
$user = Application_Model_User::getCurrentUser();
$this->setDecorators(array(
array('ViewScript', array('viewScript' => 'form/showbuilder.phtml'))

View file

@ -2,27 +2,27 @@
class Application_Model_Auth {
const TOKEN_LIFETIME = 'P2D'; // DateInterval syntax
const TOKEN_LIFETIME = 'P2D'; // DateInterval syntax
private function generateToken($action, $user_id)
{
$salt = md5("pro");
$token = self::generateRandomString();
private function generateToken($action, $user_id)
{
$salt = md5("pro");
$token = self::generateRandomString();
$info = new CcSubjsToken();
$info->setDbUserId($user_id);
$info->setDbAction($action);
$info->setDbToken(sha1($token.$salt));
$info->setDbCreated(gmdate('Y-m-d H:i:s'));
$info->save();
$info = new CcSubjsToken();
$info->setDbUserId($user_id);
$info->setDbAction($action);
$info->setDbToken(sha1($token.$salt));
$info->setDbCreated(gmdate('Y-m-d H:i:s'));
$info->save();
Logging::debug("generated token {$token}");
Logging::debug("generated token {$token}");
return $token;
}
return $token;
}
public function sendPasswordRestoreLink($user, $view)
{
public function sendPasswordRestoreLink($user, $view)
{
$token = $this->generateToken('password.restore', $user->getDbId());
$e_link_protocol = empty($_SERVER['HTTPS']) ? "http" : "https";
@ -31,22 +31,22 @@ class Application_Model_Auth {
$message = "Click this link: {$e_link_protocol}://{$e_link_base}{$e_link_path}";
$success = Application_Model_Email::send('Airtime Password Reset', $message, $user->getDbEmail());
$success = Application_Model_Email::send('Airtime Password Reset', $message, $user->getDbEmail());
return $success;
}
return $success;
}
public function invalidateTokens($user, $action)
{
CcSubjsTokenQuery::create()
->filterByDbAction($action)
->filterByDbUserId($user->getDbId())
->delete();
}
public function invalidateTokens($user, $action)
{
CcSubjsTokenQuery::create()
->filterByDbAction($action)
->filterByDbUserId($user->getDbId())
->delete();
}
public function checkToken($user_id, $token, $action)
{
$salt = md5("pro");
$salt = md5("pro");
$token_info = CcSubjsTokenQuery::create()
->filterByDbAction($action)

View file

@ -2,103 +2,103 @@
class Application_Model_Datatables {
/*
* query used to return data for a paginated/searchable datatable.
*/
public static function findEntries($con, $displayColumns, $fromTable, $data, $dataProp = "aaData")
{
$where = array();
/*
* query used to return data for a paginated/searchable datatable.
*/
public static function findEntries($con, $displayColumns, $fromTable, $data, $dataProp = "aaData")
{
$where = array();
if ($data["sSearch"] !== "") {
$searchTerms = explode(" ", $data["sSearch"]);
}
if ($data["sSearch"] !== "") {
$searchTerms = explode(" ", $data["sSearch"]);
}
$selectorCount = "SELECT COUNT(*) ";
$selectorRows = "SELECT ".join(",", $displayColumns)." ";
$selectorCount = "SELECT COUNT(*) ";
$selectorRows = "SELECT ".join(",", $displayColumns)." ";
$sql = $selectorCount." FROM ".$fromTable;
$sqlTotalRows = $sql;
$sql = $selectorCount." FROM ".$fromTable;
$sqlTotalRows = $sql;
if (isset($searchTerms)) {
$searchCols = array();
for ($i = 0; $i < $data["iColumns"]; $i++) {
if ($data["bSearchable_".$i] == "true") {
$searchCols[] = $data["mDataProp_{$i}"];
}
}
if (isset($searchTerms)) {
$searchCols = array();
for ($i = 0; $i < $data["iColumns"]; $i++) {
if ($data["bSearchable_".$i] == "true") {
$searchCols[] = $data["mDataProp_{$i}"];
}
}
$outerCond = array();
$outerCond = array();
foreach ($searchTerms as $term) {
$innerCond = array();
foreach ($searchTerms as $term) {
$innerCond = array();
foreach ($searchCols as $col) {
$escapedTerm = pg_escape_string($term);
$innerCond[] = "{$col}::text ILIKE '%{$escapedTerm}%'";
}
$outerCond[] = "(".join(" OR ", $innerCond).")";
}
$where[] = "(".join(" AND ", $outerCond).")";
}
// End Where clause
foreach ($searchCols as $col) {
$escapedTerm = pg_escape_string($term);
$innerCond[] = "{$col}::text ILIKE '%{$escapedTerm}%'";
}
$outerCond[] = "(".join(" OR ", $innerCond).")";
}
$where[] = "(".join(" AND ", $outerCond).")";
}
// End Where clause
// Order By clause
$orderby = array();
for ($i = 0; $i < $data["iSortingCols"]; $i++){
$num = $data["iSortCol_".$i];
$orderby[] = $data["mDataProp_{$num}"]." ".$data["sSortDir_".$i];
}
$orderby[] = "id";
$orderby = join("," , $orderby);
// End Order By clause
// Order By clause
$orderby = array();
for ($i = 0; $i < $data["iSortingCols"]; $i++){
$num = $data["iSortCol_".$i];
$orderby[] = $data["mDataProp_{$num}"]." ".$data["sSortDir_".$i];
}
$orderby[] = "id";
$orderby = join("," , $orderby);
// End Order By clause
$displayLength = intval($data["iDisplayLength"]);
if (count($where) > 0) {
$where = join(" AND ", $where);
$sql = $selectorCount." FROM ".$fromTable." WHERE ".$where;
$sqlTotalDisplayRows = $sql;
$displayLength = intval($data["iDisplayLength"]);
if (count($where) > 0) {
$where = join(" AND ", $where);
$sql = $selectorCount." FROM ".$fromTable." WHERE ".$where;
$sqlTotalDisplayRows = $sql;
$sql = $selectorRows." FROM ".$fromTable." WHERE ".$where." ORDER BY ".$orderby;
$sql = $selectorRows." FROM ".$fromTable." WHERE ".$where." ORDER BY ".$orderby;
//limit the results returned.
if ($displayLength !== -1) {
$sql .= " OFFSET ".$data["iDisplayStart"]." LIMIT ".$displayLength;
}
}
else {
$sql = $selectorRows." FROM ".$fromTable." ORDER BY ".$orderby;
//limit the results returned.
if ($displayLength !== -1) {
$sql .= " OFFSET ".$data["iDisplayStart"]." LIMIT ".$displayLength;
}
}
else {
$sql = $selectorRows." FROM ".$fromTable." ORDER BY ".$orderby;
//limit the results returned.
if ($displayLength !== -1) {
$sql .= " OFFSET ".$data["iDisplayStart"]." LIMIT ".$displayLength;
}
}
//limit the results returned.
if ($displayLength !== -1) {
$sql .= " OFFSET ".$data["iDisplayStart"]." LIMIT ".$displayLength;
}
}
try {
$r = $con->query($sqlTotalRows);
$totalRows = $r->fetchColumn(0);
try {
$r = $con->query($sqlTotalRows);
$totalRows = $r->fetchColumn(0);
if (isset($sqlTotalDisplayRows)) {
$r = $con->query($sqlTotalDisplayRows);
$totalDisplayRows = $r->fetchColumn(0);
}
else {
$totalDisplayRows = $totalRows;
}
if (isset($sqlTotalDisplayRows)) {
$r = $con->query($sqlTotalDisplayRows);
$totalDisplayRows = $r->fetchColumn(0);
}
else {
$totalDisplayRows = $totalRows;
}
$r = $con->query($sql);
$r->setFetchMode(PDO::FETCH_ASSOC);
$results = $r->fetchAll();
}
catch (Exception $e) {
Logging::debug($e->getMessage());
}
$r = $con->query($sql);
$r->setFetchMode(PDO::FETCH_ASSOC);
$results = $r->fetchAll();
}
catch (Exception $e) {
Logging::debug($e->getMessage());
}
return array(
"sEcho" => intval($data["sEcho"]),
"iTotalDisplayRecords" => intval($totalDisplayRows),
"iTotalRecords" => intval($totalRows),
$dataProp => $results
);
}
return array(
"sEcho" => intval($data["sEcho"]),
"iTotalDisplayRecords" => intval($totalDisplayRows),
"iTotalRecords" => intval($totalRows),
$dataProp => $results
);
}
}

View file

@ -20,17 +20,17 @@ class Application_Model_Playlist {
*/
private $id;
/**
/**
* propel object for this playlist.
*/
private $pl;
private $pl;
/**
/**
* info needed to insert a new playlist element.
*/
private $plItem = array(
private $plItem = array(
"id" => "",
"pos" => "",
"pos" => "",
"cliplength" => "",
"cuein" => "00:00:00",
"cueout" => "00:00:00",
@ -38,13 +38,13 @@ class Application_Model_Playlist {
"fadeout" => "0.0",
);
//using propel's phpNames.
private $categories = array(
"dc:title" => "Name",
"dc:creator" => "Creator",
"dc:description" => "Description",
"dcterms:extent" => "Length"
);
//using propel's phpNames.
private $categories = array(
"dc:title" => "Name",
"dc:creator" => "Creator",
"dc:description" => "Description",
"dcterms:extent" => "Length"
);
public function __construct($id=null, $con=null)
@ -90,12 +90,12 @@ class Application_Model_Playlist {
*/
public function setName($p_newname)
{
$this->pl->setDbName($p_newname);
$this->pl->setDbMtime(new DateTime("now", new DateTimeZone("UTC")));
$this->pl->save($this->con);
$this->pl->setDbName($p_newname);
$this->pl->setDbMtime(new DateTime("now", new DateTimeZone("UTC")));
$this->pl->save($this->con);
}
/**
/**
* Get mnemonic playlist name
*
* @return string
@ -107,9 +107,9 @@ class Application_Model_Playlist {
public function setDescription($p_description)
{
$this->pl->setDbDescription($p_description);
$this->pl->setDbMtime(new DateTime("now", new DateTimeZone("UTC")));
$this->pl->save($this->con);
$this->pl->setDbDescription($p_description);
$this->pl->setDbMtime(new DateTime("now", new DateTimeZone("UTC")));
$this->pl->save($this->con);
}
public function getDescription()
@ -145,7 +145,7 @@ class Application_Model_Playlist {
/**
* Get the entire playlist as a two dimentional array, sorted in order of play.
* @param boolean $filterFiles if this is true, it will only return files that has
* file_exists flag set to true
* file_exists flag set to true
* @return array
*/
public function getContents($filterFiles=false) {
@ -416,7 +416,7 @@ class Application_Model_Playlist {
* Remove audioClip from playlist
*
* @param array $p_items
* array of unique item ids to remove from the playlist..
* array of unique item ids to remove from the playlist..
*/
public function delAudioClips($p_items)
{
@ -452,11 +452,11 @@ class Application_Model_Playlist {
}
public function getFadeInfo($pos) {
public function getFadeInfo($pos) {
Logging::log("Getting fade info for pos {$pos}");
Logging::log("Getting fade info for pos {$pos}");
$row = CcPlaylistcontentsQuery::create()
$row = CcPlaylistcontentsQuery::create()
->joinWith(CcFilesPeer::OM_CLASS)
->filterByDbPlaylistId($this->id)
->filterByDbPosition($pos)
@ -466,24 +466,24 @@ class Application_Model_Playlist {
$fadeIn = $row->getDbFadein();
$fadeOut = $row->getDbFadeout();
return array($fadeIn, $fadeOut);
}
}
/**
* Change fadeIn and fadeOut values for playlist Element
*
* @param int $pos
* position of audioclip in playlist
* position of audioclip in playlist
* @param string $fadeIn
* new value in ss.ssssss or extent format
* new value in ss.ssssss or extent format
* @param string $fadeOut
* new value in ss.ssssss or extent format
* new value in ss.ssssss or extent format
* @return boolean
*/
public function changeFadeInfo($id, $fadeIn, $fadeOut)
{
//See issue CC-2065, pad the fadeIn and fadeOut so that it is TIME compatable with the DB schema
//For the top level PlayList either fadeIn or fadeOut will sometimes be Null so need a gaurd against
//setting it to nonNull for checks down below
//setting it to nonNull for checks down below
$fadeIn = $fadeIn?'00:00:'.$fadeIn:$fadeIn;
$fadeOut = $fadeOut?'00:00:'.$fadeOut:$fadeOut;
@ -502,8 +502,8 @@ class Application_Model_Playlist {
if (!is_null($fadeIn)) {
$sql = "SELECT INTERVAL '{$fadeIn}' > INTERVAL '{$clipLength}'";
$r = $this->con->query($sql);
$sql = "SELECT INTERVAL '{$fadeIn}' > INTERVAL '{$clipLength}'";
$r = $this->con->query($sql);
if ($r->fetchColumn(0)) {
//"Fade In can't be larger than overall playlength.";
$fadeIn = $clipLength;
@ -512,8 +512,8 @@ class Application_Model_Playlist {
}
if (!is_null($fadeOut)){
$sql = "SELECT INTERVAL '{$fadeOut}' > INTERVAL '{$clipLength}'";
$r = $this->con->query($sql);
$sql = "SELECT INTERVAL '{$fadeOut}' > INTERVAL '{$clipLength}'";
$r = $this->con->query($sql);
if ($r->fetchColumn(0)) {
//Fade Out can't be larger than overall playlength.";
$fadeOut = $clipLength;
@ -562,11 +562,11 @@ class Application_Model_Playlist {
* Change cueIn/cueOut values for playlist element
*
* @param int $pos
* position of audioclip in playlist
* position of audioclip in playlist
* @param string $cueIn
* new value in ss.ssssss or extent format
* new value in ss.ssssss or extent format
* @param string $cueOut
* new value in ss.ssssss or extent format
* new value in ss.ssssss or extent format
* @return boolean or pear error object
*/
public function changeClipLength($id, $cueIn, $cueOut)
@ -604,23 +604,23 @@ class Application_Model_Playlist {
$cueOut = $origLength;
}
$sql = "SELECT INTERVAL '{$cueIn}' > INTERVAL '{$cueOut}'";
$r = $this->con->query($sql);
$sql = "SELECT INTERVAL '{$cueIn}' > INTERVAL '{$cueOut}'";
$r = $this->con->query($sql);
if ($r->fetchColumn(0)) {
$errArray["error"] = "Can't set cue in to be larger than cue out.";
return $errArray;
}
$sql = "SELECT INTERVAL '{$cueOut}' > INTERVAL '{$origLength}'";
$r = $this->con->query($sql);
$sql = "SELECT INTERVAL '{$cueOut}' > INTERVAL '{$origLength}'";
$r = $this->con->query($sql);
if ($r->fetchColumn(0)){
$errArray["error"] = "Can't set cue out to be greater than file length.";
return $errArray;
}
$sql = "SELECT INTERVAL '{$cueOut}' - INTERVAL '{$cueIn}'";
$r = $this->con->query($sql);
$cliplength = $r->fetchColumn(0);
$sql = "SELECT INTERVAL '{$cueOut}' - INTERVAL '{$cueIn}'";
$r = $this->con->query($sql);
$cliplength = $r->fetchColumn(0);
$row->setDbCuein($cueIn);
$row->setDbCueout($cueOut);
@ -629,16 +629,16 @@ class Application_Model_Playlist {
}
else if (!is_null($cueIn)) {
$sql = "SELECT INTERVAL '{$cueIn}' > INTERVAL '{$oldCueOut}'";
$r = $this->con->query($sql);
$sql = "SELECT INTERVAL '{$cueIn}' > INTERVAL '{$oldCueOut}'";
$r = $this->con->query($sql);
if ($r->fetchColumn(0)) {
$errArray["error"] = "Can't set cue in to be larger than cue out.";
return $errArray;
}
$sql = "SELECT INTERVAL '{$oldCueOut}' - INTERVAL '{$cueIn}'";
$r = $this->con->query($sql);
$cliplength = $r->fetchColumn(0);
$r = $this->con->query($sql);
$cliplength = $r->fetchColumn(0);
$row->setDbCuein($cueIn);
$row->setDBCliplength($cliplength);
@ -649,23 +649,23 @@ class Application_Model_Playlist {
$cueOut = $origLength;
}
$sql = "SELECT INTERVAL '{$cueOut}' < INTERVAL '{$oldCueIn}'";
$r = $this->con->query($sql);
$sql = "SELECT INTERVAL '{$cueOut}' < INTERVAL '{$oldCueIn}'";
$r = $this->con->query($sql);
if ($r->fetchColumn(0)) {
$errArray["error"] = "Can't set cue out to be smaller than cue in.";
return $errArray;
}
$sql = "SELECT INTERVAL '{$cueOut}' > INTERVAL '{$origLength}'";
$r = $this->con->query($sql);
$sql = "SELECT INTERVAL '{$cueOut}' > INTERVAL '{$origLength}'";
$r = $this->con->query($sql);
if ($r->fetchColumn(0)){
$errArray["error"] = "Can't set cue out to be greater than file length.";
return $errArray;
}
$sql = "SELECT INTERVAL '{$cueOut}' - INTERVAL '{$oldCueIn}'";
$r = $this->con->query($sql);
$cliplength = $r->fetchColumn(0);
$r = $this->con->query($sql);
$cliplength = $r->fetchColumn(0);
$row->setDbCueout($cueOut);
$row->setDBCliplength($cliplength);
@ -673,15 +673,15 @@ class Application_Model_Playlist {
$cliplength = $row->getDbCliplength();
$sql = "SELECT INTERVAL '{$fadeIn}' > INTERVAL '{$cliplength}'";
$r = $this->con->query($sql);
$sql = "SELECT INTERVAL '{$fadeIn}' > INTERVAL '{$cliplength}'";
$r = $this->con->query($sql);
if ($r->fetchColumn(0)){
$fadeIn = $cliplength;
$row->setDbFadein($fadeIn);
}
$sql = "SELECT INTERVAL '{$fadeOut}' > INTERVAL '{$cliplength}'";
$r = $this->con->query($sql);
$sql = "SELECT INTERVAL '{$fadeOut}' > INTERVAL '{$cliplength}'";
$r = $this->con->query($sql);
if ($r->fetchColumn(0)){
$fadeOut = $cliplength;
$row->setDbFadein($fadeOut);

View file

@ -4,80 +4,80 @@ require_once 'formatters/LengthFormatter.php';
class Application_Model_PlayoutHistory {
private $con;
private $timezone;
private $con;
private $timezone;
//in UTC timezone
private $startDT;
//in UTC timezone
private $endDT;
//in UTC timezone
private $startDT;
//in UTC timezone
private $endDT;
private $epoch_now;
private $opts;
private $epoch_now;
private $opts;
private $mDataPropMap = array(
"artist" => "file.artist_name",
"title" => "file.track_title",
"played" => "playout.played",
"length" => "file.length",
"composer" => "file.composer",
"copyright" => "file.copyright",
);
private $mDataPropMap = array(
"artist" => "file.artist_name",
"title" => "file.track_title",
"played" => "playout.played",
"length" => "file.length",
"composer" => "file.composer",
"copyright" => "file.copyright",
);
public function __construct($p_startDT, $p_endDT, $p_opts) {
public function __construct($p_startDT, $p_endDT, $p_opts) {
$this->con = Propel::getConnection(CcSchedulePeer::DATABASE_NAME);
$this->startDT = $p_startDT;
$this->endDT = $p_endDT;
$this->timezone = date_default_timezone_get();
$this->epoch_now = time();
$this->opts = $p_opts;
}
$this->con = Propel::getConnection(CcSchedulePeer::DATABASE_NAME);
$this->startDT = $p_startDT;
$this->endDT = $p_endDT;
$this->timezone = date_default_timezone_get();
$this->epoch_now = time();
$this->opts = $p_opts;
}
/*
* map front end mDataProp labels to proper column names for searching etc.
*/
private function translateColumns() {
/*
* map front end mDataProp labels to proper column names for searching etc.
*/
private function translateColumns() {
for ($i = 0; $i < $this->opts["iColumns"]; $i++){
for ($i = 0; $i < $this->opts["iColumns"]; $i++){
$this->opts["mDataProp_{$i}"] = $this->mDataPropMap[$this->opts["mDataProp_{$i}"]];
}
}
$this->opts["mDataProp_{$i}"] = $this->mDataPropMap[$this->opts["mDataProp_{$i}"]];
}
}
public function getItems() {
public function getItems() {
$this->translateColumns();
$this->translateColumns();
$select = array(
"file.track_title as title",
"file.artist_name as artist",
"playout.played",
"playout.file_id",
"file.composer",
"file.copyright",
"file.length"
);
$select = array(
"file.track_title as title",
"file.artist_name as artist",
"playout.played",
"playout.file_id",
"file.composer",
"file.copyright",
"file.length"
);
$start = $this->startDT->format("Y-m-d H:i:s");
$end = $this->endDT->format("Y-m-d H:i:s");
$start = $this->startDT->format("Y-m-d H:i:s");
$end = $this->endDT->format("Y-m-d H:i:s");
$historyTable = "(
select count(schedule.file_id) as played, schedule.file_id as file_id
from cc_schedule as schedule
where schedule.starts >= '{$start}' and schedule.starts < '{$end}'
and schedule.playout_status > 0 and schedule.media_item_played != FALSE and schedule.broadcasted = 1
group by schedule.file_id
)
AS playout left join cc_files as file on (file.id = playout.file_id)";
$historyTable = "(
select count(schedule.file_id) as played, schedule.file_id as file_id
from cc_schedule as schedule
where schedule.starts >= '{$start}' and schedule.starts < '{$end}'
and schedule.playout_status > 0 and schedule.media_item_played != FALSE and schedule.broadcasted = 1
group by schedule.file_id
)
AS playout left join cc_files as file on (file.id = playout.file_id)";
$results = Application_Model_Datatables::findEntries($this->con, $select, $historyTable, $this->opts, "history");
$results = Application_Model_Datatables::findEntries($this->con, $select, $historyTable, $this->opts, "history");
foreach ($results["history"] as &$row) {
$formatter = new LengthFormatter($row['length']);
$row['length'] = $formatter->format();
}
foreach ($results["history"] as &$row) {
$formatter = new LengthFormatter($row['length']);
$row['length'] = $formatter->format();
}
return $results;
}
return $results;
}
}

View file

@ -298,75 +298,75 @@ class Application_Model_Preference
}
public static function SetPhone($phone){
self::setValue("phone", $phone);
self::setValue("phone", $phone);
}
public static function GetPhone(){
return self::getValue("phone");
return self::getValue("phone");
}
public static function SetEmail($email){
self::setValue("email", $email);
public static function SetEmail($email){
self::setValue("email", $email);
}
public static function GetEmail(){
return self::getValue("email");
return self::getValue("email");
}
public static function SetStationWebSite($site){
self::setValue("station_website", $site);
public static function SetStationWebSite($site){
self::setValue("station_website", $site);
}
public static function GetStationWebSite(){
return self::getValue("station_website");
return self::getValue("station_website");
}
public static function SetSupportFeedback($feedback){
self::setValue("support_feedback", $feedback);
public static function SetSupportFeedback($feedback){
self::setValue("support_feedback", $feedback);
}
public static function GetSupportFeedback(){
return self::getValue("support_feedback");
return self::getValue("support_feedback");
}
public static function SetPublicise($publicise){
self::setValue("publicise", $publicise);
public static function SetPublicise($publicise){
self::setValue("publicise", $publicise);
}
public static function GetPublicise(){
return self::getValue("publicise");
return self::getValue("publicise");
}
public static function SetRegistered($registered){
self::setValue("registered", $registered);
public static function SetRegistered($registered){
self::setValue("registered", $registered);
}
public static function GetRegistered(){
return self::getValue("registered");
return self::getValue("registered");
}
public static function SetStationCountry($country){
self::setValue("country", $country);
public static function SetStationCountry($country){
self::setValue("country", $country);
}
public static function GetStationCountry(){
return self::getValue("country");
return self::getValue("country");
}
public static function SetStationCity($city){
self::setValue("city", $city);
public static function SetStationCity($city){
self::setValue("city", $city);
}
public static function GetStationCity(){
return self::getValue("city");
public static function GetStationCity(){
return self::getValue("city");
}
public static function SetStationDescription($description){
self::setValue("description", $description);
public static function SetStationDescription($description){
self::setValue("description", $description);
}
public static function GetStationDescription(){
return self::getValue("description");
public static function GetStationDescription(){
return self::getValue("description");
}
public static function SetTimezone($timezone){
@ -380,139 +380,139 @@ class Application_Model_Preference
}
public static function SetStationLogo($imagePath){
if(!empty($imagePath)){
$image = @file_get_contents($imagePath);
$image = base64_encode($image);
self::setValue("logoImage", $image);
}
if(!empty($imagePath)){
$image = @file_get_contents($imagePath);
$image = base64_encode($image);
self::setValue("logoImage", $image);
}
}
public static function GetStationLogo(){
return self::getValue("logoImage");
public static function GetStationLogo(){
return self::getValue("logoImage");
}
public static function GetUniqueId(){
return self::getValue("uniqueId");
return self::getValue("uniqueId");
}
public static function GetCountryList()
{
$con = Propel::getConnection();
$sql = "SELECT * FROM cc_country";
$res = $con->query($sql)->fetchAll();
$out = array();
$out[""] = "Select Country";
foreach($res as $r){
$out[$r["isocode"]] = $r["name"];
}
return $out;
$con = Propel::getConnection();
$sql = "SELECT * FROM cc_country";
$res = $con->query($sql)->fetchAll();
$out = array();
$out[""] = "Select Country";
foreach($res as $r){
$out[$r["isocode"]] = $r["name"];
}
return $out;
}
public static function GetSystemInfo($returnArray=false, $p_testing=false)
{
exec('/usr/bin/airtime-check-system --no-color', $output);
$output = preg_replace('/\s+/', ' ', $output);
exec('/usr/bin/airtime-check-system --no-color', $output);
$output = preg_replace('/\s+/', ' ', $output);
$systemInfoArray = array();
foreach( $output as $key => &$out){
$info = explode('=', $out);
if(isset($info[1])){
$key = str_replace(' ', '_', trim($info[0]));
$key = strtoupper($key);
if ($key == 'WEB_SERVER' || $key == 'CPU' || $key == 'OS' || $key == 'TOTAL_RAM' ||
$key == 'FREE_RAM' || $key == 'AIRTIME_VERSION' || $key == 'KERNAL_VERSION' ||
$key == 'MACHINE_ARCHITECTURE' || $key == 'TOTAL_MEMORY_MBYTES' || $key == 'TOTAL_SWAP_MBYTES' ||
$key == 'PLAYOUT_ENGINE_CPU_PERC' ) {
if($key == 'AIRTIME_VERSION'){
// remove hash tag on the version string
$version = explode('+', $info[1]);
$systemInfoArray[$key] = $version[0];
}else{
$systemInfoArray[$key] = $info[1];
}
}
}
}
$systemInfoArray = array();
foreach( $output as $key => &$out){
$info = explode('=', $out);
if(isset($info[1])){
$key = str_replace(' ', '_', trim($info[0]));
$key = strtoupper($key);
if ($key == 'WEB_SERVER' || $key == 'CPU' || $key == 'OS' || $key == 'TOTAL_RAM' ||
$key == 'FREE_RAM' || $key == 'AIRTIME_VERSION' || $key == 'KERNAL_VERSION' ||
$key == 'MACHINE_ARCHITECTURE' || $key == 'TOTAL_MEMORY_MBYTES' || $key == 'TOTAL_SWAP_MBYTES' ||
$key == 'PLAYOUT_ENGINE_CPU_PERC' ) {
if($key == 'AIRTIME_VERSION'){
// remove hash tag on the version string
$version = explode('+', $info[1]);
$systemInfoArray[$key] = $version[0];
}else{
$systemInfoArray[$key] = $info[1];
}
}
}
}
$outputArray = array();
$outputArray = array();
$outputArray['LIVE_DURATION'] = Application_Model_LiveLog::GetLiveShowDuration($p_testing);
$outputArray['SCHEDULED_DURATION'] = Application_Model_LiveLog::GetScheduledDuration($p_testing);
$outputArray['SOUNDCLOUD_ENABLED'] = self::GetUploadToSoundcloudOption();
$outputArray['LIVE_DURATION'] = Application_Model_LiveLog::GetLiveShowDuration($p_testing);
$outputArray['SCHEDULED_DURATION'] = Application_Model_LiveLog::GetScheduledDuration($p_testing);
$outputArray['SOUNDCLOUD_ENABLED'] = self::GetUploadToSoundcloudOption();
if ($outputArray['SOUNDCLOUD_ENABLED']) {
$outputArray['NUM_SOUNDCLOUD_TRACKS_UPLOADED'] = Application_Model_StoredFile::getSoundCloudUploads();
$outputArray['NUM_SOUNDCLOUD_TRACKS_UPLOADED'] = Application_Model_StoredFile::getSoundCloudUploads();
} else {
$outputArray['NUM_SOUNDCLOUD_TRACKS_UPLOADED'] = NULL;
}
$outputArray['STATION_NAME'] = self::GetStationName();
$outputArray['PHONE'] = self::GetPhone();
$outputArray['EMAIL'] = self::GetEmail();
$outputArray['STATION_WEB_SITE'] = self::GetStationWebSite();
$outputArray['STATION_COUNTRY'] = self::GetStationCountry();
$outputArray['STATION_CITY'] = self::GetStationCity();
$outputArray['STATION_DESCRIPTION'] = self::GetStationDescription();
$outputArray['STATION_NAME'] = self::GetStationName();
$outputArray['PHONE'] = self::GetPhone();
$outputArray['EMAIL'] = self::GetEmail();
$outputArray['STATION_WEB_SITE'] = self::GetStationWebSite();
$outputArray['STATION_COUNTRY'] = self::GetStationCountry();
$outputArray['STATION_CITY'] = self::GetStationCity();
$outputArray['STATION_DESCRIPTION'] = self::GetStationDescription();
// get web server info
if(isset($systemInfoArray["AIRTIME_VERSION_URL"])){
$url = $systemInfoArray["AIRTIME_VERSION_URL"];
// get web server info
if(isset($systemInfoArray["AIRTIME_VERSION_URL"])){
$url = $systemInfoArray["AIRTIME_VERSION_URL"];
$index = strpos($url,'/api/');
$url = substr($url, 0, $index);
$headerInfo = get_headers(trim($url),1);
$outputArray['WEB_SERVER'] = $headerInfo['Server'][0];
}
}
$outputArray['NUM_OF_USERS'] = Application_Model_User::getUserCount();
$outputArray['NUM_OF_SONGS'] = Application_Model_StoredFile::getFileCount();
$outputArray['NUM_OF_PLAYLISTS'] = Application_Model_Playlist::getPlaylistCount();
$outputArray['NUM_OF_SCHEDULED_PLAYLISTS'] = Application_Model_Schedule::getSchduledPlaylistCount();
$outputArray['NUM_OF_PAST_SHOWS'] = Application_Model_ShowInstance::GetShowInstanceCount(gmdate("Y-m-d H:i:s"));
$outputArray['UNIQUE_ID'] = self::GetUniqueId();
$outputArray['SAAS'] = self::GetPlanLevel();
if ($outputArray['SAAS'] != 'disabled') {
$outputArray['TRIAL_END_DATE'] = self::GetTrialEndingDate();
} else {
$outputArray['NUM_OF_USERS'] = Application_Model_User::getUserCount();
$outputArray['NUM_OF_SONGS'] = Application_Model_StoredFile::getFileCount();
$outputArray['NUM_OF_PLAYLISTS'] = Application_Model_Playlist::getPlaylistCount();
$outputArray['NUM_OF_SCHEDULED_PLAYLISTS'] = Application_Model_Schedule::getSchduledPlaylistCount();
$outputArray['NUM_OF_PAST_SHOWS'] = Application_Model_ShowInstance::GetShowInstanceCount(gmdate("Y-m-d H:i:s"));
$outputArray['UNIQUE_ID'] = self::GetUniqueId();
$outputArray['SAAS'] = self::GetPlanLevel();
if ($outputArray['SAAS'] != 'disabled') {
$outputArray['TRIAL_END_DATE'] = self::GetTrialEndingDate();
} else {
$outputArray['TRIAL_END_DATE'] = NULL;
}
$outputArray['INSTALL_METHOD'] = self::GetInstallMethod();
$outputArray['NUM_OF_STREAMS'] = self::GetNumOfStreams();
$outputArray['STREAM_INFO'] = Application_Model_StreamSetting::getStreamInfoForDataCollection();
$outputArray['INSTALL_METHOD'] = self::GetInstallMethod();
$outputArray['NUM_OF_STREAMS'] = self::GetNumOfStreams();
$outputArray['STREAM_INFO'] = Application_Model_StreamSetting::getStreamInfoForDataCollection();
$outputArray = array_merge($systemInfoArray, $outputArray);
$outputArray = array_merge($systemInfoArray, $outputArray);
$outputString = "\n";
foreach($outputArray as $key => $out){
if($key == 'TRIAL_END_DATE' && ($out != '' || $out != 'NULL')){
continue;
}
if($key == "STREAM_INFO"){
$outputString .= $key." :\n";
foreach($out as $s_info){
foreach($s_info as $k => $v){
$outputString .= "\t".strtoupper($k)." : ".$v."\n";
}
}
}else if ($key == "SOUNDCLOUD_ENABLED") {
if ($out) {
$outputString .= $key." : TRUE\n";
} else if (!$out) {
$outputString .= $key." : FALSE\n";
}
}else if ($key == "SAAS") {
$outputString = "\n";
foreach($outputArray as $key => $out){
if($key == 'TRIAL_END_DATE' && ($out != '' || $out != 'NULL')){
continue;
}
if($key == "STREAM_INFO"){
$outputString .= $key." :\n";
foreach($out as $s_info){
foreach($s_info as $k => $v){
$outputString .= "\t".strtoupper($k)." : ".$v."\n";
}
}
}else if ($key == "SOUNDCLOUD_ENABLED") {
if ($out) {
$outputString .= $key." : TRUE\n";
} else if (!$out) {
$outputString .= $key." : FALSE\n";
}
}else if ($key == "SAAS") {
if (strcmp($out, 'disabled')!=0) {
$outputString .= $key.' : '.$out."\n";
}
}else{
$outputString .= $key.' : '.$out."\n";
}
}
if($returnArray){
$outputArray['PROMOTE'] = self::GetPublicise();
$outputArray['LOGOIMG'] = self::GetStationLogo();
return $outputArray;
}else{
return $outputString;
}
}else{
$outputString .= $key.' : '.$out."\n";
}
}
if($returnArray){
$outputArray['PROMOTE'] = self::GetPublicise();
$outputArray['LOGOIMG'] = self::GetStationLogo();
return $outputArray;
}else{
return $outputString;
}
}
public static function GetInstallMethod(){
@ -530,8 +530,8 @@ class Application_Model_Preference
}
public static function SetRemindMeDate(){
$weekAfter = mktime(0, 0, 0, gmdate("m"), gmdate("d")+7, gmdate("Y"));
self::setValue("remindme", $weekAfter);
$weekAfter = mktime(0, 0, 0, gmdate("m"), gmdate("d")+7, gmdate("Y"));
self::setValue("remindme", $weekAfter);
}
public static function GetRemindMeDate(){
@ -679,7 +679,7 @@ class Application_Model_Preference
}
public static function GetWeekStartDay() {
$val = self::getValue("week_start_day");
$val = self::getValue("week_start_day");
if (strlen($val) == 0){
return "0";
} else {
@ -721,7 +721,7 @@ class Application_Model_Preference
/**
* 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) {
self::setValue("calendar_time_scale", $timeScale, true /* user specific */);
@ -736,16 +736,16 @@ class Application_Model_Preference
if(strlen($val) == 0) {
$val = "month";
}
return $val;
return $val;
}
/**
* 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) {
self::setValue("library_num_entries", $numEntries, true /* user specific */);
self::setValue("library_num_entries", $numEntries, true /* user specific */);
}
/**
@ -753,7 +753,7 @@ class Application_Model_Preference
* Defaults to 10 if no entry exists
*/
public static function GetLibraryNumEntries() {
$val = self::getValue("library_num_entries", true /* user specific */);
$val = self::getValue("library_num_entries", true /* user specific */);
if(strlen($val) == 0) {
$val = "10";
}
@ -763,7 +763,7 @@ class Application_Model_Preference
/**
* Sets the time interval preference in Calendar.
*
* @param $timeInterval new time interval
* @param $timeInterval new time interval
*/
public static function SetCalendarTimeInterval($timeInterval) {
self::setValue("calendar_time_interval", $timeInterval, true /* user specific */);
@ -774,7 +774,7 @@ class Application_Model_Preference
* Defaults to 30 min if no entry exists
*/
public static function GetCalendarTimeInterval() {
$val = self::getValue("calendar_time_interval", true /* user specific */);
$val = self::getValue("calendar_time_interval", true /* user specific */);
if(strlen($val) == 0) {
$val = "30";
}
@ -908,44 +908,44 @@ class Application_Model_Preference
}
public static function SetMailServerConfigured($value) {
self::setValue("mail_server_configured", $value, false);
}
self::setValue("mail_server_configured", $value, false);
}
public static function GetMailServerConfigured() {
return self::getValue("mail_server_configured");
}
public static function GetMailServerConfigured() {
return self::getValue("mail_server_configured");
}
public static function SetMailServer($value) {
self::setValue("mail_server", $value, false);
}
public static function SetMailServer($value) {
self::setValue("mail_server", $value, false);
}
public static function GetMailServer() {
return self::getValue("mail_server");
}
public static function GetMailServer() {
return self::getValue("mail_server");
}
public static function SetMailServerEmailAddress($value) {
self::setValue("mail_server_email_address", $value, false);
}
public static function SetMailServerEmailAddress($value) {
self::setValue("mail_server_email_address", $value, false);
}
public static function GetMailServerEmailAddress() {
return self::getValue("mail_server_email_address");
}
public static function GetMailServerEmailAddress() {
return self::getValue("mail_server_email_address");
}
public static function SetMailServerPassword($value) {
self::setValue("mail_server_password", $value, false);
}
public static function SetMailServerPassword($value) {
self::setValue("mail_server_password", $value, false);
}
public static function GetMailServerPassword() {
return self::getValue("mail_server_password");
}
public static function GetMailServerPassword() {
return self::getValue("mail_server_password");
}
public static function SetMailServerPort($value) {
self::setValue("mail_server_port", $value, false);
}
public static function SetMailServerPort($value) {
self::setValue("mail_server_port", $value, false);
}
public static function GetMailServerPort() {
return self::getValue("mail_server_port");
}
public static function GetMailServerPort() {
return self::getValue("mail_server_port");
}
/* User specific preferences end */
public static function ShouldShowPopUp(){

View file

@ -231,15 +231,15 @@ class Application_Model_Schedule {
return $row;
}
/*
*
* @param DateTime $p_startDateTime
*
* @param DateTime $p_endDateTime
*
* @return array $scheduledItems
*
*/
/*
*
* @param DateTime $p_startDateTime
*
* @param DateTime $p_endDateTime
*
* @return array $scheduledItems
*
*/
public static function GetScheduleDetailItems($p_start, $p_end, $p_shows)
{
global $CC_CONFIG;
@ -626,18 +626,18 @@ class Application_Model_Schedule {
$isSaas = Application_Model_Preference::GetPlanLevel() == 'disabled'?false:true;
$formWhat = new Application_Form_AddShowWhat();
$formWho = new Application_Form_AddShowWho();
$formWhen = new Application_Form_AddShowWhen();
$formRepeats = new Application_Form_AddShowRepeats();
$formStyle = new Application_Form_AddShowStyle();
$formLive = new Application_Form_AddShowLiveStream();
$formWho = new Application_Form_AddShowWho();
$formWhen = new Application_Form_AddShowWhen();
$formRepeats = new Application_Form_AddShowRepeats();
$formStyle = new Application_Form_AddShowStyle();
$formLive = new Application_Form_AddShowLiveStream();
$formWhat->removeDecorator('DtDdWrapper');
$formWho->removeDecorator('DtDdWrapper');
$formWhen->removeDecorator('DtDdWrapper');
$formRepeats->removeDecorator('DtDdWrapper');
$formStyle->removeDecorator('DtDdWrapper');
$formLive->removeDecorator('DtDdWrapper');
$formWhat->removeDecorator('DtDdWrapper');
$formWho->removeDecorator('DtDdWrapper');
$formWhen->removeDecorator('DtDdWrapper');
$formRepeats->removeDecorator('DtDdWrapper');
$formStyle->removeDecorator('DtDdWrapper');
$formLive->removeDecorator('DtDdWrapper');
$p_view->what = $formWhat;
$p_view->when = $formWhen;
@ -681,18 +681,18 @@ class Application_Model_Schedule {
$isSaas = (Application_Model_Preference::GetPlanLevel() != 'disabled');
$formWhat = new Application_Form_AddShowWhat();
$formWhen = new Application_Form_AddShowWhen();
$formRepeats = new Application_Form_AddShowRepeats();
$formWho = new Application_Form_AddShowWho();
$formStyle = new Application_Form_AddShowStyle();
$formLive = new Application_Form_AddShowLiveStream();
$formWhen = new Application_Form_AddShowWhen();
$formRepeats = new Application_Form_AddShowRepeats();
$formWho = new Application_Form_AddShowWho();
$formStyle = new Application_Form_AddShowStyle();
$formLive = new Application_Form_AddShowLiveStream();
$formWhat->removeDecorator('DtDdWrapper');
$formWhen->removeDecorator('DtDdWrapper');
$formRepeats->removeDecorator('DtDdWrapper');
$formWho->removeDecorator('DtDdWrapper');
$formStyle->removeDecorator('DtDdWrapper');
$formLive->removeDecorator('DtDdWrapper');
$formWhat->removeDecorator('DtDdWrapper');
$formWhen->removeDecorator('DtDdWrapper');
$formRepeats->removeDecorator('DtDdWrapper');
$formWho->removeDecorator('DtDdWrapper');
$formStyle->removeDecorator('DtDdWrapper');
$formLive->removeDecorator('DtDdWrapper');
if(!$isSaas){
$formRecord = new Application_Form_AddShowRR();
@ -765,22 +765,22 @@ class Application_Model_Schedule {
$record = false;
$formWhat = new Application_Form_AddShowWhat();
$formWho = new Application_Form_AddShowWho();
$formWhen = new Application_Form_AddShowWhen();
$formRepeats = new Application_Form_AddShowRepeats();
$formStyle = new Application_Form_AddShowStyle();
$formLive = new Application_Form_AddShowLiveStream();
$formWho = new Application_Form_AddShowWho();
$formWhen = new Application_Form_AddShowWhen();
$formRepeats = new Application_Form_AddShowRepeats();
$formStyle = new Application_Form_AddShowStyle();
$formLive = new Application_Form_AddShowLiveStream();
$formWhat->removeDecorator('DtDdWrapper');
$formWho->removeDecorator('DtDdWrapper');
$formWhen->removeDecorator('DtDdWrapper');
$formRepeats->removeDecorator('DtDdWrapper');
$formStyle->removeDecorator('DtDdWrapper');
$formLive->removeDecorator('DtDdWrapper');
$formWhat->removeDecorator('DtDdWrapper');
$formWho->removeDecorator('DtDdWrapper');
$formWhen->removeDecorator('DtDdWrapper');
$formRepeats->removeDecorator('DtDdWrapper');
$formStyle->removeDecorator('DtDdWrapper');
$formLive->removeDecorator('DtDdWrapper');
$what = $formWhat->isValid($data);
$when = $formWhen->isValid($data);
$live = $formLive->isValid($data);
$what = $formWhat->isValid($data);
$when = $formWhen->isValid($data);
$live = $formLive->isValid($data);
if($when) {
$when = $formWhen->checkReliantFields($data, $validateStartDate, $originalStartDate, $update, $instanceId);
}
@ -798,11 +798,11 @@ class Application_Model_Schedule {
$mValue = 0;
if($hPos !== false){
$hValue = trim(substr($data["add_show_duration"], 0, $hPos));
$hValue = trim(substr($data["add_show_duration"], 0, $hPos));
}
if($mPos !== false){
$hPos = $hPos === FALSE ? 0 : $hPos+1;
$mValue = trim(substr($data["add_show_duration"], $hPos, -1 ));
$mValue = trim(substr($data["add_show_duration"], $hPos, -1 ));
}
$data["add_show_duration"] = $hValue.":".$mValue;
@ -821,7 +821,7 @@ class Application_Model_Schedule {
}
if($data["add_show_repeats"]) {
$repeats = $formRepeats->isValid($data);
$repeats = $formRepeats->isValid($data);
if($repeats) {
$repeats = $formRepeats->checkReliantFields($data);
}
@ -857,8 +857,8 @@ class Application_Model_Schedule {
}
}
$who = $formWho->isValid($data);
$style = $formStyle->isValid($data);
$who = $formWho->isValid($data);
$style = $formStyle->isValid($data);
if ($what && $when && $repeats && $who && $style && $live) {
if(!$isSaas){
if($record && $rebroadAb && $rebroad){
@ -898,7 +898,7 @@ class Application_Model_Schedule {
//$controller->view->newForm = $controller->view->render('schedule/add-show-form.phtml');
return true;
}
} else {
} else {
$controller->view->what = $formWhat;
$controller->view->when = $formWhen;
$controller->view->repeats = $formRepeats;

View file

@ -32,7 +32,7 @@ class Application_Model_Scheduler {
$this->nowDT = DateTime::createFromFormat("U", time(), new DateTimeZone("UTC"));
}
$this->user = Application_Model_User::GetCurrentUser();
$this->user = Application_Model_User::getCurrentUser();
}
public function setCheckUserPermissions($value) {

View file

@ -303,8 +303,6 @@ class Application_Model_Show {
." AND starts > TIMESTAMP '$timestamp'"
." AND show_id = $showId";
//Logging::log($sql);
$con->exec($sql);
}
@ -594,8 +592,8 @@ class Application_Model_Show {
* The start date in the format YYYY-MM-DD
*/
public function getStartDate(){
list($date,) = explode(" ", $this->getStartDateAndTime());
return $date;
list($date,) = explode(" ", $this->getStartDateAndTime());
return $date;
}
/**
@ -606,8 +604,8 @@ class Application_Model_Show {
*/
public function getStartTime(){
list(,$time) = explode(" ", $this->getStartDateAndTime());
return $time;
list(,$time) = explode(" ", $this->getStartDateAndTime());
return $time;
}
/**
@ -1251,8 +1249,8 @@ class Application_Model_Show {
$rebroadcasts = $con->query($sql)->fetchAll();
if ($showInstance->isRecorded()){
$showInstance->deleteRebroadcasts();
self::createRebroadcastInstances($rebroadcasts, $currentUtcTimestamp, $show_id, $show_instance_id, $start, $duration, $timezone);
$showInstance->deleteRebroadcasts();
self::createRebroadcastInstances($rebroadcasts, $currentUtcTimestamp, $show_id, $show_instance_id, $start, $duration, $timezone);
}
}
}

View file

@ -54,7 +54,7 @@ class Application_Model_ShowBuilder {
$this->startDT = $p_startDT;
$this->endDT = $p_endDT;
$this->timezone = date_default_timezone_get();
$this->user = Application_Model_User::GetCurrentUser();
$this->user = Application_Model_User::getCurrentUser();
$this->opts = $p_opts;
$this->epoch_now = floatval(microtime(true));
$this->currentShow = false;

View file

@ -670,30 +670,30 @@ class Application_Model_ShowInstance {
public function getLastAudioItemEnd()
{
$con = Propel::getConnection();
$con = Propel::getConnection();
$sql = "SELECT ends FROM cc_schedule "
."WHERE instance_id = {$this->_instanceId} "
."ORDER BY ends DESC "
."LIMIT 1";
$sql = "SELECT ends FROM cc_schedule "
."WHERE instance_id = {$this->_instanceId} "
."ORDER BY ends DESC "
."LIMIT 1";
$query = $con->query($sql)->fetchColumn(0);
$query = $con->query($sql)->fetchColumn(0);
return ($query !== false) ? $query : NULL;
}
}
public function getShowEndGapTime(){
$showEnd = $this->getShowInstanceEnd();
$lastItemEnd = $this->getLastAudioItemEnd();
$showEnd = $this->getShowInstanceEnd();
$lastItemEnd = $this->getLastAudioItemEnd();
if (is_null($lastItemEnd)){
$lastItemEnd = $this->getShowInstanceStart();
}
if (is_null($lastItemEnd)){
$lastItemEnd = $this->getShowInstanceStart();
}
$diff = strtotime($showEnd) - strtotime($lastItemEnd);
$diff = strtotime($showEnd) - strtotime($lastItemEnd);
return ($diff < 0) ? 0 : $diff;
}
return ($diff < 0) ? 0 : $diff;
}
public static function GetLastShowInstance($p_timeNow){
global $CC_CONFIG;
@ -777,10 +777,10 @@ class Application_Model_ShowInstance {
$con = Propel::getConnection();
$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
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";
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";
return $con->query($sql)->fetchAll();
}

View file

@ -5,7 +5,7 @@ class Application_Model_Soundcloud {
private $_soundcloud;
public function __construct()
public function __construct()
{
global $CC_CONFIG;

View file

@ -161,9 +161,9 @@ class Application_Model_StoredFile {
* Set metadata element value
*
* @param string $category
* Metadata element by metadata constant
* Metadata element by metadata constant
* @param string $value
* value to store, if NULL then delete record
* value to store, if NULL then delete record
*/
public function setMetadataValue($p_category, $p_value)
{
@ -176,9 +176,9 @@ class Application_Model_StoredFile {
* Set metadata element value
*
* @param string $category
* Metadata element by db column
* Metadata element by db column
* @param string $value
* value to store, if NULL then delete record
* value to store, if NULL then delete record
*/
public function setDbColMetadataValue($p_category, $p_value)
{
@ -273,9 +273,9 @@ class Application_Model_StoredFile {
* Set state of virtual file
*
* @param string $p_state
* 'empty'|'incomplete'|'ready'|'edited'
* 'empty'|'incomplete'|'ready'|'edited'
* @param int $p_editedby
* user id | 'NULL' for clear editedBy field
* user id | 'NULL' for clear editedBy field
* @return TRUE
*/
public function setState($p_state, $p_editedby=NULL)
@ -367,7 +367,7 @@ class Application_Model_StoredFile {
* Return suitable extension.
*
* @return string
* file extension without a dot
* file extension without a dot
*/
public function getFileExtension()
{
@ -500,9 +500,9 @@ Logging::log("getting media! - 2");
* be NULL.
*
* @param int $p_id
* local id
* local id
* @param string $p_gunid
* global unique id of file
* global unique id of file
* @param string $p_md5sum
* MD5 sum of the file
* @param boolean $exist
@ -570,7 +570,7 @@ Logging::log("getting media! - 2");
* by gunid.
*
* @param string $p_gunid
* global unique id of file
* global unique id of file
* @return Application_Model_StoredFile|NULL
*/
public static function RecallByGunid($p_gunid)
@ -624,7 +624,7 @@ Logging::log("getting media! - 2");
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",
"year", "utime", "mtime", "ftype", "track_number", "mood", "bpm", "composer", "info_url",
@ -967,9 +967,9 @@ Logging::log("getting media! - 2");
public static function getSoundCloudUploads()
{
try {
$con = Propel::getConnection();
$con = Propel::getConnection();
$sql = "SELECT soundcloud_id as id, soundcloud_upload_time"
$sql = "SELECT soundcloud_id as id, soundcloud_upload_time"
." FROM CC_FILES"
." WHERE (id != -2 and id != -3) and"
." (soundcloud_upload_time >= (now() - (INTERVAL '1 day')))";
@ -1023,8 +1023,8 @@ Logging::log("getting media! - 2");
}
public function getDirectory(){
return $this->_file->getDbDirectory();
}
return $this->_file->getDbDirectory();
}
public function setFileExistsFlag($flag){
$this->_file->setDbFileExists($flag)

View file

@ -11,191 +11,220 @@ class Application_Model_User {
public function __construct($userId)
{
if (empty($userId)){
if (empty($userId)) {
$this->_userInstance = $this->createUser();
}
else {
} else {
$this->_userInstance = CcSubjsQuery::create()->findPK($userId);
if (is_null($this->_userInstance)){
if (is_null($this->_userInstance)) {
throw new Exception();
}
}
}
public function getId() {
public function getId()
{
return $this->_userInstance->getDbId();
}
public function isGuest() {
public function isGuest()
{
return $this->getType() == UTYPE_GUEST;
}
public function isHost($showId) {
return $this->isUserType(UTYPE_HOST, $showId);
public function isHost($showId)
{
return $this->isUserType(UTYPE_HOST, $showId);
}
public function isPM() {
public function isPM()
{
return $this->isUserType(UTYPE_PROGRAM_MANAGER);
}
public function isAdmin() {
public function isAdmin()
{
return $this->isUserType(UTYPE_ADMIN);
}
public function canSchedule($p_showId) {
$type = $this->getType();
$result = false;
public function canSchedule($p_showId)
{
$type = $this->getType();
$result = false;
if ( $type === UTYPE_ADMIN ||
if ($type === UTYPE_ADMIN ||
$type === UTYPE_PROGRAM_MANAGER ||
CcShowHostsQuery::create()->filterByDbShow($p_showId)->filterByDbHost($this->getId())->count() > 0 )
{
$result = true;
}
CcShowHostsQuery::create()->filterByDbShow($p_showId)->filterByDbHost($this->getId())->count() > 0) {
$result = true;
}
return $result;
return $result;
}
public function isUserType($type, $showId=''){
if(is_array($type)){
$result = false;
foreach($type as $t){
switch($t){
case UTYPE_ADMIN:
$result = $this->_userInstance->getDbType() === 'A';
break;
case UTYPE_HOST:
$userId = $this->_userInstance->getDbId();
$result = CcShowHostsQuery::create()->filterByDbShow($showId)->filterByDbHost($userId)->count() > 0;
break;
case UTYPE_PROGRAM_MANAGER:
$result = $this->_userInstance->getDbType() === 'P';
break;
}
if($result){
return $result;
}
}
}else{
switch($type){
case UTYPE_ADMIN:
return $this->_userInstance->getDbType() === 'A';
case UTYPE_HOST:
$userId = $this->_userInstance->getDbId();
return CcShowHostsQuery::create()->filterByDbShow($showId)->filterByDbHost($userId)->count() > 0;
case UTYPE_PROGRAM_MANAGER:
return $this->_userInstance->getDbType() === 'P';
}
}
public function isUserType($type, $showId='')
{
if (is_array($type)) {
$result = false;
foreach ($type as $t) {
switch($t){
case UTYPE_ADMIN:
$result = $this->_userInstance->getDbType() === 'A';
break;
case UTYPE_HOST:
$userId = $this->_userInstance->getDbId();
$result = CcShowHostsQuery::create()
->filterByDbShow($showId)
->filterByDbHost($userId)->count() > 0;
break;
case UTYPE_PROGRAM_MANAGER:
$result = $this->_userInstance->getDbType() === 'P';
break;
}
if ($result) {
return $result;
}
}
} else {
switch($type) {
case UTYPE_ADMIN:
return $this->_userInstance->getDbType() === 'A';
case UTYPE_HOST:
$userId = $this->_userInstance->getDbId();
return CcShowHostsQuery::create()->filterByDbShow($showId)->filterByDbHost($userId)->count() > 0;
case UTYPE_PROGRAM_MANAGER:
return $this->_userInstance->getDbType() === 'P';
}
}
}
public function setLogin($login){
public function setLogin($login)
{
$user = $this->_userInstance;
$user->setDbLogin($login);
}
public function setPassword($password){
public function setPassword($password)
{
$user = $this->_userInstance;
$user->setDbPass(md5($password));
}
public function setFirstName($firstName){
public function setFirstName($firstName)
{
$user = $this->_userInstance;
$user->setDbFirstName($firstName);
}
public function setLastName($lastName){
public function setLastName($lastName)
{
$user = $this->_userInstance;
$user->setDbLastName($lastName);
}
public function setType($type){
public function setType($type)
{
$user = $this->_userInstance;
$user->setDbType($type);
}
public function setEmail($email){
public function setEmail($email)
{
$user = $this->_userInstance;
$user->setDbEmail(strtolower($email));
}
public function setCellPhone($cellPhone){
public function setCellPhone($cellPhone)
{
$user = $this->_userInstance;
$user->setDbCellPhone($cellPhone);
}
public function setSkype($skype){
public function setSkype($skype)
{
$user = $this->_userInstance;
$user->setDbSkypeContact($skype);
}
public function setJabber($jabber){
public function setJabber($jabber)
{
$user = $this->_userInstance;
$user->setDbJabberContact($jabber);
}
public function getLogin(){
public function getLogin()
{
$user = $this->_userInstance;
return $user->getDbLogin();
}
public function getPassword(){
public function getPassword()
{
$user = $this->_userInstance;
return $user->getDbPass();
}
public function getFirstName(){
public function getFirstName()
{
$user = $this->_userInstance;
return $user->getDbFirstName();
}
public function getLastName(){
public function getLastName()
{
$user = $this->_userInstance;
return $user->getDbLastName();
}
public function getType(){
public function getType()
{
$user = $this->_userInstance;
return $user->getDbType();
}
public function getEmail(){
public function getEmail()
{
$user = $this->_userInstance;
return $user->getDbEmail();
}
public function getCellPhone(){
public function getCellPhone()
{
$user = $this->_userInstance;
return $user->getDbCellPhone();
}
public function getSkype(){
public function getSkype()
{
$user = $this->_userInstance;
return $user->getDbSkypeContact();
}
public function getJabber(){
public function getJabber()
{
$user = $this->_userInstance;
return $user->getDbJabberContact();
}
public function save(){
public function save()
{
$this->_userInstance->save();
}
public function delete(){
if (!$this->_userInstance->isDeleted())
public function delete()
{
if (!$this->_userInstance->isDeleted()) {
$this->_userInstance->delete();
}
}
private function createUser() {
private function createUser()
{
$user = new CcSubjs();
return $user;
}
public static function getUsers($type, $search=NULL)
public static function getUsers($type, $search=null)
{
$con = Propel::getConnection();
@ -203,12 +232,11 @@ class Application_Model_User {
$sql = $sql_gen;
if (is_array($type)) {
for($i=0; $i<count($type); $i++) {
for ($i=0; $i<count($type); $i++) {
$type[$i] = "type = '{$type[$i]}'";
}
$sql_type = join(" OR ", $type);
}
else {
} else {
$sql_type = "type = {$type}";
}
@ -225,39 +253,40 @@ class Application_Model_User {
return $con->query($sql)->fetchAll();;
}
public static function getUserCount($type=NULL){
public static function getUserCount($type=null)
{
$con = Propel::getConnection();
$sql = '';
$sql_gen = "SELECT count(*) AS cnt FROM cc_subjs ";
if (!isset($type)) {
$sql = $sql_gen;
}
else{
if (is_array($type)) {
for ($i=0; $i<count($type); $i++) {
$type[$i] = "type = '{$type[$i]}'";
}
$sql_type = join(" OR ", $type);
}
else {
$sql_type = "type = {$type}";
}
$sql = $sql_gen;
} else {
if (is_array($type)) {
for ($i=0; $i<count($type); $i++) {
$type[$i] = "type = '{$type[$i]}'";
}
$sql_type = join(" OR ", $type);
} else {
$sql_type = "type = {$type}";
}
$sql = $sql_gen ." WHERE (". $sql_type.") ";
$sql = $sql_gen ." WHERE (". $sql_type.") ";
}
$query = $con->query($sql)->fetchColumn(0);
return ($query !== false) ? $query : NULL;
return ($query !== false) ? $query : null;
}
public static function getHosts($search=NULL) {
public static function getHosts($search=null)
{
return Application_Model_User::getUsers(array('H'), $search);
}
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");
$fromTable = "cc_subjs";
@ -273,8 +302,8 @@ class Application_Model_User {
$res = Application_Model_Datatables::findEntries($con, $displayColumns, $fromTable, $datatables);
// mark record which is for the current user
foreach($res['aaData'] as &$record){
if($record['login'] == $username){
foreach ($res['aaData'] as &$record) {
if ($record['login'] == $username) {
$record['delete'] = "self";
} else {
$record['delete'] = "";
@ -284,7 +313,8 @@ class Application_Model_User {
return $res;
}
public static function getUserData($id){
public static function getUserData($id)
{
$con = Propel::getConnection();
$sql = "SELECT login, first_name, last_name, type, id, email, cell_phone, skype_contact, jabber_contact"
@ -294,24 +324,16 @@ class Application_Model_User {
return $con->query($sql)->fetch();
}
public static function GetUserID($login){
$user = CcSubjsQuery::create()->findOneByDbLogin($login);
if (is_null($user)){
return -1;
} else {
return $user->getDbId();
}
}
public static function GetCurrentUser() {
public static function getCurrentUser()
{
$userinfo = Zend_Auth::getInstance()->getStorage()->read();
if (is_null($userinfo)){
if (is_null($userinfo)) {
return null;
} else {
try {
return new self($userinfo->id);
} catch (Exception $e){
} catch (Exception $e) {
//we get here if $userinfo->id is defined, but doesn't exist
//in the database anymore.
Zend_Auth::getInstance()->clearIdentity();

View file

@ -13,7 +13,7 @@
*/
class CcFiles extends BaseCcFiles {
public function getDbLength($format = "H:i:s.u")
public function getDbLength($format = "H:i:s.u")
{
return parent::getDbLength($format);
}

View file

@ -2,9 +2,9 @@
class Common {
public static function setTimeInSub($row, $col, $time)
public static function setTimeInSub($row, $col, $time)
{
$class = get_class($row).'Peer';
$class = get_class($row).'Peer';
$con = Propel::getConnection($class::DATABASE_NAME);

View file

@ -17,8 +17,8 @@ class StoredFileTest extends PHPUnit_TestCase {
|| ($metadata["audio"]["dataformat"] != "mp3")
|| ($metadata["dc:type"] != "Speech")) {
$str = " [dc:description] = " . $metadata["dc:description"] ."\n"
. " [audio][dataformat] = " . $metadata["audio"]["dataformat"]."\n"
. " [dc:type] = ".$metadata["dc:type"]."\n";
. " [audio][dataformat] = " . $metadata["audio"]["dataformat"]."\n"
. " [dc:type] = ".$metadata["dc:type"]."\n";
$this->fail("Metadata has unexpected values:\n".$str);
}
//var_dump($metadata);

@ -1 +1 @@
Subproject commit 492242f4bb7367afebbf2f096067cb5a5d3c0449
Subproject commit 0653ec0b89362921f075af96ee8772538b801a7c