function follow_tags_get_activity_follow_tags($options) { $dbprefix = elgg_get_config("dbprefix"); $tags = elgg_get_metadata(array(follow_tags_get_tag_guid(elgg_get_logged_in_user_guid()), 'tags')); $cnt = 0; //Count the followTags and Create string for the SQL-query switch (count($tags)) { case 0: break; case 1: $tagid = $tags['value_id']; $value_ids = "value_id = {$tagid}"; break; default: foreach ($tags as $tag) { $tagid = $tag['value_id']; $cnt++; if ($cnt != count($tags)) { $value_ids .= "value_id = {$tagid}"; $value_ids .= " OR "; } else { $value_ids .= "value_id = {$tagid}"; } } break; } //Check if the user have any FollowTags $user = elgg_get_logged_in_user_entity(); $user = $user->username; if (count($tags) != 0) { $sql_where = "object_guid IN (SELECT entity_guid FROM {$dbprefix}metadata WHERE {$value_ids}) AND action_type = 'create'"; $options['wheres'] = array($sql_where); $activity = elgg_list_river($options); } return $activity; }
<?php /** * Save / Change Action **/ //Get Tags from Taginput $follow_tag_input = get_input('followtags'); //Save the FollowTags in the TagObj if (!follow_tags_save_follow_tags($follow_tag_input, follow_tags_get_tag_guid(elgg_get_logged_in_user_guid()), $notify_input)) { register_error(elgg_echo("follow_tags:save:error")); } else { system_message(elgg_echo("follow_tags:save:message")); } forward(REFERER);
<?php /** * help/save form body * * * for Elgg 1.8 */ //Get current Tags from logged in User and Notify value $value = follow_tags_get_current_tags(elgg_get_logged_in_user_guid()); $check = follow_tags_get_notification_settings(follow_tags_get_tag_guid(elgg_get_logged_in_user_guid())); //Create Views Elements $save_btn = elgg_view('input/submit', array('value' => elgg_echo('save'), 'class' => 'elgg-button-submit ')); $follow_tags = elgg_view('input/tags', array('name' => 'followtags', 'value' => $value, 'id' => 'follow')); $follow_tags_checkbox = elgg_view('input/checkbox', array('name' => 'notifyfollow', 'checked' => $check)); $strings_title_tag = elgg_echo("follow_tags:settings:title:tags"); $strings_title_notify = elgg_echo("follow_tags:settings:title:notify"); $strings_notify_description = elgg_echo("follow_tags:settings:notify:description"); // Display Elements echo <<<HTML <div class="notification_personal"> <div class="elgg-module elgg-module-info"> \t<div class="elgg-head"> \t\t<h3>{$strings_title_notify}</h3> \t</div> \t<table id="notificationstable" cellspacing="0" width="100%"> \t\t<tr> \t\t\t<td width="50%">{$strings_notify_description}</td> \t\t\t<td><a>{$follow_tags_checkbox}</a></td> \t\t</tr>
<?php /** * Save / Change Action **/ //Get Notification Settings $notify_input = get_input('notifyfollow'); //Save the FollowTags in the TagObj follow_tags_save_notify(follow_tags_get_tag_guid(elgg_get_logged_in_user_guid()), $notify_input); forward(REFERER);