CC-4895: Remove all json die() statements from code

This commit is contained in:
denise 2013-01-31 14:06:45 -05:00
parent 3bc2876f27
commit d4e89df94e
8 changed files with 34 additions and 34 deletions

View File

@ -411,7 +411,7 @@ class ApiController extends Zend_Controller_Action
$result = Application_Model_StoredFile::copyFileToStor($upload_dir, $fileName, $tempFileName); $result = Application_Model_StoredFile::copyFileToStor($upload_dir, $fileName, $tempFileName);
if (!is_null($result)) { 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; $response['key'] = $k;
array_push($responses, $response); array_push($responses, $response);
} }
die( json_encode($responses) ); $this->_helper->json->sendJson( json_encode($responses) );
} }
public function listAllFilesAction() public function listAllFilesAction()

View File

@ -507,7 +507,7 @@ class LibraryController extends Zend_Controller_Action
$id = $this->_getParam('id'); $id = $this->_getParam('id');
Application_Model_Soundcloud::uploadSoundcloud($id); Application_Model_Soundcloud::uploadSoundcloud($id);
// we should die with ui info // we should die with ui info
die(); $this->_helper->json->sendJson(null);
} }
public function getUploadToSoundcloudStatusAction() public function getUploadToSoundcloudStatusAction()

View File

@ -76,6 +76,6 @@ class ListenerstatController extends Zend_Controller_Action
$endsDT = DateTime::createFromFormat("U", $ends_epoch, new DateTimeZone("UTC")); $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); $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));
} }
} }

View File

@ -132,7 +132,7 @@ class PlaylistController extends Zend_Controller_Action
if (!$p_isJson) { if (!$p_isJson) {
$this->createFullResponse(null); $this->createFullResponse(null);
} else { } 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; $result["modified"] = $this->view->modified;
die(json_encode($result)); $this->_helper->json->sendJson(json_encode($result));
} }
public function smartBlockGenerateAction() public function smartBlockGenerateAction()
@ -504,7 +504,7 @@ class PlaylistController extends Zend_Controller_Action
$form->startForm($params['obj_id']); $form->startForm($params['obj_id']);
if ($form->isValid($params)) { if ($form->isValid($params)) {
$result = $bl->generateSmartBlock($params['data']); $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 { } else {
$this->view->obj = $bl; $this->view->obj = $bl;
$this->view->id = $bl->getId(); $this->view->id = $bl->getId();
@ -512,7 +512,7 @@ class PlaylistController extends Zend_Controller_Action
$viewPath = 'playlist/smart-block.phtml'; $viewPath = 'playlist/smart-block.phtml';
$result['html'] = $this->view->render($viewPath); $result['html'] = $this->view->render($viewPath);
$result['result'] = 1; $result['result'] = 1;
die(json_encode($result)); $this->_helper->json->sendJson(json_encode($result));
} }
} catch (BlockNotFoundException $e) { } catch (BlockNotFoundException $e) {
$this->playlistNotFound('block', true); $this->playlistNotFound('block', true);
@ -531,9 +531,9 @@ class PlaylistController extends Zend_Controller_Action
$result = $bl->shuffleSmartBlock(); $result = $bl->shuffleSmartBlock();
if ($result['result'] == 0) { 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 { } else {
die(json_encode($result)); $this->_helper->json->sendJson(json_encode($result));
} }
} catch (BlockNotFoundException $e) { } catch (BlockNotFoundException $e) {
$this->playlistNotFound('block', true); $this->playlistNotFound('block', true);
@ -551,9 +551,9 @@ class PlaylistController extends Zend_Controller_Action
$result = $pl->shuffle(); $result = $pl->shuffle();
if ($result['result'] == 0) { 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 { } else {
die(json_encode($result)); $this->_helper->json->sendJson(json_encode($result));
} }
} catch (PlaylistNotFoundException $e) { } catch (PlaylistNotFoundException $e) {
$this->playlistNotFound('block', true); $this->playlistNotFound('block', true);
@ -574,7 +574,7 @@ class PlaylistController extends Zend_Controller_Action
$out = $bl->getCriteria(); $out = $bl->getCriteria();
$out['isStatic'] = false; $out['isStatic'] = false;
} }
die(json_encode($out)); $this->_helper->json->sendJson(json_encode($out));
} }
} }
class WrongTypeToBlockException extends Exception {} class WrongTypeToBlockException extends Exception {}

View File

@ -32,7 +32,7 @@ class PluploadController extends Zend_Controller_Action
$tempFilePath = Application_Model_StoredFile::uploadFile($upload_dir); $tempFilePath = Application_Model_StoredFile::uploadFile($upload_dir);
$tempFileName = basename($tempFilePath); $tempFileName = basename($tempFilePath);
die('{"jsonrpc" : "2.0", "tempfilepath" : "'.$tempFileName.'" }'); $this->_helper->json->sendJson(array("jsonrpc" => "2.0", "tempfilepath" => $tempFileName));
} }
public function copyfileAction() public function copyfileAction()
@ -43,8 +43,8 @@ class PluploadController extends Zend_Controller_Action
$result = Application_Model_StoredFile::copyFileToStor($upload_dir, $result = Application_Model_StoredFile::copyFileToStor($upload_dir,
$filename, $tempname); $filename, $tempname);
if (!is_null($result)) 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"}');
} }
} }

View File

@ -70,10 +70,10 @@ class PreferenceController extends Zend_Controller_Action
$this->view->statusMsg = "<div class='success'>". _("Preferences updated.")."</div>"; $this->view->statusMsg = "<div class='success'>". _("Preferences updated.")."</div>";
$this->view->form = $form; $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 { } else {
$this->view->form = $form; $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; $this->view->form = $form;
@ -322,7 +322,7 @@ class PreferenceController extends Zend_Controller_Action
$this->view->form = $form; $this->view->form = $form;
$this->view->num_stream = $num_of_stream; $this->view->num_stream = $num_of_stream;
$this->view->statusMsg = "<div class='success'>"._("Stream Setting Updated.")."</div>"; $this->view->statusMsg = "<div class='success'>"._("Stream Setting Updated.")."</div>";
die(json_encode(array( $this->_helper->json->sendJson(json_encode(array(
"valid"=>"true", "valid"=>"true",
"html"=>$this->view->render('preference/stream-setting.phtml'), "html"=>$this->view->render('preference/stream-setting.phtml'),
"s1_set_admin_pass"=>$s1_set_admin_pass, "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->enable_stream_conf = Application_Model_Preference::GetEnableStreamConf();
$this->view->form = $form; $this->view->form = $form;
$this->view->num_stream = $num_of_stream; $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); ksort($result);
//returns format serverBrowse is looking for. //returns format serverBrowse is looking for.
die(json_encode($result)); $this->_helper->json->sendJson($result);
} }
public function changeStorDirectoryAction() public function changeStorDirectoryAction()
@ -420,7 +420,7 @@ class PreferenceController extends Zend_Controller_Action
Application_Model_RabbitMq::SendMessageToMediaMonitor('rescan_watch', $data); Application_Model_RabbitMq::SendMessageToMediaMonitor('rescan_watch', $data);
Logging::info("Unhiding all files belonging to:: $dir_path"); Logging::info("Unhiding all files belonging to:: $dir_path");
$dir->unhideFiles(); $dir->unhideFiles();
die(); # Get rid of this ugliness later $this->_helper->json->sendJson(null);
} }
public function removeWatchDirectoryAction() public function removeWatchDirectoryAction()
@ -440,7 +440,7 @@ class PreferenceController extends Zend_Controller_Action
if (Application_Model_Preference::GetImportTimestamp()+10 > $now) { if (Application_Model_Preference::GetImportTimestamp()+10 > $now) {
$res = true; $res = true;
} }
die(json_encode($res)); $this->_helper->json->sendJson(json_encode($res));
} }
public function getLiquidsoapStatusAction() public function getLiquidsoapStatusAction()
@ -455,7 +455,7 @@ class PreferenceController extends Zend_Controller_Action
} }
$out[] = array("id"=>$i, "status"=>$status); $out[] = array("id"=>$i, "status"=>$status);
} }
die(json_encode($out)); $this->_helper->json->sendJson(json_encode($out));
} }
public function setSourceConnectionUrlAction() public function setSourceConnectionUrlAction()
@ -473,7 +473,7 @@ class PreferenceController extends Zend_Controller_Action
Application_Model_Preference::SetLiveDjConnectionUrlOverride($override); Application_Model_Preference::SetLiveDjConnectionUrlOverride($override);
} }
die(); $this->_helper->json->sendJson(null);
} }
public function getAdminPasswordStatusAction() public function getAdminPasswordStatusAction()
@ -486,6 +486,6 @@ class PreferenceController extends Zend_Controller_Action
$out["s".$i] = true; $out["s".$i] = true;
} }
} }
die(json_encode($out)); $this->_helper->json->sendJson(json_encode($out));
} }
} }

View File

@ -218,7 +218,7 @@ class ScheduleController extends Zend_Controller_Action
$id = $file->getId(); $id = $file->getId();
Application_Model_Soundcloud::uploadSoundcloud($id); Application_Model_Soundcloud::uploadSoundcloud($id);
// we should die with ui info // we should die with ui info
die(); $this->_helper->json->sendJson(null);
} }
public function makeContextMenuAction() public function makeContextMenuAction()
@ -897,7 +897,7 @@ class ScheduleController extends Zend_Controller_Action
'title' => _('Download')); 'title' => _('Download'));
//returns format jjmenu is looking for. //returns format jjmenu is looking for.
die(json_encode($menu)); $this->_helper->json->sendJson(json_encode($menu));
} }
/** /**

View File

@ -53,7 +53,7 @@ class UserController extends Zend_Controller_Action
&& $formData['user_id'] != 0) { && $formData['user_id'] != 0) {
$this->view->form = $form; $this->view->form = $form;
$this->view->successMessage = "<div class='errors'>"._("Specific action is not allowed in demo version!")."</div>"; $this->view->successMessage = "<div class='errors'>"._("Specific action is not allowed in demo version!")."</div>";
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)) { } elseif ($form->validateLogin($formData)) {
$user = new Application_Model_User($formData['user_id']); $user = new Application_Model_User($formData['user_id']);
if (empty($formData['user_id'])) { if (empty($formData['user_id'])) {
@ -89,14 +89,14 @@ class UserController extends Zend_Controller_Action
$this->view->successMessage = "<div class='success'>"._("User updated successfully!")."</div>"; $this->view->successMessage = "<div class='success'>"._("User updated successfully!")."</div>";
} }
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 { } else {
$this->view->form = $form; $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 { } else {
$this->view->form = $form; $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(); $post = $this->getRequest()->getPost();
$users = Application_Model_User::getUsersDataTablesInfo($post); $users = Application_Model_User::getUsersDataTablesInfo($post);
die(json_encode($users)); $this->_helper->json->sendJson($users);
} }
public function getUserDataAction() public function getUserDataAction()
@ -135,7 +135,7 @@ class UserController extends Zend_Controller_Action
&& $formData['cu_login'] == 'admin') { && $formData['cu_login'] == 'admin') {
$this->view->form = $form; $this->view->form = $form;
$this->view->successMessage = "<div class='errors'>"._("Specific action is not allowed in demo version!")."</div>"; $this->view->successMessage = "<div class='errors'>"._("Specific action is not allowed in demo version!")."</div>";
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) && } else if ($form->isValid($formData) &&
$form->validateLogin($formData['cu_login'], $formData['cu_user_id'])) { $form->validateLogin($formData['cu_login'], $formData['cu_user_id'])) {
$user = new Application_Model_User($formData['cu_user_id']); $user = new Application_Model_User($formData['cu_user_id']);