public static function editGroup($params) { $resultInfo = array(); $actionType = BugfreeModel::ACTION_OPEN; $oldRecordAttributs = array(); if (empty($params['id'])) { $group = new UserGroup(); } else { $group = self::loadModel($params['id']); $oldRecordAttributs = $group->attributes; if (!empty($group->group_user)) { $oldRecordAttributs['group_user'] = join(',', $group->group_user); } $oldRecordAttributs['group_manager'] = $group->group_manager; $actionType = BugfreeModel::ACTION_EDIT; } if (!self::isGroupEditable($group->id)) { $resultInfo['status'] = CommonService::$ApiResult['FAIL']; $resultInfo['detail']['id'] = Yii::t('Common', 'Required URL not found or permission denied.'); return $resultInfo; } $group->attributes = $params; if (!$group->save()) { $resultInfo['status'] = CommonService::$ApiResult['FAIL']; $resultInfo['detail'] = $group->getErrors(); } else { Yii::app()->db->createCommand()->delete('{{map_user_group}}', 'user_group_id=:groupId', array(':groupId' => $group->id)); $managerNameArr = CommonService::splitStringToArray(',', $params['group_manager']); $managerIdArr = array(); foreach ($managerNameArr as $mangerName) { $managerInfo = TestUserService::getUserInfoByRealname($mangerName); if ($managerInfo !== null) { $managerIdArr[] = $managerInfo['id']; } } $allUserId = array_unique(array_merge($params['group_user'], $managerIdArr)); foreach ($allUserId as $userId) { $mapUserGroup = new MapUserGroup(); $mapUserGroup->test_user_id = $userId; $mapUserGroup->user_group_id = $group->id; if (in_array($userId, $managerIdArr)) { $mapUserGroup->is_admin = CommonService::$TrueFalseStatus['TRUE']; } else { $mapUserGroup->is_admin = CommonService::$TrueFalseStatus['FALSE']; } $mapUserGroup->save(); } $newRecord = self::loadModel($group->id); if (!empty($newRecord->group_user)) { $newRecord->group_user = join(',', $newRecord->group_user); } $addActionResult = AdminActionService::addActionNotes('user_group', $actionType, $newRecord, $oldRecordAttributs); $resultInfo['status'] = CommonService::$ApiResult['SUCCESS']; $resultInfo['detail'] = array('id' => $group->id); } return $resultInfo; }
public static function getCreateLinkStr($productId, $type, $userId) { $actionStr = ''; $myTemplateArr = self::getUserTemplate($productId, $type, $userId); foreach ($myTemplateArr as $template) { $deleteLinkStr = CommonService::getDeleteLink('template', $template['id']); $actionStr .= '<li id="user_template_' . $template['id'] . '">' . $deleteLinkStr . ' <a href="' . Yii::app()->createUrl('info/edit', array('type' => $type, 'action' => Info::ACTION_OPEN, 'template_id' => $template['id'])) . '" target="_blank" title="' . $template['title'] . '">' . CHtml::encode($template['title']) . '</a></li>'; } return $actionStr; }
/** * basic info convert * * @todo convert $action for bug import * * @param array $basicInfo * @param string $infoType * @return string */ private function basicInfoConv($basicInfo, $infoType) { // hard code for productmodule_id if (isset($basicInfo['productmodule_id'])) { $moduleSplitterPos = strpos($basicInfo['productmodule_id'], ProductModule::MODULE_SPLITTER); if (false !== $moduleSplitterPos) { $moduleName = substr($basicInfo['productmodule_id'], $moduleSplitterPos + 1); $moduleInfo = ProductModule::model()->findByAttributes(array('product_id' => $basicInfo['product_id'], 'full_path_name' => $moduleName)); if (!empty($moduleInfo)) { $basicInfo['productmodule_id'] = $moduleInfo->id; } } else { //$basicInfo['productmodule_id'] = 0; } } // hard code for id if (isset($basicInfo['id']) && '' == $basicInfo['id']) { unset($basicInfo['id']); } // hard code for delete_flag if (isset($basicInfo['delete_flag'])) { $basicInfo['delete_flag'] = CommonService::getTrueFalseValue($basicInfo['delete_flag']); } if (isset($basicInfo['priority'])) { if (Info::TYPE_CASE == $infoType) { $basicInfo['priority'] = ProductService::getCasePriorityValueByName($basicInfo['product_id'], $basicInfo['priority']); } else { if (Info::TYPE_BUG == $infoType) { $basicInfo['priority'] = ProductService::getBugPriorityValueByName($basicInfo['product_id'], $basicInfo['priority']); } } } if (isset($basicInfo['severity']) && Info::TYPE_BUG == $infoType) { $basicInfo['severity'] = ProductService::getBugSeverityValueByName($basicInfo['product_id'], $basicInfo['severity']); } // @TODO convert for bug import $bugUserKeyArr = array('resolved_by', 'closed_by'); foreach ($bugUserKeyArr as $bugUserKey) { if (isset($basicInfo[$bugUserKey])) { $resolvedByInfo = TestUserService::getUserInfoByRealname($basicInfo[$bugUserKey]); if (!empty($resolvedByInfo)) { $basicInfo[$bugUserKey] = $resolvedByInfo['id']; } else { unset($basicInfo[$bugUserKey]); } } } $bugDateKeyArr = array('resolved_at', 'closed_at'); foreach ($bugDateKeyArr as $bugDateKey) { if (empty($basicInfo[$bugDateKey])) { unset($basicInfo[$bugDateKey]); } } return $basicInfo; }
/** * 得到数据模型的详细信息 * @param array $where 查询条件 * @param string $fields 插叙字段 * @return array */ public function getPagination($where, $fields, $order, $firstRow, $listRows) { $models = parent::getPagination($where, $fields, $order, $firstRow, $listRows); foreach ($models as $key => $model) { // 模型拥有的字段数目 $models[$key]['fields_count'] = count($model['fields']); // 记录行数 $rows = D('Common')->getTableRows($model['tbl_name']); $models[$key]['rows'] = $rows; } return $models; }
/** * Lists all models. */ public function actionIndex() { $pageSize = CommonService::getPageSize(); $criteria = new CDbCriteria(); $name = ''; if (isset($_GET['name'])) { $name = $_GET['name']; $criteria->addSearchCondition('option_name', $name); } $dataProvider = new CActiveDataProvider('TestOption', array('criteria' => $criteria, 'sort' => array('defaultOrder' => array('id' => true)), 'pagination' => array('pageSize' => $pageSize))); $this->render('index', array('dataProvider' => $dataProvider, 'name' => $name)); }
/** * Lists all models. */ public function actionIndex() { $pageSize = CommonService::getPageSize(); $criteria = new CDbCriteria(); $name = ''; if (isset($_GET['name'])) { $name = $_GET['name']; $userArr = TestUserService::getUserList($name, 'id'); $criteria->addInCondition('created_by', array_keys($userArr)); $criteria->addSearchCondition('ip', $name, true, 'OR'); } $dataProvider = new CActiveDataProvider('UserLog', array('criteria' => $criteria, 'sort' => array('defaultOrder' => array('id' => true)), 'pagination' => array('pageSize' => $pageSize))); $this->render('index', array('dataProvider' => $dataProvider, 'name' => $name)); }
/** * Lists all models. */ public function actionIndex() { $pageSize = CommonService::getPageSize(); $criteria = new CDbCriteria(); if (CommonService::$TrueFalseStatus['FALSE'] == Yii::app()->user->getState('system_admin')) { $managedgroups = UserGroupService::getManagedGroup(Yii::app()->user->id); $criteria->addInCondition('id', $managedgroups); } $name = ''; if (isset($_GET['name'])) { $name = $_GET['name']; $criteria->addSearchCondition('name', $name); } $dataProvider = new CActiveDataProvider('UserGroup', array('criteria' => $criteria, 'sort' => array('defaultOrder' => array('id' => true)), 'pagination' => array('pageSize' => $pageSize))); $this->render('index', array('dataProvider' => $dataProvider, 'name' => $name)); }
public static function getNoResultStepBr($stepStr) { $handledStr = ''; $stepArr = preg_split('/<br\\s*\\/>/i', $stepStr); foreach ($stepArr as $step) { if (preg_match('/^(\\r\\n)*\\s*\\d+\\..*?$/', strip_tags($step))) { $handledStr .= '<table bugfree_table_already_set><tbody><tr valign="top"><td style="width:370px;">' . $step . '</td>'; $handledStr .= '<td>' . self::getSelectStr() . '</td>'; $handledStr .= '</tr></tbody></table>'; } else { $handledStr .= $step . '<br />'; } } if (CommonService::endsWith($handledStr, '<br />')) { $handledStr = substr($handledStr, 0, strlen($handledStr) - strlen('<br />')); } return $handledStr; }
/** * Lists all models. */ public function actionIndex() { $pageSize = CommonService::getPageSize(); $criteria = new CDbCriteria(); $name = ''; if (isset($_GET['name'])) { $name = $_GET['name']; $criteria->addSearchCondition('target_id', $name); } $targetTable = ''; if (isset($_GET['target_table']) && !empty($_GET['target_table'])) { $targetTable = $_GET['target_table']; $criteria->addCondition('target_table=' . Yii::app()->db->quoteValue($targetTable)); } $targetTableOption = CHtml::dropDownList('target_table', $targetTable, array('' => Yii::t('AdminCommon', 'All'), 'product' => Yii::t('AdminCommon', 'product'), 'product_module' => Yii::t('AdminCommon', 'product_module'), 'field_config' => Yii::t('AdminCommon', 'field_config'), 'test_user' => Yii::t('AdminCommon', 'test_user'), 'user_group' => Yii::t('AdminCommon', 'user_group'), 'test_option' => Yii::t('AdminCommon', 'test_option'))); $dataProvider = new CActiveDataProvider('AdminAction', array('criteria' => $criteria, 'sort' => array('defaultOrder' => array('id' => true)), 'pagination' => array('pageSize' => $pageSize))); $this->render('index', array('dataProvider' => $dataProvider, 'name' => $name, 'targetTableOption' => $targetTableOption)); }
public static function getBasicSearchFieldConfig($productId) { $searchAbleField = self::getBasicSearchField(); $returnArr = array(); foreach ($searchAbleField as $key => $value) { $returnArr[$key] = array('label' => CaseInfoView::model()->getAttributeLabel($key), 'type' => $value, 'isBasic' => true); if ('case_status' == $key) { $returnArr[$key]['value'] = self::getStatusOption(); array_unshift($returnArr[$key]['value'], ''); } else { if ('priority' == $key) { $returnArr[$key]['value'] = ProductService::getCasePriorityOption($productId); } else { if ('delete_flag' == $key) { $returnArr[$key]['value'] = CommonService::getTrueFalseOptions(); array_unshift($returnArr[$key]['value'], ''); } } } } return $returnArr; }
/** * Lists all models. */ public function actionIndex() { $name = ''; $pageSize = CommonService::getPageSize(); $productIdNameArr = ProductService::getActiveProductIdNameArr(); $criteria = new CDbCriteria(); if (CommonService::$TrueFalseStatus['FALSE'] == Yii::app()->user->getState('system_admin')) { $managedProducts = TestUserService::getManagedProduct(Yii::app()->user->id); $criteria->addInCondition('id', $managedProducts); $criteria->addCondition('is_dropped="0"'); } if (isset($_GET['name'])) { $name = $_GET['name']; $criteria->addSearchCondition('name', $name); } $dataProvider = new CActiveDataProvider('Product', array('criteria' => $criteria, 'sort' => array('defaultOrder' => array('is_dropped' => false, 'display_order' => true)), 'pagination' => array('pageSize' => $pageSize))); $this->render('index', array('dataProvider' => $dataProvider, 'name' => $name, 'productIdNameArr' => $productIdNameArr)); }
public function __construct() { parent::__construct('sms', 'v3', 'IPMaterialService'); }
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; }
public function __construct() { parent::__construct('sms', 'v3', 'SearchService'); }
?> </legend> <div class="row"> <?php echo $form->label($model, 'created_by'); ?> <?php echo CHtml::encode($model->created_by_name); ?> </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['result_open']) ? '' : $customfield['result_open']; ?> </fieldset> <fieldset> <legend><?php echo Yii::t('FieldConfig', 'result_environment'); ?> </legend> <?php echo empty($customfield['result_environment']) ? '' : $customfield['result_environment']; ?> </fieldset>
public function __construct() { parent::__construct('sms', 'v3', 'AdgroupService'); }
public function __construct() { parent::__construct('sms', 'v3', 'KeywordService'); }
public function __construct() { parent::__construct('sms', 'v3', 'AccountService'); }
public function __construct() { parent::__construct('sms', 'v3', 'CompetitionService'); }
public function __construct() { parent::__construct('sms', 'v3', 'DynamicCreativeService'); }
public function __construct() { parent::__construct('sms', 'v3', 'FolderService'); }
private function getGridShowContent($searchFieldConfig, $showFieldArr, $infoType, $productId, $filterColumn, $whereStr, $isAllBasicField = false) { $pageSize = CommonService::getPageSize(); $viewColumnArr = SearchService::getViewColumnArr($searchFieldConfig, $showFieldArr, $infoType, $productId, $filterColumn); $totalNum = SqlService::getTotalFoundNum($infoType, $productId, $whereStr, $isAllBasicField); $sql = SqlService::getRawDataSql($searchFieldConfig, $infoType, $productId, $this->getSqlSelectFieldArr($infoType, $showFieldArr), $whereStr, $isAllBasicField); $dataProvider = new CSqlDataProvider($sql, array('totalItemCount' => $totalNum, 'sort' => array('defaultOrder' => array('id' => true), 'multiSort' => true, 'attributes' => array_merge($showFieldArr, array(Info::MARK))), 'pagination' => array('pageSize' => $pageSize))); $sortArr = $dataProvider->getSort()->getDirections(); Yii::app()->user->setState($productId . '_' . $infoType . '_sortArr', $sortArr); $preNextSessionSql = SqlService::getPreNextSql($searchFieldConfig, $infoType, $productId, $whereStr, Yii::app()->user->getState($productId . '_' . $infoType . '_sortArr', $isAllBasicField)); Yii::app()->user->setState($productId . '_' . $infoType . '_prenextsql', $preNextSessionSql); return array('viewColumnArr' => $viewColumnArr, 'dataProvider' => $dataProvider, 'totalNum' => $totalNum); }
</div> <div class="row"> <?php echo $form->label($model, 'related_result'); ?> <?php echo InfoService::getRelatedIdHtml('result', $model->related_result); ?> </div> </fieldset> <fieldset> <legend> <?php echo Yii::t('Common', 'Attachments') . '(' . TestFileService::getFileSize(CommonService::getMaxFileSize()) . ')'; ?> </legend> <?php echo $model->attachment_file; ?> <?php $this->widget('CMultiFileUpload', array('model' => $model, 'name' => 'attachment_file', 'accept' => '', 'htmlOptions' => array('size' => 16), 'remove' => '<img src="' . Yii::app()->theme->baseUrl . '/assets/images/deletefile.gif" alt="remove" />', 'options' => array())); ?> </fieldset> </div> </div> <div style="clear:both;"> <fieldset class="action_note" style="width:460px;"> <legend><?php echo Yii::t('Common', 'Comment');
<?php echo $form->label($model, 'case_step_template'); ?> <div style="width:560px;margin-left: 190px;"> <?php $this->widget('application.extensions.kindeditor4.KindEditorWidget', array('model' => $model, 'attribute' => 'case_step_template', 'htmlOptions' => array('style' => 'width:100%;'), 'editorname' => 'case_step_template_editor')); ?> </div> </div> <div class="row"> <?php echo $form->label($model, 'is_dropped'); ?> <?php echo $form->dropDownList($model, 'is_dropped', CommonService::getTrueFalseOptions(), array('class' => 'required')); ?> </div> <br/> <div style="clear:both;"></div> <hr/> <br/> <?php echo CHtml::submitButton(Yii::t('Product', 'Save Product'), array('class' => 'margin-left-190')); ?> <?php $this->endWidget(); ?> </div><!-- form -->
public function __construct() { parent::__construct('sms', 'v3', 'ReportService'); }
/** * 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; }
private static function getFileType($fileName) { $fileType = CommonService::splitStringToArray(".", $fileName); $fileType = strtolower(array_pop($fileType)); if (strlen($fileType) == strlen($fileName)) { return ''; } return $fileType; }
echo $bugInfo['bug_status']; ?> </td> <td align="center"><?php echo $bugInfo['created_by_name']; ?> </td> <td align="center"><?php echo $bugInfo['assign_to_name']; ?> </td> <td align="center"><?php echo $bugInfo['resolved_by_name']; ?> </td> <td align="center"><?php echo $bugInfo['solution']; ?> </td> <td align="center"><?php echo CommonService::getDateStr($bugInfo['updated_at']); ?> </td> </tr> <?php } ?> </table> </body> </html>
public function __construct() { parent::__construct('sms', 'v3', 'CampaignService'); }
public static function isSystemAdmin($userId) { $userInfo = TestUser::model()->findByPk($userId); $systemAdminStr = TestOption::model()->findByAttributes(array('option_name' => TestOption::SYSTEM_ADMIN)); $systemAdminArr = array(); if ($systemAdminStr !== null && !empty($systemAdminStr['option_value'])) { $systemAdminArr = CommonService::splitStringToArray(",", $systemAdminStr['option_value']); } if (in_array($userInfo['username'], $systemAdminArr)) { return CommonService::$TrueFalseStatus['TRUE']; } else { return CommonService::$TrueFalseStatus['FALSE']; } }