2011-02-03 23:51:35 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
class Application_Model_Preference
|
|
|
|
{
|
2014-11-05 23:04:18 +01:00
|
|
|
private static function getUserId()
|
|
|
|
{
|
2022-03-14 11:15:04 +01:00
|
|
|
// pass in true so the check is made with the autoloader
|
|
|
|
// we need this check because saas calls this function from outside Zend
|
2021-10-11 16:10:47 +02:00
|
|
|
if (!class_exists('Zend_Session', true) || !Zend_Session::isStarted() || !class_exists('Zend_Auth', true) || !Zend_Auth::getInstance()->hasIdentity()) {
|
2014-11-05 23:04:18 +01:00
|
|
|
$userId = null;
|
|
|
|
} else {
|
|
|
|
$auth = Zend_Auth::getInstance();
|
|
|
|
$userId = $auth->getIdentity()->id;
|
|
|
|
}
|
2020-05-04 06:32:52 +02:00
|
|
|
|
2014-11-05 23:04:18 +01:00
|
|
|
return $userId;
|
|
|
|
}
|
2020-05-04 06:32:52 +02:00
|
|
|
|
2013-01-03 22:19:02 +01:00
|
|
|
/**
|
2021-10-11 16:10:47 +02:00
|
|
|
* @param bool $isUserValue is true when we are setting a value for the current user
|
|
|
|
* @param mixed $key
|
|
|
|
* @param mixed $value
|
2013-01-03 22:19:02 +01:00
|
|
|
*/
|
2013-11-11 22:20:51 +01:00
|
|
|
private static function setValue($key, $value, $isUserValue = false)
|
2012-07-16 03:17:13 +02:00
|
|
|
{
|
2015-07-04 06:38:53 +02:00
|
|
|
$con = Propel::getConnection(CcPrefPeer::DATABASE_NAME);
|
2015-09-02 16:40:38 +02:00
|
|
|
|
2022-03-14 11:15:04 +01:00
|
|
|
// We are using row-level locking in Postgres via "FOR UPDATE" instead of a transaction here
|
|
|
|
// because sometimes this function needs to be called while a transaction is already started.
|
2013-05-07 22:21:34 +02:00
|
|
|
|
2015-07-04 06:38:53 +02:00
|
|
|
try {
|
2015-07-07 00:03:44 +02:00
|
|
|
/* Comment this out while we reevaluate it in favor of a unique constraint
|
|
|
|
static::_lock($con); */
|
2013-11-11 22:20:51 +01:00
|
|
|
$userId = self::getUserId();
|
2020-05-04 06:32:52 +02:00
|
|
|
|
2015-07-04 06:38:53 +02:00
|
|
|
if ($isUserValue && is_null($userId)) {
|
2014-11-05 23:04:18 +01:00
|
|
|
throw new Exception("User id can't be null for a user preference {$key}.");
|
2015-07-04 06:38:53 +02:00
|
|
|
}
|
|
|
|
|
2022-03-14 11:15:04 +01:00
|
|
|
// Check if key already exists
|
2021-10-11 16:10:47 +02:00
|
|
|
$sql = 'SELECT valstr FROM cc_pref'
|
|
|
|
. ' WHERE keystr = :key';
|
2020-05-04 06:32:52 +02:00
|
|
|
|
2021-10-11 16:10:47 +02:00
|
|
|
$paramMap = [];
|
2012-09-06 22:46:22 +02:00
|
|
|
$paramMap[':key'] = $key;
|
2020-05-04 06:32:52 +02:00
|
|
|
|
2022-03-14 11:15:04 +01:00
|
|
|
// For user specific preference, check if id matches as well
|
2013-11-11 22:20:51 +01:00
|
|
|
if ($isUserValue) {
|
2021-10-11 16:10:47 +02:00
|
|
|
$sql .= ' AND subjid = :id';
|
2013-01-03 22:19:02 +01:00
|
|
|
$paramMap[':id'] = $userId;
|
2015-09-02 16:40:38 +02:00
|
|
|
}
|
|
|
|
|
2021-10-11 16:10:47 +02:00
|
|
|
$sql .= ' FOR UPDATE';
|
2013-05-27 21:58:29 +02:00
|
|
|
|
2021-10-11 16:10:47 +02:00
|
|
|
$result = Application_Common_Database::prepareAndExecute(
|
|
|
|
$sql,
|
|
|
|
$paramMap,
|
|
|
|
Application_Common_Database::ROW_COUNT,
|
|
|
|
PDO::FETCH_ASSOC,
|
|
|
|
$con
|
|
|
|
);
|
2012-05-06 04:29:16 +02:00
|
|
|
|
2021-10-11 16:10:47 +02:00
|
|
|
$paramMap = [];
|
2013-05-07 21:36:21 +02:00
|
|
|
if ($result > 1) {
|
2022-03-14 11:15:04 +01:00
|
|
|
// this case should not happen.
|
2023-11-13 19:46:47 +01:00
|
|
|
$caller = debug_backtrace()[1]['function'];
|
|
|
|
|
2021-10-11 16:10:47 +02:00
|
|
|
throw new Exception('Invalid number of results returned. Should be ' .
|
2023-11-13 19:46:47 +01:00
|
|
|
"0 or 1, but is '{$result}' instead, caller={$caller}");
|
2021-10-11 16:10:47 +02:00
|
|
|
}
|
|
|
|
if ($result == 1) {
|
2012-05-06 04:29:16 +02:00
|
|
|
// result found
|
2013-12-11 22:55:35 +01:00
|
|
|
if (!$isUserValue) {
|
2012-05-06 04:29:16 +02:00
|
|
|
// system pref
|
2021-10-11 16:10:47 +02:00
|
|
|
$sql = 'UPDATE cc_pref'
|
|
|
|
. ' SET subjid = NULL, valstr = :value'
|
|
|
|
. ' WHERE keystr = :key';
|
2014-11-05 23:04:18 +01:00
|
|
|
} else {
|
2012-05-06 04:29:16 +02:00
|
|
|
// user pref
|
2021-10-11 16:10:47 +02:00
|
|
|
$sql = 'UPDATE cc_pref'
|
|
|
|
. ' SET valstr = :value'
|
|
|
|
. ' WHERE keystr = :key AND subjid = :id';
|
2020-05-04 06:32:52 +02:00
|
|
|
|
2013-11-11 22:20:51 +01:00
|
|
|
$paramMap[':id'] = $userId;
|
2012-05-06 04:29:16 +02:00
|
|
|
}
|
2014-11-05 23:04:18 +01:00
|
|
|
} else {
|
2012-05-06 04:29:16 +02:00
|
|
|
// result not found
|
2013-12-11 22:55:35 +01:00
|
|
|
if (!$isUserValue) {
|
2012-05-06 04:29:16 +02:00
|
|
|
// system pref
|
2021-10-11 16:10:47 +02:00
|
|
|
$sql = 'INSERT INTO cc_pref (keystr, valstr)'
|
|
|
|
. ' VALUES (:key, :value)';
|
2014-11-05 23:04:18 +01:00
|
|
|
} else {
|
2012-05-06 04:29:16 +02:00
|
|
|
// user pref
|
2021-10-11 16:10:47 +02:00
|
|
|
$sql = 'INSERT INTO cc_pref (subjid, keystr, valstr)'
|
|
|
|
. ' VALUES (:id, :key, :value)';
|
2020-05-04 06:32:52 +02:00
|
|
|
|
2013-11-11 22:20:51 +01:00
|
|
|
$paramMap[':id'] = $userId;
|
2012-05-06 04:29:16 +02:00
|
|
|
}
|
|
|
|
}
|
2012-09-06 22:46:22 +02:00
|
|
|
$paramMap[':key'] = $key;
|
|
|
|
$paramMap[':value'] = $value;
|
2011-03-23 23:16:08 +01:00
|
|
|
|
2021-10-11 16:10:47 +02:00
|
|
|
Application_Common_Database::prepareAndExecute(
|
|
|
|
$sql,
|
|
|
|
$paramMap,
|
|
|
|
Application_Common_Database::EXECUTE,
|
|
|
|
PDO::FETCH_ASSOC,
|
|
|
|
$con
|
|
|
|
);
|
2014-11-05 23:04:18 +01:00
|
|
|
} catch (Exception $e) {
|
2012-05-04 18:40:44 +02:00
|
|
|
header('HTTP/1.0 503 Service Unavailable');
|
2021-10-11 16:10:47 +02:00
|
|
|
Logging::info('Database error: ' . $e->getMessage());
|
|
|
|
|
2012-05-04 18:40:44 +02:00
|
|
|
exit;
|
|
|
|
}
|
2012-05-06 04:29:16 +02:00
|
|
|
}
|
2012-04-01 21:51:03 +02:00
|
|
|
|
2015-07-04 06:38:53 +02:00
|
|
|
/**
|
2021-10-11 16:10:47 +02:00
|
|
|
* Given a PDO connection, lock the cc_pref table for the current transaction.
|
2015-07-04 06:38:53 +02:00
|
|
|
*
|
|
|
|
* Creates a table level lock, which defaults to ACCESS EXCLUSIVE mode;
|
2022-08-25 16:25:54 +02:00
|
|
|
* see https://www.postgresql.org/docs/9.1/static/explicit-locking.html
|
2015-07-04 06:38:53 +02:00
|
|
|
*
|
|
|
|
* @param PDO $con
|
|
|
|
*/
|
2021-10-11 16:10:47 +02:00
|
|
|
private static function _lock($con)
|
|
|
|
{
|
2015-07-04 06:38:53 +02:00
|
|
|
// If we're not in a transaction, a lock is pointless
|
|
|
|
if (!$con->inTransaction()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
// Don't specify NOWAIT here; we should block on obtaining this lock
|
|
|
|
// in case we're handling simultaneous requests.
|
|
|
|
// Locks only last until the end of the transaction, so we shouldn't have to
|
|
|
|
// worry about this causing any noticeable difference in request processing speed
|
2021-10-11 16:10:47 +02:00
|
|
|
$sql = 'LOCK TABLE cc_pref';
|
2015-07-04 06:38:53 +02:00
|
|
|
$st = $con->prepare($sql);
|
|
|
|
$st->execute();
|
|
|
|
}
|
|
|
|
|
2015-09-29 17:28:20 +02:00
|
|
|
/**
|
2021-10-11 16:10:47 +02:00
|
|
|
* @param string $key the preference key string
|
|
|
|
* @param bool|false $isUserValue select the preference for the current user
|
|
|
|
* @param bool|false $forceDefault only look for default (no user ID) values
|
|
|
|
*
|
2015-09-29 17:28:20 +02:00
|
|
|
* @return mixed the preference value
|
|
|
|
*/
|
|
|
|
private static function getValue($key, $isUserValue = false, $forceDefault = false)
|
2012-07-16 03:17:13 +02:00
|
|
|
{
|
2012-05-06 04:29:16 +02:00
|
|
|
try {
|
2015-09-25 16:41:51 +02:00
|
|
|
$userId = null;
|
|
|
|
if ($isUserValue) {
|
2022-03-14 11:15:04 +01:00
|
|
|
// This is nested in here because so we can still use getValue() when the session hasn't started yet.
|
2015-09-25 16:41:51 +02:00
|
|
|
$userId = self::getUserId();
|
|
|
|
if (is_null($userId)) {
|
|
|
|
throw new Exception("User id can't be null for a user preference.");
|
|
|
|
}
|
|
|
|
}
|
2014-11-05 23:04:18 +01:00
|
|
|
|
2022-03-14 11:15:04 +01:00
|
|
|
// Check if key already exists
|
2021-10-11 16:10:47 +02:00
|
|
|
$sql = 'SELECT COUNT(*) FROM cc_pref'
|
2022-07-07 20:01:15 +02:00
|
|
|
. ' WHERE keystr = :key';
|
2020-05-04 06:32:52 +02:00
|
|
|
|
2021-10-11 16:10:47 +02:00
|
|
|
$paramMap = [];
|
2013-05-13 17:42:11 +02:00
|
|
|
$paramMap[':key'] = $key;
|
2020-05-04 06:32:52 +02:00
|
|
|
|
2022-03-14 11:15:04 +01:00
|
|
|
// For user specific preference, check if id matches as well
|
2014-11-05 23:04:18 +01:00
|
|
|
if ($isUserValue) {
|
2021-10-11 16:10:47 +02:00
|
|
|
$sql .= ' AND subjid = :id';
|
2013-11-11 21:07:13 +01:00
|
|
|
$paramMap[':id'] = $userId;
|
2021-10-11 16:10:47 +02:00
|
|
|
} elseif ($forceDefault) {
|
|
|
|
$sql .= ' AND subjid IS NULL';
|
2012-05-06 04:29:16 +02:00
|
|
|
}
|
2015-07-07 19:54:19 +02:00
|
|
|
|
2013-05-13 17:42:11 +02:00
|
|
|
$result = Application_Common_Database::prepareAndExecute($sql, $paramMap, Application_Common_Database::COLUMN);
|
2015-07-07 19:54:19 +02:00
|
|
|
|
2022-03-14 11:15:04 +01:00
|
|
|
// return an empty string if the result doesn't exist.
|
2012-09-14 22:51:14 +02:00
|
|
|
if ($result == 0) {
|
2021-10-11 16:10:47 +02:00
|
|
|
$res = '';
|
2014-11-05 23:04:18 +01:00
|
|
|
} else {
|
2021-10-11 16:10:47 +02:00
|
|
|
$sql = 'SELECT valstr FROM cc_pref'
|
2022-07-07 20:01:15 +02:00
|
|
|
. ' WHERE keystr = :key';
|
2020-05-04 06:32:52 +02:00
|
|
|
|
2021-10-11 16:10:47 +02:00
|
|
|
$paramMap = [];
|
2013-05-13 17:42:11 +02:00
|
|
|
$paramMap[':key'] = $key;
|
2012-05-06 04:29:16 +02:00
|
|
|
|
2022-03-14 11:15:04 +01:00
|
|
|
// For user specific preference, check if id matches as well
|
2013-12-06 23:11:07 +01:00
|
|
|
if ($isUserValue) {
|
2021-10-11 16:10:47 +02:00
|
|
|
$sql .= ' AND subjid = :id';
|
2013-11-11 21:07:13 +01:00
|
|
|
$paramMap[':id'] = $userId;
|
2012-05-06 04:29:16 +02:00
|
|
|
}
|
2020-05-04 06:32:52 +02:00
|
|
|
|
2013-05-13 17:42:11 +02:00
|
|
|
$result = Application_Common_Database::prepareAndExecute($sql, $paramMap, Application_Common_Database::COLUMN);
|
2012-07-16 03:17:13 +02:00
|
|
|
|
2021-10-11 16:10:47 +02:00
|
|
|
$res = ($result !== false) ? $result : '';
|
2012-05-06 04:29:16 +02:00
|
|
|
}
|
2020-05-04 06:32:52 +02:00
|
|
|
|
2013-11-11 22:20:51 +01:00
|
|
|
return $res;
|
2021-10-11 16:10:47 +02:00
|
|
|
} catch (Exception $e) {
|
2012-05-06 04:29:16 +02:00
|
|
|
header('HTTP/1.0 503 Service Unavailable');
|
2021-10-11 16:10:47 +02:00
|
|
|
Logging::info('Could not connect to database: ' . $e);
|
|
|
|
|
2012-07-11 00:51:32 +02:00
|
|
|
exit;
|
2011-02-03 23:51:35 +01:00
|
|
|
}
|
|
|
|
}
|
2011-03-23 23:16:08 +01:00
|
|
|
|
2012-07-16 03:17:13 +02:00
|
|
|
public static function GetHeadTitle()
|
|
|
|
{
|
2021-10-11 16:10:47 +02:00
|
|
|
$title = self::getValue('station_name');
|
2019-09-12 21:59:34 +02:00
|
|
|
if (empty($title)) {
|
|
|
|
$title = PRODUCT_NAME;
|
|
|
|
}
|
2011-03-23 23:16:08 +01:00
|
|
|
|
2019-09-12 21:59:34 +02:00
|
|
|
return $title;
|
2011-02-04 01:17:52 +01:00
|
|
|
}
|
2011-03-23 23:16:08 +01:00
|
|
|
|
2021-10-11 16:10:47 +02:00
|
|
|
public static function SetHeadTitle($title, $view = null)
|
2012-07-16 03:17:13 +02:00
|
|
|
{
|
2021-10-11 16:10:47 +02:00
|
|
|
self::setValue('station_name', $title);
|
2011-03-23 23:16:08 +01:00
|
|
|
|
2011-11-14 22:05:19 +01:00
|
|
|
// in case this is called from airtime-saas script
|
2012-07-16 03:17:13 +02:00
|
|
|
if ($view !== null) {
|
2022-03-14 11:15:04 +01:00
|
|
|
// set session variable to new station name so that html title is updated.
|
|
|
|
// should probably do this in a view helper to keep this controller as minimal as possible.
|
|
|
|
$view->headTitle()->exchangeArray([]); // clear headTitle ArrayObject
|
2011-11-14 22:05:19 +01:00
|
|
|
$view->headTitle(self::GetHeadTitle());
|
|
|
|
}
|
2012-04-01 21:51:03 +02:00
|
|
|
|
2021-10-11 16:10:47 +02:00
|
|
|
$eventType = 'update_station_name';
|
|
|
|
$md = ['station_name' => $title];
|
2012-04-01 21:51:03 +02:00
|
|
|
|
2012-02-11 00:43:40 +01:00
|
|
|
Application_Model_RabbitMq::SendMessageToPypo($eventType, $md);
|
2011-02-04 01:17:52 +01:00
|
|
|
}
|
2011-02-03 23:51:35 +01:00
|
|
|
|
2011-11-11 20:54:08 +01:00
|
|
|
/**
|
2012-04-01 21:51:03 +02:00
|
|
|
* Set the furthest date that a never-ending show
|
2011-11-11 20:54:08 +01:00
|
|
|
* should be populated until.
|
2012-04-01 21:51:03 +02:00
|
|
|
*
|
2011-11-11 20:54:08 +01:00
|
|
|
* @param DateTime $dateTime
|
2021-10-11 16:10:47 +02:00
|
|
|
* A row from cc_show_days table
|
2012-04-01 21:51:03 +02:00
|
|
|
*/
|
2012-07-16 03:17:13 +02:00
|
|
|
public static function SetShowsPopulatedUntil($dateTime)
|
|
|
|
{
|
2021-10-11 16:10:47 +02:00
|
|
|
$dateTime->setTimezone(new DateTimeZone('UTC'));
|
|
|
|
self::setValue('shows_populated_until', $dateTime->format(DEFAULT_TIMESTAMP_FORMAT));
|
2011-02-05 22:00:05 +01:00
|
|
|
}
|
|
|
|
|
2011-11-11 20:54:08 +01:00
|
|
|
/**
|
2012-04-01 21:51:03 +02:00
|
|
|
* Get the furthest date that a never-ending show
|
2011-11-11 20:54:08 +01:00
|
|
|
* should be populated until.
|
|
|
|
*
|
|
|
|
* Returns null if the value hasn't been set, otherwise returns
|
2012-04-01 21:51:03 +02:00
|
|
|
* a DateTime object representing the date.
|
|
|
|
*
|
2011-11-11 20:54:08 +01:00
|
|
|
* @return DateTime (in UTC Timezone)
|
|
|
|
*/
|
2012-07-16 03:17:13 +02:00
|
|
|
public static function GetShowsPopulatedUntil()
|
|
|
|
{
|
2021-10-11 16:10:47 +02:00
|
|
|
$date = self::getValue('shows_populated_until');
|
2012-04-01 21:51:03 +02:00
|
|
|
|
2021-10-11 16:10:47 +02:00
|
|
|
if ($date == '') {
|
2011-11-11 20:54:08 +01:00
|
|
|
return null;
|
|
|
|
}
|
2021-10-11 16:10:47 +02:00
|
|
|
|
|
|
|
return new DateTime($date, new DateTimeZone('UTC'));
|
2011-02-05 22:00:05 +01:00
|
|
|
}
|
2020-05-04 06:32:52 +02:00
|
|
|
|
2013-05-02 22:52:30 +02:00
|
|
|
public static function SetDefaultCrossfadeDuration($duration)
|
|
|
|
{
|
2021-10-11 16:10:47 +02:00
|
|
|
self::setValue('default_crossfade_duration', $duration);
|
2013-05-02 22:52:30 +02:00
|
|
|
}
|
2020-05-04 06:32:52 +02:00
|
|
|
|
2013-05-02 22:52:30 +02:00
|
|
|
public static function GetDefaultCrossfadeDuration()
|
|
|
|
{
|
2021-10-11 16:10:47 +02:00
|
|
|
$duration = self::getValue('default_crossfade_duration');
|
2020-05-04 06:32:52 +02:00
|
|
|
|
2021-10-11 16:10:47 +02:00
|
|
|
if ($duration === '') {
|
2014-11-05 23:04:18 +01:00
|
|
|
// the default value of the fade is 00.5
|
2021-10-11 16:10:47 +02:00
|
|
|
return '0';
|
2014-11-05 23:04:18 +01:00
|
|
|
}
|
2020-05-04 06:32:52 +02:00
|
|
|
|
2014-11-05 23:04:18 +01:00
|
|
|
return $duration;
|
2013-05-02 22:15:21 +02:00
|
|
|
}
|
2020-05-04 06:32:52 +02:00
|
|
|
|
2013-04-29 23:01:08 +02:00
|
|
|
public static function SetDefaultFadeIn($fade)
|
|
|
|
{
|
2021-10-11 16:10:47 +02:00
|
|
|
self::setValue('default_fade_in', $fade);
|
2013-04-29 23:01:08 +02:00
|
|
|
}
|
2020-05-04 06:32:52 +02:00
|
|
|
|
2013-04-29 23:01:08 +02:00
|
|
|
public static function GetDefaultFadeIn()
|
|
|
|
{
|
2021-10-11 16:10:47 +02:00
|
|
|
$fade = self::getValue('default_fade_in');
|
2020-05-04 06:32:52 +02:00
|
|
|
|
2021-10-11 16:10:47 +02:00
|
|
|
if ($fade === '') {
|
2014-11-05 23:04:18 +01:00
|
|
|
// the default value of the fade is 00.5
|
2021-10-11 16:10:47 +02:00
|
|
|
return '0.5';
|
2014-11-05 23:04:18 +01:00
|
|
|
}
|
2020-05-04 06:32:52 +02:00
|
|
|
|
2014-11-05 23:04:18 +01:00
|
|
|
return $fade;
|
2013-04-29 22:55:08 +02:00
|
|
|
}
|
2020-05-04 06:32:52 +02:00
|
|
|
|
2013-04-29 23:01:08 +02:00
|
|
|
public static function SetDefaultFadeOut($fade)
|
|
|
|
{
|
2021-10-11 16:10:47 +02:00
|
|
|
self::setValue('default_fade_out', $fade);
|
2013-04-29 23:01:08 +02:00
|
|
|
}
|
2020-05-04 06:32:52 +02:00
|
|
|
|
2013-04-29 23:01:08 +02:00
|
|
|
public static function GetDefaultFadeOut()
|
|
|
|
{
|
2021-10-11 16:10:47 +02:00
|
|
|
$fade = self::getValue('default_fade_out');
|
2020-05-04 06:32:52 +02:00
|
|
|
|
2021-10-11 16:10:47 +02:00
|
|
|
if ($fade === '') {
|
2015-01-13 18:18:57 +01:00
|
|
|
// the default value of the fade is 0.5
|
2021-10-11 16:10:47 +02:00
|
|
|
return '0.5';
|
2014-11-05 23:04:18 +01:00
|
|
|
}
|
2020-05-04 06:32:52 +02:00
|
|
|
|
2014-11-05 23:04:18 +01:00
|
|
|
return $fade;
|
2013-04-29 22:55:08 +02:00
|
|
|
}
|
2011-02-05 22:00:05 +01:00
|
|
|
|
2012-07-16 03:17:13 +02:00
|
|
|
public static function SetDefaultFade($fade)
|
|
|
|
{
|
2021-10-11 16:10:47 +02:00
|
|
|
self::setValue('default_fade', $fade);
|
2011-02-11 23:46:55 +01:00
|
|
|
}
|
|
|
|
|
2012-07-16 03:17:13 +02:00
|
|
|
public static function SetDefaultTransitionFade($fade)
|
|
|
|
{
|
2021-10-11 16:10:47 +02:00
|
|
|
self::setValue('default_transition_fade', $fade);
|
2012-04-01 21:51:03 +02:00
|
|
|
|
2021-10-11 16:10:47 +02:00
|
|
|
$eventType = 'update_transition_fade';
|
|
|
|
$md = ['transition_fade' => $fade];
|
2012-03-21 03:16:17 +01:00
|
|
|
Application_Model_RabbitMq::SendMessageToPypo($eventType, $md);
|
|
|
|
}
|
2012-04-01 21:51:03 +02:00
|
|
|
|
2012-07-16 03:17:13 +02:00
|
|
|
public static function GetDefaultTransitionFade()
|
|
|
|
{
|
2021-10-11 16:10:47 +02:00
|
|
|
$transition_fade = self::getValue('default_transition_fade');
|
|
|
|
|
|
|
|
return ($transition_fade == '') ? '0.000' : $transition_fade;
|
2012-03-21 03:16:17 +01:00
|
|
|
}
|
2011-02-11 23:46:55 +01:00
|
|
|
|
2012-07-16 03:17:13 +02:00
|
|
|
public static function SetStreamLabelFormat($type)
|
|
|
|
{
|
2021-10-11 16:10:47 +02:00
|
|
|
self::setValue('stream_label_format', $type);
|
2012-04-01 21:51:03 +02:00
|
|
|
|
2021-10-11 16:10:47 +02:00
|
|
|
$eventType = 'update_stream_format';
|
|
|
|
$md = ['stream_format' => $type];
|
2012-04-01 21:51:03 +02:00
|
|
|
|
2012-02-11 00:43:40 +01:00
|
|
|
Application_Model_RabbitMq::SendMessageToPypo($eventType, $md);
|
2011-03-04 18:07:22 +01:00
|
|
|
}
|
|
|
|
|
2012-07-16 03:17:13 +02:00
|
|
|
public static function GetStreamLabelFormat()
|
|
|
|
{
|
2021-10-11 16:10:47 +02:00
|
|
|
return self::getValue('stream_label_format');
|
2011-03-04 18:07:22 +01:00
|
|
|
}
|
|
|
|
|
2022-08-06 19:18:40 +02:00
|
|
|
public static function getOffAirMeta()
|
|
|
|
{
|
|
|
|
return self::getValue('off_air_meta');
|
|
|
|
}
|
|
|
|
|
|
|
|
public static function setOffAirMeta($offAirMeta)
|
|
|
|
{
|
|
|
|
self::setValue('off_air_meta', $offAirMeta);
|
2022-08-17 15:09:57 +02:00
|
|
|
|
|
|
|
Application_Model_RabbitMq::SendMessageToPypo(
|
|
|
|
'update_message_offline',
|
|
|
|
['message_offline' => $offAirMeta]
|
|
|
|
);
|
2022-08-06 19:18:40 +02:00
|
|
|
}
|
|
|
|
|
2012-07-16 03:17:13 +02:00
|
|
|
public static function GetStationName()
|
|
|
|
{
|
2021-10-11 16:10:47 +02:00
|
|
|
return self::getValue('station_name');
|
2011-03-04 18:07:22 +01:00
|
|
|
}
|
2011-03-18 22:15:12 +01:00
|
|
|
|
2015-03-03 21:10:10 +01:00
|
|
|
public static function SetStationName($station_name)
|
|
|
|
{
|
2021-10-11 16:10:47 +02:00
|
|
|
self::setValue('station_name', $station_name);
|
2015-03-03 21:10:10 +01:00
|
|
|
}
|
|
|
|
|
2012-07-16 03:17:13 +02:00
|
|
|
public static function SetAllow3rdPartyApi($bool)
|
|
|
|
{
|
2021-10-11 16:10:47 +02:00
|
|
|
self::setValue('third_party_api', $bool);
|
2011-03-30 21:34:35 +02:00
|
|
|
}
|
2017-03-17 02:10:04 +01:00
|
|
|
|
2012-07-16 03:17:13 +02:00
|
|
|
public static function GetAllow3rdPartyApi()
|
|
|
|
{
|
2021-10-11 16:10:47 +02:00
|
|
|
$val = self::getValue('third_party_api');
|
|
|
|
|
|
|
|
return (strlen($val) == 0) ? '1' : $val;
|
2011-03-30 21:34:35 +02:00
|
|
|
}
|
2011-06-21 11:20:35 +02:00
|
|
|
|
2017-03-16 21:48:31 +01:00
|
|
|
public static function SetPodcastAlbumOverride($bool)
|
|
|
|
{
|
2021-10-11 16:10:47 +02:00
|
|
|
self::setValue('podcast_album_override', $bool);
|
2017-03-16 21:48:31 +01:00
|
|
|
}
|
2020-05-04 06:32:52 +02:00
|
|
|
|
2017-03-16 21:48:31 +01:00
|
|
|
public static function GetPodcastAlbumOverride()
|
|
|
|
{
|
2021-10-11 16:10:47 +02:00
|
|
|
$val = self::getValue('podcast_album_override');
|
|
|
|
|
2017-03-17 02:10:04 +01:00
|
|
|
return $val === '1' ? true : false;
|
2017-03-16 21:48:31 +01:00
|
|
|
}
|
|
|
|
|
2017-08-23 18:16:42 +02:00
|
|
|
public static function SetPodcastAutoSmartblock($bool)
|
|
|
|
{
|
2021-10-11 16:10:47 +02:00
|
|
|
self::setValue('podcast_auto_smartblock', $bool);
|
2017-08-23 18:16:42 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public static function GetPodcastAutoSmartblock()
|
|
|
|
{
|
2021-10-11 16:10:47 +02:00
|
|
|
$val = self::getValue('podcast_auto_smartblock');
|
|
|
|
|
2017-08-23 18:16:42 +02:00
|
|
|
return $val === '1' ? true : false;
|
|
|
|
}
|
|
|
|
|
2020-05-04 06:32:52 +02:00
|
|
|
public static function SetTrackTypeDefault($tracktype)
|
|
|
|
{
|
2021-10-11 16:10:47 +02:00
|
|
|
self::setValue('tracktype_default', $tracktype);
|
2020-05-04 06:32:52 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public static function GetTrackTypeDefault()
|
|
|
|
{
|
2021-10-11 16:10:47 +02:00
|
|
|
return self::getValue('tracktype_default');
|
2020-05-04 06:32:52 +02:00
|
|
|
}
|
|
|
|
|
2019-01-21 01:20:13 +01:00
|
|
|
public static function GetIntroPlaylist()
|
|
|
|
{
|
2021-10-11 16:10:47 +02:00
|
|
|
return self::getValue('intro_playlist');
|
2019-01-21 01:20:13 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public static function GetOutroPlaylist()
|
|
|
|
{
|
2021-10-11 16:10:47 +02:00
|
|
|
return self::getValue('outro_playlist');
|
2019-01-21 01:20:13 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public static function SetIntroPlaylist($playlist)
|
|
|
|
{
|
2021-10-11 16:10:47 +02:00
|
|
|
self::setValue('intro_playlist', $playlist);
|
2019-01-21 01:20:13 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public static function SetOutroPlaylist($playlist)
|
|
|
|
{
|
2021-10-11 16:10:47 +02:00
|
|
|
self::setValue('outro_playlist', $playlist);
|
2019-01-21 01:20:13 +01:00
|
|
|
}
|
2017-08-23 18:16:42 +02:00
|
|
|
|
2012-07-16 03:17:13 +02:00
|
|
|
public static function SetPhone($phone)
|
|
|
|
{
|
2021-10-11 16:10:47 +02:00
|
|
|
self::setValue('phone', $phone);
|
2011-06-09 15:56:32 +02:00
|
|
|
}
|
2011-06-21 11:20:35 +02:00
|
|
|
|
2012-07-16 03:17:13 +02:00
|
|
|
public static function GetPhone()
|
|
|
|
{
|
2021-10-11 16:10:47 +02:00
|
|
|
return self::getValue('phone');
|
2011-06-09 15:56:32 +02:00
|
|
|
}
|
2011-06-21 11:20:35 +02:00
|
|
|
|
2012-07-16 03:17:13 +02:00
|
|
|
public static function SetEmail($email)
|
|
|
|
{
|
2021-10-11 16:10:47 +02:00
|
|
|
self::setValue('email', $email);
|
2011-06-09 15:56:32 +02:00
|
|
|
}
|
2011-06-21 11:20:35 +02:00
|
|
|
|
2012-07-16 03:17:13 +02:00
|
|
|
public static function GetEmail()
|
|
|
|
{
|
2021-10-11 16:10:47 +02:00
|
|
|
return self::getValue('email');
|
2011-06-09 15:56:32 +02:00
|
|
|
}
|
2011-06-21 11:20:35 +02:00
|
|
|
|
2012-07-16 03:17:13 +02:00
|
|
|
public static function SetStationWebSite($site)
|
|
|
|
{
|
2021-10-11 16:10:47 +02:00
|
|
|
self::setValue('station_website', $site);
|
2011-06-09 15:56:32 +02:00
|
|
|
}
|
2011-06-21 11:20:35 +02:00
|
|
|
|
2012-07-16 03:17:13 +02:00
|
|
|
public static function GetStationWebSite()
|
|
|
|
{
|
2021-10-11 16:10:47 +02:00
|
|
|
return self::getValue('station_website');
|
2011-06-09 15:56:32 +02:00
|
|
|
}
|
2011-06-21 11:20:35 +02:00
|
|
|
|
2012-07-16 03:17:13 +02:00
|
|
|
public static function SetSupportFeedback($feedback)
|
|
|
|
{
|
2021-10-11 16:10:47 +02:00
|
|
|
self::setValue('support_feedback', $feedback);
|
2011-06-09 15:56:32 +02:00
|
|
|
}
|
2011-06-21 11:20:35 +02:00
|
|
|
|
2012-07-16 03:17:13 +02:00
|
|
|
public static function GetSupportFeedback()
|
|
|
|
{
|
2021-10-11 16:10:47 +02:00
|
|
|
return self::getValue('support_feedback');
|
2011-06-09 15:56:32 +02:00
|
|
|
}
|
2011-06-21 11:20:35 +02:00
|
|
|
|
2012-07-16 03:17:13 +02:00
|
|
|
public static function SetPublicise($publicise)
|
|
|
|
{
|
2021-10-11 16:10:47 +02:00
|
|
|
self::setValue('publicise', $publicise);
|
2011-06-15 18:06:50 +02:00
|
|
|
}
|
2011-06-21 11:20:35 +02:00
|
|
|
|
2012-07-16 03:17:13 +02:00
|
|
|
public static function GetPublicise()
|
|
|
|
{
|
2021-10-11 16:10:47 +02:00
|
|
|
return self::getValue('publicise');
|
2011-06-15 18:06:50 +02:00
|
|
|
}
|
2011-06-21 11:20:35 +02:00
|
|
|
|
2012-07-16 03:17:13 +02:00
|
|
|
public static function SetRegistered($registered)
|
|
|
|
{
|
2021-10-11 16:10:47 +02:00
|
|
|
self::setValue('registered', $registered);
|
2011-06-09 15:56:32 +02:00
|
|
|
}
|
2011-06-21 11:20:35 +02:00
|
|
|
|
2012-07-16 03:17:13 +02:00
|
|
|
public static function GetRegistered()
|
|
|
|
{
|
2021-10-11 16:10:47 +02:00
|
|
|
return self::getValue('registered');
|
2011-06-09 15:56:32 +02:00
|
|
|
}
|
2011-06-21 11:20:35 +02:00
|
|
|
|
2012-07-16 03:17:13 +02:00
|
|
|
public static function SetStationCountry($country)
|
|
|
|
{
|
2021-10-11 16:10:47 +02:00
|
|
|
self::setValue('country', $country);
|
2011-06-15 18:06:50 +02:00
|
|
|
}
|
2011-06-21 11:20:35 +02:00
|
|
|
|
2012-07-16 03:17:13 +02:00
|
|
|
public static function GetStationCountry()
|
|
|
|
{
|
2021-10-11 16:10:47 +02:00
|
|
|
return self::getValue('country');
|
2011-06-15 18:06:50 +02:00
|
|
|
}
|
2011-06-21 11:20:35 +02:00
|
|
|
|
2012-07-16 03:17:13 +02:00
|
|
|
public static function SetStationCity($city)
|
|
|
|
{
|
2021-10-11 16:10:47 +02:00
|
|
|
self::setValue('city', $city);
|
2011-06-15 18:06:50 +02:00
|
|
|
}
|
2011-06-21 11:20:35 +02:00
|
|
|
|
2012-07-16 03:17:13 +02:00
|
|
|
public static function GetStationCity()
|
|
|
|
{
|
2021-10-11 16:10:47 +02:00
|
|
|
return self::getValue('city');
|
2011-06-15 18:06:50 +02:00
|
|
|
}
|
2011-06-21 11:20:35 +02:00
|
|
|
|
2012-07-16 03:17:13 +02:00
|
|
|
public static function SetStationDescription($description)
|
|
|
|
{
|
2021-10-11 16:10:47 +02:00
|
|
|
self::setValue('description', $description);
|
2011-06-15 18:06:50 +02:00
|
|
|
}
|
2011-06-21 11:20:35 +02:00
|
|
|
|
2012-07-16 03:17:13 +02:00
|
|
|
public static function GetStationDescription()
|
|
|
|
{
|
2021-10-11 16:10:47 +02:00
|
|
|
$description = self::getValue('description');
|
2015-06-09 15:01:15 +02:00
|
|
|
if (!empty($description)) {
|
|
|
|
return $description;
|
|
|
|
}
|
2021-10-11 16:10:47 +02:00
|
|
|
|
|
|
|
return sprintf(_('Powered by %s'), SAAS_PRODUCT_BRANDING_NAME);
|
2011-06-15 18:06:50 +02:00
|
|
|
}
|
2011-09-30 00:11:22 +02:00
|
|
|
|
2013-09-25 20:33:43 +02:00
|
|
|
// Returns station default timezone (from preferences)
|
2013-01-09 19:38:38 +01:00
|
|
|
public static function GetDefaultTimezone()
|
2012-07-16 03:17:13 +02:00
|
|
|
{
|
2022-09-14 12:48:08 +02:00
|
|
|
return Config::get('general.timezone');
|
2011-08-12 20:14:07 +02:00
|
|
|
}
|
2013-01-03 22:19:02 +01:00
|
|
|
|
2013-11-11 22:20:51 +01:00
|
|
|
public static function SetUserTimezone($timezone = null)
|
2013-01-09 19:38:38 +01:00
|
|
|
{
|
2021-10-11 16:10:47 +02:00
|
|
|
self::setValue('user_timezone', $timezone, true);
|
2013-01-09 19:38:38 +01:00
|
|
|
}
|
|
|
|
|
2013-11-11 22:32:43 +01:00
|
|
|
public static function GetUserTimezone()
|
2013-01-09 19:38:38 +01:00
|
|
|
{
|
2021-10-11 16:10:47 +02:00
|
|
|
$timezone = self::getValue('user_timezone', true);
|
2013-01-16 18:42:58 +01:00
|
|
|
if (!$timezone) {
|
|
|
|
return self::GetDefaultTimezone();
|
|
|
|
}
|
2021-10-11 16:10:47 +02:00
|
|
|
|
|
|
|
return $timezone;
|
2013-01-09 19:38:38 +01:00
|
|
|
}
|
|
|
|
|
2013-09-25 20:33:43 +02:00
|
|
|
// Always attempts to returns the current user's personal timezone setting
|
2013-01-09 19:38:38 +01:00
|
|
|
public static function GetTimezone()
|
|
|
|
{
|
2013-11-11 22:20:51 +01:00
|
|
|
$userId = self::getUserId();
|
2020-05-04 06:32:52 +02:00
|
|
|
|
2013-11-11 22:20:51 +01:00
|
|
|
if (!is_null($userId)) {
|
|
|
|
return self::GetUserTimezone();
|
2013-01-09 19:38:38 +01:00
|
|
|
}
|
2021-10-11 16:10:47 +02:00
|
|
|
|
|
|
|
return self::GetDefaultTimezone();
|
2013-01-09 19:38:38 +01:00
|
|
|
}
|
|
|
|
|
2013-01-03 22:19:02 +01:00
|
|
|
// This is the language setting on preferences page
|
2013-01-08 00:18:40 +01:00
|
|
|
public static function SetDefaultLocale($locale)
|
2012-11-21 18:44:50 +01:00
|
|
|
{
|
2021-10-11 16:10:47 +02:00
|
|
|
self::setValue('locale', $locale);
|
2012-11-21 18:44:50 +01:00
|
|
|
}
|
2013-01-03 22:19:02 +01:00
|
|
|
|
2013-01-08 00:18:40 +01:00
|
|
|
public static function GetDefaultLocale()
|
2012-11-21 18:44:50 +01:00
|
|
|
{
|
2021-10-11 16:10:47 +02:00
|
|
|
return self::getValue('locale');
|
2012-11-21 18:44:50 +01:00
|
|
|
}
|
2013-01-07 12:41:29 +01:00
|
|
|
|
2013-11-11 22:20:51 +01:00
|
|
|
public static function GetUserLocale()
|
2013-01-03 22:19:02 +01:00
|
|
|
{
|
2021-10-11 16:10:47 +02:00
|
|
|
$locale = self::getValue('user_locale', true);
|
2015-09-01 22:10:33 +02:00
|
|
|
// empty() checks for null and empty strings - more robust than !val
|
|
|
|
if (empty($locale)) {
|
2013-01-16 18:42:58 +01:00
|
|
|
return self::GetDefaultLocale();
|
|
|
|
}
|
2021-10-11 16:10:47 +02:00
|
|
|
|
|
|
|
return $locale;
|
2013-01-03 22:19:02 +01:00
|
|
|
}
|
|
|
|
|
2013-11-11 22:20:51 +01:00
|
|
|
public static function SetUserLocale($locale = null)
|
2013-01-03 22:19:02 +01:00
|
|
|
{
|
|
|
|
// When a new user is created they will get the default locale
|
|
|
|
// setting which the admin sets on preferences page
|
2021-10-11 16:10:47 +02:00
|
|
|
if (is_null($locale)) {
|
2013-01-08 00:18:40 +01:00
|
|
|
$locale = self::GetDefaultLocale();
|
2021-10-11 16:10:47 +02:00
|
|
|
}
|
|
|
|
self::setValue('user_locale', $locale, true);
|
2013-01-03 22:19:02 +01:00
|
|
|
}
|
|
|
|
|
2013-01-08 00:18:40 +01:00
|
|
|
public static function GetLocale()
|
2013-01-03 22:19:02 +01:00
|
|
|
{
|
2013-11-11 22:20:51 +01:00
|
|
|
$userId = self::getUserId();
|
2020-05-04 06:32:52 +02:00
|
|
|
|
2013-11-11 22:20:51 +01:00
|
|
|
if (!is_null($userId)) {
|
2013-11-11 22:32:43 +01:00
|
|
|
return self::GetUserLocale();
|
2013-01-08 00:18:40 +01:00
|
|
|
}
|
2021-10-11 16:10:47 +02:00
|
|
|
|
|
|
|
return self::GetDefaultLocale();
|
2013-01-03 22:19:02 +01:00
|
|
|
}
|
2011-06-21 11:20:35 +02:00
|
|
|
|
2012-07-16 03:17:13 +02:00
|
|
|
public static function SetStationLogo($imagePath)
|
|
|
|
{
|
2015-02-24 18:12:30 +01:00
|
|
|
if (empty($imagePath)) {
|
2021-10-11 16:10:47 +02:00
|
|
|
Logging::info('Removed station logo');
|
2012-07-11 00:51:32 +02:00
|
|
|
}
|
2015-02-24 18:12:30 +01:00
|
|
|
$image = @file_get_contents($imagePath);
|
|
|
|
$image = base64_encode($image);
|
2021-10-11 16:10:47 +02:00
|
|
|
self::setValue('logoImage', $image);
|
2011-06-15 18:06:50 +02:00
|
|
|
}
|
2011-06-21 11:20:35 +02:00
|
|
|
|
2012-07-16 03:17:13 +02:00
|
|
|
public static function GetStationLogo()
|
|
|
|
{
|
2021-10-11 16:10:47 +02:00
|
|
|
$logoImage = self::getValue('logoImage');
|
2015-06-03 17:53:32 +02:00
|
|
|
if (!empty($logoImage)) {
|
|
|
|
return $logoImage;
|
|
|
|
}
|
2021-10-11 16:10:47 +02:00
|
|
|
// We return the Airtime logo if no logo is set in the database.
|
|
|
|
// airtime_logo.png is stored under the public directory
|
2022-07-27 09:51:14 +02:00
|
|
|
$image = @file_get_contents(ROOT_PATH . '/public/' . DEFAULT_LOGO_FILE);
|
2021-10-11 16:10:47 +02:00
|
|
|
|
|
|
|
return base64_encode($image);
|
2011-06-15 18:06:50 +02:00
|
|
|
}
|
2020-05-04 06:32:52 +02:00
|
|
|
|
2014-04-23 21:41:15 +02:00
|
|
|
public static function SetUniqueId($id)
|
|
|
|
{
|
2021-10-11 16:10:47 +02:00
|
|
|
self::setValue('uniqueId', $id);
|
2014-04-23 21:41:15 +02:00
|
|
|
}
|
2011-06-21 11:20:35 +02:00
|
|
|
|
2012-07-16 03:17:13 +02:00
|
|
|
public static function GetUniqueId()
|
|
|
|
{
|
2021-10-11 16:10:47 +02:00
|
|
|
return self::getValue('uniqueId');
|
2011-06-15 18:06:50 +02:00
|
|
|
}
|
2011-06-21 11:20:35 +02:00
|
|
|
|
2012-04-01 21:51:03 +02:00
|
|
|
public static function GetCountryList()
|
|
|
|
{
|
2021-10-11 16:10:47 +02:00
|
|
|
$sql = 'SELECT * FROM cc_country';
|
2020-05-04 06:32:52 +02:00
|
|
|
|
2021-10-11 16:10:47 +02:00
|
|
|
$res = Application_Common_Database::prepareAndExecute($sql, []);
|
2013-05-13 17:42:11 +02:00
|
|
|
|
2021-10-11 16:10:47 +02:00
|
|
|
$out = [];
|
|
|
|
$out[''] = _('Select Country');
|
2012-07-16 03:17:13 +02:00
|
|
|
foreach ($res as $r) {
|
2021-10-11 16:10:47 +02:00
|
|
|
$out[$r['isocode']] = $r['name'];
|
2012-07-11 00:51:32 +02:00
|
|
|
}
|
2012-07-16 03:17:13 +02:00
|
|
|
|
2012-07-11 00:51:32 +02:00
|
|
|
return $out;
|
2011-06-15 18:06:50 +02:00
|
|
|
}
|
2011-06-21 11:20:35 +02:00
|
|
|
|
2021-10-11 16:10:47 +02:00
|
|
|
public static function GetSystemInfo($returnArray = false, $p_testing = false)
|
2012-05-11 23:27:14 +02:00
|
|
|
{
|
2012-07-11 00:51:32 +02:00
|
|
|
exec('/usr/bin/airtime-check-system --no-color', $output);
|
|
|
|
$output = preg_replace('/\s+/', ' ', $output);
|
|
|
|
|
2021-10-11 16:10:47 +02:00
|
|
|
$systemInfoArray = [];
|
2012-07-16 03:17:13 +02:00
|
|
|
foreach ($output as $key => &$out) {
|
2012-07-11 00:51:32 +02:00
|
|
|
$info = explode('=', $out);
|
2012-07-16 03:17:13 +02:00
|
|
|
if (isset($info[1])) {
|
2012-07-11 00:51:32 +02:00
|
|
|
$key = str_replace(' ', '_', trim($info[0]));
|
|
|
|
$key = strtoupper($key);
|
2022-07-07 20:01:15 +02:00
|
|
|
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'
|
|
|
|
) {
|
2012-07-16 03:17:13 +02:00
|
|
|
if ($key == 'AIRTIME_VERSION') {
|
2012-07-11 00:51:32 +02:00
|
|
|
// remove hash tag on the version string
|
|
|
|
$version = explode('+', $info[1]);
|
|
|
|
$systemInfoArray[$key] = $version[0];
|
2012-07-16 03:17:13 +02:00
|
|
|
} else {
|
2012-07-11 00:51:32 +02:00
|
|
|
$systemInfoArray[$key] = $info[1];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-10-11 16:10:47 +02:00
|
|
|
$outputArray = [];
|
2012-07-11 00:51:32 +02:00
|
|
|
|
|
|
|
$outputArray['LIVE_DURATION'] = Application_Model_LiveLog::GetLiveShowDuration($p_testing);
|
|
|
|
$outputArray['SCHEDULED_DURATION'] = Application_Model_LiveLog::GetScheduledDuration($p_testing);
|
2012-10-19 17:09:34 +02:00
|
|
|
|
2012-07-11 00:51:32 +02:00
|
|
|
$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
|
2021-10-11 16:10:47 +02:00
|
|
|
if (isset($systemInfoArray['AIRTIME_VERSION_URL'])) {
|
|
|
|
$url = $systemInfoArray['AIRTIME_VERSION_URL'];
|
|
|
|
$index = strpos($url, '/api/');
|
|
|
|
$url = substr($url, 0, $index);
|
2020-05-04 06:32:52 +02:00
|
|
|
|
2021-10-11 16:10:47 +02:00
|
|
|
$headerInfo = get_headers(trim($url), 1);
|
|
|
|
$outputArray['WEB_SERVER'] = $headerInfo['Server'][0];
|
2012-07-11 00:51:32 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
$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();
|
2015-06-26 20:42:52 +02:00
|
|
|
$outputArray['NUM_OF_PAST_SHOWS'] = Application_Model_ShowInstance::GetShowInstanceCount(gmdate(DEFAULT_TIMESTAMP_FORMAT));
|
2012-07-11 00:51:32 +02:00
|
|
|
$outputArray['UNIQUE_ID'] = self::GetUniqueId();
|
|
|
|
$outputArray['INSTALL_METHOD'] = self::GetInstallMethod();
|
|
|
|
$outputArray['NUM_OF_STREAMS'] = self::GetNumOfStreams();
|
|
|
|
$outputArray['STREAM_INFO'] = Application_Model_StreamSetting::getStreamInfoForDataCollection();
|
|
|
|
|
|
|
|
$outputArray = array_merge($systemInfoArray, $outputArray);
|
|
|
|
|
|
|
|
$outputString = "\n";
|
2012-07-16 03:17:13 +02:00
|
|
|
foreach ($outputArray as $key => $out) {
|
2021-10-11 16:10:47 +02:00
|
|
|
if ($key == 'STREAM_INFO') {
|
|
|
|
$outputString .= $key . " :\n";
|
2012-07-16 03:17:13 +02:00
|
|
|
foreach ($out as $s_info) {
|
|
|
|
foreach ($s_info as $k => $v) {
|
2021-10-11 16:10:47 +02:00
|
|
|
$outputString .= "\t" . strtoupper($k) . ' : ' . $v . "\n";
|
2012-07-11 00:51:32 +02:00
|
|
|
}
|
|
|
|
}
|
2012-07-16 03:17:13 +02:00
|
|
|
} else {
|
2021-10-11 16:10:47 +02:00
|
|
|
$outputString .= $key . ' : ' . $out . "\n";
|
2012-07-11 00:51:32 +02:00
|
|
|
}
|
|
|
|
}
|
2012-07-16 03:17:13 +02:00
|
|
|
if ($returnArray) {
|
2012-07-11 00:51:32 +02:00
|
|
|
$outputArray['PROMOTE'] = self::GetPublicise();
|
|
|
|
$outputArray['LOGOIMG'] = self::GetStationLogo();
|
2012-07-16 03:17:13 +02:00
|
|
|
|
2012-07-11 00:51:32 +02:00
|
|
|
return $outputArray;
|
|
|
|
}
|
2021-10-11 16:10:47 +02:00
|
|
|
|
|
|
|
return $outputString;
|
2011-06-15 18:06:50 +02:00
|
|
|
}
|
2012-04-01 21:51:03 +02:00
|
|
|
|
2012-07-16 03:17:13 +02:00
|
|
|
public static function GetInstallMethod()
|
|
|
|
{
|
2012-02-17 21:39:31 +01:00
|
|
|
$easy_install = file_exists('/usr/bin/airtime-easy-setup');
|
2011-11-09 19:13:21 +01:00
|
|
|
$debian_install = file_exists('/var/lib/dpkg/info/airtime.config');
|
2012-07-16 03:17:13 +02:00
|
|
|
if ($debian_install) {
|
|
|
|
if ($easy_install) {
|
2021-10-11 16:10:47 +02:00
|
|
|
return 'easy_install';
|
2011-11-09 19:13:21 +01:00
|
|
|
}
|
2021-10-11 16:10:47 +02:00
|
|
|
|
|
|
|
return 'debian_install';
|
2011-11-09 19:13:21 +01:00
|
|
|
}
|
2021-10-11 16:10:47 +02:00
|
|
|
|
|
|
|
return 'manual_install';
|
2011-11-09 19:13:21 +01:00
|
|
|
}
|
2011-06-21 11:20:35 +02:00
|
|
|
|
2012-08-28 23:30:34 +02:00
|
|
|
public static function SetRemindMeDate($p_never = false)
|
2012-07-16 03:17:13 +02:00
|
|
|
{
|
2012-08-28 23:30:34 +02:00
|
|
|
if ($p_never) {
|
2021-10-11 16:10:47 +02:00
|
|
|
self::setValue('remindme', -1);
|
2012-08-28 23:30:34 +02:00
|
|
|
} else {
|
2021-10-11 16:10:47 +02:00
|
|
|
$weekAfter = mktime(0, 0, 0, gmdate('m'), gmdate('d') + 7, gmdate('Y'));
|
|
|
|
self::setValue('remindme', $weekAfter);
|
2012-08-28 23:30:34 +02:00
|
|
|
}
|
2011-06-09 15:56:32 +02:00
|
|
|
}
|
2011-06-21 11:20:35 +02:00
|
|
|
|
2012-07-16 03:17:13 +02:00
|
|
|
public static function GetRemindMeDate()
|
|
|
|
{
|
2021-10-11 16:10:47 +02:00
|
|
|
return self::getValue('remindme');
|
2011-06-15 23:51:44 +02:00
|
|
|
}
|
2011-09-30 00:11:22 +02:00
|
|
|
|
2012-07-16 03:17:13 +02:00
|
|
|
public static function SetImportTimestamp()
|
|
|
|
{
|
2011-08-08 20:44:05 +02:00
|
|
|
$now = time();
|
2021-10-11 16:10:47 +02:00
|
|
|
if (self::GetImportTimestamp() + 5 < $now) {
|
|
|
|
self::setValue('import_timestamp', $now);
|
2011-08-09 16:40:10 +02:00
|
|
|
}
|
2011-08-08 20:44:05 +02:00
|
|
|
}
|
2011-09-30 00:11:22 +02:00
|
|
|
|
2012-07-16 03:17:13 +02:00
|
|
|
public static function GetImportTimestamp()
|
|
|
|
{
|
2021-10-11 16:10:47 +02:00
|
|
|
return (int) self::getValue('import_timestamp');
|
2011-08-08 20:44:05 +02:00
|
|
|
}
|
2011-09-30 00:11:22 +02:00
|
|
|
|
2012-07-16 03:17:13 +02:00
|
|
|
public static function SetPrivacyPolicyCheck($flag)
|
|
|
|
{
|
2021-10-11 16:10:47 +02:00
|
|
|
self::setValue('privacy_policy', $flag);
|
2011-08-23 21:11:21 +02:00
|
|
|
}
|
2011-09-30 00:11:22 +02:00
|
|
|
|
2012-07-16 03:17:13 +02:00
|
|
|
public static function GetPrivacyPolicyCheck()
|
|
|
|
{
|
2021-10-11 16:10:47 +02:00
|
|
|
return self::getValue('privacy_policy');
|
2011-08-23 21:11:21 +02:00
|
|
|
}
|
2011-09-30 00:11:22 +02:00
|
|
|
|
2012-07-16 03:17:13 +02:00
|
|
|
public static function GetNumOfStreams()
|
|
|
|
{
|
2022-09-06 12:00:50 +02:00
|
|
|
return count(Config::get('stream.outputs.merged'));
|
2011-08-26 21:41:20 +02:00
|
|
|
}
|
2011-09-30 00:11:22 +02:00
|
|
|
|
2012-07-16 03:17:13 +02:00
|
|
|
public static function SetEnableStreamConf($bool)
|
|
|
|
{
|
2021-10-11 16:10:47 +02:00
|
|
|
self::setValue('enable_stream_conf', $bool);
|
2011-09-02 22:13:30 +02:00
|
|
|
}
|
2011-09-30 00:11:22 +02:00
|
|
|
|
2012-07-16 03:17:13 +02:00
|
|
|
public static function GetEnableStreamConf()
|
|
|
|
{
|
2021-10-11 16:10:47 +02:00
|
|
|
if (self::getValue('enable_stream_conf') == null) {
|
|
|
|
return 'true';
|
2011-10-03 21:25:55 +02:00
|
|
|
}
|
2012-07-16 03:17:13 +02:00
|
|
|
|
2021-10-11 16:10:47 +02:00
|
|
|
return self::getValue('enable_stream_conf');
|
2011-09-23 22:26:19 +02:00
|
|
|
}
|
2015-01-19 19:41:23 +01:00
|
|
|
|
|
|
|
public static function GetSchemaVersion()
|
|
|
|
{
|
2022-03-14 11:15:04 +01:00
|
|
|
CcPrefPeer::clearInstancePool(); // Ensure we don't get a cached Propel object (cached DB results)
|
|
|
|
// because we're updating this version number within this HTTP request as well.
|
2015-01-19 19:41:23 +01:00
|
|
|
|
2022-03-14 11:15:04 +01:00
|
|
|
// New versions use schema_version
|
2015-05-22 22:05:29 +02:00
|
|
|
$pref = CcPrefQuery::create()
|
|
|
|
->filterByKeystr('schema_version')
|
2022-01-23 19:15:55 +01:00
|
|
|
->findOne();
|
2015-01-19 19:41:23 +01:00
|
|
|
|
2015-05-22 22:05:29 +02:00
|
|
|
if (empty($pref)) {
|
2022-03-14 11:15:04 +01:00
|
|
|
// Pre-2.5.2 releases all used this ambiguous "system_version" key to represent both the code and schema versions...
|
2015-05-22 22:05:29 +02:00
|
|
|
$pref = CcPrefQuery::create()
|
|
|
|
->filterByKeystr('system_version')
|
2022-01-23 19:15:55 +01:00
|
|
|
->findOne();
|
2015-05-22 22:05:29 +02:00
|
|
|
}
|
2021-10-11 16:10:47 +02:00
|
|
|
|
|
|
|
return $pref->getValStr();
|
2015-01-19 19:41:23 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public static function SetSchemaVersion($version)
|
2014-04-23 21:41:15 +02:00
|
|
|
{
|
2021-10-11 16:10:47 +02:00
|
|
|
self::setValue('schema_version', $version);
|
2014-04-23 21:41:15 +02:00
|
|
|
}
|
2011-09-23 22:26:19 +02:00
|
|
|
|
2012-07-16 03:17:13 +02:00
|
|
|
public static function GetLatestVersion()
|
|
|
|
{
|
2017-03-10 20:28:54 +01:00
|
|
|
$config = Config::getConfig();
|
2017-03-20 20:34:23 +01:00
|
|
|
|
|
|
|
$latest = json_decode(self::getValue('latest_version'));
|
|
|
|
$nextCheck = self::getValue('latest_version_nextcheck');
|
|
|
|
if ($latest && $nextCheck > time()) {
|
|
|
|
return $latest;
|
|
|
|
}
|
|
|
|
|
|
|
|
$rss = new SimplePie();
|
2021-10-11 16:10:47 +02:00
|
|
|
$rss->set_feed_url([LIBRETIME_UPDATE_FEED]);
|
2017-03-20 20:34:23 +01:00
|
|
|
$rss->enable_cache(false);
|
|
|
|
$rss->init();
|
|
|
|
$rss->handle_content_type();
|
|
|
|
// get all available versions ut to default github api limit
|
2021-10-11 16:10:47 +02:00
|
|
|
$versions = [];
|
2017-03-20 20:34:23 +01:00
|
|
|
foreach ($rss->get_items() as $item) {
|
|
|
|
$versions[] = $item->get_title();
|
|
|
|
}
|
|
|
|
$latest = $versions;
|
|
|
|
self::setValue('latest_version_nextcheck', strtotime('+1 week'));
|
|
|
|
if (empty($latest)) {
|
2021-10-11 16:10:47 +02:00
|
|
|
return [$config['airtime_version']];
|
2011-11-14 06:34:53 +01:00
|
|
|
}
|
2018-11-21 02:25:27 +01:00
|
|
|
|
|
|
|
self::setValue('latest_version', json_encode($latest));
|
2021-10-11 16:10:47 +02:00
|
|
|
|
2018-11-21 02:25:27 +01:00
|
|
|
return $latest;
|
2011-11-14 06:34:53 +01:00
|
|
|
}
|
2012-04-01 21:51:03 +02:00
|
|
|
|
2012-07-16 03:17:13 +02:00
|
|
|
public static function SetLatestVersion($version)
|
|
|
|
{
|
2021-10-12 11:09:46 +02:00
|
|
|
$pattern = '/^[0-9]+\.[0-9]+\.[0-9]+/';
|
2012-07-16 03:17:13 +02:00
|
|
|
if (preg_match($pattern, $version)) {
|
2021-10-11 16:10:47 +02:00
|
|
|
self::setValue('latest_version', $version);
|
2011-11-14 06:34:53 +01:00
|
|
|
}
|
|
|
|
}
|
2012-04-01 21:51:03 +02:00
|
|
|
|
2012-07-16 03:17:13 +02:00
|
|
|
public static function GetLatestLink()
|
|
|
|
{
|
2021-10-11 16:10:47 +02:00
|
|
|
$link = self::getValue('latest_link');
|
2012-07-16 03:17:13 +02:00
|
|
|
if ($link == null || strlen($link) == 0) {
|
2017-03-20 20:34:23 +01:00
|
|
|
return LIBRETIME_WHATS_NEW_URL;
|
2011-11-17 20:10:26 +01:00
|
|
|
}
|
2021-10-11 16:10:47 +02:00
|
|
|
|
|
|
|
return $link;
|
2011-11-17 20:10:26 +01:00
|
|
|
}
|
2012-04-01 21:51:03 +02:00
|
|
|
|
2012-07-16 03:17:13 +02:00
|
|
|
public static function SetLatestLink($link)
|
|
|
|
{
|
2021-10-11 16:10:47 +02:00
|
|
|
$pattern = '#^(http|https|ftp)://' .
|
2021-10-12 11:09:46 +02:00
|
|
|
'([a-zA-Z0-9]+\.)*[a-zA-Z0-9]+' .
|
|
|
|
'(/[a-zA-Z0-9\-\.\_\~\:\?\#\[\]\@\!\$\&\'\(\)\*\+\,\;\=]+)*/?$#';
|
2012-07-16 03:17:13 +02:00
|
|
|
if (preg_match($pattern, $link)) {
|
2021-10-11 16:10:47 +02:00
|
|
|
self::setValue('latest_link', $link);
|
2011-11-17 21:33:29 +01:00
|
|
|
}
|
2011-11-17 20:10:26 +01:00
|
|
|
}
|
2011-10-14 20:17:06 +02:00
|
|
|
|
2012-07-16 03:17:13 +02:00
|
|
|
public static function SetWeekStartDay($day)
|
|
|
|
{
|
2021-10-11 16:10:47 +02:00
|
|
|
self::setValue('week_start_day', $day);
|
2011-10-19 18:42:22 +02:00
|
|
|
}
|
|
|
|
|
2012-07-16 03:17:13 +02:00
|
|
|
public static function GetWeekStartDay()
|
|
|
|
{
|
2021-10-11 16:10:47 +02:00
|
|
|
$val = self::getValue('week_start_day');
|
|
|
|
|
|
|
|
return (strlen($val) == 0) ? '0' : $val;
|
2011-10-19 18:42:22 +02:00
|
|
|
}
|
2012-04-01 21:51:03 +02:00
|
|
|
|
2011-11-30 02:15:38 +01:00
|
|
|
/**
|
2021-10-11 16:10:47 +02:00
|
|
|
* Stores the last timestamp of user updating stream setting.
|
|
|
|
*/
|
2012-07-16 03:17:13 +02:00
|
|
|
public static function SetStreamUpdateTimestamp()
|
|
|
|
{
|
2011-11-30 02:15:38 +01:00
|
|
|
$now = time();
|
2021-10-11 16:10:47 +02:00
|
|
|
self::setValue('stream_update_timestamp', $now);
|
2011-11-30 02:15:38 +01:00
|
|
|
}
|
2012-04-01 21:51:03 +02:00
|
|
|
|
2011-11-30 02:15:38 +01:00
|
|
|
/**
|
2021-10-11 16:10:47 +02:00
|
|
|
* Gets the last timestamp of user updating stream setting.
|
2011-11-30 02:15:38 +01:00
|
|
|
*/
|
2012-07-16 03:17:13 +02:00
|
|
|
public static function GetStreamUpdateTimestemp()
|
|
|
|
{
|
2021-10-11 16:10:47 +02:00
|
|
|
$update_time = self::getValue('stream_update_timestamp');
|
|
|
|
|
2012-09-11 20:33:50 +02:00
|
|
|
return ($update_time == null) ? 0 : $update_time;
|
2011-11-30 02:15:38 +01:00
|
|
|
}
|
2012-04-01 21:51:03 +02:00
|
|
|
|
2012-07-16 03:17:13 +02:00
|
|
|
public static function GetClientId()
|
|
|
|
{
|
2021-10-11 16:10:47 +02:00
|
|
|
return self::getValue('client_id');
|
2011-12-08 23:23:46 +01:00
|
|
|
}
|
2012-04-01 21:51:03 +02:00
|
|
|
|
2012-07-16 03:17:13 +02:00
|
|
|
public static function SetClientId($id)
|
|
|
|
{
|
2011-12-08 23:23:46 +01:00
|
|
|
if (is_numeric($id)) {
|
2021-10-11 16:10:47 +02:00
|
|
|
self::setValue('client_id', $id);
|
2012-09-11 20:33:50 +02:00
|
|
|
} else {
|
2021-10-11 16:10:47 +02:00
|
|
|
Logging::warn("Attempting to set client_id to invalid value: {$id}");
|
2011-12-08 23:23:46 +01:00
|
|
|
}
|
|
|
|
}
|
2020-05-04 06:32:52 +02:00
|
|
|
|
2021-10-11 16:10:47 +02:00
|
|
|
// User specific preferences start
|
2011-10-14 20:17:06 +02:00
|
|
|
|
|
|
|
/**
|
2011-11-16 21:52:05 +01:00
|
|
|
* Sets the time scale preference (agendaDay/agendaWeek/month) in Calendar.
|
2012-04-01 21:51:03 +02:00
|
|
|
*
|
2023-05-25 15:06:18 +02:00
|
|
|
* @param $timeScale new time scale
|
2011-10-14 20:17:06 +02:00
|
|
|
*/
|
2012-07-16 03:17:13 +02:00
|
|
|
public static function SetCalendarTimeScale($timeScale)
|
|
|
|
{
|
2021-10-11 16:10:47 +02:00
|
|
|
self::setValue('calendar_time_scale', $timeScale, true /* user specific */);
|
2011-10-14 20:17:06 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Retrieves the time scale preference for the current user.
|
2021-10-11 16:10:47 +02:00
|
|
|
* Defaults to month if no entry exists.
|
2011-10-14 20:17:06 +02:00
|
|
|
*/
|
2012-07-16 03:17:13 +02:00
|
|
|
public static function GetCalendarTimeScale()
|
|
|
|
{
|
2021-10-11 16:10:47 +02:00
|
|
|
$val = self::getValue('calendar_time_scale', true /* user specific */);
|
2012-07-16 03:17:13 +02:00
|
|
|
if (strlen($val) == 0) {
|
2021-10-11 16:10:47 +02:00
|
|
|
$val = 'month';
|
2011-11-16 21:52:05 +01:00
|
|
|
}
|
2012-07-16 03:17:13 +02:00
|
|
|
|
2012-07-11 00:51:32 +02:00
|
|
|
return $val;
|
2011-10-14 20:17:06 +02:00
|
|
|
}
|
2012-04-01 21:51:03 +02:00
|
|
|
|
2011-10-18 16:10:35 +02:00
|
|
|
/**
|
|
|
|
* Sets the number of entries to show preference in library under Playlist Builder.
|
2012-04-01 21:51:03 +02:00
|
|
|
*
|
2023-05-25 15:06:18 +02:00
|
|
|
* @param $numEntries new number of entries to show
|
2011-10-18 16:10:35 +02:00
|
|
|
*/
|
2012-07-16 03:17:13 +02:00
|
|
|
public static function SetLibraryNumEntries($numEntries)
|
|
|
|
{
|
2021-10-11 16:10:47 +02:00
|
|
|
self::setValue('library_num_entries', $numEntries, true /* user specific */);
|
2011-10-18 16:10:35 +02:00
|
|
|
}
|
2012-04-01 21:51:03 +02:00
|
|
|
|
2011-10-18 16:10:35 +02:00
|
|
|
/**
|
|
|
|
* Retrieves the number of entries to show preference in library under Playlist Builder.
|
2021-10-11 16:10:47 +02:00
|
|
|
* Defaults to 10 if no entry exists.
|
2011-10-18 16:10:35 +02:00
|
|
|
*/
|
2012-07-16 03:17:13 +02:00
|
|
|
public static function GetLibraryNumEntries()
|
|
|
|
{
|
2021-10-11 16:10:47 +02:00
|
|
|
$val = self::getValue('library_num_entries', true /* user specific */);
|
2012-07-16 03:17:13 +02:00
|
|
|
if (strlen($val) == 0) {
|
2021-10-11 16:10:47 +02:00
|
|
|
$val = '10';
|
2011-11-16 22:12:58 +01:00
|
|
|
}
|
2012-07-16 03:17:13 +02:00
|
|
|
|
2011-11-16 22:12:58 +01:00
|
|
|
return $val;
|
2011-10-18 16:10:35 +02:00
|
|
|
}
|
2012-04-01 21:51:03 +02:00
|
|
|
|
2011-10-18 16:10:35 +02:00
|
|
|
/**
|
|
|
|
* Sets the time interval preference in Calendar.
|
2012-04-01 21:51:03 +02:00
|
|
|
*
|
2023-05-25 15:06:18 +02:00
|
|
|
* @param $timeInterval new time interval
|
2011-10-18 16:10:35 +02:00
|
|
|
*/
|
2012-07-16 03:17:13 +02:00
|
|
|
public static function SetCalendarTimeInterval($timeInterval)
|
|
|
|
{
|
2021-10-11 16:10:47 +02:00
|
|
|
self::setValue('calendar_time_interval', $timeInterval, true /* user specific */);
|
2011-10-18 16:10:35 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Retrieves the time interval preference for the current user.
|
2021-10-11 16:10:47 +02:00
|
|
|
* Defaults to 30 min if no entry exists.
|
2011-10-18 16:10:35 +02:00
|
|
|
*/
|
2012-07-16 03:17:13 +02:00
|
|
|
public static function GetCalendarTimeInterval()
|
|
|
|
{
|
2021-10-11 16:10:47 +02:00
|
|
|
$val = self::getValue('calendar_time_interval', true /* user specific */);
|
|
|
|
|
|
|
|
return (strlen($val) == 0) ? '30' : $val;
|
2011-10-18 16:10:35 +02:00
|
|
|
}
|
2012-04-01 21:51:03 +02:00
|
|
|
|
2012-07-16 03:17:13 +02:00
|
|
|
public static function SetDiskQuota($value)
|
|
|
|
{
|
2021-10-11 16:10:47 +02:00
|
|
|
self::setValue('disk_quota', $value, false);
|
2012-01-04 20:18:40 +01:00
|
|
|
}
|
2012-04-01 21:51:03 +02:00
|
|
|
|
2012-07-16 03:17:13 +02:00
|
|
|
public static function GetDiskQuota()
|
|
|
|
{
|
2021-10-11 16:10:47 +02:00
|
|
|
$val = self::getValue('disk_quota');
|
|
|
|
|
|
|
|
return empty($val) ? 2147483648 : $val; // If there is no value for disk quota, return 2GB
|
2012-01-04 20:18:40 +01:00
|
|
|
}
|
2012-04-01 21:51:03 +02:00
|
|
|
|
2012-10-17 21:16:03 +02:00
|
|
|
public static function SetLiveStreamMasterUsername($value)
|
2012-07-16 03:17:13 +02:00
|
|
|
{
|
2021-10-11 16:10:47 +02:00
|
|
|
self::setValue('live_stream_master_username', $value, false);
|
2012-02-06 23:51:02 +01:00
|
|
|
}
|
2012-04-01 21:51:03 +02:00
|
|
|
|
2012-10-17 21:16:03 +02:00
|
|
|
public static function GetLiveStreamMasterUsername()
|
2012-07-16 03:17:13 +02:00
|
|
|
{
|
2021-10-11 16:10:47 +02:00
|
|
|
return self::getValue('live_stream_master_username');
|
2012-02-06 23:51:02 +01:00
|
|
|
}
|
2012-04-01 21:51:03 +02:00
|
|
|
|
2012-10-17 21:16:03 +02:00
|
|
|
public static function SetLiveStreamMasterPassword($value)
|
2012-07-16 03:17:13 +02:00
|
|
|
{
|
2021-10-11 16:10:47 +02:00
|
|
|
self::setValue('live_stream_master_password', $value, false);
|
2012-02-06 23:51:02 +01:00
|
|
|
}
|
2012-04-01 21:51:03 +02:00
|
|
|
|
2012-10-17 21:16:03 +02:00
|
|
|
public static function GetLiveStreamMasterPassword()
|
2012-07-16 03:17:13 +02:00
|
|
|
{
|
2021-10-11 16:10:47 +02:00
|
|
|
return self::getValue('live_stream_master_password');
|
2012-02-06 23:51:02 +01:00
|
|
|
}
|
2012-04-01 21:51:03 +02:00
|
|
|
|
2012-07-16 03:17:13 +02:00
|
|
|
public static function SetSourceStatus($sourcename, $status)
|
|
|
|
{
|
2012-07-10 05:32:21 +02:00
|
|
|
self::setValue($sourcename, $status, false);
|
2012-03-08 23:42:38 +01:00
|
|
|
}
|
2012-04-01 21:51:03 +02:00
|
|
|
|
2012-07-16 03:17:13 +02:00
|
|
|
public static function GetSourceStatus($sourcename)
|
|
|
|
{
|
2012-07-10 05:32:21 +02:00
|
|
|
$value = self::getValue($sourcename);
|
2021-10-11 16:10:47 +02:00
|
|
|
|
|
|
|
return !($value == null || $value == 'false');
|
2012-03-08 23:42:38 +01:00
|
|
|
}
|
2012-04-01 21:51:03 +02:00
|
|
|
|
2012-07-16 03:17:13 +02:00
|
|
|
public static function SetSourceSwitchStatus($sourcename, $status)
|
|
|
|
{
|
2021-10-11 16:10:47 +02:00
|
|
|
self::setValue($sourcename . '_switch', $status, false);
|
2012-03-08 23:42:38 +01:00
|
|
|
}
|
2012-04-01 21:51:03 +02:00
|
|
|
|
2012-07-16 03:17:13 +02:00
|
|
|
public static function GetSourceSwitchStatus($sourcename)
|
|
|
|
{
|
2015-08-06 17:14:43 +02:00
|
|
|
// Scheduled play switch should always be "on".
|
|
|
|
// Even though we've hidden this element in the dashboard we should
|
|
|
|
// always make sure it's on or else a station's stream could go offline.
|
2021-10-11 16:10:47 +02:00
|
|
|
if ($sourcename == 'scheduled_play') {
|
|
|
|
return 'on';
|
2015-08-06 17:14:43 +02:00
|
|
|
}
|
|
|
|
|
2021-10-11 16:10:47 +02:00
|
|
|
$value = self::getValue($sourcename . '_switch');
|
|
|
|
|
|
|
|
return ($value == null || $value == 'off') ? 'off' : 'on';
|
2012-03-08 23:42:38 +01:00
|
|
|
}
|
2012-04-01 21:51:03 +02:00
|
|
|
|
2012-07-16 03:17:13 +02:00
|
|
|
public static function GetMasterDJSourceConnectionURL()
|
|
|
|
{
|
2022-09-06 12:00:50 +02:00
|
|
|
if (Config::has('stream.inputs.main.public_url') && Config::get('stream.inputs.main.public_url')) {
|
|
|
|
return Config::get('stream.inputs.main.public_url');
|
2021-10-11 16:10:47 +02:00
|
|
|
}
|
2017-03-16 15:18:43 +01:00
|
|
|
|
2022-09-06 12:00:50 +02:00
|
|
|
$host = Config::get('general.public_url_raw')->getHost();
|
|
|
|
$port = Application_Model_StreamSetting::getMasterLiveStreamPort();
|
|
|
|
$mount = Application_Model_StreamSetting::getMasterLiveStreamMountPoint();
|
2023-03-30 20:39:02 +02:00
|
|
|
$secure = Application_Model_StreamSetting::getMasterLiveStreamSecure();
|
2012-07-11 00:51:32 +02:00
|
|
|
|
2023-03-30 20:39:02 +02:00
|
|
|
$scheme = $secure ? 'https' : 'http';
|
|
|
|
|
|
|
|
return "{$scheme}://{$host}:{$port}/{$mount}";
|
2012-03-10 00:48:23 +01:00
|
|
|
}
|
2012-04-01 21:51:03 +02:00
|
|
|
|
2012-07-16 03:17:13 +02:00
|
|
|
public static function GetLiveDJSourceConnectionURL()
|
|
|
|
{
|
2022-09-06 12:00:50 +02:00
|
|
|
if (Config::has('stream.inputs.show.public_url') && Config::get('stream.inputs.show.public_url')) {
|
|
|
|
return Config::get('stream.inputs.show.public_url');
|
2017-03-16 15:18:43 +01:00
|
|
|
}
|
2021-10-11 16:10:47 +02:00
|
|
|
|
2022-09-06 12:00:50 +02:00
|
|
|
$host = Config::get('general.public_url_raw')->getHost();
|
|
|
|
$port = Application_Model_StreamSetting::getDjLiveStreamPort();
|
|
|
|
$mount = Application_Model_StreamSetting::getDjLiveStreamMountPoint();
|
2023-03-30 20:39:02 +02:00
|
|
|
$secure = Application_Model_StreamSetting::getDjLiveStreamSecure();
|
|
|
|
|
|
|
|
$scheme = $secure ? 'https' : 'http';
|
2012-07-11 00:51:32 +02:00
|
|
|
|
2023-03-30 20:39:02 +02:00
|
|
|
return "{$scheme}://{$host}:{$port}/{$mount}";
|
2012-06-06 23:06:46 +02:00
|
|
|
}
|
2012-07-11 00:51:32 +02:00
|
|
|
|
2012-07-16 03:17:13 +02:00
|
|
|
public static function SetAutoTransition($value)
|
|
|
|
{
|
2021-10-11 16:10:47 +02:00
|
|
|
self::setValue('auto_transition', $value, false);
|
2012-06-05 22:41:41 +02:00
|
|
|
}
|
2012-07-11 00:51:32 +02:00
|
|
|
|
2012-07-16 03:17:13 +02:00
|
|
|
public static function GetAutoTransition()
|
|
|
|
{
|
2021-10-11 16:10:47 +02:00
|
|
|
return self::getValue('auto_transition');
|
2012-06-05 22:41:41 +02:00
|
|
|
}
|
2012-07-11 00:51:32 +02:00
|
|
|
|
2012-07-16 03:17:13 +02:00
|
|
|
public static function SetAutoSwitch($value)
|
|
|
|
{
|
2021-10-11 16:10:47 +02:00
|
|
|
self::setValue('auto_switch', $value, false);
|
2012-06-12 21:38:03 +02:00
|
|
|
}
|
2012-07-11 00:51:32 +02:00
|
|
|
|
2012-07-16 03:17:13 +02:00
|
|
|
public static function GetAutoSwitch()
|
|
|
|
{
|
2021-10-11 16:10:47 +02:00
|
|
|
return self::getValue('auto_switch');
|
2012-06-12 21:38:03 +02:00
|
|
|
}
|
2021-10-11 16:10:47 +02:00
|
|
|
// User specific preferences end
|
2012-04-01 21:51:03 +02:00
|
|
|
|
2012-07-16 03:17:13 +02:00
|
|
|
public static function ShouldShowPopUp()
|
|
|
|
{
|
2021-10-11 16:10:47 +02:00
|
|
|
$today = mktime(0, 0, 0, gmdate('m'), gmdate('d'), gmdate('Y'));
|
2012-07-16 03:17:13 +02:00
|
|
|
$remindDate = Application_Model_Preference::GetRemindMeDate();
|
2012-08-28 23:30:34 +02:00
|
|
|
$retVal = false;
|
2020-05-04 06:32:52 +02:00
|
|
|
|
2012-09-14 18:09:40 +02:00
|
|
|
if (is_null($remindDate) || ($remindDate != -1 && $today >= $remindDate)) {
|
2012-08-28 23:30:34 +02:00
|
|
|
$retVal = true;
|
2012-07-16 03:17:13 +02:00
|
|
|
}
|
2020-05-04 06:32:52 +02:00
|
|
|
|
2012-08-28 23:30:34 +02:00
|
|
|
return $retVal;
|
2012-03-29 16:27:08 +02:00
|
|
|
}
|
2012-08-29 16:58:03 +02:00
|
|
|
|
2012-10-17 21:16:03 +02:00
|
|
|
public static function getOrderingMap($pref_param)
|
2012-08-29 16:58:03 +02:00
|
|
|
{
|
2012-09-19 22:34:46 +02:00
|
|
|
$v = self::getValue($pref_param, true);
|
2012-09-13 20:56:03 +02:00
|
|
|
|
2022-07-07 20:01:15 +02:00
|
|
|
$id = function ($x) {
|
|
|
|
return $x;
|
|
|
|
};
|
2012-09-19 22:34:46 +02:00
|
|
|
|
|
|
|
if ($v === '') {
|
|
|
|
return $id;
|
|
|
|
}
|
|
|
|
|
|
|
|
$ds = unserialize($v);
|
2020-05-04 06:32:52 +02:00
|
|
|
|
2014-06-06 00:04:42 +02:00
|
|
|
if (is_null($ds) || !is_array($ds)) {
|
|
|
|
return $id;
|
|
|
|
}
|
2020-05-04 06:32:52 +02:00
|
|
|
|
2012-09-19 22:34:46 +02:00
|
|
|
if (!array_key_exists('ColReorder', $ds)) {
|
|
|
|
return $id;
|
2012-09-11 19:56:48 +02:00
|
|
|
}
|
2012-09-19 22:34:46 +02:00
|
|
|
|
|
|
|
return function ($x) use ($ds) {
|
|
|
|
if (array_key_exists($x, $ds['ColReorder'])) {
|
|
|
|
return $ds['ColReorder'][$x];
|
|
|
|
}
|
2021-10-11 16:10:47 +02:00
|
|
|
/*For now we just have this hack for debugging. We should not
|
|
|
|
rely on this behaviour in case of failure*/
|
|
|
|
Logging::warn("Index {$x} does not exist preferences");
|
|
|
|
Logging::warn('Defaulting to identity and printing preferences');
|
|
|
|
Logging::warn($ds);
|
|
|
|
|
|
|
|
return $x;
|
2012-09-19 22:34:46 +02:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
public static function getCurrentLibraryTableColumnMap()
|
|
|
|
{
|
2021-10-11 16:10:47 +02:00
|
|
|
return self::getOrderingMap('library_datatable');
|
2012-09-14 18:09:40 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public static function setCurrentLibraryTableSetting($settings)
|
|
|
|
{
|
|
|
|
$data = serialize($settings);
|
2021-10-11 16:10:47 +02:00
|
|
|
self::setValue('library_datatable', $data, true);
|
2012-09-14 18:09:40 +02:00
|
|
|
}
|
|
|
|
|
2012-09-14 20:53:25 +02:00
|
|
|
public static function getCurrentLibraryTableSetting()
|
|
|
|
{
|
2021-10-11 16:10:47 +02:00
|
|
|
$data = self::getValue('library_datatable', true);
|
2012-09-14 20:53:25 +02:00
|
|
|
|
2021-10-11 16:10:47 +02:00
|
|
|
return ($data != '') ? unserialize($data) : null;
|
|
|
|
}
|
2012-09-14 18:09:40 +02:00
|
|
|
|
|
|
|
public static function setTimelineDatatableSetting($settings)
|
|
|
|
{
|
|
|
|
$data = serialize($settings);
|
2021-10-11 16:10:47 +02:00
|
|
|
self::setValue('timeline_datatable', $data, true);
|
2012-09-14 18:09:40 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public static function getTimelineDatatableSetting()
|
|
|
|
{
|
2021-10-11 16:10:47 +02:00
|
|
|
$data = self::getValue('timeline_datatable', true);
|
2012-09-14 18:09:40 +02:00
|
|
|
|
2021-10-11 16:10:47 +02:00
|
|
|
return ($data != '') ? unserialize($data) : null;
|
|
|
|
}
|
2012-09-14 18:09:40 +02:00
|
|
|
|
|
|
|
public static function setNowPlayingScreenSettings($settings)
|
|
|
|
{
|
|
|
|
$data = serialize($settings);
|
2021-10-11 16:10:47 +02:00
|
|
|
self::setValue('nowplaying_screen', $data, true);
|
2012-09-14 18:09:40 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public static function getNowPlayingScreenSettings()
|
|
|
|
{
|
2021-10-11 16:10:47 +02:00
|
|
|
$data = self::getValue('nowplaying_screen', true);
|
|
|
|
|
|
|
|
return ($data != '') ? unserialize($data) : null;
|
2012-08-23 16:41:40 +02:00
|
|
|
}
|
2013-02-19 16:58:48 +01:00
|
|
|
|
|
|
|
public static function setLibraryScreenSettings($settings)
|
|
|
|
{
|
|
|
|
$data = serialize($settings);
|
2021-10-11 16:10:47 +02:00
|
|
|
self::setValue('library_screen', $data, true);
|
2013-02-19 16:58:48 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public static function getLibraryScreenSettings()
|
|
|
|
{
|
2021-10-11 16:10:47 +02:00
|
|
|
$data = self::getValue('library_screen', true);
|
|
|
|
|
|
|
|
return ($data != '') ? unserialize($data) : null;
|
2013-02-19 16:58:48 +01:00
|
|
|
}
|
|
|
|
|
2021-10-11 16:10:47 +02:00
|
|
|
public static function SetEnableReplayGain($value)
|
|
|
|
{
|
|
|
|
self::setValue('enable_replay_gain', $value, false);
|
2013-01-10 19:49:41 +01:00
|
|
|
}
|
2020-05-04 06:32:52 +02:00
|
|
|
|
2021-10-11 16:10:47 +02:00
|
|
|
public static function GetEnableReplayGain()
|
|
|
|
{
|
|
|
|
return self::getValue('enable_replay_gain', false);
|
2013-01-10 19:49:41 +01:00
|
|
|
}
|
2020-05-04 06:32:52 +02:00
|
|
|
|
2021-10-11 16:10:47 +02:00
|
|
|
public static function getReplayGainModifier()
|
|
|
|
{
|
|
|
|
$rg_modifier = self::getValue('replay_gain_modifier');
|
2020-05-04 06:32:52 +02:00
|
|
|
|
2021-10-11 16:10:47 +02:00
|
|
|
if ($rg_modifier === '') {
|
|
|
|
return '0';
|
|
|
|
}
|
2020-05-04 06:32:52 +02:00
|
|
|
|
2012-12-27 06:36:11 +01:00
|
|
|
return $rg_modifier;
|
|
|
|
}
|
2020-05-04 06:32:52 +02:00
|
|
|
|
2012-12-27 06:36:11 +01:00
|
|
|
public static function setReplayGainModifier($rg_modifier)
|
|
|
|
{
|
2024-02-08 19:48:49 +01:00
|
|
|
self::setValue('replay_gain_modifier', $rg_modifier, false);
|
2012-12-27 06:36:11 +01:00
|
|
|
}
|
2020-05-04 06:32:52 +02:00
|
|
|
|
2021-10-11 16:10:47 +02:00
|
|
|
public static function SetHistoryItemTemplate($value)
|
|
|
|
{
|
|
|
|
self::setValue('history_item_template', $value);
|
2013-07-23 00:11:44 +02:00
|
|
|
}
|
2020-05-04 06:32:52 +02:00
|
|
|
|
2021-10-11 16:10:47 +02:00
|
|
|
public static function GetHistoryItemTemplate()
|
|
|
|
{
|
|
|
|
return self::getValue('history_item_template');
|
2013-07-23 00:11:44 +02:00
|
|
|
}
|
2020-05-04 06:32:52 +02:00
|
|
|
|
2021-10-11 16:10:47 +02:00
|
|
|
public static function SetHistoryFileTemplate($value)
|
|
|
|
{
|
|
|
|
self::setValue('history_file_template', $value);
|
2013-08-02 21:30:35 +02:00
|
|
|
}
|
2020-05-04 06:32:52 +02:00
|
|
|
|
2021-10-11 16:10:47 +02:00
|
|
|
public static function GetHistoryFileTemplate()
|
|
|
|
{
|
|
|
|
return self::getValue('history_file_template');
|
2013-08-02 21:29:39 +02:00
|
|
|
}
|
2014-03-21 14:50:03 +01:00
|
|
|
|
|
|
|
public static function getDiskUsage()
|
|
|
|
{
|
2021-10-11 16:10:47 +02:00
|
|
|
$val = self::getValue('disk_usage');
|
|
|
|
|
2014-05-05 18:25:42 +02:00
|
|
|
return (strlen($val) == 0) ? 0 : $val;
|
2014-03-21 14:50:03 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public static function setDiskUsage($value)
|
|
|
|
{
|
2021-10-11 16:10:47 +02:00
|
|
|
self::setValue('disk_usage', $value);
|
2014-03-21 14:50:03 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public static function updateDiskUsage($filesize)
|
|
|
|
{
|
|
|
|
$currentDiskUsage = self::getDiskUsage();
|
|
|
|
if (empty($currentDiskUsage)) {
|
|
|
|
$currentDiskUsage = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
self::setDiskUsage($currentDiskUsage + $filesize);
|
|
|
|
}
|
2015-04-10 23:14:56 +02:00
|
|
|
|
2015-05-13 22:05:37 +02:00
|
|
|
public static function setTuneinEnabled($value)
|
|
|
|
{
|
2021-10-11 16:10:47 +02:00
|
|
|
self::setValue('tunein_enabled', $value);
|
2015-05-13 22:05:37 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public static function getTuneinEnabled()
|
|
|
|
{
|
2021-10-11 16:10:47 +02:00
|
|
|
return self::getValue('tunein_enabled');
|
2015-05-13 22:05:37 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public static function setTuneinPartnerKey($value)
|
|
|
|
{
|
2021-10-11 16:10:47 +02:00
|
|
|
self::setValue('tunein_partner_key', $value);
|
2015-05-13 22:05:37 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public static function getTuneinPartnerKey()
|
|
|
|
{
|
2021-10-11 16:10:47 +02:00
|
|
|
return self::getValue('tunein_partner_key');
|
2015-05-13 22:05:37 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public static function setTuneinPartnerId($value)
|
|
|
|
{
|
2021-10-11 16:10:47 +02:00
|
|
|
self::setValue('tunein_partner_id', $value);
|
2015-05-13 22:05:37 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public static function getTuneinPartnerId()
|
|
|
|
{
|
2021-10-11 16:10:47 +02:00
|
|
|
return self::getValue('tunein_partner_id');
|
2015-05-13 22:05:37 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public static function setTuneinStationId($value)
|
|
|
|
{
|
2021-10-11 16:10:47 +02:00
|
|
|
self::setValue('tunein_station_id', $value);
|
2015-05-13 22:05:37 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public static function getTuneinStationId()
|
|
|
|
{
|
2021-10-11 16:10:47 +02:00
|
|
|
return self::getValue('tunein_station_id');
|
2015-05-13 22:05:37 +02:00
|
|
|
}
|
2015-05-25 21:37:45 +02:00
|
|
|
|
|
|
|
public static function geLastTuneinMetadataUpdate()
|
|
|
|
{
|
2021-10-11 16:10:47 +02:00
|
|
|
return self::getValue('last_tunein_metadata_update');
|
2015-05-25 21:37:45 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public static function setLastTuneinMetadataUpdate($value)
|
|
|
|
{
|
2021-10-11 16:10:47 +02:00
|
|
|
self::setValue('last_tunein_metadata_update', $value);
|
2015-05-25 21:37:45 +02:00
|
|
|
}
|
2015-06-03 22:57:17 +02:00
|
|
|
|
2015-06-16 21:10:08 +02:00
|
|
|
// TaskManager Lock Timestamp
|
|
|
|
|
2021-10-11 16:10:47 +02:00
|
|
|
public static function getTaskManagerLock()
|
|
|
|
{
|
|
|
|
return self::getValue('task_manager_lock');
|
2015-06-16 21:10:08 +02:00
|
|
|
}
|
|
|
|
|
2021-10-11 16:10:47 +02:00
|
|
|
public static function setTaskManagerLock($value)
|
|
|
|
{
|
|
|
|
self::setValue('task_manager_lock', $value);
|
2015-06-16 21:10:08 +02:00
|
|
|
}
|
|
|
|
|
2015-07-03 19:32:41 +02:00
|
|
|
// SAAS-876 - Toggle indicating whether user is using custom stream settings
|
|
|
|
|
2021-10-11 16:10:47 +02:00
|
|
|
public static function getUsingCustomStreamSettings()
|
|
|
|
{
|
|
|
|
$val = self::getValue('using_custom_stream_settings');
|
|
|
|
|
2015-08-10 14:57:21 +02:00
|
|
|
return empty($val) ? false : $val;
|
2015-07-03 19:32:41 +02:00
|
|
|
}
|
|
|
|
|
2021-10-11 16:10:47 +02:00
|
|
|
public static function setUsingCustomStreamSettings($value)
|
|
|
|
{
|
|
|
|
self::setValue('using_custom_stream_settings', $value);
|
2015-07-03 19:32:41 +02:00
|
|
|
}
|
|
|
|
|
2015-07-13 18:28:58 +02:00
|
|
|
// SAAS-876 - Store the default Icecast password to restore when switching
|
|
|
|
// back to Airtime Pro streaming settings
|
|
|
|
|
2015-07-09 20:38:44 +02:00
|
|
|
public static function getRadioPageDisplayLoginButton()
|
|
|
|
{
|
2021-10-11 16:10:47 +02:00
|
|
|
return self::getValue('radio_page_display_login_button');
|
2015-07-09 20:38:44 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public static function setRadioPageDisplayLoginButton($value)
|
|
|
|
{
|
2021-10-11 16:10:47 +02:00
|
|
|
self::setValue('radio_page_display_login_button', $value);
|
2015-07-09 20:38:44 +02:00
|
|
|
}
|
2015-07-27 13:06:22 +02:00
|
|
|
|
2024-02-02 20:17:23 +01:00
|
|
|
public static function getScheduleTrimOverbooked()
|
|
|
|
{
|
|
|
|
return boolval(self::getValue('schedule_trim_overbooked', false));
|
|
|
|
}
|
|
|
|
|
|
|
|
public static function setScheduleTrimOverbooked($value)
|
|
|
|
{
|
|
|
|
self::setValue('schedule_trim_overbooked', $value);
|
|
|
|
}
|
|
|
|
|
2024-02-02 19:04:12 +01:00
|
|
|
public static function getRadioPageDisabled()
|
|
|
|
{
|
|
|
|
return boolval(self::getValue('radio_page_disabled', false));
|
|
|
|
}
|
|
|
|
|
|
|
|
public static function setRadioPageDisabled($value)
|
|
|
|
{
|
|
|
|
self::setValue('radio_page_disabled', $value);
|
|
|
|
}
|
|
|
|
|
2015-07-27 13:06:22 +02:00
|
|
|
public static function getLangTimezoneSetupComplete()
|
|
|
|
{
|
2021-10-11 16:10:47 +02:00
|
|
|
return self::getValue('lang_tz_setup_complete');
|
2015-07-27 13:06:22 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public static function setLangTimezoneSetupComplete($value)
|
|
|
|
{
|
2021-10-11 16:10:47 +02:00
|
|
|
self::setValue('lang_tz_setup_complete', $value);
|
2015-07-27 13:06:22 +02:00
|
|
|
}
|
2015-09-28 23:19:02 +02:00
|
|
|
|
|
|
|
public static function getWhatsNewDialogViewed()
|
|
|
|
{
|
2021-10-11 16:10:47 +02:00
|
|
|
$val = self::getValue('whats_new_dialog_viewed', true);
|
2015-09-29 17:28:20 +02:00
|
|
|
if (empty($val)) {
|
|
|
|
// Check the default (no user ID) value if the user value is empty
|
|
|
|
// This is so that new stations won't see the popup
|
2021-10-11 16:10:47 +02:00
|
|
|
$val = self::getValue('whats_new_dialog_viewed', false, true);
|
2015-09-29 17:28:20 +02:00
|
|
|
}
|
2021-10-11 16:10:47 +02:00
|
|
|
|
2015-09-28 23:19:02 +02:00
|
|
|
return empty($val) ? false : $val;
|
|
|
|
}
|
|
|
|
|
|
|
|
public static function setWhatsNewDialogViewed($value)
|
|
|
|
{
|
2021-10-11 16:10:47 +02:00
|
|
|
self::setValue('whats_new_dialog_viewed', $value, true);
|
2015-09-28 23:19:02 +02:00
|
|
|
}
|
2020-05-04 06:32:52 +02:00
|
|
|
|
2021-10-11 16:10:47 +02:00
|
|
|
public static function getAutoPlaylistPollLock()
|
|
|
|
{
|
|
|
|
return self::getValue('autoplaylist_poll_lock');
|
2017-02-13 15:35:09 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public static function setAutoPlaylistPollLock($value)
|
|
|
|
{
|
2021-10-11 16:10:47 +02:00
|
|
|
self::setValue('autoplaylist_poll_lock', $value);
|
2017-02-13 15:35:09 +01:00
|
|
|
}
|
2015-10-15 20:44:17 +02:00
|
|
|
|
2021-10-11 16:10:47 +02:00
|
|
|
public static function getPodcastPollLock()
|
|
|
|
{
|
|
|
|
return self::getValue('podcast_poll_lock');
|
2015-10-15 20:44:17 +02:00
|
|
|
}
|
|
|
|
|
2015-10-19 17:54:53 +02:00
|
|
|
public static function setPodcastPollLock($value)
|
|
|
|
{
|
2021-10-11 16:10:47 +02:00
|
|
|
self::setValue('podcast_poll_lock', $value);
|
2015-10-15 20:44:17 +02:00
|
|
|
}
|
2015-10-19 17:54:53 +02:00
|
|
|
|
|
|
|
public static function getStationPodcastId()
|
|
|
|
{
|
2015-11-03 22:23:17 +01:00
|
|
|
// Create the Station podcast if it doesn't exist.
|
2021-10-11 16:10:47 +02:00
|
|
|
$stationPodcastId = self::getValue('station_podcast_id');
|
2015-11-03 22:23:17 +01:00
|
|
|
if (empty($stationPodcastId)) {
|
|
|
|
$stationPodcastId = Application_Service_PodcastService::createStationPodcast();
|
|
|
|
}
|
2021-10-11 16:10:47 +02:00
|
|
|
|
2015-11-03 22:23:17 +01:00
|
|
|
return $stationPodcastId;
|
2015-10-19 17:54:53 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public static function setStationPodcastId($value)
|
|
|
|
{
|
2021-10-11 16:10:47 +02:00
|
|
|
self::setValue('station_podcast_id', $value);
|
2015-10-19 17:54:53 +02:00
|
|
|
}
|
2015-10-21 01:03:34 +02:00
|
|
|
|
2015-10-21 18:54:50 +02:00
|
|
|
// SAAS-1081 - Implement a universal download key for downloading episodes from the station podcast
|
|
|
|
// Store and increment the download counter, resetting every month
|
|
|
|
|
2021-10-11 16:10:47 +02:00
|
|
|
public static function getStationPodcastDownloadKey()
|
|
|
|
{
|
|
|
|
return self::getValue('station_podcast_download_key');
|
2015-10-21 01:03:34 +02:00
|
|
|
}
|
|
|
|
|
2021-10-11 16:10:47 +02:00
|
|
|
public static function setStationPodcastDownloadKey($value = null)
|
|
|
|
{
|
2015-10-21 01:03:34 +02:00
|
|
|
$value = empty($value) ? (new Application_Model_Auth())->generateRandomString() : $value;
|
2021-10-11 16:10:47 +02:00
|
|
|
self::setValue('station_podcast_download_key', $value);
|
2015-10-21 01:03:34 +02:00
|
|
|
}
|
2015-10-21 18:54:50 +02:00
|
|
|
|
2021-10-11 16:10:47 +02:00
|
|
|
public static function getStationPodcastDownloadResetTimer()
|
|
|
|
{
|
|
|
|
return self::getValue('station_podcast_download_reset_timer');
|
2015-10-21 18:54:50 +02:00
|
|
|
}
|
|
|
|
|
2021-10-11 16:10:47 +02:00
|
|
|
public static function setStationPodcastDownloadResetTimer($value)
|
|
|
|
{
|
|
|
|
self::setValue('station_podcast_download_reset_timer', $value);
|
2015-10-21 18:54:50 +02:00
|
|
|
}
|
|
|
|
|
2021-10-11 16:10:47 +02:00
|
|
|
public static function getStationPodcastDownloadCounter()
|
|
|
|
{
|
|
|
|
return self::getValue('station_podcast_download_counter');
|
2015-10-21 18:54:50 +02:00
|
|
|
}
|
|
|
|
|
2021-10-11 16:10:47 +02:00
|
|
|
public static function resetStationPodcastDownloadCounter()
|
|
|
|
{
|
|
|
|
self::setValue('station_podcast_download_counter', 0);
|
2015-10-21 18:54:50 +02:00
|
|
|
}
|
|
|
|
|
2021-10-11 16:10:47 +02:00
|
|
|
public static function incrementStationPodcastDownloadCounter()
|
|
|
|
{
|
2015-10-21 18:54:50 +02:00
|
|
|
$c = self::getStationPodcastDownloadCounter();
|
2021-10-11 16:10:47 +02:00
|
|
|
self::setValue('station_podcast_download_counter', empty($c) ? 1 : ++$c);
|
2015-10-21 18:54:50 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// For fail cases, we may need to decrement the download counter
|
2021-10-11 16:10:47 +02:00
|
|
|
public static function decrementStationPodcastDownloadCounter()
|
|
|
|
{
|
2015-10-21 18:54:50 +02:00
|
|
|
$c = self::getStationPodcastDownloadCounter();
|
2021-10-11 16:10:47 +02:00
|
|
|
self::setValue('station_podcast_download_counter', empty($c) ? 0 : --$c);
|
2015-10-21 18:54:50 +02:00
|
|
|
}
|
2015-10-21 23:30:24 +02:00
|
|
|
|
2015-11-23 20:55:37 +01:00
|
|
|
/**
|
|
|
|
* @return int either 0 (public) or 1 (private)
|
|
|
|
*/
|
2021-10-11 16:10:47 +02:00
|
|
|
public static function getStationPodcastPrivacy()
|
|
|
|
{
|
|
|
|
return self::getValue('station_podcast_privacy');
|
2015-10-21 23:30:24 +02:00
|
|
|
}
|
|
|
|
|
2021-10-11 16:10:47 +02:00
|
|
|
public static function setStationPodcastPrivacy($value)
|
|
|
|
{
|
|
|
|
self::setValue('station_podcast_privacy', $value);
|
2015-10-21 23:30:24 +02:00
|
|
|
}
|
2015-11-19 22:08:25 +01:00
|
|
|
|
2017-03-10 15:10:56 +01:00
|
|
|
/**
|
2021-01-03 12:40:06 +01:00
|
|
|
* Getter for feature preview mode.
|
2017-03-10 15:10:56 +01:00
|
|
|
*
|
2021-01-03 12:40:06 +01:00
|
|
|
* @return bool
|
2017-03-10 15:10:56 +01:00
|
|
|
*/
|
2021-10-11 16:10:47 +02:00
|
|
|
public static function GetFeaturePreviewMode()
|
|
|
|
{
|
2021-01-03 12:40:06 +01:00
|
|
|
return self::getValue('feature_preview_mode') === '1';
|
2017-03-10 15:10:56 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2021-01-03 12:40:06 +01:00
|
|
|
* Setter for feature preview mode.
|
2017-03-10 15:10:56 +01:00
|
|
|
*
|
2021-01-03 12:40:06 +01:00
|
|
|
* @param bool $value
|
2017-03-10 15:10:56 +01:00
|
|
|
*/
|
2021-10-11 16:10:47 +02:00
|
|
|
public static function SetFeaturePreviewMode($value)
|
|
|
|
{
|
2021-01-03 12:40:06 +01:00
|
|
|
return self::setValue('feature_preview_mode', $value);
|
2017-03-10 15:10:56 +01:00
|
|
|
}
|
2022-08-06 19:57:13 +02:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Stores liquidsoap status if $boot_time > save time.
|
|
|
|
* save time is the time that user clicked save on stream setting page
|
|
|
|
*/
|
|
|
|
public static function setLiquidsoapError($stream_id, $msg, $boot_time = null)
|
|
|
|
{
|
|
|
|
$update_time = Application_Model_Preference::GetStreamUpdateTimestemp();
|
|
|
|
|
|
|
|
if ($boot_time == null || $boot_time > $update_time) {
|
|
|
|
$stream_id = trim($stream_id, 's');
|
|
|
|
self::setValue("stream_liquidsoap_status:{$stream_id}", $msg);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public static function getLiquidsoapError($stream_id)
|
|
|
|
{
|
|
|
|
$result = self::getValue("stream_liquidsoap_status:{$stream_id}");
|
|
|
|
|
|
|
|
return ($result !== false) ? $result : null;
|
|
|
|
}
|
2022-08-06 23:56:58 +02:00
|
|
|
|
|
|
|
public static function GetAllListenerStatErrors()
|
|
|
|
{
|
|
|
|
$sql = <<<'SQL'
|
|
|
|
SELECT *
|
|
|
|
FROM cc_pref
|
|
|
|
WHERE keystr LIKE 'stream_stats_status:%'
|
|
|
|
SQL;
|
|
|
|
|
|
|
|
return Application_Common_Database::prepareAndExecute($sql, []);
|
|
|
|
}
|
|
|
|
|
|
|
|
public static function SetListenerStatError($stream_id, $value)
|
|
|
|
{
|
|
|
|
$stream_id = trim($stream_id, 's');
|
|
|
|
self::setValue("stream_stats_status:{$stream_id}", $value);
|
|
|
|
}
|
2011-02-03 23:51:35 +01:00
|
|
|
}
|