function hook_get_alert_count_by_type
Search API
This will allow modules to add to the "count" for alerts, that generally would trigger a notification badge on the bell at the top-right of the screen.
Below is a functional example from the alerts module.
Returns an array containing the calculations for read, unread, and total.
See also
alerts_get_alert_count_by_type()
3 functions implement hook_get_alert_count_by_type()
Note: this list is generated by pattern matching, so it may include some functions that are not actually implementations of this hook.
- alerts_get_alert_count_by_type in modules/
alerts/ alerts.module - Implements hook_get_count_for_alert_type
- engagements_get_alert_count_by_type in modules/
engagements/ engagements.module - Implements hook_get_count_for_alert_type
- fp_get_alert_count_by_type in includes/
misc.inc - Returns back the total, read, and unread numbers previously calculated to see if we need to place a badge next to the bell icon at the top of the screen. If unset, we will call the recalculate function.
File
- includes/
hook.api.php, line 33 - Lists all available hooks within FlightPath's core code.
Code
function hook_get_alert_count_by_type($account = NULL) {
global $user;
if ($account === NULL) {
$account = $user;
}
$rtn = array();
$types = array('alert', 'activity_record');
// We need to know this user's list of advisees.
$advisees = advise_get_advisees($account->cwid);
$advisee_line = " AND b.field__student_id IN (" . join(",", $advisees) . ") ";
foreach ($types as $type) {
$total_count = db_result(db_query("SELECT COUNT(*) as mycount
FROM content__$type b,
content n
WHERE n.type = ?
AND n.published = 1
AND n.delete_flag = 0
AND n.cid = b.cid
AND b.vid = n.vid
$advisee_line ", array($type)));
$read_count = db_result(db_query("SELECT COUNT(*) as mycount
FROM content_last_access a,
content__$type b,
content n
WHERE n.type = ?
AND n.published = 1
AND n.delete_flag = 0
AND n.cid = a.cid
AND n.cid = b.cid
AND b.vid = n.vid
$advisee_line
AND a.user_id = ?", array($type, $account->id)));
$rtn [$type]['total'] = intval($total_count);
$rtn [$type]['read'] = intval($read_count);
$rtn [$type]['unread'] = $total_count - $read_count;
} // foreach types
return $rtn;
}