コード例 #1
0
ファイル: Activity.php プロジェクト: keltstr/yii2-podium
 /**
  * Adds registered user activity.
  * @param string $ip
  * @param string $url
  * @return boolean
  */
 protected static function _addUser($ip, $url)
 {
     $user = new PodiumUser();
     $activity = self::findOne(['user_id' => $user->getId()]);
     if (!$activity) {
         $activity = new Activity();
         $activity->user_id = $user->getId();
     }
     $activity->username = $user->getName();
     $activity->user_role = $user->getRole();
     $activity->user_slug = $user->getSlug();
     $activity->url = $url;
     $activity->ip = $ip;
     $activity->anonymous = $user->getAnonymous();
     return $activity->save();
 }
コード例 #2
0
ファイル: thread.php プロジェクト: keltstr/yii2-podium
use yii\widgets\ListView;
use yii\widgets\Pjax;
use Zelenin\yii\widgets\Summernote\Summernote;
$this->registerJs('jQuery(\'.add-subscription\').click(function(e){
    e.preventDefault();
    jQuery.post(\'' . Url::to(['profile/add', 'id' => $thread->id]) . '\', {}, null, \'json\').
        fail(function(){ console.log(\'Subscription Add Error!\'); }).
        done(function(data){ jQuery(\'#subsription-status\').html(data.msg); });
})', View::POS_READY, 'add-subscription');
$this->registerJs('var anchor=window.location.hash; if (anchor.match(/^#post[0-9]+$/)) jQuery(anchor).find(\'.podium-content\').addClass(\'podium-gradient\');', View::POS_READY, 'anchor-marked');
$this->title = Html::encode($thread->name);
$this->params['breadcrumbs'][] = ['label' => Yii::t('podium/view', 'Main Forum'), 'url' => ['index']];
$this->params['breadcrumbs'][] = ['label' => Html::encode($category->name), 'url' => ['category', 'id' => $category->id, 'slug' => $category->slug]];
$this->params['breadcrumbs'][] = ['label' => Html::encode($forum->name), 'url' => ['forum', 'cid' => $forum->category_id, 'id' => $forum->id, 'slug' => $forum->slug]];
$this->params['breadcrumbs'][] = $this->title;
$podiumUser = new PodiumUser();
?>

<?php 
if (Yii::$app->user->can('updatePodiumThread', ['item' => $thread])) {
    ?>
<div class="row">
    <div class="col-sm-12">
        <div class="panel panel-warning">
            <div class="panel-heading">
                <ul class="list-inline">
                    <li><strong><?php 
    echo Yii::t('podium/view', 'Moderator options');
    ?>
</strong>:</li>
                    <li><a href="<?php 
コード例 #3
0
ファイル: _navbar.php プロジェクト: keltstr/yii2-podium
<?php

use bizley\podium\components\Config;
use bizley\podium\components\PodiumUser;
use bizley\podium\Module as PodiumModule;
use yii\bootstrap\Nav;
use yii\bootstrap\NavBar;
use yii\helpers\Html;
$items = [['label' => Yii::t('podium/layout', 'Home'), 'url' => ['default/index']]];
$podiumUser = new PodiumUser();
$podiumModule = PodiumModule::getInstance();
if (Yii::$app->user->isGuest) {
    if (Config::getInstance()->get('members_visible')) {
        $items[] = ['label' => Yii::t('podium/layout', 'Members'), 'url' => ['members/index'], 'active' => $this->context->id == 'members'];
    }
    if ($podiumModule->userComponent == PodiumModule::USER_OWN) {
        if (!empty($podiumModule->loginUrl)) {
            $items[] = ['label' => Yii::t('podium/layout', 'Sign in'), 'url' => $podiumModule->loginUrl];
        }
        if (!empty($podiumModule->registerUrl)) {
            $items[] = ['label' => Yii::t('podium/layout', 'Register'), 'url' => $podiumModule->registerUrl];
        }
    }
} else {
    $messageCount = $podiumUser->getNewMessagesCount();
    $subscriptionCount = $podiumUser->getSubscriptionsCount();
    if (Yii::$app->user->can('changePodiumSettings')) {
        $items[] = ['label' => Yii::t('podium/layout', 'Administration'), 'url' => ['admin/index'], 'active' => $this->context->id == 'admin'];
    }
    $items[] = ['label' => Yii::t('podium/layout', 'Members'), 'url' => ['members/index'], 'active' => $this->context->id == 'members'];
    $items[] = ['label' => Yii::t('podium/layout', 'Profile') . ($subscriptionCount ? ' ' . Html::tag('span', $subscriptionCount, ['class' => 'badge']) : ''), 'url' => ['profile/index'], 'items' => [['label' => Yii::t('podium/view', 'My Profile'), 'url' => ['profile/index']], ['label' => Yii::t('podium/view', 'Account Details'), 'url' => ['profile/details']], ['label' => Yii::t('podium/view', 'Forum Details'), 'url' => ['profile/forum']], ['label' => Yii::t('podium/view', 'Subscriptions'), 'url' => ['profile/subscriptions']]]];
コード例 #4
0
 /**
  * Replying to the message of given ID.
  * @param integer $id
  * @return string|\yii\web\Response
  */
 public function actionReply($id = null)
 {
     $model = new Message();
     $podiumUser = new PodiumUser();
     $reply = Message::findOne(['id' => $id, 'receiver_id' => $podiumUser->getId()]);
     if ($reply) {
         $model->topic = Message::re() . ' ' . $reply->topic;
         if ($model->load(Yii::$app->request->post())) {
             if ($model->validate()) {
                 if (!$podiumUser->isIgnoredBy($model->receiver_id)) {
                     $model->replyto = $reply->id;
                     if ($model->send()) {
                         $this->success('Message has been sent.');
                         return $this->redirect(['inbox']);
                     }
                 } else {
                     $this->error('Sorry! This member ignores you so you can not send the message.');
                 }
             }
         }
         $model->receiver_id = $reply->sender_id;
         return $this->render('reply', ['model' => $model, 'reply' => $reply]);
     } else {
         $this->error('Sorry! We can not find the message with the given ID.');
         return $this->redirect(['inbox']);
     }
 }