From d4e89df94e6e66a6f6cb61631713c710d3a3a0b1 Mon Sep 17 00:00:00 2001 From: denise Date: Thu, 31 Jan 2013 14:06:45 -0500 Subject: [PATCH] CC-4895: Remove all json die() statements from code --- .../application/controllers/ApiController.php | 4 ++-- .../controllers/LibraryController.php | 2 +- .../controllers/ListenerstatController.php | 2 +- .../controllers/PlaylistController.php | 18 ++++++++--------- .../controllers/PluploadController.php | 6 +++--- .../controllers/PreferenceController.php | 20 +++++++++---------- .../controllers/ScheduleController.php | 4 ++-- .../controllers/UserController.php | 12 +++++------ 8 files changed, 34 insertions(+), 34 deletions(-) diff --git a/airtime_mvc/application/controllers/ApiController.php b/airtime_mvc/application/controllers/ApiController.php index 6bbe480da..ffbae08aa 100644 --- a/airtime_mvc/application/controllers/ApiController.php +++ b/airtime_mvc/application/controllers/ApiController.php @@ -411,7 +411,7 @@ class ApiController extends Zend_Controller_Action $result = Application_Model_StoredFile::copyFileToStor($upload_dir, $fileName, $tempFileName); if (!is_null($result)) { - die('{"jsonrpc" : "2.0", "error" : {"code": '.$result['code'].', "message" : "'.$result['message'].'"}}'); + $this->_helper->json->sendJson('{"jsonrpc" : "2.0", "error" : {"code": '.$result['code'].', "message" : "'.$result['message'].'"}}'); } } @@ -600,7 +600,7 @@ class ApiController extends Zend_Controller_Action $response['key'] = $k; array_push($responses, $response); } - die( json_encode($responses) ); + $this->_helper->json->sendJson( json_encode($responses) ); } public function listAllFilesAction() diff --git a/airtime_mvc/application/controllers/LibraryController.php b/airtime_mvc/application/controllers/LibraryController.php index a180be814..2974d85a1 100644 --- a/airtime_mvc/application/controllers/LibraryController.php +++ b/airtime_mvc/application/controllers/LibraryController.php @@ -507,7 +507,7 @@ class LibraryController extends Zend_Controller_Action $id = $this->_getParam('id'); Application_Model_Soundcloud::uploadSoundcloud($id); // we should die with ui info - die(); + $this->_helper->json->sendJson(null); } public function getUploadToSoundcloudStatusAction() diff --git a/airtime_mvc/application/controllers/ListenerstatController.php b/airtime_mvc/application/controllers/ListenerstatController.php index 817f6ca11..f64ea8bfb 100644 --- a/airtime_mvc/application/controllers/ListenerstatController.php +++ b/airtime_mvc/application/controllers/ListenerstatController.php @@ -76,6 +76,6 @@ class ListenerstatController extends Zend_Controller_Action $endsDT = DateTime::createFromFormat("U", $ends_epoch, new DateTimeZone("UTC")); $data = Application_Model_ListenerStat::getDataPointsWithinRange($startsDT->format("Y-m-d H:i:s"), $endsDT->format("Y-m-d H:i:s"), $mountName); - die(json_encode($data)); + $this->_helper->json->sendJson(json_encode($data)); } } diff --git a/airtime_mvc/application/controllers/PlaylistController.php b/airtime_mvc/application/controllers/PlaylistController.php index 19c2756e7..789d4a904 100644 --- a/airtime_mvc/application/controllers/PlaylistController.php +++ b/airtime_mvc/application/controllers/PlaylistController.php @@ -132,7 +132,7 @@ class PlaylistController extends Zend_Controller_Action if (!$p_isJson) { $this->createFullResponse(null); } else { - die(json_encode(array("error"=>$this->view->error, "result"=>1, "html"=>$this->createFullResponse(null, $p_isJson)))); + $this->_helper->json->sendJson(json_encode(array("error"=>$this->view->error, "result"=>1, "html"=>$this->createFullResponse(null, $p_isJson)))); } } @@ -488,7 +488,7 @@ class PlaylistController extends Zend_Controller_Action } $result["modified"] = $this->view->modified; - die(json_encode($result)); + $this->_helper->json->sendJson(json_encode($result)); } public function smartBlockGenerateAction() @@ -504,7 +504,7 @@ class PlaylistController extends Zend_Controller_Action $form->startForm($params['obj_id']); if ($form->isValid($params)) { $result = $bl->generateSmartBlock($params['data']); - die(json_encode(array("result"=>0, "html"=>$this->createFullResponse($bl, true, true)))); + $this->_helper->json->sendJson(json_encode(array("result"=>0, "html"=>$this->createFullResponse($bl, true, true)))); } else { $this->view->obj = $bl; $this->view->id = $bl->getId(); @@ -512,7 +512,7 @@ class PlaylistController extends Zend_Controller_Action $viewPath = 'playlist/smart-block.phtml'; $result['html'] = $this->view->render($viewPath); $result['result'] = 1; - die(json_encode($result)); + $this->_helper->json->sendJson(json_encode($result)); } } catch (BlockNotFoundException $e) { $this->playlistNotFound('block', true); @@ -531,9 +531,9 @@ class PlaylistController extends Zend_Controller_Action $result = $bl->shuffleSmartBlock(); if ($result['result'] == 0) { - die(json_encode(array("result"=>0, "html"=>$this->createFullResponse($bl, true)))); + $this->_helper->json->sendJson(json_encode(array("result"=>0, "html"=>$this->createFullResponse($bl, true)))); } else { - die(json_encode($result)); + $this->_helper->json->sendJson(json_encode($result)); } } catch (BlockNotFoundException $e) { $this->playlistNotFound('block', true); @@ -551,9 +551,9 @@ class PlaylistController extends Zend_Controller_Action $result = $pl->shuffle(); if ($result['result'] == 0) { - die(json_encode(array("result"=>0, "html"=>$this->createFullResponse($pl, true)))); + $this->_helper->json->sendJson(json_encode(array("result"=>0, "html"=>$this->createFullResponse($pl, true)))); } else { - die(json_encode($result)); + $this->_helper->json->sendJson(json_encode($result)); } } catch (PlaylistNotFoundException $e) { $this->playlistNotFound('block', true); @@ -574,7 +574,7 @@ class PlaylistController extends Zend_Controller_Action $out = $bl->getCriteria(); $out['isStatic'] = false; } - die(json_encode($out)); + $this->_helper->json->sendJson(json_encode($out)); } } class WrongTypeToBlockException extends Exception {} diff --git a/airtime_mvc/application/controllers/PluploadController.php b/airtime_mvc/application/controllers/PluploadController.php index ed7403693..49b706644 100644 --- a/airtime_mvc/application/controllers/PluploadController.php +++ b/airtime_mvc/application/controllers/PluploadController.php @@ -32,7 +32,7 @@ class PluploadController extends Zend_Controller_Action $tempFilePath = Application_Model_StoredFile::uploadFile($upload_dir); $tempFileName = basename($tempFilePath); - die('{"jsonrpc" : "2.0", "tempfilepath" : "'.$tempFileName.'" }'); + $this->_helper->json->sendJson(array("jsonrpc" => "2.0", "tempfilepath" => $tempFileName)); } public function copyfileAction() @@ -43,8 +43,8 @@ class PluploadController extends Zend_Controller_Action $result = Application_Model_StoredFile::copyFileToStor($upload_dir, $filename, $tempname); if (!is_null($result)) - die('{"jsonrpc" : "2.0", "error" : '.json_encode($result).'}'); + $this->_helper->json->sendJson('{"jsonrpc" : "2.0", "error" : '.json_encode($result).'}'); - die('{"jsonrpc" : "2.0"}'); + $this->_helper->json->sendJson('{"jsonrpc" : "2.0"}'); } } diff --git a/airtime_mvc/application/controllers/PreferenceController.php b/airtime_mvc/application/controllers/PreferenceController.php index 269215783..af78f996a 100644 --- a/airtime_mvc/application/controllers/PreferenceController.php +++ b/airtime_mvc/application/controllers/PreferenceController.php @@ -70,10 +70,10 @@ class PreferenceController extends Zend_Controller_Action $this->view->statusMsg = "
". _("Preferences updated.")."
"; $this->view->form = $form; - die(json_encode(array("valid"=>"true", "html"=>$this->view->render('preference/index.phtml')))); + $this->_helper->json->sendJson(json_encode(array("valid"=>"true", "html"=>$this->view->render('preference/index.phtml')))); } else { $this->view->form = $form; - die(json_encode(array("valid"=>"false", "html"=>$this->view->render('preference/index.phtml')))); + $this->_helper->json->sendJson(json_encode(array("valid"=>"false", "html"=>$this->view->render('preference/index.phtml')))); } } $this->view->form = $form; @@ -322,7 +322,7 @@ class PreferenceController extends Zend_Controller_Action $this->view->form = $form; $this->view->num_stream = $num_of_stream; $this->view->statusMsg = "
"._("Stream Setting Updated.")."
"; - die(json_encode(array( + $this->_helper->json->sendJson(json_encode(array( "valid"=>"true", "html"=>$this->view->render('preference/stream-setting.phtml'), "s1_set_admin_pass"=>$s1_set_admin_pass, @@ -334,7 +334,7 @@ class PreferenceController extends Zend_Controller_Action $this->view->enable_stream_conf = Application_Model_Preference::GetEnableStreamConf(); $this->view->form = $form; $this->view->num_stream = $num_of_stream; - die(json_encode(array("valid"=>"false", "html"=>$this->view->render('preference/stream-setting.phtml')))); + $this->_helper->json->sendJson(json_encode(array("valid"=>"false", "html"=>$this->view->render('preference/stream-setting.phtml')))); } } @@ -378,7 +378,7 @@ class PreferenceController extends Zend_Controller_Action } ksort($result); //returns format serverBrowse is looking for. - die(json_encode($result)); + $this->_helper->json->sendJson($result); } public function changeStorDirectoryAction() @@ -420,7 +420,7 @@ class PreferenceController extends Zend_Controller_Action Application_Model_RabbitMq::SendMessageToMediaMonitor('rescan_watch', $data); Logging::info("Unhiding all files belonging to:: $dir_path"); $dir->unhideFiles(); - die(); # Get rid of this ugliness later + $this->_helper->json->sendJson(null); } public function removeWatchDirectoryAction() @@ -440,7 +440,7 @@ class PreferenceController extends Zend_Controller_Action if (Application_Model_Preference::GetImportTimestamp()+10 > $now) { $res = true; } - die(json_encode($res)); + $this->_helper->json->sendJson(json_encode($res)); } public function getLiquidsoapStatusAction() @@ -455,7 +455,7 @@ class PreferenceController extends Zend_Controller_Action } $out[] = array("id"=>$i, "status"=>$status); } - die(json_encode($out)); + $this->_helper->json->sendJson(json_encode($out)); } public function setSourceConnectionUrlAction() @@ -473,7 +473,7 @@ class PreferenceController extends Zend_Controller_Action Application_Model_Preference::SetLiveDjConnectionUrlOverride($override); } - die(); + $this->_helper->json->sendJson(null); } public function getAdminPasswordStatusAction() @@ -486,6 +486,6 @@ class PreferenceController extends Zend_Controller_Action $out["s".$i] = true; } } - die(json_encode($out)); + $this->_helper->json->sendJson(json_encode($out)); } } diff --git a/airtime_mvc/application/controllers/ScheduleController.php b/airtime_mvc/application/controllers/ScheduleController.php index 15dca0621..22257025d 100644 --- a/airtime_mvc/application/controllers/ScheduleController.php +++ b/airtime_mvc/application/controllers/ScheduleController.php @@ -218,7 +218,7 @@ class ScheduleController extends Zend_Controller_Action $id = $file->getId(); Application_Model_Soundcloud::uploadSoundcloud($id); // we should die with ui info - die(); + $this->_helper->json->sendJson(null); } public function makeContextMenuAction() @@ -897,7 +897,7 @@ class ScheduleController extends Zend_Controller_Action 'title' => _('Download')); //returns format jjmenu is looking for. - die(json_encode($menu)); + $this->_helper->json->sendJson(json_encode($menu)); } /** diff --git a/airtime_mvc/application/controllers/UserController.php b/airtime_mvc/application/controllers/UserController.php index 395156f97..14728512a 100644 --- a/airtime_mvc/application/controllers/UserController.php +++ b/airtime_mvc/application/controllers/UserController.php @@ -53,7 +53,7 @@ class UserController extends Zend_Controller_Action && $formData['user_id'] != 0) { $this->view->form = $form; $this->view->successMessage = "
"._("Specific action is not allowed in demo version!")."
"; - die(json_encode(array("valid"=>"false", "html"=>$this->view->render('user/add-user.phtml')))); + $this->_helper->json->sendJson(json_encode(array("valid"=>"false", "html"=>$this->view->render('user/add-user.phtml')))); } elseif ($form->validateLogin($formData)) { $user = new Application_Model_User($formData['user_id']); if (empty($formData['user_id'])) { @@ -89,14 +89,14 @@ class UserController extends Zend_Controller_Action $this->view->successMessage = "
"._("User updated successfully!")."
"; } - die(json_encode(array("valid"=>"true", "html"=>$this->view->render('user/add-user.phtml')))); + $this->_helper->json->sendJson(json_encode(array("valid"=>"true", "html"=>$this->view->render('user/add-user.phtml')))); } else { $this->view->form = $form; - die(json_encode(array("valid"=>"false", "html"=>$this->view->render('user/add-user.phtml')))); + $this->_helper->json->sendJson(json_encode(array("valid"=>"false", "html"=>$this->view->render('user/add-user.phtml')))); } } else { $this->view->form = $form; - die(json_encode(array("valid"=>"false", "html"=>$this->view->render('user/add-user.phtml')))); + $this->_helper->json->sendJson(json_encode(array("valid"=>"false", "html"=>$this->view->render('user/add-user.phtml')))); } } @@ -115,7 +115,7 @@ class UserController extends Zend_Controller_Action $post = $this->getRequest()->getPost(); $users = Application_Model_User::getUsersDataTablesInfo($post); - die(json_encode($users)); + $this->_helper->json->sendJson($users); } public function getUserDataAction() @@ -135,7 +135,7 @@ class UserController extends Zend_Controller_Action && $formData['cu_login'] == 'admin') { $this->view->form = $form; $this->view->successMessage = "
"._("Specific action is not allowed in demo version!")."
"; - die(json_encode(array("html"=>$this->view->render('user/edit-user.phtml')))); + $this->_helper->json->sendJson(json_encode(array("html"=>$this->view->render('user/edit-user.phtml')))); } else if ($form->isValid($formData) && $form->validateLogin($formData['cu_login'], $formData['cu_user_id'])) { $user = new Application_Model_User($formData['cu_user_id']);