AddPeopleModule::__construct PHP Method

__construct() public method

public __construct ( Gdn_Controller $Sender = null )
$Sender Gdn_Controller
    public function __construct($Sender = null)
    {
        if (property_exists($Sender, 'Conversation')) {
            $this->Conversation = $Sender->Conversation;
        }
        // Allowed to use this module?
        $this->AddUserAllowed = $Sender->ConversationModel->addUserAllowed($this->Conversation->ConversationID);
        $this->Form = Gdn::factory('Form', 'AddPeople');
        // If the form was posted back, check for people to add to the conversation
        if ($this->Form->authenticatedPostBack()) {
            // Defer exceptions until they try to use the form so we don't fill our logs
            if (!$this->AddUserAllowed || !checkPermission('Conversations.Conversations.Add')) {
                throw permissionException();
            }
            $NewRecipientUserIDs = array();
            $NewRecipients = explode(',', $this->Form->getFormValue('AddPeople', ''));
            $UserModel = Gdn::factory("UserModel");
            foreach ($NewRecipients as $Name) {
                if (trim($Name) != '') {
                    $User = $UserModel->getByUsername(trim($Name));
                    if (is_object($User)) {
                        $NewRecipientUserIDs[] = $User->UserID;
                    }
                }
            }
            $Sender->ConversationModel->addUserToConversation($this->Conversation->ConversationID, $NewRecipientUserIDs);
            $Sender->informMessage(t('Your changes were saved.'));
            $Sender->RedirectUrl = url('/messages/' . $this->Conversation->ConversationID);
        }
        $this->_ApplicationFolder = $Sender->Application;
        $this->_ThemeFolder = $Sender->Theme;
    }