applications/conversations/controllers/class.messagescontroller.php
public function Add($Recipient = '') {
      $this->Form->SetModel($this->ConversationModel);
      
      if ($this->Form->AuthenticatedPostBack()) {
         $RecipientUserIDs = array();
         $To = explode(',', $this->Form->GetFormValue('To', ''));
         $UserModel = new UserModel();
         foreach ($To as $Name) {
            if (trim($Name) != '') {
               $User = $UserModel->GetByUsername(trim($Name));
               if (is_object($User))
                  $RecipientUserIDs[] = $User->UserID;
            }
         }
         
         $this->EventArguments['Recipients'] = $RecipientUserIDs;
         $this->FireEvent('BeforeAddConversation');
         
         $this->Form->SetFormValue('RecipientUserID', $RecipientUserIDs);
         $ConversationID = $this->Form->Save($this->ConversationMessageModel);
         if ($ConversationID !== FALSE) {
            $Target = $this->Form->GetFormValue('Target', 'messages/'.$ConversationID);
            
            $this->RedirectUrl = Url($Target);
         }
      } else {
         if ($Recipient != '')
            $this->Form->SetValue('To', $Recipient);
      }
      if ($Target = Gdn::Request()->Get('Target'))
            $this->Form->AddHidden('Target', $Target);

      Gdn_Theme::Section('PostConversation');
      $this->Title(T('New Conversation'));
      $this->SetData('Breadcrumbs', array(array('Name' => T('Inbox'), 'Url' => '/messages/inbox'), array('Name' => $this->Data('Title'), 'Url' => 'messages/add')));
      $this->Render();      
   }
public function Add($Recipient = '') {
      $this->Form->SetModel($this->ConversationModel);
      
      if ($this->Form->AuthenticatedPostBack()) {
         $RecipientUserIDs = array();
         $To = explode(',', $this->Form->GetFormValue('To', ''));
         $UserModel = new UserModel();
         foreach ($To as $Name) {
            if (trim($Name) != '') {
               $User = $UserModel->GetByUsername(trim($Name));
               if (is_object($User))
                  $RecipientUserIDs[] = $User->UserID;
            }
         }
         
         $this->EventArguments['Recipients'] = $RecipientUserIDs;
         $this->FireEvent('BeforeAddConversation');
         
         $this->Form->SetFormValue('RecipientUserID', $RecipientUserIDs);
         $ConversationID = $this->Form->Save($this->ConversationMessageModel);
         if ($ConversationID !== FALSE) {
            $Target = $this->Form->GetFormValue('Target', 'messages/'.$ConversationID);
            
            $this->RedirectUrl = Url($Target);
         }
      } else {
         if ($Recipient != '')
            $this->Form->SetValue('To', $Recipient);
      }
      if ($Target = Gdn::Request()->Get('Target'))
            $this->Form->AddHidden('Target', $Target);

      Gdn_Theme::Section('PostConversation');
      $this->Title(T('New Conversation'));
      $this->SetData('Breadcrumbs', array(array('Name' => T('Inbox'), 'Url' => '/messages/inbox'), array('Name' => $this->Data('Title'), 'Url' => 'messages/add')));
      $this->Render();      
   }
public function Add ( $ Recipient = '' ) { $ this -> Form -> SetModel ( $ this -> ConversationModel ) ; if ( $ this -> Form -> AuthenticatedPostBack ( ) ) { $ RecipientUserIDs = array ( ) ; $ To = explode ( ',' , $ this -> Form -> GetFormValue ( 'To' , '' ) ) ; $ UserModel = new UserModel ( ) ; foreach ( $ To as $ Name ) { if ( trim ( $ Name ) != '' ) { $ User = $ UserModel -> GetByUsername ( trim ( $ Name ) ) ; if ( is_object ( $ User ) ) $ RecipientUserIDs [ ] = $ User -> UserID ; } } $ this -> EventArguments [ 'Recipients' ] = $ RecipientUserIDs ; $ this -> FireEvent ( 'BeforeAddConversation' ) ; $ this -> Form -> SetFormValue ( 'RecipientUserID' , $ RecipientUserIDs ) ; $ ConversationID = $ this -> Form -> Save ( $ this -> ConversationMessageModel ) ; if ( $ ConversationID !== FALSE ) { $ Target = $ this -> Form -> GetFormValue ( 'Target' , 'messages/' . $ ConversationID ) ; $ this -> RedirectUrl = Url ( $ Target ) ; } } else { if ( $ Recipient != '' ) $ this -> Form -> SetValue ( 'To' , $ Recipient ) ; } if ( $ Target = Gdn :: Request ( ) -> Get ( 'Target' ) ) $ this -> Form -> AddHidden ( 'Target' , $ Target ) ; Gdn_Theme :: Section ( 'PostConversation' ) ; $ this -> Title ( T ( 'New Conversation' ) ) ; $ this -> SetData ( 'Breadcrumbs' , array ( array ( 'Name' => T ( 'Inbox' ) , 'Url' => '/messages/inbox' ) , array ( 'Name' => $ this -> Data ( 'Title' ) , 'Url' => 'messages/add' ) ) ) ; $ this -> Render ( ) ; }
Start a new conversation.

@since 2.0.0
@access public

@param string $Recipient Username of the recipient.
Start a new conversation .