public function actionLoad()
    {
        if (!Yii::$app->request->isAjax) {
            return $this->redirect(['forum/index']);
        }

        $result = ['messages' => '', 'more' => 0];

        if (!Podium::getInstance()->user->isGuest) {
            $loggedId = User::loggedId();
            $id = Yii::$app->request->post('message');
            $message = Message::find()->where(['id' => $id])->limit(1)->one();
            if ($message && ($message->sender_id == $loggedId || $message->isMessageReceiver($loggedId))) {
                $stack = 0;
                $reply = clone $message;
                while ($reply->reply && $stack < 5) {
                    $result['more'] = 0;
                    if ($reply->reply->sender_id == $loggedId && $reply->reply->sender_status == Message::STATUS_DELETED) {
                        $reply = $reply->reply;
                        continue;
                    }
                    $result['messages'] .= $this->renderPartial('load', ['reply' => $reply]);
                    $reply = $reply->reply;
                    if ($reply) {
                        $result['more'] = $reply->id;
                    }
                    $stack++;
                }
            }
        }
        return Json::encode($result);
    }
public function actionLoad()
    {
        if (!Yii::$app->request->isAjax) {
            return $this->redirect(['forum/index']);
        }

        $result = ['messages' => '', 'more' => 0];

        if (!Podium::getInstance()->user->isGuest) {
            $loggedId = User::loggedId();
            $id = Yii::$app->request->post('message');
            $message = Message::find()->where(['id' => $id])->limit(1)->one();
            if ($message && ($message->sender_id == $loggedId || $message->isMessageReceiver($loggedId))) {
                $stack = 0;
                $reply = clone $message;
                while ($reply->reply && $stack < 5) {
                    $result['more'] = 0;
                    if ($reply->reply->sender_id == $loggedId && $reply->reply->sender_status == Message::STATUS_DELETED) {
                        $reply = $reply->reply;
                        continue;
                    }
                    $result['messages'] .= $this->renderPartial('load', ['reply' => $reply]);
                    $reply = $reply->reply;
                    if ($reply) {
                        $result['more'] = $reply->id;
                    }
                    $stack++;
                }
            }
        }
        return Json::encode($result);
    }
public function actionLoad ( ) { if ( ! Yii :: $ app -> request -> isAjax ) { return $ this -> redirect ( [ 'forum/index' ] ) ; } $ result = [ 'messages' => '' , 'more' => 0 ] ; if ( ! Podium :: getInstance ( ) -> user -> isGuest ) { $ loggedId = User :: loggedId ( ) ; $ id = Yii :: $ app -> request -> post ( 'message' ) ; $ message = Message :: find ( ) -> where ( [ 'id' => $ id ] ) -> limit ( 1 ) -> one ( ) ; if ( $ message && ( $ message -> sender_id == $ loggedId || $ message -> isMessageReceiver ( $ loggedId ) ) ) { $ stack = 0 ; $ reply = clone $ message ; while ( $ reply -> reply && $ stack < 5 ) { $ result [ 'more' ] = 0 ; if ( $ reply -> reply -> sender_id == $ loggedId && $ reply -> reply -> sender_status == Message :: STATUS_DELETED ) { $ reply = $ reply -> reply ; continue ; } $ result [ 'messages' ] .= $ this -> renderPartial ( 'load' , [ 'reply' => $ reply ] ) ; $ reply = $ reply -> reply ; if ( $ reply ) { $ result [ 'more' ] = $ reply -> id ; } $ stack ++ ; } } } return Json :: encode ( $ result ) ; }
Loads older messages in thread.
@return string
Loads older messages in thread .