/** * Add a menu item to the filter menu * * @param string $hook the name of the hook * @param string $type the type of the hook * @param \ElggMenuItem[] $return_value current return value * @param mixed $params supplied params * * @return void|\ElggMenuItem[] */ public static function registerActivityTab($hook, $type, $return_value, $params) { if (!elgg_is_logged_in() || !elgg_in_context('activity')) { return; } $tags = tag_tools_get_user_following_tags(); if (empty($tags)) { return; } $selected = false; if (strpos(current_page_url(), elgg_normalize_url('activity/tags')) === 0) { $selected = true; } $return_value[] = \ElggMenuItem::factory(['name' => 'tags', 'text' => elgg_echo('tags'), 'href' => 'activity/tags', 'selected' => $selected, 'priority' => 9999]); return $return_value; }
<?php $user = elgg_extract("entity", $vars, elgg_get_page_owner_entity()); if (empty($user) || !elgg_instanceof($user, "user")) { return; } echo elgg_view_module("info", "", elgg_echo("tag_tools:notifications:description")); $NOTIFICATION_HANDLERS = _elgg_services()->notifications->getMethodsAsDeprecatedGlobal(); $tags = tag_tools_get_user_following_tags($user->getGUID()); if (empty($tags)) { echo elgg_view('output/longtext', array('value' => elgg_echo("tag_tools:notifications:empty"))); return; } elgg_require_js("tag_tools/notifications"); echo "<table class='elgg-table-alt'>"; // header with notification methods and delete echo "<thead>"; echo "<tr><th> </th>"; foreach ($NOTIFICATION_HANDLERS as $method => $foo) { echo "<th class='center'>" . elgg_echo('notification:method:' . $method) . "</th>"; } echo "<th class='center'>" . elgg_echo("delete") . "</th>"; echo "</tr>"; echo "</thead>"; echo "<tbody>"; // all tags foreach ($tags as $tag) { $encoded_tag = htmlspecialchars($tag, ENT_QUOTES, "UTF-8", false); echo "<tr>"; echo "<td>"; echo $encoded_tag;
<?php /** * activity stream based on tags */ elgg_gatekeeper(); elgg_set_page_owner_guid(elgg_get_logged_in_user_guid()); $tags = tag_tools_get_user_following_tags(); if (empty($tags)) { forward('activity'); } $name_ids = []; foreach ($tags as $tag) { $name_ids[] = elgg_get_metastring_id($tag); } $options = []; $title = elgg_echo('tag_tools:activity:tags'); $type = preg_replace('[\\W]', '', get_input('type', 'all')); $subtype = preg_replace('[\\W]', '', get_input('subtype', '')); if ($subtype) { $selector = "type={$type}&subtype={$subtype}"; } else { $selector = "type={$type}"; } if ($type != 'all') { $options['type'] = $type; if ($subtype) { $options['subtype'] = $subtype; } } $dbprefix = elgg_get_config('dbprefix');
/** * Add a filter tab on the activity page * * @param string $hook the name of the hook * @param string $type the type of the hook * @param ElggMenuItem[] $return_value the current return value * @param array $params supplied params * * @return ElggMenuItem[] */ function tag_tools_activity_filter_menu_hook_handler($hook, $type, $return_value, $params) { if (!elgg_in_context("activity") || !elgg_is_logged_in()) { return $return_value; } $tags = tag_tools_get_user_following_tags(); if (empty($tags)) { return $return_value; } $selected = false; if (strpos(current_page_url(), elgg_normalize_url("activity/tags")) === 0) { $selected = true; } $item = ElggMenuItem::factory(array("name" => "tags", "text" => elgg_echo("tags"), "href" => "activity/tags", "selected" => $selected, "priority" => 9999)); $return_value[] = $item; return $return_value; }
/** * Add or remove a tag from the follow list of a user * * @param string $tag the tag to (un)follow * @param int $user_guid the user to save the setting for * @param bool $track add/remove the tag * * @return void */ function tag_tools_toggle_following_tag($tag, $user_guid = 0, $track = null) { if (empty($tag)) { return; } $user_guid = sanitise_int($user_guid, false); if (empty($user_guid)) { $user_guid = elgg_get_logged_in_user_guid(); } $user = get_user($user_guid); if (empty($user)) { return; } if ($track === null) { $track = !tag_tools_is_user_following_tag($tag, $user_guid); } // remove the tag from the follow list $ia = elgg_set_ignore_access(true); elgg_delete_annotations(['guid' => $user_guid, 'limit' => false, 'annotation_name' => 'follow_tag', 'annotation_value' => $tag]); tag_tools_remove_tag_from_notification_settings($tag, $user_guid); elgg_set_ignore_access($ia); // did the user want to follow the tag if ($track) { $user->annotate('follow_tag', $tag, ACCESS_PUBLIC); } // reset cache tag_tools_get_user_following_tags($user_guid, true); }