From 408f8d4d9105412945a94fe43b6304451e3c043b Mon Sep 17 00:00:00 2001 From: zhujinyong Date: Tue, 22 Feb 2022 14:15:00 +0800 Subject: [PATCH] * Move die to return. --- module/productplan/model.php | 16 ++--- module/program/control.php | 36 +++++------ module/program/model.php | 6 +- module/programplan/model.php | 2 +- module/project/control.php | 62 +++++++++--------- module/project/model.php | 6 +- module/projectstory/control.php | 4 +- module/qa/control.php | 2 +- module/qa/model.php | 2 +- module/release/control.php | 32 +++++----- module/repo/control.php | 34 +++++----- module/repo/model.php | 4 +- module/report/control.php | 3 +- module/search/control.php | 14 ++-- module/search/model.php | 2 +- module/sonarqube/control.php | 4 +- module/sso/control.php | 36 +++++------ module/sso/model.php | 6 +- module/stage/control.php | 4 +- module/stakeholder/control.php | 22 +++---- module/story/control.php | 109 +++++++++++++++++--------------- module/story/model.php | 18 +++--- module/svn/control.php | 5 +- module/task/control.php | 87 ++++++++++++------------- module/task/model.php | 16 ++--- module/testcase/control.php | 99 +++++++++++++++-------------- module/testcase/model.php | 18 +++--- module/testreport/control.php | 44 ++++++------- module/testsuite/control.php | 18 +++--- module/todo/control.php | 65 +++++++++---------- module/todo/model.php | 8 +-- module/tree/control.php | 10 +-- module/tree/model.php | 6 +- module/tutorial/control.php | 12 ++-- module/upgrade/control.php | 32 +++++----- module/upgrade/model.php | 8 +-- module/user/control.php | 55 ++++++++-------- module/user/model.php | 46 +++++++------- module/webhook/control.php | 16 ++--- module/webhook/model.php | 2 +- 40 files changed, 489 insertions(+), 482 deletions(-) diff --git a/module/productplan/model.php b/module/productplan/model.php index 3a4202134b..5001a01933 100644 --- a/module/productplan/model.php +++ b/module/productplan/model.php @@ -626,8 +626,8 @@ class productplanModel extends model $plan->status = isset($data->status[$planID]) ? $data->status[$planID] : $oldPlans[$planID]->status; $plan->parent = $oldPlans[$planID]->parent; - if(empty($plan->title)) die(js::alter(sprintf($this->lang->productplan->errorNoTitle, $planID))); - if($plan->begin > $plan->end and !empty($plan->end)) die(js::alert(sprintf($this->lang->productplan->beginGeEnd, $planID))); + if(empty($plan->title)) return print(js::alter(sprintf($this->lang->productplan->errorNoTitle, $planID))); + if($plan->begin > $plan->end and !empty($plan->end)) return print(js::alert(sprintf($this->lang->productplan->beginGeEnd, $planID))); if($plan->begin == '') $plan->begin = $this->config->productplan->future; if($plan->end == '') $plan->end = $this->config->productplan->future; @@ -639,7 +639,7 @@ class productplanModel extends model $plan->{$extendField->field} = htmlSpecialString($plan->{$extendField->field}); $message = $this->checkFlowRule($extendField, $plan->{$extendField->field}); - if($message) die(js::alert($message)); + if($message) return print(js::alert($message)); } $plans[$planID] = $plan; @@ -656,11 +656,11 @@ class productplanModel extends model $parent = isset($plans[$parentID]) ? $plans[$parentID] : $this->getByID($parentID); if($parent->begin != $this->config->productplan->future and $plan->begin != $this->config->productplan->future and $plan->begin < $parent->begin) { - die(js::alert(sprintf($this->lang->productplan->beginLetterParentTip, $planID, $plan->begin, $parent->begin))); + return print(js::alert(sprintf($this->lang->productplan->beginLetterParentTip, $planID, $plan->begin, $parent->begin))); } elseif($parent->end != $this->config->productplan->future and $plan->end != $this->config->productplan->future and $plan->end > $parent->end) { - die(js::alert(sprintf($this->lang->productplan->endGreaterParentTip, $planID, $plan->end, $parent->end))); + return print(js::alert(sprintf($this->lang->productplan->endGreaterParentTip, $planID, $plan->end, $parent->end))); } } elseif($parentID == -1 and $plan->begin != $this->config->productplan->future) @@ -674,8 +674,8 @@ class productplanModel extends model if($childPlan->begin < $minBegin and $minBegin != $this->config->productplan->future) $minBegin = $childPlan->begin; if($childPlan->end > $maxEnd and $maxEnd != $this->config->productplan->future) $maxEnd = $childPlan->end; } - if($minBegin < $plan->begin and $minBegin != $this->config->productplan->future) die(js::alert(sprintf($this->lang->productplan->beginGreaterChildTip, $planID, $plan->begin, $minBegin))); - if($maxEnd > $plan->end and $maxEnd != $this->config->productplan->future) die(js::alert(sprintf($this->lang->productplan->endLetterChildTip, $planID, $plan->end, $maxEnd))); + if($minBegin < $plan->begin and $minBegin != $this->config->productplan->future) return print(js::alert(sprintf($this->lang->productplan->beginGreaterChildTip, $planID, $plan->begin, $minBegin))); + if($maxEnd > $plan->end and $maxEnd != $this->config->productplan->future) return print(js::alert(sprintf($this->lang->productplan->endLetterChildTip, $planID, $plan->end, $maxEnd))); } $change = common::createChanges($oldPlans[$planID], $plan); @@ -683,7 +683,7 @@ class productplanModel extends model { if($parentID > 0 and !isset($parents[$parentID])) $parents[$parentID] = $parentID; $this->dao->update(TABLE_PRODUCTPLAN)->data($plan)->autoCheck()->where('id')->eq($planID)->exec(); - if(dao::isError()) die(js::error(dao::getError())); + if(dao::isError()) return print(js::error(dao::getError())); $changes[$planID] = $change; } } diff --git a/module/program/control.php b/module/program/control.php index 6c8e8d9cf6..5404e5a6c8 100644 --- a/module/program/control.php +++ b/module/program/control.php @@ -243,10 +243,10 @@ class program extends control { /* Only when all subprograms and subprojects are closed can the program be closed. */ $hasUnfinished = $this->program->hasUnfinished($program); - if($hasUnfinished) die(js::error($this->lang->program->closeErrorMessage)); + if($hasUnfinished) return print(js::error($this->lang->program->closeErrorMessage)); $changes = $this->project->close($programID); - if(dao::isError()) die(js::error(dao::getError())); + if(dao::isError()) return print(js::error(dao::getError())); if($this->post->comment != '' or !empty($changes)) { @@ -255,7 +255,7 @@ class program extends control } $this->executeHooks($programID); - die(js::reload('parent.parent')); + return print(js::reload('parent.parent')); } $this->view->title = $this->lang->program->close; @@ -281,7 +281,7 @@ class program extends control if(!empty($_POST)) { $changes = $this->project->start($programID, 'program'); - if(dao::isError()) die(js::error(dao::getError())); + if(dao::isError()) return print(js::error(dao::getError())); if($this->post->comment != '' or !empty($changes)) { @@ -291,7 +291,7 @@ class program extends control $this->loadModel('common')->syncPPEStatus($programID); $this->executeHooks($programID); - die(js::reload('parent.parent')); + return print(js::reload('parent.parent')); } $this->view->title = $this->lang->program->start; @@ -317,14 +317,14 @@ class program extends control if(!empty($_POST)) { $changes = $this->project->activate($programID); - if(dao::isError()) die(js::error(dao::getError())); + if(dao::isError()) return print(js::error(dao::getError())); if($this->post->comment != '' or !empty($changes)) { $actionID = $this->action->create('program', $programID, 'Activated', $this->post->comment); $this->action->logHistory($actionID, $changes); } - die(js::reload('parent.parent')); + return print(js::reload('parent.parent')); } $newBegin = date('Y-m-d'); @@ -355,7 +355,7 @@ class program extends control if(!empty($_POST)) { $changes = $this->project->suspend($programID); - if(dao::isError()) die(js::error(dao::getError())); + if(dao::isError()) return print(js::error(dao::getError())); if($this->post->comment != '' or !empty($changes)) { @@ -363,7 +363,7 @@ class program extends control $this->action->logHistory($actionID, $changes); } $this->executeHooks($programID); - die(js::reload('parent.parent')); + return print(js::reload('parent.parent')); } $this->view->title = $this->lang->program->suspend; @@ -389,19 +389,19 @@ class program extends control if($childrenCount) { if($this->viewType == 'json' or (defined('RUN_MODE') && RUN_MODE == 'api')) return $this->send(array('result' => 'fail', 'message' => 'Cannot delete the program has children')); - die(js::alert($this->lang->program->hasChildren)); + return print(js::alert($this->lang->program->hasChildren)); } $productCount = $this->dao->select('count(*) as count')->from(TABLE_PRODUCT)->where('program')->eq($programID)->andWhere('deleted')->eq(0)->fetch('count'); - if($productCount) die(js::alert($this->lang->program->hasProduct)); + if($productCount) return print(js::alert($this->lang->program->hasProduct)); $program = $this->dao->select('*')->from(TABLE_PROGRAM)->where('id')->eq($programID)->fetch(); - if($confirm == 'no') die(js::confirm($this->lang->program->confirmDelete, $this->createLink('program', 'delete', "programID=$programID&confirm=yes"))); + if($confirm == 'no') return print(js::confirm($this->lang->program->confirmDelete, $this->createLink('program', 'delete', "programID=$programID&confirm=yes"))); $this->dao->update(TABLE_PROGRAM)->set('deleted')->eq(1)->where('id')->eq($programID)->exec(); $this->loadModel('action')->create('program', $programID, 'deleted', '', ACTIONMODEL::CAN_UNDELETED); - die(js::reload('parent')); + echo js::reload('parent'); } /** @@ -508,7 +508,7 @@ class program extends control { if($confirm == 'no') { - die(js::confirm($this->lang->program->confirmDelete, $this->inlink('unlinkStakeholder', "stakeholderID=$stakeholderID&programID=$programID&confirm=yes"))); + return print(js::confirm($this->lang->program->confirmDelete, $this->inlink('unlinkStakeholder', "stakeholderID=$stakeholderID&programID=$programID&confirm=yes"))); } else { @@ -518,7 +518,7 @@ class program extends control $this->loadModel('user')->updateUserView($programID, 'program', array($account)); $this->updateChildUserView($programID, $account); - die(js::reload('parent')); + return print(js::reload('parent')); } } @@ -537,7 +537,7 @@ class program extends control if($confirm == 'no') { - die(js::confirm($this->lang->program->confirmBatchUnlink, $this->inlink('batchUnlinkStakeholders', "programID=$programID&stakeholderIDList=$stakeholderIDList&confirm=yes"))); + return print(js::confirm($this->lang->program->confirmBatchUnlink, $this->inlink('batchUnlinkStakeholders', "programID=$programID&stakeholderIDList=$stakeholderIDList&confirm=yes"))); } else { @@ -547,7 +547,7 @@ class program extends control $this->loadModel('user')->updateUserView($programID, 'program', $account); $this->updateChildUserView($programID, $account); - die(js::reload('parent')); + return print(js::reload('parent')); } } @@ -723,7 +723,7 @@ class program extends control { $programID = (int)$programID; $program = $this->program->getByID($programID); - if(!$program) die(js::error($this->lang->notFound) . js::locate('back')); + if(!$program) return print(js::error($this->lang->notFound) . js::locate('back')); echo $this->fetch('program', 'product', "programID=$programID"); } diff --git a/module/program/model.php b/module/program/model.php index 6f886c80c2..455a2ef3d0 100644 --- a/module/program/model.php +++ b/module/program/model.php @@ -11,12 +11,12 @@ class programModel extends model { echo(js::alert($this->lang->program->accessDenied)); - if(!$this->server->http_referer) die(js::locate(helper::createLink('my', 'index'))); + if(!$this->server->http_referer) return print(js::locate(helper::createLink('my', 'index'))); $loginLink = $this->config->requestType == 'GET' ? "?{$this->config->moduleVar}=user&{$this->config->methodVar}=login" : "user{$this->config->requestFix}login"; - if(strpos($this->server->http_referer, $loginLink) !== false) die(js::locate(helper::createLink('my', 'index'))); + if(strpos($this->server->http_referer, $loginLink) !== false) return print(js::locate(helper::createLink('my', 'index'))); - die(js::locate('back')); + echo js::locate('back'); } /** diff --git a/module/programplan/model.php b/module/programplan/model.php index e87070e9eb..387e554187 100644 --- a/module/programplan/model.php +++ b/module/programplan/model.php @@ -627,7 +627,7 @@ class programplanModel extends model /* If child plans has milestone, update parent plan set milestone eq 0 . */ if($parentID and $milestone) $this->dao->update(TABLE_PROJECT)->set('milestone')->eq(0)->where('id')->eq($parentID)->exec(); - if(dao::isError()) die(js::error(dao::getError())); + if(dao::isError()) return print(js::error(dao::getError())); } } diff --git a/module/project/control.php b/module/project/control.php index a25329f7ee..2bf7da8198 100644 --- a/module/project/control.php +++ b/module/project/control.php @@ -178,7 +178,7 @@ class project extends control ->andWhere('t1.type')->eq('execution') ->andWhere('t1.account')->eq($account) ->fetchPairs(); - if(empty($executionMembers)) die(); + if(empty($executionMembers)) return; $executionNames = ''; $count = 0; @@ -198,7 +198,7 @@ class project extends control { $this->lang->project->unlinkExecutionMember = sprintf($this->lang->project->unlinkExecutionMember, count($executionMembers), $executionNames, $this->lang->project->etc); } - die($this->lang->project->unlinkExecutionMember); + echo $this->lang->project->unlinkExecutionMember; } /** @@ -238,7 +238,7 @@ class project extends control $this->project->setMenu($projectID); $project = $this->project->getByID($projectID); - if(empty($project) || $project->type != 'project') die(js::error($this->lang->notFound) . js::locate('back')); + if(empty($project) || $project->type != 'project') return print(js::error($this->lang->notFound) . js::locate('back')); if(!$projectID) $this->locate($this->createLink('project', 'browse')); setCookie("lastProject", $projectID, $this->config->cookieLife, $this->config->webRoot, '', false, true); @@ -355,7 +355,7 @@ class project extends control { $programTitle = $this->post->programTitle; $this->setting->setItem($this->app->user->account . '.project.programTitle', $programTitle); - die(js::reload('parent.parent')); + return print(js::reload('parent.parent')); } $status = $this->setting->getItem('owner=' . $this->app->user->account . '&module=project&key=programTitle'); @@ -665,12 +665,13 @@ class project extends control $this->action->logHistory($actionID, $changes); } } - die(js::locate($this->session->projectList, 'parent')); + return print(js::locate($this->session->projectList, 'parent')); } if($this->app->tab == 'program') $this->loadModel('program')->setMenu(0); - $projectIdList = $this->post->projectIdList ? $this->post->projectIdList : die(js::locate($this->session->projectList, 'parent')); + if(!$this->post->projectIdList) return print(js::locate($this->session->projectList, 'parent')); + $projectIdList = $this->post->projectIdList; $projects = $this->dao->select('*')->from(TABLE_PROJECT)->where('id')->in($projectIdList)->fetchAll('id'); /* Get program list. */ @@ -709,7 +710,7 @@ class project extends control if(empty($project) || strpos('scrum,waterfall,kanban', $project->model) === false) { if(defined('RUN_MODE') && RUN_MODE == 'api') return $this->send(array('status' => 'fail', 'code' => 404, 'message' => '404 Not found')); - die(js::error($this->lang->notFound) . js::locate($this->createLink('project', 'browse'))); + return print(js::error($this->lang->notFound) . js::locate($this->createLink('project', 'browse'))); } $this->project->setMenu($projectID); @@ -791,9 +792,9 @@ class project extends control { $_POST['project'] = $projectID; $groupID = $this->group->create(); - if(dao::isError()) die(js::error(dao::getError())); + if(dao::isError()) return print(js::error(dao::getError())); if($this->viewType == 'json') return $this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess, 'id' => $groupID)); - die(js::closeModal('parent.parent')); + return print(js::closeModal('parent.parent')); } $this->view->title = $this->lang->company->orgView . $this->lang->colon . $this->lang->group->create; @@ -1296,7 +1297,7 @@ class project extends control */ public function unlinkMember($projectID, $userID, $confirm = 'no', $removeExecution = 'no') { - if($confirm == 'no') die(js::confirm($this->lang->project->confirmUnlinkMember, $this->inlink('unlinkMember', "projectID=$projectID&userID=$userID&confirm=yes"))); + if($confirm == 'no') return print(js::confirm($this->lang->project->confirmUnlinkMember, $this->inlink('unlinkMember', "projectID=$projectID&userID=$userID&confirm=yes"))); $user = $this->loadModel('user')->getById($userID, 'id'); $account = $user->account; @@ -1319,7 +1320,7 @@ class project extends control } return $this->send($response); } - die(js::locate($this->inlink('team', "projectID=$projectID"), 'parent')); + echo js::locate($this->inlink('team', "projectID=$projectID"), 'parent'); } /** @@ -1388,8 +1389,8 @@ class project extends control if(!empty($_POST)) { $this->group->updateUser($groupID); - if(isonlybody()) die(js::closeModal('parent.parent', 'this')); - die(js::locate($this->createLink('group', 'browse'), 'parent')); + if(isonlybody()) return print(js::closeModal('parent.parent', 'this')); + return print(js::locate($this->createLink('group', 'browse'), 'parent')); } $group = $this->group->getById($groupID); @@ -1432,8 +1433,8 @@ class project extends control $group = $this->group->getByID($groupID); $_POST['project'] = $group->project; $this->group->copy($groupID); - if(dao::isError()) die(js::error(dao::getError())); - die(js::closeModal('parent.parent', 'this')); + if(dao::isError()) return print(js::error(dao::getError())); + return print(js::closeModal('parent.parent', 'this')); } $this->view->title = $this->lang->company->orgView . $this->lang->colon . $this->lang->group->copy; @@ -1456,7 +1457,7 @@ class project extends control if(!empty($_POST)) { $this->group->update($groupID); - die(js::closeModal('parent.parent', 'this')); + return print(js::closeModal('parent.parent', 'this')); } $this->view->title = $this->lang->company->orgView . $this->lang->colon . $this->lang->group->edit; @@ -1481,7 +1482,7 @@ class project extends control if(!empty($_POST)) { $changes = $this->project->start($projectID); - if(dao::isError()) die(js::error(dao::getError())); + if(dao::isError()) return print(js::error(dao::getError())); if($this->post->comment != '' or !empty($changes)) { @@ -1501,7 +1502,7 @@ class project extends control if($project->status == 'wait' || $project->status == 'suspended') { $changes = $this->project->start($projectID); - if(dao::isError()) die(js::error(dao::getError())); + if(dao::isError()) return print(js::error(dao::getError())); if($this->post->comment != '' or !empty($changes)) { @@ -1514,7 +1515,7 @@ class project extends control $this->loadModel('common')->syncPPEStatus($projectID); $this->executeHooks($projectID); - die(js::reload('parent.parent')); + return print(js::reload('parent.parent')); } $this->view->title = $this->lang->project->start; @@ -1539,7 +1540,7 @@ class project extends control if(!empty($_POST)) { $changes = $this->project->suspend($projectID); - if(dao::isError()) die(js::error(dao::getError())); + if(dao::isError()) return print(js::error(dao::getError())); if($this->post->comment != '' or !empty($changes)) { @@ -1547,7 +1548,7 @@ class project extends control $this->action->logHistory($actionID, $changes); } $this->executeHooks($projectID); - die(js::reload('parent.parent')); + return print(js::reload('parent.parent')); } $this->view->title = $this->lang->project->suspend; @@ -1573,7 +1574,7 @@ class project extends control if(!empty($_POST)) { $changes = $this->project->close($projectID); - if(dao::isError()) die(js::error(dao::getError())); + if(dao::isError()) return print(js::error(dao::getError())); if($this->post->comment != '' or !empty($changes)) { @@ -1581,7 +1582,7 @@ class project extends control $this->action->logHistory($actionID, $changes); } $this->executeHooks($projectID); - die(js::reload('parent.parent')); + return print(js::reload('parent.parent')); } $this->view->title = $this->lang->project->close; @@ -1609,7 +1610,7 @@ class project extends control if(!empty($_POST)) { $changes = $this->project->activate($projectID); - if(dao::isError()) die(js::error(dao::getError())); + if(dao::isError()) return print(js::error(dao::getError())); if($this->post->comment != '' or !empty($changes)) { @@ -1617,7 +1618,7 @@ class project extends control $this->action->logHistory($actionID, $changes); } $this->executeHooks($projectID); - die(js::reload('parent.parent')); + return print(js::reload('parent.parent')); } $newBegin = date('Y-m-d'); @@ -1648,8 +1649,7 @@ class project extends control if($confirm == 'no') { $project = $this->project->getByID($projectID); - echo js::confirm(sprintf($this->lang->project->confirmDelete, $project->name), $this->createLink('project', 'delete', "projectID=$projectID&confirm=yes")); - die(); + return print(js::confirm(sprintf($this->lang->project->confirmDelete, $project->name), $this->createLink('project', 'delete', "projectID=$projectID&confirm=yes"))); } else { @@ -1669,7 +1669,7 @@ class project extends control if(empty($executionIdList)) { if($this->viewType == 'json') return $this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess)); - die(js::locate($url, 'parent')); + return print(js::locate($url, 'parent')); } $this->dao->update(TABLE_EXECUTION)->set('deleted')->eq(1)->where('id')->in(array_keys($executionIdList))->exec(); @@ -1679,7 +1679,7 @@ class project extends control if($this->viewType == 'json') return $this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess)); $this->session->set('project', ''); - die(js::locate($url, 'parent')); + return print(js::locate($url, 'parent')); } } @@ -1862,7 +1862,7 @@ class project extends control $oldTopPGM = $this->loadModel('program')->getTopByID($project->parent); $newTopPGM = $this->program->getTopByID($programID); - if($oldTopPGM == $newTopPGM) die(); + if($oldTopPGM == $newTopPGM) return; $response = array(); $response['result'] = true; @@ -1884,6 +1884,6 @@ class project extends control $response['message'] = $multiLinkedProducts; $response['multiLinkedProjects'] = $multiLinkedProjects; } - die(json_encode($response)); + echo json_encode($response); } } diff --git a/module/project/model.php b/module/project/model.php index 6d034a9093..3a24e89449 100644 --- a/module/project/model.php +++ b/module/project/model.php @@ -1223,10 +1223,10 @@ class projectModel extends model $projects[$projectID]->{$extendField->field} = htmlSpecialString($projects[$projectID]->{$extendField->field}); $message = $this->checkFlowRule($extendField, $projects[$projectID]->{$extendField->field}); - if($message) die(js::alert($message)); + if($message) hepler::end(js::alert($message)); } } - if(dao::isError()) die(js::error(dao::getError())); + if(dao::isError()) helper::end(js::error(dao::getError())); foreach($projects as $projectID => $project) { @@ -1244,7 +1244,7 @@ class projectModel extends model ->where('id')->eq($projectID) ->exec(); - if(dao::isError()) die(js::error('project#' . $projectID . dao::getError(true))); + if(dao::isError()) helper::end(js::error('project#' . $projectID . dao::getError(true))); if(!dao::isError()) { $linkedProducts = $this->dao->select('product')->from(TABLE_PROJECTPRODUCT)->where('project')->eq($projectID)->fetchPairs(); diff --git a/module/projectstory/control.php b/module/projectstory/control.php index 652b9de23b..4f5db62636 100644 --- a/module/projectstory/control.php +++ b/module/projectstory/control.php @@ -37,7 +37,7 @@ class projectStory extends control public function story($projectID = 0, $productID = 0, $branch = 0, $browseType = '', $param = 0, $storyType = 'story', $orderBy = '', $recTotal = 0, $recPerPage = 20, $pageID = 1) { $this->products = $this->loadModel('product')->getProductPairsByProject($projectID); - if(empty($this->products)) die($this->locate($this->createLink('product', 'showErrorNone', 'moduleName=project&activeMenu=story&projectID=' . $projectID))); + if(empty($this->products)) return print($this->locate($this->createLink('product', 'showErrorNone', 'moduleName=project&activeMenu=story&projectID=' . $projectID))); echo $this->fetch('product', 'browse', "productID=$productID&branch=$branch&browseType=$browseType¶m=$param&storyType=$storyType&orderBy=$orderBy&recTotal=$recTotal&recPerPage=$recPerPage&pageID=$pageID&projectID=$projectID"); } @@ -140,7 +140,7 @@ ETO; } if(!dao::isError()) $this->loadModel('score')->create('ajax', 'batchOther'); - die($html); + echo $html; } /** diff --git a/module/qa/control.php b/module/qa/control.php index b2b35c4e3e..f520f1c4d6 100644 --- a/module/qa/control.php +++ b/module/qa/control.php @@ -20,7 +20,7 @@ class qa extends control public function index($locate = 'auto', $productID = 0, $projectID = 0) { $products = $this->loadModel('product')->getProductPairsByProject($projectID, 'noclosed'); - if(empty($products)) die($this->locate($this->createLink('product', 'showErrorNone', "moduleName=qa&activeMenu=index"))); + if(empty($products)) return print($this->locate($this->createLink('product', 'showErrorNone', "moduleName=qa&activeMenu=index"))); if($locate == 'yes') $this->locate($this->createLink('bug', 'browse')); $productID = $this->product->saveState($productID, $products); diff --git a/module/qa/model.php b/module/qa/model.php index f69a0797b7..92e8924375 100644 --- a/module/qa/model.php +++ b/module/qa/model.php @@ -26,7 +26,7 @@ class qaModel extends model if(!$this->app->user->admin and strpos(",{$this->app->user->view->products},", ",$productID,") === false and $productID != 0 and !defined('TUTORIAL')) { $this->app->loadLang('product'); - die(js::error($this->lang->product->accessDenied) . js::locate('back')); + return print(js::error($this->lang->product->accessDenied) . js::locate('back')); } $branch = ($this->cookie->preBranch !== '' and $branch === '') ? $this->cookie->preBranch : $branch; diff --git a/module/release/control.php b/module/release/control.php index 702c8f053c..d2c5d103f3 100644 --- a/module/release/control.php +++ b/module/release/control.php @@ -162,7 +162,7 @@ class release extends control { $releaseID = (int)$releaseID; $release = $this->release->getByID($releaseID, true); - if(!$release) die(js::error($this->lang->notFound) . js::locate($this->createLink('product', 'index'))); + if(!$release) return print(js::error($this->lang->notFound) . js::locate($this->createLink('product', 'index'))); if($type == 'story') $this->session->set('storyList', $this->app->getURI(true), 'product'); if($type == 'bug' or $type == 'leftBug') $this->session->set('bugList', $this->app->getURI(true), 'qa'); @@ -224,8 +224,8 @@ class release extends control /** * Notify for release. - * - * @param int $releaseID + * + * @param int $releaseID * @access public * @return void */ @@ -235,7 +235,7 @@ class release extends control { if(isset($_POST['notify'])) { - $notify = implode(',', $this->post->notify); + $notify = implode(',', $this->post->notify); $this->dao->update(TABLE_RELEASE)->set('notify')->eq($notify)->where('id')->eq($releaseID)->exec(); $this->release->sendmail($releaseID); @@ -244,7 +244,7 @@ class release extends control $this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess, 'locate' => 'parent')); } - + $this->view->release = $this->release->getById($releaseID); $this->view->actions = $this->loadModel('action')->getList('release', $releaseID); $this->view->users = $this->loadModel('user')->getPairs('noletter|noclosed'); @@ -263,7 +263,7 @@ class release extends control { if($confirm == 'no') { - die(js::confirm($this->lang->release->confirmDelete, $this->createLink('release', 'delete', "releaseID=$releaseID&confirm=yes"))); + return print(js::confirm($this->lang->release->confirmDelete, $this->createLink('release', 'delete', "releaseID=$releaseID&confirm=yes"))); } else { @@ -297,7 +297,7 @@ class release extends control if($this->viewType == 'json') return $this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess)); $locateLink = $this->session->releaseList ? $this->session->releaseList : inlink('browse', "productID={$release->product}"); - die(js::locate($locateLink, 'parent')); + return print(js::locate($locateLink, 'parent')); } } @@ -404,7 +404,7 @@ class release extends control } $html = "{$this->post->fileName}$html"; - die($this->fetch('file', 'sendDownHeader', array('fileName' => $this->post->fileName, 'html', $html))); + return print($this->fetch('file', 'sendDownHeader', array('fileName' => $this->post->fileName, 'html', $html))); } $this->display(); @@ -427,7 +427,7 @@ class release extends control if(!empty($_POST['stories'])) { $this->release->linkStory($releaseID); - die(js::locate(inlink('view', "releaseID=$releaseID&type=story"), 'parent')); + return print(js::locate(inlink('view', "releaseID=$releaseID&type=story"), 'parent')); } $this->session->set('storyList', inlink('view', "releaseID=$releaseID&type=story&link=true¶m=" . helper::safe64Encode("&browseType=$browseType&queryID=$param")), 'product'); @@ -512,7 +512,7 @@ class release extends control } return $this->send($response); } - die(js::reload('parent')); + echo js::reload('parent'); } /** @@ -525,7 +525,7 @@ class release extends control public function batchUnlinkStory($releaseID) { $this->release->batchUnlinkStory($releaseID); - die(js::locate($this->createLink('release', 'view', "releaseID=$releaseID&type=story"), 'parent')); + echo js::locate($this->createLink('release', 'view', "releaseID=$releaseID&type=story"), 'parent'); } /** @@ -546,7 +546,7 @@ class release extends control if(!empty($_POST['bugs'])) { $this->release->linkBug($releaseID, $type); - die(js::locate(inlink('view', "releaseID=$releaseID&type=$type"), 'parent')); + return print(js::locate(inlink('view', "releaseID=$releaseID&type=$type"), 'parent')); } $this->session->set('bugList', inlink('view', "releaseID=$releaseID&type=$type&link=true¶m=" . helper::safe64Encode("&browseType=$browseType&queryID=$param")), 'qa'); @@ -643,7 +643,7 @@ class release extends control } return $this->send($response); } - die(js::reload('parent')); + echo js::reload('parent'); } /** @@ -657,7 +657,7 @@ class release extends control public function batchUnlinkBug($releaseID, $type = 'bug') { $this->release->batchUnlinkBug($releaseID, $type); - die(js::locate($this->createLink('release', 'view', "releaseID=$releaseID&type=$type"), 'parent')); + echo js::locate($this->createLink('release', 'view', "releaseID=$releaseID&type=$type"), 'parent'); } /** @@ -671,8 +671,8 @@ class release extends control public function changeStatus($releaseID, $status) { $this->release->changeStatus($releaseID, $status); - if(dao::isError()) die(js::error(dao::getError())); + if(dao::isError()) return print(js::error(dao::getError())); $actionID = $this->loadModel('action')->create('release', $releaseID, 'changestatus', '', $status); - die(js::reload('parent')); + echo js::reload('parent'); } } diff --git a/module/repo/control.php b/module/repo/control.php index 09d2d5b55b..dc39bad950 100644 --- a/module/repo/control.php +++ b/module/repo/control.php @@ -26,7 +26,7 @@ class repo extends control if(stripos(",$disFuncs,", ',exec,') !== false or stripos(",$disFuncs,", ',shell_exec,') !== false) { echo js::alert($this->lang->repo->error->useless); - die(js::locate('back')); + return print(js::locate('back')); } $this->projectID = $this->session->project ? $this->session->project : 0; @@ -61,7 +61,7 @@ class repo extends control $this->repo->setMenu($this->repos, $repoID); } - if(empty($this->repos) and $this->methodName != 'create') die($this->locate($this->repo->createLink('create', "objectID=$objectID"))); + if(empty($this->repos) and $this->methodName != 'create') return print($this->locate($this->repo->createLink('create', "objectID=$objectID"))); } /** @@ -216,7 +216,7 @@ class repo extends control */ public function delete($repoID, $objectID = 0, $confirm = 'no') { - if($confirm == 'no') die(js::confirm($this->lang->repo->notice->delete, $this->repo->createLink('delete', "repoID=$repoID&objectID=$objectID&confirm=yes"))); + if($confirm == 'no') return print(js::confirm($this->lang->repo->notice->delete, $this->repo->createLink('delete', "repoID=$repoID&objectID=$objectID&confirm=yes"))); $relationID = $this->dao->select('id')->from(TABLE_RELATION) ->where('extra')->eq($repoID) @@ -228,15 +228,15 @@ class repo extends control $jobs = $this->dao->select('*')->from(TABLE_JOB)->where('repo')->eq($repoID)->andWhere('deleted')->eq('0')->fetchAll(); if($jobs) $error .= ($error ? '\n' : '') . $this->lang->repo->error->linkedJob; - if($error) die(js::alert($error)); + if($error) return print(js::alert($error)); $this->dao->delete()->from(TABLE_REPO)->where('id')->eq($repoID)->exec(); $this->dao->delete()->from(TABLE_REPOHISTORY)->where('repo')->eq($repoID)->exec(); $this->dao->delete()->from(TABLE_REPOFILES)->where('repo')->eq($repoID)->exec(); $this->dao->delete()->from(TABLE_REPOBRANCH)->where('repo')->eq($repoID)->exec(); - if(dao::isError()) die(js::error(dao::getError())); - die(js::reload('parent')); + if(dao::isError()) return print(js::error(dao::getError())); + echo js::reload('parent'); } /** @@ -907,8 +907,8 @@ class repo extends control { set_time_limit(0); $repo = $this->repo->getRepoByID($repoID); - if(empty($repo)) die(); - if($repo->synced) die('finish'); + if(empty($repo)) return; + if($repo->synced) return print('finish'); $this->commonAction($repoID); $this->scm->setEngine($repo); @@ -979,7 +979,7 @@ class repo extends control if(empty($branchID)) { $this->repo->markSynced($repoID); - die('finish'); + return print('finish'); } } } @@ -1000,8 +1000,8 @@ class repo extends control { set_time_limit(0); $repo = $this->repo->getRepoByID($repoID); - if(empty($repo)) die(); - if(strpos($repo->SCM, 'Git') === false) die('finish'); + if(empty($repo)) return; + if(strpos($repo->SCM, 'Git') === false) return print('finish'); if($branch) $branch = base64_decode($branch); $this->scm->setEngine($repo); @@ -1030,7 +1030,7 @@ class repo extends control setcookie("syncBranch", $branch, 0, $this->config->webRoot, '', $this->config->cookieSecure, true); $this->repo->markSynced($repoID); - die('finish'); + return print('finish'); } $this->dao->update(TABLE_REPO)->set('commits=commits + ' . $commitCount)->where('id')->eq($repoID)->exec(); @@ -1083,7 +1083,7 @@ class repo extends control public function ajaxGetSVNDirs($repoID, $path = '') { $repo = $this->repo->getRepoByID($repoID); - if($repo->SCM != 'Subversion') die(json_encode(array())); + if($repo->SCM != 'Subversion') return print(json_encode(array())); $path = $this->repo->decodePath($path); $dirs = array(); @@ -1099,7 +1099,7 @@ class repo extends control $dirs['/'] = $this->repo->encodePath($path); foreach($tags as $dirPath => $dirName) $dirs[$dirPath] = $this->repo->encodePath($dirPath); } - die(json_encode($dirs)); + return print(json_encode($dirs)); } /** @@ -1122,7 +1122,7 @@ class repo extends control } $reposHtml .= ''; - die($reposHtml); + return print($reposHtml); } /** @@ -1167,7 +1167,7 @@ class repo extends control $options .= ""; } - die($options); + return print($options); } /** @@ -1193,7 +1193,7 @@ class repo extends control } $branchesHtml .= ''; - die($branchesHtml); + return print($branchesHtml); } /** diff --git a/module/repo/model.php b/module/repo/model.php index 4a3245d85c..ab12ca3c29 100644 --- a/module/repo/model.php +++ b/module/repo/model.php @@ -46,13 +46,13 @@ class repoModel extends model if(empty($repo)) { echo(js::alert($this->lang->repo->error->noFound)); - die(js::locate('back')); + return print(js::locate('back')); } if(!$this->checkPriv($repo)) { echo(js::alert($this->lang->repo->error->accessDenied)); - die(js::locate('back')); + return print(js::locate('back')); } } diff --git a/module/report/control.php b/module/report/control.php index 984a13d518..a793b4ee35 100644 --- a/module/report/control.php +++ b/module/report/control.php @@ -369,6 +369,7 @@ class report extends control $this->view->dept = $dept; $this->view->userID = $userID; $this->view->months = $this->report->getYearMonths($year); - die($this->display()); + + $this->display(); } } diff --git a/module/search/control.php b/module/search/control.php index 89673a6f17..75b12ab794 100644 --- a/module/search/control.php +++ b/module/search/control.php @@ -73,21 +73,21 @@ class search extends control $actionURL = $this->post->actionURL; $parsedURL = parse_url($actionURL); - if(isset($parsedURL['host'])) die(); + if(isset($parsedURL['host'])) return; if($this->config->requestType != 'GET') { $path = $parsedURL['path']; $path = str_replace($this->config->webRoot, '', $path); if(strpos($path, '.') !== false) $path = substr($path, 0, strpos($path, '.')); - if(preg_match("/^\w+{$this->config->requestFix}\w+/", $path) == 0) die(); + if(preg_match("/^\w+{$this->config->requestFix}\w+/", $path) == 0) return; } else { $query = $parsedURL['query']; - if(preg_match("/^{$this->config->moduleVar}=\w+\&{$this->config->methodVar}=\w+/", $query) == 0) die(); + if(preg_match("/^{$this->config->moduleVar}=\w+\&{$this->config->methodVar}=\w+/", $query) == 0) return; } - die(js::locate($actionURL, 'parent')); + echo js::locate($actionURL, 'parent'); } /** @@ -125,8 +125,8 @@ class search extends control public function deleteQuery($queryID) { $this->search->deleteQuery($queryID); - if(dao::isError()) die(js::error(dao::getError())); - die('success'); + if(dao::isError()) return print(js::error(dao::getError())); + echo 'success'; } /** @@ -149,7 +149,7 @@ class search extends control if(empty($queryID)) continue; $html .= '
  • ' . html::a("javascript:executeQuery({$queryID})", $queryName . (common::hasPriv('search', 'deleteQuery') ? '' : ''), '', "class='label user-query' data-query-id='$queryID'") . '
  • '; } - die($html); + echo $html; } /** diff --git a/module/search/model.php b/module/search/model.php index ceb44431d2..eaaa6dd92c 100644 --- a/module/search/model.php +++ b/module/search/model.php @@ -389,7 +389,7 @@ class searchModel extends model public function deleteQuery($queryID) { $this->dao->delete()->from(TABLE_USERQUERY)->where('id')->eq($queryID)->andWhere('account')->eq($this->app->user->account)->exec(); - die('success'); + echo 'success'; } /** diff --git a/module/sonarqube/control.php b/module/sonarqube/control.php index 5f77e03a9c..02f617ed4e 100644 --- a/module/sonarqube/control.php +++ b/module/sonarqube/control.php @@ -210,7 +210,7 @@ class sonarqube extends control */ public function delete($sonarqubeID, $confirm = 'no') { - if($confirm != 'yes') die(js::confirm($this->lang->sonarqube->confirmDelete, inlink('delete', "sonarqubeID=$sonarqubeID&confirm=yes"))); + if($confirm != 'yes') return print(js::confirm($this->lang->sonarqube->confirmDelete, inlink('delete', "sonarqubeID=$sonarqubeID&confirm=yes"))); $oldSonarQube = $this->loadModel('pipeline')->getByID($sonarqubeID); $this->loadModel('action'); @@ -319,7 +319,7 @@ class sonarqube extends control */ public function deleteProject($sonarqubeID, $projectKey, $confirm = 'no') { - if($confirm != 'yes') die(js::confirm($this->lang->sonarqube->confirmDeleteProject, inlink('deleteProject', "sonarqubeID=$sonarqubeID&projectKey=$projectKey&confirm=yes"))); + if($confirm != 'yes') return print(js::confirm($this->lang->sonarqube->confirmDeleteProject, inlink('deleteProject', "sonarqubeID=$sonarqubeID&projectKey=$projectKey&confirm=yes"))); /* Fix error when request type is PATH_INFO and the tag name contains '-'.*/ $projectKey = str_replace('*', '-', $projectKey); diff --git a/module/sso/control.php b/module/sso/control.php index f813258261..9b744832a6 100644 --- a/module/sso/control.php +++ b/module/sso/control.php @@ -24,7 +24,7 @@ class sso extends control $locate = empty($referer) ? getWebRoot() : base64_decode($referer); $this->app->loadConfig('sso'); - if(!$this->config->sso->turnon) die($this->locate($locate)); + if(!$this->config->sso->turnon) return print($this->locate($locate)); $userIP = $this->server->remote_addr; $code = $this->config->sso->code; @@ -92,7 +92,7 @@ class sso extends control if($this->loadModel('user')->isLogon()) { - if($this->session->user && $this->session->user->account == $user->account) die($this->locate($locate)); + if($this->session->user && $this->session->user->account == $user->account) return print($this->locate($locate)); } $this->user->cleanLocked($user->account); @@ -116,7 +116,8 @@ class sso extends control $this->session->set('user', $user); $this->app->user = $this->session->user; $this->loadModel('action')->create('user', $user->id, 'login'); - die($this->locate($locate)); + + return print($this->locate($locate)); } } $this->locate($this->createLink('user', 'login', empty($referer) ? '' : "referer=$referer")); @@ -170,7 +171,7 @@ class sso extends control */ public function ajaxSetConfig() { - if(!$this->app->user->admin) die('deny'); + if(!$this->app->user->admin) return print('deny'); if($_POST) { @@ -181,8 +182,8 @@ class sso extends control $ssoConfig->key = trim($this->post->key); $this->loadModel('setting')->setItems('system.sso', $ssoConfig); - if(dao::isError()) die('fail'); - die('success'); + if(dao::isError()) return print('fail'); + echo 'success'; } } @@ -195,19 +196,19 @@ class sso extends control */ public function bind($referer = '') { - if(!$this->session->ssoData) die(); + if(!$this->session->ssoData) return; $ssoData = $this->session->ssoData; $userIP = $this->server->remote_addr; $code = $this->config->sso->code; $key = $this->config->sso->key; - if($ssoData->auth != md5($code . $userIP . $ssoData->token . $key))die(); + if($ssoData->auth != md5($code . $userIP . $ssoData->token . $key)) return; $this->loadModel('user'); if($_POST) { $user = $this->sso->bind(); - if(dao::isError()) die(js::error(dao::getError())); + if(dao::isError()) return print(js::error(dao::getError())); /* Authorize him and save to session. */ $user->rights = $this->user->authorize($user->account); @@ -219,7 +220,7 @@ class sso extends control $this->app->user = $this->session->user; $this->loadModel('action')->create('user', $user->id, 'login'); unset($_SESSION['ssoData']); - die(js::locate(helper::safe64Decode($referer), 'parent')); + return print(js::locate(helper::safe64Decode($referer), 'parent')); } $this->view->title = $this->lang->sso->bind; $this->view->users = $this->user->getPairs('noclosed|nodeleted'); @@ -237,7 +238,7 @@ class sso extends control { if(!$this->sso->checkKey()) return false; $users = $this->loadModel('user')->getPairs('noclosed|nodeleted'); - die(json_encode($users)); + echo json_encode($users); } /** @@ -250,7 +251,7 @@ class sso extends control { if(!$this->sso->checkKey()) return false; $users = $this->sso->getBindUsers(); - die(json_encode($users)); + echo json_encode($users); } /** @@ -265,8 +266,8 @@ class sso extends control { $this->dao->update(TABLE_USER)->set('ranzhi')->eq('')->where('ranzhi')->eq($this->post->ranzhiAccount)->exec(); $this->dao->update(TABLE_USER)->set('ranzhi')->eq($this->post->ranzhiAccount)->where('account')->eq($this->post->zentaoAccount)->exec(); - if(dao::isError()) die(dao::getError()); - die('success'); + if(dao::isError()) return print(dao::getError()); + return print('success'); } } @@ -282,8 +283,8 @@ class sso extends control { $result = $this->sso->createUser(); if($this->viewType == 'json') return $this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess, 'id' => $result['id'])); - if($result['status'] != 'success') die($result['data']); - die('success'); + if($result['status'] != 'success') return print($result['data']); + return print('success'); } } @@ -303,7 +304,7 @@ class sso extends control $datas = array(); $datas['task'] = $this->dao->select("id, name")->from(TABLE_TASK)->where('assignedTo')->eq($account)->andWhere('status')->in('wait,doing')->andWhere('deleted')->eq(0)->fetchPairs(); $datas['bug'] = $this->dao->select("id, title")->from(TABLE_BUG)->where('assignedTo')->eq($account)->andWhere('status')->eq('active')->andWhere('deleted')->eq(0)->fetchPairs(); - die(json_encode($datas)); + echo json_encode($datas); } /** @@ -426,6 +427,5 @@ class sso extends control $this->view->title = $this->lang->sso->deny; $this->view->message = $message; $this->display('sso', 'error'); - die(); } } diff --git a/module/sso/model.php b/module/sso/model.php index 80a73e9938..d49d26cfc8 100644 --- a/module/sso/model.php +++ b/module/sso/model.php @@ -48,10 +48,10 @@ class ssoModel extends model $data = fixer::input('post')->get(); if($data->bindType == 'bind') { - if(empty($data->bindPassword))die(js::alert($this->lang->sso->bindNoPassword)); + if(empty($data->bindPassword)) return print(js::alert($this->lang->sso->bindNoPassword)); $password = md5($data->bindPassword); $user = $this->dao->select('*')->from(TABLE_USER)->where('account')->eq($data->bindUser)->andWhere('password')->eq($password)->andWhere('deleted')->eq('0')->fetch(); - if(empty($user))die(js::alert($this->lang->sso->bindNoUser)); + if(empty($user)) return print(js::alert($this->lang->sso->bindNoUser)); $user->ranzhi = $this->session->ssoData->account; $this->dao->update(TABLE_USER)->set('ranzhi')->eq($user->ranzhi)->where('id')->eq($user->id)->exec(); } @@ -59,7 +59,7 @@ class ssoModel extends model { if(!$this->loadModel('user')->checkPassword()) return; $user = $this->dao->select('*')->from(TABLE_USER)->where('account')->eq($data->account)->fetch(); - if($user) die(js::alert($this->lang->sso->bindHasAccount)); + if($user) return print(js::alert($this->lang->sso->bindHasAccount)); $user = new stdclass(); $user->account = $data->account; diff --git a/module/stage/control.php b/module/stage/control.php index 6fa1d394ae..73eca224db 100644 --- a/module/stage/control.php +++ b/module/stage/control.php @@ -173,13 +173,13 @@ class stage extends control if($confirm == 'no') { - die(js::confirm($this->lang->stage->confirmDelete, inlink('delete', "stageID=$stageID&confirm=yes"))); + return print(js::confirm($this->lang->stage->confirmDelete, inlink('delete', "stageID=$stageID&confirm=yes"))); } else { $this->stage->delete(TABLE_STAGE, $stageID); - die(js::reload('parent')); + return print(js::reload('parent')); } } } diff --git a/module/stakeholder/control.php b/module/stakeholder/control.php index cb4a237340..b3d0e9afbd 100644 --- a/module/stakeholder/control.php +++ b/module/stakeholder/control.php @@ -105,7 +105,7 @@ class stakeholder extends control { $stakeholderList = $this->stakeholder->batchCreate($projectID); if($this->viewType == 'json') return $this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess, 'idList' => $stakeholderList)); - die(js::locate($this->createLink('stakeholder', 'browse', "projectID=$projectID"), 'parent')); + return print(js::locate($this->createLink('stakeholder', 'browse', "projectID=$projectID"), 'parent')); } if($this->app->tab == 'program') @@ -206,7 +206,7 @@ class stakeholder extends control { $members = $this->loadModel('user')->getTeamMemberPairs($projectID, 'project'); } - die(html::select('user', $members, $user, "class='form-control chosen'")); + echo html::select('user', $members, $user, "class='form-control chosen'"); } /** @@ -232,7 +232,7 @@ class stakeholder extends control $users = $this->loadModel('user')->getPairs('noclosed'); $companyUsers = array('' => '') + array_diff($users, $members); - die(html::select('user', $companyUsers, $user, "class='form-control chosen'")); + echo html::select('user', $companyUsers, $user, "class='form-control chosen'"); } /** @@ -245,7 +245,7 @@ class stakeholder extends control { $users = $this->loadModel('user')->getPairs('noclosed|outside|noletter'); - die(html::select('user', $users, '', "class='form-control chosen' onchange=changeUser(this.value);")); + echo html::select('user', $users, '', "class='form-control chosen' onchange=changeUser(this.value);"); } /** @@ -288,7 +288,7 @@ class stakeholder extends control $partakeList = array_merge($insideList, $outsideList); - die(json_encode(array('begin' => $begin, 'realBegin' => $realBegin, 'status' => $status, 'situation' => $situation, 'partakeList' => $partakeList))); + echo json_encode(array('begin' => $begin, 'realBegin' => $realBegin, 'status' => $status, 'situation' => $situation, 'partakeList' => $partakeList)); } /** @@ -303,7 +303,7 @@ class stakeholder extends control { if($confirm == 'no') { - die(js::confirm($this->lang->stakeholder->confirmDelete, inLink('delete', "userID=$userID&confirm=yes"))); + return print(js::confirm($this->lang->stakeholder->confirmDelete, inLink('delete', "userID=$userID&confirm=yes"))); } else { @@ -316,7 +316,7 @@ class stakeholder extends control { $this->loadModel('project')->updateInvolvedUserView($stakeholder->objectID, $stakeholder->user); } - die(js::reload('parent')); + return print(js::reload('parent')); } } @@ -393,8 +393,8 @@ class stakeholder extends control if(!empty($_POST)) { $result = $this->stakeholder->communicate($userID); - if(dao::isError()) die(js::error(dao::getError())); - if(isonlybody()) die(js::closeModal('parent.parent', 'this')); + if(dao::isError()) return print(js::error(dao::getError())); + if(isonlybody()) return print(js::closeModal('parent.parent', 'this')); } $this->view->title = $this->lang->stakeholder->common . $this->lang->colon . $this->lang->stakeholder->communicate; @@ -418,9 +418,9 @@ class stakeholder extends control if(!empty($_POST)) { $expectID = $this->stakeholder->expect($user->id); - if(dao::isError()) die(js::error(dao::getError())); + if(dao::isError()) return print(js::error(dao::getError())); - die(js::closeModal('parent.parent', 'this')); + return print(js::closeModal('parent.parent', 'this')); } $this->view->title = $this->lang->stakeholder->common . $this->lang->colon . $this->lang->stakeholder->communicate; diff --git a/module/story/control.php b/module/story/control.php index 24f65342ef..64eedf623a 100644 --- a/module/story/control.php +++ b/module/story/control.php @@ -83,7 +83,7 @@ class story extends control if(isset($fromObjectID)) { $fromObject = $this->loadModel($fromObjectName)->getById($fromObjectID); - if(!$fromObject) die(js::error($this->lang->notFound) . js::locate('back', 'parent')); + if(!$fromObject) return print(js::error($this->lang->notFound) . js::locate('back', 'parent')); $this->view->$fromObjectIDKey = $fromObjectID; $this->view->$fromObjectName = $fromObject; @@ -222,7 +222,7 @@ class story extends control $users = $this->user->getPairs('pdfirst|noclosed|nodeleted'); $moduleOptionMenu = $this->tree->getOptionMenu($productID, $viewType = 'story', 0, $branch === 'all' ? 0 : $branch); - if(empty($moduleOptionMenu)) die(js::locate(helper::createLink('tree', 'browse', "productID=$productID&view=story"))); + if(empty($moduleOptionMenu)) return print(js::locate(helper::createLink('tree', 'browse', "productID=$productID&view=story"))); /* Init vars. */ $source = ''; @@ -437,7 +437,7 @@ class story extends control if($storyID and !empty($mails)) { $this->story->subdivide($storyID, $stories); - if(dao::isError()) die(js::error(dao::getError())); + if(dao::isError()) return print(js::error(dao::getError())); } if($this->viewType == 'json') return $this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess, 'idList' => $stories)); @@ -644,7 +644,7 @@ class story extends control if(!empty($_POST)) { $changes = $this->story->update($storyID); - if(dao::isError()) die(js::error(dao::getError())); + if(dao::isError()) return print(js::error(dao::getError())); if($this->post->comment != '' or !empty($changes)) { $action = !empty($changes) ? 'Edited' : 'Commented'; @@ -657,9 +657,9 @@ class story extends control $this->executeHooks($storyID); - if(isonlybody()) die(js::reload('parent.parent')); + if(isonlybody()) return print(js::reload('parent.parent')); if(defined('RUN_MODE') && RUN_MODE == 'api') return $this->send(array('status' => 'success', 'data' => $storyID)); - die(js::locate($this->createLink($this->app->rawModule, 'view', "storyID=$storyID"), 'parent')); + return print(js::locate($this->createLink($this->app->rawModule, 'view', "storyID=$storyID"), 'parent')); } $this->commonAction($storyID); @@ -791,10 +791,11 @@ class story extends control $this->action->logHistory($actionID, $changes); } } - die(js::locate($this->session->storyList, 'parent')); + return print(js::locate($this->session->storyList, 'parent')); } - $storyIdList = $this->post->storyIdList ? $this->post->storyIdList : die(js::locate($this->session->storyList, 'parent')); + if(!$this->post->storyIdList) return print(js::locate($this->session->storyList, 'parent')); + $storyIdList = $this->post->storyIdList; $storyIdList = array_unique($storyIdList); /* Get edited stories. */ @@ -934,7 +935,7 @@ class story extends control if(dao::isError()) { if(defined('RUN_MODE') && RUN_MODE == 'api') return $this->send(array('status' => 'fail', 'message' => dao::getError())); - die(js::error(dao::getError())); + return print(js::error(dao::getError())); } $story = $this->story->getByID($storyID); $version = $this->dao->findById($storyID)->from(TABLE_STORY)->fetch('version'); @@ -1011,7 +1012,7 @@ class story extends control if(!empty($_POST)) { $changes = $this->story->activate($storyID); - if(dao::isError()) die(js::error(dao::getError())); + if(dao::isError()) return print(js::error(dao::getError())); if($changes) { @@ -1065,7 +1066,7 @@ class story extends control $storyID = (int)$storyID; $story = $this->story->getById($storyID, $version, true); - if(!$story) die(js::error($this->lang->notFound) . js::locate($this->createLink('product', 'index'))); + if(!$story) return print(js::error($this->lang->notFound) . js::locate($this->createLink('product', 'index'))); $story = $this->story->mergeReviewer($story, true); @@ -1148,7 +1149,7 @@ class story extends control public function delete($storyID, $confirm = 'no') { $story = $this->story->getById($storyID); - if($story->parent < 0) die(js::alert($this->lang->story->cannotDeleteParent)); + if($story->parent < 0) return print(js::alert($this->lang->story->cannotDeleteParent)); if($confirm == 'no') { @@ -1169,7 +1170,7 @@ class story extends control if(defined('RUN_MODE') && RUN_MODE == 'api') return $this->send(array('status' => 'success')); $locateLink = $this->session->storyList ? $this->session->storyList : $this->createLink('product', 'browse', "productID={$story->product}"); - die(js::locate($locateLink, 'parent')); + return print(js::locate($locateLink, 'parent')); } } @@ -1188,7 +1189,7 @@ class story extends control if(!empty($_POST)) { $changes = $this->story->review($storyID); - if(dao::isError()) die(js::error(dao::getError())); + if(dao::isError()) return print(js::error(dao::getError())); if($changes) { @@ -1199,10 +1200,10 @@ class story extends control $this->executeHooks($storyID); - if(isonlybody()) die(js::reload('parent.parent')); + if(isonlybody()) return print(js::reload('parent.parent')); $module = $from == 'project' ? 'projectstory' : 'story'; - die(js::locate($this->createLink($module, 'view', "storyID=$storyID"), 'parent')); + return print(js::locate($this->createLink($module, 'view', "storyID=$storyID"), 'parent')); } /* Get story and product. */ @@ -1266,13 +1267,14 @@ class story extends control */ public function batchReview($result, $reason = '') { - $storyIdList = $this->post->storyIdList ? $this->post->storyIdList : die(js::locate($this->session->storyList, 'parent')); + if(!$this->post->storyIdList) return print(js::locate($this->session->storyList, 'parent')); + $storyIdList = $this->post->storyIdList; $storyIdList = array_unique($storyIdList); $actions = $this->story->batchReview($storyIdList, $result, $reason); - if(dao::isError()) die(js::error(dao::getError())); + if(dao::isError()) return print(js::error(dao::getError())); if(!dao::isError()) $this->loadModel('score')->create('ajax', 'batchOther'); - die(js::reload('parent')); + echo js::reload('parent'); } /** @@ -1289,7 +1291,7 @@ class story extends control $this->loadModel('action')->create('story', $storyID, 'Recalled'); $locateLink = $this->session->storyList ? $this->session->storyList : $this->createLink('product', 'browse', "productID={$story->product}"); - die(js::locate($locateLink, 'parent')); + echo js::locate($locateLink, 'parent'); } /** @@ -1393,10 +1395,11 @@ class story extends control } if(!dao::isError()) $this->loadModel('score')->create('ajax', 'batchOther'); - die(js::locate($this->session->storyList, 'parent')); + return print(js::locate($this->session->storyList, 'parent')); } - $storyIdList = $this->post->storyIdList ? $this->post->storyIdList : die(js::locate($this->session->storyList, 'parent')); + if(!$this->post->storyIdList) return print(js::locate($this->session->storyList, 'parent')); + $storyIdList = $this->post->storyIdList; $storyIdList = array_unique($storyIdList); /* Get edited stories. */ @@ -1488,17 +1491,18 @@ class story extends control */ public function batchChangeModule($moduleID) { - $storyIdList = !empty($_POST['storyIdList']) ? $this->post->storyIdList : die(js::locate($this->session->storyList, 'parent')); + if(empty($_POST['storyIdList'])) return print(js::locate($this->session->storyList, 'parent')); + $storyIdList = $this->post->storyIdList; $storyIdList = array_unique($storyIdList); $allChanges = $this->story->batchChangeModule($storyIdList, $moduleID); - if(dao::isError()) die(js::error(dao::getError())); + if(dao::isError()) return print(js::error(dao::getError())); foreach($allChanges as $storyID => $changes) { $actionID = $this->action->create('story', $storyID, 'Edited'); $this->action->logHistory($actionID, $changes); } if(!dao::isError()) $this->loadModel('score')->create('ajax', 'batchOther'); - die(js::locate($this->session->storyList, 'parent')); + echo js::locate($this->session->storyList, 'parent'); } /** @@ -1539,17 +1543,18 @@ class story extends control */ public function batchChangePlan($planID, $oldPlanID = 0) { - $storyIdList = !empty($_POST['storyIdList']) ? $this->post->storyIdList : die(js::locate($this->session->storyList, 'parent')); + if(empty($_POST['storyIdList'])) return print(js::locate($this->session->storyList, 'parent')); + $storyIdList = $this->post->storyIdList; $storyIdList = array_unique($storyIdList); $allChanges = $this->story->batchChangePlan($storyIdList, $planID, $oldPlanID); - if(dao::isError()) die(js::error(dao::getError())); + if(dao::isError()) return print(js::error(dao::getError())); foreach($allChanges as $storyID => $changes) { $actionID = $this->action->create('story', $storyID, 'Edited'); $this->action->logHistory($actionID, $changes); } if(!dao::isError()) $this->loadModel('score')->create('ajax', 'batchOther'); - die(js::locate($this->session->storyList, 'parent')); + echo js::locate($this->session->storyList, 'parent'); } /** @@ -1563,8 +1568,8 @@ class story extends control */ public function batchChangeBranch($branchID, $confirm = '', $storyIdList = '') { - if(!empty($_POST['storyIdList'])) $storyIdList = $_POST['storyIdList']; - $storyIdList = !empty($storyIdList) ? $storyIdList : die(js::locate($this->session->storyList, 'parent')); + if(empty($_POST['storyIdList'])) return print(js::locate($this->session->storyList, 'parent')); + $storyIdList = $this->post->storyIdList; $plans = $this->loadModel('productplan')->getPlansByStories($storyIdList); if(empty($confirm)) { @@ -1598,21 +1603,21 @@ class story extends control $storyIdList = implode(',', $storyIdList); $confirmURL = $this->createLink('story', 'batchChangeBranch', "branchID=$branchID&confirm=yes&storyIdList=$storyIdList"); $cancelURL = $this->createLink('story', 'batchChangeBranch', "branchID=$branchID&confirm=no&storyIdList=$normalStotyIdList"); - die(js::confirm(sprintf($this->lang->story->confirmChangeBranch, $conflictStoryIdList ), $confirmURL, $cancelURL)); + return print(js::confirm(sprintf($this->lang->story->confirmChangeBranch, $conflictStoryIdList ), $confirmURL, $cancelURL)); } } if(is_string($storyIdList)) $storyIdList = array_filter(explode(',', $storyIdList)); $storyIdList = array_unique($storyIdList); $allChanges = $this->story->batchChangeBranch($storyIdList, $branchID, $confirm, $plans); - if(dao::isError()) die(js::error(dao::getError())); + if(dao::isError()) return print(js::error(dao::getError())); foreach($allChanges as $storyID => $changes) { $actionID = $this->action->create('story', $storyID, 'Edited'); $this->action->logHistory($actionID, $changes); } if(!dao::isError()) $this->loadModel('score')->create('ajax', 'batchOther'); - die(js::reload('parent')); + echo js::reload('parent'); } /** @@ -1625,11 +1630,11 @@ class story extends control public function batchChangeStage($stage) { $storyIdList = $this->post->storyIdList; - if(empty($storyIdList)) die(js::locate($this->session->storyList, 'parent')); + if(empty($storyIdList)) return print(js::locate($this->session->storyList, 'parent')); $storyIdList = array_unique($storyIdList); $allChanges = $this->story->batchChangeStage($storyIdList, $stage); - if(dao::isError()) die(js::error(dao::getError())); + if(dao::isError()) return print(js::error(dao::getError())); $action = $stage == 'verified' ? 'Verified' : 'Edited'; foreach($allChanges as $storyID => $changes) @@ -1638,7 +1643,7 @@ class story extends control $this->action->logHistory($actionID, $changes); } if(!dao::isError()) $this->loadModel('score')->create('ajax', 'batchOther'); - die(js::locate($this->session->storyList, 'parent')); + echo js::locate($this->session->storyList, 'parent'); } /** @@ -1653,7 +1658,7 @@ class story extends control if(!empty($_POST)) { $changes = $this->story->assign($storyID); - if(dao::isError()) die(js::error(dao::getError())); + if(dao::isError()) return print(js::error(dao::getError())); if($changes) { $actionID = $this->loadModel('action')->create('story', $storyID, 'Assigned', $this->post->comment, $this->post->assignedTo); @@ -1706,7 +1711,7 @@ class story extends control if(!empty($_POST) && isset($_POST['storyIdList'])) { $allChanges = $this->story->batchAssignTo(); - if(dao::isError()) die(js::error(dao::getError())); + if(dao::isError()) return print(js::error(dao::getError())); foreach($allChanges as $storyID => $changes) { $actionID = $this->action->create('story', $storyID, 'Assigned', '', $this->post->assignedTo); @@ -1714,7 +1719,7 @@ class story extends control } } if(!dao::isError()) $this->loadModel('score')->create('ajax', 'batchOther'); - die(js::locate($this->session->storyList, 'parent')); + echo js::locate($this->session->storyList, 'parent'); } /** @@ -1893,15 +1898,15 @@ class story extends control if($type == 'remove') { $result = $this->story->unlinkStory($storyID, $linkedStoryID); - die(js::reload('parent')); + return print(js::reload('parent')); } if($_POST) { $this->story->linkStories($storyID); - if(dao::isError()) die(js::error(dao::getError())); - die(js::closeModal('parent.parent', 'this')); + if(dao::isError()) return print(js::error(dao::getError())); + return print(js::closeModal('parent.parent', 'this')); } /* Get story, product, products, and queryID. */ @@ -1953,7 +1958,7 @@ class story extends control if($result == 'no') { $this->dao->update(TABLE_STORY)->set('URChanged')->eq(0)->where('id')->eq($storyID)->exec(); - die(js::reload('parent', 'this')); + return print(js::reload('parent', 'this')); } $this->view->changedStories = $this->story->getChangedStories($story); @@ -1983,16 +1988,16 @@ class story extends control $stories = $this->story->getExecutionStoryPairs($executionID, $productID, $branch, $moduleID, $type); if($this->app->getViewType() === 'json') { - die(json_encode($stories)); + return print(json_encode($stories)); } elseif($this->app->getViewType() == 'mhtml') { - die(html::select('story', empty($stories) ? array('' => '') : $stories, $storyID, 'onchange=setStoryRelated()')); + return print(html::select('story', empty($stories) ? array('' => '') : $stories, $storyID, 'onchange=setStoryRelated()')); } else { $storyName = $number === '' ? 'story' : "story[$number]"; - die(html::select($storyName, empty($stories) ? array('' => '') : $stories, $storyID, 'class=form-control onchange=setStoryRelated(' . $number . ');')); + return print(html::select($storyName, empty($stories) ? array('' => '') : $stories, $storyID, 'class=form-control onchange=setStoryRelated(' . $number . ');')); } } @@ -2044,8 +2049,8 @@ class story extends control $select = html::select('story' . $number, empty($stories) ? array('' => '') : $stories, $storyID, "class='form-control'"); /* If only need options, remove select wrap. */ - if($onlyOption == 'true') die(substr($select, strpos($select, '>') + 1, -10)); - die($select); + if($onlyOption == 'true') return print(substr($select, strpos($select, '>') + 1, -10)); + echo $select; } /** @@ -2093,7 +2098,7 @@ class story extends control $result['info'] = $this->lang->noResultsMatch; } - die(json_encode($result)); + echo json_encode($result); } /** @@ -2476,8 +2481,8 @@ class story extends control $user = $this->loadModel('user')->getById($userID, 'id'); $stories = $this->story->getUserStoryPairs($user->account); - if($id) die(html::select("stories[$id]", $stories, '', 'class="form-control"')); - die(html::select('story', $stories, '', 'class=form-control')); + if($id) return print(html::select("stories[$id]", $stories, '', 'class="form-control"')); + echo html::select('story', $stories, '', 'class=form-control'); } /** @@ -2513,6 +2518,6 @@ class story extends control $status = $oldStory->status; if($params['result'] == 'revert') $status = 'active'; } - die($status); + echo $status; } } diff --git a/module/story/model.php b/module/story/model.php index 8f34c62857..3cbdb10482 100644 --- a/module/story/model.php +++ b/module/story/model.php @@ -487,7 +487,7 @@ class storyModel extends model $story->{$extendField->field} = htmlSpecialString($story->{$extendField->field}); $message = $this->checkFlowRule($extendField, $story->{$extendField->field}); - if($message) die(js::alert($message)); + if($message) return print(js::alert($message)); } foreach(explode(',', $this->config->story->create->requiredFields) as $field) @@ -514,7 +514,7 @@ class storyModel extends model if(dao::isError()) { echo js::error(dao::getError()); - die(js::reload('parent')); + return print(js::reload('parent')); } $storyID = $this->dao->lastInsertID(); @@ -1206,7 +1206,7 @@ class storyModel extends model $story->{$extendField->field} = htmlSpecialString($story->{$extendField->field}); $message = $this->checkFlowRule($extendField, $story->{$extendField->field}); - if($message) die(js::alert($message)); + if($message) return print(js::alert($message)); } $stories[$storyID] = $story; @@ -1246,7 +1246,7 @@ class storyModel extends model } else { - die(js::error('story#' . $storyID . dao::getError(true))); + return print(js::error('story#' . $storyID . dao::getError(true))); } } } @@ -1263,8 +1263,8 @@ class storyModel extends model */ public function review($storyID) { - if($this->post->result == false) die(js::alert($this->lang->story->mustChooseResult)); - if($this->post->result == 'revert' and $this->post->preVersion == false) die(js::alert($this->lang->story->mustChoosePreVersion)); + if($this->post->result == false) return print(js::alert($this->lang->story->mustChooseResult)); + if($this->post->result == 'revert' and $this->post->preVersion == false) return print(js::alert($this->lang->story->mustChoosePreVersion)); if(strpos($this->config->story->review->requiredFields, 'comment') !== false and !$this->post->comment) { @@ -1457,11 +1457,11 @@ class storyModel extends model $this->dao->insert(TABLE_RELATION)->data($data)->autoCheck()->exec(); } - if(dao::isError()) die(js::error(dao::getError())); + if(dao::isError()) return print(js::error(dao::getError())); $isonlybody = isonlybody(); unset($_GET['onlybody']); - die(js::locate(helper::createLink('product', 'browse', "productID=$oldStory->product&branch=0&browseType=unclosed&queryID=0&type=story"), $isonlybody ? 'parent.parent' : 'parent')); + return print(js::locate(helper::createLink('product', 'browse', "productID=$oldStory->product&branch=0&browseType=unclosed&queryID=0&type=story"), $isonlybody ? 'parent.parent' : 'parent')); } else { @@ -1591,7 +1591,7 @@ class storyModel extends model } else { - die(js::error('story#' . $storyID . dao::getError(true))); + return print(js::error('story#' . $storyID . dao::getError(true))); } if(!dao::isError()) $this->loadModel('score')->create('story', 'close', $storyID); } diff --git a/module/svn/control.php b/module/svn/control.php index 2ffa0bab50..d33d5a9531 100644 --- a/module/svn/control.php +++ b/module/svn/control.php @@ -144,7 +144,7 @@ class svn extends control $files = $this->post->files; /* Ignore git. */ - if(strpos($repoUrl, '://') === false) die(); + if(strpos($repoUrl, '://') === false) return; $parsedFiles = array(); $repoDirs = explode('/', trim($repoUrl, '/')); @@ -182,7 +182,6 @@ class svn extends control $log->files = $parsedFiles; $this->repo->saveAction2PMS($objects, $log, $repoUrl); } - die(); } /** @@ -194,6 +193,6 @@ class svn extends control public function ajaxGetRepos() { $repos = $this->svn->getRepos(); - die(json_encode($repos)); + echo json_encode($repos); } } diff --git a/module/task/control.php b/module/task/control.php index e02ea9544d..f1bb5cdfcc 100644 --- a/module/task/control.php +++ b/module/task/control.php @@ -53,7 +53,7 @@ class task extends control if(strpos(",{$limitedExecutions},", ",$executionID,") !== false) { echo js::alert($this->lang->task->createDenied); - die(js::locate($this->createLink('execution', 'task', "executionID=$executionID"))); + return print(js::locate($this->createLink('execution', 'task', "executionID=$executionID"))); } $task = new stdClass(); @@ -284,7 +284,7 @@ class task extends control if(strpos(",{$limitedExecutions},", ",$executionID,") !== false) { echo js::alert($this->lang->task->createDenied); - die(js::locate($this->createLink('execution', 'task', "executionID=$executionID"))); + return print(js::locate($this->createLink('execution', 'task', "executionID=$executionID"))); } $execution = $this->execution->getById($executionID); @@ -449,7 +449,7 @@ class task extends control { $confirmURL = $this->createLink('bug', 'view', "id=$task->fromBug"); $cancelURL = $this->server->HTTP_REFERER; - die(js::confirm(sprintf($this->lang->task->remindBug, $task->fromBug), $confirmURL, $cancelURL, 'parent', 'parent')); + return print(js::confirm(sprintf($this->lang->task->remindBug, $task->fromBug), $confirmURL, $cancelURL, 'parent', 'parent')); } } } @@ -476,7 +476,7 @@ class task extends control } else { - die(js::locate($this->createLink('task', 'view', "taskID=$taskID"), 'parent')); + return print(js::locate($this->createLink('task', 'view', "taskID=$taskID"), 'parent')); } } @@ -525,7 +525,7 @@ class task extends control if($this->post->names) { $allChanges = $this->task->batchUpdate(); - if(dao::isError()) die(js::error(dao::getError())); + if(dao::isError()) return print(js::error(dao::getError())); if(!empty($allChanges)) { @@ -560,7 +560,7 @@ class task extends control { $confirmURL = $this->createLink('bug', 'view', "id=$task->fromBug"); $cancelURL = $this->server->HTTP_REFERER; - die(js::confirm(sprintf($this->lang->task->remindBug, $task->fromBug), $confirmURL, $cancelURL, 'parent', 'parent')); + return print(js::confirm(sprintf($this->lang->task->remindBug, $task->fromBug), $confirmURL, $cancelURL, 'parent', 'parent')); } } } @@ -568,10 +568,10 @@ class task extends control } } $this->loadModel('score')->create('ajax', 'batchOther'); - die(js::locate($this->session->taskList, 'parent')); + return print(js::locate($this->session->taskList, 'parent')); } - $taskIDList = $this->post->taskIDList ? $this->post->taskIDList : die(js::locate($this->session->taskList, 'parent')); + $taskIDList = $this->post->taskIDList ? $this->post->taskIDList : return print(js::locate($this->session->taskList, 'parent')); $taskIDList = array_unique($taskIDList); /* The tasks of execution. */ @@ -658,7 +658,7 @@ class task extends control if(dao::isError()) { if($this->viewType == 'json' or (defined('RUN_MODE') && RUN_MODE == 'api')) return $this->send(array('result' => 'fail', 'message' => dao::getError())); - die(js::error(dao::getError())); + return print(js::error(dao::getError())); } $actionID = $this->action->create('task', $taskID, 'Assigned', $this->post->comment, $this->post->assignedTo); @@ -722,7 +722,7 @@ class task extends control $taskIDList = array_unique($taskIDList); unset($_POST['taskIDList']); $allChanges = $this->task->batchChangeModule($taskIDList, $moduleID); - if(dao::isError()) die(js::error(dao::getError())); + if(dao::isError()) return print(js::error(dao::getError())); foreach($allChanges as $taskID => $changes) { $this->loadModel('action'); @@ -731,7 +731,7 @@ class task extends control } if(!dao::isError()) $this->loadModel('score')->create('ajax', 'batchOther'); } - die(js::reload('parent')); + echo js::reload('parent'); } /** @@ -749,7 +749,7 @@ class task extends control $taskIDList = $this->post->taskIDList; $taskIDList = array_unique($taskIDList); unset($_POST['taskIDList']); - if(!is_array($taskIDList)) die(js::locate($this->createLink('execution', 'task', "executionID=$execution"), 'parent')); + if(!is_array($taskIDList)) return print(js::locate($this->createLink('execution', 'task', "executionID=$execution"), 'parent')); $taskIDList = array_unique($taskIDList); $muletipleTasks = $this->dao->select('root , account')->from(TABLE_TEAM)->where('type')->eq('task')->andWhere('root')->in($taskIDList)->fetchGroup('root', 'account'); @@ -761,12 +761,12 @@ class task extends control if(isset($muletipleTasks[$taskID]) and !isset($muletipleTasks[$taskID][$this->post->assignedTo])) continue; $changes = $this->task->assign($taskID); - if(dao::isError()) die(js::error(dao::getError())); + if(dao::isError()) return print(js::error(dao::getError())); $actionID = $this->action->create('task', $taskID, 'Assigned', $this->post->comment, $this->post->assignedTo); $this->action->logHistory($actionID, $changes); } if(!dao::isError()) $this->loadModel('score')->create('ajax', 'batchOther'); - die(js::reload('parent')); + return print(js::reload('parent')); } } @@ -788,7 +788,7 @@ class task extends control if(!$task) { if(defined('RUN_MODE') && RUN_MODE == 'api') return $this->send(array('status' => 'fail', 'code' => 404, 'message' => '404 Not found')); - die(js::error($this->lang->notFound) . js::locate($this->createLink('execution', 'all'))); + return print(js::error($this->lang->notFound) . js::locate($this->createLink('execution', 'all'))); } $this->session->project = $task->project; @@ -856,7 +856,7 @@ class task extends control $this->executeHooks($taskID); - die(js::reload('parent')); + echo js::reload('parent'); } /** @@ -884,7 +884,7 @@ class task extends control if(dao::isError()) { if($this->viewType == 'json' or (defined('RUN_MODE') && RUN_MODE == 'api')) return $this->send(array('result' => 'fail', 'message' => dao::getError())); - die(js::error(dao::getError())); + return print(js::error(dao::getError())); } if($this->post->comment != '' or !empty($changes)) @@ -907,7 +907,7 @@ class task extends control $confirmURL = $this->createLink('bug', 'view', "id=$task->fromBug"); unset($_GET['onlybody']); $cancelURL = $this->createLink('task', 'view', "taskID=$taskID"); - die(js::confirm(sprintf($this->lang->task->remindBug, $task->fromBug), $confirmURL, $cancelURL, 'parent', 'parent.parent')); + return print(js::confirm(sprintf($this->lang->task->remindBug, $task->fromBug), $confirmURL, $cancelURL, 'parent', 'parent.parent')); } } } @@ -930,7 +930,7 @@ class task extends control return print(js::closeModal('parent.parent', 'this', "function(){parent.parent.location.reload();}")); } } - die(js::locate($this->createLink('task', 'view', "taskID=$taskID"), 'parent')); + return print(js::locate($this->createLink('task', 'view', "taskID=$taskID"), 'parent')); } $this->view->title = $this->view->execution->name . $this->lang->colon .$this->lang->task->start; @@ -956,7 +956,7 @@ class task extends control if(!empty($_POST)) { $changes = $this->task->recordEstimate($taskID); - if(dao::isError()) die(js::error(dao::getError())); + if(dao::isError()) return print(js::error(dao::getError())); $this->loadModel('common')->syncPPEStatus($taskID); @@ -971,7 +971,7 @@ class task extends control $confirmURL = $this->createLink('bug', 'view', "id=$task->fromBug"); unset($_GET['onlybody']); $cancelURL = $this->createLink('task', 'view', "taskID=$taskID"); - die(js::confirm(sprintf($this->lang->task->remindBug, $task->fromBug), $confirmURL, $cancelURL, 'parent', 'parent.parent')); + return print(js::confirm(sprintf($this->lang->task->remindBug, $task->fromBug), $confirmURL, $cancelURL, 'parent', 'parent.parent')); } } } @@ -1016,13 +1016,13 @@ class task extends control if(!empty($_POST)) { $changes = $this->task->updateEstimate($estimateID); - if(dao::isError()) die(js::error(dao::getError())); + if(dao::isError()) return print(js::error(dao::getError())); $actionID = $this->loadModel('action')->create('task', $estimate->task, 'EditEstimate', $this->post->work); $this->action->logHistory($actionID, $changes); $url = $this->session->estimateList ? $this->session->estimateList : inlink('record', "taskID={$estimate->task}"); - die(js::locate($url, 'parent')); + return print(js::locate($url, 'parent')); } $estimate = $this->task->getEstimateById($estimateID); @@ -1045,17 +1045,17 @@ class task extends control { if($confirm == 'no') { - die(js::confirm($this->lang->task->confirmDeleteEstimate, $this->createLink('task', 'deleteEstimate', "estimateID=$estimateID&confirm=yes"))); + return print(js::confirm($this->lang->task->confirmDeleteEstimate, $this->createLink('task', 'deleteEstimate', "estimateID=$estimateID&confirm=yes"))); } else { $estimate = $this->task->getEstimateById($estimateID); $changes = $this->task->deleteEstimate($estimateID); - if(dao::isError()) die(js::error(dao::getError())); + if(dao::isError()) return print(js::error(dao::getError())); $actionID = $this->loadModel('action')->create('task', $estimate->task, 'DeleteEstimate'); $this->action->logHistory($actionID, $changes); - die(js::reload('parent')); + return print(js::reload('parent')); } } @@ -1081,7 +1081,7 @@ class task extends control if(dao::isError()) { if($this->viewType == 'json' or (defined('RUN_MODE') && RUN_MODE == 'api')) return $this->send(array('result' => 'fail', 'message' => dao::getError())); - die(js::error(dao::getError())); + return print(js::error(dao::getError())); } $files = $this->loadModel('file')->saveUpload('task', $taskID); @@ -1104,7 +1104,7 @@ class task extends control $confirmURL = $this->createLink('bug', 'view', "id=$task->fromBug", '', true); unset($_GET['onlybody']); $cancelURL = $this->createLink('task', 'view', "taskID=$taskID"); - die(js::confirm(sprintf($this->lang->task->remindBug, $task->fromBug), $confirmURL, $cancelURL, 'parent', 'parent.parent')); + return print(js::confirm(sprintf($this->lang->task->remindBug, $task->fromBug), $confirmURL, $cancelURL, 'parent', 'parent.parent')); } } } @@ -1133,7 +1133,7 @@ class task extends control } else { - die(js::locate($this->createLink('task', 'view', "taskID=$taskID"), 'parent')); + return print(js::locate($this->createLink('task', 'view', "taskID=$taskID"), 'parent')); } } @@ -1186,7 +1186,7 @@ class task extends control { $this->loadModel('action'); $changes = $this->task->pause($taskID, $extra); - if(dao::isError()) die(js::error(dao::getError())); + if(dao::isError()) return print(js::error(dao::getError())); if($this->post->comment != '' or !empty($changes)) { @@ -1241,7 +1241,7 @@ class task extends control { $this->loadModel('action'); $changes = $this->task->start($taskID); - if(dao::isError()) die(js::error(dao::getError())); + if(dao::isError()) return print(js::error(dao::getError())); if($this->post->comment != '' or !empty($changes)) { @@ -1300,7 +1300,7 @@ class task extends control $this->loadModel('action'); $changes = $this->task->close($taskID, $extra); - if(dao::isError()) die(js::error(dao::getError())); + if(dao::isError()) return print(js::error(dao::getError())); if($this->post->comment != '' or !empty($changes)) { @@ -1334,7 +1334,7 @@ class task extends control } else { - die(js::locate($this->createLink('task', 'view', "taskID=$taskID"), 'parent')); + return print(js::locate($this->createLink('task', 'view', "taskID=$taskID"), 'parent')); } } @@ -1377,7 +1377,7 @@ class task extends control } } - die(js::reload('parent')); + echo js::reload('parent'); } /** @@ -1425,11 +1425,12 @@ class task extends control $skipTasks = join(',', $skipTasks); $confirmURL = $this->createLink('task', 'batchClose', "skipTaskIdList=$skipTasks"); $cancelURL = $this->server->HTTP_REFERER; - die(js::confirm(sprintf($this->lang->task->error->skipClose, $skipTasks), $confirmURL, $cancelURL, 'self', 'parent')); + return print(js::confirm(sprintf($this->lang->task->error->skipClose, $skipTasks), $confirmURL, $cancelURL, 'self', 'parent')); } if(!dao::isError()) $this->loadModel('score')->create('ajax', 'batchOther'); } - die(js::reload('parent')); + + echo js::reload('parent'); } /** @@ -1451,7 +1452,7 @@ class task extends control { $this->loadModel('action'); $changes = $this->task->cancel($taskID, $extra); - if(dao::isError()) die(js::error(dao::getError())); + if(dao::isError()) return print(js::error(dao::getError())); if($this->post->comment != '' or !empty($changes)) { @@ -1478,7 +1479,7 @@ class task extends control return print(js::closeModal('parent.parent', 'this')); } } - die(js::locate($this->createLink('task', 'view', "taskID=$taskID"), 'parent')); + return print(js::locate($this->createLink('task', 'view', "taskID=$taskID"), 'parent')); } $this->view->title = $this->view->execution->name . $this->lang->colon .$this->lang->task->cancel; @@ -1507,7 +1508,7 @@ class task extends control { $this->loadModel('action'); $changes = $this->task->activate($taskID, $extra); - if(dao::isError()) die(js::error(dao::getError())); + if(dao::isError()) return print(js::error(dao::getError())); if($this->post->comment != '' or !empty($changes)) { @@ -1609,8 +1610,8 @@ class task extends control if(isset($suspendedTasks[$taskid])) unset($tasks[$taskid]); } - if($id) die(html::select("tasks[$id]", $tasks, '', 'class="form-control"')); - die(html::select('task', $tasks, '', 'class=form-control')); + if($id) return print(html::select("tasks[$id]", $tasks, '', 'class="form-control"')); + echo html::select('task', $tasks, '', 'class=form-control'); } /** @@ -1624,7 +1625,7 @@ class task extends control public function ajaxGetExecutionTasks($executionID, $taskID = 0) { $tasks = $this->task->getExecutionTaskPairs((int)$executionID); - die(html::select('task', empty($tasks) ? array('' => '') : $tasks, $taskID, "class='form-control'")); + echo html::select('task', empty($tasks) ? array('' => '') : $tasks, $taskID, "class='form-control'"); } /** @@ -1965,6 +1966,6 @@ class task extends control $stage = $this->dao->select('*')->from(TABLE_STORY)->where('id')->eq($task->story)->andWhere('version')->eq($task->storyVersion)->fetch('stage'); $task->storyStage = zget($this->lang->story->stageList, $stage); } - die(json_encode($task)); + echo json_encode($task); } } diff --git a/module/task/model.php b/module/task/model.php index 4482e1639f..cb7a802615 100644 --- a/module/task/model.php +++ b/module/task/model.php @@ -866,7 +866,7 @@ class taskModel extends model { $taskConsumed = 0; $taskConsumed = $this->dao->select('consumed')->from(TABLE_TASK)->where('id')->eq($this->post->parent)->andWhere('parent')->eq(0)->fetch('consumed'); - if($taskConsumed > 0) die(js::error($this->lang->task->error->alreadyConsumed)); + if($taskConsumed > 0) return print(js::error($this->lang->task->error->alreadyConsumed)); } $now = helper::now(); @@ -915,7 +915,7 @@ class taskModel extends model ->remove('comment,files,labels,uid,multiple,team,teamEstimate,teamConsumed,teamLeft,contactListMenu') ->get(); - if($task->consumed < $oldTask->consumed) die(js::error($this->lang->task->error->consumedSmall)); + if($task->consumed < $oldTask->consumed) return print(js::error($this->lang->task->error->consumedSmall)); /* Fix bug#1388, Check children task executionID and moduleID. */ if(isset($task->execution) and $task->execution != $oldTask->execution) @@ -1166,7 +1166,7 @@ class taskModel extends model $task->{$extendField->field} = htmlSpecialString($task->{$extendField->field}); $message = $this->checkFlowRule($extendField, $task->{$extendField->field}); - if($message) die(js::alert($message)); + if($message) return print(js::alert($message)); } if($data->consumeds[$taskID]) @@ -1245,9 +1245,9 @@ class taskModel extends model /* Check field not empty. */ foreach($tasks as $taskID => $task) { - if($task->status == 'done' and $task->consumed == false) die(js::error('task#' . $taskID . sprintf($this->lang->error->notempty, $this->lang->task->consumedThisTime))); + if($task->status == 'done' and $task->consumed == false) return print(js::error('task#' . $taskID . sprintf($this->lang->error->notempty, $this->lang->task->consumedThisTime))); if($task->status == 'cancel') continue; - if(!empty($task->deadline) and $task->estStarted > $task->deadline) die(js::error('task#' . $taskID . $this->lang->task->error->deadlineSmall)); + if(!empty($task->deadline) and $task->estStarted > $task->deadline) return print(js::error('task#' . $taskID . $this->lang->task->error->deadlineSmall)); foreach(explode(',', $this->config->task->edit->requiredFields) as $field) { $field = trim($field); @@ -1315,7 +1315,7 @@ class taskModel extends model } else { - die(js::error('task#' . $taskID . dao::getError(true))); + return print(js::error('task#' . $taskID . dao::getError(true))); } } if(!dao::isError()) $this->loadModel('score')->create('ajax', 'batchEdit'); @@ -1533,8 +1533,8 @@ class taskModel extends model if(!empty($record->work[$id]) or !empty($record->consumed[$id])) { - if(!$record->consumed[$id]) die(js::alert($this->lang->task->error->consumedThisTime)); - if($record->left[$id] === '') die(js::alert($this->lang->task->error->left)); + if(!$record->consumed[$id]) return print(js::alert($this->lang->task->error->consumedThisTime)); + if($record->left[$id] === '') return print(js::alert($this->lang->task->error->left)); $estimates[$id] = new stdclass(); $estimates[$id]->date = $record->dates[$id]; diff --git a/module/testcase/control.php b/module/testcase/control.php index a8607dfbc3..5ee331738e 100644 --- a/module/testcase/control.php +++ b/module/testcase/control.php @@ -61,7 +61,7 @@ class testcase extends control { $products = $this->product->getPairs(); } - if(empty($products) and !helper::isAjaxRequest()) die($this->locate($this->createLink('product', 'showErrorNone', "moduleName=$tab&activeMenu=testcase&objectID=$objectID"))); + if(empty($products) and !helper::isAjaxRequest()) return print($this->locate($this->createLink('product', 'showErrorNone', "moduleName=$tab&activeMenu=testcase&objectID=$objectID"))); } else { @@ -537,7 +537,7 @@ class testcase extends control $currentModule = $this->app->tab == 'project' ? 'project' : 'testcase'; $currentMethod = $this->app->tab == 'project' ? 'testcase' : 'browse'; $projectParam = $this->app->tab == 'project' ? "projectID={$this->session->project}&" : ''; - die(js::locate($this->createLink($currentModule, $currentMethod, $projectParam . "productID=$productID&branch=$branch&browseType=all¶m=0&orderBy=id_desc"), 'parent')); + return print(js::locate($this->createLink($currentModule, $currentMethod, $projectParam . "productID=$productID&branch=$branch&browseType=all¶m=0&orderBy=id_desc"), 'parent')); } if(empty($this->products)) $this->locate($this->createLink('product', 'create')); @@ -649,7 +649,7 @@ class testcase extends control $results = $this->testtask->getResults(0, $caseID); } - if(!$case) die(js::error($this->lang->notFound) . js::locate('back', 'parent')); + if(!$case) return print(js::error($this->lang->notFound) . js::locate('back', 'parent')); $this->view->title = $this->products[$productID] . $this->lang->colon . $this->lang->testcase->createBug; $this->view->runID = $runID; @@ -677,7 +677,7 @@ class testcase extends control if(!$case) { if(defined('RUN_MODE') && RUN_MODE == 'api') return $this->send(array('status' => 'fail', 'message' => '404 Not found')); - die(js::error($this->lang->notFound) . js::locate($this->createLink('qa', 'index'))); + return print(js::error($this->lang->notFound) . js::locate($this->createLink('qa', 'index'))); } if($case->auto == 'unit') { @@ -783,7 +783,7 @@ class testcase extends control if($comment == false) { $changes = $this->testcase->update($caseID); - if(dao::isError()) die(js::error(dao::getError())); + if(dao::isError()) return print(js::error(dao::getError())); $files = $this->loadModel('file')->saveUpload('testcase', $caseID); } if($this->post->comment != '' or !empty($changes) or !empty($files)) @@ -804,12 +804,12 @@ class testcase extends control } else { - die(js::locate($this->createLink('testcase', 'view', "caseID=$caseID"), 'parent')); + return print(js::locate($this->createLink('testcase', 'view', "caseID=$caseID"), 'parent')); } } $case = $this->testcase->getById($caseID); - if(!$case) die(js::error($this->lang->notFound) . js::locate('back')); + if(!$case) return print(js::error($this->lang->notFound) . js::locate('back')); if($case->auto == 'unit') { $this->lang->testcase->subMenu->testcase->feature['alias'] = ''; @@ -935,11 +935,11 @@ class testcase extends control } } - die(js::locate($this->session->caseList, 'parent')); + return print(js::locate($this->session->caseList, 'parent')); } - $caseIDList = $this->post->caseIDList ? $this->post->caseIDList : die(js::locate($this->session->caseList)); - $caseIDList = array_unique($caseIDList); + if(!$this->post->caseIDList) return print(js::locate($this->session->caseList)); + $caseIDList = array_unique($this->post->caseIDList); $branchProduct = false; if($this->app->tab == 'project') $this->loadModel('project')->setMenu($this->session->project); @@ -1085,7 +1085,7 @@ class testcase extends control if($_POST) { $changes = $this->testcase->review($caseID); - if(dao::isError()) die(js::error(dao::getError())); + if(dao::isError()) return print(js::error(dao::getError())); if($changes or $this->post->comment != '') { @@ -1096,7 +1096,7 @@ class testcase extends control $this->executeHooks($caseID); - die(js::reload('parent.parent')); + return print(js::reload('parent.parent')); } $this->view->users = $this->user->getPairs('noletter|noclosed|nodeleted'); @@ -1114,12 +1114,12 @@ class testcase extends control */ public function batchReview($result) { - $caseIdList = $this->post->caseIDList ? $this->post->caseIDList : die(js::locate($this->session->caseList, 'parent')); - $caseIdList = array_unique($caseIdList); + if(!$this->post->caseIDList) return print(js::locate($this->session->caseList, 'parent')); + $caseIdList = array_unique($this->post->caseIDList); $actions = $this->testcase->batchReview($caseIdList, $result); - if(dao::isError()) die(js::error(dao::getError())); - die(js::locate($this->session->caseList, 'parent')); + if(dao::isError()) return print(js::error(dao::getError())); + echo js::locate($this->session->caseList, 'parent'); } /** @@ -1134,7 +1134,7 @@ class testcase extends control { if($confirm == 'no') { - die(js::confirm($this->lang->testcase->confirmDelete, inlink('delete', "caseID=$caseID&confirm=yes"))); + return print(js::confirm($this->lang->testcase->confirmDelete, inlink('delete', "caseID=$caseID&confirm=yes"))); } else { @@ -1161,7 +1161,7 @@ class testcase extends control $locateLink = $this->session->caseList ? $this->session->caseList : inlink('browse', "productID={$case->product}"); if(defined('RUN_MODE') && RUN_MODE == 'api') return $this->send(array('status' => 'success')); - die(js::locate($locateLink, 'parent')); + return print(js::locate($locateLink, 'parent')); } } @@ -1174,11 +1174,11 @@ class testcase extends control */ public function batchDelete($productID = 0) { - $caseIDList = $this->post->caseIDList ? $this->post->caseIDList : die(js::locate($this->session->caseList)); - $caseIDList = array_unique($caseIDList); + if(!$this->post->caseIDList) return print(js::locate($this->session->caseList)); + $caseIDList = array_unique($this->post->caseIDList); foreach($caseIDList as $caseID) $this->testcase->delete(TABLE_CASE, $caseID); - die(js::locate($this->session->caseList)); + echo js::locate($this->session->caseList); } /** @@ -1196,7 +1196,7 @@ class testcase extends control $caseIDList = array_unique($caseIDList); unset($_POST['caseIDList']); $allChanges = $this->testcase->batchChangeBranch($caseIDList, $branchID); - if(dao::isError()) die(js::error(dao::getError())); + if(dao::isError()) return print(js::error(dao::getError())); foreach($allChanges as $caseID => $changes) { $this->loadModel('action'); @@ -1205,7 +1205,7 @@ class testcase extends control } } - die(js::locate($this->session->caseList, 'parent')); + echo js::locate($this->session->caseList, 'parent'); } /** @@ -1223,7 +1223,7 @@ class testcase extends control $caseIDList = array_unique($caseIDList); unset($_POST['caseIDList']); $allChanges = $this->testcase->batchChangeModule($caseIDList, $moduleID); - if(dao::isError()) die(js::error(dao::getError())); + if(dao::isError()) return print(js::error(dao::getError())); foreach($allChanges as $caseID => $changes) { $this->loadModel('action'); @@ -1232,7 +1232,7 @@ class testcase extends control } } - die(js::locate($this->session->caseList, 'parent')); + echo js::locate($this->session->caseList, 'parent'); } /** @@ -1244,12 +1244,12 @@ class testcase extends control */ public function batchCaseTypeChange($result) { - $caseIdList = $this->post->caseIDList ? $this->post->caseIDList : die(js::locate($this->session->caseList, 'parent')); + $caseIdList = $this->post->caseIDList ? $this->post->caseIDList : return print(js::locate($this->session->caseList, 'parent')); $caseIDList = array_unique($caseIDList); $this->testcase->batchCaseTypeChange($caseIdList, $result); - if(dao::isError()) die(js::error(dao::getError())); - die(js::locate($this->session->caseList, 'parent')); + if(dao::isError()) return print(js::error(dao::getError())); + echo js::locate($this->session->caseList, 'parent'); } /** @@ -1305,8 +1305,8 @@ class testcase extends control { $case = $this->testcase->getById($caseID); $this->dao->update(TABLE_TESTRUN)->set('version')->eq($case->version)->where('`case`')->eq($caseID)->exec(); - if($from == 'view') die(js::locate(inlink('view', "caseID=$caseID&version=$case->version&from=testtask&taskID=$taskID"), 'parent')); - die(js::reload('parent')); + if($from == 'view') return print(js::locate(inlink('view', "caseID=$caseID&version=$case->version&from=testtask&taskID=$taskID"), 'parent')); + echo js::reload('parent'); } /** @@ -1331,7 +1331,7 @@ class testcase extends control $step->version = $version; $this->dao->insert(TABLE_CASESTEP)->data($step)->exec(); } - die(js::locate($this->createLink('testcase', 'view', "caseID=$caseID&version=$version"), 'parent')); + echo js::locate($this->createLink('testcase', 'view', "caseID=$caseID&version=$version"), 'parent'); } /** @@ -1343,9 +1343,9 @@ class testcase extends control */ public function ignoreLibcaseChange($caseID) { - $case = $this->testcase->getById($caseID); + $case = $this->testcase->getById($caseID); $this->dao->update(TABLE_CASE)->set('fromCaseVersion')->eq($case->version)->where('id')->eq($caseID)->exec(); - die(js::reload('parent')); + echo js::reload('parent'); } /** @@ -1360,7 +1360,7 @@ class testcase extends control $case = $this->testcase->getById($caseID); $this->dao->update(TABLE_CASE)->set('storyVersion')->eq($case->latestStoryVersion)->where('id')->eq($caseID)->exec(); $this->loadModel('action')->create('case', $caseID, 'confirmed', '', $case->latestStoryVersion); - if($reload) die(js::reload('parent')); + if($reload) return print(js::reload('parent')); } /** @@ -1372,11 +1372,11 @@ class testcase extends control */ public function batchConfirmStoryChange($productID = 0) { - $caseIDList = $this->post->caseIDList ? $this->post->caseIDList : die(js::locate($this->session->caseList)); - $caseIDList = array_unique($caseIDList); + if(!$this->post->caseIDList) return print(js::locate($this->session->caseList)); + $caseIDList = array_unique($this->post->caseIDList); foreach($caseIDList as $caseID) $this->confirmStoryChange($caseID,false); - die(js::locate($this->session->caseList)); + echo js::locate($this->session->caseList); } /** @@ -1741,13 +1741,14 @@ class testcase extends control if(!isset($fields[$title])) continue; $columnKey[] = $fields[$title]; } - if(count($columnKey) == 0) die(js::alert($this->lang->testcase->errorEncode)); + if(count($columnKey) == 0) return print(js::alert($this->lang->testcase->errorEncode)); } $this->session->set('fileImport', $fileName); - die(js::locate(inlink('showImport', "productID=$productID&branch=$branch"), 'parent.parent')); + return print(js::locate(inlink('showImport', "productID=$productID&branch=$branch"), 'parent.parent')); } + $this->display(); } @@ -1777,7 +1778,7 @@ class testcase extends control if($_POST) { $this->testcase->importFromLib($productID); - die(js::reload('parent')); + return print(js::reload('parent')); } $this->app->tab == 'project' ? $this->loadModel('project')->setMenu($this->session->project) : $this->testcase->setMenu($this->products, $productID, $branch); @@ -1786,7 +1787,7 @@ class testcase extends control if(empty($libraries)) { echo js::alert($this->lang->testcase->noLibrary); - die(js::locate($this->session->caseList)); + return print(js::locate($this->session->caseList)); } if(empty($libID) or !isset($libraries[$libID])) $libID = key($libraries); @@ -1854,16 +1855,16 @@ class testcase extends control if($this->app->tab == 'project') { - die(js::locate($this->createLink('project', 'testcase', "projectID={$this->session->project}&productID=$productID"), 'parent')); + return print(js::locate($this->createLink('project', 'testcase', "projectID={$this->session->project}&productID=$productID"), 'parent')); } else { - die(js::locate(inlink('browse', "productID=$productID"), 'parent')); + return print(js::locate(inlink('browse', "productID=$productID"), 'parent')); } } else { - die(js::locate(inlink('showImport', "productID=$productID&branch=$branch&pagerID=" . ($this->post->pagerID + 1) . "&maxImport=$maxImport&insert=" . zget($_POST, 'insert', '')), 'parent')); + return print(js::locate(inlink('showImport', "productID=$productID&branch=$branch&pagerID=" . ($this->post->pagerID + 1) . "&maxImport=$maxImport&insert=" . zget($_POST, 'insert', '')), 'parent')); } } @@ -2030,7 +2031,7 @@ class testcase extends control if(empty($caseData)) { echo js::alert($this->lang->error->noData); - die(js::locate($this->createLink('testcase', 'browse', "productID=$productID&branch=$branch"))); + return print(js::locate($this->createLink('testcase', 'browse', "productID=$productID&branch=$branch"))); } $allCount = count($caseData); @@ -2043,13 +2044,13 @@ class testcase extends control $this->view->maxImport = $maxImport; $this->view->productID = $productID; $this->view->branch = $branch; - die($this->display()); + return print($this->display()); } $allPager = ceil($allCount / $maxImport); $caseData = array_slice($caseData, ($pagerID - 1) * $maxImport, $maxImport, true); } - if(empty($caseData)) die(js::locate(inlink('browse', "productID=$productID&branch=$branch"))); + if(empty($caseData)) return print(js::locate(inlink('browse', "productID=$productID&branch=$branch"))); /* Judge whether the editedCases is too large and set session. */ $countInputVars = count($caseData) * 12 + (isset($stepVars) ? $stepVars : 0); @@ -2105,7 +2106,7 @@ class testcase extends control { $story = $this->dao->select('module')->from(TABLE_STORY)->where('id')->eq($storyID)->fetch(); $moduleID = !empty($story) ? $story->module : 0; - die(json_encode(array('moduleID'=> $moduleID))); + echo json_encode(array('moduleID'=> $moduleID)); } /** @@ -2121,7 +2122,7 @@ class testcase extends control $case = $this->testcase->getByID($caseID); $status = $this->testcase->getStatus($methodName, $case); if($methodName == 'update') $status = zget($status, 1, ''); - die($status); + echo $status; } /** diff --git a/module/testcase/model.php b/module/testcase/model.php index d5d701742e..365372313a 100644 --- a/module/testcase/model.php +++ b/module/testcase/model.php @@ -115,7 +115,7 @@ class testcaseModel extends model foreach($cases->title as $i => $title) { - if(!empty($cases->title[$i]) and empty($cases->type[$i])) die(js::alert(sprintf($this->lang->error->notempty, $this->lang->testcase->type))); + if(!empty($cases->title[$i]) and empty($cases->type[$i])) return print(js::alert(sprintf($this->lang->error->notempty, $this->lang->testcase->type))); } $module = 0; @@ -176,13 +176,13 @@ class testcaseModel extends model $data[$i]->{$extendField->field} = htmlSpecialString($data[$i]->{$extendField->field}); $message = $this->checkFlowRule($extendField, $data[$i]->{$extendField->field}); - if($message) die(js::alert($message)); + if($message) return print(js::alert($message)); } foreach(explode(',', $this->config->testcase->create->requiredFields) as $field) { $field = trim($field); - if($field and empty($data[$i]->$field)) die(js::alert(sprintf($this->lang->error->notempty, $this->lang->testcase->$field))); + if($field and empty($data[$i]->$field)) return print(js::alert(sprintf($this->lang->error->notempty, $this->lang->testcase->$field))); } } @@ -197,7 +197,7 @@ class testcaseModel extends model if(dao::isError()) { echo js::error(dao::getError()); - die(js::reload('parent')); + return print(js::reload('parent')); } $caseID = $this->dao->lastInsertID(); @@ -793,7 +793,7 @@ class testcaseModel extends model */ public function review($caseID) { - if($this->post->result == false) die(js::alert($this->lang->testcase->mustChooseResult)); + if($this->post->result == false) return print(js::alert($this->lang->testcase->mustChooseResult)); $oldCase = $this->getById($caseID); @@ -932,7 +932,7 @@ class testcaseModel extends model $case->{$extendField->field} = htmlSpecialString($case->{$extendField->field}); $message = $this->checkFlowRule($extendField, $case->{$extendField->field}); - if($message) die(js::alert($message)); + if($message) return print(js::alert($message)); } $cases[$caseID] = $case; @@ -964,7 +964,7 @@ class testcaseModel extends model } else { - die(js::error('case#' . $caseID . dao::getError(true))); + return print(js::error('case#' . $caseID . dao::getError(true))); } } @@ -1199,7 +1199,7 @@ class testcaseModel extends model $cases[$key] = $caseData; $line++; } - if(dao::isError()) die(js::error(dao::getError())); + if(dao::isError()) return print(js::error(dao::getError())); $forceNotReview = $this->forceNotReview(); foreach($cases as $key => $caseData) @@ -1562,7 +1562,7 @@ class testcaseModel extends model else { $showBranch = isset($this->config->testcase->browse->showBranch) ? $this->config->testcase->browse->showBranch : 1; - } + } if(isset($branches[$case->branch]) and $showBranch) echo "{$branches[$case->branch]} "; if($modulePairs and $case->module and isset($modulePairs[$case->module])) echo "{$modulePairs[$case->module]} "; echo $canView ? ($fromCaseID ? html::a($caseLink, $case->title, null, "style='color: $case->color' data-app='{$this->app->tab}'") . html::a(helper::createLink('testcase', 'view', "caseID=$fromCaseID"), "[#$fromCaseID]", '', "data-app='{$this->app->tab}'") : html::a($caseLink, $case->title, null, "style='color: $case->color' data-app='{$this->app->tab}'")) : "$case->title"; diff --git a/module/testreport/control.php b/module/testreport/control.php index ca1c40d2e4..57e7b88168 100644 --- a/module/testreport/control.php +++ b/module/testreport/control.php @@ -64,7 +64,7 @@ class testreport extends control { $products = $this->product->getPairs(); } - if(empty($products) and !helper::isAjaxRequest()) die($this->locate($this->createLink('product', 'showErrorNone', "moduleName=$tab&activeMenu=testreport&objectID=$objectID"))); + if(empty($products) and !helper::isAjaxRequest()) return print($this->locate($this->createLink('product', 'showErrorNone', "moduleName=$tab&activeMenu=testreport&objectID=$objectID"))); } else { @@ -88,7 +88,7 @@ class testreport extends control */ public function browse($objectID = 0, $objectType = 'product', $extra = '', $orderBy = 'id_desc', $recTotal = 0, $recPerPage = 20, $pageID = 1) { - if(strpos('product|execution|project', $objectType) === false) die('Type Error!'); + if(strpos('product|execution|project', $objectType) === false) return print('Type Error!'); $objectID = $this->commonAction($objectID, $objectType); $object = $this->$objectType->getById($objectID); @@ -171,10 +171,10 @@ class testreport extends control if($_POST) { $reportID = $this->testreport->create(); - if(dao::isError()) die(js::error(dao::getError())); + if(dao::isError()) return print(js::error(dao::getError())); $this->loadModel('action')->create('testreport', $reportID, 'Opened'); if($this->viewType == 'json') return $this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess, 'id' => $reportID)); - die(js::locate(inlink('view', "reportID=$reportID"), 'parent')); + return print(js::locate(inlink('view', "reportID=$reportID"), 'parent')); } if($objectType == 'testtask') @@ -195,7 +195,7 @@ class testreport extends control if($testTask->build == 'trunk') continue; $taskPairs[$testTask->id] = $testTask->name; } - if(empty($taskPairs)) die(js::alert($this->lang->testreport->noTestTask) . js::locate('back')); + if(empty($taskPairs)) return print(js::alert($this->lang->testreport->noTestTask) . js::locate('back')); if(empty($objectID)) { @@ -209,10 +209,10 @@ class testreport extends control if($this->app->tab == 'project') $this->project->setMenu($task->project); } - if(empty($objectID)) die(js::alert($this->lang->testreport->noObjectID) . js::locate('back')); + if(empty($objectID)) return print(js::alert($this->lang->testreport->noObjectID) . js::locate('back')); if($objectType == 'testtask') { - if($productID != $task->product) die(js::error($this->lang->error->accessDenied) . js::locate('back')); + if($productID != $task->product) return print(js::error($this->lang->error->accessDenied) . js::locate('back')); $productIdList[$productID] = $productID; $begin = !empty($begin) ? date("Y-m-d", strtotime($begin)) : $task->begin; @@ -222,7 +222,7 @@ class testreport extends control if($task->build == 'trunk') { echo js::alert($this->lang->testreport->errorTrunk); - die(js::locate('back')); + return print(js::locate('back')); } else { @@ -246,7 +246,7 @@ class testreport extends control elseif($objectType == 'execution') { $executionID = $this->commonAction($objectID, $objectType); - if($executionID != $objectID) die(js::error($this->lang->error->accessDenied) . js::locate('back')); + if($executionID != $objectID) return print(js::error($this->lang->error->accessDenied) . js::locate('back')); $execution = $this->execution->getById($executionID); $tasks = $this->testtask->getExecutionTasks($executionID); @@ -270,7 +270,7 @@ class testreport extends control if(count($productIdList) > 1) { echo(js::alert($this->lang->testreport->moreProduct)); - die(js::locate('back')); + return print(js::locate('back')); } if($this->app->tab == 'qa') @@ -355,14 +355,14 @@ class testreport extends control if($_POST) { $changes = $this->testreport->update($reportID); - if(dao::isError()) die(js::error(dao::getError())); + if(dao::isError()) return print(js::error(dao::getError())); $files = $this->loadModel('file')->saveUpload('testreport', $reportID); $fileAction = !empty($files) ? $this->lang->addFiles . join(',', $files) . "\n" : ''; $actionID = $this->loadModel('action')->create('testreport', $reportID, 'Edited', $fileAction); if(!empty($changes)) $this->action->logHistory($actionID, $changes); - die(js::locate(inlink('view', "reportID=$reportID"), 'parent')); + return print(js::locate(inlink('view', "reportID=$reportID"), 'parent')); } $report = $this->testreport->getById($reportID); @@ -374,7 +374,7 @@ class testreport extends control { $product = $this->product->getById($report->product); $productID = $this->commonAction($report->product, 'product'); - if($productID != $report->product) die(js::error($this->lang->error->accessDenied) . js::locate('back')); + if($productID != $report->product) return print(js::error($this->lang->error->accessDenied) . js::locate('back')); $browseLink = inlink('browse', "objectID=$productID&objectType=product"); $this->view->position[] = html::a($browseLink, $product->name); @@ -385,12 +385,12 @@ class testreport extends control if($this->app->tab == 'execution') { $objectID = $this->commonAction($report->execution, 'execution'); - if($objectID != $report->execution) die(js::error($this->lang->error->accessDenied) . js::locate('back')); + if($objectID != $report->execution) return print(js::error($this->lang->error->accessDenied) . js::locate('back')); } else { $objectID = $this->commonAction($report->project, 'project'); - if($objectID != $report->project) die(js::error($this->lang->error->accessDenied) . js::locate('back')); + if($objectID != $report->project) return print(js::error($this->lang->error->accessDenied) . js::locate('back')); } $browseLink = inlink('browse', "objectID=$objectID&objectType=execution"); @@ -408,7 +408,7 @@ class testreport extends control if($task->build == 'trunk') { echo js::alert($this->lang->testreport->errorTrunk); - die(js::locate('back')); + return print(js::locate('back')); } else { @@ -483,7 +483,7 @@ class testreport extends control { $reportID = (int)$reportID; $report = $this->testreport->getById($reportID); - if(!$report) die(js::error($this->lang->notFound) . js::locate($this->createLink('qa', 'index'))); + if(!$report) return print(js::error($this->lang->notFound) . js::locate($this->createLink('qa', 'index'))); $this->session->project = $report->project; $browseLink = ''; @@ -492,7 +492,7 @@ class testreport extends control { $product = $this->product->getById($report->product); $productID = $this->commonAction($report->product, 'product'); - if($productID != $report->product) die(js::error($this->lang->error->accessDenied) . js::locate('back')); + if($productID != $report->product) return print(js::error($this->lang->error->accessDenied) . js::locate('back')); $browseLink = inlink('browse', "objectID=$productID&objectType=product"); $this->view->position[] = html::a($browseLink, $product->name); @@ -502,12 +502,12 @@ class testreport extends control if($this->app->tab == 'execution') { $objectID = $this->commonAction($report->execution, 'execution'); - if($objectID != $report->execution) die(js::error($this->lang->error->accessDenied) . js::locate('back')); + if($objectID != $report->execution) return print(js::error($this->lang->error->accessDenied) . js::locate('back')); } else { $objectID = $this->commonAction($report->project, 'project'); - if($objectID != $report->project) die(js::error($this->lang->error->accessDenied) . js::locate('back')); + if($objectID != $report->project) return print(js::error($this->lang->error->accessDenied) . js::locate('back')); } $browseLink = inlink('browse', "objectID=$objectID&objectType=execution"); @@ -589,7 +589,7 @@ class testreport extends control { if($confirm == 'no') { - die(js::confirm($this->lang->testreport->confirmDelete, inlink('delete', "reportID=$reportID&confirm=yes"))); + return print(js::confirm($this->lang->testreport->confirmDelete, inlink('delete', "reportID=$reportID&confirm=yes"))); } else { @@ -597,7 +597,7 @@ class testreport extends control $locateLink = $this->session->reportList ? $this->session->reportList : inlink('browse', "productID={$testreport->product}"); $this->testreport->delete(TABLE_TESTREPORT, $reportID); - die(js::locate($locateLink, 'parent')); + return print(js::locate($locateLink, 'parent')); } } diff --git a/module/testsuite/control.php b/module/testsuite/control.php index 3f9b6e4c6f..7d826b7982 100644 --- a/module/testsuite/control.php +++ b/module/testsuite/control.php @@ -32,7 +32,7 @@ class testsuite extends control parent::__construct($moduleName, $methodName); $this->view->products = $this->products = $this->loadModel('product')->getPairs(); - if(empty($this->products) and !helper::isAjaxRequest()) die($this->locate($this->createLink('product', 'showErrorNone', "moduleName=qa&activeMenu=testsuite"))); + if(empty($this->products) and !helper::isAjaxRequest()) return print($this->locate($this->createLink('product', 'showErrorNone', "moduleName=qa&activeMenu=testsuite"))); } /** @@ -158,8 +158,8 @@ class testsuite extends control /* Get test suite, and set menu. */ $suite = $this->testsuite->getById($suiteID, true); - if(!$suite) die(js::error($this->lang->notFound) . js::locate('back')); - if($suite->type == 'private' and $suite->addedBy != $this->app->user->account and !$this->app->user->admin) die(js::error($this->lang->error->accessDenied) . js::locate('back')); + if(!$suite) return print(js::error($this->lang->notFound) . js::locate('back')); + if($suite->type == 'private' and $suite->addedBy != $this->app->user->account and !$this->app->user->admin) return print(js::error($this->lang->error->accessDenied) . js::locate('back')); /* Set product session. */ $productID = $this->product->saveState($suite->product, $this->products); @@ -229,7 +229,7 @@ class testsuite extends control return $this->send($response); } - if($suite->type == 'private' and $suite->addedBy != $this->app->user->account and !$this->app->user->admin) die(js::error($this->lang->error->accessDenied) . js::locate('back')); + if($suite->type == 'private' and $suite->addedBy != $this->app->user->account and !$this->app->user->admin) return print(js::error($this->lang->error->accessDenied) . js::locate('back')); /* Set product session. */ $productID = $this->product->saveState($suite->product, $this->products); @@ -256,12 +256,12 @@ class testsuite extends control { if($confirm == 'no') { - die(js::confirm($this->lang->testsuite->confirmDelete, inlink('delete', "suiteID=$suiteID&confirm=yes"))); + return print(js::confirm($this->lang->testsuite->confirmDelete, inlink('delete', "suiteID=$suiteID&confirm=yes"))); } else { $suite = $this->testsuite->getById($suiteID); - if($suite->type == 'private' and $suite->addedBy != $this->app->user->account and !$this->app->user->admin) die(js::error($this->lang->error->accessDenied) . js::locate('back')); + if($suite->type == 'private' and $suite->addedBy != $this->app->user->account and !$this->app->user->admin) return print(js::error($this->lang->error->accessDenied) . js::locate('back')); $this->testsuite->delete($suiteID); @@ -282,7 +282,7 @@ class testsuite extends control } return $this->send($response); } - die(js::reload('parent')); + return print(js::reload('parent')); } } @@ -358,7 +358,7 @@ class testsuite extends control { if($confirm == 'no') { - die(js::confirm($this->lang->testsuite->confirmUnlinkCase, $this->createLink('testsuite', 'unlinkCase', "rowID=$rowID&confirm=yes"))); + return print(js::confirm($this->lang->testsuite->confirmUnlinkCase, $this->createLink('testsuite', 'unlinkCase', "rowID=$rowID&confirm=yes"))); } else { @@ -392,6 +392,6 @@ class testsuite extends control ->exec(); } - die(js::locate($this->createLink('testsuite', 'view', "suiteID=$suiteID"))); + return print(js::locate($this->createLink('testsuite', 'view', "suiteID=$suiteID"))); } } diff --git a/module/todo/control.php b/module/todo/control.php index 4cfe437bfd..0e6b5e22bf 100644 --- a/module/todo/control.php +++ b/module/todo/control.php @@ -46,7 +46,7 @@ class todo extends control if(!empty($_POST)) { $todoID = $this->todo->create($date, $account); - if(dao::isError()) die(js::error(dao::getError())); + if(dao::isError()) return print(js::error(dao::getError())); $this->loadModel('action')->create('todo', $todoID, 'opened'); $date = str_replace('-', '', $this->post->date); @@ -69,9 +69,9 @@ class todo extends control } if($this->viewType == 'json') return $this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess, 'id' => $todoID)); - if($this->viewType == 'xhtml') die(js::locate($this->createLink('todo', 'view', "todoID=$todoID", 'html'), 'parent')); - if(isonlybody()) die(js::closeModal('parent.parent')); - die(js::locate($this->createLink('my', 'todo', "type=all&userID=&status=all&orderBy=id_desc"), 'parent')); + if($this->viewType == 'xhtml') return print(js::locate($this->createLink('todo', 'view', "todoID=$todoID", 'html'), 'parent')); + if(isonlybody()) return print(js::closeModal('parent.parent')); + return print(js::locate($this->createLink('my', 'todo', "type=all&userID=&status=all&orderBy=id_desc"), 'parent')); } unset($this->lang->todo->typeList['cycle']); @@ -97,7 +97,7 @@ class todo extends control if(!empty($_POST)) { $todoIDList = $this->todo->batchCreate(); - if(dao::isError()) die(js::error(dao::getError())); + if(dao::isError()) return print(js::error(dao::getError())); /* Locate the browser. */ $date = str_replace('-', '', $this->post->date); @@ -111,8 +111,8 @@ class todo extends control } if($this->viewType == 'json') return $this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess, 'idList' => $todoIDList)); - if(isonlybody())die(js::reload('parent.parent')); - die(js::locate($this->createLink('my', 'todo', "type=$date"), 'parent')); + if(isonlybody()) return print(js::reload('parent.parent')); + return print(js::locate($this->createLink('my', 'todo', "type=$date"), 'parent')); } /* Set Custom*/ @@ -146,7 +146,7 @@ class todo extends control if(dao::isError()) { if(defined('RUN_MODE') && RUN_MODE == 'api') return $this->send(array('status' => 'fail', 'message' => dao::getError())); - die(js::error(dao::getError())); + return print(js::error(dao::getError())); } if($changes) { @@ -155,12 +155,12 @@ class todo extends control } if(defined('RUN_MODE') && RUN_MODE == 'api') return $this->send(array('status' => 'success')); - die(js::locate($this->session->todoList, 'parent.parent')); + return print(js::locate($this->session->todoList, 'parent.parent')); } /* Judge a private todo or not, If private, die. */ $todo = $this->todo->getById($todoID); - if($todo->private and $this->app->user->account != $todo->account) die('private'); + if($todo->private and $this->app->user->account != $todo->account) return print('private'); unset($this->lang->todo->typeList['cycle']); $todo->date = date("Y-m-d", strtotime($todo->date)); @@ -271,7 +271,7 @@ class todo extends control $this->action->logHistory($actionID, $changes); } - die(js::locate($this->session->todoList, 'parent')); + return print(js::locate($this->session->todoList, 'parent')); } } @@ -295,10 +295,11 @@ class todo extends control if($todo->type == 'task') $app = 'execution'; if($todo->type == 'story') $app = 'product'; $cancelURL = $this->server->HTTP_REFERER; - die(js::confirm(sprintf($this->lang->todo->$confirmNote, $todo->idvalue), $confirmURL, $cancelURL, $okTarget, 'parent', $app)); + return print(js::confirm(sprintf($this->lang->todo->$confirmNote, $todo->idvalue), $confirmURL, $cancelURL, $okTarget, 'parent', $app)); } - if(isonlybody())die(js::reload('parent.parent')); - die(js::reload('parent')); + + if(isonlybody())return print(js::reload('parent.parent')); + echo js::reload('parent'); } /** @@ -313,8 +314,8 @@ class todo extends control $todo = $this->todo->getById($todoID); if($todo->status == 'done' or $todo->status == 'closed') $this->todo->activate($todoID); if(defined('RUN_MODE') && RUN_MODE == 'api') return $this->send(array('status' => 'success')); - if(isonlybody()) die(js::reload('parent.parent')); - die(js::reload('parent')); + if(isonlybody()) return print(js::reload('parent.parent')); + echo js::reload('parent'); } /** @@ -329,8 +330,8 @@ class todo extends control { $todo = $this->todo->getById($todoID); if($todo->status == 'done') $this->todo->close($todoID); - if(isonlybody()) die(js::reload('parent.parent')); - die(js::reload('parent')); + if(isonlybody()) return print(js::reload('parent.parent')); + echo js::reload('parent'); } /** @@ -345,10 +346,10 @@ class todo extends control { if(!empty($_POST)) { - if(empty($_POST['assignedTo'])) die(js::error($this->lang->todo->noAssignedTo)); + if(empty($_POST['assignedTo'])) return print(js::error($this->lang->todo->noAssignedTo)); $this->todo->assignTo($todoID); - if(dao::isError()) die(js::error(dao::getError())); - die(js::reload('parent.parent')); + if(dao::isError()) return print(js::error(dao::getError())); + return print(js::reload('parent.parent')); } $this->view->todo = $this->todo->getById($todoID); @@ -373,7 +374,7 @@ class todo extends control if(!$todo) { if(defined('RUN_MODE') && RUN_MODE == 'api') return $this->send(array('status' => 'fail', 'message' => '404 Not found')); - die(js::error($this->lang->notFound) . js::locate('back')); + return print(js::error($this->lang->notFound) . js::locate('back')); } /* Save the session. */ if(!isonlybody()) @@ -450,10 +451,10 @@ class todo extends control } if(defined('RUN_MODE') && RUN_MODE == 'api') return $this->send(array('status' => 'success')); - if(isonlybody()) die(js::reload('parent.parent')); + if(isonlybody()) return print(js::reload('parent.parent')); $browseLink = $this->session->todoList ? $this->session->todoList : $this->createLink('my', 'todo'); - die(js::locate($browseLink, 'parent')); + return print(js::locate($browseLink, 'parent')); } } @@ -478,11 +479,11 @@ class todo extends control if($todo->type == 'story') $app = 'product'; $cancelURL = $this->server->HTTP_REFERER; if(defined('RUN_MODE') && RUN_MODE == 'api') return $this->send(array('status' => 'success', 'message' => sprintf($this->lang->todo->$confirmNote, $todo->idvalue), 'locate' => $confirmURL)); - die(js::confirm(sprintf($this->lang->todo->$confirmNote, $todo->idvalue), $confirmURL, $cancelURL, $okTarget, 'parent', $app)); + return print(js::confirm(sprintf($this->lang->todo->$confirmNote, $todo->idvalue), $confirmURL, $cancelURL, $okTarget, 'parent', $app)); } if(defined('RUN_MODE') && RUN_MODE == 'api') return $this->send(array('status' => 'success')); - if(isonlybody())die(js::reload('parent.parent')); - die(js::reload('parent')); + if(isonlybody()) return print(js::reload('parent.parent')); + echo js::reload('parent'); } /** @@ -500,7 +501,7 @@ class todo extends control $todo = $this->todo->getById($todoID); if($todo->status != 'done' && $todo->status != 'closed') $this->todo->finish($todoID); } - die(js::reload('parent')); + return print(js::reload('parent')); } } @@ -521,7 +522,7 @@ class todo extends control } if(!empty($waitIdList)) echo js::alert(sprintf($this->lang->todo->unfinishedTodo, implode(',', $waitIdList))); - die(js::reload('parent')); + echo js::reload('parent'); } /** @@ -654,7 +655,7 @@ class todo extends control { $table = $objectType == 'project' ? TABLE_PROJECT : TABLE_PRODUCT; $field = $objectType == 'project' ? 'parent' : 'program'; - die($this->dao->select($field)->from($table)->where('id')->eq($objectID)->fetch($field)); + echo $this->dao->select($field)->from($table)->where('id')->eq($objectID)->fetch($field); } /** @@ -671,7 +672,7 @@ class todo extends control $executions = $this->loadModel('execution')->getByProject($projectID, 'undone'); foreach($executions as $id => $execution) $executions[$id] = $execution->name; - die(html::select('execution', $executions, '', "class='form-control chosen'")); + echo html::select('execution', $executions, '', "class='form-control chosen'"); } /** @@ -686,7 +687,7 @@ class todo extends control $this->session->set('project', $projectID); $products = $this->loadModel('product')->getProductPairsByProject($projectID); - die(html::select('bugProduct', $products, '', "class='form-control chosen'")); + echo html::select('bugProduct', $products, '', "class='form-control chosen'"); } /** diff --git a/module/todo/model.php b/module/todo/model.php index d842163c4e..f863864f26 100644 --- a/module/todo/model.php +++ b/module/todo/model.php @@ -187,7 +187,7 @@ class todoModel extends model if(isset($object->title)) $todo->name = $object->title; } - if($todo->end < $todo->begin) die(js::alert(sprintf($this->lang->error->gt, $this->lang->todo->end, $this->lang->todo->begin))); + if($todo->end < $todo->begin) return print(js::alert(sprintf($this->lang->error->gt, $this->lang->todo->end, $this->lang->todo->begin))); $validTodos[] = $todo; } @@ -209,7 +209,7 @@ class todoModel extends model if(dao::isError()) { echo js::error(dao::getError()); - die(js::reload('parent')); + return print(js::reload('parent')); } $todoID = $this->dao->lastInsertID(); $todoIDList[] = $todoID; @@ -335,7 +335,7 @@ class todoModel extends model { $todo->idvalue = isset($data->{$this->config->todo->objectList[$todo->type]}[$todoID]) ? $data->{$this->config->todo->objectList[$todo->type]}[$todoID] : 0; } - if($todo->end < $todo->begin) die(js::alert(sprintf($this->lang->error->gt, $this->lang->todo->end, $this->lang->todo->begin))); + if($todo->end < $todo->begin) return print(js::alert(sprintf($this->lang->error->gt, $this->lang->todo->end, $this->lang->todo->begin))); $todos[$todoID] = $todo; } @@ -368,7 +368,7 @@ class todoModel extends model } else { - die(js::error('todo#' . $todoID . dao::getError(true))); + return print(js::error('todo#' . $todoID . dao::getError(true))); } } } diff --git a/module/tree/control.php b/module/tree/control.php index 8fb10b00d0..878886378a 100644 --- a/module/tree/control.php +++ b/module/tree/control.php @@ -339,7 +339,7 @@ class tree extends control $childs = $this->tree->getAllChildId($moduleID); foreach($childs as $childModuleID) unset($this->view->optionMenu[$childModuleID]); - die($this->display()); + $this->display(); } /** @@ -353,7 +353,7 @@ class tree extends control public function fix($root, $type) { $this->tree->fixModulePath($root, $type); - die(js::alert($this->lang->tree->successFixed) . js::reload('parent')); + echo js::alert($this->lang->tree->successFixed) . js::reload('parent'); } /** @@ -417,7 +417,7 @@ class tree extends control else { $result = $this->tree->delete($moduleID); - if(!$result) die(); + if(!$result) return; die(js::reload('parent')); } @@ -543,7 +543,7 @@ class tree extends control $moduleName = $viewType == 'bug' ? "modules[$number]" : "module[$number]"; $modules = empty($modules) ? array('' => '') : $modules; - die(html::select($moduleName, $modules, $currentModuleID, 'class=form-control')); + echo html::select($moduleName, $modules, $currentModuleID, 'class=form-control'); } /** @@ -563,6 +563,6 @@ class tree extends control ->andWhere('type')->eq($type) ->andWhere('deleted')->eq(0) ->fetchAll('id'); - die(json_encode($modules)); + echo json_encode($modules); } } diff --git a/module/tree/model.php b/module/tree/model.php index f904af3b41..b8d9e1b586 100644 --- a/module/tree/model.php +++ b/module/tree/model.php @@ -1565,7 +1565,7 @@ class treeModel extends model foreach($childs as $moduleID => $moduleName) { - if(preg_match('/(^\s+$)/', $moduleName)) die(js::alert($this->lang->tree->shouldNotBlank)); + if(preg_match('/(^\s+$)/', $moduleName)) return print(js::alert($this->lang->tree->shouldNotBlank)); } $module = new stdClass(); @@ -1573,7 +1573,7 @@ class treeModel extends model $module->type = $type; $module->parent = $parentModuleID; $repeatName = $this->checkUnique($module, $childs); - if($repeatName) die(js::alert(sprintf($this->lang->tree->repeatName, $repeatName))); + if($repeatName) return print(js::alert(sprintf($this->lang->tree->repeatName, $repeatName))); $parentModule = $this->getByID($parentModuleID); @@ -1651,7 +1651,7 @@ class treeModel extends model if(!isset($_POST['branch'])) $module->branch = $self->branch; $repeatName = $this->checkUnique($self, array("id{$self->id}" => $module->name), array("id{$self->id}" => $module->branch)); - if($repeatName) die(js::alert(sprintf($this->lang->tree->repeatName, $repeatName))); + if($repeatName) return print(js::alert(sprintf($this->lang->tree->repeatName, $repeatName))); $parent = $this->getById($this->post->parent); $childs = $this->getAllChildId($moduleID); diff --git a/module/tutorial/control.php b/module/tutorial/control.php index 91e1e8dde3..f09b4f00f4 100644 --- a/module/tutorial/control.php +++ b/module/tutorial/control.php @@ -73,7 +73,7 @@ class tutorial extends control $this->session->set('tutorialMode', false); $this->loadModel('setting')->setItem($this->app->user->account . '.common.global.novice', 0); if(empty($referer)) $referer = helper::safe64Encode(helper::createLink('my', 'index', '', 'html')); - die(js::locate(helper::safe64Decode($referer), 'parent')); + echo js::locate(helper::safe64Decode($referer), 'parent'); } /** @@ -86,7 +86,7 @@ class tutorial extends control { $this->session->set('tutorialMode', false); $this->loadModel('setting')->setItem($this->app->user->account . '.common.global.novice', 0); - die(json_encode(array('result' => 'success'))); + echo json_encode(array('result' => 'success')); } /** @@ -118,7 +118,7 @@ class tutorial extends control } } if(!$hasPriv and $module == 'my' and $method == 'index') $hasPriv = true; - if(!$hasPriv) die(js::locate('back')); + if(!$hasPriv) return print(js::locate('back')); $params = helper::safe64Decode($params); if($_POST) @@ -127,9 +127,9 @@ class tutorial extends control if(($module == 'story' or $module == 'task' or $module == 'bug') and $method == 'create') $target = 'self'; if($module == 'execution' and $method == 'linkStory') $target = 'self'; if($module == 'execution' and $method == 'managemembers') $target = 'self'; - die(js::locate(helper::createLink('tutorial', 'wizard', "module=$module&method=$method¶ms=" . helper::safe64Encode($params)), $target)); + return print(js::locate(helper::createLink('tutorial', 'wizard', "module=$module&method=$method¶ms=" . helper::safe64Encode($params)), $target)); } - die($this->fetch($module, $method, $params)); + echo $this->fetch($module, $method, $params); } /** @@ -144,7 +144,7 @@ class tutorial extends control public function ajaxSaveNovice($novice = 'true', $reload = 'false') { $this->loadModel('setting')->setItem($this->app->user->account . '.common.global.novice', $novice == true ? 1 : 0); - if($reload == 'true') die(js::reload('parent')); + if($reload == 'true') return print(js::reload('parent')); } /** diff --git a/module/upgrade/control.php b/module/upgrade/control.php index fc29abaa09..86d89b9705 100644 --- a/module/upgrade/control.php +++ b/module/upgrade/control.php @@ -127,7 +127,7 @@ class upgrade extends control $this->view->result = 'fail'; $this->view->errors = $result; - die($this->display()); + return $this->display()); } $fromVersion = isset($_POST['fromVersion']) ? $this->post->fromVersion : $fromVersion; @@ -265,7 +265,7 @@ class upgrade extends control /* Create Program. */ list($programID, $projectList, $lineID) = $this->upgrade->createProgram($linkedProducts, $linkedSprints); - if(dao::isError()) die(js::error(dao::getError())); + if(dao::isError()) return print(js::error(dao::getError())); /* Process merged products and projects. */ if($_POST['projectType'] == 'execution') @@ -317,7 +317,7 @@ class upgrade extends control /* Create Program. */ list($programID, $projectList, $lineID) = $this->upgrade->createProgram($linkedProducts, $linkedSprints); - if(dao::isError()) die(js::error(dao::getError())); + if(dao::isError()) return print(js::error(dao::getError())); /* Process productline. */ $this->dao->delete()->from(TABLE_MODULE)->where('`root`')->eq(0)->andWhere('`type`')->eq('line')->exec(); @@ -347,7 +347,7 @@ class upgrade extends control /* Create Program. */ list($programID, $projectList, $lineID) = $this->upgrade->createProgram(array(), $linkedSprints); - if(dao::isError()) die(js::error(dao::getError())); + if(dao::isError()) return print(js::error(dao::getError())); if($_POST['projectType'] == 'execution') { @@ -369,7 +369,7 @@ class upgrade extends control /* Create Program. */ list($programID, $projectList, $lineID) = $this->upgrade->createProgram(array(), $linkedSprints); - if(dao::isError()) die(js::error(dao::getError())); + if(dao::isError()) return print(js::error(dao::getError())); if($_POST['projectType'] == 'execution') { @@ -401,7 +401,7 @@ class upgrade extends control } } - die(js::locate($this->createLink('upgrade', 'mergeProgram', "type=$type&programID=$programID&projectType=$projectType"), 'parent')); + return print(js::locate($this->createLink('upgrade', 'mergeProgram', "type=$type&programID=$programID&projectType=$projectType"), 'parent')); } /* Get no merged product and project count. */ @@ -423,7 +423,7 @@ class upgrade extends control /* Update sprints history. */ $sprints = $this->dao->select('id')->from(TABLE_PROJECT)->where('type')->eq('sprint')->fetchAll('id'); $this->dao->update(TABLE_ACTION)->set('objectType')->eq('execution')->where('objectID')->in(array_keys($sprints))->andWhere('objectType')->eq('project')->exec(); - die(js::locate($this->createLink('upgrade', 'mergeRepo'))); + return print(js::locate($this->createLink('upgrade', 'mergeRepo'))); } $this->view->noMergedProductCount = $noMergedProductCount; @@ -622,7 +622,7 @@ class upgrade extends control $this->dao->update(TABLE_PROJECT)->set('name')->eq($projectName)->where('id')->eq($projectID)->exec(); } - die(js::closeModal('parent.parent', '')); + return print(js::closeModal('parent.parent', '')); } $objectGroup = array(); @@ -649,7 +649,7 @@ class upgrade extends control if($_POST) { $this->upgrade->mergeRepo(); - die(js::locate($this->createLink('upgrade', 'mergeRepo'), 'parent')); + return print(js::locate($this->createLink('upgrade', 'mergeRepo'), 'parent')); } $repoes = $this->dao->select('id, name')->from(TABLE_REPO)->where('deleted')->eq(0)->andWhere('product')->eq('')->fetchPairs(); @@ -659,7 +659,7 @@ class upgrade extends control $this->dao->delete()->from(TABLE_BLOCK)->exec(); $this->dao->delete()->from(TABLE_CONFIG)->where('`key`')->eq('blockInited')->exec(); $this->loadModel('setting')->deleteItems('owner=system&module=common§ion=global&key=upgradeStep'); - die(js::locate($this->createLink('upgrade', 'afterExec', "fromVersion=&processed=no"))); + return print(js::locate($this->createLink('upgrade', 'afterExec', "fromVersion=&processed=no"))); } $this->view->title = $this->lang->upgrade->mergeRepo; @@ -680,7 +680,7 @@ class upgrade extends control public function ajaxGetProjectPairsByProgram($programID = 0) { $projects = array('' => '') + $this->upgrade->getProjectPairsByProgram($programID); - die(html::select('projects', $projects, '', 'class="form-control prj-exist" onchange="getProgramStatus(\'project\', this.value)"')); + echo html::select('projects', $projects, '', 'class="form-control prj-exist" onchange="getProgramStatus(\'project\', this.value)"'); } /** @@ -694,7 +694,7 @@ class upgrade extends control { $lines = array('' => ''); if((int)$programID) $lines += $this->loadModel('product')->getLinePairs($programID); - die(html::select('lines', $lines, '', 'class="form-control line-exist"')); + echo html::select('lines', $lines, '', 'class="form-control line-exist"'); } /** @@ -712,7 +712,7 @@ class upgrade extends control { $this->view->title = $this->lang->upgrade->consistency; $this->view->alterSQL = $alterSQL; - die($this->display('upgrade', 'consistency')); + return print($this->display('upgrade', 'consistency')); } unset($_SESSION['user']); @@ -837,7 +837,7 @@ class upgrade extends control $response['nextType'] = $result['type']; $response['message'] = zget($this->lang->searchObjects, $result['type']) . " 0"; } - die(json_encode($response)); + echo json_encode($response); } /** @@ -849,7 +849,7 @@ class upgrade extends control */ public function ajaxGetProductName($productID) { - die($this->dao->findByID($productID)->from(TABLE_PRODUCT)->fetch('name')); + echo $this->dao->findByID($productID)->from(TABLE_PRODUCT)->fetch('name'); } /** @@ -861,6 +861,6 @@ class upgrade extends control */ public function ajaxGetProgramStatus($programID) { - die($this->dao->select('status')->from(TABLE_PROGRAM)->where('id')->eq($programID)->fetch('status')); + echo $this->dao->select('status')->from(TABLE_PROGRAM)->where('id')->eq($programID)->fetch('status'); } } diff --git a/module/upgrade/model.php b/module/upgrade/model.php index 458aa13d3b..5613522b16 100644 --- a/module/upgrade/model.php +++ b/module/upgrade/model.php @@ -4364,9 +4364,9 @@ class upgradeModel extends model if(isset($data->newProgram)) { - if(!$this->post->longTime and !$this->post->end and isset($data->begin)) die(js::alert(sprintf($this->lang->error->notempty, $this->lang->upgrade->end))); + if(!$this->post->longTime and !$this->post->end and isset($data->begin)) return print(js::alert(sprintf($this->lang->error->notempty, $this->lang->upgrade->end))); - if(isset($data->projectName) and $data->projectType == 'execution' and empty($data->projectName)) die(js::alert(sprintf($this->lang->error->notempty, $this->lang->upgrade->projectName))); + if(isset($data->projectName) and $data->projectType == 'execution' and empty($data->projectName)) return print(js::alert(sprintf($this->lang->error->notempty, $this->lang->upgrade->projectName))); /* Insert program. */ $program = new stdclass(); @@ -4445,7 +4445,7 @@ class upgradeModel extends model if(isset($data->newProject)) { - if(!$this->post->longTime and !$this->post->end) die(js::alert(sprintf($this->lang->error->notempty, $this->lang->upgrade->end))); + if(!$this->post->longTime and !$this->post->end) return print(js::alert(sprintf($this->lang->error->notempty, $this->lang->upgrade->end))); /* Create a project. */ $this->loadModel('action'); @@ -4618,7 +4618,7 @@ class upgradeModel extends model /* No project is created when there are no sprints. */ if(!$sprintIdList) return; - if(!$projectID) die(js::alert($this->lang->upgrade->projectEmpty)); + if(!$projectID) return print(js::alert($this->lang->upgrade->projectEmpty)); $this->dao->update(TABLE_BUG)->set('project')->eq($projectID)->where('product')->in($productIdList)->exec(); $this->dao->update(TABLE_TESTREPORT)->set('project')->eq($projectID)->where('product')->in($productIdList)->exec(); diff --git a/module/user/control.php b/module/user/control.php index 21651689b9..17dbd92726 100644 --- a/module/user/control.php +++ b/module/user/control.php @@ -60,8 +60,8 @@ class user extends control { $userID = (int)$userID; $user = $this->user->getById($userID, 'id'); - if(empty($user)) die(js::error($this->lang->notFound) . js::locate($this->createLink('my', 'team'))); - if($user->deleted == 1) die(js::error($this->lang->user->noticeHasDeleted) . js::locate('back')); + if(empty($user)) return print(js::error($this->lang->notFound) . js::locate($this->createLink('my', 'team'))); + if($user->deleted == 1) return print(js::error($this->lang->user->noticeHasDeleted) . js::locate('back')); /* Set thie url to session. */ $uri = $this->app->getURI(true); @@ -81,7 +81,7 @@ class user extends control $todos = $this->todo->getList($type, $account, $status, 0, $pager, $sort); $date = (int)$type == 0 ? helper::today() : $type; $users = $this->loadModel('dept')->getDeptUserPairs($this->app->user->dept, 'id'); - if(!isset($users[$userID])) die(js::error($this->lang->user->error->noAccess) . js::locate('back')); + if(!isset($users[$userID])) return print(js::error($this->lang->user->error->noAccess) . js::locate('back')); /* set menus. */ $this->view->userList = $this->user->setUserList($users, $userID); @@ -573,7 +573,7 @@ class user extends control $userIDList = $this->user->batchCreate(); if($this->viewType == 'json') return $this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess, 'idList' => $userIDList)); - die(js::locate($this->createLink('company', 'browse'), 'parent')); + return print(js::locate($this->createLink('company', 'browse'), 'parent')); } /* Set custom. */ @@ -654,7 +654,7 @@ class user extends control elseif($_POST) { if($this->post->account) $this->user->batchEdit(); - die(js::locate($this->session->userList ? $this->session->userList : $this->createLink('company', 'browse', "deptID=$deptID"), 'parent')); + return print(js::locate($this->session->userList ? $this->session->userList : $this->createLink('company', 'browse', "deptID=$deptID"), 'parent')); } $this->lang->user->menu = $this->lang->company->menu; $this->lang->user->menuOrder = $this->lang->company->menuOrder; @@ -693,7 +693,7 @@ class user extends control if($this->app->user->admin and $this->app->user->account == $user->account) return; if($_POST) { - if($this->post->verifyPassword != md5($this->app->user->password . $this->session->rand)) die(js::alert($this->lang->user->error->verifyPassword)); + if($this->post->verifyPassword != md5($this->app->user->password . $this->session->rand)) return print(js::alert($this->lang->user->error->verifyPassword)); $this->user->delete(TABLE_USER, $userID); if(!dao::isError()) { @@ -716,7 +716,7 @@ class user extends control } return $this->send($response); } - die(js::locate($this->session->userList, 'parent.parent')); + return print(js::locate($this->session->userList, 'parent.parent')); } $this->view->rand = $this->user->updateSessionRandom(); @@ -734,11 +734,11 @@ class user extends control */ public function unlock($userID, $confirm = 'no') { - if($confirm == 'no') die(js::confirm($this->lang->user->confirmUnlock, $this->createLink('user', 'unlock', "userID=$userID&confirm=yes"))); + if($confirm == 'no') return print(js::confirm($this->lang->user->confirmUnlock, $this->createLink('user', 'unlock', "userID=$userID&confirm=yes"))); $user = $this->user->getById($userID, 'id'); $this->user->cleanLocked($user->account); - die(js::locate($this->session->userList ? $this->session->userList : $this->createLink('company', 'browse'), 'parent')); + return print(js::locate($this->session->userList ? $this->session->userList : $this->createLink('company', 'browse'), 'parent')); } /** @@ -751,11 +751,11 @@ class user extends control */ public function unbind($userID, $confirm = 'no') { - if($confirm == 'no') die(js::confirm($this->lang->user->confirmUnbind, $this->createLink('user', 'unbind', "userID=$userID&confirm=yes"))); + if($confirm == 'no') return print(js::confirm($this->lang->user->confirmUnbind, $this->createLink('user', 'unbind', "userID=$userID&confirm=yes"))); $user = $this->user->getById($userID, 'id'); $this->user->unbind($user->account); - die(js::locate($this->session->userList ? $this->session->userList : $this->createLink('company', 'browse'), 'parent')); + return print(js::locate($this->session->userList ? $this->session->userList : $this->createLink('company', 'browse'), 'parent')); } @@ -787,11 +787,11 @@ class user extends control { if(strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') { - die(sprintf($this->lang->user->mkdirWin, $floderPath, $floderPath)); + return print(sprintf($this->lang->user->mkdirWin, $floderPath, $floderPath)); } else { - die(sprintf($this->lang->user->mkdirLinux, $floderPath, $floderPath, $floderPath, $floderPath)); + return print(sprintf($this->lang->user->mkdirLinux, $floderPath, $floderPath, $floderPath, $floderPath)); } } @@ -813,7 +813,7 @@ class user extends control if($this->app->getViewType() == 'json') { $data = $this->user->getDataInJSON($this->app->user); - die(helper::removeUTF8Bom(json_encode(array('status' => 'success') + $data))); + return print(helper::removeUTF8Bom(json_encode(array('status' => 'success') + $data))); } $response['result'] = 'success'; @@ -847,7 +847,7 @@ class user extends control { $response['result'] = 'fail'; $response['message'] = sprintf($this->lang->user->loginLocked, $this->config->user->lockMinutes); - if($this->app->getViewType() == 'json') die(helper::removeUTF8Bom(json_encode(array('status' => 'failed', 'reason' => $failReason)))); + if($this->app->getViewType() == 'json') return print(helper::removeUTF8Bom(json_encode(array('status' => 'failed', 'reason' => $failReason)))); return $this->send($response); } @@ -871,7 +871,7 @@ class user extends control if($this->app->getViewType() == 'json') { $data = $this->user->getDataInJSON($user); - die(helper::removeUTF8Bom(json_encode(array('status' => 'success') + $data))); + return print(helper::removeUTF8Bom(json_encode(array('status' => 'success') + $data))); } /* Get the module and method of the referer. */ @@ -911,7 +911,7 @@ class user extends control if($this->app->getViewType() == 'json') { $data = $this->user->getDataInJSON($user); - die(helper::removeUTF8Bom(json_encode(array('status' => 'success') + $data))); + return print(helper::removeUTF8Bom(json_encode(array('status' => 'success') + $data))); } $response['locate'] = $this->config->webRoot; @@ -923,7 +923,7 @@ class user extends control { $response['result'] = 'fail'; $fails = $this->user->failPlus($account); - if($this->app->getViewType() == 'json') die(helper::removeUTF8Bom(json_encode(array('status' => 'failed', 'reason' => $this->lang->user->loginFailed)))); + if($this->app->getViewType() == 'json') return print(helper::removeUTF8Bom(json_encode(array('status' => 'failed', 'reason' => $this->lang->user->loginFailed)))); $remainTimes = $this->config->user->failTimes - $fails; if($remainTimes <= 0) { @@ -993,7 +993,7 @@ class user extends control $this->view->denyType = $denyType; - die($this->display()); + $this->display(); } /** @@ -1009,7 +1009,7 @@ class user extends control setcookie('za', false); setcookie('zp', false); - if($this->app->getViewType() == 'json') die(json_encode(array('status' => 'success'))); + if($this->app->getViewType() == 'json') return print(json_encode(array('status' => 'success'))); $vars = !empty($referer) ? "referer=$referer" : ''; $this->locate($this->createLink('user', 'login', $vars)); } @@ -1035,15 +1035,15 @@ class user extends control if($_POST) { - if($needCreateFile) die(js::reload('parent')); + if($needCreateFile) return print(js::reload('parent')); $result = $this->user->resetPassword(); - if(dao::isError()) die(js::error(dao::getError())); - if(!$result) die(js::alert($this->lang->user->resetFail)); + if(dao::isError()) return print(js::error(dao::getError())); + if(!$result) return print(js::alert($this->lang->user->resetFail)); echo js::alert($this->lang->user->resetSuccess); $referer = helper::safe64Encode($this->createLink('index', 'index')); - die(js::locate(inlink('logout', 'referer=' . $referer), 'parent')); + return print(js::locate(inlink('logout', 'referer=' . $referer), 'parent')); } /* Remove the real path for security reason. */ @@ -1229,7 +1229,7 @@ class user extends control { $this->user->saveUserTemplate($type); if(dao::isError()) echo js::error(dao::getError(), $full = false); - die($this->fetch('user', 'ajaxPrintTemplates', "type=$type")); + return print($this->fetch('user', 'ajaxPrintTemplates', "type=$type")); } /** @@ -1244,7 +1244,6 @@ class user extends control $this->dao->delete()->from(TABLE_USERTPL)->where('id')->eq($templateID) ->beginIF(!$this->app->user->admin)->andWhere('account')->eq($this->app->user->account)->fi() ->exec(); - die(); } /** @@ -1272,7 +1271,7 @@ class user extends control $newUsers[$account] = $realname; } - die(json_encode($newUsers)); + echo json_encode($newUsers); } /** @@ -1284,6 +1283,6 @@ class user extends control public function refreshRandom() { $rand = (string)$this->user->updateSessionRandom(); - die($rand); + echo $rand; } } diff --git a/module/user/model.php b/module/user/model.php index 0d09c394ec..b609bda207 100644 --- a/module/user/model.php +++ b/module/user/model.php @@ -375,7 +375,7 @@ class userModel extends model */ public function batchCreate() { - if(empty($_POST['verifyPassword']) or $this->post->verifyPassword != md5($this->app->user->password . $this->session->rand)) die(js::alert($this->lang->user->error->verifyPassword)); + if(empty($_POST['verifyPassword']) or $this->post->verifyPassword != md5($this->app->user->password . $this->session->rand)) return print(js::alert($this->lang->user->error->verifyPassword)); $users = fixer::input('post')->get(); $data = array(); @@ -385,24 +385,24 @@ class userModel extends model $users->account[$i] = trim($users->account[$i]); if($users->account[$i] != '') { - if(strtolower($users->account[$i]) == 'guest') die(js::error(sprintf($this->lang->user->error->reserved, $i + 1))); + if(strtolower($users->account[$i]) == 'guest') return print(js::error(sprintf($this->lang->user->error->reserved, $i + 1))); $account = $this->dao->select('account')->from(TABLE_USER)->where('account')->eq($users->account[$i])->fetch(); - if($account) die(js::error(sprintf($this->lang->user->error->accountDupl, $i + 1))); - if(in_array($users->account[$i], $accounts)) die(js::error(sprintf($this->lang->user->error->accountDupl, $i + 1))); - if(!validater::checkAccount($users->account[$i])) die(js::error(sprintf($this->lang->user->error->account, $i + 1))); - if($users->realname[$i] == '') die(js::error(sprintf($this->lang->user->error->realname, $i + 1))); - if($users->email[$i] and !validater::checkEmail($users->email[$i])) die(js::error(sprintf($this->lang->user->error->mail, $i + 1))); + if($account) return print(js::error(sprintf($this->lang->user->error->accountDupl, $i + 1))); + if(in_array($users->account[$i], $accounts)) return print(js::error(sprintf($this->lang->user->error->accountDupl, $i + 1))); + if(!validater::checkAccount($users->account[$i])) return print(js::error(sprintf($this->lang->user->error->account, $i + 1))); + if($users->realname[$i] == '') return print(js::error(sprintf($this->lang->user->error->realname, $i + 1))); + if($users->email[$i] and !validater::checkEmail($users->email[$i])) return print(js::error(sprintf($this->lang->user->error->mail, $i + 1))); $users->password[$i] = (isset($prev['password']) and $users->ditto[$i] == 'on' and !$this->post->password[$i]) ? $prev['password'] : $this->post->password[$i]; - if(!validater::checkReg($users->password[$i], '|(.){6,}|')) die(js::error(sprintf($this->lang->user->error->password, $i + 1))); + if(!validater::checkReg($users->password[$i], '|(.){6,}|')) return print(js::error(sprintf($this->lang->user->error->password, $i + 1))); $role = $users->role[$i] == 'ditto' ? (isset($prev['role']) ? $prev['role'] : '') : $users->role[$i]; $visions = in_array('ditto', $users->visions[$i]) ? (isset($prev['visions']) ? $prev['visions'] : array()) : $users->visions[$i]; /* Check weak and common weak password. */ - if(isset($this->config->safe->mode) and $this->computePasswordStrength($users->password[$i]) < $this->config->safe->mode) die(js::error(sprintf($this->lang->user->error->weakPassword, $i + 1))); + if(isset($this->config->safe->mode) and $this->computePasswordStrength($users->password[$i]) < $this->config->safe->mode) return print(js::error(sprintf($this->lang->user->error->weakPassword, $i + 1))); if(!empty($this->config->safe->changeWeak)) { if(!isset($this->config->safe->weak)) $this->app->loadConfig('admin'); - if(strpos(",{$this->config->safe->weak},", ",{$users->password[$i]},") !== false) die(js::error(sprintf($this->lang->user->error->dangerPassword, $i + 1, $this->config->safe->weak))); + if(strpos(",{$this->config->safe->weak},", ",{$users->password[$i]},") !== false) return print(js::error(sprintf($this->lang->user->error->dangerPassword, $i + 1, $this->config->safe->weak))); } $data[$i] = new stdclass(); @@ -438,7 +438,7 @@ class userModel extends model if(!isset($data[$i]->$field)) continue; if(!empty($data[$i]->$field)) continue; - die(js::error(sprintf($this->lang->error->notempty, $this->lang->user->$field))); + return print(js::error(sprintf($this->lang->error->notempty, $this->lang->user->$field))); } /* Change for append field, such as feedback. */ @@ -485,7 +485,7 @@ class userModel extends model if(dao::isError()) { echo js::error(dao::getError()); - die(js::reload('parent')); + return print(js::reload('parent')); } else { @@ -638,7 +638,7 @@ class userModel extends model public function batchEdit() { $data = fixer::input('post')->get(); - if(empty($_POST['verifyPassword']) or $this->post->verifyPassword != md5($this->app->user->password . $this->session->rand)) die(js::alert($this->lang->user->error->verifyPassword)); + if(empty($_POST['verifyPassword']) or $this->post->verifyPassword != md5($this->app->user->password . $this->session->rand)) return print(js::alert($this->lang->user->error->verifyPassword)); $oldUsers = $this->dao->select('id, account, email')->from(TABLE_USER)->where('id')->in(array_keys($data->account))->fetchAll('id'); $accountGroup = $this->dao->select('id, account')->from(TABLE_USER)->where('account')->in($data->account)->fetchGroup('account', 'id'); @@ -675,7 +675,7 @@ class userModel extends model if(!isset($users[$id][$field])) continue; if(!empty($users[$id][$field])) continue; - die(js::error(sprintf($this->lang->error->notempty, $this->lang->user->$field))); + return print(js::error(sprintf($this->lang->error->notempty, $this->lang->user->$field))); } if(!empty($this->config->user->batchAppendFields)) @@ -690,11 +690,11 @@ class userModel extends model } } - if(isset($accountGroup[$account]) and count($accountGroup[$account]) > 1) die(js::error(sprintf($this->lang->user->error->accountDupl, $id))); - if(in_array($account, $accounts)) die(js::error(sprintf($this->lang->user->error->accountDupl, $id))); - if(!validater::checkAccount($users[$id]['account'])) die(js::error(sprintf($this->lang->user->error->account, $id))); - if($users[$id]['realname'] == '') die(js::error(sprintf($this->lang->user->error->realname, $id))); - if($users[$id]['email'] and !validater::checkEmail($users[$id]['email'])) die(js::error(sprintf($this->lang->user->error->mail, $id))); + if(isset($accountGroup[$account]) and count($accountGroup[$account]) > 1) return print(js::error(sprintf($this->lang->user->error->accountDupl, $id))); + if(in_array($account, $accounts)) return print(js::error(sprintf($this->lang->user->error->accountDupl, $id))); + if(!validater::checkAccount($users[$id]['account'])) return print(js::error(sprintf($this->lang->user->error->account, $id))); + if($users[$id]['realname'] == '') return print(js::error(sprintf($this->lang->user->error->realname, $id))); + if($users[$id]['email'] and !validater::checkEmail($users[$id]['email'])) return print(js::error(sprintf($this->lang->user->error->mail, $id))); $accounts[$id] = $account; $prev['dept'] = $users[$id]['dept']; @@ -1406,13 +1406,13 @@ class userModel extends model if(empty($data->listName)) { dao::$errors['listName'][] = sprintf($this->lang->error->notempty, $this->lang->user->contacts->listName); - die(js::error(dao::getError())); + return print(js::error(dao::getError())); } $this->dao->insert(TABLE_USERCONTACT)->data($data) ->autoCheck() ->exec(); - if(dao::isError()) die(js::error(dao::getError())); + if(dao::isError()) return print(js::error(dao::getError())); return $this->dao->lastInsertID(); } @@ -1435,13 +1435,13 @@ class userModel extends model if(empty($data->listName)) { dao::$errors['listName'][] = sprintf($this->lang->error->notempty, $this->lang->user->contacts->listName); - die(js::error(dao::getError())); + return print(js::error(dao::getError())); } $this->dao->update(TABLE_USERCONTACT)->data($data) ->where('id')->eq($listID) ->exec(); - if(dao::isError()) die(js::error(dao::getError())); + if(dao::isError()) return print(js::error(dao::getError())); } /** diff --git a/module/webhook/control.php b/module/webhook/control.php index d9e9c14268..1cef0ff5c0 100644 --- a/module/webhook/control.php +++ b/module/webhook/control.php @@ -181,16 +181,16 @@ class webhook extends control if($_POST) { $this->webhook->bind($id); - if(dao::isError()) die(js::error(dao::getError())); + if(dao::isError()) return print(js::error(dao::getError())); - die(js::reload('parent')); + return print(js::reload('parent')); } $webhook = $this->webhook->getById($id); if($webhook->type != 'dinguser' && $webhook->type != 'wechatuser' && $webhook->type != 'feishuuser') { echo js::alert($this->lang->webhook->note->bind); - die(js::locate($this->createLink('webhook', 'browse'))); + return print(js::locate($this->createLink('webhook', 'browse'))); } $webhook->secret = json_decode($webhook->secret); @@ -226,11 +226,11 @@ class webhook extends control if($response['message'] == 'nodept') { echo js::error($this->lang->webhook->error->noDept); - die(js::locate($this->createLink('webhook', 'chooseDept', "id=$id"))); + return print(js::locate($this->createLink('webhook', 'chooseDept', "id=$id"))); } echo js::error($response['message']); - die(js::locate($this->createLink('webhook', 'browse'))); + return print(js::locate($this->createLink('webhook', 'browse'))); } $oauthUsers = $response['data']; @@ -278,7 +278,7 @@ class webhook extends control if($webhook->type != 'dinguser' && $webhook->type != 'wechatuser' && $webhook->type != 'feishuuser') { echo js::alert($this->lang->webhook->note->bind); - die(js::locate($this->createLink('webhook', 'browse'))); + return print(js::locate($this->createLink('webhook', 'browse'))); } $webhook->secret = json_decode($webhook->secret); @@ -299,7 +299,7 @@ class webhook extends control if($response['result'] == 'fail') { echo js::error($response['message']); - die(js::locate($this->createLink('webhook', 'browse'))); + return print(js::locate($this->createLink('webhook', 'browse'))); } if($response['result'] == 'selected') @@ -307,7 +307,7 @@ class webhook extends control $locateLink = $this->createLink('webhook', 'bind', "id={$id}"); $locateLink .= strpos($locateLink, '?') !== false ? '&' : '?'; $locateLink .= 'selectedDepts=' . join(',', $response['data']); - die(js::locate($locateLink)); + return print(js::locate($locateLink)); } $this->view->title = $this->lang->webhook->chooseDept; diff --git a/module/webhook/model.php b/module/webhook/model.php index 2d596eba17..e8638e0df5 100644 --- a/module/webhook/model.php +++ b/module/webhook/model.php @@ -640,7 +640,7 @@ class webhookModel extends model */ public function fetchHook($webhook, $sendData, $actionID = 0) { - if(!extension_loaded('curl')) die(helper::jsonEncode($this->lang->webhook->error->curl)); + if(!extension_loaded('curl')) return print(helper::jsonEncode($this->lang->webhook->error->curl)); if($webhook->type == 'dinguser' || $webhook->type == 'wechatuser' || $webhook->type == 'feishuuser') {