original_string: public function QueueNotification($ActivityID, $Story = '', $Position = 'last', $Force = FALSE) {
        $Activity = $this->GetID($ActivityID);
        if (!is_object($Activity))
           return;
        
        $Story = Gdn_Format::Text($Story == '' ? $Activity->Story : $Story, FALSE);
        // If this is a comment on another activity, fudge the activity a bit so that everything appears properly.
        if (is_null($Activity->RegardingUserID) && $Activity->CommentActivityID > 0) {
           $CommentActivity = $this->GetID($Activity->CommentActivityID);
           $Activity->RegardingUserID = $CommentActivity->RegardingUserID;
           $Activity->Route = '/activity/item/'.$Activity->CommentActivityID;
        }
        $User = Gdn::UserModel()->GetID($Activity->RegardingUserID, DATASET_TYPE_OBJECT); //$this->SQL->Select('UserID, Name, Email, Preferences')->From('User')->Where('UserID', $Activity->RegardingUserID)->Get()->FirstRow();
        
        if ($User) {
           if ($Force)
              $Preference = $Force;
           else {
  //            $Preferences = Gdn_Format::Unserialize($User->Preferences);
              $ConfigPreference = C('Preferences.Email.'.$Activity->ActivityType, '0');
              if ($ConfigPreference !== FALSE)
                 $Preference = GetValue('Email.'.$Activity->ActivityType, $User->Preferences, $ConfigPreference);
              else
                 $Preference = FALSE;
           }
           
           if ($Preference) {
              $ActivityHeadline = Gdn_Format::Text(Gdn_Format::ActivityHeadline($Activity, $Activity->ActivityUserID, $Activity->RegardingUserID), FALSE);
              $Email = new Gdn_Email();
              $Email->Subject(sprintf(T('[%1$s] %2$s'), Gdn::Config('Garden.Title'), $ActivityHeadline));
              $Email->To($User);
              $Message = sprintf(
                    $Story == '' ? T('EmailNotification', "%1\$s\n\n%2\$s") : T('EmailStoryNotification', "%3\$s\n\n%2\$s"),
                    $ActivityHeadline,
                    ExternalUrl($Activity->Route == '' ? '/' : $Activity->Route),
                    $Story
                 );
              $Email->Message($Message);
              if (!array_key_exists($User->UserID, $this->_NotificationQueue))
                 $this->_NotificationQueue[$User->UserID] = array();
  
              $Notification = array('ActivityID' => $ActivityID, 'User' => $User, 'Email' => $Email, 'Route' => $Activity->Route, 'Story' => $Story, 'Headline' => $ActivityHeadline, 'Activity' => $Activity);
              if ($Position == 'first')
                 $this->_NotificationQueue[$User->UserID] = array_merge(array($Notification), $this->_NotificationQueue[$User->UserID]);
              else
                 $this->_NotificationQueue[$User->UserID][] = $Notification;
           }
        }
     }
code: public function QueueNotification($ActivityID, $Story = '', $Position = 'last', $Force = FALSE) {
        $Activity = $this->GetID($ActivityID);
        if (!is_object($Activity))
           return;
        
        $Story = Gdn_Format::Text($Story == '' ? $Activity->Story : $Story, FALSE);
        // If this is a comment on another activity, fudge the activity a bit so that everything appears properly.
        if (is_null($Activity->RegardingUserID) && $Activity->CommentActivityID > 0) {
           $CommentActivity = $this->GetID($Activity->CommentActivityID);
           $Activity->RegardingUserID = $CommentActivity->RegardingUserID;
           $Activity->Route = '/activity/item/'.$Activity->CommentActivityID;
        }
        $User = Gdn::UserModel()->GetID($Activity->RegardingUserID, DATASET_TYPE_OBJECT); //$this->SQL->Select('UserID, Name, Email, Preferences')->From('User')->Where('UserID', $Activity->RegardingUserID)->Get()->FirstRow();
        
        if ($User) {
           if ($Force)
              $Preference = $Force;
           else {
  //            $Preferences = Gdn_Format::Unserialize($User->Preferences);
              $ConfigPreference = C('Preferences.Email.'.$Activity->ActivityType, '0');
              if ($ConfigPreference !== FALSE)
                 $Preference = GetValue('Email.'.$Activity->ActivityType, $User->Preferences, $ConfigPreference);
              else
                 $Preference = FALSE;
           }
           
           if ($Preference) {
              $ActivityHeadline = Gdn_Format::Text(Gdn_Format::ActivityHeadline($Activity, $Activity->ActivityUserID, $Activity->RegardingUserID), FALSE);
              $Email = new Gdn_Email();
              $Email->Subject(sprintf(T('[%1$s] %2$s'), Gdn::Config('Garden.Title'), $ActivityHeadline));
              $Email->To($User);
              $Message = sprintf(
                    $Story == '' ? T('EmailNotification', "%1\$s\n\n%2\$s") : T('EmailStoryNotification', "%3\$s\n\n%2\$s"),
                    $ActivityHeadline,
                    ExternalUrl($Activity->Route == '' ? '/' : $Activity->Route),
                    $Story
                 );
              $Email->Message($Message);
              if (!array_key_exists($User->UserID, $this->_NotificationQueue))
                 $this->_NotificationQueue[$User->UserID] = array();
  
              $Notification = array('ActivityID' => $ActivityID, 'User' => $User, 'Email' => $Email, 'Route' => $Activity->Route, 'Story' => $Story, 'Headline' => $ActivityHeadline, 'Activity' => $Activity);
              if ($Position == 'first')
                 $this->_NotificationQueue[$User->UserID] = array_merge(array($Notification), $this->_NotificationQueue[$User->UserID]);
              else
                 $this->_NotificationQueue[$User->UserID][] = $Notification;
           }
        }
     }
code_tokens: public function QueueNotification ( $ ActivityID , $ Story = '' , $ Position = 'last' , $ Force = FALSE ) { $ Activity = $ this -> GetID ( $ ActivityID ) ; if ( ! is_object ( $ Activity ) ) return ; $ Story = Gdn_Format :: Text ( $ Story == '' ? $ Activity -> Story : $ Story , FALSE ) ; // If this is a comment on another activity, fudge the activity a bit so that everything appears properly. if ( is_null ( $ Activity -> RegardingUserID ) && $ Activity -> CommentActivityID > 0 ) { $ CommentActivity = $ this -> GetID ( $ Activity -> CommentActivityID ) ; $ Activity -> RegardingUserID = $ CommentActivity -> RegardingUserID ; $ Activity -> Route = '/activity/item/' . $ Activity -> CommentActivityID ; } $ User = Gdn :: UserModel ( ) -> GetID ( $ Activity -> RegardingUserID , DATASET_TYPE_OBJECT ) ; //$this->SQL->Select('UserID, Name, Email, Preferences')->From('User')->Where('UserID', $Activity->RegardingUserID)->Get()->FirstRow(); if ( $ User ) { if ( $ Force ) $ Preference = $ Force ; else { //            $Preferences = Gdn_Format::Unserialize($User->Preferences); $ ConfigPreference = C ( 'Preferences.Email.' . $ Activity -> ActivityType , '0' ) ; if ( $ ConfigPreference !== FALSE ) $ Preference = GetValue ( 'Email.' . $ Activity -> ActivityType , $ User -> Preferences , $ ConfigPreference ) ; else $ Preference = FALSE ; } if ( $ Preference ) { $ ActivityHeadline = Gdn_Format :: Text ( Gdn_Format :: ActivityHeadline ( $ Activity , $ Activity -> ActivityUserID , $ Activity -> RegardingUserID ) , FALSE ) ; $ Email = new Gdn_Email ( ) ; $ Email -> Subject ( sprintf ( T ( '[%1$s] %2$s' ) , Gdn :: Config ( 'Garden.Title' ) , $ ActivityHeadline ) ) ; $ Email -> To ( $ User ) ; $ Message = sprintf ( $ Story == '' ? T ( 'EmailNotification' , "%1\$s\n\n%2\$s" ) : T ( 'EmailStoryNotification' , "%3\$s\n\n%2\$s" ) , $ ActivityHeadline , ExternalUrl ( $ Activity -> Route == '' ? '/' : $ Activity -> Route ) , $ Story ) ; $ Email -> Message ( $ Message ) ; if ( ! array_key_exists ( $ User -> UserID , $ this -> _NotificationQueue ) ) $ this -> _NotificationQueue [ $ User -> UserID ] = array ( ) ; $ Notification = array ( 'ActivityID' => $ ActivityID , 'User' => $ User , 'Email' => $ Email , 'Route' => $ Activity -> Route , 'Story' => $ Story , 'Headline' => $ ActivityHeadline , 'Activity' => $ Activity ) ; if ( $ Position == 'first' ) $ this -> _NotificationQueue [ $ User -> UserID ] = array_merge ( array ( $ Notification ) , $ this -> _NotificationQueue [ $ User -> UserID ] ) ; else $ this -> _NotificationQueue [ $ User -> UserID ] [ ] = $ Notification ; } } }
docstring: Queue a notification for sending.
  
  @since 2.0.17
  @access public
  @param int $ActivityID
  @param string $Story
  @param string $Position
  @param bool $Force
docstring_tokens: Queue a notification for sending .