protected function getProductId($infoType) { if (isset($_GET['product_id'])) { $productId = $_GET['product_id']; if (!Info::isProductAccessable($productId)) { throw new CHttpException(400, Yii::t('Common', 'Required URL not found or permission denied.')); } Yii::app()->user->setState('product', $productId); TestUserService::updateUserProductCookie($productId); return $productId; } else { throw new CHttpException(400, Yii::t('Common', 'Required URL not found or permission denied.')); } }
public function relatedCaseValidator($attribute, $params) { if (isset($this->related_case)) { $this->related_case = $this->handleSpliter($this->related_case); $relatedBugArr = CommonService::splitStringToArray(',', $this->related_case); foreach ($relatedBugArr as $caseIdTmp) { $infoObj = CaseInfo::model()->findByPk($caseIdTmp); if ($infoObj == null || $infoObj->id != $caseIdTmp) { $this->addError('related_case', 'Case ID[' . $caseIdTmp . ']' . Yii::t('Common', 'is not existed')); } elseif (!Info::isProductAccessable($infoObj->product_id)) { $this->addError('related_case', 'Case ID[' . $caseIdTmp . ']' . Yii::t('Common', 'No access right')); } } } }
/** * get info's relate id's html * * @author youzhao.zxw<*****@*****.**> * @param string $infoType bug,case or result * @param string $idStr related id string * @return string relate id's html */ public static function getRelatedIdHtml($infoType, $idStr) { $returnStr = ''; $idArr = CommonService::splitStringToArray(',', $idStr); $modelName = ucfirst($infoType) . 'Info'; $targetModel = new $modelName(); foreach ($idArr as $id) { $infoObj = $targetModel->model()->findByPk($id); if ($infoObj != null) { if (!Info::isProductAccessable($infoObj->product_id)) { $singleLink = '<a title="' . Yii::t('Common', 'No access right') . '" href="' . Yii::app()->createUrl('info/edit', array('type' => $infoType, 'id' => $id)) . '" target="_blank">' . $id . '</a>'; } else { $singleLink = '<a title="' . $infoObj->title . '" href="' . Yii::app()->createUrl('info/edit', array('type' => $infoType, 'id' => $id)) . '" target="_blank">' . $id . '</a>'; } if ('' == $returnStr) { $returnStr = $singleLink; } else { $returnStr .= ',' . $singleLink; } } } if ('' != $returnStr) { $returnStr = '<div style="word-break:break-all;word-wrap:break-word;">' . $returnStr . '</div>'; } return $returnStr; }
public function duplicateIdValidator($attribute, $params) { if (self::DUPLICATE_SOLUTION == $this->solution) { $duplicatedIdError = $this->getError('duplicate_id'); if (empty($duplicatedIdError)) { if (empty($this->duplicate_id)) { $this->addError('duplicate_id', Yii::t('BugInfo', self::ERROR_DUPLICATE_ID)); } else { $this->duplicate_id = $this->handleSpliter($this->duplicate_id); $duplicatedIdArr = CommonService::splitStringToArray(',', $this->duplicate_id); foreach ($duplicatedIdArr as $dupId) { if ($dupId != ceil($dupId)) { $this->addError('duplicate_id', 'Duplicate ID[' . $dupId . ']' . Yii::t('BugInfo', self::ERROR_DUPLICATE_ID)); } else { $infoObj = BugInfo::model()->findByPk($dupId); if ($infoObj == null || $infoObj->id != $dupId) { $this->addError('duplicate_id', 'Duplicate ID[' . $dupId . ']' . Yii::t('BugInfo', self::ERROR_DUPLICATE_ID)); } elseif (!Info::isProductAccessable($infoObj->product_id)) { $this->addError('duplicate_id', 'Duplicate ID[' . $dupId . ']' . Yii::t('Common', 'No access right')); } } } } } } else { $this->duplicate_id = null; } }