Skip to content
Open
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
7 changes: 2 additions & 5 deletions CRM/Smsinbox/Utils.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,10 @@ class CRM_Smsinbox_Utils {
* If there are unread SMS messages, this displays a message.
*/
public static function checkForUnreadMessageStatus() {

$unreadMessageCount = CRM_Smsinbox_SmsInbound::count_unread();

if (0 == $unreadMessageCount) {
return;
return NULL;
}
elseif (1 == $unreadMessageCount) {
$message = 'You have one unread SMS message. Click <a href="/civicrm/smsinbox">here</a> to read it.';
Expand All @@ -23,9 +22,7 @@ public static function checkForUnreadMessageStatus() {
$message = 'You have %1 unread SMS messages. Click <a href="/civicrm/smsinbox">here</a> to read them.';
}

CRM_Core_Session::setStatus(E::ts($message, array(
1 => $unreadMessageCount,
)), '', 'info');
return E::ts($message, [1 => $unreadMessageCount]);
}

public static function getDisplayNameWithFallback($contactId) {
Expand Down
33 changes: 28 additions & 5 deletions smsinbox.php
Original file line number Diff line number Diff line change
Expand Up @@ -180,12 +180,35 @@ function smsinbox_civicrm_navigationMenu(&$params) {
*
* @param type $page
*/
function smsinbox_civicrm_pageRun(&$page) {
if (get_class($page) == 'CRM_Smsinbox_Page_SmsInbox') {
function smsinbox_civicrm_check(&$messages, $statusNames, $includeDisabled) {
// Early return if $statusNames doesn't call for our check
if ($statusNames && !in_array('smsinbox', $statusNames)) {
return;
}

CRM_Smsinbox_Utils::checkForUnreadMessageStatus();
if (!$includeDisabled) {
$disabled = \Civi\Api4\StatusPreference::get()
->setCheckPermissions(FALSE)
->addWhere('is_active', '=', FALSE)
->addWhere('domain_id', '=', 'current_domain')
->addWhere('name', '=', 'smsinbox')
->execute()->count();
if ($disabled) {
return;
}
}
$messageText = CRM_Smsinbox_Utils::checkForUnreadMessageStatus();

if ($messageText) {
$message = new CRM_Utils_Check_Message(
'smsinbox',
$messageText,
E::ts('Unread SMSInbox messages'),
\Psr\Log\LogLevel::WARNING,
'fa-flag'
);
$message->addHelp(E::ts('You can read these messages by clicking the SMSInbox menu item from the Mailings menu.'));
$messages[] = $message;
}
}

/**
Expand All @@ -199,4 +222,4 @@ function smsinbox_civicrm_buildForm($formName, &$form) {
return;
}
CRM_Smsinbox_Utils::checkForUnreadMessageStatus();
}
}