Skip to content

Issues-506: Removed excerpt and fixed styles for notification popup #516

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 1, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
<?php
/**
* Creates and sends notifications to user.
*
* @copyright 2009-2019 Vanilla Forums Inc.
* @license GPL-2.0-only
* @package Dashboard
* @since 2.0
*/

use Vanilla\Formatting\Formats\HtmlFormat;

/**
* Handle /notifications endpoint.
*/
class NotificationsController extends Gdn_Controller {

/**
* CSS, JS and module includes.
*/
public function initialize() {
$this->Head = new HeadModule($this);
$this->addJsFile('jquery.js');
$this->addJsFile('jquery.form.js');
$this->addJsFile('jquery.popup.js');
$this->addJsFile('jquery.gardenhandleajaxform.js');
$this->addJsFile('global.js');
$this->addCssFile('style.css');
$this->addCssFile('vanillicon.css', 'static');
$this->addModule('GuestModule');
parent::initialize();
}

/**
* Adds inform messages to response for inclusion in pages dynamically.
*
* @since 2.0.18
* @access public
*/
public function inform() {
$this->deliveryType(DELIVERY_TYPE_BOOL);
$this->deliveryMethod(DELIVERY_METHOD_JSON);

// Retrieve all notifications and inform them.
NotificationsController::informNotifications($this);
$this->fireEvent('BeforeInformNotifications');

$this->render();
}

/**
* Grabs all new notifications and adds them to the sender's inform queue.
*
* This method gets called by dashboard's hooks file to display new
* notifications on every pageload.
*
* @since 2.0.18
* @access public
*
* @param Gdn_Controller $sender The object calling this method.
*/
public static function informNotifications($sender) {
$session = Gdn::session();
if (!$session->isValid()) {
return;
}

$activityModel = new ActivityModel();
// Get five pending notifications.
$where = [
'NotifyUserID' => Gdn::session()->UserID,
'Notified' => ActivityModel::SENT_PENDING];

// If we're in the middle of a visit only get very recent notifications.
$where['DateUpdated >'] = Gdn_Format::toDateTime(strtotime('-5 minutes'));

$activities = $activityModel->getWhere($where, '', '', 5, 0)->resultArray();

$activityIDs = array_column($activities, 'ActivityID');
$activityModel->setNotified($activityIDs);

$sender->EventArguments['Activities'] = &$activities;
$sender->fireEvent('InformNotifications');

foreach ($activities as $activity) {
if ($activity['Photo']) {
$userPhoto = anchor(
img($activity['Photo'], ['class' => 'ProfilePhotoMedium']),
$activity['Url'],
'Icon'
);
} else {
$userPhoto = '';
}

$excerpt = '';
$story = $activity['Story'] ?? null;
$format = $activity['Format'] ?? HtmlFormat::FORMAT_KEY;
$excerpt = htmlspecialchars($story ? Gdn::formatService()->renderExcerpt($story, $format) : $excerpt);
$activityClass = ' Activity-'.$activity['ActivityType'];

// FIX: https://github.com/topcoder-platform/forums/issues/506
$sender->informMessage(
$userPhoto
.wrap($activity['Headline'], 'div', ['class' => 'Title'])
//.wrap($excerpt, 'div', ['class' => 'Excerpt'])
,'Dismissable AutoDismiss'.$activityClass.($userPhoto == '' ? '' : ' HasIcon')
);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ function writeListItem($category, $depth) {
t('%s discussions')
), bigPlural(val('CountAllDiscussions', $category), '%s discussion')) ?>
</span>
<span class="MiddleDot">&#183;</span>
<span class="MItem MiddleDot">&#183;</span>
<span class="MItem CommentCount">
<?php echo sprintf(
pluralTranslate(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ function writeDiscussion($discussion, $sender, $session) {
'%s comment html', '%s comments html', t('%s comment'), t('%s comments')),
bigPlural($discussion->CountComments, '%s comment'));
?></span>
<span class="MiddleDot">&#183;</span>
<span class="MItem MiddleDot">&#183;</span>
<span class="MItem MCount ViewCount"><?php
printf(pluralTranslate($discussion->CountViews,
'%s view html', '%s views html', t('%s view'), t('%s views')),
Expand Down
Loading