Example #1
0
    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;
    echo elgg_view("input/hidden", array("name" => "tags[" . $encoded_tag . "]", "value" => "0"));
    echo "</td>";
    foreach ($NOTIFICATION_HANDLERS as $method => $foo) {
        $checked = tag_tools_check_user_tag_notification_method($encoded_tag, $method, $user->getGUID());
        echo "<td class='center'>";
        echo elgg_view("input/checkbox", array("name" => "tags[" . $encoded_tag . "][]", "checked" => $checked, "value" => $method, "default" => false));
        echo "</td>";
    }
    echo "<td class='center'>";
    echo elgg_view("output/url", array("text" => elgg_view_icon("delete"), "href" => "action/tag_tools/follow_tag?tag=" . urlencode($encoded_tag), "class" => "tag-tools-unfollow-tag", "is_action" => true));
    echo "</td>";
    echo "</tr>";
}
echo "</tbody>";
echo "</table>";
echo "<div class='elgg-foot'>";
echo elgg_view("input/hidden", array("name" => "user_guid", "value" => $user->getGUID()));
echo elgg_view("input/submit", array("value" => elgg_echo("save"), "class" => "elgg-button-submit mtl"));
echo "</div>";
Example #2
0
 /**
  * Make the tag tools notification
  *
  * @param string                           $hook         the name of the hook
  * @param string                           $type         the type of the hook
  * @param \Elgg\Notifications\Notification $return_value current return value
  * @param array                            $params       supplied params
  *
  * @return void|\Elgg\Notifications\Notification
  */
 public static function prepareMessage($hook, $type, $return_value, $params)
 {
     if (!self::validateNotificationEvent($params)) {
         return;
     }
     $recipient = $return_value->getRecipient();
     $method = elgg_extract('method', $params);
     $relationship = elgg_extract('object', $params);
     $language = elgg_extract('language', $params);
     $entity = get_entity($relationship->guid_two);
     $sending_tags = tag_tools_get_unsent_tags($entity);
     $tag = [];
     foreach ($sending_tags as $sending_tag) {
         if (!tag_tools_is_user_following_tag($sending_tag, $recipient->getGUID())) {
             // user is not following this tag
             continue;
         }
         if (!tag_tools_check_user_tag_notification_method($sending_tag, $method, $recipient->getGUID())) {
             continue;
         }
         $tag[] = $sending_tag;
     }
     $tag = implode(', ', $tag);
     // is this a new entity of an update on an existing
     $time_diff = (int) $entity->time_updated - (int) $entity->time_created;
     if ($time_diff < 60) {
         // new entity
         $return_value->subject = elgg_echo('tag_tools:notification:follow:subject', [$tag], $language);
         $return_value->summary = elgg_echo('tag_tools:notification:follow:summary', [$tag], $language);
         $return_value->body = elgg_echo('tag_tools:notification:follow:message', [$tag, $entity->getURL()], $language);
     } else {
         // updated entity
         $return_value->subject = elgg_echo('tag_tools:notification:follow:update:subject', [$tag], $language);
         $return_value->summary = elgg_echo('tag_tools:notification:follow:update:summary', [$tag], $language);
         $return_value->body = elgg_echo('tag_tools:notification:follow:update:message', [$tag, $entity->getURL()], $language);
     }
     return $return_value;
 }