Adding a new message.
@param int $user message receiver's ID
@return string|Response
505445
public function actionNew($user = null)
    {
        $podiumUser = User::findMe();

        if (Message::tooMany($podiumUser->id)) {
            $this->warning(Yii::t('podium/flash', 'You have reached maximum {max_messages, plural, =1{ message} other{ messages}} per {max_minutes, plural, =1{ minute} other{ minutes}} limit. Wait few minutes before sending a new message.', [
                'max_messages' => Message::SPAM_MESSAGES,
                'max_minutes' => Message::SPAM_WAIT
            ]));
            return $this->redirect(['messages/inbox']);
        }

        $model = new Message();
        $to = null;
        if (!empty($user) && (int)$user > 0 && (int)$user != $podiumUser->id) {
            $member = User::find()->where(['id' => (int)$user, 'status' => User::STATUS_ACTIVE])->limit(1)->one();
            if ($member) {
                $model->receiversId = [$member->id];
                $to = $member;
            }
        }

        if ($model->load(Yii::$app->request->post())) {
            if ($model->validate()) {
                $validated = [];
                $errors = false;
                if (!empty($model->friendsId)) {
                    $model->receiversId = array_merge(
                        is_array($model->receiversId) ? $model->receiversId : [],
                        is_array($model->friendsId) ? $model->friendsId : []
                    );
                }
                if (empty($model->receiversId)) {
                    $model->addError('receiversId', Yii::t('podium/view', 'You have to select at least one message receiver.'));
                    $errors = true;
                } else {
                    foreach ($model->receiversId as $r) {
                        if ($r == $podiumUser->id) {
                            $model->addError('receiversId', Yii::t('podium/view', 'You can not send message to yourself.'));
                            $errors = true;
                        } elseif ($podiumUser->isIgnoredBy($r)) {
                            $model->addError('receiversId', Yii::t('podium/view', 'One of the selected members ignores you and has been removed from message receivers.'));
                            $errors = true;
                        } else {
                            $member = User::find()->where(['id' => (int)$r, 'status' => User::STATUS_ACTIVE])->limit(1)->one();
                            if ($member) {
                                $validated[] = $member->id;
                                if (count($validated) > Message::MAX_RECEIVERS) {
                                    $model->addError('receiversId', Yii::t('podium/view', 'You can send message up to a maximum of 10 receivers at once.'));
                                    $errors = true;
                                    break;
                                }
                            }
                        }
                    }
                    $model->receiversId = $validated;
                }
                if (!$errors) {
                    if ($model->send()) {
                        $this->success(Yii::t('podium/flash', 'Message has been sent.'));
                        return $this->redirect(['messages/inbox']);
                    }
                    $this->error(Yii::t('podium/flash', 'Sorry! There was some error while sending your message.'));
                }
            }
        }
        return $this->render('new', ['model' => $model, 'to' => $to, 'friends' => User::friendsList()]);
    }
441654
public function getNotificationsReadAction(User $user)
    {
        $this->notificationManager->markAllNotificationsAsViewed($user->getId());

        return $this->notificationManager->getUserNotifications($user);
    }
1204809
public function Update($user)
    {
        $className = get_class($user);
        if ($className == 'MangoPay\UserNatural') {
            $methodKey = 'users_savenaturals';
            if (!is_null($user->Address)
                && is_a($user->Address, "MangoPay\Address")
                && $user->Address->CanBeNull()) {
                $user->Address = null;
            }
        } elseif ($className == 'MangoPay\UserLegal') {
            $methodKey = 'users_savelegals';
            if (!is_null($user->HeadquartersAddress)
                && is_a($user->HeadquartersAddress, "MangoPay\Address")
                && $user->HeadquartersAddress->CanBeNull()) {
                $user->HeadquartersAddress = null;
            }
            if (!is_null($user->LegalRepresentativeAddress)
                && is_a($user->LegalRepresentativeAddress, "MangoPay\Address")
                && $user->LegalRepresentativeAddress->CanBeNull()) {
                $user->LegalRepresentativeAddress = null;
            }
        } else {
            throw new Libraries\Exception('Wrong entity class for user');
        }

        $response = $this->SaveObject($methodKey, $user);
        return $this->GetUserResponse($response);
    }
1303783
public function addComment($user, string $comment) : Comment
    {
        return $this->comments()->create([
            'user_id' => $user->id,
            'comment' => $comment,
        ]);
    }
430438
private function createEditForm(User $user)
    {
        $form = $this->createForm(new UserType(), $user, array(
            'action' => $this->generateUrl('admin_user_update', array('id' => $user->getId())),
            'method' => 'PUT',
        ));

        $form->add('submit', 'submit', array('label' => 'Update'));

        return $form;
    }
1036740
public function sendGeneratedPassword(User $user, $password)
    {
        return $this->sendMessage(
            $user->email,
            $this->getNewPasswordSubject(),
            'new_password',
            ['user' => $user, 'password' => $password, 'module' => $this->module]
        );
    }
921169
public function sendNotification($user)
  {
    $token = Hash::random(35);

    VerifiedUser::create([
      'email' => $user->email,
      'token' => $token
    ]);

    return $this->sendVerifyEmailNotification($user, $token);
  }
1181406
public function updateAction(User $user)
    {
        $this->userService->updateUser($user);
        $this->addFlashMessage('Your user has been updated.', 'User updated', Message::SEVERITY_OK);
        $this->redirect('edit');
    }
371607
public function sendActivationMail($user)
    {
        if( ! $this->shouldSend($user) ) {
            return trans('HCACL::users.activation.check_email');
        }

        \DB::beginTransaction();

        try {
            $token = $this->createActivation($user);

            $user->sendActivationLinkNotification($token);
        } catch ( \Exception $e ) {
            \DB::rollback();

            throw new \Exception('Activation code or mail sending failed');
        }

        \DB::commit();

        return trans('HCACL::users.activation.resent_activation');
    }
163434
public function addMessage($message) {
        $this->message = trim(trim($this->message).NL.$message);
        return $this;
    }
204876
public function userConversations($user)
    {
        $userId = is_object($user) ? $user->getKey() : $user;

        return $this->join('mc_conversation_user', 'mc_conversation_user.conversation_id', '=', 'mc_conversations.id')
            ->where('mc_conversation_user.user_id', $userId)
            ->where('private', true)
            ->pluck('mc_conversations.id');
    }
695827
public static function AddNewUserToSession($caller, $user) {
        $users = self::GetAndStoreUsersInSession($caller);
        $users[] = $user;
        $caller->app()->user->setAttribute(
                \Puzzlout\Framework\Enums\SessionKeys::AllUsers, $users
        );
    }
1068188
private function invitationHandlerArguments($user)
    {
        return [
            $this->container->getDefinition(
                'bengor.user.infrastructure.persistence.' . $user . '_repository'
            ),
            $this->container->getDefinition(
                'bengor.user.infrastructure.security.symfony.' . $user . '_password_encoder'
            ),
        ];
    }
195948
public function addMessage(string $message)
  {
    if ( false === ($step=$this->currentStep()) ){
      throw new \Exception('No current step');
    }
    
    $step->addMessage($message);
    return $this;
  }
172711
public function addUser($user)
    {
        if (!$this->hasUser($user)) {
            return RoleUser::create(['role_id' => $this->id, 'user_id' => $user->id]);
        }

        return false;
    }
1048742
public function addRecipient($user)
    {

        // AddRecipient
        $user = new Collection($user);

        $body = $user->map(function ($v, $k) {
            return [ucfirst($k) => $v];
        })->collapse()->toArray();

        // $body = [
        //     'Email'     => $user->email,
        //     'FirstName' => $user->firstName,
        //     'LastName'  => $user->lastName,
        //     'Groups'    => $user->groups,
        // ];

        $data = $this->setBody($body)->call('AddRecipient');

        if ($data['Error']) {
            $msg = $data['Message'] ? $data['Message'] : $data['ErrorObject']['ErrorCode'];

            return Resp::error([], $msg, $data['Error']);
        }

        if (isset($data['AdditionalParams'])) {
            $user['id'] = $data['AdditionalParams'];

            return Resp::success(new Collection($user), $data['Message']);
        }

        return $this->unknown('AddRecipient');
    }
959250
public function newAction(User $user = null)
    {
        $this->view->assignMultiple([
            'currentUser' => $this->currentUser,
            'user' => $user,
            'roles' => $this->policyService->getRoles(),
            'providers' => $this->getAuthenticationProviders()
        ]);
    }