public static function getActionCleanContent($actionInfo, $type, $id) { $actionStr = $actionInfo['created_at'] . ' '; if ('bug' == $type && BugInfo::ACTION_RESOLVE == $actionInfo['action_type']) { $mixedInfo = InfoService::loadModel($type, $id); $bugInfo = $mixedInfo->getBasicInfo(); $actionStr .= '<strong>' . Yii::t('BugInfo', $actionInfo['action_type']) . '</strong> as <strong>' . $bugInfo['solution'] . '</strong> by <strong>' . CommonService::getUserRealName($actionInfo['created_by']) . '</strong>'; } else { $actionStr .= '<strong>' . Yii::t('BugInfo', $actionInfo['action_type']) . '</strong> by <strong>' . CommonService::getUserRealName($actionInfo['created_by']) . '</strong>'; } return $actionStr; }
/** * Prepare info page * * @author youzhao.zxw<*****@*****.**> * @param String $infoType bug,case or result * @param CController $controller page controller * @param String $actionType edit action * @param array $request page request info * @return array page information */ public static function initInfoPage($infoType, $controller, $actionType, $request) { $basicModelName = ucfirst(strtolower($infoType)) . 'InfoView'; $infoId = $request->getParam('id'); $fileDeleteable = true; if ('view' == $actionType) { $fileDeleteable = false; } if (isset($infoId)) { $mixedInfo = InfoService::loadModel($infoType, $infoId, $fileDeleteable); $model = $mixedInfo->getBasicInfo(); $customInfo = $mixedInfo->getCustomInfo(); if (Info::TYPE_BUG == $infoType) { if (!in_array($actionType, BugInfo::model()->getLegalActionByState($model->getAttribute($infoType . '_status')))) { throw new CHttpException(400, Yii::t('Common', 'Required URL not found or permission denied.')); } if ('view' != $actionType) { $model->setAttribute('bug_status', self::getBugStatusByAction($actionType)); } if (BugInfo::ACTION_OPEN == $actionType) { } elseif (BugInfo::ACTION_RESOLVE == $actionType) { $model->resolved_at = date(CommonService::DATE_FORMAT); $model->resolved_by = Yii::app()->user->id; $model->assign_to = $model->created_by; $model->assign_to_name = CommonService::getUserRealName($model->created_by); } elseif (BugInfo::ACTION_CLOSE == $actionType) { $model->closed_at = date(CommonService::DATE_FORMAT); $model->closed_by = Yii::app()->user->id; $model->assign_to = TestUser::CLOSE_USER_ID; $model->assign_to_name = TestUser::CLOSE_USER_NAME; } elseif (BugInfo::ACTION_ACTIVATE == $actionType) { $customInfo = self::filterCustomInfoInReactive($customInfo, $model->product_id); $model->reopen_count += 1; $model->assign_to = $model->resolved_by; $model->assign_to_name = CommonService::getUserRealName($model->resolved_by); $model = self::setBugActiveModel($model); } $model->scenario = $actionType; } $productId = $model->product_id; $customFieldArr = FieldConfigService::getCustomFieldConfig($productId, $infoType, $controller, $actionType, array(), $customInfo); } else { $model = new $basicModelName(); $customInfo = array(); $sourceId = $request->getParam('source_id'); $templateId = $request->getParam('template_id'); $caseId = $request->getParam('case_id'); $resultId = $request->getParam('result_id'); $bugId = $request->getParam('bug_id'); $bactchRunProductId = $request->getParam('batch_product_id'); if (isset($sourceId)) { $mixedInfo = InfoService::loadModel($infoType, $sourceId, $fileDeleteable); $model = $mixedInfo->getBasicInfo(); unset($model->id); $model->setIsNewRecord(true); $productId = $model->product_id; if ('bug' == $infoType) { $customInfo = FieldConfigService::getBugAvailableValueByAction($mixedInfo->getCustomInfo(), $actionType, $productId); $model = self::setBugActiveModel($model); } else { if ('case' == $infoType) { $customInfo = $mixedInfo->getCustomInfo(); unset($customInfo['id']); unset($customInfo['case_id']); } } $customFieldArr = FieldConfigService::getCustomFieldConfig($productId, $infoType, $controller, $actionType, array(), $customInfo); } elseif (isset($templateId)) { $templateInfo = UserTemplate::model()->findByPk($templateId); if ($templateInfo === null) { throw new CHttpException(404, 'The requested page does not exist.'); } $mixedInfo = unserialize($templateInfo['template_content']); $model->attributes = $mixedInfo->getBasicInfo(); $productId = $model->product_id; $productInfo = Product::model()->findByPk($productId); $model->product_name = $productInfo->name; $customInfo = $mixedInfo->getCustomInfo(); //no need custom id and info_id from template if (Info::TYPE_BUG == $infoType) { $customInfo = FieldConfigService::getBugAvailableValueByAction($customInfo, $actionType, $productId); $model = self::setBugActiveModel($model); } else { if (Info::TYPE_CASE == $infoType) { unset($customInfo['id']); unset($customInfo['case_id']); } } //unset($model->id); $customFieldArr = FieldConfigService::getCustomFieldConfig($productId, $infoType, $controller, $actionType, array(), $customInfo); } elseif (isset($caseId)) { $caseMixedInfo = InfoService::loadModel('case', $caseId, $fileDeleteable); $caseModel = $caseMixedInfo->getBasicInfo(); $model->related_case_id = $caseId; $model->title = $caseModel->title; $model->product_id = $caseModel->product_id; $model->product_name = $caseModel->product_name; $model->module_name = $caseModel->module_name; $model->productmodule_id = $caseModel->productmodule_id; $model->result_step = $caseModel->case_step; $model->assign_to = TestUser::CLOSE_USER_ID; $model->assign_to_name = TestUser::CLOSE_USER_NAME; $productId = $caseModel->product_id; $customFieldArr = FieldConfigService::getCustomFieldConfig($productId, $infoType, $controller, $actionType, array(), $customInfo); } elseif (isset($bugId)) { $bugMixedInfo = InfoService::loadModel(Info::TYPE_BUG, $bugId, $fileDeleteable); $bugModel = $bugMixedInfo->getBasicInfo(); $model->related_bug = $bugId; $model->title = $bugModel->title; $model->product_id = $bugModel->product_id; $model->product_name = $bugModel->product_name; $model->priority = $bugModel->priority; $model->module_name = $bugModel->module_name; $model->productmodule_id = $bugModel->productmodule_id; $model->case_step = $bugModel->repeat_step; $model->assign_to = $bugModel->assign_to; $model->assign_to_name = $bugModel->assign_to_name; $model->mail_to = $bugModel->mail_to; $productId = $bugModel->product_id; $customFieldArr = FieldConfigService::getCustomFieldConfig($productId, $infoType, $controller, $actionType, array(), $customInfo); } elseif (isset($bactchRunProductId)) { $model->title = Yii::t('Common', 'Mutiple items'); $model->product_id = $bactchRunProductId; $model->product_name = Yii::t('Common', 'Mutiple items'); $model->module_name = Yii::t('Common', 'Mutiple items'); $model->assign_to = TestUser::CLOSE_USER_ID; $model->assign_to_name = TestUser::CLOSE_USER_NAME; $productId = $bactchRunProductId; $customFieldArr = FieldConfigService::getCustomFieldConfig($productId, $infoType, $controller, $actionType, array(), $customInfo); } elseif (isset($resultId)) { $resultMixedInfo = InfoService::loadModel('result', $resultId, $fileDeleteable); $resultModel = $resultMixedInfo->getBasicInfo(); $resultCustomInfo = $resultMixedInfo->getCustomInfo(); $model->related_result = $resultId; $model->title = $resultModel->title; $model->module_name = $resultModel->module_name; $model->repeat_step = ResultStepService::removeStepResultForBug($resultModel->result_step); $model->product_id = $resultModel->product_id; $model->productmodule_id = $resultModel->productmodule_id; $model->assign_to = TestUser::ACTIVE_USER_ID; $model->assign_to_name = TestUser::ACTIVE_USER_NAME; $productId = $resultModel->product_id; $copyFieldArr = FieldConfigService::getBugCopyableFields($productId); foreach ($copyFieldArr as $resultField) { $copyFieldName = $resultField['field_name']; if (isset($resultCustomInfo[$copyFieldName])) { $customInfo[$copyFieldName] = $resultCustomInfo[$copyFieldName]; } } $customFieldArr = FieldConfigService::getCustomFieldConfig($productId, $infoType, $controller, $actionType, array(), $customInfo); } else { $productId = $request->getParam('product_id'); $productInfo = Product::model()->findByPk($productId); $model->product_name = $productInfo->name; $selectModuleId = Yii::app()->user->getState($productId . '_' . $infoType . '_selectedModule'); if (!empty($selectModuleId)) { $model->productmodule_id = $selectModuleId; $selectedModuleInfo = ProductModule::model()->findByPk($selectModuleId); if (!empty($selectedModuleInfo)) { $model->assign_to = $selectedModuleInfo['owner']; $model->assign_to_name = CommonService::getUserRealName($selectedModuleInfo['owner']); } } if (Info::TYPE_BUG == $infoType) { $model->repeat_step = $productInfo[$infoType . '_step_template']; } elseif (Info::TYPE_CASE == $infoType) { $model->case_step = $productInfo[$infoType . '_step_template']; } $customFieldArr = FieldConfigService::getCustomFieldConfig($productId, $infoType, $controller, Info::ACTION_OPEN); } if (Info::TYPE_RESULT != $infoType) { $model->setAttribute($infoType . '_status', 'Active'); } else { $model->setAttribute($infoType . '_status', ResultInfo::STATUS_COMPLETED); } if (Info::TYPE_BUG == $infoType) { $model->reopen_count = 0; } if (Info::TYPE_CASE == $infoType) { $model->delete_flag = CommonService::$TrueFalseStatus['FALSE']; } $model->attachment_file = ''; $model->created_at = date(CommonService::DATE_FORMAT); $model->created_by = Yii::app()->user->id; $model->updated_at = ''; $model->updated_by = ''; } $model->product_id = $productId; $assignToName = self::parseAssignToName($model->assign_to); if ('' != $assignToName) { $model->assign_to_name = $assignToName; } return array($productId, $model, $customInfo, $customFieldArr); }