Merge branch 'cc-84-smart-playlist' of dev.sourcefabric.org:airtime into cc-84-smart-playlist

This commit is contained in:
denise 2012-07-11 11:50:52 -04:00
commit fe75ba0e93
71 changed files with 2122 additions and 2072 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'); $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)){ if (!is_null($user)){
$userType = $user->getType(); $userType = $user->getType();
} else { } else {

View File

@ -270,18 +270,18 @@ class ApiController extends Zend_Controller_Action
$date = new Application_Common_DateHelper; $date = new Application_Common_DateHelper;
$utcTimeNow = $date->getUtcTimestamp(); $utcTimeNow = $date->getUtcTimestamp();
$utcTimeEnd = ""; // if empty, GetNextShows will use interval instead of end of day $utcTimeEnd = ""; // if empty, getNextShows will use interval instead of end of day
$request = $this->getRequest(); $request = $this->getRequest();
$type = $request->getParam('type'); $type = $request->getParam('type');
if($type == "endofday") { if($type == "endofday") {
// make GetNextShows use end of day // make getNextShows use end of day
$utcTimeEnd = Application_Common_DateHelper::GetDayEndTimestampInUtc(); $utcTimeEnd = Application_Common_DateHelper::GetDayEndTimestampInUtc();
$result = array("env"=>APPLICATION_ENV, $result = array("env"=>APPLICATION_ENV,
"schedulerTime"=>gmdate("Y-m-d H:i:s"), "schedulerTime"=>gmdate("Y-m-d H:i:s"),
"nextShow"=>Application_Model_Show::GetNextShows($utcTimeNow, 5, $utcTimeEnd)); "nextShow"=>Application_Model_Show::getNextShows($utcTimeNow, 5, $utcTimeEnd));
Application_Model_Show::ConvertToLocalTimeZone($result["nextShow"], array("starts", "ends", "start_timestamp", "end_timestamp")); Application_Model_Show::convertToLocalTimeZone($result["nextShow"], array("starts", "ends", "start_timestamp", "end_timestamp"));
}else{ }else{
$limit = $request->getParam('limit'); $limit = $request->getParam('limit');
@ -292,8 +292,8 @@ class ApiController extends Zend_Controller_Action
$result = Application_Model_Schedule::GetPlayOrderRange(); $result = Application_Model_Schedule::GetPlayOrderRange();
//Convert from UTC to localtime for user. //Convert from UTC to localtime for user.
Application_Model_Show::ConvertToLocalTimeZone($result["currentShow"], array("starts", "ends", "start_timestamp", "end_timestamp")); Application_Model_Show::convertToLocalTimeZone($result["currentShow"], array("starts", "ends", "start_timestamp", "end_timestamp"));
Application_Model_Show::ConvertToLocalTimeZone($result["nextShow"], array("starts", "ends", "start_timestamp", "end_timestamp")); Application_Model_Show::convertToLocalTimeZone($result["nextShow"], array("starts", "ends", "start_timestamp", "end_timestamp"));
} }
$result['AIRTIME_API_VERSION'] = AIRTIME_API_VERSION; //used by caller to determine if the airtime they are running or widgets in use is out of date. $result['AIRTIME_API_VERSION'] = AIRTIME_API_VERSION; //used by caller to determine if the airtime they are running or widgets in use is out of date.
@ -324,10 +324,10 @@ class ApiController extends Zend_Controller_Action
$result = array(); $result = array();
for ($i=0; $i<7; $i++){ for ($i=0; $i<7; $i++){
$utcDayEnd = Application_Common_DateHelper::GetDayEndTimestamp($utcDayStart); $utcDayEnd = Application_Common_DateHelper::GetDayEndTimestamp($utcDayStart);
$shows = Application_Model_Show::GetNextShows($utcDayStart, "0", $utcDayEnd); $shows = Application_Model_Show::getNextShows($utcDayStart, "0", $utcDayEnd);
$utcDayStart = $utcDayEnd; $utcDayStart = $utcDayEnd;
Application_Model_Show::ConvertToLocalTimeZone($shows, array("starts", "ends", "start_timestamp", "end_timestamp")); Application_Model_Show::convertToLocalTimeZone($shows, array("starts", "ends", "start_timestamp", "end_timestamp"));
$result[$dow[$i]] = $shows; $result[$dow[$i]] = $shows;
} }
@ -413,7 +413,7 @@ class ApiController extends Zend_Controller_Action
$this->view->server_timezone = Application_Model_Preference::GetTimezone(); $this->view->server_timezone = Application_Model_Preference::GetTimezone();
$rows = Application_Model_Show::GetCurrentShow($today_timestamp); $rows = Application_Model_Show::GetCurrentShow($today_timestamp);
Application_Model_Show::ConvertToLocalTimeZone($rows, array("starts", "ends", "start_timestamp", "end_timestamp")); Application_Model_Show::convertToLocalTimeZone($rows, array("starts", "ends", "start_timestamp", "end_timestamp"));
if (count($rows) > 0){ if (count($rows) > 0){
$this->view->is_recording = ($rows[0]['record'] == 1); $this->view->is_recording = ($rows[0]['record'] == 1);

View File

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

View File

@ -186,7 +186,6 @@ class PlaylistController extends Zend_Controller_Action
try { try {
$pl = new Application_Model_Playlist($id); $pl = new Application_Model_Playlist($id);
$this->createFullResponse($pl); $this->createFullResponse($pl);
//$this->view->form = $form;
} }
catch (PlaylistNotFoundException $e) { catch (PlaylistNotFoundException $e) {
$this->playlistNotFound(); $this->playlistNotFound();

View File

@ -254,10 +254,10 @@ class PreferenceController extends Zend_Controller_Action
} }
// extra info that goes into cc_stream_setting // extra info that goes into cc_stream_setting
Application_Model_StreamSetting::SetMasterLiveSteamPort($values["master_harbor_input_port"]); Application_Model_StreamSetting::setMasterLiveStreamPort($values["master_harbor_input_port"]);
Application_Model_StreamSetting::SetMasterLiveSteamMountPoint($values["master_harbor_input_mount_point"]); Application_Model_StreamSetting::setMasterLiveStreamMountPoint($values["master_harbor_input_mount_point"]);
Application_Model_StreamSetting::SetDJLiveSteamPort($values["dj_harbor_input_port"]); Application_Model_StreamSetting::setDjLiveStreamPort($values["dj_harbor_input_port"]);
Application_Model_StreamSetting::SetDJLiveSteamMountPoint($values["dj_harbor_input_mount_point"]); Application_Model_StreamSetting::setDjLiveStreamMountPoint($values["dj_harbor_input_mount_point"]);
} }
// store stream update timestamp // store stream update timestamp

View File

@ -90,7 +90,7 @@ class ScheduleController extends Zend_Controller_Action
Application_Model_Schedule::createNewFormSections($this->view); 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))){ if($user->isUserType(array(UTYPE_ADMIN, UTYPE_PROGRAM_MANAGER))){
$this->view->preloadShowForm = true; $this->view->preloadShowForm = true;
@ -357,8 +357,8 @@ class ScheduleController extends Zend_Controller_Action
$range["next"]["ends"] = Application_Common_DateHelper::ConvertToLocalDateTimeString($range["next"]["ends"]); $range["next"]["ends"] = Application_Common_DateHelper::ConvertToLocalDateTimeString($range["next"]["ends"]);
} }
Application_Model_Show::ConvertToLocalTimeZone($range["currentShow"], array("starts", "ends", "start_timestamp", "end_timestamp")); Application_Model_Show::convertToLocalTimeZone($range["currentShow"], array("starts", "ends", "start_timestamp", "end_timestamp"));
Application_Model_Show::ConvertToLocalTimeZone($range["nextShow"], array("starts", "ends", "start_timestamp", "end_timestamp")); Application_Model_Show::convertToLocalTimeZone($range["nextShow"], array("starts", "ends", "start_timestamp", "end_timestamp"));
$source_status = array(); $source_status = array();
$switch_status = array(); $switch_status = array();
@ -689,7 +689,7 @@ class ScheduleController extends Zend_Controller_Action
public function getFormAction() { public function getFormAction() {
$user = Application_Model_User::GetCurrentUser(); $user = Application_Model_User::getCurrentUser();
if($user->isUserType(array(UTYPE_ADMIN, UTYPE_PROGRAM_MANAGER))){ if($user->isUserType(array(UTYPE_ADMIN, UTYPE_PROGRAM_MANAGER))){
Application_Model_Schedule::createNewFormSections($this->view); Application_Model_Schedule::createNewFormSections($this->view);
@ -822,7 +822,7 @@ class ScheduleController extends Zend_Controller_Action
public function cancelShowAction() public function cancelShowAction()
{ {
$user = Application_Model_User::GetCurrentUser(); $user = Application_Model_User::getCurrentUser();
if ($user->isUserType(array(UTYPE_ADMIN, UTYPE_PROGRAM_MANAGER))) { if ($user->isUserType(array(UTYPE_ADMIN, UTYPE_PROGRAM_MANAGER))) {
$showInstanceId = $this->_getParam('id'); $showInstanceId = $this->_getParam('id');
@ -842,7 +842,7 @@ class ScheduleController extends Zend_Controller_Action
public function cancelCurrentShowAction() public function cancelCurrentShowAction()
{ {
$user = Application_Model_User::GetCurrentUser(); $user = Application_Model_User::getCurrentUser();
if ($user->isUserType(array(UTYPE_ADMIN, UTYPE_PROGRAM_MANAGER))) { if ($user->isUserType(array(UTYPE_ADMIN, UTYPE_PROGRAM_MANAGER))) {
$id = $this->_getParam('id'); $id = $this->_getParam('id');

View File

@ -22,12 +22,12 @@ class ShowbuilderController extends Zend_Controller_Action
$request = $this->getRequest(); $request = $this->getRequest();
$baseUrl = $request->getBaseUrl(); $baseUrl = $request->getBaseUrl();
$user = Application_Model_User::GetCurrentUser(); $user = Application_Model_User::getCurrentUser();
$userType = $user->getType(); $userType = $user->getType();
$this->view->headScript()->appendScript("localStorage.setItem( 'user-type', '$userType' );"); $this->view->headScript()->appendScript("localStorage.setItem( 'user-type', '$userType' );");
$data = Application_Model_Preference::GetValue("library_datatable", true); $data = Application_Model_Preference::getValue("library_datatable", true);
if ($data != "") { if ($data != "") {
$libraryTable = json_encode(unserialize($data)); $libraryTable = json_encode(unserialize($data));
$this->view->headScript()->appendScript("localStorage.setItem( 'datatables-library', JSON.stringify($libraryTable) );"); $this->view->headScript()->appendScript("localStorage.setItem( 'datatables-library', JSON.stringify($libraryTable) );");
@ -36,7 +36,7 @@ class ShowbuilderController extends Zend_Controller_Action
$this->view->headScript()->appendScript("localStorage.setItem( 'datatables-library', '' );"); $this->view->headScript()->appendScript("localStorage.setItem( 'datatables-library', '' );");
} }
$data = Application_Model_Preference::GetValue("timeline_datatable", true); $data = Application_Model_Preference::getValue("timeline_datatable", true);
if ($data != "") { if ($data != "") {
$timelineTable = json_encode(unserialize($data)); $timelineTable = json_encode(unserialize($data));
$this->view->headScript()->appendScript("localStorage.setItem( 'datatables-timeline', JSON.stringify($timelineTable) );"); $this->view->headScript()->appendScript("localStorage.setItem( 'datatables-timeline', JSON.stringify($timelineTable) );");
@ -130,7 +130,7 @@ class ShowbuilderController extends Zend_Controller_Action
$showLib = false; $showLib = false;
if (!$user->isGuest()) { if (!$user->isGuest()) {
$disableLib = false; $disableLib = false;
$data = Application_Model_Preference::GetValue("nowplaying_screen", true); $data = Application_Model_Preference::getValue("nowplaying_screen", true);
if ($data != "") { if ($data != "") {
$settings = unserialize($data); $settings = unserialize($data);
@ -184,7 +184,7 @@ class ShowbuilderController extends Zend_Controller_Action
$baseUrl = $request->getBaseUrl(); $baseUrl = $request->getBaseUrl();
$menu = array(); $menu = array();
$user = Application_Model_User::GetCurrentUser(); $user = Application_Model_User::getCurrentUser();
$item = CcScheduleQuery::create()->findPK($id); $item = CcScheduleQuery::create()->findPK($id);
$instance = $item->getCcShowInstances(); $instance = $item->getCcShowInstances();

View File

@ -23,12 +23,12 @@ class UsersettingsController extends Zend_Controller_Action
$settings = $request->getParam("settings"); $settings = $request->getParam("settings");
$data = serialize($settings); $data = serialize($settings);
Application_Model_Preference::SetValue("nowplaying_screen", $data, true); Application_Model_Preference::setValue("nowplaying_screen", $data, true);
} }
public function getNowPlayingScreenSettingsAction() { public function getNowPlayingScreenSettingsAction() {
$data = Application_Model_Preference::GetValue("nowplaying_screen", true); $data = Application_Model_Preference::getValue("nowplaying_screen", true);
if ($data != "") { if ($data != "") {
$this->view->settings = unserialize($data); $this->view->settings = unserialize($data);
} }
@ -40,12 +40,12 @@ class UsersettingsController extends Zend_Controller_Action
$settings = $request->getParam("settings"); $settings = $request->getParam("settings");
$data = serialize($settings); $data = serialize($settings);
Application_Model_Preference::SetValue("library_datatable", $data, true); Application_Model_Preference::setValue("library_datatable", $data, true);
} }
public function getLibraryDatatableAction() { public function getLibraryDatatableAction() {
$data = Application_Model_Preference::GetValue("library_datatable", true); $data = Application_Model_Preference::getValue("library_datatable", true);
if ($data != "") { if ($data != "") {
$this->view->settings = unserialize($data); $this->view->settings = unserialize($data);
} }
@ -59,7 +59,7 @@ class UsersettingsController extends Zend_Controller_Action
$settings = $request->getParam("settings"); $settings = $request->getParam("settings");
$data = serialize($settings); $data = serialize($settings);
Application_Model_Preference::SetValue("timeline_datatable", $data, true); Application_Model_Preference::setValue("timeline_datatable", $data, true);
$end = microtime(true); $end = microtime(true);
@ -71,7 +71,7 @@ class UsersettingsController extends Zend_Controller_Action
$start = microtime(true); $start = microtime(true);
$data = Application_Model_Preference::GetValue("timeline_datatable", true); $data = Application_Model_Preference::getValue("timeline_datatable", true);
if ($data != "") { if ($data != "") {
$this->view->settings = unserialize($data); $this->view->settings = unserialize($data);
} }

View File

@ -6,7 +6,7 @@ class Application_Form_AddShowWhat extends Zend_Form_SubForm
{ {
// retrieves the length limit for each char field // retrieves the length limit for each char field
// and store to assoc array // and store to assoc array
$maxLens = Application_Model_Show::GetMaxLengths(); $maxLens = Application_Model_Show::getMaxLengths();
// Hidden element to indicate whether the show is new or // Hidden element to indicate whether the show is new or
// whether we are updating an existing show. // whether we are updating an existing show.

View File

@ -86,6 +86,9 @@ class Application_Form_AddShowWhen extends Zend_Form_SubForm
public function checkReliantFields($formData, $validateStartDate, $originalStartDate=null, $update=false, $instanceId=null) { public function checkReliantFields($formData, $validateStartDate, $originalStartDate=null, $update=false, $instanceId=null) {
$valid = true; $valid = true;
$hours;
$minutes;
$start_time = $formData['add_show_start_date']." ".$formData['add_show_start_time']; $start_time = $formData['add_show_start_date']." ".$formData['add_show_start_time'];
$end_time = $formData['add_show_end_date_no_repeat']." ".$formData['add_show_end_time']; $end_time = $formData['add_show_end_date_no_repeat']." ".$formData['add_show_end_time'];
@ -148,12 +151,114 @@ class Application_Form_AddShowWhen extends Zend_Form_SubForm
$show_end = new DateTime($end_time); $show_end = new DateTime($end_time);
$show_end->setTimezone(new DateTimeZone('UTC')); $show_end->setTimezone(new DateTimeZone('UTC'));
if ($formData["add_show_repeats"]) {
//get repeating show end date
if ($formData["add_show_no_end"]) {
$date = Application_Model_Preference::GetShowsPopulatedUntil();
if (is_null($date)) {
$populateUntilDateTime = new DateTime("now", new DateTimeZone('UTC'));
Application_Model_Preference::SetShowsPopulatedUntil($populateUntilDateTime);
} else {
$populateUntilDateTime = clone $date;
}
} elseif (!$formData["add_show_no_end"]) {
$popUntil = $formData["add_show_end_date"]." ".$formData["add_show_end_time"];
$populateUntilDateTime = new DateTime($popUntil, new DateTimeZone('UTC'));
}
//get repeat interval
if ($formData["add_show_repeat_type"] == 0) {
$interval = 'P7D';
} elseif ($formData["add_show_repeat_type"] == 1) {
$interval = 'P14D';
} elseif ($formData["add_show_repeat_type"] == 2) {
$interval = 'P1M';
}
/* Check first show
* Continue if the first show does not overlap
*/
$overlapping = Application_Model_Schedule::checkOverlappingShows($show_start, $show_end, $update, $instanceId);
/* Check if repeats overlap with previously scheduled shows
* Do this for each show day
*/
if (!$overlapping) {
$startDow = date("w", $show_start->getTimestamp());
foreach($formData["add_show_day_check"] as $day) {
$repeatShowStart = clone $show_start;
$repeatShowEnd = clone $show_end;
$daysAdd=0;
if ($startDow !== $day){
if ($startDow > $day)
$daysAdd = 6 - $startDow + 1 + $day;
else
$daysAdd = $day - $startDow;
$repeatShowStart->add(new DateInterval("P".$daysAdd."D"));
$repeatShowEnd->add(new DateInterval("P".$daysAdd."D"));
}
while ($repeatShowStart->getTimestamp() < $populateUntilDateTime->getTimestamp()) {
$overlapping = Application_Model_Schedule::checkOverlappingShows($repeatShowStart, $repeatShowEnd, $update, $instanceId);
if ($overlapping) {
$valid = false;
$this->getElement('add_show_duration')->setErrors(array('Cannot schedule overlapping shows'));
break 1;
} else {
$repeatShowStart->add(new DateInterval($interval));
$repeatShowEnd->add(new DateInterval($interval));
}
}
}
} else {
$valid = false;
$this->getElement('add_show_duration')->setErrors(array('Cannot schedule overlapping shows'));
}
} elseif ($formData["add_show_rebroadcast"]) {
/* Check first show
* Continue if the first show does not overlap
*/
$overlapping = Application_Model_Schedule::checkOverlappingShows($show_start, $show_end, $update, $instanceId);
if (!$overlapping) {
for ($i = 1; $i <= 10; $i++) {
$hours = ltrim($hours, '0');
if ($minutes != "00") {
$minutes = ltrim($minutes, '0');
$durationToAdd = "PT".$hours."H".$minutes."I";
} else {
$minutes = "0";
$durationToAdd = "PT".$hours."H";
}
$abs_rebroadcast_start = $formData["add_show_rebroadcast_date_absolute_".$i]." ".
$formData["add_show_rebroadcast_time_absolute_".$i];
$rebroadcastShowStart = new DateTime($abs_rebroadcast_start);
$rebroadcastShowStart->setTimezone(new DateTimeZone('UTC'));
$rebroadcastShowEnd = clone $rebroadcastShowStart;
$rebroadcastShowEnd->add(new DateInterval($durationToAdd));
$overlapping = Application_Model_Schedule::checkOverlappingShows($rebroadcastShowStart, $rebroadcastShowEnd, $update, $instanceId);
if ($overlapping) {
$valid = false;
$this->getElement('add_show_duration')->setErrors(array('Cannot schedule overlapping shows'));
break;
}
}
} else {
$valid = false;
$this->getElement('add_show_duration')->setErrors(array('Cannot schedule overlapping shows'));
}
} else {
$overlapping = Application_Model_Schedule::checkOverlappingShows($show_start, $show_end, $update, $instanceId); $overlapping = Application_Model_Schedule::checkOverlappingShows($show_start, $show_end, $update, $instanceId);
if ($overlapping) { if ($overlapping) {
$this->getElement('add_show_duration')->setErrors(array('Cannot schedule overlapping shows')); $this->getElement('add_show_duration')->setErrors(array('Cannot schedule overlapping shows'));
$valid = false; $valid = false;
} }
} }
}
return $valid; return $valid;
} }

View File

@ -24,7 +24,7 @@ class Application_Form_GeneralPreferences extends Zend_Form_SubForm
'label' => 'Station Name', 'label' => 'Station Name',
'required' => false, 'required' => false,
'filters' => array('StringTrim'), 'filters' => array('StringTrim'),
'value' => Application_Model_Preference::GetValue("station_name"), 'value' => Application_Model_Preference::getValue("station_name"),
'decorators' => array( 'decorators' => array(
'ViewHelper' 'ViewHelper'
) )

View File

@ -83,7 +83,7 @@ class Application_Form_LiveStreamingPreferences extends Zend_Form_SubForm
//liquidsoap harbor.input port //liquidsoap harbor.input port
if (!$isSaas) { if (!$isSaas) {
$m_port = Application_Model_StreamSetting::GetMasterLiveSteamPort(); $m_port = Application_Model_StreamSetting::getMasterLiveStreamPort();
$master_dj_port = new Zend_Form_Element_Text('master_harbor_input_port'); $master_dj_port = new Zend_Form_Element_Text('master_harbor_input_port');
$master_dj_port->setLabel("Master Source Port") $master_dj_port->setLabel("Master Source Port")
->setValue($m_port) ->setValue($m_port)
@ -92,7 +92,7 @@ class Application_Form_LiveStreamingPreferences extends Zend_Form_SubForm
->setDecorators(array('ViewHelper')); ->setDecorators(array('ViewHelper'));
$this->addElement($master_dj_port); $this->addElement($master_dj_port);
$m_mount = Application_Model_StreamSetting::GetMasterLiveSteamMountPoint(); $m_mount = Application_Model_StreamSetting::getMasterLiveStreamMountPoint();
$master_dj_mount = new Zend_Form_Element_Text('master_harbor_input_mount_point'); $master_dj_mount = new Zend_Form_Element_Text('master_harbor_input_mount_point');
$master_dj_mount->setLabel("Master Source Mount Point") $master_dj_mount->setLabel("Master Source Mount Point")
->setValue($m_mount) ->setValue($m_mount)
@ -102,7 +102,7 @@ class Application_Form_LiveStreamingPreferences extends Zend_Form_SubForm
$this->addElement($master_dj_mount); $this->addElement($master_dj_mount);
//liquidsoap harbor.input port //liquidsoap harbor.input port
$l_port = Application_Model_StreamSetting::GetDJLiveSteamPort(); $l_port = Application_Model_StreamSetting::getDjLiveStreamPort();
$live_dj_port = new Zend_Form_Element_Text('dj_harbor_input_port'); $live_dj_port = new Zend_Form_Element_Text('dj_harbor_input_port');
$live_dj_port->setLabel("Show Source Port") $live_dj_port->setLabel("Show Source Port")
->setValue($l_port) ->setValue($l_port)
@ -111,7 +111,7 @@ class Application_Form_LiveStreamingPreferences extends Zend_Form_SubForm
->setDecorators(array('ViewHelper')); ->setDecorators(array('ViewHelper'));
$this->addElement($live_dj_port); $this->addElement($live_dj_port);
$l_mount = Application_Model_StreamSetting::GetDJLiveSteamMountPoint(); $l_mount = Application_Model_StreamSetting::getDjLiveStreamMountPoint();
$live_dj_mount = new Zend_Form_Element_Text('dj_harbor_input_mount_point'); $live_dj_mount = new Zend_Form_Element_Text('dj_harbor_input_mount_point');
$live_dj_mount->setLabel("Show Source Mount Point") $live_dj_mount->setLabel("Show Source Mount Point")
->setValue($l_mount) ->setValue($l_mount)
@ -159,7 +159,7 @@ class Application_Form_LiveStreamingPreferences extends Zend_Form_SubForm
} }
if($master_harbor_input_port != ""){ if($master_harbor_input_port != ""){
if(is_numeric($master_harbor_input_port)){ if(is_numeric($master_harbor_input_port)){
if($master_harbor_input_port != Application_Model_StreamSetting::GetMasterLiveSteamPort()){ if($master_harbor_input_port != Application_Model_StreamSetting::getMasterLiveStreamPort()){
$sock = socket_create(AF_INET, SOCK_STREAM, SOL_TCP); $sock = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
$res = socket_bind($sock, 0, $master_harbor_input_port); $res = socket_bind($sock, 0, $master_harbor_input_port);
if(!$res){ if(!$res){
@ -175,7 +175,7 @@ class Application_Form_LiveStreamingPreferences extends Zend_Form_SubForm
} }
if($dj_harbor_input_port != ""){ if($dj_harbor_input_port != ""){
if(is_numeric($dj_harbor_input_port)){ if(is_numeric($dj_harbor_input_port)){
if($dj_harbor_input_port != Application_Model_StreamSetting::GetDJLiveSteamPort()){ if($dj_harbor_input_port != Application_Model_StreamSetting::getDjLiveStreamPort()){
$sock = socket_create(AF_INET, SOCK_STREAM, SOL_TCP); $sock = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
$res = socket_bind($sock, 0, $dj_harbor_input_port); $res = socket_bind($sock, 0, $dj_harbor_input_port);
if(!$res){ if(!$res){

View File

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

View File

@ -24,7 +24,7 @@ class Application_Form_SupportSettings extends Zend_Form
'required' => true, 'required' => true,
'filters' => array('StringTrim'), 'filters' => array('StringTrim'),
'validator' => array('NotEmpty'), 'validator' => array('NotEmpty'),
'value' => Application_Model_Preference::GetValue("station_name"), 'value' => Application_Model_Preference::getValue("station_name"),
'decorators' => array( 'decorators' => array(
'ViewHelper' 'ViewHelper'
) )

View File

@ -3,7 +3,7 @@
class Application_Model_Preference class Application_Model_Preference
{ {
public static function SetValue($key, $value, $isUserValue = false){ public static function setValue($key, $value, $isUserValue = false){
try { try {
$con = Propel::getConnection(); $con = Propel::getConnection();
@ -72,7 +72,7 @@ class Application_Model_Preference
} }
public static function GetValue($key, $isUserValue = false){ public static function getValue($key, $isUserValue = false){
try { try {
$con = Propel::getConnection(); $con = Propel::getConnection();
@ -110,7 +110,7 @@ class Application_Model_Preference
} }
public static function GetHeadTitle(){ public static function GetHeadTitle(){
$title = self::GetValue("station_name"); $title = self::getValue("station_name");
$defaultNamespace->title = $title; $defaultNamespace->title = $title;
if (strlen($title) > 0) if (strlen($title) > 0)
$title .= " - "; $title .= " - ";
@ -119,7 +119,7 @@ class Application_Model_Preference
} }
public static function SetHeadTitle($title, $view=null){ public static function SetHeadTitle($title, $view=null){
self::SetValue("station_name", $title); self::setValue("station_name", $title);
// in case this is called from airtime-saas script // in case this is called from airtime-saas script
if($view !== null){ if($view !== null){
@ -143,7 +143,7 @@ class Application_Model_Preference
* A row from cc_show_days table * A row from cc_show_days table
*/ */
public static function SetShowsPopulatedUntil($dateTime) { public static function SetShowsPopulatedUntil($dateTime) {
self::SetValue("shows_populated_until", $dateTime->format("Y-m-d H:i:s")); self::setValue("shows_populated_until", $dateTime->format("Y-m-d H:i:s"));
} }
/** /**
@ -156,7 +156,7 @@ class Application_Model_Preference
* @return DateTime (in UTC Timezone) * @return DateTime (in UTC Timezone)
*/ */
public static function GetShowsPopulatedUntil() { public static function GetShowsPopulatedUntil() {
$date = self::GetValue("shows_populated_until"); $date = self::getValue("shows_populated_until");
if ($date == ""){ if ($date == ""){
return null; return null;
@ -166,11 +166,11 @@ class Application_Model_Preference
} }
public static function SetDefaultFade($fade) { public static function SetDefaultFade($fade) {
self::SetValue("default_fade", $fade); self::setValue("default_fade", $fade);
} }
public static function GetDefaultFade() { public static function GetDefaultFade() {
$fade = self::GetValue("default_fade"); $fade = self::getValue("default_fade");
if ($fade === "") { if ($fade === "") {
// the default value of the fade is 00.500000 // the default value of the fade is 00.500000
@ -195,7 +195,7 @@ class Application_Model_Preference
} }
public static function SetDefaultTransitionFade($fade) { public static function SetDefaultTransitionFade($fade) {
self::SetValue("default_transition_fade", $fade); self::setValue("default_transition_fade", $fade);
$eventType = "update_transition_fade"; $eventType = "update_transition_fade";
$md = array("transition_fade"=>$fade); $md = array("transition_fade"=>$fade);
@ -203,7 +203,7 @@ class Application_Model_Preference
} }
public static function GetDefaultTransitionFade() { public static function GetDefaultTransitionFade() {
$transition_fade = self::GetValue("default_transition_fade"); $transition_fade = self::getValue("default_transition_fade");
if($transition_fade == ""){ if($transition_fade == ""){
$transition_fade = "00.000000"; $transition_fade = "00.000000";
} }
@ -211,7 +211,7 @@ class Application_Model_Preference
} }
public static function SetStreamLabelFormat($type){ public static function SetStreamLabelFormat($type){
self::SetValue("stream_label_format", $type); self::setValue("stream_label_format", $type);
$eventType = "update_stream_format"; $eventType = "update_stream_format";
$md = array("stream_format"=>$type); $md = array("stream_format"=>$type);
@ -228,68 +228,68 @@ class Application_Model_Preference
} }
public static function SetAutoUploadRecordedShowToSoundcloud($upload) { public static function SetAutoUploadRecordedShowToSoundcloud($upload) {
self::SetValue("soundcloud_auto_upload_recorded_show", $upload); self::setValue("soundcloud_auto_upload_recorded_show", $upload);
} }
public static function GetAutoUploadRecordedShowToSoundcloud() { public static function GetAutoUploadRecordedShowToSoundcloud() {
return self::GetValue("soundcloud_auto_upload_recorded_show"); return self::getValue("soundcloud_auto_upload_recorded_show");
} }
public static function SetSoundCloudUser($user) { public static function SetSoundCloudUser($user) {
self::SetValue("soundcloud_user", $user); self::setValue("soundcloud_user", $user);
} }
public static function GetSoundCloudUser() { public static function GetSoundCloudUser() {
return self::GetValue("soundcloud_user"); return self::getValue("soundcloud_user");
} }
public static function SetSoundCloudPassword($password) { public static function SetSoundCloudPassword($password) {
if (strlen($password) > 0) if (strlen($password) > 0)
self::SetValue("soundcloud_password", $password); self::setValue("soundcloud_password", $password);
} }
public static function GetSoundCloudPassword() { public static function GetSoundCloudPassword() {
return self::GetValue("soundcloud_password"); return self::getValue("soundcloud_password");
} }
public static function SetSoundCloudTags($tags) { public static function SetSoundCloudTags($tags) {
self::SetValue("soundcloud_tags", $tags); self::setValue("soundcloud_tags", $tags);
} }
public static function GetSoundCloudTags() { public static function GetSoundCloudTags() {
return self::GetValue("soundcloud_tags"); return self::getValue("soundcloud_tags");
} }
public static function SetSoundCloudGenre($genre) { public static function SetSoundCloudGenre($genre) {
self::SetValue("soundcloud_genre", $genre); self::setValue("soundcloud_genre", $genre);
} }
public static function GetSoundCloudGenre() { public static function GetSoundCloudGenre() {
return self::GetValue("soundcloud_genre"); return self::getValue("soundcloud_genre");
} }
public static function SetSoundCloudTrackType($track_type) { public static function SetSoundCloudTrackType($track_type) {
self::SetValue("soundcloud_tracktype", $track_type); self::setValue("soundcloud_tracktype", $track_type);
} }
public static function GetSoundCloudTrackType() { public static function GetSoundCloudTrackType() {
return self::GetValue("soundcloud_tracktype"); return self::getValue("soundcloud_tracktype");
} }
public static function SetSoundCloudLicense($license) { public static function SetSoundCloudLicense($license) {
self::SetValue("soundcloud_license", $license); self::setValue("soundcloud_license", $license);
} }
public static function GetSoundCloudLicense() { public static function GetSoundCloudLicense() {
return self::GetValue("soundcloud_license"); return self::getValue("soundcloud_license");
} }
public static function SetAllow3rdPartyApi($bool) { public static function SetAllow3rdPartyApi($bool) {
self::SetValue("third_party_api", $bool); self::setValue("third_party_api", $bool);
} }
public static function GetAllow3rdPartyApi() { public static function GetAllow3rdPartyApi() {
$val = self::GetValue("third_party_api"); $val = self::getValue("third_party_api");
if (strlen($val) == 0){ if (strlen($val) == 0){
return "0"; return "0";
} else { } else {
@ -298,101 +298,101 @@ class Application_Model_Preference
} }
public static function SetPhone($phone){ public static function SetPhone($phone){
self::SetValue("phone", $phone); self::setValue("phone", $phone);
} }
public static function GetPhone(){ public static function GetPhone(){
return self::GetValue("phone"); return self::getValue("phone");
} }
public static function SetEmail($email){ public static function SetEmail($email){
self::SetValue("email", $email); self::setValue("email", $email);
} }
public static function GetEmail(){ public static function GetEmail(){
return self::GetValue("email"); return self::getValue("email");
} }
public static function SetStationWebSite($site){ public static function SetStationWebSite($site){
self::SetValue("station_website", $site); self::setValue("station_website", $site);
} }
public static function GetStationWebSite(){ public static function GetStationWebSite(){
return self::GetValue("station_website"); return self::getValue("station_website");
} }
public static function SetSupportFeedback($feedback){ public static function SetSupportFeedback($feedback){
self::SetValue("support_feedback", $feedback); self::setValue("support_feedback", $feedback);
} }
public static function GetSupportFeedback(){ public static function GetSupportFeedback(){
return self::GetValue("support_feedback"); return self::getValue("support_feedback");
} }
public static function SetPublicise($publicise){ public static function SetPublicise($publicise){
self::SetValue("publicise", $publicise); self::setValue("publicise", $publicise);
} }
public static function GetPublicise(){ public static function GetPublicise(){
return self::GetValue("publicise"); return self::getValue("publicise");
} }
public static function SetRegistered($registered){ public static function SetRegistered($registered){
self::SetValue("registered", $registered); self::setValue("registered", $registered);
} }
public static function GetRegistered(){ public static function GetRegistered(){
return self::GetValue("registered"); return self::getValue("registered");
} }
public static function SetStationCountry($country){ public static function SetStationCountry($country){
self::SetValue("country", $country); self::setValue("country", $country);
} }
public static function GetStationCountry(){ public static function GetStationCountry(){
return self::GetValue("country"); return self::getValue("country");
} }
public static function SetStationCity($city){ public static function SetStationCity($city){
self::SetValue("city", $city); self::setValue("city", $city);
} }
public static function GetStationCity(){ public static function GetStationCity(){
return self::GetValue("city"); return self::getValue("city");
} }
public static function SetStationDescription($description){ public static function SetStationDescription($description){
self::SetValue("description", $description); self::setValue("description", $description);
} }
public static function GetStationDescription(){ public static function GetStationDescription(){
return self::GetValue("description"); return self::getValue("description");
} }
public static function SetTimezone($timezone){ public static function SetTimezone($timezone){
self::SetValue("timezone", $timezone); self::setValue("timezone", $timezone);
date_default_timezone_set($timezone); date_default_timezone_set($timezone);
$md = array("timezone" => $timezone); $md = array("timezone" => $timezone);
} }
public static function GetTimezone(){ public static function GetTimezone(){
return self::GetValue("timezone"); return self::getValue("timezone");
} }
public static function SetStationLogo($imagePath){ public static function SetStationLogo($imagePath){
if(!empty($imagePath)){ if(!empty($imagePath)){
$image = @file_get_contents($imagePath); $image = @file_get_contents($imagePath);
$image = base64_encode($image); $image = base64_encode($image);
self::SetValue("logoImage", $image); self::setValue("logoImage", $image);
} }
} }
public static function GetStationLogo(){ public static function GetStationLogo(){
return self::GetValue("logoImage"); return self::getValue("logoImage");
} }
public static function GetUniqueId(){ public static function GetUniqueId(){
return self::GetValue("uniqueId"); return self::getValue("uniqueId");
} }
public static function GetCountryList() public static function GetCountryList()
@ -531,64 +531,64 @@ class Application_Model_Preference
public static function SetRemindMeDate(){ public static function SetRemindMeDate(){
$weekAfter = mktime(0, 0, 0, gmdate("m"), gmdate("d")+7, gmdate("Y")); $weekAfter = mktime(0, 0, 0, gmdate("m"), gmdate("d")+7, gmdate("Y"));
self::SetValue("remindme", $weekAfter); self::setValue("remindme", $weekAfter);
} }
public static function GetRemindMeDate(){ public static function GetRemindMeDate(){
return self::GetValue("remindme"); return self::getValue("remindme");
} }
public static function SetImportTimestamp(){ public static function SetImportTimestamp(){
$now = time(); $now = time();
if(self::GetImportTimestamp()+5 < $now){ if(self::GetImportTimestamp()+5 < $now){
self::SetValue("import_timestamp", $now); self::setValue("import_timestamp", $now);
} }
} }
public static function GetImportTimestamp(){ public static function GetImportTimestamp(){
return self::GetValue("import_timestamp"); return self::getValue("import_timestamp");
} }
public static function GetStreamType(){ public static function GetStreamType(){
$st = self::GetValue("stream_type"); $st = self::getValue("stream_type");
return explode(',', $st); return explode(',', $st);
} }
public static function GetStreamBitrate(){ public static function GetStreamBitrate(){
$sb = self::GetValue("stream_bitrate"); $sb = self::getValue("stream_bitrate");
return explode(',', $sb); return explode(',', $sb);
} }
public static function SetPrivacyPolicyCheck($flag){ public static function SetPrivacyPolicyCheck($flag){
self::SetValue("privacy_policy", $flag); self::setValue("privacy_policy", $flag);
} }
public static function GetPrivacyPolicyCheck(){ public static function GetPrivacyPolicyCheck(){
return self::GetValue("privacy_policy"); return self::getValue("privacy_policy");
} }
public static function SetNumOfStreams($num){ public static function SetNumOfStreams($num){
self::SetValue("num_of_streams", intval($num)); self::setValue("num_of_streams", intval($num));
} }
public static function GetNumOfStreams(){ public static function GetNumOfStreams(){
return self::GetValue("num_of_streams"); return self::getValue("num_of_streams");
} }
public static function SetMaxBitrate($bitrate){ public static function SetMaxBitrate($bitrate){
self::SetValue("max_bitrate", intval($bitrate)); self::setValue("max_bitrate", intval($bitrate));
} }
public static function GetMaxBitrate(){ public static function GetMaxBitrate(){
return self::GetValue("max_bitrate"); return self::getValue("max_bitrate");
} }
public static function SetPlanLevel($plan){ public static function SetPlanLevel($plan){
self::SetValue("plan_level", $plan); self::setValue("plan_level", $plan);
} }
public static function GetPlanLevel(){ public static function GetPlanLevel(){
$plan = self::GetValue("plan_level"); $plan = self::getValue("plan_level");
if(trim($plan) == ''){ if(trim($plan) == ''){
$plan = 'disabled'; $plan = 'disabled';
} }
@ -596,36 +596,36 @@ class Application_Model_Preference
} }
public static function SetTrialEndingDate($date){ public static function SetTrialEndingDate($date){
self::SetValue("trial_end_date", $date); self::setValue("trial_end_date", $date);
} }
public static function GetTrialEndingDate(){ public static function GetTrialEndingDate(){
return self::GetValue("trial_end_date"); return self::getValue("trial_end_date");
} }
public static function SetEnableStreamConf($bool){ public static function SetEnableStreamConf($bool){
self::SetValue("enable_stream_conf", $bool); self::setValue("enable_stream_conf", $bool);
} }
public static function GetEnableStreamConf(){ public static function GetEnableStreamConf(){
if(self::GetValue("enable_stream_conf") == Null){ if(self::getValue("enable_stream_conf") == Null){
return "true"; return "true";
} }
return self::GetValue("enable_stream_conf"); return self::getValue("enable_stream_conf");
} }
public static function GetAirtimeVersion(){ public static function GetAirtimeVersion(){
if (defined('APPLICATION_ENV') && APPLICATION_ENV == "development" && function_exists('exec')){ if (defined('APPLICATION_ENV') && APPLICATION_ENV == "development" && function_exists('exec')){
$version = exec("git rev-parse --short HEAD 2>/dev/null", $out, $return_code); $version = exec("git rev-parse --short HEAD 2>/dev/null", $out, $return_code);
if ($return_code == 0){ if ($return_code == 0){
return self::GetValue("system_version")."+".$version.":".time(); return self::getValue("system_version")."+".$version.":".time();
} }
} }
return self::GetValue("system_version"); return self::getValue("system_version");
} }
public static function GetLatestVersion(){ public static function GetLatestVersion(){
$latest = self::GetValue("latest_version"); $latest = self::getValue("latest_version");
if($latest == null || strlen($latest) == 0) { if($latest == null || strlen($latest) == 0) {
return self::GetAirtimeVersion(); return self::GetAirtimeVersion();
} else { } else {
@ -636,12 +636,12 @@ class Application_Model_Preference
public static function SetLatestVersion($version){ public static function SetLatestVersion($version){
$pattern = "/^[0-9]+\.[0-9]+\.[0-9]+/"; $pattern = "/^[0-9]+\.[0-9]+\.[0-9]+/";
if(preg_match($pattern, $version)) { if(preg_match($pattern, $version)) {
self::SetValue("latest_version", $version); self::setValue("latest_version", $version);
} }
} }
public static function GetLatestLink(){ public static function GetLatestLink(){
$link = self::GetValue("latest_link"); $link = self::getValue("latest_link");
if($link == null || strlen($link) == 0) { if($link == null || strlen($link) == 0) {
return 'http://airtime.sourcefabric.org'; return 'http://airtime.sourcefabric.org';
} else { } else {
@ -654,32 +654,32 @@ class Application_Model_Preference
"([a-zA-Z0-9]+\.)*[a-zA-Z0-9]+" . "([a-zA-Z0-9]+\.)*[a-zA-Z0-9]+" .
"(/[a-zA-Z0-9\-\.\_\~\:\?\#\[\]\@\!\$\&\'\(\)\*\+\,\;\=]+)*/?$#"; "(/[a-zA-Z0-9\-\.\_\~\:\?\#\[\]\@\!\$\&\'\(\)\*\+\,\;\=]+)*/?$#";
if(preg_match($pattern, $link)) { if(preg_match($pattern, $link)) {
self::SetValue("latest_link", $link); self::setValue("latest_link", $link);
} }
} }
public static function SetUploadToSoundcloudOption($upload) { public static function SetUploadToSoundcloudOption($upload) {
self::SetValue("soundcloud_upload_option", $upload); self::setValue("soundcloud_upload_option", $upload);
} }
public static function GetUploadToSoundcloudOption() { public static function GetUploadToSoundcloudOption() {
return self::GetValue("soundcloud_upload_option"); return self::getValue("soundcloud_upload_option");
} }
public static function SetSoundCloudDownloadbleOption($upload) { public static function SetSoundCloudDownloadbleOption($upload) {
self::SetValue("soundcloud_downloadable", $upload); self::setValue("soundcloud_downloadable", $upload);
} }
public static function GetSoundCloudDownloadbleOption() { public static function GetSoundCloudDownloadbleOption() {
return self::GetValue("soundcloud_downloadable"); return self::getValue("soundcloud_downloadable");
} }
public static function SetWeekStartDay($day) { public static function SetWeekStartDay($day) {
self::SetValue("week_start_day", $day); self::setValue("week_start_day", $day);
} }
public static function GetWeekStartDay() { public static function GetWeekStartDay() {
$val = self::GetValue("week_start_day"); $val = self::getValue("week_start_day");
if (strlen($val) == 0){ if (strlen($val) == 0){
return "0"; return "0";
} else { } else {
@ -692,14 +692,14 @@ class Application_Model_Preference
*/ */
public static function SetStreamUpdateTimestamp() { public static function SetStreamUpdateTimestamp() {
$now = time(); $now = time();
self::SetValue("stream_update_timestamp", $now); self::setValue("stream_update_timestamp", $now);
} }
/** /**
* Gets the last timestamp of user updating stream setting * Gets the last timestamp of user updating stream setting
*/ */
public static function GetStreamUpdateTimestemp() { public static function GetStreamUpdateTimestemp() {
$update_time = self::GetValue("stream_update_timestamp"); $update_time = self::getValue("stream_update_timestamp");
if($update_time == null){ if($update_time == null){
$update_time = 0; $update_time = 0;
} }
@ -707,12 +707,12 @@ class Application_Model_Preference
} }
public static function GetClientId() { public static function GetClientId() {
return self::GetValue("client_id"); return self::getValue("client_id");
} }
public static function SetClientId($id) { public static function SetClientId($id) {
if (is_numeric($id)) { if (is_numeric($id)) {
self::SetValue("client_id", $id); self::setValue("client_id", $id);
} }
} }
@ -724,7 +724,7 @@ class Application_Model_Preference
* @param $timeScale new time scale * @param $timeScale new time scale
*/ */
public static function SetCalendarTimeScale($timeScale) { public static function SetCalendarTimeScale($timeScale) {
self::SetValue("calendar_time_scale", $timeScale, true /* user specific */); self::setValue("calendar_time_scale", $timeScale, true /* user specific */);
} }
/** /**
@ -732,7 +732,7 @@ class Application_Model_Preference
* Defaults to month if no entry exists * Defaults to month if no entry exists
*/ */
public static function GetCalendarTimeScale() { public static function GetCalendarTimeScale() {
$val = self::GetValue("calendar_time_scale", true /* user specific */); $val = self::getValue("calendar_time_scale", true /* user specific */);
if(strlen($val) == 0) { if(strlen($val) == 0) {
$val = "month"; $val = "month";
} }
@ -745,7 +745,7 @@ class Application_Model_Preference
* @param $numEntries new number of entries to show * @param $numEntries new number of entries to show
*/ */
public static function SetLibraryNumEntries($numEntries) { public static function SetLibraryNumEntries($numEntries) {
self::SetValue("library_num_entries", $numEntries, true /* user specific */); self::setValue("library_num_entries", $numEntries, true /* user specific */);
} }
/** /**
@ -753,7 +753,7 @@ class Application_Model_Preference
* Defaults to 10 if no entry exists * Defaults to 10 if no entry exists
*/ */
public static function GetLibraryNumEntries() { 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) { if(strlen($val) == 0) {
$val = "10"; $val = "10";
} }
@ -766,7 +766,7 @@ class Application_Model_Preference
* @param $timeInterval new time interval * @param $timeInterval new time interval
*/ */
public static function SetCalendarTimeInterval($timeInterval) { public static function SetCalendarTimeInterval($timeInterval) {
self::SetValue("calendar_time_interval", $timeInterval, true /* user specific */); 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 * Defaults to 30 min if no entry exists
*/ */
public static function GetCalendarTimeInterval() { 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) { if(strlen($val) == 0) {
$val = "30"; $val = "30";
} }
@ -782,11 +782,11 @@ class Application_Model_Preference
} }
public static function SetDiskQuota($value){ public static function SetDiskQuota($value){
self::SetValue("disk_quota", $value, false); self::setValue("disk_quota", $value, false);
} }
public static function GetDiskQuota(){ public static function GetDiskQuota(){
$val = self::GetValue("disk_quota"); $val = self::getValue("disk_quota");
if(strlen($val) == 0) { if(strlen($val) == 0) {
$val = "0"; $val = "0";
} }
@ -794,27 +794,27 @@ class Application_Model_Preference
} }
public static function SetLiveSteamMasterUsername($value){ public static function SetLiveSteamMasterUsername($value){
self::SetValue("live_stream_master_username", $value, false); self::setValue("live_stream_master_username", $value, false);
} }
public static function GetLiveSteamMasterUsername(){ public static function GetLiveSteamMasterUsername(){
return self::GetValue("live_stream_master_username"); return self::getValue("live_stream_master_username");
} }
public static function SetLiveSteamMasterPassword($value){ public static function SetLiveSteamMasterPassword($value){
self::SetValue("live_stream_master_password", $value, false); self::setValue("live_stream_master_password", $value, false);
} }
public static function GetLiveSteamMasterPassword(){ public static function GetLiveSteamMasterPassword(){
return self::GetValue("live_stream_master_password"); return self::getValue("live_stream_master_password");
} }
public static function SetSourceStatus($sourcename, $status){ public static function SetSourceStatus($sourcename, $status){
self::SetValue($sourcename, $status, false); self::setValue($sourcename, $status, false);
} }
public static function GetSourceStatus($sourcename){ public static function GetSourceStatus($sourcename){
$value = self::GetValue($sourcename); $value = self::getValue($sourcename);
if($value == null || $value == "false"){ if($value == null || $value == "false"){
return false; return false;
}else{ }else{
@ -823,11 +823,11 @@ class Application_Model_Preference
} }
public static function SetSourceSwitchStatus($sourcename, $status){ public static function SetSourceSwitchStatus($sourcename, $status){
self::SetValue($sourcename."_switch", $status, false); self::setValue($sourcename."_switch", $status, false);
} }
public static function GetSourceSwitchStatus($sourcename){ public static function GetSourceSwitchStatus($sourcename){
$value = self::GetValue($sourcename."_switch"); $value = self::getValue($sourcename."_switch");
if($value == null || $value == "off"){ if($value == null || $value == "off"){
return "off"; return "off";
}else{ }else{
@ -836,61 +836,61 @@ class Application_Model_Preference
} }
public static function SetMasterDJSourceConnectionURL($value){ public static function SetMasterDJSourceConnectionURL($value){
self::SetValue("master_dj_source_connection_url", $value, false); self::setValue("master_dj_source_connection_url", $value, false);
} }
public static function GetMasterDJSourceConnectionURL(){ public static function GetMasterDJSourceConnectionURL(){
return self::GetValue("master_dj_source_connection_url"); return self::getValue("master_dj_source_connection_url");
} }
public static function SetLiveDJSourceConnectionURL($value){ public static function SetLiveDJSourceConnectionURL($value){
self::SetValue("live_dj_source_connection_url", $value, false); self::setValue("live_dj_source_connection_url", $value, false);
} }
public static function GetLiveDJSourceConnectionURL(){ public static function GetLiveDJSourceConnectionURL(){
return self::GetValue("live_dj_source_connection_url"); return self::getValue("live_dj_source_connection_url");
} }
/* Source Connection URL override status starts */ /* Source Connection URL override status starts */
public static function GetLiveDjConnectionUrlOverride(){ public static function GetLiveDjConnectionUrlOverride(){
return self::GetValue("live_dj_connection_url_override"); return self::getValue("live_dj_connection_url_override");
} }
public static function SetLiveDjConnectionUrlOverride($value){ public static function SetLiveDjConnectionUrlOverride($value){
self::SetValue("live_dj_connection_url_override", $value, false); self::setValue("live_dj_connection_url_override", $value, false);
} }
public static function GetMasterDjConnectionUrlOverride(){ public static function GetMasterDjConnectionUrlOverride(){
return self::GetValue("master_dj_connection_url_override"); return self::getValue("master_dj_connection_url_override");
} }
public static function SetMasterDjConnectionUrlOverride($value){ public static function SetMasterDjConnectionUrlOverride($value){
self::SetValue("master_dj_connection_url_override", $value, false); self::setValue("master_dj_connection_url_override", $value, false);
} }
/* Source Connection URL override status ends */ /* Source Connection URL override status ends */
public static function SetAutoTransition($value){ public static function SetAutoTransition($value){
self::SetValue("auto_transition", $value, false); self::setValue("auto_transition", $value, false);
} }
public static function GetAutoTransition(){ public static function GetAutoTransition(){
return self::GetValue("auto_transition"); return self::getValue("auto_transition");
} }
public static function SetAutoSwitch($value){ public static function SetAutoSwitch($value){
self::SetValue("auto_switch", $value, false); self::setValue("auto_switch", $value, false);
} }
public static function GetAutoSwitch(){ public static function GetAutoSwitch(){
return self::GetValue("auto_switch"); return self::getValue("auto_switch");
} }
public static function SetEnableSystemEmail($upload) { public static function SetEnableSystemEmail($upload) {
self::SetValue("enable_system_email", $upload); self::setValue("enable_system_email", $upload);
} }
public static function GetEnableSystemEmail() { public static function GetEnableSystemEmail() {
$v = self::GetValue("enable_system_email"); $v = self::getValue("enable_system_email");
if ($v === "") { if ($v === "") {
return 0; return 0;
@ -900,51 +900,51 @@ class Application_Model_Preference
} }
public static function SetSystemEmail($value) { public static function SetSystemEmail($value) {
self::SetValue("system_email", $value, false); self::setValue("system_email", $value, false);
} }
public static function GetSystemEmail() { public static function GetSystemEmail() {
return self::GetValue("system_email"); return self::getValue("system_email");
} }
public static function SetMailServerConfigured($value) { public static function SetMailServerConfigured($value) {
self::SetValue("mail_server_configured", $value, false); self::setValue("mail_server_configured", $value, false);
} }
public static function GetMailServerConfigured() { public static function GetMailServerConfigured() {
return self::GetValue("mail_server_configured"); return self::getValue("mail_server_configured");
} }
public static function SetMailServer($value) { public static function SetMailServer($value) {
self::SetValue("mail_server", $value, false); self::setValue("mail_server", $value, false);
} }
public static function GetMailServer() { public static function GetMailServer() {
return self::GetValue("mail_server"); return self::getValue("mail_server");
} }
public static function SetMailServerEmailAddress($value) { public static function SetMailServerEmailAddress($value) {
self::SetValue("mail_server_email_address", $value, false); self::setValue("mail_server_email_address", $value, false);
} }
public static function GetMailServerEmailAddress() { public static function GetMailServerEmailAddress() {
return self::GetValue("mail_server_email_address"); return self::getValue("mail_server_email_address");
} }
public static function SetMailServerPassword($value) { public static function SetMailServerPassword($value) {
self::SetValue("mail_server_password", $value, false); self::setValue("mail_server_password", $value, false);
} }
public static function GetMailServerPassword() { public static function GetMailServerPassword() {
return self::GetValue("mail_server_password"); return self::getValue("mail_server_password");
} }
public static function SetMailServerPort($value) { public static function SetMailServerPort($value) {
self::SetValue("mail_server_port", $value, false); self::setValue("mail_server_port", $value, false);
} }
public static function GetMailServerPort() { public static function GetMailServerPort() {
return self::GetValue("mail_server_port"); return self::getValue("mail_server_port");
} }
/* User specific preferences end */ /* User specific preferences end */

View File

@ -32,7 +32,7 @@ class Application_Model_Scheduler {
$this->nowDT = DateTime::createFromFormat("U", time(), new DateTimeZone("UTC")); $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) { public function setCheckUserPermissions($value) {

View File

@ -303,8 +303,6 @@ class Application_Model_Show {
." AND starts > TIMESTAMP '$timestamp'" ." AND starts > TIMESTAMP '$timestamp'"
." AND show_id = $showId"; ." AND show_id = $showId";
//Logging::log($sql);
$con->exec($sql); $con->exec($sql);
} }
@ -1733,7 +1731,8 @@ class Application_Model_Show {
$timeNow = $date->getUtcTimestamp(); $timeNow = $date->getUtcTimestamp();
} }
//TODO, returning starts + ends twice (once with an alias). Unify this after the 2.0 release. --Martin //TODO, returning starts + ends twice (once with an alias). Unify this after the 2.0 release. --Martin
$sql = "SELECT si.starts as start_timestamp, si.ends as end_timestamp, s.name, s.id, si.id as instance_id, si.record, s.url, starts, ends" $sql = "SELECT si.starts as start_timestamp, si.ends as end_timestamp, s.name,"
." s.id, si.id as instance_id, si.record, s.url, starts, ends"
." FROM $CC_CONFIG[showInstances] si, $CC_CONFIG[showTable] s" ." FROM $CC_CONFIG[showInstances] si, $CC_CONFIG[showTable] s"
." WHERE si.show_id = s.id" ." WHERE si.show_id = s.id"
." AND si.starts <= TIMESTAMP '$timeNow'" ." AND si.starts <= TIMESTAMP '$timeNow'"
@ -1746,14 +1745,16 @@ class Application_Model_Show {
} }
/** /**
* Gets the current show, previous and next with an 2day window from the given timeNow, so timeNow-2days and timeNow+2days. * Gets the current show, previous and next with an 2day window from
* the given timeNow, so timeNow-2days and timeNow+2days.
*/ */
public static function getPrevCurrentNext($p_timeNow) public static function getPrevCurrentNext($p_timeNow)
{ {
global $CC_CONFIG; global $CC_CONFIG;
$con = Propel::getConnection(); $con = Propel::getConnection();
//TODO, returning starts + ends twice (once with an alias). Unify this after the 2.0 release. --Martin //TODO, returning starts + ends twice (once with an alias). Unify this after the 2.0 release. --Martin
$sql = "SELECT si.starts as start_timestamp, si.ends as end_timestamp, s.name, s.id, si.id as instance_id, si.record, s.url, starts, ends" $sql = "SELECT si.starts as start_timestamp, si.ends as end_timestamp, s.name,"
." s.id, si.id as instance_id, si.record, s.url, starts, ends"
." FROM $CC_CONFIG[showInstances] si, $CC_CONFIG[showTable] s" ." FROM $CC_CONFIG[showInstances] si, $CC_CONFIG[showTable] s"
." WHERE si.show_id = s.id" ." WHERE si.show_id = s.id"
." AND si.starts > TIMESTAMP '$p_timeNow' - INTERVAL '2 days'" ." AND si.starts > TIMESTAMP '$p_timeNow' - INTERVAL '2 days'"
@ -1772,7 +1773,8 @@ class Application_Model_Show {
for ($i = 0; $i < $numberOfRows; ++$i) { for ($i = 0; $i < $numberOfRows; ++$i) {
//Find the show that is within the current time. //Find the show that is within the current time.
if ((strtotime($rows[$i]['starts']) <= $timeNowAsMillis) && (strtotime($rows[$i]['ends']) > $timeNowAsMillis)){ if ((strtotime($rows[$i]['starts']) <= $timeNowAsMillis)
&& (strtotime($rows[$i]['ends']) > $timeNowAsMillis)) {
if ($i-1 >= 0) { if ($i-1 >= 0) {
$results['previousShow'][0] = array( $results['previousShow'][0] = array(
"id"=>$rows[$i-1]['id'], "id"=>$rows[$i-1]['id'],
@ -1801,7 +1803,6 @@ class Application_Model_Show {
"ends"=>$rows[$i+1]['ends'], "ends"=>$rows[$i+1]['ends'],
"record"=>$rows[$i+1]['record'], "record"=>$rows[$i+1]['record'],
"type"=>"show"); "type"=>"show");
} }
break; break;
} }
@ -1855,7 +1856,7 @@ class Application_Model_Show {
* @param String $timeEnd - interval end time (in UTC) * @param String $timeEnd - interval end time (in UTC)
* @return array - the next $limit number of shows within the time interval * @return array - the next $limit number of shows within the time interval
*/ */
public static function GetNextShows($timeStart, $limit = "0", $timeEnd = "") public static function getNextShows($timeStart, $limit = "0", $timeEnd = "")
{ {
global $CC_CONFIG; global $CC_CONFIG;
$con = Propel::getConnection(); $con = Propel::getConnection();
@ -1893,7 +1894,8 @@ class Application_Model_Show {
* @param type $rows arrays of arrays containing database query result * @param type $rows arrays of arrays containing database query result
* @param type $columnsToConvert array of column names to convert * @param type $columnsToConvert array of column names to convert
*/ */
public static function ConvertToLocalTimeZone(&$rows, $columnsToConvert) { public static function convertToLocalTimeZone(&$rows, $columnsToConvert)
{
$timezone = date_default_timezone_get(); $timezone = date_default_timezone_get();
if (!is_array($rows)) { if (!is_array($rows)) {
@ -1906,7 +1908,8 @@ class Application_Model_Show {
} }
} }
public static function GetMaxLengths() { public static function getMaxLengths()
{
global $CC_CONFIG; global $CC_CONFIG;
$con = Propel::getConnection(); $con = Propel::getConnection();

View File

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

View File

@ -1,7 +1,7 @@
<?php <?php
class Application_Model_StreamSetting { class Application_Model_StreamSetting {
public static function SetValue($key, $value, $type) public static function setValue($key, $value, $type)
{ {
global $CC_CONFIG; global $CC_CONFIG;
$con = Propel::getConnection(); $con = Propel::getConnection();
@ -27,7 +27,7 @@ class Application_Model_StreamSetting {
return $con->exec($sql); return $con->exec($sql);
} }
public static function GetValue($key) public static function getValue($key)
{ {
global $CC_CONFIG; global $CC_CONFIG;
$con = Propel::getConnection(); $con = Propel::getConnection();
@ -37,14 +37,14 @@ class Application_Model_StreamSetting {
." WHERE keyname = '$key'"; ." WHERE keyname = '$key'";
$result = $con->query($sql)->fetchColumn(0); $result = $con->query($sql)->fetchColumn(0);
if ($result == 0) if ($result == 0) {
return ""; return "";
else { } else {
$sql = "SELECT value FROM cc_stream_setting" $sql = "SELECT value FROM cc_stream_setting"
." WHERE keyname = '$key'"; ." WHERE keyname = '$key'";
$result = $con->query($sql)->fetchColumn(0); $result = $con->query($sql)->fetchColumn(0);
return ($result !== false) ? $result : NULL; return ($result !== false) ? $result : null;
} }
} }
@ -130,16 +130,24 @@ class Application_Model_StreamSetting {
} }
if (!isset($exists["master_live_stream_port"])) { if (!isset($exists["master_live_stream_port"])) {
$rows[] = (array("keyname" =>"master_live_stream_port", "value"=>self::GetMasterLiveSteamPort(), "type"=>"integer")); $rows[] = array("keyname" =>"master_live_stream_port",
"value"=>self::getMasterLiveStreamPort(),
"type"=>"integer");
} }
if (!isset($exists["master_live_stream_mp"])) { if (!isset($exists["master_live_stream_mp"])) {
$rows[] = (array("keyname" =>"master_live_stream_mp", "value"=>self::GetMasterLiveSteamMountPoint(), "type"=>"string")); $rows[] = array("keyname" =>"master_live_stream_mp",
"value"=>self::getMasterLiveStreamMountPoint(),
"type"=>"string");
} }
if (!isset($exists["dj_live_stream_port"])) { if (!isset($exists["dj_live_stream_port"])) {
$rows[] = (array("keyname" =>"dj_live_stream_port", "value"=>self::GetDJLiveSteamPort(), "type"=>"integer")); $rows[] = array("keyname" =>"dj_live_stream_port",
"value"=>self::getDjLiveStreamPort(),
"type"=>"integer");
} }
if (!isset($exists["dj_live_stream_mp"])) { if (!isset($exists["dj_live_stream_mp"])) {
$rows[] = (array("keyname" =>"dj_live_stream_mp", "value"=>self::GetDJLiveSteamMountPoint(), "type"=>"string")); $rows[] = array("keyname" =>"dj_live_stream_mp",
"value"=>self::getDjLiveStreamMountPoint(),
"type"=>"string");
} }
return $rows; return $rows;
} }
@ -233,7 +241,7 @@ class Application_Model_StreamSetting {
." WHERE keyname = '$keyname'"; ." WHERE keyname = '$keyname'";
$result = $con->query($sql)->fetchColumn(0); $result = $con->query($sql)->fetchColumn(0);
return ($result !== false) ? $result : NULL; return ($result !== false) ? $result : null;
} }
public static function getStreamEnabled($stream_id) public static function getStreamEnabled($stream_id)
@ -264,7 +272,8 @@ class Application_Model_StreamSetting {
$enabled_stream = self::getEnabledStreamIds(); $enabled_stream = self::getEnabledStreamIds();
foreach ($enabled_stream as $stream) { foreach ($enabled_stream as $stream) {
$keys = "'".$stream."_output', "."'".$stream."_type', "."'".$stream."_bitrate', "."'".$stream."_host'"; $keys = "'".$stream."_output', "."'".$stream."_type', "."'"
.$stream."_bitrate', "."'".$stream."_host'";
$sql = "SELECT keyname, value FROM cc_stream_setting" $sql = "SELECT keyname, value FROM cc_stream_setting"
." WHERE keyname IN ($keys)"; ." WHERE keyname IN ($keys)";
@ -280,35 +289,43 @@ class Application_Model_StreamSetting {
return $out; return $out;
} }
public static function SetMasterLiveSteamPort($value){ public static function setMasterLiveStreamPort($value)
self::SetValue("master_live_stream_port", $value, "integer"); {
self::setValue("master_live_stream_port", $value, "integer");
} }
public static function GetMasterLiveSteamPort(){ public static function getMasterLiveStreamPort()
return self::GetValue("master_live_stream_port"); {
return self::getValue("master_live_stream_port");
} }
public static function SetMasterLiveSteamMountPoint($value){ public static function setMasterLiveStreamMountPoint($value)
self::SetValue("master_live_stream_mp", $value, "string"); {
self::setValue("master_live_stream_mp", $value, "string");
} }
public static function GetMasterLiveSteamMountPoint(){ public static function getMasterLiveStreamMountPoint()
return self::GetValue("master_live_stream_mp"); {
return self::getValue("master_live_stream_mp");
} }
public static function SetDJLiveSteamPort($value){ public static function setDjLiveStreamPort($value)
self::SetValue("dj_live_stream_port", $value, "integer"); {
self::setValue("dj_live_stream_port", $value, "integer");
} }
public static function GetDJLiveSteamPort(){ public static function getDjLiveStreamPort()
return self::GetValue("dj_live_stream_port"); {
return self::getValue("dj_live_stream_port");
} }
public static function SetDJLiveSteamMountPoint($value){ public static function setDjLiveStreamMountPoint($value)
self::SetValue("dj_live_stream_mp", $value, "string"); {
self::setValue("dj_live_stream_mp", $value, "string");
} }
public static function GetDJLiveSteamMountPoint(){ public static function getDjLiveStreamMountPoint()
return self::GetValue("dj_live_stream_mp"); {
return self::getValue("dj_live_stream_mp");
} }
} }

View File

@ -18,102 +18,6 @@ class Application_Model_Subjects {
/* ======================================================= public methods */ /* ======================================================= public methods */
/**
* Check login and password
*
* @param string $login
* @param string $pass
* optional
* @return boolean|int|PEAR_Error
*/
public static function Authenticate($login, $pass='')
{
global $CC_CONFIG;
$con = Propel::getConnection();
$cpass = md5($pass);
$sql = "SELECT id FROM ".$CC_CONFIG['subjTable']
." WHERE login='$login' AND pass='$cpass' AND type='U'"
." LIMIT 1";
$query = $con->query($sql)->fetchColumn(0);
return $query;
}
/**
* Change user password
*
* @param string $login
* @param string $oldpass
* old password (optional for 'superuser mode')
* @param string $pass
* optional
* @param boolean $passenc
* optional, password already encrypted if true
* @return boolean|PEAR_Error
*/
public static function Passwd($login, $oldpass=null, $pass='', $passenc=FALSE)
{
global $CC_CONFIG;
$con = Propel::getConnection();
if (!$passenc) {
$cpass = md5($pass);
} else {
$cpass = $pass;
}
if (!is_null($oldpass)) {
$oldcpass = md5($oldpass);
$oldpCond = "AND pass='$oldcpass'";
} else {
$oldpCond = '';
}
$sql = "UPDATE ".$CC_CONFIG['subjTable']." SET pass='$cpass'"
." WHERE login='$login' $oldpCond AND type='U'";
$con->exec($sql);
return TRUE;
}
/* --------------------------------------------------------------- groups */
/* --------------------------------------------------------- info methods */
/**
* Get subject id from login
*
* @param string $login
* @return int|false
*/
public static function GetSubjId($login)
{
global $CC_CONFIG;
$con = Propel::getConnection();
$sql = "SELECT id FROM ".$CC_CONFIG['subjTable']
." WHERE login='$login'";
$query = $con->query($sql)->fetchColumn(0);
return ($query !== false) ? $query : NULL;
}
/**
* Return true if uid is direct member of gid
*
* @param int $uid
* local user id
* @param int $gid
* local group id
* @return boolean
*/
public static function IsMemberOf($uid, $gid)
{
global $CC_CONFIG;
$con = Propel::getConnection();
$sql = "SELECT count(*) as cnt"
." FROM ".$CC_CONFIG['smembTable']
." WHERE uid='$uid' AND gid='$gid'";
$res = $con->query($sql)->fetchColumn(0);
return (intval($res) > 0);
}
public static function increaseLoginAttempts($login) public static function increaseLoginAttempts($login)
{ {
global $CC_CONFIG; global $CC_CONFIG;
@ -131,7 +35,7 @@ class Application_Model_Subjects {
$sql = "UPDATE ".$CC_CONFIG['subjTable']." SET login_attempts = '0'" $sql = "UPDATE ".$CC_CONFIG['subjTable']." SET login_attempts = '0'"
." WHERE login='$login'"; ." WHERE login='$login'";
$res = $con->exec($sql); $res = $con->exec($sql);
return TRUE; return true;
} }
public static function getLoginAttempts($login) public static function getLoginAttempts($login)

View File

@ -13,8 +13,7 @@ class Application_Model_User {
{ {
if (empty($userId)) { if (empty($userId)) {
$this->_userInstance = $this->createUser(); $this->_userInstance = $this->createUser();
} } else {
else {
$this->_userInstance = CcSubjsQuery::create()->findPK($userId); $this->_userInstance = CcSubjsQuery::create()->findPK($userId);
if (is_null($this->_userInstance)) { if (is_null($this->_userInstance)) {
@ -23,41 +22,47 @@ class Application_Model_User {
} }
} }
public function getId() { public function getId()
{
return $this->_userInstance->getDbId(); return $this->_userInstance->getDbId();
} }
public function isGuest() { public function isGuest()
{
return $this->getType() == UTYPE_GUEST; return $this->getType() == UTYPE_GUEST;
} }
public function isHost($showId) { public function isHost($showId)
{
return $this->isUserType(UTYPE_HOST, $showId); return $this->isUserType(UTYPE_HOST, $showId);
} }
public function isPM() { public function isPM()
{
return $this->isUserType(UTYPE_PROGRAM_MANAGER); return $this->isUserType(UTYPE_PROGRAM_MANAGER);
} }
public function isAdmin() { public function isAdmin()
{
return $this->isUserType(UTYPE_ADMIN); return $this->isUserType(UTYPE_ADMIN);
} }
public function canSchedule($p_showId) { public function canSchedule($p_showId)
{
$type = $this->getType(); $type = $this->getType();
$result = false; $result = false;
if ($type === UTYPE_ADMIN || if ($type === UTYPE_ADMIN ||
$type === UTYPE_PROGRAM_MANAGER || $type === UTYPE_PROGRAM_MANAGER ||
CcShowHostsQuery::create()->filterByDbShow($p_showId)->filterByDbHost($this->getId())->count() > 0 ) CcShowHostsQuery::create()->filterByDbShow($p_showId)->filterByDbHost($this->getId())->count() > 0) {
{
$result = true; $result = true;
} }
return $result; return $result;
} }
public function isUserType($type, $showId=''){ public function isUserType($type, $showId='')
{
if (is_array($type)) { if (is_array($type)) {
$result = false; $result = false;
foreach ($type as $t) { foreach ($type as $t) {
@ -67,7 +72,9 @@ class Application_Model_User {
break; break;
case UTYPE_HOST: case UTYPE_HOST:
$userId = $this->_userInstance->getDbId(); $userId = $this->_userInstance->getDbId();
$result = CcShowHostsQuery::create()->filterByDbShow($showId)->filterByDbHost($userId)->count() > 0; $result = CcShowHostsQuery::create()
->filterByDbShow($showId)
->filterByDbHost($userId)->count() > 0;
break; break;
case UTYPE_PROGRAM_MANAGER: case UTYPE_PROGRAM_MANAGER:
$result = $this->_userInstance->getDbType() === 'P'; $result = $this->_userInstance->getDbType() === 'P';
@ -90,112 +97,134 @@ class Application_Model_User {
} }
} }
public function setLogin($login){ public function setLogin($login)
{
$user = $this->_userInstance; $user = $this->_userInstance;
$user->setDbLogin($login); $user->setDbLogin($login);
} }
public function setPassword($password){ public function setPassword($password)
{
$user = $this->_userInstance; $user = $this->_userInstance;
$user->setDbPass(md5($password)); $user->setDbPass(md5($password));
} }
public function setFirstName($firstName){ public function setFirstName($firstName)
{
$user = $this->_userInstance; $user = $this->_userInstance;
$user->setDbFirstName($firstName); $user->setDbFirstName($firstName);
} }
public function setLastName($lastName){ public function setLastName($lastName)
{
$user = $this->_userInstance; $user = $this->_userInstance;
$user->setDbLastName($lastName); $user->setDbLastName($lastName);
} }
public function setType($type){ public function setType($type)
{
$user = $this->_userInstance; $user = $this->_userInstance;
$user->setDbType($type); $user->setDbType($type);
} }
public function setEmail($email){ public function setEmail($email)
{
$user = $this->_userInstance; $user = $this->_userInstance;
$user->setDbEmail(strtolower($email)); $user->setDbEmail(strtolower($email));
} }
public function setCellPhone($cellPhone){ public function setCellPhone($cellPhone)
{
$user = $this->_userInstance; $user = $this->_userInstance;
$user->setDbCellPhone($cellPhone); $user->setDbCellPhone($cellPhone);
} }
public function setSkype($skype){ public function setSkype($skype)
{
$user = $this->_userInstance; $user = $this->_userInstance;
$user->setDbSkypeContact($skype); $user->setDbSkypeContact($skype);
} }
public function setJabber($jabber){ public function setJabber($jabber)
{
$user = $this->_userInstance; $user = $this->_userInstance;
$user->setDbJabberContact($jabber); $user->setDbJabberContact($jabber);
} }
public function getLogin(){ public function getLogin()
{
$user = $this->_userInstance; $user = $this->_userInstance;
return $user->getDbLogin(); return $user->getDbLogin();
} }
public function getPassword(){ public function getPassword()
{
$user = $this->_userInstance; $user = $this->_userInstance;
return $user->getDbPass(); return $user->getDbPass();
} }
public function getFirstName(){ public function getFirstName()
{
$user = $this->_userInstance; $user = $this->_userInstance;
return $user->getDbFirstName(); return $user->getDbFirstName();
} }
public function getLastName(){ public function getLastName()
{
$user = $this->_userInstance; $user = $this->_userInstance;
return $user->getDbLastName(); return $user->getDbLastName();
} }
public function getType(){ public function getType()
{
$user = $this->_userInstance; $user = $this->_userInstance;
return $user->getDbType(); return $user->getDbType();
} }
public function getEmail(){ public function getEmail()
{
$user = $this->_userInstance; $user = $this->_userInstance;
return $user->getDbEmail(); return $user->getDbEmail();
} }
public function getCellPhone(){ public function getCellPhone()
{
$user = $this->_userInstance; $user = $this->_userInstance;
return $user->getDbCellPhone(); return $user->getDbCellPhone();
} }
public function getSkype(){ public function getSkype()
{
$user = $this->_userInstance; $user = $this->_userInstance;
return $user->getDbSkypeContact(); return $user->getDbSkypeContact();
} }
public function getJabber(){ public function getJabber()
{
$user = $this->_userInstance; $user = $this->_userInstance;
return $user->getDbJabberContact(); return $user->getDbJabberContact();
} }
public function save(){ public function save()
{
$this->_userInstance->save(); $this->_userInstance->save();
} }
public function delete(){ public function delete()
if (!$this->_userInstance->isDeleted()) {
if (!$this->_userInstance->isDeleted()) {
$this->_userInstance->delete(); $this->_userInstance->delete();
} }
}
private function createUser() { private function createUser()
{
$user = new CcSubjs(); $user = new CcSubjs();
return $user; return $user;
} }
public static function getUsers($type, $search=NULL) public static function getUsers($type, $search=null)
{ {
$con = Propel::getConnection(); $con = Propel::getConnection();
@ -207,8 +236,7 @@ class Application_Model_User {
$type[$i] = "type = '{$type[$i]}'"; $type[$i] = "type = '{$type[$i]}'";
} }
$sql_type = join(" OR ", $type); $sql_type = join(" OR ", $type);
} } else {
else {
$sql_type = "type = {$type}"; $sql_type = "type = {$type}";
} }
@ -225,22 +253,21 @@ class Application_Model_User {
return $con->query($sql)->fetchAll();; return $con->query($sql)->fetchAll();;
} }
public static function getUserCount($type=NULL){ public static function getUserCount($type=null)
{
$con = Propel::getConnection(); $con = Propel::getConnection();
$sql = ''; $sql = '';
$sql_gen = "SELECT count(*) AS cnt FROM cc_subjs "; $sql_gen = "SELECT count(*) AS cnt FROM cc_subjs ";
if (!isset($type)) { if (!isset($type)) {
$sql = $sql_gen; $sql = $sql_gen;
} } else {
else{
if (is_array($type)) { if (is_array($type)) {
for ($i=0; $i<count($type); $i++) { for ($i=0; $i<count($type); $i++) {
$type[$i] = "type = '{$type[$i]}'"; $type[$i] = "type = '{$type[$i]}'";
} }
$sql_type = join(" OR ", $type); $sql_type = join(" OR ", $type);
} } else {
else {
$sql_type = "type = {$type}"; $sql_type = "type = {$type}";
} }
@ -248,14 +275,16 @@ class Application_Model_User {
} }
$query = $con->query($sql)->fetchColumn(0); $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); 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);
@ -284,7 +313,8 @@ class Application_Model_User {
return $res; return $res;
} }
public static function getUserData($id){ public static function getUserData($id)
{
$con = Propel::getConnection(); $con = Propel::getConnection();
$sql = "SELECT login, first_name, last_name, type, id, email, cell_phone, skype_contact, jabber_contact" $sql = "SELECT login, first_name, last_name, type, id, email, cell_phone, skype_contact, jabber_contact"
@ -294,16 +324,8 @@ class Application_Model_User {
return $con->query($sql)->fetch(); return $con->query($sql)->fetch();
} }
public static function GetUserID($login){ public static function getCurrentUser()
$user = CcSubjsQuery::create()->findOneByDbLogin($login); {
if (is_null($user)){
return -1;
} else {
return $user->getDbId();
}
}
public static function GetCurrentUser() {
$userinfo = Zend_Auth::getInstance()->getStorage()->read(); $userinfo = Zend_Auth::getInstance()->getStorage()->read();
if (is_null($userinfo)) { if (is_null($userinfo)) {

View File

@ -51,7 +51,7 @@ class MediaMonitorCommon:
def is_audio_file(self, filename): def is_audio_file(self, filename):
info = filename.split(".") info = filename.split(".")
if len(info) < 2: return false # handle cases like filename="mp3" if len(info) < 2: return False # handle cases like filename="mp3"
return info[-1].lower() in self.supported_file_formats return info[-1].lower() in self.supported_file_formats
#check if file is readable by "nobody" #check if file is readable by "nobody"

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