本文整理汇总了PHP中humhub\modules\user\models\User::isCurrentUser方法的典型用法代码示例。如果您正苦于以下问题:PHP User::isCurrentUser方法的具体用法?PHP User::isCurrentUser怎么用?PHP User::isCurrentUser使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类humhub\modules\user\models\User
的用法示例。
在下文中一共展示了User::isCurrentUser方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: run
/**
* @inheritdoc
*/
public function run()
{
if ($this->user->isCurrentUser() || \Yii::$app->user->isGuest) {
return;
}
if (Yii::$app->getModule('friendship')->getIsEnabled()) {
// Don't show follow button, when friends
if (Friendship::getFriendsQuery($this->user)->one() !== null) {
return;
}
}
// Add class for javascript handling
$this->followOptions['class'] .= ' followButton';
$this->unfollowOptions['class'] .= ' unfollowButton';
// Hide inactive button
if ($this->user->isFollowedByUser()) {
$this->followOptions['style'] .= ' display:none;';
} else {
$this->unfollowOptions['style'] .= ' display:none;';
}
// Add UserId Buttons
$this->followOptions['data-userid'] = $this->user->id;
$this->unfollowOptions['data-userid'] = $this->user->id;
$this->view->registerJsFile('@web/resources/user/followButton.js');
return Html::a($this->unfollowLabel, $this->user->createUrl('/user/profile/unfollow'), $this->unfollowOptions) . Html::a($this->followLabel, $this->user->createUrl('/user/profile/follow'), $this->followOptions);
}
示例2: run
/**
* @inheritdoc
*/
public function run()
{
if ($this->user->isCurrentUser() || \Yii::$app->user->isGuest) {
return;
}
// Add class for javascript handling
$this->followOptions['class'] .= ' followButton';
$this->unfollowOptions['class'] .= ' unfollowButton';
// Hide inactive button
if ($this->user->isFollowedByUser()) {
$this->followOptions['style'] .= ' display:none;';
} else {
$this->unfollowOptions['style'] .= ' display:none;';
}
// Add UserId Buttons
$this->followOptions['data-userid'] = $this->user->id;
$this->unfollowOptions['data-userid'] = $this->user->id;
$this->view->registerJsFile('@web/resources/user/followButton.js');
return Html::a($this->unfollowLabel, $this->user->createUrl('/user/profile/unfollow'), $this->unfollowOptions) . Html::a($this->followLabel, $this->user->createUrl('/user/profile/follow'), $this->followOptions);
}