Esempio n. 1
0
 protected function afterValidate()
 {
     //check product permission
     if (!self::isProductAccessable($this->product_id)) {
         $this->addError('product_id', $this->getAttributeLabel('product_id') . ' ' . Yii::t('Product', 'No access right to this product'));
     }
     //set modified_by
     if ($this->isNewRecord) {
         $this->modified_by = $this->updated_by;
     } else {
         $dbBugInfo = $this->model()->findByPk($this->id);
         $oldModifiedBy = $dbBugInfo->modified_by;
         if (!in_array($this->updated_by, CommonService::splitStringToArray(',', $oldModifiedBy))) {
             if (empty($this->modified_by)) {
                 $this->modified_by = $this->updated_by;
             } else {
                 $this->modified_by .= ',' . $this->updated_by;
             }
         }
     }
     //set productmodule_id to be null if productmodule_id = 0
     if (0 == $this->productmodule_id) {
         $this->productmodule_id = null;
     }
     //filter duplicated mail_to
     if (!empty($this->mail_to)) {
         $this->mail_to = join(',', CommonService::splitStringToArray(',', $this->mail_to));
     }
     //set assign_to
     if (!empty($this->assign_to_name)) {
         if (TestUser::ACTIVE_USER_NAME == $this->assign_to_name) {
             $this->assign_to = TestUser::ACTIVE_USER_ID;
         } else {
             if (TestUser::CLOSE_USER_NAME == $this->assign_to_name) {
                 $this->assign_to = TestUser::CLOSE_USER_ID;
             } else {
                 $assigntoInfo = TestUser::model()->findByAttributes(array('realname' => $this->assign_to_name));
                 if ($assigntoInfo !== null) {
                     $this->assign_to = $assigntoInfo->id;
                 } else {
                     $assigntoNameError = $this->getError('assign_to_name');
                     if (empty($assigntoNameError)) {
                         $this->addError('assign_to_name', $this->getAttributeLabel('assign_to_name') . ' ' . Yii::t('TestUser', 'user not found'));
                     }
                 }
             }
         }
     } else {
         $this->assign_to = null;
     }
     return parent::afterValidate();
 }
Esempio n. 2
0
 public function actionGetModuleOwner()
 {
     $moduleId = $_GET['module_id'];
     $moduleInfo = ProductModule::model()->findByPk($moduleId);
     $owner = '';
     if ($moduleInfo != null && !empty($moduleInfo->owner)) {
         $ownerInfo = TestUser::model()->findByPk($moduleInfo->owner);
         if ($ownerInfo != null) {
             $owner = $ownerInfo->realname;
         }
     }
     echo $owner;
 }
Esempio n. 3
0
 /**
  * get realname by name
  *
  * @param string $name
  * @return string
  */
 private function getRealNameByName($name)
 {
     $user = TestUser::model()->findByAttributes(array('username' => $name));
     if (null !== $user) {
         $name = $user->realname;
     }
     return $name;
 }
Esempio n. 4
0
 public static function getUserInfoByRealname($realname)
 {
     $userInfo = TestUser::model()->findByAttributes(array('realname' => $realname, 'is_dropped' => '0'));
     return $userInfo;
 }
Esempio n. 5
0
 /**
  * send mail message after action
  *
  * @author                                  youzhao.zxw<*****@*****.**>
  * @param   int    $infoId                  info id
  * @param   string $infoType                bug,case or result
  * @param   int    $actionId                action id
  * @param   string $repeatStep              repeat step
  * @param   string $replyNote               reply note
  * @return
  */
 private static function sendMessage($infoId, $infoType, $actionId, $repeatStep = '', $replyNote = '')
 {
     $className = ucfirst(strtolower($infoType)) . 'Info';
     $targetModel = new $className();
     $basicInfo = $targetModel->model()->findByPk($infoId);
     list($mailMsg, $wangwangMsg) = self::getMessageContent($basicInfo, $infoType, $actionId, $repeatStep, $replyNote);
     $assignToEmail = '';
     $wangwang = '';
     if (!empty($basicInfo->assign_to)) {
         if (Yii::app()->user->id != $basicInfo->assign_to) {
             $assignUserInfo = TestUser::model()->findByPk($basicInfo->assign_to);
             $assignToEmail = self::getUserEmail($assignUserInfo);
             $wangwang = self::getWangwang($assignUserInfo);
         }
     }
     $ccArr = self::getCCList($basicInfo, $assignToEmail);
     MailService::sysMail($assignToEmail, $ccArr, ucfirst(strtolower($infoType)) . ' #' . $infoId . ' ' . CommonService::sysSubStr($basicInfo['title'], 150, true), $mailMsg);
 }
Esempio n. 6
0
 /**
  * Returns the static model of the specified AR class.
  * Please note that you should have this exact method in all your CActiveRecord descendants!
  * @param string $className active record class name.
  * @return WTestUser the static model class
  */
 public static function model($className = __CLASS__)
 {
     return parent::model($className);
 }
Esempio n. 7
0
 /**
  * get user realname according to id
  *
  * @author                                  youzhao.zxw<*****@*****.**>
  * @param   int         $userId             user id
  * @return  string                          user realname
  */
 public static function getUserRealName($userId)
 {
     if (0 === $userId) {
         return Yii::t('Common', 'system created');
     } elseif (empty($userId)) {
         return '';
     }
     $userInfo = TestUser::model()->findByPk($userId);
     if ($userInfo !== null) {
         return $userInfo->realname;
     } else {
         //return Yii::t('Common', 'invalid user');
         return '';
     }
 }
Esempio n. 8
0
 /**
  * get the update user pinyin sql
  * @return sql str
  */
 public function actionSyncPinyin()
 {
     set_time_limit(0);
     $count = TestUser::model()->count();
     echo 'total count:' . $count;
     $start = 0;
     $errorno = 0;
     while ($start < $count) {
         $condition = new CDbCriteria();
         $condition->limit = 100;
         $condition->offset = $start;
         $users = TestUser::model()->findAll($condition);
         foreach ($users as $user) {
             if (!empty($user['realname'])) {
                 $pinyin = PinyinService::pinyin(strtolower($user['realname']));
                 //not full translated
                 if ($pinyin[2] == false) {
                     $errorno += 1;
                     echo "Error#update {{test_user}} set full_pinyin='" . $pinyin[0] . "',first_pinyin='" . $pinyin[1] . "' where id=" . $user['id'] . " and realname = '" . $user['realname'] . "' and username='******'username'] . "' ;<br/>";
                 } else {
                     echo "update {{test_user}} set full_pinyin='" . $pinyin[0] . "',first_pinyin='" . $pinyin[1] . "' where id=" . $user['id'] . " ;<br/>";
                 }
             }
         }
         $start += 100;
     }
     echo "total error:" . $errorno . '<br/>';
 }
Esempio n. 9
0
 protected function afterValidate()
 {
     if (!$this->getErrors()) {
         if (self::SCENARIO_EDIT == $this->scenario) {
             if (isset($this->owner_name) && '' != $this->owner_name) {
                 $userInfo = TestUser::model()->findByAttributes(array('realname' => $this->owner_name, 'is_dropped' => CommonService::$TrueFalseStatus['FALSE']));
                 if ($userInfo !== null) {
                     $this->owner = $userInfo->id;
                 } else {
                     $this->addError('owner_name', Yii::t('TestUser', 'user not found'));
                 }
             } else {
                 $this->owner = null;
             }
         }
     }
 }
Esempio n. 10
0
 public function confirmpassword($attribute, $params)
 {
     $model = TestUser::model()->findByPk($this->id);
     if (md5($this->password_old) != $model->password) {
         $this->addError('password_old', Yii::t('TestUser', 'old password wrong'));
     }
 }
Esempio n. 11
0
 /**
  * api authenticate
  * use the database data to validate
  *
  */
 public function apiAuthenticate()
 {
     $user = TestUser::model()->findByAttributes(array('username' => $this->username));
     if ($user === null) {
         $this->errorCode = self::ERROR_USER_NOT_FOUND;
     } else {
         if (CommonService::$TrueFalseStatus['TRUE'] == $user->is_dropped) {
             $this->errorCode = self::ERROR_USER_DISABLED;
             return !$this->errorCode;
         }
         if ($this->password !== $user->password) {
             $this->errorCode = self::ERROR_PASSWORD_INVALID;
         } else {
             $this->_id = $user->id;
             $this->username = $user->username;
             $this->setState('realname', $user->realname);
             $this->errorCode = self::ERROR_NONE;
         }
     }
     return !$this->errorCode;
 }
Esempio n. 12
0
 public static function getProductManagers($productId)
 {
     $managerNameStr = '';
     $managerIds = self::getProductManagerIds($productId);
     foreach ($managerIds as $managerId) {
         $userInfo = TestUser::model()->findByPk($managerId);
         if ($userInfo != null) {
             $managerNameStr .= $userInfo->realname . ",";
         }
     }
     if ('' != $managerNameStr) {
         $managerNameStr = substr($managerNameStr, 0, strlen($managerNameStr) - 1);
     }
     return $managerNameStr;
 }