/** * load info object * * @author youzhao.zxw<*****@*****.**> * @param string $infoType bug,case or result * @param int $id info object id * @return array load data result */ public static function loadRawData($infoType, $id) { $resultInfo = array(); $mixedInfo = new MixInfo(); $infoType = strtolower($infoType); $className = ucfirst($infoType) . 'InfoView'; $targetModel = new $className(); $model = $targetModel->model()->findByPk((int) $id); if (null === $model) { $resultInfo['status'] = CommonService::$ApiResult['FAIL']; $resultInfo['detail'] = Yii::t('Common', 'Requested object does not exist'); return $resultInfo; } $modelProductId = $model->product_id; if (!Info::isProductAccessable($modelProductId)) { $resultInfo['status'] = CommonService::$ApiResult['FAIL']; $resultInfo['detail'] = Yii::t('Common', 'No access right'); return $resultInfo; } else { $fileInfo = TestFileService::getRelatedFileInfos($infoType, $id); $model->attachment_file = $fileInfo; $mixedInfo->setBasicInfo($model); $customInfo = FieldConfigService::getCustomFieldValue($model->product_id, $infoType, $id); if (false === $customInfo) { $customInfo = array(); } $mixedInfo->setCustomInfo($customInfo); } $model->assign_to_name = CommonService::getUserRealName($model->assign_to); $resultInfo['status'] = CommonService::$ApiResult['SUCCESS']; $resultInfo['detail'] = $mixedInfo; return $resultInfo; }
public static function getInfoActionForApi($type, $id, $productId) { $fieldLabelArr = FieldConfigService::getCustomFieldLabel($type, $productId); $actionInfos = Yii::app()->db->createCommand()->select('*')->from('{{' . $type . '_action' . '}}')->where($type . 'info_id = :id', array(':id' => $id))->order('id desc')->queryAll(); list($addFileInfos, $deleteFileInfos) = self::getFileEditInfos($type, $id); $actionCount = count($actionInfos); for ($i = 0; $i < $actionCount; $i++) { $actionInfos[$i]['action_note'] = CHtml::encode($actionInfos[$i]['action_note']); $actionInfos[$i]['created_by_name'] = CommonService::getUserRealName($actionInfos[$i]['created_by']); $actionInfos[$i]['action_history'] = self::getFieldEditInfoForApi($actionInfos[$i], $type, $fieldLabelArr); $actionInfos[$i]['added_file'] = array(); $actionInfos[$i]['deleted_file'] = array(); if (isset($addFileInfos[$actionInfos[$i]['id']])) { $actionInfos[$i]['added_file'] = $addFileInfos[$actionInfos[$i]['id']]; } if (isset($deleteFileInfos[$actionInfos[$i]['id']])) { $actionInfos[$i]['deleted_file'] = $deleteFileInfos[$actionInfos[$i]['id']]; } } return $actionInfos; }
echo CHtml::encode(CommonService::getDateStr($model->updated_at)); ?> </div> </fieldset> <div style="float: left;width: 33%"> <fieldset> <legend><?php echo Yii::t('Common', 'Open'); ?> </legend> <div class="row"> <?php echo $form->label($model, 'created_by'); ?> <?php echo CHtml::encode(CommonService::getUserRealName($model->created_by)); ?> </div> <div class="row"> <?php echo $form->label($model, 'created_at'); ?> <?php echo CHtml::encode(CommonService::getDateStr($model->created_at)); ?> </div> <?php echo empty($customfield['case_open']) ? '' : $customfield['case_open']; ?> </fieldset> <fieldset>
?> </legend> <div class="row"> <?php echo $form->label($model, 'bug_status'); ?> <?php echo CHtml::encode($model->bug_status); ?> </div> <div class="row"> <?php echo $form->label($model, 'assign_to'); ?> <?php echo CHtml::encode(CommonService::getUserRealName($model->assign_to)); ?> </div> <div class="row"> <?php echo $form->label($model, 'mail_to'); ?> <?php echo $form->textField($model, 'mail_to', array('readonly' => 'readonly', 'class' => 'info_input readonly_field', 'title' => $model->mail_to)); ?> </div> <div class="row"> <?php echo $form->label($model, 'severity'); ?> <?php
public static function formatColumnData($infoType, $productId, $fieldType, $columnName, $value) { $returnValue = $value; if (Info::$InputType['people'] == $fieldType) { $returnValue = CommonService::getUserRealName($value); } elseif (Info::$InputType['multipeople'] == $fieldType) { $returnValue = CommonService::getMultiUserRealName($value); } $returnValue = '<a href="' . Yii::app()->createUrl('info/index', array('type' => $infoType, 'product_id' => $productId, 'filter' => $columnName . '|' . $value)) . '">' . $returnValue . '</a>'; return $returnValue; }
private static function parseRawData($data, $infoType, $fieldName, $fieldType) { $rawData = $data; if (Info::$InputType['people'] == $fieldType) { $data = CommonService::getUserRealName($data); } elseif (Info::$InputType['multipeople'] == $fieldType) { $data = CommonService::getMultiUserRealName($data); } return $data; }
/** * Returns the data model based on the primary key given in the GET variable. * If the data model is not found, an HTTP exception will be raised. * @param integer the ID of the model to be loaded */ public static function loadModel($id) { $model = ProductModule::model()->findByPk((int) $id); if ($model === null) { throw new CHttpException(404, 'The requested page does not exist.'); } else { $model->owner_name = CommonService::getUserRealName($model->owner); $model->product_name = $model->product->name; } return $model; }