diff --git a/airtime_mvc/application/controllers/ApiController.php b/airtime_mvc/application/controllers/ApiController.php index 033369802..a0918d60d 100644 --- a/airtime_mvc/application/controllers/ApiController.php +++ b/airtime_mvc/application/controllers/ApiController.php @@ -415,8 +415,9 @@ class ApiController extends Zend_Controller_Action $this->uploadRecordedActionParam($show_instance_id, $file_id); } - // The paramterized version of the uploadRecordedAction controller. We want this controller's action - // to be invokable from other controllers instead being of only through http + // The paramterized version of the uploadRecordedAction controller. + // We want this controller's action to be invokable from other + // controllers instead being of only through http public function uploadRecordedActionParam($show_instance_id, $file_id) { $showCanceled = false; @@ -430,10 +431,10 @@ class ApiController extends Zend_Controller_Action } catch (Exception $e) { //we've reached here probably because the show was - //cancelled, and therefore the show instance does not - //exist anymore (ShowInstance constructor threw this error). - //We've done all we can do (upload the file and put it in - //the library), now lets just return. + //cancelled, and therefore the show instance does not exist + //anymore (ShowInstance constructor threw this error). We've + //done all we can do (upload the file and put it in the + //library), now lets just return. $showCanceled = true; } @@ -444,7 +445,7 @@ class ApiController extends Zend_Controller_Action if (!$showCanceled && Application_Model_Preference::GetAutoUploadRecordedShowToSoundcloud()) { $id = $file->getId(); - $res = exec("/usr/lib/airtime/utils/soundcloud-uploader $id > /dev/null &"); + Application_Model_Soundcloud::uploadSoundcloud($id); } } diff --git a/airtime_mvc/application/controllers/DashboardController.php b/airtime_mvc/application/controllers/DashboardController.php index 327321383..9609a1ef8 100644 --- a/airtime_mvc/application/controllers/DashboardController.php +++ b/airtime_mvc/application/controllers/DashboardController.php @@ -25,9 +25,7 @@ class DashboardController extends Zend_Controller_Action $user = new Application_Model_User($userInfo->id); $show = Application_Model_Show::getCurrentShow(); - - $show_id = isset($show['id'])?$show['id']:0; - + $show_id = isset($show[0]['id'])?$show[0]['id']:0; $source_connected = Application_Model_Preference::GetSourceStatus($sourcename); if ($user->canSchedule($show_id) && $source_connected) { diff --git a/airtime_mvc/application/controllers/LibraryController.php b/airtime_mvc/application/controllers/LibraryController.php index fa6a92e68..2d8f06b71 100644 --- a/airtime_mvc/application/controllers/LibraryController.php +++ b/airtime_mvc/application/controllers/LibraryController.php @@ -469,7 +469,7 @@ class LibraryController extends Zend_Controller_Action public function uploadFileSoundcloudAction() { $id = $this->_getParam('id'); - $res = exec("/usr/lib/airtime/utils/soundcloud-uploader $id > /dev/null &"); + Application_Model_Soundcloud::uploadSoundcloud($id); // we should die with ui info die(); } diff --git a/airtime_mvc/application/controllers/ScheduleController.php b/airtime_mvc/application/controllers/ScheduleController.php index f65ce1332..c2fe93dbb 100644 --- a/airtime_mvc/application/controllers/ScheduleController.php +++ b/airtime_mvc/application/controllers/ScheduleController.php @@ -217,7 +217,8 @@ class ScheduleController extends Zend_Controller_Action $file = $show_inst->getRecordedFile(); $id = $file->getId(); - $res = exec("/usr/lib/airtime/utils/soundcloud-uploader $id > /dev/null &"); + //$res = exec("/usr/lib/airtime/utils/soundcloud-uploader $id > /dev/null &"); + Application_Model_Soundcloud::uploadSoundcloud($id); // we should die with ui info die(); } diff --git a/airtime_mvc/application/models/Soundcloud.php b/airtime_mvc/application/models/Soundcloud.php index 7e2b74d57..4dd99444a 100644 --- a/airtime_mvc/application/models/Soundcloud.php +++ b/airtime_mvc/application/models/Soundcloud.php @@ -52,7 +52,6 @@ class Application_Model_Soundcloud //YYYY-MM-DD-HH-mm-SS $release = explode("-", $release); - $track_data['track[release_year]'] = $release[0]; $track_data['track[release_month]'] = $release[1]; $track_data['track[release_day]'] = $release[2]; @@ -87,6 +86,13 @@ class Application_Model_Soundcloud throw new NoSoundCloundToken(); } } + + public static function uploadSoundcloud($id) + { + $cmd = "/usr/lib/airtime/utils/soundcloud-uploader $id > /dev/null &"; + Logging::info("Uploading soundcloud with command: $cmd"); + exec($cmd); + } } class NoSoundCloundToken extends Exception {} diff --git a/airtime_mvc/application/models/User.php b/airtime_mvc/application/models/User.php index d07552472..1d9d94e07 100644 --- a/airtime_mvc/application/models/User.php +++ b/airtime_mvc/application/models/User.php @@ -35,7 +35,6 @@ class Application_Model_User public function isHostOfShow($showId) { $userId = $this->_userInstance->getDbId(); - return CcShowHostsQuery::create() ->filterByDbShow($showId) ->filterByDbHost($userId)->count() > 0; @@ -63,10 +62,9 @@ class Application_Model_User if ($type === UTYPE_ADMIN || $type === UTYPE_PROGRAM_MANAGER || - CcShowHostsQuery::create()->filterByDbShow($p_showId)->filterByDbHost($this->getId())->count() > 0) { + self::isHostOfShow($p_showId)) { $result = true; } - return $result; } @@ -210,7 +208,7 @@ class Application_Model_User $this->_userInstance->delete(); } } - public function getOwnedFiles() + public function getOwnedFiles() { $user = $this->_userInstance; // do we need a find call at the end here? diff --git a/utils/soundcloud-uploader.php b/utils/soundcloud-uploader.php index ea6826aab..2660d32e2 100644 --- a/utils/soundcloud-uploader.php +++ b/utils/soundcloud-uploader.php @@ -33,6 +33,7 @@ set_include_path(implode(PATH_SEPARATOR, array( require_once($CC_CONFIG['phpDir'].'/application/models/StoredFile.php'); require_once($CC_CONFIG['phpDir'].'/application/models/Preference.php'); require_once($CC_CONFIG['phpDir'].'/application/models/MusicDir.php'); +require_once($CC_CONFIG['phpDir'].'/application/common/OsPath.php'); set_include_path($CC_CONFIG['phpDir'].'/library' . PATH_SEPARATOR . get_include_path()); require_once($CC_CONFIG['phpDir'].'/application/models/Soundcloud.php');