Reply on a comment.
If creation is successful, the browser will be redirected to the 'index' page.
@return mixed
352747
public function actionReply($id)
    {
        $comment = $this->findModel($id);
        if (!\Yii::$app->user->can('replyStranger', ['comment' => $comment]))
            return $this->alert(\Yii::t('app', 'Access denied.'));
        
        // fill in a new Comment
        $model = $this->newModel();
        $model->model = $comment->model;
        $model->parent_id = $comment->parent_id;
        $model->thread = $comment->thread;
        $model->user_id = \Yii::$app->user->id; // comment of a current user
        $model->status = Comment::STATUS_APPROVED; // comment approved by default
        $model->last = 1; // only the last comment in the thread can be replied

        if ($model->load(\Yii::$app->request->post()) && $model->save()) {
            // the comment to which we reply must be approved
            if ($comment->status == Comment::STATUS_PENDING) {
                $comment->status = Comment::STATUS_APPROVED;
                $comment->save(false);
            }
            return YII_DEBUG 
                ? $this->redirect(['index'])
                : $this->redirect(\Yii::$app->request->referrer);
        } else {
            return $this->renderAjax('reply', [
                'model' => $model,
                'comment' => $comment,
            ]);
        }
    }
403759
def reply(self):
        """"""
        status = self.get_selected_status()
        app, user = self.app, self.user
        if not app or not user:
            self.footer.draw_message("You must be logged in to reply", Color.RED)
            return

        compose_modal = ComposeModal(self.stdscr, default_cw='\n'.join(status['spoiler_text']) or None, resize_callback=self.on_resize)
        content, cw = compose_modal.loop()
        self.full_redraw()
        if content is None:
            return
        elif len(content) == 0:
            self.footer.draw_message("Status must contain content", Color.RED)
            return

        self.footer.draw_message("Submitting reply...", Color.YELLOW)
        response = api.post_status(app, user, content, spoiler_text=cw, sensitive=cw is not None, in_reply_to_id=status['id'])
        status = parse_status(response)
        self.statuses.insert(0, status)
        self.selected += 1
        self.left.draw_statuses(self.statuses, self.selected)
        self.footer.draw_message("✓ Reply posted", Color.GREEN)
944114
public function indexAction()
    {
        parent::indexAction();

        $this->flashMessenger()->addSuccessMessage('Action not enabled');
        
        return $this->redirect()->toRoute('history-index');
        
        $request = $this->getRequest();

        $id = $this->params()->fromRoute('id');

        $entity = $this->service->get($id);

        if(! $entity) {
        	$this->flashMessenger()->addErrorMessage('Object was not found');
        	return $this->redirect()->toRoute('history-index');
        }

        if ($request->isPost()) {
        	$postData = $request->getPost();

        	$this->form->setData($postData);

        	if ($this->form->isValid()) {
        		$entity = $this->form->getData();

        		$historyEntity = $this->service->save($entity);

        		$this->getEventManager()->trigger('historyCreate', $this, array(
        			'authId' => $this->identity()->getAuthId(),
        			'requestUrl' => $this->getRequest()->getUri(),
        			'historyEntity' => $entity
        		));

        		$this->flashMessenger()->addSuccessMessage('Object was saved');

        		return $this->redirect()->toRoute('history-view', array(
        			'id' => $historyEntity->getHistoryId()
        		));
        	}
        }

        $this->form->bind($entity);

        return new ViewModel(array(
        	'form' => $this->form
        ));
    }
1251123
public function actionCreateFromPage()
    {
        $this->menuFlush();
        $model = new Nav();
        $response = $model->createItemLanguageCopy($this->postArg('id'), $this->postArg('toLangId'), $this->postArg('title'), $this->postArg('alias'));
        
        if (is_array($response)) {
            return $this->sendArrayError($response);
        }
        
        return $response;
    }
1182806
public function actionCreate()
    {
        if (($source = $this->findModel(Yii::$app->request->post('source_id'))) != null) {
            $model = new Comment();
            $model->scenario = Comment::SCENARIO_CREATE;
            if ($model->load(Yii::$app->request->post(), '') && $model->save()) {
                $source->updateCounters(['comments' => 1]);
                if ($model->to_user_id > 0) {
                    notify(Yii::$app->user->id, $model->to_user_id, 'reply_comment',  $source->title, $source->id, $model->content, 'article', $source->id);
                } else {
                    notify(Yii::$app->user->id, $source->user_id, 'comment_article',  $source->title, $source->id, $model->content, 'article', $source->id);
                }
                return $this->renderPartial('detail', ['model' => $model]);
            }
        }
        throw new NotFoundHttpException(Yii::t('yii', 'The requested page does not exist'));
    }
677533
public function updatePositionAction()
    {
        // Check current user authorization
        if (null !== $response = $this->checkAuth($this->resourceCode, $this->getModuleCode(), AccessManager::UPDATE)) {
            return $response;
        }

        try {
            $mode = $this->getRequest()->get('mode', null);

            if ($mode == 'up') {
                $mode = UpdatePositionEvent::POSITION_UP;
            } elseif ($mode == 'down') {
                $mode = UpdatePositionEvent::POSITION_DOWN;
            } else {
                $mode = UpdatePositionEvent::POSITION_ABSOLUTE;
            }

            $position = $this->getRequest()->get('position', null);

            $event = $this->createUpdatePositionEvent($mode, $position);

            $this->dispatch($this->changePositionEventIdentifier, $event);
        } catch (\Exception $ex) {
            // Any error
            return $this->errorPage($ex);
        }

        $response = $this->performAdditionalUpdatePositionAction($event);

        if ($response == null) {
            return $this->redirectToListTemplate();
        } else {
            return $response;
        }
    }
1124634
public function index()
    {
        if (!isLoggedIn()) {
            unauthorised();
        }

        $oInput     = Factory::service('Input');
        $oEncrypt   = Factory::service('Encrypt');
        $oEmailer   = Factory::service('Emailer', 'nails/module-email');
        $oUserModel = Factory::model('User', 'nails/module-auth');

        $sToken = $oInput->get('token');
        $aToken = $oEncrypt->decode($sToken, APP_PRIVATE_KEY);

        if (!$aToken) {
            show404();
        }

        $aToken = explode('|', $aToken);

        if (count($aToken) != 3) {
            show404();
        }

        $oUser = $oUserModel->getById($aToken[2]);
        if (!$oUser || $oUser->id != activeUser('id ')) {
            show404();
        }

        $oEmail = $oEmailer->getByRef($aToken[1]);

        if (!$oEmail || empty($oEmail->type->isUnsubscribable)) {
            show404();
        }

        // --------------------------------------------------------------------------

        //  All seems above board, action the request
        if ($oInput->get('undo')) {
            if ($oEmailer->userHasUnsubscribed(activeUser('id'), $aToken[0])) {
                $oEmailer->subscribeUser(activeUser('id'), $aToken[0]);
            }
        } else {
            if (!$oEmailer->userHasUnsubscribed(activeUser('id'), $aToken[0])) {
                $oEmailer->unsubscribeUser(activeUser('id'), $aToken[0]);
            }
        }

        //  Load views
        $oView = Factory::service('View');
        $oView->load('email/utilities/unsubscribe', $this->data);
    }
1219088
private function createComment()
	{
		$model = new Comments;
		$model->attributes = $_POST;

		$model->user_id = $this->user->id;
		if ($model->save())
			return $model->getApiAttributes();

		return $this->returnError(400, NULL, $model->getErrors());
	}
1152318
public function processUpdateSeoAction()
    {
        // Check current user authorization
        if (null !== $response = $this->checkAuth($this->resourceCode, $this->getModuleCode(), AccessManager::UPDATE)) {
            return $response;
        }

        // Error (Default: false)
        $error_msg = false;

        // Create the Form from the request
        $updateSeoForm = $this->getUpdateSeoForm($this->getRequest());

        // Pass the object id to the request
        $this->getRequest()->attributes->set($this->objectName . '_id', $this->getRequest()->get('current_id'));

        try {
            // Check the form against constraints violations
            $form = $this->validateForm($updateSeoForm, "POST");

            // Get the form field values
            $data = $form->getData();

            // Create a new event object with the modified fields
            $updateSeoEvent = $this->getUpdateSeoEvent($data);

            // Dispatch Update SEO Event
            $this->dispatch($this->updateSeoEventIdentifier, $updateSeoEvent);

            // Execute additional Action
            $response = $this->performAdditionalUpdateSeoAction($updateSeoEvent);

            if ($response == null) {
                // If we have to stay on the same page, do not redirect to the successUrl,
                // just redirect to the edit page again.
                if ($this->getRequest()->get('save_mode') == 'stay') {
                    return $this->redirectToEditionTemplate($this->getRequest());
                }

                // Redirect to the success URL
                return $this->generateSuccessRedirect($updateSeoForm);
            } else {
                return $response;
            }
        } catch (FormValidationException $ex) {
            // Form cannot be validated
            $error_msg = $this->createStandardFormValidationErrorMessage($ex);
            /*} catch (\Exception $ex) {
                // Any other error
                $error_msg = $ex->getMessage();*/
        }

        // Load object if exist
        if (null !== $object = $this->getExistingObject()) {
            // Hydrate the form abd pass it to the parser
            $changeForm = $this->hydrateObjectForm($object);

            // Pass it to the parser
            $this->getParserContext()->addForm($changeForm);
        }

        if (false !== $error_msg) {
            $this->setupFormErrorContext(
                $this->getTranslator()->trans("%obj SEO modification", array('%obj' => $this->objectName)),
                $error_msg,
                $updateSeoForm,
                $ex
            );

            // At this point, the form has errors, and should be redisplayed.
            return $this->renderEditionTemplate();
        }
    }
1317100
public function indexAction()
    {
        /** @var Response $response */
        $response = $this->getResponse();

        $headers = new Headers();

        $headers->addHeaders(
            [
                'cache-control' => 'no-store, no-cache, must-revalidate',
                'content-type' => 'application/javascript',
                'pragma' => 'no-cache',
            ]
        );

        $response->setHeaders(
            $headers
        );

        $isAllowed = $this->cmsPermissionChecks->siteAdminCheck($this->siteService->getCurrentSite());

        if (!$isAllowed) {
            $response->setContent(
                '// rcmBlockConfigs not available'
            );

            return $response;
        }

        $content = $this->rendererAvailableBlocksJs->__invoke();

        $response->setContent(
            $content
        );

        return $response;
    }
86609
public function Comment() {
      $this->Permission('Garden.Profiles.Edit');
      
      $Session = Gdn::Session();
      $this->Form->SetModel($this->ActivityModel);
      $NewActivityID = 0;
      
      // Form submitted
      if ($this->Form->IsPostBack()) {
         $Body = $this->Form->GetValue('Body', '');
         $ActivityID = $this->Form->GetValue('ActivityID', '');
         if (is_numeric($ActivityID) && $ActivityID > 0) {
            $ActivityComment = array(
                'ActivityID' => $ActivityID,
                'Body' => $Body,
                'Format' => 'Text');
            
            $ID = $this->ActivityModel->Comment($ActivityComment);
            
            if ($ID == SPAM || $ID == UNAPPROVED) {
               $this->StatusMessage = T('ActivityCommentRequiresApproval', 'Your comment will appear after it is approved.');
               $this->Render('Blank', 'Utility');
               return;
            }
            
            $this->Form->SetValidationResults($this->ActivityModel->ValidationResults());
            if ($this->Form->ErrorCount() > 0) {
               throw new Exception($this->ActivityModel->Validation->ResultsText());
               
               $this->ErrorMessage($this->Form->Errors());
            }
         }
      }
      
      // Redirect back to the sending location if this isn't an ajax request
      if ($this->_DeliveryType === DELIVERY_TYPE_ALL) {
         $Target = $this->Form->GetValue('Return');
         if (!$Target)
            $Target = '/activity';
         Redirect($Target);
      } else {
         // Load the newly added comment.
         $this->SetData('Comment', $this->ActivityModel->GetComment($ID));
         
         // Set it in the appropriate view.
         $this->View = 'comment';
      }

      // And render
      $this->Render();
   }
1295376
public function getCommentsRequireLogin()
    {
        if ($this->owner->getCommentsOption('require_login_cms')) {
            return (bool) $this->owner->getField('CommentsRequireLogin');
        }
        return (bool) $this->owner->getCommentsOption('require_login');
    }
178933
public function getResponse() {
		$l = $this->action->layout('output');
		
		switch($l) {
			case 'object':
			case 'object_list':
			case 'hash':
			case 'hash_list':
				return $this->envelope->response->{$this->action->getNamespace('output')};
				
			default:
				return $this->envelope->response;
		}
	}
1219052
public function actionCreate()
    {
        $id = Yii::$app->request->post('question_id');
        if (($question = Question::findOne($id)) == null) {
            return $this->goBack();
        }
        $model = new Answer(['question_id' => $question->id]);
        if ($model->load(Yii::$app->request->post()) && $model->save() != null) {
            Yii::$app->session->setFlash('success', Yii::t('question', 'Operation completed.'));
            return $this->redirect(['/question/question/view', 'id' => $id]);
        }
        return $this->render('create', ['model' => $model, 'question' => $question]);
    }
671327
public function actionCreate()
    {
        $model = new Question();
        if ($model->load(Yii::$app->request->post()) && $model->save() != null) {
            Yii::$app->session->setFlash('success', 'question Submitted');
            return $this->redirect(['view', 'id' => $model->id]);
        }
        return $this->render('create', ['model' => $model]);
    }
750692
public function toResponse()
    {
        $response = Http::getInstance()->response();
        $response->reset();
        $response->status($this->code);
        if (is_string($this->details)) {
            $response->body($this->details);
        } elseif (is_string($this->message)) {
            $response->body($this->message);
        }

        return $response;
    }
1040381
public function getIndex()
    {
        $question = new Question($this->di->get("db"));

        $views = [
            ["comment/question/view-all", ["questions" => $question->getQuestions(),
             "headerTitle" => "Senaste frågor"], "main"]
        ];

        $this->di->get("pageRenderComment")->renderPage([
            "views" => $views,
            "title" => "All questions"
        ]);
    }