当前位置: 首页>>代码示例>>PHP>>正文


PHP User::getRoles方法代码示例

本文整理汇总了PHP中bizley\podium\models\User::getRoles方法的典型用法代码示例。如果您正苦于以下问题:PHP User::getRoles方法的具体用法?PHP User::getRoles怎么用?PHP User::getRoles使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在bizley\podium\models\User的用法示例。


在下文中一共展示了User::getRoles方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: rules

 /**
  * @inheritdoc
  */
 public function rules()
 {
     return [[['id'], 'integer'], [['username', 'email'], 'safe'], [['status'], 'in', 'range' => array_keys(User::getStatuses())], [['role'], 'in', 'range' => array_keys(User::getRoles())]];
 }
开发者ID:Avenger1,项目名称:yii2-podium,代码行数:7,代码来源:UserSearch.php

示例2: function

</a></li>
    <li role="presentation"><a href="<?php 
echo Url::to(['members/mods']);
?>
"><span class="glyphicon glyphicon-scissors"></span> <?php 
echo Yii::t('podium/view', 'Moderation Team');
?>
</a></li>
</ul>
<br>
<?php 
Pjax::begin();
echo PageSizer::widget();
echo GridView::widget(['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'filterSelector' => 'select#per-page', 'tableOptions' => ['class' => 'table table-striped table-hover'], 'columns' => [['attribute' => 'username', 'label' => Yii::t('podium/view', 'Username') . Helper::sortOrder('username'), 'encodeLabel' => false, 'format' => 'raw', 'value' => function ($model) {
    return Html::a($model->podiumName, ['members/view', 'id' => $model->id, 'slug' => $model->podiumSlug], ['data-pjax' => '0']);
}], ['attribute' => 'role', 'label' => Yii::t('podium/view', 'Role') . Helper::sortOrder('role'), 'encodeLabel' => false, 'format' => 'raw', 'filter' => User::getRoles(), 'value' => function ($model) {
    return Helper::roleLabel($model->role);
}], ['attribute' => 'created_at', 'label' => Yii::t('podium/view', 'Joined') . Helper::sortOrder('created_at'), 'encodeLabel' => false, 'value' => function ($model) {
    return Yii::$app->formatter->asDatetime($model->created_at);
}], ['attribute' => 'threads_count', 'label' => Yii::t('podium/view', 'Threads'), 'encodeLabel' => false, 'value' => function ($model) {
    return $model->threadsCount;
}], ['attribute' => 'posts_count', 'label' => Yii::t('podium/view', 'Posts'), 'encodeLabel' => false, 'value' => function ($model) {
    return $model->postsCount;
}], ['class' => ActionColumn::className(), 'header' => Yii::t('podium/view', 'Actions'), 'contentOptions' => ['class' => 'text-right'], 'headerOptions' => ['class' => 'text-right'], 'template' => '{view}' . (!Yii::$app->user->isGuest ? ' {pm}' : ''), 'buttons' => ['view' => function ($url, $model) {
    return Html::a('<span class="glyphicon glyphicon-eye-open"></span>', ['members/view', 'id' => $model->id, 'slug' => $model->podiumSlug], ['class' => 'btn btn-default btn-xs', 'data-pjax' => '0', 'data-toggle' => 'tooltip', 'data-placement' => 'top', 'title' => Yii::t('podium/view', 'View Member')]);
}, 'pm' => function ($url, $model) {
    if ($model->id !== User::loggedId()) {
        return Html::a('<span class="glyphicon glyphicon-envelope"></span>', ['messages/new', 'user' => $model->id], ['class' => 'btn btn-default btn-xs', 'data-pjax' => '0', 'data-toggle' => 'tooltip', 'data-placement' => 'top', 'title' => Yii::t('podium/view', 'Send Message')]);
    } else {
        return Html::a('<span class="glyphicon glyphicon-envelope"></span>', '#', ['class' => 'btn btn-xs disabled text-muted']);
    }
开发者ID:gitter-badger,项目名称:yii2-podium,代码行数:31,代码来源:index.php

示例3: roleLabel

 /**
  * Gets role label html.
  * @param integer|null $role role ID
  * @return string label html
  */
 public static function roleLabel($role = null)
 {
     switch ($role) {
         case User::ROLE_ADMIN:
             $label = 'danger';
             $name = ArrayHelper::getValue(User::getRoles(), $role);
             break;
         case User::ROLE_MODERATOR:
             $label = 'primary';
             $name = ArrayHelper::getValue(User::getRoles(), $role);
             break;
         default:
             $label = 'success';
             $name = ArrayHelper::getValue(User::getRoles(), User::ROLE_MEMBER);
     }
     return Html::tag('span', Yii::t('podium/view', $name), ['class' => 'label label-' . $label]);
 }
开发者ID:keltstr,项目名称:yii2-podium,代码行数:22,代码来源:Helper.php

示例4: function

    <li role="presentation"><a href="<?php 
echo Url::to(['members/mods']);
?>
"><span class="glyphicon glyphicon-scissors"></span> <?php 
echo Yii::t('podium/view', 'Moderation Team');
?>
</a></li>
</ul>
<br>
<?php 
Pjax::begin();
echo PageSizer::widget();
echo GridView::widget(['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'filterSelector' => 'select#per-page', 'tableOptions' => ['class' => 'table table-striped table-hover'], 'columns' => [['attribute' => 'username', 'label' => Yii::t('podium/view', 'Username') . Helper::sortOrder('username'), 'encodeLabel' => false, 'format' => 'raw', 'value' => function ($model) {
    return Html::a($model->podiumName, ['members/view', 'id' => $model->id, 'slug' => $model->podiumSlug], ['data-pjax' => '0']);
}], ['attribute' => 'role', 'label' => Yii::t('podium/view', 'Role') . Helper::sortOrder('role'), 'encodeLabel' => false, 'filter' => User::getRoles(), 'value' => function ($model) {
    return Yii::t('podium/view', ArrayHelper::getValue(User::getRoles(), $model->role));
}], ['attribute' => 'created_at', 'label' => Yii::t('podium/view', 'Joined') . Helper::sortOrder('created_at'), 'encodeLabel' => false, 'value' => function ($model) {
    return Yii::$app->formatter->asDatetime($model->created_at);
}], ['attribute' => 'threads_count', 'label' => Yii::t('podium/view', 'Threads'), 'encodeLabel' => false, 'value' => function ($model) {
    return $model->threadsCount;
}], ['attribute' => 'posts_count', 'label' => Yii::t('podium/view', 'Posts'), 'encodeLabel' => false, 'value' => function ($model) {
    return $model->postsCount;
}], ['class' => ActionColumn::className(), 'header' => Yii::t('podium/view', 'Actions'), 'contentOptions' => ['class' => 'text-right'], 'headerOptions' => ['class' => 'text-right'], 'template' => '{view}' . (!Yii::$app->user->isGuest ? ' {pm}' : ''), 'buttons' => ['view' => function ($url) {
    return Html::a('<span class="glyphicon glyphicon-eye-open"></span>', $url, ['class' => 'btn btn-default btn-xs', 'data-pjax' => '0', 'data-toggle' => 'tooltip', 'data-placement' => 'top', 'title' => Yii::t('podium/view', 'View Member')]);
}, 'pm' => function ($url, $model) {
    if ($model->id !== User::loggedId()) {
        return Html::a('<span class="glyphicon glyphicon-envelope"></span>', ['messages/new', 'user' => $model->id], ['class' => 'btn btn-default btn-xs', 'data-pjax' => '0', 'data-toggle' => 'tooltip', 'data-placement' => 'top', 'title' => Yii::t('podium/view', 'Send Message')]);
    } else {
        return Html::a('<span class="glyphicon glyphicon-envelope"></span>', '#', ['class' => 'btn btn-xs disabled text-muted']);
    }
}]]]]);
开发者ID:Avenger1,项目名称:yii2-podium,代码行数:31,代码来源:index.php

示例5: roleLabel

 /**
  * Returns role label html.
  * @param integer|null $role role ID
  * @return string label html
  */
 public static function roleLabel($role = null)
 {
     switch ($role) {
         case User::ROLE_ADMIN:
             $label = 'danger';
             $name = ArrayHelper::getValue(User::getRoles(), $role);
             break;
         case User::ROLE_MODERATOR:
             $label = 'info';
             $name = ArrayHelper::getValue(User::getRoles(), $role);
             break;
         default:
             $label = 'warning';
             $name = ArrayHelper::getValue(User::getRoles(), User::ROLE_MEMBER);
     }
     return Html::tag('span', $name, ['class' => 'label label-' . $label]);
 }
开发者ID:gitter-badger,项目名称:yii2-podium,代码行数:22,代码来源:Helper.php

示例6: function

$this->params['breadcrumbs'][] = $this->title;
$this->registerJs("\$('[data-toggle=\"tooltip\"]').tooltip();");
$this->registerJs("\$('#podiumModalDelete').on('show.bs.modal', function(e) { var button = \$(e.relatedTarget); \$('#deleteUrl').attr('href', button.data('url')); });");
$this->registerJs("\$('#podiumModalBan').on('show.bs.modal', function(e) { var button = \$(e.relatedTarget); \$('#banUrl').attr('href', button.data('url')); });");
$this->registerJs("\$('#podiumModalUnBan').on('show.bs.modal', function(e) { var button = \$(e.relatedTarget); \$('#unbanUrl').attr('href', button.data('url')); });");
$loggedId = User::loggedId();
echo $this->render('/elements/admin/_navbar', ['active' => 'members']);
?>
<br>
<?php 
Pjax::begin();
echo PageSizer::widget();
echo GridView::widget(['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'filterSelector' => 'select#per-page', 'tableOptions' => ['class' => 'table table-striped table-hover'], 'columns' => [['attribute' => 'id', 'label' => Yii::t('podium/view', 'ID') . Helper::sortOrder('id'), 'encodeLabel' => false, 'contentOptions' => ['class' => 'col-sm-1 text-right'], 'headerOptions' => ['class' => 'col-sm-1 text-right']], ['attribute' => 'username', 'label' => Yii::t('podium/view', 'Username') . Helper::sortOrder('username'), 'encodeLabel' => false], ['attribute' => 'email', 'label' => Yii::t('podium/view', 'E-mail') . Helper::sortOrder('email'), 'encodeLabel' => false, 'format' => 'raw', 'value' => function ($model) {
    return Html::mailto($model->email);
}], ['attribute' => 'role', 'label' => Yii::t('podium/view', 'Role') . Helper::sortOrder('role'), 'encodeLabel' => false, 'filter' => User::getRoles(), 'value' => function ($model) {
    return ArrayHelper::getValue(User::getRoles(), $model->role);
}], ['attribute' => 'status', 'label' => Yii::t('podium/view', 'Status') . Helper::sortOrder('status'), 'encodeLabel' => false, 'filter' => User::getStatuses(), 'value' => function ($model) {
    return ArrayHelper::getValue(User::getStatuses(), $model->status);
}], ['class' => ActionColumn::className(), 'header' => Yii::t('podium/view', 'Actions'), 'contentOptions' => ['class' => 'text-right'], 'headerOptions' => ['class' => 'text-right'], 'template' => '{view} {pm} {ban} {delete}', 'buttons' => ['view' => function ($url) {
    return Html::a('<span class="glyphicon glyphicon-eye-open"></span>', $url, ['class' => 'btn btn-default btn-xs', 'data-pjax' => '0', 'data-toggle' => 'tooltip', 'data-placement' => 'top', 'title' => Yii::t('podium/view', 'View Member')]);
}, 'pm' => function ($url, $model) use($loggedId) {
    if ($model->id !== $loggedId) {
        return Html::a('<span class="glyphicon glyphicon-envelope"></span>', ['messages/new', 'user' => $model->id], ['class' => 'btn btn-default btn-xs', 'data-pjax' => '0', 'data-toggle' => 'tooltip', 'data-placement' => 'top', 'title' => Yii::t('podium/view', 'Send Message')]);
    } else {
        return Html::a('<span class="glyphicon glyphicon-envelope"></span>', '#', ['class' => 'btn btn-xs disabled text-muted']);
    }
}, 'ban' => function ($url, $model) use($loggedId) {
    if ($model->id !== $loggedId) {
        if ($model->status !== User::STATUS_BANNED) {
            return Html::tag('span', Html::tag('button', '<span class="glyphicon glyphicon-ban-circle"></span>', ['class' => 'btn btn-danger btn-xs', 'data-toggle' => 'tooltip', 'data-placement' => 'top', 'title' => Yii::t('podium/view', 'Ban Member')]), ['data-toggle' => 'modal', 'data-target' => '#podiumModalBan', 'data-url' => $url]);
        } else {
开发者ID:gitter-badger,项目名称:yii2-podium,代码行数:31,代码来源:members.php


注:本文中的bizley\podium\models\User::getRoles方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。