CC-4090: Make code style PSR compliant - part 4
-controllers dir
This commit is contained in:
parent
b2327472e8
commit
699a49a103
|
@ -378,7 +378,6 @@ class ApiController extends Zend_Controller_Action
|
|||
Application_Common_DateHelper::ConvertToUtcDateTime($end_timestamp, date_default_timezone_get()),
|
||||
$excludeInstance = null, $onlyRecord = true);
|
||||
|
||||
|
||||
$this->view->is_recording = false;
|
||||
$this->view->server_timezone = Application_Model_Preference::GetTimezone();
|
||||
|
||||
|
@ -482,35 +481,32 @@ class ApiController extends Zend_Controller_Action
|
|||
$file->setFileExistsFlag(true);
|
||||
$file->setMetadata($md);
|
||||
}
|
||||
}
|
||||
else if ($mode == "modify") {
|
||||
} elseif ($mode == "modify") {
|
||||
$filepath = $md['MDATA_KEY_FILEPATH'];
|
||||
$file = Application_Model_StoredFile::RecallByFilepath($filepath);
|
||||
|
||||
//File is not in database anymore.
|
||||
if (is_null($file)) {
|
||||
$return_hash['error'] = "File does not exist in Airtime.";
|
||||
|
||||
return $return_hash;
|
||||
}
|
||||
//Updating a metadata change.
|
||||
else {
|
||||
$file->setMetadata($md);
|
||||
}
|
||||
}
|
||||
else if ($mode == "moved") {
|
||||
} elseif ($mode == "moved") {
|
||||
$md5 = $md['MDATA_KEY_MD5'];
|
||||
$file = Application_Model_StoredFile::RecallByMd5($md5);
|
||||
|
||||
if (is_null($file)) {
|
||||
return "File doesn't exist in Airtime.";
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$filepath = $md['MDATA_KEY_FILEPATH'];
|
||||
//$filepath = str_replace("\\", "", $filepath);
|
||||
$file->setFilePath($filepath);
|
||||
}
|
||||
}
|
||||
else if ($mode == "delete") {
|
||||
} elseif ($mode == "delete") {
|
||||
$filepath = $md['MDATA_KEY_FILEPATH'];
|
||||
//$filepath = str_replace("\\", "", $filepath);
|
||||
$file = Application_Model_StoredFile::RecallByFilepath($filepath);
|
||||
|
@ -519,24 +515,25 @@ class ApiController extends Zend_Controller_Action
|
|||
$return_hash['error'] = "File doesn't exist in Airtime.";
|
||||
Logging::warn("Attempt to delete file that doesn't exist.
|
||||
Path: '$filepath'");
|
||||
|
||||
return $return_hash;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$file->deleteByMediaMonitor();
|
||||
}
|
||||
}
|
||||
else if ($mode == "delete_dir") {
|
||||
} elseif ($mode == "delete_dir") {
|
||||
$filepath = $md['MDATA_KEY_FILEPATH'];
|
||||
//$filepath = str_replace("\\", "", $filepath);
|
||||
$files = Application_Model_StoredFile::RecallByPartialFilepath($filepath);
|
||||
|
||||
foreach($files as $file){
|
||||
foreach ($files as $file) {
|
||||
$file->deleteByMediaMonitor();
|
||||
}
|
||||
$return_hash['success'] = 1;
|
||||
|
||||
return $return_hash;
|
||||
}
|
||||
$return_hash['fileid'] = $file->getId();
|
||||
|
||||
return $return_hash;
|
||||
}
|
||||
|
||||
|
@ -554,19 +551,19 @@ class ApiController extends Zend_Controller_Action
|
|||
foreach ($request->getParams() as $k => $raw_json) {
|
||||
// Valid requests must start with mdXXX where XXX represents at
|
||||
// least 1 digit
|
||||
if( !preg_match('/^md\d+$/', $k) ) { continue; }
|
||||
if ( !preg_match('/^md\d+$/', $k) ) { continue; }
|
||||
$info_json = json_decode($raw_json, $assoc = true);
|
||||
$recorded = $info_json["is_record"];
|
||||
unset( $info_json["is_record"] );
|
||||
// Log invalid requests
|
||||
if( !array_key_exists('mode', $info_json) ) {
|
||||
if ( !array_key_exists('mode', $info_json) ) {
|
||||
Logging::info("Received bad request(key=$k), no 'mode' parameter. Bad request is:");
|
||||
Logging::info( $info_json );
|
||||
array_push( $responses, array(
|
||||
'error' => "Bad request. no 'mode' parameter passed.",
|
||||
'key' => $k));
|
||||
continue;
|
||||
} elseif ( !in_array($info_json['mode'], $valid_modes) ) {
|
||||
} elseif ( !in_array($info_json['mode'], $valid_modes) ) {
|
||||
// A request still has a chance of being invalid even if it
|
||||
// exists but it's validated by $valid_modes array
|
||||
$mode = $info_json['mode'];
|
||||
|
@ -631,7 +628,7 @@ class ApiController extends Zend_Controller_Action
|
|||
$file->setMetadata($md);
|
||||
}
|
||||
}
|
||||
} else if ($mode == "modify") {
|
||||
} elseif ($mode == "modify") {
|
||||
$filepath = $md['MDATA_KEY_FILEPATH'];
|
||||
//$filepath = str_replace("\\", "", $filepath);
|
||||
$file = Application_Model_StoredFile::RecallByFilepath($filepath);
|
||||
|
@ -645,7 +642,7 @@ class ApiController extends Zend_Controller_Action
|
|||
//Updating a metadata change.
|
||||
$file->setMetadata($md);
|
||||
}
|
||||
} else if ($mode == "moved") {
|
||||
} elseif ($mode == "moved") {
|
||||
$md5 = $md['MDATA_KEY_MD5'];
|
||||
$file = Application_Model_StoredFile::RecallByMd5($md5);
|
||||
|
||||
|
@ -658,7 +655,7 @@ class ApiController extends Zend_Controller_Action
|
|||
//$filepath = str_replace("\\", "", $filepath);
|
||||
$file->setFilePath($filepath);
|
||||
}
|
||||
} else if ($mode == "delete") {
|
||||
} elseif ($mode == "delete") {
|
||||
$filepath = $md['MDATA_KEY_FILEPATH'];
|
||||
//$filepath = str_replace("\\", "", $filepath);
|
||||
$file = Application_Model_StoredFile::RecallByFilepath($filepath);
|
||||
|
@ -670,7 +667,7 @@ class ApiController extends Zend_Controller_Action
|
|||
} else {
|
||||
$file->deleteByMediaMonitor();
|
||||
}
|
||||
} else if ($mode == "delete_dir") {
|
||||
} elseif ($mode == "delete_dir") {
|
||||
$filepath = $md['MDATA_KEY_FILEPATH'];
|
||||
//$filepath = str_replace("\\", "", $filepath);
|
||||
$files = Application_Model_StoredFile::RecallByPartialFilepath($filepath);
|
||||
|
@ -833,7 +830,7 @@ class ApiController extends Zend_Controller_Action
|
|||
// if mount path itself was watched
|
||||
if ($dirPath == $ad) {
|
||||
Application_Model_MusicDir::addWatchedDir($dirPath, false);
|
||||
} else if (substr($dirPath, 0, strlen($ad)) === $ad && $dir->getExistsFlag() == false) {
|
||||
} elseif (substr($dirPath, 0, strlen($ad)) === $ad && $dir->getExistsFlag() == false) {
|
||||
// if dir contains any dir in removed_list( if watched dir resides on new mounted path )
|
||||
Application_Model_MusicDir::addWatchedDir($dirPath, false);
|
||||
} elseif (substr($ad, 0, strlen($dirPath)) === $dirPath) {
|
||||
|
|
|
@ -29,7 +29,6 @@ class AudiopreviewController extends Zend_Controller_Action
|
|||
$request = $this->getRequest();
|
||||
$baseUrl = $request->getBaseUrl();
|
||||
|
||||
|
||||
$baseDir = dirname($_SERVER['SCRIPT_FILENAME']);
|
||||
|
||||
$this->view->headScript()->appendFile(
|
||||
|
@ -53,7 +52,7 @@ class AudiopreviewController extends Zend_Controller_Action
|
|||
$uri = "/api/get-media/file/".$audioFileID;
|
||||
$media = Application_Model_StoredFile::Recall($audioFileID);
|
||||
$mime = $media->getPropelOrm()->getDbMime();
|
||||
} else if ($type == "stream") {
|
||||
} elseif ($type == "stream") {
|
||||
$webstream = CcWebstreamQuery::create()->findPk($audioFileID);
|
||||
$uri = $webstream->getDbUrl();
|
||||
$mime = $webstream->getDbMime();
|
||||
|
@ -208,7 +207,7 @@ class AudiopreviewController extends Zend_Controller_Action
|
|||
//TODO: use MIME type for this
|
||||
if (strtolower($fileExtension) === 'mp3') {
|
||||
$elementMap['element_mp3'] = $track['item_id'];
|
||||
} else if (strtolower($fileExtension) === 'ogg') {
|
||||
} elseif (strtolower($fileExtension) === 'ogg') {
|
||||
$elementMap['element_oga'] = $track['item_id'];
|
||||
} else {
|
||||
//the media was neither mp3 or ogg
|
||||
|
@ -219,6 +218,7 @@ class AudiopreviewController extends Zend_Controller_Action
|
|||
} else {
|
||||
$elementMap['uri'] = $track['path'];
|
||||
}
|
||||
|
||||
return $elementMap;
|
||||
}
|
||||
|
||||
|
|
|
@ -143,7 +143,6 @@ class LibraryController extends Zend_Controller_Action
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
public function contextMenuAction()
|
||||
{
|
||||
$id = $this->_getParam('id');
|
||||
|
@ -172,13 +171,13 @@ class LibraryController extends Zend_Controller_Action
|
|||
// if the user is not admin or pm, check the creator and see if this person owns the playlist or Block
|
||||
if ($obj_sess->type == 'playlist') {
|
||||
$obj = new Application_Model_Playlist($obj_sess->id);
|
||||
} else if ($obj_sess->type == 'block') {
|
||||
} elseif ($obj_sess->type == 'block') {
|
||||
$obj = new Application_Model_Block($obj_sess->id);
|
||||
}
|
||||
if ($isAdminOrPM || $obj->getCreatorId() == $user->getId()) {
|
||||
if ($obj_sess->type === "playlist") {
|
||||
$menu["pl_add"] = array("name"=> "Add to Playlist", "icon" => "add-playlist", "icon" => "copy");
|
||||
} else if ($obj_sess->type === "block") {
|
||||
} elseif ($obj_sess->type === "block") {
|
||||
$menu["pl_add"] = array("name"=> "Add to Smart Block", "icon" => "add-playlist", "icon" => "copy");
|
||||
}
|
||||
}
|
||||
|
@ -190,10 +189,10 @@ class LibraryController extends Zend_Controller_Action
|
|||
|
||||
$url = $file->getRelativeFileUrl($baseUrl).'/download/true';
|
||||
$menu["download"] = array("name" => "Download", "icon" => "download", "url" => $url);
|
||||
} else if ($type === "playlist" || $type === "block") {
|
||||
} elseif ($type === "playlist" || $type === "block") {
|
||||
if ($type === 'playlist') {
|
||||
$obj = new Application_Model_Playlist($id);
|
||||
} else if ($type === 'block') {
|
||||
} elseif ($type === 'block') {
|
||||
$obj = new Application_Model_Block($id);
|
||||
if (!$obj->isStatic()) {
|
||||
unset($menu["play"]);
|
||||
|
@ -213,7 +212,7 @@ class LibraryController extends Zend_Controller_Action
|
|||
if ($isAdminOrPM || $obj->getCreatorId() == $user->getId()) {
|
||||
$menu["del"] = array("name"=> "Delete", "icon" => "delete", "url" => "/library/delete");
|
||||
}
|
||||
} else if ($type == "stream") {
|
||||
} elseif ($type == "stream") {
|
||||
|
||||
$webstream = CcWebstreamQuery::create()->findPK($id);
|
||||
$obj = new Application_Model_Webstream($webstream);
|
||||
|
@ -296,10 +295,10 @@ class LibraryController extends Zend_Controller_Action
|
|||
Application_Model_Playlist::deletePlaylists($playlists, $user->getId());
|
||||
} catch (PlaylistNoPermissionException $e) {
|
||||
$this->view->message = "You don't have permission to delete selected items.";
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
try {
|
||||
Application_Model_Block::deleteBlocks($blocks, $user->getId());
|
||||
} catch (Exception $e) {
|
||||
|
@ -425,7 +424,7 @@ class LibraryController extends Zend_Controller_Action
|
|||
|
||||
$this->view->md = $md;
|
||||
|
||||
} else if ($type == "playlist") {
|
||||
} elseif ($type == "playlist") {
|
||||
|
||||
$file = new Application_Model_Playlist($id);
|
||||
$this->view->type = $type;
|
||||
|
@ -436,7 +435,7 @@ class LibraryController extends Zend_Controller_Action
|
|||
|
||||
$this->view->md = $md;
|
||||
$this->view->contents = $file->getContents();
|
||||
} else if ($type == "block") {
|
||||
} elseif ($type == "block") {
|
||||
$block = new Application_Model_Block($id);
|
||||
$this->view->type = $type;
|
||||
$md = $block->getAllPLMetaData();
|
||||
|
@ -453,7 +452,7 @@ class LibraryController extends Zend_Controller_Action
|
|||
$this->view->contents = $block->getCriteria();
|
||||
}
|
||||
$this->view->block = $block;
|
||||
} else if ($type == "stream") {
|
||||
} elseif ($type == "stream") {
|
||||
$webstream = CcWebstreamQuery::create()->findPK($id);
|
||||
$ws = new Application_Model_Webstream($webstream);
|
||||
|
||||
|
|
|
@ -48,7 +48,6 @@ class PlaylistController extends Zend_Controller_Action
|
|||
return $obj;
|
||||
}
|
||||
|
||||
|
||||
private function createUpdateResponse($obj)
|
||||
{
|
||||
$formatter = new LengthFormatter($obj->getLength());
|
||||
|
@ -205,7 +204,6 @@ class PlaylistController extends Zend_Controller_Action
|
|||
$userInfo = Zend_Auth::getInstance()->getStorage()->read();
|
||||
$user = new Application_Model_User($userInfo->id);
|
||||
|
||||
|
||||
$obj_sess = new Zend_Session_Namespace(UI_PLAYLISTCONTROLLER_OBJ_SESSNAME);
|
||||
|
||||
try {
|
||||
|
@ -255,7 +253,7 @@ class PlaylistController extends Zend_Controller_Action
|
|||
}
|
||||
}
|
||||
$obj->addAudioClips($ids, $afterItem, $addType);
|
||||
} else if ($obj->isStatic()) {
|
||||
} elseif ($obj->isStatic()) {
|
||||
// if the dest is a block object
|
||||
//check if any items are playlists
|
||||
foreach ($ids as $id) {
|
||||
|
@ -274,17 +272,13 @@ class PlaylistController extends Zend_Controller_Action
|
|||
$this->playlistOutdated($e);
|
||||
} catch (PlaylistNotFoundException $e) {
|
||||
$this->playlistNotFound($obj_type);
|
||||
}
|
||||
catch (WrongTypeToBlockException $e) {
|
||||
} catch (WrongTypeToBlockException $e) {
|
||||
$this->wrongTypeToBlock($obj);
|
||||
}
|
||||
catch (WrongTypeToPlaylistException $e) {
|
||||
} catch (WrongTypeToPlaylistException $e) {
|
||||
$this->wrongTypeToPlaylist($obj);
|
||||
}
|
||||
catch (BlockDynamicException $e) {
|
||||
} catch (BlockDynamicException $e) {
|
||||
$this->blockDynamic($obj);
|
||||
}
|
||||
catch (Exception $e) {
|
||||
} catch (Exception $e) {
|
||||
$this->playlistUnknownError($e);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,6 +18,7 @@ class WebstreamController extends Zend_Controller_Action
|
|||
$userInfo = Zend_Auth::getInstance()->getStorage()->read();
|
||||
if (!$this->isAuthorized(-1)) {
|
||||
header("Status: 401 Not Authorized");
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -63,7 +64,6 @@ class WebstreamController extends Zend_Controller_Action
|
|||
throw new Exception("Missing parameter 'id'");
|
||||
}
|
||||
|
||||
|
||||
$webstream = CcWebstreamQuery::create()->findPK($id);
|
||||
if ($webstream) {
|
||||
Application_Model_Library::changePlaylist($id, "stream");
|
||||
|
@ -80,6 +80,7 @@ class WebstreamController extends Zend_Controller_Action
|
|||
|
||||
if (!$this->isAuthorized($id)) {
|
||||
header("Status: 401 Not Authorized");
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -135,6 +136,7 @@ class WebstreamController extends Zend_Controller_Action
|
|||
|
||||
if (!$this->isAuthorized($id)) {
|
||||
header("Status: 401 Not Authorized");
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue