From 05916a4d266136e05882da28a9b1bdf8990bd010 Mon Sep 17 00:00:00 2001 From: Rudi Grinberg Date: Fri, 14 Sep 2012 15:13:08 -0400 Subject: [PATCH 1/7] Code cleanup --- airtime_mvc/application/controllers/LibraryController.php | 4 ++-- airtime_mvc/application/models/Webstream.php | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/airtime_mvc/application/controllers/LibraryController.php b/airtime_mvc/application/controllers/LibraryController.php index d160b600a..e05747200 100644 --- a/airtime_mvc/application/controllers/LibraryController.php +++ b/airtime_mvc/application/controllers/LibraryController.php @@ -90,9 +90,9 @@ class LibraryController extends Zend_Controller_Action protected function playlistNotFound($p_type) { - $this->view->error = "{$p_type} not found"; + $this->view->error = "$p_type not found"; - Logging::info("{$p_type} not found"); + Logging::info("$p_type not found"); Application_Model_Library::changePlaylist(null, $p_type); $this->createFullResponse(null); } diff --git a/airtime_mvc/application/models/Webstream.php b/airtime_mvc/application/models/Webstream.php index 1c483e983..e3f08858a 100644 --- a/airtime_mvc/application/models/Webstream.php +++ b/airtime_mvc/application/models/Webstream.php @@ -78,11 +78,11 @@ class Application_Model_Webstream implements Application_Model_LibraryEditable $username = $subjs->getDbLogin(); return array( - "name" => $this->webstream->getDbName(), - "length" => $this->webstream->getDbLength(), + "name" => $this->webstream->getDbName(), + "length" => $this->webstream->getDbLength(), "description" => $this->webstream->getDbDescription(), - "login"=> $username, - "url" => $this->webstream->getDbUrl(), + "login" => $username, + "url" => $this->webstream->getDbUrl(), ); } From 4201176b3a34dec111c5002296c85e825d8a5e20 Mon Sep 17 00:00:00 2001 From: denise Date: Fri, 14 Sep 2012 15:59:34 -0400 Subject: [PATCH 2/7] -small UI change --- airtime_mvc/application/views/scripts/library/index.phtml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/airtime_mvc/application/views/scripts/library/index.phtml b/airtime_mvc/application/views/scripts/library/index.phtml index dcc7cde95..30c18e365 100644 --- a/airtime_mvc/application/views/scripts/library/index.phtml +++ b/airtime_mvc/application/views/scripts/library/index.phtml @@ -2,7 +2,7 @@ render('library/library.phtml') ?> -
+
type == 'block') { echo $this->render('playlist/smart-block.phtml'); } else if ($this->type == 'playlist') { From ba08355c388ad9f3c7eadbb97c5d1419237d1e9d Mon Sep 17 00:00:00 2001 From: Rudi Grinberg Date: Fri, 14 Sep 2012 16:16:52 -0400 Subject: [PATCH 3/7] quick fix --- airtime_mvc/application/controllers/UserController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/airtime_mvc/application/controllers/UserController.php b/airtime_mvc/application/controllers/UserController.php index 679a20b8e..1ee54fe39 100644 --- a/airtime_mvc/application/controllers/UserController.php +++ b/airtime_mvc/application/controllers/UserController.php @@ -109,7 +109,7 @@ class UserController extends Zend_Controller_Action # TODO : remove this. we only use default for now not to break the UI. if (!$files_action) { # set default action $files_action = "reassign_to"; - $valid_actions = + $delId = 1; } # only delete when valid action is selected for the owned files From b61abe24742a3f5121b800712d2efdfb5b5b1457 Mon Sep 17 00:00:00 2001 From: Rudi Grinberg Date: Fri, 14 Sep 2012 16:19:34 -0400 Subject: [PATCH 4/7] Hard coded mime for wav --- python_apps/media-monitor2/media/monitor/metadata.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python_apps/media-monitor2/media/monitor/metadata.py b/python_apps/media-monitor2/media/monitor/metadata.py index c935e0667..0fc278e9e 100644 --- a/python_apps/media-monitor2/media/monitor/metadata.py +++ b/python_apps/media-monitor2/media/monitor/metadata.py @@ -51,7 +51,7 @@ class FakeMutagen(dict): FakeInfo = namedtuple('FakeInfo','length bitrate') def __init__(self,path): self.path = path - self.mime = [] + self.mime = ['audio/wav'] self.info = FakeMutagen.FakeInfo(0.0, '') dict.__init__(self) def set_length(self,l): From 8ffaaaef2538b9260291133a824905b9f6052512 Mon Sep 17 00:00:00 2001 From: denise Date: Fri, 14 Sep 2012 16:38:26 -0400 Subject: [PATCH 5/7] -skip playable test if item is a smart block --- .../views/scripts/playlist/update.phtml | 6 +-- airtime_mvc/public/js/airtime/library/spl.js | 49 ++++++++++--------- 2 files changed, 29 insertions(+), 26 deletions(-) diff --git a/airtime_mvc/application/views/scripts/playlist/update.phtml b/airtime_mvc/application/views/scripts/playlist/update.phtml index 5c21e22f3..05f4e9e91 100644 --- a/airtime_mvc/application/views/scripts/playlist/update.phtml +++ b/airtime_mvc/application/views/scripts/playlist/update.phtml @@ -17,12 +17,12 @@ if ($item['type'] == 2) {
-
+
">
-
"> - +
"> +
diff --git a/airtime_mvc/public/js/airtime/library/spl.js b/airtime_mvc/public/js/airtime/library/spl.js index 07b5ad3d8..dc2f80c08 100644 --- a/airtime_mvc/public/js/airtime/library/spl.js +++ b/airtime_mvc/public/js/airtime/library/spl.js @@ -367,30 +367,33 @@ var AIRTIME = (function(AIRTIME){ //then the playlist element is greyed out mod.validatePlaylistElements = function(){ $.each($(".big_play"), function(index, value){ - var mime = $(value).attr("data-mime-type"); - if (isAudioSupported(mime)) { - $(value).bind("click", openAudioPreview); - } else { - $(value).attr("class", "big_play_disabled dark_class"); - $(value).qtip({ - content: 'Your browser does not support playing this file type: "'+ mime +'"', - show: 'mouseover', - hide: { - delay: 500, - fixed: true - }, - style: { - border: { - width: 0, - radius: 4 + if ($(value).attr('blockId') === undefined) { + var mime = $(value).attr("data-mime-type"); + console.log($(value)); + if (isAudioSupported(mime)) { + $(value).bind("click", openAudioPreview); + } else { + $(value).attr("class", "big_play_disabled dark_class"); + $(value).qtip({ + content: 'Your browser does not support playing this file type: "'+ mime +'"', + show: 'mouseover', + hide: { + delay: 500, + fixed: true }, - classes: "ui-tooltip-dark ui-tooltip-rounded" - }, - position: { - my: "left bottom", - at: "right center" - }, - }) + style: { + border: { + width: 0, + radius: 4 + }, + classes: "ui-tooltip-dark ui-tooltip-rounded" + }, + position: { + my: "left bottom", + at: "right center" + }, + }) + } } }); } From bf651a96aaa3d3382ae21ecab63eefe17efa57d7 Mon Sep 17 00:00:00 2001 From: Rudi Grinberg Date: Fri, 14 Sep 2012 16:47:55 -0400 Subject: [PATCH 6/7] cc-4431: Fixed isUserType --- .../controllers/WebstreamController.php | 34 +++++++++++-------- airtime_mvc/application/models/User.php | 31 +++-------------- 2 files changed, 24 insertions(+), 41 deletions(-) diff --git a/airtime_mvc/application/controllers/WebstreamController.php b/airtime_mvc/application/controllers/WebstreamController.php index 0521d58b1..9cea83a5e 100644 --- a/airtime_mvc/application/controllers/WebstreamController.php +++ b/airtime_mvc/application/controllers/WebstreamController.php @@ -17,8 +17,9 @@ class WebstreamController extends Zend_Controller_Action $userInfo = Zend_Auth::getInstance()->getStorage()->read(); if (!$this->isAuthorized(-1)) { + // TODO: this header call does not actually print any error message header("Status: 401 Not Authorized"); - + Logging::info("Ain't not Authorized"); return; } @@ -94,30 +95,35 @@ class WebstreamController extends Zend_Controller_Action } + /*TODO : make a user object be passed a parameter into this function so + that it does not have to be fetched multiple times.*/ public function isAuthorized($webstream_id) { - $hasPermission = false; $user = Application_Model_User::getCurrentUser(); if ($user->isUserType(array(UTYPE_ADMIN, UTYPE_PROGRAM_MANAGER))) { - $hasPermission = true; + return true; } - if (!$hasPermission && $user->isHost()) { + if ($user->isHost()) { + // not creating a webstream if ($webstream_id != -1) { $webstream = CcWebstreamQuery::create()->findPK($webstream_id); - //we are updating a playlist. Ensure that if the user is a host/dj, that he has the correct permission. + /*we are updating a playlist. Ensure that if the user is a + host/dj, that he has the correct permission.*/ $user = Application_Model_User::getCurrentUser(); - - if ($webstream->getDbCreatorId() == $user->getId()) { - $hasPermission = true; - } - } else { - //we are creating a new stream. Don't need to check whether the DJ/Host owns the stream - $hasPermission = true; + //only allow when webstream belongs to the DJ + Logging::info("Webstream id:".$webstream->getDbCreatorId()); + Logging::info("User id:".$user->getId()); + return $webstream->getDbCreatorId() == $user->getId(); } + /*we are creating a new stream. Don't need to check whether the + DJ/Host owns the stream*/ + return true; + } else { + Logging::info( $user ); } - - return $hasPermission; + Logging::info("what the fuck"); + return false; } public function saveAction() diff --git a/airtime_mvc/application/models/User.php b/airtime_mvc/application/models/User.php index 5f68cc240..57130cf9b 100644 --- a/airtime_mvc/application/models/User.php +++ b/airtime_mvc/application/models/User.php @@ -72,34 +72,11 @@ class Application_Model_User public function isUserType($type) { - if (is_array($type)) { - $result = false; - foreach ($type as $t) { - switch ($t) { - case UTYPE_ADMIN: - $result = $this->_userInstance->getDbType() === 'A'; - break; - case UTYPE_HOST: - $result = $this->_userInstance->getDbType() === 'H'; - break; - case UTYPE_PROGRAM_MANAGER: - $result = $this->_userInstance->getDbType() === 'P'; - break; - } - if ($result) { - return $result; - } - } - } else { - switch ($type) { - case UTYPE_ADMIN: - return $this->_userInstance->getDbType() === 'A'; - case UTYPE_HOST: - return $this->_userInstance->getDbId() === 'H'; - case UTYPE_PROGRAM_MANAGER: - return $this->_userInstance->getDbType() === 'P'; - } + if (!is_array($type)) { + $type = array($type); } + $real_type = $this->_userInstance->getDbType(); + return in_array($real_type, $type); } public function setLogin($login) From ec3e0a9b9f17e5552580ff8799f5f2d69b0b07bd Mon Sep 17 00:00:00 2001 From: Rudi Grinberg Date: Fri, 14 Sep 2012 16:50:28 -0400 Subject: [PATCH 7/7] Added todo --- airtime_mvc/application/models/User.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/airtime_mvc/application/models/User.php b/airtime_mvc/application/models/User.php index 57130cf9b..9fcf9f62c 100644 --- a/airtime_mvc/application/models/User.php +++ b/airtime_mvc/application/models/User.php @@ -70,6 +70,8 @@ class Application_Model_User return $result; } + // TODO : refactor code to only accept arrays for isUserType and + // simplify code even further public function isUserType($type) { if (!is_array($type)) {