public static function updateUser($user_id, $data = null) { $user = User::findOne($user_id); $user->scenario = 'settings'; $profile = $user->profile; $oldEmail = $user->email; if ($user->load(['User' => $data]) && $user->validate()) { if ($user->email != $oldEmail) { $user->unconfirmed_email = $user->email; $user->email = $oldEmail; $token = \Yii::createObject(['class' => Token::className(), 'user_id' => $user->id, 'type' => Token::TYPE_CONFIRM_NEW_EMAIL]); $token->save(false); $mailer = Yii::createObject(['class' => Mailer::className(), 'reconfirmationSubject' => 'Mail confirmation']); $mailer->sendReconfirmationMessage($user, $token); } if (!$profile) { $profile = Yii::createObject(['class' => Profile::className(), 'user_id' => $user->id]); $profile->save(); } $profile->load(['Profile' => $data]); $profile->save(); $user->save(); } else { self::error($user); } return self::clearUserData($user); }
/** * undocumented function * * @return void * @author **/ public function actionTest() { // $logo = 'http://mmbiz.qpic.cn/mmbiz/VaOtLa56KEQOCrPR9fudMianNoYbnEcbRW2eMRK5EvBpeOfPfMrcbVqKH2OAp6E2xWEKDoKGMGKHCqDq7aVuuGA/0'; // $fh = file_get_contents($logo); // file_put_contents(Yii::getAlias('@frontend/web/') . 'erweima.jpg', $fh); // $wechat = Yii::$app->wechat->getPfInstance($this->config->platform_info); // $xml = '<xml> // <AppId><![CDATA[wxc66ffc63e5b9576f]]></AppId> // <Encrypt><![CDATA[MIQKxqY9v6fHupdatePfToken(null, true)d5ynDqqjcDa1ahOALIECq1p1uQCmZGIwisYCeuntcO9oDUZPermloooPPguxEVGD0GV0t0YNu9+V7wpEHO2sBmtMOf0zECoaKq7KlTbewGUXfW5l1UrxQsmsQjO1Idc/t5MxImMKAa6822GmZ7KiL8D7cWe05V8kfaGMdHElX0e9Ql7gAtqwZ9SIAUF2CR4UEXUtc+qcekExsZA5D4FDIOXYC0h38FagcXV//Mtd0yALRSsFROWJAj85ZPErNEtyEv1MVzlPBJgnMXxJ6HsqIkBRmmVeV7ymVecsAY9K3Vn1MUso3jSoC0Vrxe+1gwvwW1s3ZWc5yY5RP9vqN5XfOZLm4p14KYeawjJ64qoB2zxygYNF26tQE2ixpXgfIoj1ILxsSwtSnVdn6+nQuio5LfZ64AYIyCEare1Aa2b1WdrfCE46hygz3d8cNtlcDX2atpUSyOz4SA==]]></Encrypt> // </xml>'; // // $wechat->clearCache(); // // $wechat->getComponentAccessToken($xml); // print_r($wechat->getAuthorizerInfo());exit; // echo file_get_contents('http://wx.chuangyejia.com/dev/wx.log'); // echo '<pre>';print_r($this->config->platform_info); $token = \frontend\models\Token::getInstance(); $token->updatePfToken(null, true); return true; }
public function actionRazzVote() { $request = Yii::$app->request; $token = Token::checkToken($request->get('token')); if (!is_array($token)) { throw new HttpException(401, $token); } $model = new Razz(); $razz = $model->getRazz($request->get('id')); if (!$razz) { throw new HttpException(404, 'Razzd not found.'); } if (!$razz['responder_stream']) { throw new HttpException(422, 'Razzd is not started.'); } if ($razz['created_at'] + Razz::DAYS < time()) { throw new HttpException(422, 'Razzd is ended.'); } $ratingModel = Yii::createObject(['class' => \frontend\widgets\rating\models\Rating::className(), 'nid' => $request->get('id'), 'model' => 'Razz', 'vote' => $request->get('vote') == 'my' ? ['my' => 1] : ['responder' => 1], 'uid' => $token['user_id']]); if ($ratingModel->save()) { return RestApi::response($ratingModel->return); } return RestApi::response($ratingModel->return); }