function oa_notifications_render_view in Open Atrium Notifications 7.2
Render the read only version of the notifications listing.
Parameters
object $node: The node being viewed/edited
Return value
A render array of the notification configuration
5 calls to oa_notifications_render_view()
- oa_notifications_ajax_callback in ./
oa_notifications.module - AJAX callback saves the quick reply notification configuration.
- oa_notifications_build_list_form in ./
oa_notifications.module - oa_notifications_form_fields_override_ajax in ./
oa_notifications.module - AJAX callback for oa_notifications_form_fields override checkbox.
- oa_notifications_remove_callback in ./
oa_notifications.module - Remove notification callback.
- oa_notification_render_details in ./
oa_notifications.module
File
- ./
oa_notifications.module, line 1183
Code
function oa_notifications_render_view($node, $editmode = FALSE, $notifications = NULL, $show_detail = FALSE) {
$nid = !empty($node->nid) ? $node->nid : 0;
$space_id = !empty($nid) ? oa_core_get_group_from_node($node) : oa_core_get_space_context();
_oa_notifications_session_detail($show_detail);
$render = array(
'#theme' => "oa_notifications_view",
'#node' => $node,
'#prefix' => '<div id="notify-data">',
'#suffix' => '</div>',
);
if (!isset($notifications)) {
$notifications = oa_notifications_load_multiple($node);
}
$remove_icon = '<i class="fa fa-times"></i>';
// Turn off ajax when on node/add form (nid = 0).
// This will be handled in javascript instead.
$remove_class = $nid ? 'use-ajax' : '';
if (array_key_exists('group', $notifications)) {
$groups = node_load_multiple(array_keys($notifications['group']));
foreach ($groups as $group) {
$name = $group->title;
$token = array(
'tok' => drupal_get_token('remove_group' . $group->nid),
) + drupal_get_destination();
$remove_link = l($remove_icon, 'oa_notifications/nojs/remove/' . $nid . '/group/' . $group->nid, array(
'attributes' => array(
'class' => $remove_class,
'title' => t('Remove ' . $name),
),
'query' => $token,
'html' => TRUE,
));
$render['#notifications']['group'][] = array(
'name' => $name,
'data' => 'group:' . $group->nid,
'url' => 'node/' . $group->nid,
'remove_link' => $remove_link,
'icon' => $group->type == OA_GROUP_TYPE ? 'fa fa-users' : 'fa fa-sitemap',
'title' => $group->type == OA_GROUP_TYPE ? t('Group: ') . $name : t('Space: ') . $name,
);
if ($show_detail) {
$users = oa_core_get_group_users_for_space($space_id, $group->nid);
foreach ($users as $user) {
$name = oa_core_realname($user);
$render['#notifications']['group'][] = array(
'name' => $name,
'url' => 'user/' . $user->uid,
'picture' => oa_users_picture($user),
'class' => 'oa-notify-detail',
'blocked' => _oa_notification_user_blocked($user, $space_id),
);
}
}
}
}
if (array_key_exists('team', $notifications)) {
$teams = node_load_multiple(array_keys($notifications['team']));
foreach ($teams as $team) {
$name = $team->title;
$token = array(
'tok' => drupal_get_token('remove_user' . $team->nid),
) + drupal_get_destination();
$remove_link = l($remove_icon, 'oa_notifications/nojs/remove/' . $nid . '/team/' . $team->nid, array(
'attributes' => array(
'class' => $remove_class,
'title' => t('Remove ' . $name),
),
'query' => $token,
'html' => TRUE,
));
$render['#notifications']['team'][] = array(
'name' => $name,
'data' => 'team:' . $team->nid,
'url' => 'node/' . $team->nid,
'remove_link' => $remove_link,
'icon' => 'fa fa-user-plus',
'title' => t('Team: ') . $name,
);
if ($show_detail) {
$users = oa_teams_get_team_members($team->nid);
$users = user_load_multiple(array_keys($users));
foreach ($users as $user) {
$name = oa_core_realname($user);
$render['#notifications']['team'][] = array(
'name' => $name,
'url' => 'user/' . $user->uid,
'picture' => oa_users_picture($user),
'class' => 'oa-notify-detail',
'blocked' => _oa_notification_user_blocked($user, $space_id),
);
}
}
}
}
if (array_key_exists('user', $notifications)) {
$users = user_load_multiple(array_keys($notifications['user']));
foreach ($users as $user) {
$name = oa_core_realname($user);
$token = array(
'tok' => drupal_get_token('remove_user' . $user->uid),
) + drupal_get_destination();
$remove_link = l($remove_icon, 'oa_notifications/nojs/remove/' . $nid . '/user/' . $user->uid, array(
'attributes' => array(
'class' => $remove_class,
'title' => t('Remove ' . $name),
),
'query' => $token,
'html' => TRUE,
));
$render['#notifications']['user'][] = array(
'name' => $name,
'data' => 'user:' . $user->uid,
'url' => 'user/' . $user->uid,
'picture' => oa_users_picture($user),
'access' => $nid ? node_access('view', $node, $user) : TRUE,
'blocked' => _oa_notification_user_blocked($user, $space_id),
'remove_link' => $remove_link,
'title' => t('Member: ') . $name,
);
}
}
if (!empty($groups) || !empty($teams)) {
$render['#prefix'] = '<div id="notify-data" class="has-details">';
}
// Attach the bootstrap tooltip in case there is an access denied user.
drupal_add_js('jQuery(document).ready(function () {
jQuery("span.label-important").tooltip();
});', 'inline');
return $render;
}