本文整理汇总了PHP中frontend\models\User::getClientIdByUid方法的典型用法代码示例。如果您正苦于以下问题:PHP User::getClientIdByUid方法的具体用法?PHP User::getClientIdByUid怎么用?PHP User::getClientIdByUid使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类frontend\models\User
的用法示例。
在下文中一共展示了User::getClientIdByUid方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: amIClient
public function amIClient($uid = null)
{
$isLogged = false;
if (is_null($uid)) {
if (!Yii::$app->user->isGuest) {
$uid = Yii::$app->getUser()->id;
}
}
if (!is_null($uid)) {
if (($client_id = (int) User::getClientIdByUid($uid)) > 0) {
$this->client_id = $client_id;
$isLogged = true;
}
}
return $isLogged;
}
示例2: actionRespond
public function actionRespond($id = null, $hash = null)
{
$model = null;
$userModel = new \frontend\models\User();
if ($id) {
$model = Razz::findOne($id);
} elseif ($hash) {
$model = Razz::findOne(['hash' => $hash]);
}
if (Yii::$app->getUser()->id === $model->uid) {
//throw new HttpException(404, 'You are not allowed to respond to your own challenge!');
return $this->render('error', ['model' => $model, 'message' => 'You are not allowed to respond to your own challenge!', 'userModel' => $userModel]);
}
if (!$model) {
throw new HttpException(404, 'Razzd not found');
}
$model->scenario = 'respond';
if ($model->responder_stream) {
throw new HttpException(403, 'Razzd already responded.');
}
if (!Yii::$app->user->isGuest && $id && $model->hash && Yii::$app->user->id != $model->responder_uid) {
// throw new HttpException(403, 'This razzd for other user.');
} elseif (Yii::$app->user->isGuest && $model->responder_uid) {
$this->redirect(['/login']);
}
if (!Yii::$app->user->isGuest && $id && $model->hash) {
if (!is_null($model->facebook_id)) {
$client_id = User::getClientIdByUid(Yii::$app->user->id);
if ((int) $client_id != (int) $model->facebook_id) {
throw new HttpException(403, 'This razzd for other user!');
}
} elseif (!is_null($model->responder_uid)) {
if (Yii::$app->user->id != $model->responder_uid) {
throw new HttpException(403, 'This razzd for other user...');
}
}
}
if ($model->load(Yii::$app->request->post()) && $model->save()) {
$this->redirect('/razz/' . $model->id);
} else {
// print_r($model->getErrors());
//exit();
}
return $this->render('respond', ['model' => $model, 'userModel' => $userModel]);
}