original_string: public function SendNotification($ActivityID, $Story = '', $Force = FALSE) {
        $Activity = $this->GetID($ActivityID);
        if (!$Activity)
           return;
        
        $Activity = (object)$Activity;
        
        $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);
  
        if ($User) {
           if ($Force)
              $Preference = $Force;
           else {
              $Preferences = $User->Preferences;
              $Preference = ArrayValue('Email.'.$Activity->ActivityType, $Preferences, Gdn::Config('Preferences.Email.'.$Activity->ActivityType));
           }
           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);
              //$Email->From(Gdn::Config('Garden.SupportEmail'), Gdn::Config('Garden.SupportName'));
              
              $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);
              
              $Notification = array('ActivityID' => $ActivityID, 'User' => $User, 'Email' => $Email, 'Route' => $Activity->Route, 'Story' => $Story, 'Headline' => $ActivityHeadline, 'Activity' => $Activity);
              $this->EventArguments = $Notification;
              $this->FireEvent('BeforeSendNotification');
              try {
                 // Only send if the user is not banned
                 if (!GetValue('Banned', $User))
                    $Email->Send();
                 
                 $Emailed = self::SENT_OK;
              } catch (phpmailerException $pex) {
                 if ($pex->getCode() == PHPMailer::STOP_CRITICAL)
                    $Emailed = self::SENT_FAIL;
                 else
                    $Emailed = self::SENT_ERROR;
              } catch (Exception $ex) {
                 $Emailed = self::SENT_FAIL; // similar to http 5xx
              }
              try {
                 $this->SQL->Put('Activity', array('Emailed' => $Emailed), array('ActivityID' => $ActivityID));
              } catch (Exception $Ex) {
              }
           }
        }
     }
code: public function SendNotification($ActivityID, $Story = '', $Force = FALSE) {
        $Activity = $this->GetID($ActivityID);
        if (!$Activity)
           return;
        
        $Activity = (object)$Activity;
        
        $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);
  
        if ($User) {
           if ($Force)
              $Preference = $Force;
           else {
              $Preferences = $User->Preferences;
              $Preference = ArrayValue('Email.'.$Activity->ActivityType, $Preferences, Gdn::Config('Preferences.Email.'.$Activity->ActivityType));
           }
           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);
              //$Email->From(Gdn::Config('Garden.SupportEmail'), Gdn::Config('Garden.SupportName'));
              
              $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);
              
              $Notification = array('ActivityID' => $ActivityID, 'User' => $User, 'Email' => $Email, 'Route' => $Activity->Route, 'Story' => $Story, 'Headline' => $ActivityHeadline, 'Activity' => $Activity);
              $this->EventArguments = $Notification;
              $this->FireEvent('BeforeSendNotification');
              try {
                 // Only send if the user is not banned
                 if (!GetValue('Banned', $User))
                    $Email->Send();
                 
                 $Emailed = self::SENT_OK;
              } catch (phpmailerException $pex) {
                 if ($pex->getCode() == PHPMailer::STOP_CRITICAL)
                    $Emailed = self::SENT_FAIL;
                 else
                    $Emailed = self::SENT_ERROR;
              } catch (Exception $ex) {
                 $Emailed = self::SENT_FAIL; // similar to http 5xx
              }
              try {
                 $this->SQL->Put('Activity', array('Emailed' => $Emailed), array('ActivityID' => $ActivityID));
              } catch (Exception $Ex) {
              }
           }
        }
     }
code_tokens: public function SendNotification ( $ ActivityID , $ Story = '' , $ Force = FALSE ) { $ Activity = $ this -> GetID ( $ ActivityID ) ; if ( ! $ Activity ) return ; $ Activity = ( object ) $ Activity ; $ 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 ) ; if ( $ User ) { if ( $ Force ) $ Preference = $ Force ; else { $ Preferences = $ User -> Preferences ; $ Preference = ArrayValue ( 'Email.' . $ Activity -> ActivityType , $ Preferences , Gdn :: Config ( 'Preferences.Email.' . $ Activity -> ActivityType ) ) ; } 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 ) ; //$Email->From(Gdn::Config('Garden.SupportEmail'), Gdn::Config('Garden.SupportName')); $ 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 ) ; $ Notification = array ( 'ActivityID' => $ ActivityID , 'User' => $ User , 'Email' => $ Email , 'Route' => $ Activity -> Route , 'Story' => $ Story , 'Headline' => $ ActivityHeadline , 'Activity' => $ Activity ) ; $ this -> EventArguments = $ Notification ; $ this -> FireEvent ( 'BeforeSendNotification' ) ; try { // Only send if the user is not banned if ( ! GetValue ( 'Banned' , $ User ) ) $ Email -> Send ( ) ; $ Emailed = self :: SENT_OK ; } catch ( phpmailerException $ pex ) { if ( $ pex -> getCode ( ) == PHPMailer :: STOP_CRITICAL ) $ Emailed = self :: SENT_FAIL ; else $ Emailed = self :: SENT_ERROR ; } catch ( Exception $ ex ) { $ Emailed = self :: SENT_FAIL ; // similar to http 5xx } try { $ this -> SQL -> Put ( 'Activity' , array ( 'Emailed' => $ Emailed ) , array ( 'ActivityID' => $ ActivityID ) ) ; } catch ( Exception $ Ex ) { } } } }
docstring: Send notification.
  
  @since 2.0.17
  @access public
  @param int $ActivityID
  @param array $Story
  @param string $Force
docstring_tokens: Send notification .