Codice PHP:
} if (count($rows) > 0) { $last_a_id = intval($rows[0]['id']); $activities = array(); foreach ($rows as $row) { $activities[] = $row; } (int)$i = 0; (int)$activity_profile_post = 0; (int)$activity_group_post = 0; (int)$activity_group_discussion = 0; (int)$activity_group_events = 0; (int)$activity_group_members = 0; (int)$activity_group_anno = 0; foreach ( $activities as $a) { /*COUNT PROFILE POSTS*/ if ($a['target'] == intval($userId) && ($a['app'] == 'profile') && $a['actor'] != intval($userId)) { $activity_profile_post++; } /*COUNT MY GROUP POSTS*/ if ($a['app'] == 'groups.wall' && $a['actor'] != intval($userId)) { if (in_array($a['groupid'], $group_ids)) { $activity_group_post++; } } /*COUNT MY GROUP DISCUSSIONS*/ if (($a['app'] == 'groups.discussion' || $a['app'] == 'groups.discussion.reply') && $a['actor'] != intval($userId)) { if (in_array($a['groupid'], $group_ids)) { $activity_group_discussion++; } } /*COUNT NEW EVENTS IN MY GROUP*/ if ($a['app'] == 'events' && $a['actor'] != intval($userId)) { if (in_array($a['groupid'], $group_ids)) { $activity_group_events++; } } /*COUNT JOINED USERS*/ if ($a['app'] == 'groups' && $a['actor'] != intval($userId)) { if (in_array($a['cid'], $group_ids)) { $activity_group_members++; } } /*COUNT NEW ANNO*/ if ($a['app'] == 'group.bulletin' && $a['actor'] != intval($userId)) { if (in_array($a['groupid'], $group_ids)) { $activity_group_anno++; } } $i++; } $notifications_arr = array('a_last_id' => $last_a_id, 'profile_posts' => $activity_profile_post, 'group_posts' => $activity_group_post, 'group_discussions' => $activity_group_discussion, 'group_events' => $activity_group_events, 'group_joins' => $activity_group_members,'group_anno' => $activity_group_anno); } else { $notifications_arr = array('a_last_id' => $a); } return $notifications_arr; } function notifications_get($a,$b,$c,$d) { $db =& JFactory::getDBO(); $user = JFactory::getUser(); $userId = $user->get('id'); /*GET MY GROUPS IDS*/ $sql = 'SELECT `groupid` FROM '.$db->nameQuote('#__community_groups_members').' WHERE `memberid` = '.intval($userId).' AND `approved` = 1'; $db->setQuery($sql); $group_ids = $db->loadResultArray(); /*GET MY CONTENT IDS*/ $sql = 'SELECT `id` FROM '.$db->nameQuote('#__community_activities').' WHERE `actor` = '.intval($userId); $db->setQuery($sql); $content_ids = $db->loadResultArray(); /*GET MY PHOTO IDS*/ $sql = 'SELECT `id` FROM '.$db->nameQuote('#__community_photos').' WHERE `creator` = '.intval($userId); $db->setQuery($sql); $photos_ids = $db->loadResultArray(); /*GET MY ALBUM IDS*/ $sql = 'SELECT `id` FROM '.$db->nameQuote('#__community_photos_albums').' WHERE `creator` = '.intval($userId); $db->setQuery($sql); $album_ids = $db->loadResultArray();
Queste sono le varie notifiche ...