public function add($ActivityUserID, $ActivityType, $Story = null, $RegardingUserID = null, $CommentActivityID = null, $Route = null, $SendEmail = '')
{
// Get the ActivityTypeID & see if this is a notification.
$ActivityTypeRow = self::getActivityType($ActivityType);
$Notify = val('Notify', $ActivityTypeRow, false);
if ($ActivityTypeRow === false) {
trigger_error(errorMessage(sprintf('Activity type could not be found: %s', $ActivityType), 'ActivityModel', 'Add'), E_USER_ERROR);
}
$Activity = ['ActivityUserID' => $ActivityUserID, 'ActivityType' => $ActivityType, 'Story' => $Story, 'RegardingUserID' => $RegardingUserID, 'Route' => $Route];
// Massage $SendEmail to allow for only sending an email.
if ($SendEmail === 'Only') {
$SendEmail = '';
} elseif ($SendEmail === 'QueueOnly') {
$SendEmail = '';
$Notify = true;
}
// If $SendEmail was FALSE or TRUE, let it override the $Notify setting.
if ($SendEmail === false || $SendEmail === true) {
$Notify = $SendEmail;
}
$Preference = false;
if (($ActivityTypeRow['Notify'] || !$ActivityTypeRow['Public']) && !empty($RegardingUserID)) {
$Activity['NotifyUserID'] = $Activity['RegardingUserID'];
$Preference = $ActivityType;
} else {
$Activity['NotifyUserID'] = self::NOTIFY_PUBLIC;
}
// Otherwise let the decision to email lie with the $Notify setting.
if ($SendEmail === 'Force' || $Notify) {
$Activity['Emailed'] = self::SENT_PENDING;
} elseif ($Notify) {
$Activity['Emailed'] = self::SENT_PENDING;
} elseif ($SendEmail === false) {
$Activity['Emailed'] = self::SENT_ARCHIVE;
}
$Activity = $this->save($Activity, $Preference);
return val('ActivityID', $Activity);
}