本文整理汇总了PHP中DiscussionUrl函数的典型用法代码示例。如果您正苦于以下问题:PHP DiscussionUrl函数的具体用法?PHP DiscussionUrl怎么用?PHP DiscussionUrl使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了DiscussionUrl函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: writeModuleDiscussion
function writeModuleDiscussion($Discussion, $Px = 'Bookmark')
{
?>
<li id="<?php
echo "{$Px}_{$Discussion->DiscussionID}";
?>
" class="<?php
echo CssClass($Discussion);
?>
">
<span class="Options">
<?php
// echo OptionsList($Discussion);
echo BookmarkButton($Discussion);
?>
</span>
<div class="Title"><?php
echo anchor(Gdn_Format::text($Discussion->Name, false), DiscussionUrl($Discussion) . ($Discussion->CountCommentWatch > 0 ? '#Item_' . $Discussion->CountCommentWatch : ''), 'DiscussionLink');
?>
</div>
<div class="Meta">
<?php
$Last = new stdClass();
$Last->UserID = $Discussion->LastUserID;
$Last->Name = $Discussion->LastName;
echo NewComments($Discussion);
echo '<span class="MItem">' . Gdn_Format::date($Discussion->LastDate, 'html') . UserAnchor($Last) . '</span>';
?>
</div>
</li>
<?php
}
示例2: DiscussionController_Bump_Create
/**
* Handle discussion option menu bump action.
*/
public function DiscussionController_Bump_Create($Sender, $Args)
{
$Sender->Permission('Garden.Moderation.Manage');
// Get discussion
$DiscussionID = $Sender->Request->Get('discussionid');
$Discussion = $Sender->DiscussionModel->GetID($DiscussionID);
if (!$Discussion) {
throw NotFoundException('Discussion');
}
// Update DateLastComment & redirect
$Sender->DiscussionModel->SetProperty($DiscussionID, 'DateLastComment', Gdn_Format::ToDateTime());
Redirect(DiscussionUrl($Discussion));
}
示例3: DiscussionController_NoIndex_Create
/**
* Handle discussion option menu NoIndex action (simple toggle).
*/
public function DiscussionController_NoIndex_Create($Sender, $Args)
{
$Sender->Permission(array('Garden.Moderation.Manage', 'Garden.Curation.Manage'), FALSE);
// Get discussion
$DiscussionID = $Sender->Request->Get('discussionid');
$Discussion = $Sender->DiscussionModel->GetID($DiscussionID);
if (!$Discussion) {
throw NotFoundException('Discussion');
}
// Toggle NoIndex
$NoIndex = GetValue('NoIndex', $Discussion) ? 0 : 1;
// Update DateLastComment & redirect
$Sender->DiscussionModel->SetProperty($DiscussionID, 'NoIndex', $NoIndex);
Redirect(DiscussionUrl($Discussion));
}
示例4: WriteDiscussionEvent
function WriteDiscussionEvent($Discussion, $Prefix = null)
{
?>
<li class="<?php
echo CssClass($Discussion);
?>
">
<div class="Title">
<?php
echo Anchor(Gdn_Format::Text($Discussion->Name, false), DiscussionUrl($Discussion) . ($Discussion->CountCommentWatch > 0 ? '#Item_' . $Discussion->CountCommentWatch : ''), 'DiscussionLink');
?>
</div><div class="Meta"><span class="MItem">
<?php
echo Gdn_Format::Date($Discussion->DiscussionEventDate, 'html');
?>
</span></div>
</li>
<?php
}
示例5: writeModuleDiscussion
function writeModuleDiscussion($Discussion, $Px = 'Bookmark', $showPhotos = false)
{
?>
<li id="<?php
echo "{$Px}_{$Discussion->DiscussionID}";
?>
" class="<?php
echo CssClass($Discussion);
?>
">
<?php
if ($showPhotos) {
$firstUser = userBuilder($Discussion, 'First');
echo userPhoto($firstUser, ['LinkClass' => 'IndexPhoto']);
}
?>
<span class="Options">
<?php
// echo OptionsList($Discussion);
echo BookmarkButton($Discussion);
?>
</span>
<div class="Title"><?php
echo anchor(Gdn_Format::text($Discussion->Name, false), DiscussionUrl($Discussion) . ($Discussion->CountCommentWatch > 0 ? '#Item_' . $Discussion->CountCommentWatch : ''), 'DiscussionLink');
?>
</div>
<div class="Meta DiscussionsModuleMeta">
<?php
$Last = new stdClass();
$Last->UserID = $Discussion->LastUserID;
$Last->Name = $Discussion->LastName;
echo NewComments($Discussion);
$translation = pluralTranslate($Discussion->CountComments, '%s comment html', '%s comments html', t('%s comment'), t('%s comments'));
echo '<span class="MItem">' . Gdn_Format::date($Discussion->LastDate, 'html') . UserAnchor($Last) . '</span>';
echo '<span class="MItem CountComments Hidden">' . sprintf($translation, $Discussion->CountComments) . '</span>';
?>
</div>
</li>
<?php
}
示例6: DiscussionController_Author_Create
/**
* Handle discussion option menu Change Author action.
*/
public function DiscussionController_Author_Create($Sender, $Args)
{
$DiscussionID = $Sender->Request->Get('discussionid');
$Discussion = $Sender->DiscussionModel->GetID($DiscussionID);
if (!$Discussion) {
throw NotFoundException('Discussion');
}
// Check edit permission
$Sender->Permission('Vanilla.Discussions.Edit', TRUE, 'Category', $Discussion->PermissionCategoryID);
if ($Sender->Form->AuthenticatedPostBack()) {
// Change the author
$Name = $Sender->Form->GetFormValue('Author', '');
$UserModel = new UserModel();
if (trim($Name) != '') {
$User = $UserModel->GetByUsername(trim($Name));
if (is_object($User)) {
if ($Discussion->InsertUserID == $User->UserID) {
$Sender->Form->AddError('That user is already the discussion author.');
} else {
// Change discussion InsertUserID
$Sender->DiscussionModel->SetField($DiscussionID, 'InsertUserID', $User->UserID);
// Update users' discussion counts
$Sender->DiscussionModel->UpdateUserDiscussionCount($Discussion->InsertUserID);
$Sender->DiscussionModel->UpdateUserDiscussionCount($User->UserID, TRUE);
// Increment
// Go to the updated discussion
Redirect(DiscussionUrl($Discussion));
}
} else {
$Sender->Form->AddError('No user with that name was found.');
}
}
} else {
// Form to change the author
$Sender->SetData('Title', $Discussion->Name);
}
$Sender->Render('changeauthor', '', 'plugins/AuthorSelector');
}
示例7: commentModel_afterSaveComment_handler
/**
*
*
* @param $Sender
* @param $Args
* @throws Gdn_UserException
*/
public function commentModel_afterSaveComment_handler($Sender, $Args)
{
if (!$this->socialSharing() || !$this->accessToken()) {
return;
}
$Share = valr('FormPostValues.ShareTwitter', $Args);
if ($Share && $this->accessToken()) {
$Row = $Args['FormPostValues'];
$DiscussionModel = new DiscussionModel();
$Discussion = $DiscussionModel->getID(val('DiscussionID', $Row));
if (!$Discussion) {
return;
}
$Url = DiscussionUrl($Discussion, '', true);
$Message = SliceTwitter(Gdn_Format::plainText($Row['Body'], $Row['Format'])) . ' ' . $Url;
$R = $this->API('/statuses/update.json', array('status' => $Message), 'POST');
}
}
示例8: writePageLink
function writePageLink($Discussion, $PageNumber)
{
echo anchor($PageNumber, DiscussionUrl($Discussion, $PageNumber));
}
示例9: ModerationController_MergeDiscussions_Create
/**
* Add a method to the ModerationController to handle merging discussions.
* @param Gdn_Controller $Sender
*/
public function ModerationController_MergeDiscussions_Create($Sender)
{
$Session = Gdn::Session();
$Sender->Form = new Gdn_Form();
$Sender->Title(T('Merge Discussions'));
$DiscussionModel = new DiscussionModel();
$CheckedDiscussions = Gdn::UserModel()->GetAttribute($Session->User->UserID, 'CheckedDiscussions', array());
if (!is_array($CheckedDiscussions)) {
$CheckedDiscussions = array();
}
$DiscussionIDs = $CheckedDiscussions;
$Sender->SetData('DiscussionIDs', $DiscussionIDs);
$CountCheckedDiscussions = count($DiscussionIDs);
$Sender->SetData('CountCheckedDiscussions', $CountCheckedDiscussions);
$Discussions = $DiscussionModel->SQL->WhereIn('DiscussionID', $DiscussionIDs)->Get('Discussion')->ResultArray();
$Sender->SetData('Discussions', $Discussions);
// Perform the merge
if ($Sender->Form->AuthenticatedPostBack()) {
// Create a new discussion record
$MergeDiscussion = FALSE;
$MergeDiscussionID = $Sender->Form->GetFormValue('MergeDiscussionID');
foreach ($Discussions as $Discussion) {
if ($Discussion['DiscussionID'] == $MergeDiscussionID) {
$MergeDiscussion = $Discussion;
break;
}
}
$RedirectLink = $Sender->Form->GetFormValue('RedirectLink');
if ($MergeDiscussion) {
$ErrorCount = 0;
// Verify that the user has permission to perform the merge.
$Category = CategoryModel::Categories($MergeDiscussion['CategoryID']);
if ($Category && !$Category['PermsDiscussionsEdit']) {
throw PermissionException('Vanilla.Discussions.Edit');
}
$DiscussionModel->DefineSchema();
$MaxNameLength = GetValue('Length', $DiscussionModel->Schema->GetField('Name'));
// Assign the comments to the new discussion record
$DiscussionModel->SQL->Update('Comment')->Set('DiscussionID', $MergeDiscussionID)->WhereIn('DiscussionID', $DiscussionIDs)->Put();
$CommentModel = new CommentModel();
foreach ($Discussions as $Discussion) {
if ($Discussion['DiscussionID'] == $MergeDiscussionID) {
continue;
}
// Create a comment out of the discussion.
$Comment = ArrayTranslate($Discussion, array('Body', 'Format', 'DateInserted', 'InsertUserID', 'InsertIPAddress', 'DateUpdated', 'UpdateUserID', 'UpdateIPAddress', 'Attributes', 'Spam', 'Likes', 'Abuse'));
$Comment['DiscussionID'] = $MergeDiscussionID;
$CommentModel->Validation->Results(TRUE);
$CommentID = $CommentModel->Save($Comment);
if ($CommentID) {
// Move any attachments (FileUpload plugin awareness)
if (class_exists('MediaModel')) {
$MediaModel = new MediaModel();
$MediaModel->Reassign($Discussion['DiscussionID'], 'discussion', $CommentID, 'comment');
}
if ($RedirectLink) {
// The discussion needs to be changed to a moved link.
$RedirectDiscussion = array('Name' => SliceString(sprintf(T('Merged: %s'), $Discussion['Name']), $MaxNameLength), 'Type' => 'redirect', 'Body' => FormatString(T('This discussion has been <a href="{url,html}">merged</a>.'), array('url' => DiscussionUrl($MergeDiscussion))), 'Format' => 'Html');
$DiscussionModel->SetField($Discussion['DiscussionID'], $RedirectDiscussion);
$CommentModel->UpdateCommentCount($Discussion['DiscussionID']);
$CommentModel->RemovePageCache($Discussion['DiscussionID']);
} else {
// Delete discussion that was merged.
$DiscussionModel->Delete($Discussion['DiscussionID']);
}
} else {
$Sender->InformMessage($CommentModel->Validation->ResultsText());
$ErrorCount++;
}
}
// Update counts on all affected discussions.
$CommentModel->UpdateCommentCount($MergeDiscussionID);
$CommentModel->RemovePageCache($MergeDiscussionID);
// Clear selections
Gdn::UserModel()->SaveAttribute($Session->UserID, 'CheckedDiscussions', FALSE);
ModerationController::InformCheckedDiscussions($Sender);
if ($ErrorCount == 0) {
$Sender->JsonTarget('', '', 'Refresh');
}
}
}
$Sender->Render('MergeDiscussions', '', 'plugins/SplitMerge');
}
示例10: WritePromotedContent
function WritePromotedContent($Content, $Sender)
{
static $UserPhotoFirst = NULL;
if ($UserPhotoFirst === NULL) {
$UserPhotoFirst = C('Vanilla.Comment.UserPhotoFirst', TRUE);
}
$ContentType = GetValue('ItemType', $Content);
$ContentID = GetValue("{$ContentType}ID", $Content);
$Author = GetValue('Author', $Content);
switch (strtolower($ContentType)) {
case 'comment':
$ContentURL = CommentUrl($Content);
break;
case 'discussion':
$ContentURL = DiscussionUrl($Content);
break;
}
?>
<div id="<?php
echo "Promoted_{$ContentType}_{$ContentID}";
?>
" class="<?php
echo CssClass($Content);
?>
">
<div class="AuthorWrap">
<span class="Author">
<?php
if ($UserPhotoFirst) {
echo UserPhoto($Author);
echo UserAnchor($Author, 'Username');
} else {
echo UserAnchor($Author, 'Username');
echo UserPhoto($Author);
}
$Sender->FireEvent('AuthorPhoto');
?>
</span>
<span class="AuthorInfo">
<?php
echo ' ' . WrapIf(htmlspecialchars(GetValue('Title', $Author)), 'span', array('class' => 'MItem AuthorTitle'));
echo ' ' . WrapIf(htmlspecialchars(GetValue('Location', $Author)), 'span', array('class' => 'MItem AuthorLocation'));
$Sender->FireEvent('AuthorInfo');
?>
</span>
</div>
<div class="Meta CommentMeta CommentInfo">
<span class="MItem DateCreated">
<?php
echo Anchor(Gdn_Format::Date($Content['DateInserted'], 'html'), $Permalink, 'Permalink', array('rel' => 'nofollow'));
?>
</span>
<?php
// Include source if one was set
if ($Source = GetValue('Source', $Content)) {
echo Wrap(sprintf(T('via %s'), T($Source . ' Source', $Source)), 'span', array('class' => 'MItem Source'));
}
$Sender->FireEvent('ContentInfo');
?>
</div>
<div class="Title"><?php
echo Anchor(Gdn_Format::Text($Content['Name'], FALSE), $ContentURL, 'DiscussionLink');
?>
</div>
<div class="Body"><?php
echo Anchor(strip_tags(Gdn_Format::To($Content['Body'], $Content['Format'])), $ContentURL, 'BodyLink');
?>
</div>
</div>
<?php
}
示例11: notifyNewDiscussion
public function notifyNewDiscussion($DiscussionID)
{
if (!c('Vanilla.QueueNotifications')) {
throw forbiddenException('NotifyNewDiscussion');
}
if (!$this->Request->isPostBack()) {
throw forbiddenException('GET');
}
// Grab the discussion.
$Discussion = $this->DiscussionModel->getID($DiscussionID);
if (!$Discussion) {
throw notFoundException('Discussion');
}
if (val('Notified', $Discussion) != ActivityModel::SENT_PENDING) {
die('Not pending');
}
// Mark the notification as in progress.
$this->DiscussionModel->setField($DiscussionID, 'Notified', ActivityModel::SENT_INPROGRESS);
$discussionType = val('Type', $Discussion);
if ($discussionType) {
$Code = "HeadlineFormat.Discussion.{$discussionType}";
} else {
$Code = 'HeadlineFormat.Discussion';
}
$HeadlineFormat = t($Code, '{ActivityUserID,user} started a new discussion: <a href="{Url,html}">{Data.Name,text}</a>');
$Category = CategoryModel::categories(val('CategoryID', $Discussion));
$Activity = array('ActivityType' => 'Discussion', 'ActivityUserID' => $Discussion->InsertUserID, 'HeadlineFormat' => $HeadlineFormat, 'RecordType' => 'Discussion', 'RecordID' => $DiscussionID, 'Route' => DiscussionUrl($Discussion), 'Data' => array('Name' => $Discussion->Name, 'Category' => val('Name', $Category)));
$ActivityModel = new ActivityModel();
$this->DiscussionModel->NotifyNewDiscussion($Discussion, $ActivityModel, $Activity);
$ActivityModel->SaveQueue();
$this->DiscussionModel->setField($DiscussionID, 'Notified', ActivityModel::SENT_OK);
die('OK');
}
示例12: incrementNewDiscussion
public function incrementNewDiscussion($Discussion)
{
if (is_numeric($Discussion)) {
$Discussion = $this->getID($Discussion);
}
if (!$Discussion) {
return;
}
$this->SQL->update('Category')->set('CountDiscussions', 'CountDiscussions + 1', false)->set('LastDiscussionID', val('DiscussionID', $Discussion))->set('LastCommentID', null)->set('LastDateInserted', val('DateInserted', $Discussion))->where('CategoryID', val('CategoryID', $Discussion))->put();
$Category = CategoryModel::categories(val('CategoryID', $Discussion));
if ($Category) {
CategoryModel::SetCache($Category['CategoryID'], array('CountDiscussions' => $Category['CountDiscussions'] + 1, 'LastDiscussionID' => val('DiscussionID', $Discussion), 'LastCommentID' => null, 'LastDateInserted' => val('DateInserted', $Discussion), 'LastTitle' => Gdn_Format::text(val('Name', $Discussion, t('No Title'))), 'LastUserID' => val('InsertUserID', $Discussion), 'LastDiscussionUserID' => val('InsertUserID', $Discussion), 'LastUrl' => DiscussionUrl($Discussion, false, '//') . '#latest'));
}
}
示例13: IncrementNewDiscussion
public function IncrementNewDiscussion($Discussion)
{
if (is_numeric($Discussion)) {
$Discussion = $this->GetID($Discussion);
}
if (!$Discussion) {
return;
}
$this->SQL->Update('Category')->Set('CountDiscussions', 'CountDiscussions + 1', FALSE)->Set('LastDiscussionID', GetValue('DiscussionID', $Discussion))->Set('LastCommentID', NULL)->Set('LastDateInserted', GetValue('DateInserted', $Discussion))->Where('CategoryID', GetValue('CategoryID', $Discussion))->Put();
$Category = CategoryModel::Categories(GetValue('CategoryID', $Discussion));
if ($Category) {
CategoryModel::SetCache($Category['CategoryID'], array('CountDiscussions' => $Category['CountDiscussions'] + 1, 'LastDiscussionID' => GetValue('DiscussionID', $Discussion), 'LastCommentID' => NULL, 'LastDateInserted' => GetValue('DateInserted', $Discussion), 'LastTitle' => Gdn_Format::Text(GetValue('Name', $Discussion, T('No Title'))), 'LastUserID' => GetValue('InsertUserID', $Discussion), 'LastDiscussionUserID' => GetValue('InsertUserID', $Discussion), 'LastUrl' => DiscussionUrl($Discussion, FALSE, '//') . '#latest'));
}
}
示例14: ConfirmDiscussionMoves
/**
* Form to ask for the destination of the move, confirmation and permission check.
*/
public function ConfirmDiscussionMoves($DiscussionID = NULL)
{
$Session = Gdn::Session();
$this->Form = new Gdn_Form();
$DiscussionModel = new DiscussionModel();
$this->Title(T('Confirm'));
if ($DiscussionID) {
$CheckedDiscussions = (array) $DiscussionID;
$ClearSelection = FALSE;
} else {
$CheckedDiscussions = Gdn::UserModel()->GetAttribute($Session->User->UserID, 'CheckedDiscussions', array());
if (!is_array($CheckedDiscussions)) {
$CheckedDiscussions = array();
}
$ClearSelection = TRUE;
}
$DiscussionIDs = $CheckedDiscussions;
$CountCheckedDiscussions = count($DiscussionIDs);
$this->SetData('CountCheckedDiscussions', $CountCheckedDiscussions);
// Check for edit permissions on each discussion
$AllowedDiscussions = array();
$DiscussionData = $DiscussionModel->SQL->Select('DiscussionID, Name, DateLastComment, CategoryID')->From('Discussion')->WhereIn('DiscussionID', $DiscussionIDs)->Get();
$DiscussionData = Gdn_DataSet::Index($DiscussionData->ResultArray(), array('DiscussionID'));
foreach ($DiscussionData as $DiscussionID => $Discussion) {
$Category = CategoryModel::Categories($Discussion['CategoryID']);
if ($Category && $Category['PermsDiscussionsEdit']) {
$AllowedDiscussions[] = $DiscussionID;
}
}
$this->SetData('CountAllowed', count($AllowedDiscussions));
$CountNotAllowed = $CountCheckedDiscussions - count($AllowedDiscussions);
$this->SetData('CountNotAllowed', $CountNotAllowed);
if ($this->Form->AuthenticatedPostBack()) {
// Retrieve the category id
$CategoryID = $this->Form->GetFormValue('CategoryID');
$Category = CategoryModel::Categories($CategoryID);
$RedirectLink = $this->Form->GetFormValue('RedirectLink');
// User must have add permission on the target category
if (!$Category['PermsDiscussionsAdd']) {
throw ForbiddenException('@' . T('You do not have permission to add discussions to this category.'));
}
// Iterate and move.
foreach ($AllowedDiscussions as $DiscussionID) {
// Create the shadow redirect.
if ($RedirectLink) {
$Discussion = GetValue($DiscussionID, $DiscussionData);
$DiscussionModel->DefineSchema();
$MaxNameLength = GetValue('Length', $DiscussionModel->Schema->GetField('Name'));
$RedirectDiscussion = array('Name' => SliceString(sprintf(T('Moved: %s'), $Discussion['Name']), $MaxNameLength), 'DateInserted' => $Discussion['DateLastComment'], 'Type' => 'redirect', 'CategoryID' => $Discussion['CategoryID'], 'Body' => FormatString(T('This discussion has been <a href="{url,html}">moved</a>.'), array('url' => DiscussionUrl($Discussion))), 'Format' => 'Html', 'Closed' => TRUE);
$RedirectID = $DiscussionModel->Save($RedirectDiscussion);
if (!$RedirectID) {
$this->Form->SetValidationResults($DiscussionModel->ValidationResults());
break;
}
}
$DiscussionModel->SetField($DiscussionID, 'CategoryID', $CategoryID);
}
// Clear selections.
if ($ClearSelection) {
Gdn::UserModel()->SaveAttribute($Session->UserID, 'CheckedDiscussions', FALSE);
ModerationController::InformCheckedDiscussions($this);
}
if ($this->Form->ErrorCount() == 0) {
$this->JsonTarget('', '', 'Refresh');
}
}
$this->Render();
}
示例15: Save2
/**
* Insert or update meta data about the comment.
*
* Updates unread comment totals, bookmarks, and activity. Sends notifications.
*
* @since 2.0.0
* @access public
*
* @param array $CommentID Unique ID for this comment.
* @param int $Insert Used as a boolean for whether this is a new comment.
* @param bool $CheckExisting Not used.
* @param bool $IncUser Whether or not to just increment the user's comment count rather than recalculate it.
*/
public function Save2($CommentID, $Insert, $CheckExisting = TRUE, $IncUser = FALSE)
{
$Session = Gdn::Session();
$UserModel = Gdn::UserModel();
// Load comment data
$Fields = $this->GetID($CommentID, DATASET_TYPE_ARRAY);
// Clear any session stashes related to this discussion
$DiscussionModel = new DiscussionModel();
$DiscussionID = GetValue('DiscussionID', $Fields);
$Discussion = $DiscussionModel->GetID($DiscussionID);
$Session->Stash('CommentForForeignID_' . GetValue('ForeignID', $Discussion));
// Make a quick check so that only the user making the comment can make the notification.
// This check may be used in the future so should not be depended on later in the method.
if ($Fields['InsertUserID'] != $Session->UserID) {
return;
}
// Update the discussion author's CountUnreadDiscussions (ie.
// the number of discussions created by the user that s/he has
// unread messages in) if this comment was not added by the
// discussion author.
$this->UpdateUser($Session->UserID, $IncUser && $Insert);
if ($Insert) {
// UPDATE COUNT AND LAST COMMENT ON CATEGORY TABLE
if ($Discussion->CategoryID > 0) {
$CountComments = $this->SQL->Select('CountComments', 'sum', 'CountComments')->From('Discussion')->Where('CategoryID', $Discussion->CategoryID)->Get()->FirstRow()->CountComments;
$CategoryModel = new CategoryModel();
$CategoryModel->SetField($Discussion->CategoryID, array('LastDiscussionID' => $DiscussionID, 'LastCommentID' => $CommentID, 'CountComments' => $CountComments, 'LastDateInserted' => $Fields['DateInserted']));
// Update the cache.
if ($DiscussionID && Gdn::Cache()->ActiveEnabled()) {
$CategoryCache = array('LastTitle' => $Discussion->Name, 'LastUserID' => $Fields['InsertUserID'], 'LastUrl' => DiscussionUrl($Discussion) . '#latest');
CategoryModel::SetCache($Discussion->CategoryID, $CategoryCache);
}
}
// Prepare the notification queue.
$ActivityModel = new ActivityModel();
$HeadlineFormat = T('HeadlineFormat.Comment', '{ActivityUserID,user} commented on <a href="{Url,html}">{Data.Name,text}</a>');
$Category = CategoryModel::Categories($Discussion->CategoryID);
$Activity = array('ActivityType' => 'Comment', 'ActivityUserID' => $Fields['InsertUserID'], 'HeadlineFormat' => $HeadlineFormat, 'RecordType' => 'Comment', 'RecordID' => $CommentID, 'Route' => "/discussion/comment/{$CommentID}#Comment_{$CommentID}", 'Data' => array('Name' => $Discussion->Name, 'Category' => GetValue('Name', $Category)));
// Allow simple fulltext notifications
if (C('Vanilla.Activity.ShowCommentBody', FALSE)) {
$Activity['Story'] = GetValue('Body', $Fields);
}
// Notify users who have bookmarked the discussion.
$BookmarkData = $DiscussionModel->GetBookmarkUsers($DiscussionID);
foreach ($BookmarkData->Result() as $Bookmark) {
// Check user can still see the discussion.
if (!$UserModel->GetCategoryViewPermission($Bookmark->UserID, $Discussion->CategoryID)) {
continue;
}
$Activity['NotifyUserID'] = $Bookmark->UserID;
$ActivityModel->Queue($Activity, 'BookmarkComment', array('CheckRecord' => TRUE));
}
// Record user-comment activity.
if ($Discussion != FALSE) {
$Activity['NotifyUserID'] = GetValue('InsertUserID', $Discussion);
$ActivityModel->Queue($Activity, 'DiscussionComment');
}
// Record advanced notifications.
if ($Discussion !== FALSE) {
$this->RecordAdvancedNotications($ActivityModel, $Activity, $Discussion);
}
// Notify any users who were mentioned in the comment.
$Usernames = GetMentions($Fields['Body']);
$NotifiedUsers = array();
foreach ($Usernames as $i => $Username) {
$User = $UserModel->GetByUsername($Username);
if (!$User) {
unset($Usernames[$i]);
continue;
}
// Check user can still see the discussion.
if (!$UserModel->GetCategoryViewPermission($User->UserID, $Discussion->CategoryID)) {
continue;
}
$HeadlineFormatBak = $Activity['HeadlineFormat'];
$Activity['HeadlineFormat'] = T('HeadlineFormat.Mention', '{ActivityUserID,user} mentioned you in <a href="{Url,html}">{Data.Name,text}</a>');
$Activity['NotifyUserID'] = $User->UserID;
$ActivityModel->Queue($Activity, 'Mention');
$Activity['HeadlineFormat'] = $HeadlineFormatBak;
}
// Throw an event for users to add their own events.
$this->EventArguments['Comment'] = $Fields;
$this->EventArguments['Discussion'] = $Discussion;
$this->EventArguments['NotifiedUsers'] = array_keys(ActivityModel::$Queue);
$this->EventArguments['MentionedUsers'] = $Usernames;
$this->EventArguments['ActivityModel'] = $ActivityModel;
$this->FireEvent('BeforeNotification');
//.........这里部分代码省略.........