/** * 预锟斤拷傻锟斤拷锟斤拷锟斤拷锟叫憋拷 * Enter description here ... */ public function actionPreGenThirdPartyUsers() { header('Content-type: application/json'); if (!Yii::app()->request->isPostRequest) { IjoyPlusServiceUtils::exportServiceError(Constants::METHOD_NOT_SUPPORT); return; } if (!IjoyPlusServiceUtils::validateAPPKey()) { IjoyPlusServiceUtils::exportServiceError(Constants::APP_KEY_INVALID); return; } if (IjoyPlusServiceUtils::validateUserID()) { IjoyPlusServiceUtils::exportServiceError(Constants::USER_ID_INVALID); return; } $sourceid = Yii::app()->request->getParam("source_ids"); $source_type = Yii::app()->request->getParam("source_type"); if (!isset($sourceid) || is_null($sourceid)) { IjoyPlusServiceUtils::exportServiceError(Constants::PARAM_IS_INVALID); return; } if (IjoyPlusServiceUtils::validateThirdPartSource($source_type)) { try { Yii::app()->user->setState("generateUsersByThirdPart_" . $source_type, '1'); User::model()->generateUsersByThirdPart($source_type, explode(',', $sourceid)); Yii::app()->user->setState("generateUsersByThirdPart_" . $source_type, '0'); IjoyPlusServiceUtils::exportServiceError(Constants::SUCC); } catch (Exception $e) { Yii::app()->user->setState("generateUsersByThirdPart_" . $source_type, '0'); IjoyPlusServiceUtils::exportServiceError(Constants::SYSTEM_ERROR); } } else { IjoyPlusServiceUtils::exportServiceError(Constants::THIRD_PART_SOURCE_TYPE_INVALID); } }
/** * register user * Enter description here ... */ function actionUpdateProfile() { header('Content-type: application/json'); // if(!Yii::app()->request->isPostRequest){ // IjoyPlusServiceUtils::exportServiceError(Constants::METHOD_NOT_SUPPORT); // return ; // } if (!IjoyPlusServiceUtils::validateAPPKey()) { IjoyPlusServiceUtils::exportServiceError(Constants::APP_KEY_INVALID); return; } $nickname = Yii::app()->request->getParam("nickname"); $pwd = Yii::app()->request->getParam("password"); $username = Yii::app()->request->getParam("username"); $sourceid = Yii::app()->request->getParam("source_id"); $source_type = Yii::app()->request->getParam("source_type"); if (!IjoyPlusServiceUtils::validateThirdPartSource($source_type)) { IjoyPlusServiceUtils::exportServiceError(Constants::THIRD_PART_SOURCE_TYPE_INVALID); return; } if (!(isset($nickname) && !is_null($nickname) && strlen($nickname) > 0)) { IjoyPlusServiceUtils::exportServiceError(Constants::NICKNAME_IS_NULL); return; } if (!(isset($pwd) && !is_null($pwd) && strlen($pwd) > 0)) { IjoyPlusServiceUtils::exportServiceError(Constants::PWD_IS_NULL); return; } if (isset($username) && !is_null($username) && strlen($username) > 0) { $emailValidator = new CEmailValidator(); if (!$emailValidator->validateValue($username)) { IjoyPlusServiceUtils::exportServiceError(Constants::EMAIL_INVALID); return; } else { $record = User::model()->find('LOWER(username)=?', array(strtolower($username))); if ($record !== null) { IjoyPlusServiceUtils::exportServiceError(Constants::USERNAME_EXIST); return; } } } try { $record = User::model()->find('LOWER(nickname)=?', array(strtolower($nickname))); if ($record !== null) { IjoyPlusServiceUtils::exportServiceError(Constants::NICKNAME_IS_EXSTING); return; } else { $model = new User(); $model->nickname = $nickname; $model->password = md5($pwd); $model->username = $username; $model->status = Constants::USER_APPROVAL; $model->create_date = new CDbExpression('NOW()'); switch ($source_type) { case Constants::THIRD_PART_ACCOUNT_DOUBAN: $model->douban_user_id = $sourceid; break; case Constants::THIRD_PART_ACCOUNT_QQ: $model->qq_wb_user_id = $sourceid; break; case Constants::THIRD_PART_ACCOUNT_REN_REN: $model->ren_user_id = $sourceid; break; case Constants::THIRD_PART_ACCOUNT_SINA: $model->sina_wb_user_id = $sourceid; break; } if ($model->save()) { $identity = new IjoyPlusUserIdentity($username, $pwd); $identity->setId($model->id); $identity->setState('nickname', $model->nickname); Yii::app()->user->login($identity); UserManager::followPrestiges($model->id); IjoyPlusServiceUtils::exportServiceError(Constants::SUCC); // } else { Yii::log(CJSON::encode($model->getErrors()), "warning"); // var_dump(); IjoyPlusServiceUtils::exportServiceError(Constants::SYSTEM_ERROR); } } } catch (Exception $e) { Yii::log(CJSON::encode($e), "error"); IjoyPlusServiceUtils::exportServiceError(Constants::SYSTEM_ERROR); } }