Пример #1
0
 /**
  * Return list of relations for current model
  * @return array
  */
 public static function getRelations()
 {
     $old = parent::getRelations();
     $old['parent'] = [DbRelations::BELONGS_TO, '\\mpf\\modules\\forum\\models\\ForumReplyThird', 'reply_id'];
     $old['replies'] = [DbRelations::HAS_MANY, '\\mpf\\modules\\forum\\models\\ForumReplyFifth', 'reply_id'];
     $old['myVote'] = DbRelation::hasOne(ForumReplyVote::className())->columnsEqual('id', 'reply_id')->hasValue('level', 4)->hasValue('user_id', WebApp::get()->user()->isConnected() ? WebApp::get()->user()->id : 0);
     return $old;
 }
Пример #2
0
    <span class="forum-page-list-elements">
        <?php 
echo $visibleElements . ' / ' . $totalElements . ' ' . $elementsName;
?>
        <?php 
if (isset($order)) {
    ?>
            |
            <?php 
    echo \mpf\web\helpers\Form::get()->openForm(['method' => 'get', 'style' => 'display:inline;']);
    ?>
            <?php 
    echo \mpf\modules\forum\components\Translator::get()->translate('Order By');
    ?>
            <?php 
    echo \mpf\web\helpers\Form::get()->select('order', \mpf\modules\forum\models\ForumReply::getOrdersForSelect(), $order, ['onchange' => 'this.form.submit();']);
    ?>
            <?php 
    echo \mpf\web\helpers\Form::get()->closeForm();
    ?>
        <?php 
}
?>
    </span>
    <?php 
if ($totalPages > 1) {
    ?>
        <ul class="forum-page-list-pages">
            <?php 
    if ($currentPage > 1) {
        ?>
Пример #3
0
 /**
  * It will save thread info(update with last reply info) + subcategory info
  * @param int $sectionId
  * @param int $level
  * @param int $userId
  * @param int $userGroupID
  * @param int $time
  * @return bool
  */
 public function saveReply($sectionId, $level = 1, $userId = null, $userGroupID = null, $time = null)
 {
     $this->user_id = is_null($userId) ? WebApp::get()->user()->id : $userId;
     $this->time = date('Y-m-d H:i:s', $time ?: time());
     $this->section_id = $sectionId;
     $this->score = $this->edited = $this->edit_user_id = $this->deleted = $this->deleted_user_id = 0;
     $this->user_group_id = $userGroupID ?: UserAccess::get()->getUserGroup($sectionId, true);
     if (!$this->save()) {
         return false;
     }
     $thread = ForumThread::findByPk($this->thread_id);
     $thread->replies = ($firstLevelReplies = ForumReply::countByAttributes(['thread_id' => $this->thread_id])) + ForumReplySecond::countByAttributes(['thread_id' => $this->thread_id]) + ForumReplyThird::countByAttributes(['thread_id' => $this->thread_id]) + ForumReplyForth::countByAttributes(['thread_id' => $this->thread_id]) + ForumReplyFifth::countByAttributes(['thread_id' => $this->thread_id]) + ForumReplySixth::countByAttributes(['thread_id' => $this->thread_id]) + ForumReplySeventh::countByAttributes(['thread_id' => $this->thread_id]) + ForumReplyEighth::countByAttributes(['thread_id' => $this->thread_id]) + ForumReplyNth::countByAttributes(['thread_id' => $this->thread_id]);
     $thread->first_level_replies = $firstLevelReplies;
     $thread->last_reply_id = $this->id;
     $thread->last_reply_user_id = $this->user_id;
     $thread->last_reply_level = $level;
     $thread->last_reply_date = $this->time;
     $thread->save(false);
     $thread->subcategory->last_active_thread_id = $thread->id;
     $thread->subcategory->last_activity_time = $this->time;
     $thread->subcategory->last_activity = 'reply';
     $thread->subcategory->last_active_user_id = $this->user_id;
     $thread->subcategory->recalculateNumbers()->save();
     return true;
 }