本文整理汇总了PHP中bizley\podium\models\User类的典型用法代码示例。如果您正苦于以下问题:PHP User类的具体用法?PHP User怎么用?PHP User使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了User类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: init
/**
* Creates inherited user account.
*/
public function init()
{
parent::init();
if (!Yii::$app->user->isGuest) {
if (PodiumModule::getInstance()->userComponent == PodiumModule::USER_INHERIT) {
$user = User::findMe();
if (empty($user)) {
$new = new User();
$new->setScenario('installation');
$new->inherited_id = Yii::$app->user->id;
$new->status = User::STATUS_ACTIVE;
$new->role = User::ROLE_MEMBER;
$new->timezone = User::DEFAULT_TIMEZONE;
if ($new->save()) {
$this->success(Yii::t('podium/flash', Messages::ACCOUNT_INHERITED, ['link' => Html::a(Yii::t('podium/layout', 'Profile'))]));
Cache::clearAfterActivate();
Log::info('Inherited account created', $new->id, __METHOD__);
} else {
throw new Exception(Yii::t('podium/view', Messages::ACCOUNT_INHERITED_ERROR));
}
} elseif ($user->status == User::STATUS_BANNED) {
return $this->redirect(['default/ban']);
}
} else {
$user = Yii::$app->user->identity;
}
if ($user && !empty($user->timezone)) {
Yii::$app->formatter->timeZone = $user->timezone;
}
}
}
开发者ID:Avenger1,项目名称:yii2-podium,代码行数:34,代码来源:BaseController.php
示例2: getUser
/**
* Returns User.
* @param integer $status
* @return User
*/
public function getUser($status = null)
{
if ($this->_user === false) {
$this->_user = User::findByKeyfield($this->username, $status);
}
return $this->_user;
}
开发者ID:Avenger1,项目名称:yii2-podium,代码行数:12,代码来源:ReForm.php
示例3: actionFieldlist
/**
* Listing the active users for ajax.
* @return string|\yii\web\Response
*/
public function actionFieldlist($q = null)
{
if (Yii::$app->request->isAjax) {
if (!is_null($q) && is_string($q)) {
$cache = Cache::getInstance()->get('members.fieldlist');
if ($cache === false || empty($cache[$q])) {
if ($cache === false) {
$cache = [];
}
$users = User::find()->where(['and', ['status' => User::STATUS_ACTIVE], ['or', ['like', 'username', $q], ['username' => null]]])->orderBy('username, id');
$results = ['results' => []];
foreach ($users->each() as $user) {
$results['results'][] = ['id' => $user->id, 'text' => $user->getPodiumTag(true)];
}
if (!empty($results['results'])) {
$cache[$q] = Json::encode($results);
Cache::getInstance()->set('members.fieldlist', $cache);
} else {
return Json::encode(['results' => []]);
}
}
return $cache[$q];
} else {
return Json::encode(['results' => []]);
}
} else {
return $this->redirect(['default/index']);
}
}
开发者ID:keltstr,项目名称:yii2-podium,代码行数:33,代码来源:MembersController.php
示例4: getUser
/**
* Return User.
* @return User
*/
public function getUser()
{
if ($this->_user === false) {
$this->_user = User::findByKeyfield($this->username);
}
return $this->_user;
}
开发者ID:Avenger1,项目名称:yii2-podium,代码行数:11,代码来源:LoginForm.php
示例5: blame
/**
* Returns ID of user responsible for logged action.
* @return integer|null
*/
public static function blame()
{
if (Yii::$app instanceof Application && !Yii::$app->user->isGuest) {
return User::loggedId();
}
return null;
}
开发者ID:Avenger1,项目名称:yii2-podium,代码行数:11,代码来源:Log.php
示例6: search
/**
* Searches for subscription
* @param array $params
* @return ActiveDataProvider
*/
public function search($params)
{
$query = self::find()->where(['user_id' => User::loggedId()]);
$dataProvider = new ActiveDataProvider(['query' => $query, 'pagination' => ['defaultPageSize' => 10, 'forcePageParam' => false]]);
$dataProvider->sort->defaultOrder = ['post_seen' => SORT_ASC, 'id' => SORT_DESC];
$dataProvider->pagination->pageSize = Yii::$app->session->get('per-page', 20);
return $dataProvider;
}
开发者ID:gitter-badger,项目名称:yii2-podium,代码行数:13,代码来源:Subscription.php
示例7: _addAdmin
/**
* Adds Administrator account.
* @return string result message.
*/
protected function _addAdmin()
{
try {
$podium = PodiumModule::getInstance();
if ($podium->userComponent == PodiumModule::USER_INHERIT) {
if (!empty($podium->adminId)) {
$this->authManager->assign($this->authManager->getRole('podiumAdmin'), $podium->adminId);
return $this->outputSuccess(Yii::t('podium/flash', Messages::ADMINISTRATOR_PRIVILEGES_SET, ['id' => $podium->adminId]));
} else {
return $this->outputWarning(Yii::t('podium/flash', Messages::NO_ADMINISTRATOR_PRIVILEGES_SET));
}
} else {
$admin = new User();
$admin->setScenario('installation');
$admin->username = self::DEFAULT_USERNAME;
$admin->email = self::DEFAULT_USER_EMAIL;
$admin->status = User::STATUS_ACTIVE;
$admin->role = User::ROLE_ADMIN;
$admin->generateAuthKey();
$admin->setPassword(self::DEFAULT_USERNAME);
if ($admin->save()) {
$this->authManager->assign($this->authManager->getRole('podiumAdmin'), $admin->getId());
return $this->outputSuccess(Yii::t('podium/flash', Messages::ADMINISTRATOR_ACCOUNT_CREATED) . ' ' . Html::tag('strong', Yii::t('podium/flash', 'Login') . ':') . ' ' . Html::tag('kbd', self::DEFAULT_USERNAME) . ' ' . Html::tag('strong', Yii::t('podium/flash', 'Password') . ':') . ' ' . Html::tag('kbd', self::DEFAULT_USERNAME));
} else {
$this->setError(true);
return $this->outputDanger(Yii::t('podium/flash', Messages::ACCOUNT_CREATING_ERROR) . ': ' . Html::tag('pre', VarDumper::dumpAsString($admin->getErrors())));
}
}
} catch (Exception $e) {
Yii::error([$e->getName(), $e->getMessage()], __METHOD__);
$this->setError(true);
return $this->outputDanger(Yii::t('podium/flash', Messages::ACCOUNT_CREATING_ERROR) . ': ' . Html::tag('pre', $e->getMessage()));
}
}
开发者ID:keltstr,项目名称:yii2-podium,代码行数:38,代码来源:Installation.php
示例8: search
/**
* Searches for threads with unread posts.
* @param array $params
* @return ActiveDataProvider
*/
public function search()
{
$loggedId = User::loggedId();
$query = Thread::find()->joinWith('threadView')->where(['or', ['and', ['user_id' => $loggedId], new Expression('`new_last_seen` < `new_post_at`')], ['and', ['user_id' => $loggedId], new Expression('`edited_last_seen` < `edited_post_at`')], ['user_id' => null]]);
$dataProvider = new ActiveDataProvider(['query' => $query, 'pagination' => ['defaultPageSize' => 10, 'forcePageParam' => false]]);
$dataProvider->sort->defaultOrder = ['edited_post_at' => SORT_ASC, 'id' => SORT_ASC];
$dataProvider->pagination->pageSize = Yii::$app->session->get('per-page', 20);
return $dataProvider;
}
开发者ID:gitter-badger,项目名称:yii2-podium,代码行数:14,代码来源:ThreadView.php
示例9: validateCurrentPassword
public function validateCurrentPassword($attribute)
{
if (!empty($this->user_id)) {
$user = User::findOne($this->user_id);
if (!$user->validatePassword($this->current_password)) {
$this->addError($attribute, Yii::t('podium/view', 'Current password is incorrect.'));
}
}
}
开发者ID:keltstr,项目名称:yii2-podium,代码行数:9,代码来源:Meta.php
示例10: search
/**
* Searches for subscription
* @param array $params
* @return ActiveDataProvider
*/
public function search($params)
{
$query = self::find()->where(['user_id' => User::loggedId()]);
$dataProvider = new ActiveDataProvider(['query' => $query, 'pagination' => ['defaultPageSize' => 10, 'forcePageParam' => false]]);
$dataProvider->sort->defaultOrder = ['post_seen' => SORT_ASC, 'id' => SORT_DESC];
if (!($this->load($params) && $this->validate())) {
return $dataProvider;
}
return $dataProvider;
}
开发者ID:Avenger1,项目名称:yii2-podium,代码行数:15,代码来源:Subscription.php
示例11: run
/**
* Renders the list of users reading current section.
* @return string
*/
public function run()
{
$url = Yii::$app->request->getUrl();
$out = '';
switch ($this->what) {
case 'forum':
$out .= Yii::t('podium/view', 'Browsing this forum') . ': ';
break;
case 'topic':
$out .= Yii::t('podium/view', 'Reading this thread') . ': ';
break;
case 'unread':
$out .= Yii::t('podium/view', 'Browsing unread threads') . ': ';
break;
case 'members':
$out .= Yii::t('podium/view', 'Browsing the members') . ': ';
break;
}
$conditions = ['and', [Activity::tableName() . '.anonymous' => 0], ['is not', 'user_id', null], new Expression('`url` LIKE :url'), ['>=', Activity::tableName() . '.updated_at', time() - 5 * 60]];
$guest = true;
$anon = false;
if (!Yii::$app->user->isGuest) {
$guest = false;
$me = User::findMe();
$conditions[] = ['not in', 'user_id', $me->id];
if ($me->anonymous == 0) {
$out .= $me->podiumTag . ' ';
} else {
$anon = true;
}
}
$users = Activity::find()->joinWith(['user'])->where($conditions)->params([':url' => $url . '%']);
foreach ($users->each() as $user) {
$out .= $user->user->podiumTag . ' ';
}
$conditions = ['and', ['anonymous' => 1], new Expression('`url` LIKE :url'), ['>=', 'updated_at', time() - 5 * 60]];
$anonymous = Activity::find()->where($conditions)->params([':url' => $url . '%'])->count('id');
if ($anon) {
$anonymous += 1;
}
$conditions = ['and', ['user_id' => null], new Expression('`url` LIKE :url'), ['>=', 'updated_at', time() - 5 * 60]];
$guests = Activity::find()->where($conditions)->params([':url' => $url . '%'])->count('id');
if ($guest) {
$guests += 1;
}
if ($anonymous) {
$out .= Html::button(Yii::t('podium/view', '{n, plural, =1{# anonymous user} other{# anonymous users}}', ['n' => $anonymous]), ['class' => 'btn btn-xs btn-default disabled']) . ' ';
}
if ($guests) {
$out .= Html::button(Yii::t('podium/view', '{n, plural, =1{# guest} other{# guests}}', ['n' => $guests]), ['class' => 'btn btn-xs btn-default disabled']);
}
return $out;
}
开发者ID:gitter-badger,项目名称:yii2-podium,代码行数:57,代码来源:Readers.php
示例12: search
/**
* @inheritdoc
*/
public function search($params, $active = false, $mods = false)
{
$query = User::find();
if ($active) {
$query->andWhere(['!=', 'status', User::STATUS_REGISTERED]);
}
if ($mods) {
$query->andWhere(['role' => [User::ROLE_ADMIN, User::ROLE_MODERATOR]]);
}
$dataProvider = new ActiveDataProvider(['query' => $query]);
$dataProvider->sort->defaultOrder = ['id' => SORT_ASC];
if (!($this->load($params) && $this->validate())) {
return $dataProvider;
}
$query->andFilterWhere(['id' => $this->id])->andFilterWhere(['status' => $this->status])->andFilterWhere(['role' => $this->role])->andFilterWhere(['like', 'email', $this->email])->andFilterWhere(['like', 'username', $this->username]);
return $dataProvider;
}
开发者ID:Avenger1,项目名称:yii2-podium,代码行数:20,代码来源:UserSearch.php
示例13: _addAdmin
/**
* Adds Administrator account.
* @return string result message.
*/
protected function _addAdmin()
{
try {
$podium = PodiumModule::getInstance();
if ($podium->userComponent == PodiumModule::USER_INHERIT) {
if (!empty($podium->adminId)) {
$admin = new User();
$admin->setScenario('installation');
$admin->inherited_id = $podium->adminId;
$admin->username = self::DEFAULT_USERNAME;
$admin->status = User::STATUS_ACTIVE;
$admin->role = User::ROLE_ADMIN;
$admin->timezone = User::DEFAULT_TIMEZONE;
if ($admin->save()) {
$this->authManager->assign($this->authManager->getRole(Rbac::ROLE_ADMIN), $podium->adminId);
return $this->outputSuccess(Yii::t('podium/flash', 'Administrator privileges have been set for the user of ID {id}.', ['id' => $podium->adminId]));
} else {
$this->setError(true);
return $this->outputDanger(Yii::t('podium/flash', 'Error during account creating') . ': ' . Html::tag('pre', VarDumper::dumpAsString($admin->getErrors())));
}
} else {
return $this->outputWarning(Yii::t('podium/flash', 'No administrator privileges have been set.'));
}
} else {
$admin = new User();
$admin->setScenario('installation');
$admin->username = self::DEFAULT_USERNAME;
$admin->status = User::STATUS_ACTIVE;
$admin->role = User::ROLE_ADMIN;
$admin->timezone = User::DEFAULT_TIMEZONE;
$admin->generateAuthKey();
$admin->setPassword(self::DEFAULT_USERNAME);
if ($admin->save()) {
$this->authManager->assign($this->authManager->getRole(Rbac::ROLE_ADMIN), $admin->getId());
return $this->outputSuccess(Yii::t('podium/flash', 'Administrator account has been created.') . ' ' . Html::tag('strong', Yii::t('podium/flash', 'Login') . ':') . ' ' . Html::tag('kbd', self::DEFAULT_USERNAME) . ' ' . Html::tag('strong', Yii::t('podium/flash', 'Password') . ':') . ' ' . Html::tag('kbd', self::DEFAULT_USERNAME));
} else {
$this->setError(true);
return $this->outputDanger(Yii::t('podium/flash', 'Error during account creating') . ': ' . Html::tag('pre', VarDumper::dumpAsString($admin->getErrors())));
}
}
} catch (Exception $e) {
Yii::error([$e->getName(), $e->getMessage()], __METHOD__);
$this->setError(true);
return $this->outputDanger(Yii::t('podium/flash', 'Error during account creating') . ': ' . Html::tag('pre', $e->getMessage()));
}
}
开发者ID:aekkapun,项目名称:yii2-podium,代码行数:50,代码来源:Installation.php
示例14: searchDeleted
public function searchDeleted($params)
{
$dataProvider = $this->search();
$dataProvider->query->where(['or', ['and', ['sender_id' => Yii::$app->user->id], ['sender_status' => Message::getDeletedStatuses()]], ['and', ['receiver_id' => Yii::$app->user->id], ['receiver_status' => Message::getDeletedStatuses()]]]);
if (!($this->load($params) && $this->validate())) {
$dataProvider->query->joinWith(['receiverUser' => function ($q) {
$q->from(User::tableName() . ' pdu_receiver');
}, 'senderUser' => function ($q) {
$q->from(User::tableName() . ' pdu_sender');
}]);
return $dataProvider;
}
$dataProvider->query->andFilterWhere(['like', 'topic', $this->topic]);
$dataProvider->query->joinWith(['receiverUser' => function ($q) {
$q->from(User::tableName() . ' pdu_receiver')->where(['like', 'pdu_receiver.username', $this->receiverName]);
}, 'senderUser' => function ($q) {
$q->from(User::tableName() . ' pdu_sender')->where(['like', 'pdu_sender.username', $this->senderName]);
}]);
return $dataProvider;
}
开发者ID:keltstr,项目名称:yii2-podium,代码行数:20,代码来源:MessageSearch.php
示例15: search
/**
* Searches for sent messages.
* @param array $params
* @return ActiveDataProvider
*/
public function search($params)
{
// not very proud of this query - slow for sure
// let me know if it can be done better.
$subquery = (new Query())->select(['m2.replyto'])->from(['m1' => Message::tableName()])->leftJoin(['m2' => Message::tableName()], '`m1`.`replyto` = `m2`.`id`')->where(['is not', 'm2.replyto', null]);
$query = self::find()->where(['and', ['sender_id' => User::loggedId(), 'sender_status' => Message::getSentStatuses()], ['not in', Message::tableName() . '.id', $subquery]]);
$dataProvider = new ActiveDataProvider(['query' => $query, 'sort' => ['attributes' => ['id', 'topic', 'created_at']]]);
$dataProvider->sort->defaultOrder = ['id' => SORT_DESC];
$dataProvider->pagination->pageSize = Yii::$app->session->get('per-page', 20);
if (!($this->load($params) && $this->validate())) {
$dataProvider->query->joinWith(['messageReceivers' => function ($q) {
$q->joinWith(['receiver']);
}]);
return $dataProvider;
}
$dataProvider->query->andFilterWhere(['like', 'topic', $this->topic]);
if (preg_match('/^(forum|orum|rum|um|m)?#([0-9]+)$/', strtolower($this->receiverName), $matches)) {
$dataProvider->query->joinWith(['messageReceivers' => function ($q) use($matches) {
$q->joinWith(['receiver' => function ($q) use($matches) {
$q->andFilterWhere(['username' => ['', null], User::tableName() . '.id' => $matches[2]]);
}]);
}]);
} elseif (preg_match('/^([0-9]+)$/', $this->receiverName, $matches)) {
$dataProvider->query->joinWith(['messageReceivers' => function ($q) use($matches) {
$q->joinWith(['receiver' => function ($q) use($matches) {
$q->andFilterWhere(['or', ['like', 'username', $this->receiverName], ['username' => ['', null], 'id' => $matches[1]]]);
}]);
}]);
} else {
$dataProvider->query->joinWith(['messageReceivers' => function ($q) {
$q->joinWith(['receiver' => function ($q) {
$q->andFilterWhere(['like', User::tableName() . '.username', $this->receiverName]);
}]);
}]);
}
return $dataProvider;
}
开发者ID:gitter-badger,项目名称:yii2-podium,代码行数:42,代码来源:MessageSearch.php
示例16:
echo Html::encode($reply->topic);
?>
</div>
<div class="popover-content">
<?php
echo $reply->content;
?>
</div>
</div>
</div>
</div>
<?php
$stack = 0;
while ($reply->reply && $stack < 4) {
$loggedId = User::loggedId();
if ($reply->reply->receiver_id == $loggedId && $reply->reply->receiver_status == Message::STATUS_REMOVED || $reply->reply->sender_id == $loggedId && $reply->reply->sender_status == Message::STATUS_REMOVED) {
$reply = $reply->reply;
} else {
?>
<div class="row">
<div class="col-sm-2 text-center">
<?php
echo Avatar::widget(['author' => $reply->reply->senderUser]);
?>
</div>
<div class="col-sm-10">
<div class="popover right podium">
<div class="arrow"></div>
<div class="popover-title">
<small class="pull-right"><span data-toggle="tooltip" data-placement="top" title="<?php
开发者ID:Avenger1,项目名称:yii2-podium,代码行数:31,代码来源:reply.php
示例17: function
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']);
}
}]]]]);
Pjax::end();
?>
<div class="panel panel-default">
<div class="panel-body small">
<ul class="list-inline pull-right">
<li><a href="<?php
echo Url::to(['default/index']);
?>
" data-toggle="tooltip" data-placement="top" title="<?php
echo Yii::t('podium/view', 'Go to the main page');
开发者ID:gitter-badger,项目名称:yii2-podium,代码行数:31,代码来源:index.php
示例18:
echo Yii::t('podium/view', 'Thumb down');
?>
"><span class="glyphicon glyphicon-thumbs-down"></span></a>
<?php
}
?>
<a href="<?php
echo Url::to(['default/report', 'cid' => $model->thread->category_id, 'fid' => $model->forum_id, 'tid' => $model->thread_id, 'pid' => $model->id, 'slug' => $model->thread->slug]);
?>
" class="btn btn-warning btn-xs" data-pjax="0" data-toggle="tooltip" data-placement="top" title="<?php
echo Yii::t('podium/view', 'Report post');
?>
"><span class="glyphicon glyphicon-flag"></span></a>
<?php
}
if ($model->author_id == $loggedId || User::can(Rbac::PERM_DELETE_POST, ['item' => $model->thread])) {
?>
<a href="<?php
echo Url::to(['default/deletepost', 'cid' => $model->thread->category_id, 'fid' => $model->forum_id, 'tid' => $model->thread_id, 'pid' => $model->id]);
?>
" class="btn btn-danger btn-xs" data-pjax="0" data-toggle="tooltip" data-placement="top" title="<?php
echo Yii::t('podium/view', 'Delete post');
?>
"><span class="glyphicon glyphicon-trash"></span></a>
<?php
}
?>
</div>
</div>
</div>
</div>
开发者ID:Avenger1,项目名称:yii2-podium,代码行数:31,代码来源:_post.php
示例19:
echo Avatar::widget(['author' => User::findMe(), 'showName' => false]);
?>
</div>
<div class="col-sm-10">
<div class="popover right podium">
<div class="arrow"></div>
<div class="popover-title">
<small class="pull-right"><?php
echo Html::tag('span', Yii::t('podium/view', 'In a while'), ['data-toggle' => 'tooltip', 'data-placement' => 'top', 'title' => Yii::t('podium/view', 'As soon as you click Post Reply')]);
?>
</small>
<strong><?php
echo Yii::t('podium/view', 'Post Quick Reply');
?>
</strong> <?php
echo User::findMe()->podiumTag;
?>
</div>
<div class="popover-content podium-content">
<?php
$form = ActiveForm::begin(['id' => 'new-quick-post-form', 'action' => ['post', 'cid' => $category->id, 'fid' => $forum->id, 'tid' => $thread->id]]);
?>
<div class="row">
<div class="col-sm-12">
<?php
echo $form->field($model, 'content')->label(false)->widget(Summernote::className(), ['clientOptions' => ['height' => '100', 'lang' => Yii::$app->language != 'en-US' ? Yii::$app->language : null, 'codemirror' => null, 'toolbar' => Helper::summerNoteToolbars()]]);
?>
</div>
</div>
<?php
if (!$thread->subscription) {
开发者ID:Avenger1,项目名称:yii2-podium,代码行数:31,代码来源:thread.php
示例20: actionFriend
/**
* Adding or removing user as a friend.
* @param integer $id user ID
* @return \yii\web\Response
* @since 0.2
*/
public function actionFriend($id = null)
{
if (Yii::$app->user->isGuest) {
return $this->redirect(['default/index']);
}
$model = User::find()->where(['and', ['id' => $id], ['!=', 'status', User::STATUS_REGISTERED]])->limit(1)->one();
if (empty($model)) {
$this->error(Yii::t('podium/flash', 'Sorry! We can not find Member with this ID.'));
return $this->redirect(['members/index']);
}
if ($model->id == User::loggedId()) {
$this->error(Yii::t('podium/flash', 'Sorry! You can not befriend your own account.'));
return $this->redirect(['members/view', 'id' => $model->id, 'slug' => $model->podiumSlug]);
}
if ($model->updateFriend()) {
if ($model->isBefriendedBy(User::loggedId())) {
$this->success(Yii::t('podium/flash', 'User is your friend now.'));
} else {
$this->success(Yii::t('podium/flash', 'User is not your friend anymore.'));
}
} else {
$this->error(Yii::t('podium/flash', 'Sorry! There was some error while performing this action.'));
}
return $this->redirect(['members/view', 'id' => $model->id, 'slug' => $model->podiumSlug]);
}
开发者ID:pezisc,项目名称:yii2-podium,代码行数:31,代码来源:MembersController.php
注:本文中的bizley\podium\models\User类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论