Exemplo n.º 1
0
 /**
  * get user marked info id arr
  *
  * @author                                    youzhao.zxw<*****@*****.**>
  * @param   array           $valueArr         id array been searched
  * @param   int             $userId           user id
  * @param   string          $type             bug,case or result
  * @return  array                             marked id array
  */
 public static function getUserMarkedInfoidArr($userId, $type)
 {
     $searchResult = array();
     if (Info::TYPE_BUG == $type) {
         $searchResult = MapUserBug::model()->findAllByAttributes(array('test_user_id' => $userId));
     } elseif (Info::TYPE_CASE == $type) {
         $searchResult = MapUserCase::model()->findAllByAttributes(array('test_user_id' => $userId));
     }
     if (Info::TYPE_RESULT == $type) {
         $searchResult = MapUserResult::model()->findAllByAttributes(array('test_user_id' => $userId));
     }
     $returnArr = array();
     foreach ($searchResult as $value) {
         $returnArr[] = $value['info_id'];
     }
     return $returnArr;
 }
Exemplo n.º 2
0
 public function actionMark()
 {
     $type = $_GET['type'];
     $infoId = $_GET['id'];
     $isAdd = $_GET['isAdd'];
     $markModelName = 'MapUser' . ucfirst($type);
     if ('1' == $isAdd) {
         $markInfo = new $markModelName();
         $markInfo->test_user_id = Yii::app()->user->id;
         $markInfo->info_id = $infoId;
         if (!$markInfo->save()) {
             echo CommonService::$ApiResult['FAIL'] . ' error:' . CJSON::encode($markInfo->getErrors());
         } else {
             echo CommonService::$ApiResult['SUCCESS'];
         }
     } else {
         if ('bug' == $type) {
             $markInfo = MapUserBug::model()->findByAttributes(array('info_id' => $infoId, 'test_user_id' => Yii::app()->user->id));
         } elseif ('case' == $type) {
             $markInfo = MapUserCase::model()->findByAttributes(array('info_id' => $infoId, 'test_user_id' => Yii::app()->user->id));
         } elseif ('result' == $type) {
             $markInfo = MapUserResult::model()->findByAttributes(array('info_id' => $infoId, 'test_user_id' => Yii::app()->user->id));
         }
         if ($markInfo !== null) {
             $markInfo->delete();
         }
         echo CommonService::$ApiResult['SUCCESS'];
     }
 }