function theme_ffd_fivestar_get_top_users($n_days = 21, $eps = 0.5) { $options = array('annotation_name' => 'fivestar', 'where' => 'n_table.time_created > ' . (time() - 3600 * 24 * $n_days), 'order_by' => 'n_table.time_created desc', 'limit' => 250); $annotations = elgg_get_annotations($options); $top_users = array(); foreach ($annotations as $annotation) { $user = $annotation->getEntity()->getOwnerGuid(); if (!array_key_exists($user, $top_users)) { $top_users[$user] = array(); } $top_users[$user][] = $annotation->value / 100; } $max_scores = 0; foreach ($top_users as $guid => $scores) { if (count($scores) > $max_scores) { $max_scores = count($scores); } } // calculate the average score $top_users = array_map(function ($scores) use($max_scores, $eps) { return $eps * (array_sum($scores) / count($scores)) * ((1 - $eps) * (count($scores) / $max_scores)); }, $top_users); arsort($top_users); $top_users = array_slice($top_users, 0, 10, true); $users = array(); foreach ($top_users as $guid => $score) { $users[] = get_entity($guid); } return $users; }
/** * Check if a invitation code results in a group * * @param string $invite_code the invite code * @param int $group_guid (optional) the group to check * * @return false|ElggGroup */ function group_tools_check_group_email_invitation($invite_code, $group_guid = 0) { if (empty($invite_code)) { return false; } $group_guid = sanitize_int($group_guid, false); // note not using elgg_get_entities_from_annotations // due to performance issues with LIKE wildcard search // prefetch metastring ids for use in lighter joins instead $name_id = elgg_get_metastring_id('email_invitation'); $code_id = elgg_get_metastring_id($invite_code); $sanitized_invite_code = sanitize_string($invite_code); $options = ['limit' => 1, 'wheres' => ["n_table.name_id = {$name_id} AND (n_table.value_id = {$code_id} OR v.string LIKE '{$sanitized_invite_code}|%')"]]; if (!empty($group_guid)) { $options['annotation_owner_guids'] = [$group_guid]; } // find hidden groups $ia = elgg_set_ignore_access(true); $annotations = elgg_get_annotations($options); if (empty($annotations)) { // restore access elgg_set_ignore_access($ia); return false; } $group = $annotations[0]->getEntity(); if ($group instanceof ElggGroup) { // restore access elgg_set_ignore_access($ia); return $group; } // restore access elgg_set_ignore_access($ia); return false; }
/** * Check if a invitation code results in a group * * @param string $invite_code the invite code * @param int $group_guid (optional) the group to check * * @return boolean|ElggGroup a group for the invitation or false */ function group_tools_check_group_email_invitation($invite_code, $group_guid = 0) { $result = false; if (!empty($invite_code)) { // note not using elgg_get_entities_from_annotations // due to performance issues with LIKE wildcard search // prefetch metastring ids for use in lighter joins instead $name_id = add_metastring('email_invitation'); $code_id = add_metastring($invite_code); $sanitized_invite_code = sanitize_string($invite_code); $options = array('limit' => 1, 'wheres' => array("n_table.name_id = {$name_id} AND (n_table.value_id = {$code_id} OR v.string LIKE '{$sanitized_invite_code}|%')")); if (!empty($group_guid)) { $options["annotation_owner_guids"] = array($group_guid); } $annotations = elgg_get_annotations($options); if (!$annotations) { return $result; } // find hidden groups $ia = elgg_set_ignore_access(true); $group = $annotations[0]->getEntity(); if ($group) { $result = $group; } // restore access elgg_set_ignore_access($ia); } return $result; }
/** * Get all the tags a user is following * * @param int $user_guid the user to get the tags for (default: current user) * @param bool $reset_cache reset the internal cache * * @return bool|array */ function tag_tools_get_user_following_tags($user_guid = 0, $reset_cache = false) { static $cache; if (!isset($cache)) { $cache = []; } $user_guid = sanitise_int($user_guid, false); if (empty($user_guid)) { $user_guid = elgg_get_logged_in_user_guid(); } if (empty($user_guid)) { return false; } if (!isset($cache[$user_guid]) || $reset_cache) { $cache[$user_guid] = []; $ia = elgg_set_ignore_access(true); $annotations = elgg_get_annotations(['guid' => $user_guid, 'annotation_name' => 'follow_tag', 'limit' => false]); elgg_set_ignore_access($ia); if (!empty($annotations)) { foreach ($annotations as $annotation) { $cache[$user_guid][] = $annotation->value; } } } return $cache[$user_guid]; }
/** * Get all the tags a user is following * * @param int $user_guid the user to get the tags for (default: current user) * @param bool $reset_cache reset the internal cache * * @return bool|array */ function tag_tools_get_user_following_tags($user_guid = 0, $reset_cache = false) { static $cache; if (!isset($cache)) { $cache = array(); } $user_guid = sanitise_int($user_guid, false); if (empty($user_guid)) { $user_guid = elgg_get_logged_in_user_guid(); } if (empty($user_guid)) { return false; } if (!isset($cache[$user_guid]) || $reset_cache) { $cache[$user_guid] = array(); $options = array("guid" => $user_guid, "annotation_name" => "follow_tag", "limit" => false); $ia = elgg_set_ignore_access(true); $annotations = elgg_get_annotations($options); elgg_set_ignore_access($ia); if (!empty($annotations)) { foreach ($annotations as $annotation) { $cache[$user_guid][] = $annotation->value; } } } return $cache[$user_guid]; }
/** * Check if the user is checked in at the place * * @param integer $user_guid GUID of the user to check * @return integer Count of checkins within checkin duration limit */ public function isCheckedIn($user_guid = 0) { if (!$user_guid) { $user_guid = elgg_get_logged_in_user_guid(); } return elgg_get_annotations(array('guids' => $this->guid, 'annotation_owner_guids' => sanitize_int($user_guid), 'annotation_names' => 'checkin', 'annotation_created_time_lower' => time() - $this->getCheckinDuration(), 'count' => true)); }
function rijkshuisstijl_get_votes(ElggObject $entity) { $result = elgg_get_annotations(array('guid' => $entity->guid, 'annotation_name' => 'vote', 'annotation_calculation' => 'sum', 'limit' => false)); if ($result) { return (int) $result; } return 0; }
/** * has the user already marked the entity as spam? */ function tu_spam_report_is_marked($object, $user) { if (!elgg_instanceof($object) || !elgg_instanceof($user, 'user')) { return false; } $annotations = elgg_get_annotations(array('guid' => $object->guid, 'annotation_owner_guid' => $user->guid, 'annotation_names' => 'tu_spam_report')); return $annotations ? true : false; }
/** * {@inheritdoc} */ public function delete(ParameterBag $params) { $likes = elgg_get_annotations(array('guid' => (int) $params->guid, 'annotation_owner_guid' => elgg_get_logged_in_user_guid(), 'annotation_name' => 'likes')); $like = !empty($likes) ? $likes[0] : false; if ($like && $like->canEdit()) { return $like->delete(); } throw new GraphException(elgg_echo("likes:notdeleted")); }
/** * Check whether the user has voted in this poll * * @param ElggUser $user * @return boolean */ public function hasVoted($user) { $votes = elgg_get_annotations(array('guid' => $this->guid, 'type' => "object", 'subtype' => "poll", 'annotation_name' => "vote", 'annotation_owner_guid' => $user->guid, 'limit' => 1)); if ($votes) { return true; } else { return false; } }
/** * When a user joins a group * * @param string $event join * @param string $type group * @param array $params array with the user and the user * * @return void */ function group_tools_join_group_event($event, $type, $params) { global $NOTIFICATION_HANDLERS; static $auto_notification; // only load plugin setting once if (!isset($auto_notification)) { $auto_notification = array(); if (isset($NOTIFICATION_HANDLERS) && is_array($NOTIFICATION_HANDLERS)) { if (elgg_get_plugin_setting("auto_notification", "group_tools") == "yes") { // Backwards compatibility $auto_notification = array("email", "site"); } foreach ($NOTIFICATION_HANDLERS as $method => $foo) { if (elgg_get_plugin_setting("auto_notification_" . $method, "group_tools") == "1") { $auto_notification[] = $method; } } } } if (!empty($params) && is_array($params)) { $group = elgg_extract("group", $params); $user = elgg_extract("user", $params); if ($user instanceof ElggUser && $group instanceof ElggGroup) { // check for the auto notification settings if (!empty($NOTIFICATION_HANDLERS) && is_array($NOTIFICATION_HANDLERS)) { foreach ($NOTIFICATION_HANDLERS as $method => $dummy) { if (in_array($method, $auto_notification)) { add_entity_relationship($user->getGUID(), "notify" . $method, $group->getGUID()); } } } // cleanup invites remove_entity_relationship($group->getGUID(), "invited", $user->getGUID()); // and requests remove_entity_relationship($user->getGUID(), "membership_request", $group->getGUID()); // cleanup email invitations $options = array("annotation_name" => "email_invitation", "annotation_value" => group_tools_generate_email_invite_code($group->getGUID(), $user->email), "limit" => false); if (elgg_is_logged_in()) { elgg_delete_annotations($options); } elseif ($annotations = elgg_get_annotations($options)) { group_tools_delete_annotations($annotations); } // welcome message $welcome_message = $group->getPrivateSetting("group_tools:welcome_message"); $check_message = trim(strip_tags($welcome_message)); if (!empty($check_message)) { // replace the place holders $welcome_message = str_ireplace("[name]", $user->name, $welcome_message); $welcome_message = str_ireplace("[group_name]", $group->name, $welcome_message); $welcome_message = str_ireplace("[group_url]", $group->getURL(), $welcome_message); // notify the user notify_user($user->getGUID(), $group->getGUID(), elgg_echo("group_tools:welcome_message:subject", array($group->name)), $welcome_message); } } } }
function polls_check_for_previous_vote($poll, $user_guid) { $options = array('guid' => $poll->guid, 'type' => "object", 'subtype' => "poll", 'annotation_name' => "vote", 'annotation_owner_guid' => $user_guid, 'limit' => 1); $votes = elgg_get_annotations($options); if ($votes) { return true; } else { return false; } }
function gvpolls_remove_previous_vote($poll, $user_guid) { $options = array('guid' => $poll->guid, 'type' => "object", 'subtype' => "poll", 'annotation_name' => "vote", 'annotation_owner_guid' => $user_guid, 'limit' => 1); $votes = elgg_get_annotations($options); if ($votes) { foreach ($votes as $vote) { $vote->delete(); } } }
public function testElggGetAnnotationsCount() { $this->object->title = 'Annotation Unit Test'; $this->object->save(); $guid = $this->object->getGUID(); create_annotation($guid, 'tested', 'tested1', 'text', 0, ACCESS_PUBLIC); create_annotation($guid, 'tested', 'tested2', 'text', 0, ACCESS_PUBLIC); $count = (int) elgg_get_annotations(array('annotation_names' => array('tested'), 'guid' => $guid, 'count' => true)); $this->assertIdentical($count, 2); $this->object->delete(); }
/** * Returns the answer given by a user * * @param string $user_guid guid of the entity * * @return boolean|ElggAnnotation */ public function getAnswerFromUser($user_guid = null) { if (empty($user_guid)) { $user_guid = elgg_get_logged_in_user_guid(); } $params = ['guid' => $this->getGUID(), 'annotation_name' => 'answer_to_event_registration', 'annotation_owner_guid' => $user_guid, 'limit' => 1]; $annotations = elgg_get_annotations($params); if (empty($annotations)) { return false; } return $annotations[0]; }
public function getAnswerFromUser($user_guid = null) { $result = false; if (empty($user_guid)) { $user_guid = elgg_get_logged_in_user_guid(); } $params = array("guid" => $this->getGUID(), "annotation_name" => "answer_to_event_registration", "annotation_owner_guid" => $user_guid, "limit" => 1); if ($annotations = elgg_get_annotations($params)) { $result = $annotations[0]; } return $result; }
/** * @param int[] $guids */ protected function preloadCurrentUserLikes(array $guids) { $owner_guid = elgg_get_logged_in_user_guid(); if (!$owner_guid) { return; } $annotation_rows = elgg_get_annotations(array('annotation_names' => 'likes', 'annotation_owner_guids' => $owner_guid, 'guids' => $guids, 'callback' => false)); foreach ($guids as $guid) { $this->data->setLikedByCurrentUser($guid, false); } foreach ($annotation_rows as $row) { $this->data->setLikedByCurrentUser($row->entity_guid, true); } }
public function processItems($type, $guids) { if ($type == 'entities') { $items = elgg_get_entities(array('guids' => $guids, 'limit' => false, 'site_guids' => false, 'callback' => 'elasticsearch_entity_row_to_std')); } elseif ($type == 'annotations') { $items = elgg_get_annotations(array('annotations_ids' => $guids, 'limit' => false, 'site_guids' => false)); } else { throw new Exception('Invalid type.'); } try { $this->interface->bulk($items); } catch (Exception $exception) { } }
function proposals_get_votes($entity) { $annotations = elgg_get_annotations(array('guid' => $entity->guid, 'annotation_name' => 'votes', 'limit' => 0)); $votes = array(); foreach (array("yes", "no", "block", "abstain") as $name) { $votes[$name] = 0; } foreach ($annotations as $annotation) { if (!isset($votes[$annotation->value])) { $votes[$annotation->value] = 0; } $votes[$annotation->value] += 1; } return $votes; }
public function testElggDeleteAnnotations() { $e = new ElggObject(); $e->save(); for ($i = 0; $i < 30; $i++) { $e->annotate('test_annotation', rand(0, 10000)); } $options = array('guid' => $e->getGUID(), 'limit' => 0); $annotations = elgg_get_annotations($options); $this->assertIdentical(30, count($annotations)); $this->assertTrue(elgg_delete_annotations($options)); $annotations = elgg_get_annotations($options); $this->assertTrue(empty($annotations)); $this->assertTrue($e->delete()); }
/** * Web service to get users who liked an entity * * @param string $entity_guid guid of object * * @return bool */ function likes_getusers($entity_guid) { $entity = get_entity($entity_guid); if (likes_count($entity) > 0) { $list = elgg_get_annotations(array('guid' => $entity_guid, 'annotation_name' => 'likes', 'limit' => 99)); foreach ($list as $singlelike) { $likes[$singlelike->id]['userid'] = $singlelike->owner_guid; $likes[$singlelike->id]['time_created'] = $singlelike->time_created; $likes[$singlelike->id]['access_id'] = $singlelike->access_id; } } else { $likes = elgg_echo('likes:userslikedthis', array(likes_count($entity))); } return $likes; }
/** * called on register action - checks user ip/email against rules * * @param type $hook * @param type $entity_type * @param type $returnvalue * @param type $params * @return boolean */ function verify_action_hook($hook, $type, $return, $params) { //Check against stopforumspam and domain blacklist $email = get_input('email'); $ip = get_ip(); if (check_spammer($email, $ip)) { return $return; } else { //Check if the ip exists $blacklisted = elgg_get_annotations(array('guid' => elgg_get_site_entity()->guid, 'annotation_names' => array('spam_login_filter_ip'), 'annotation_values' => array($ip))); if (!$blacklisted) { elgg_get_site_entity()->annotate('spam_login_filter_ip', $ip, ACCESS_PUBLIC); } forward(); } }
public function testElggEnableAnnotations() { $e = new \ElggObject(); $e->save(); for ($i = 0; $i < 30; $i++) { $e->annotate('test_annotation', rand(0, 10000)); } $options = array('guid' => $e->getGUID(), 'limit' => 0); $this->assertTrue(elgg_disable_annotations($options)); // cannot see any annotations so returns null $this->assertNull(elgg_enable_annotations($options)); access_show_hidden_entities(true); $this->assertTrue(elgg_enable_annotations($options)); access_show_hidden_entities(false); $annotations = elgg_get_annotations($options); $this->assertIdentical(30, count($annotations)); $this->assertTrue($e->delete()); }
/** * Unban users whose timeouts have expired * * @return void */ function ban_cron() { $previous = elgg_set_ignore_access(); $dbprefix = get_config('dbprefix'); $params = array('type' => 'user', 'annotation_names' => array('ban_release'), 'joins' => array("JOIN {$dbprefix}users_entity u on e.guid = u.guid"), 'wheres' => array("u.banned='yes'")); $now = time(); $users = elgg_get_entities_from_annotations($params); foreach ($users as $user) { $releases = elgg_get_annotations(array('guid' => $user->guid, 'annotation_name' => 'ban_release', 'limit' => 1, 'order' => 'n_table.time_created desc')); foreach ($releases as $release) { if ($release->value < $now) { if ($user->unban()) { $release->delete(); } } } } elgg_set_ignore_access($previous); }
public function testElggEnityGetAndSetAnnotations() { $this->assertIdentical($this->entity->getAnnotations(array('annotation_name' => 'non_existent')), array()); // save entity and check for annotation $this->entity->annotate('non_existent', 'foo'); $annotations = $this->entity->getAnnotations(array('annotation_name' => 'non_existent')); $this->assertIsA($annotations[0], 'ElggAnnotation'); $this->assertIdentical($annotations[0]->name, 'non_existent'); $this->assertEqual($this->entity->countAnnotations('non_existent'), 1); // @todo belongs in Annotations API test class $this->assertIdentical($annotations, elgg_get_annotations(array('guid' => $this->entity->getGUID()))); $this->assertIdentical($annotations, elgg_get_annotations(array('guid' => $this->entity->getGUID(), 'type' => 'object'))); $this->assertIdentical(false, elgg_get_annotations(array('guid' => $this->entity->getGUID(), 'type' => 'object', 'subtype' => 'fail'))); // clear annotation $this->assertTrue($this->entity->deleteAnnotations()); $this->assertEqual($this->entity->countAnnotations('non_existent'), 0); // @todo belongs in Annotations API test class $this->assertIdentical(array(), elgg_get_annotations(array('guid' => $this->entity->getGUID()))); $this->assertIdentical(array(), elgg_get_annotations(array('guid' => $this->entity->getGUID(), 'type' => 'object'))); }
/** * Get the download trends * * @param int $guid Plugin project guid or 0 for all plugins * @param int $days Number of days starting from today or 0 for dawn of time * @return array */ function get_downloads_histogram($guid = 0, $days = 30) { $start_date = time() - $days * 3600 * 24; if ($days == 0) { $start_date = 0; } $downloads = elgg_get_annotations(array('guid' => $guid, 'limit' => 0, 'order_by' => 'time_created asc', 'annotation_name' => 'download', 'annotation_created_time_lower' => $start_date)); // if queried for all downloads, need to set epoch based on first download $first_time = $downloads[0]->time_created; $num_actual_days = (int) (time() - $first_time) / (3600 * 24) + 1; if ($start_date == 0) { $start_date = $first_time; $days = max($days, $num_actual_days); } // compute histogram of downloads $histogram = array_fill(0, $days, 0); foreach ($downloads as $download) { $day = (int) floor(($download->time_created - $start_date) / (3600 * 24)); $histogram[$day]++; } return $histogram; }
function group_tools_join_group_event($event, $type, $params) { global $NOTIFICATION_HANDLERS; static $auto_notification; // only load plugin setting once if (!isset($auto_notification)) { $auto_notification = false; if (elgg_get_plugin_setting("auto_notification", "group_tools") == "yes") { $auto_notification = true; } } if (!empty($params) && is_array($params)) { $group = elgg_extract("group", $params); $user = elgg_extract("user", $params); if ($user instanceof ElggUser && $group instanceof ElggGroup) { if ($auto_notification && !empty($NOTIFICATION_HANDLERS) && is_array($NOTIFICATION_HANDLERS)) { // only auto subscribe to site and email notifications $auto_notification_handlers = array("site", "email"); foreach ($NOTIFICATION_HANDLERS as $method => $dummy) { if (in_array($method, $auto_notification_handlers)) { add_entity_relationship($user->getGUID(), "notify" . $method, $group->getGUID()); } } } // cleanup invites remove_entity_relationship($group->getGUID(), "invited", $user->getGUID()); // and requests remove_entity_relationship($user->getGUID(), "membership_request", $group->getGUID()); // cleanup email invitations $options = array("annotation_name" => "email_invitation", "annotation_value" => group_tools_generate_email_invite_code($group->getGUID(), $user->email), "limit" => false); if (elgg_is_logged_in()) { elgg_delete_annotations($options); } elseif ($annotations = elgg_get_annotations($options)) { group_tools_delete_annotations($annotations); } } } }
/** * Add a like button to river actions */ function likes_river_menu_setup($hook, $type, $return, $params) { if (elgg_is_logged_in()) { $item = $params['item']; $object = $item->getObjectEntity(); if (!elgg_in_context('widgets') && $item->annotation_id == 0) { if ($object->canAnnotate(0, 'likes')) { if (!elgg_annotation_exists($object->getGUID(), 'likes')) { // user has not liked this yet $url = "action/likes/add?guid={$object->getGUID()}"; $options = array('name' => 'like', 'href' => $url, 'text' => elgg_view('likes/display', array('entity' => $object)), 'is_action' => true, 'priority' => 100); } else { // user has liked this $likes = elgg_get_annotations(array('guid' => $object->getGUID(), 'annotation_name' => 'likes', 'annotation_owner_guid' => elgg_get_logged_in_user_guid())); $url = elgg_get_site_url() . "action/likes/delete?annotation_id={$likes[0]->id}"; $options = array('name' => 'like', 'href' => $url, 'text' => elgg_view('likes/display', array('entity' => $object)), 'is_action' => true, 'priority' => 100); } $return[] = ElggMenuItem::factory($options); } } } return $return; }
/** * Note - only needed for 1.8 * * @param type $time * @param type $block * @return type */ function elgg_solr_get_comment_stats($time, $block) { $type = 'annotation'; $fq = array('subtype' => "subtype:generic_comment"); $stats = array(); switch ($block) { case 'hour': // I don't think we need minute resolution right now... break; case 'day': for ($i = 0; $i < 24; $i++) { $starttime = mktime($i, 0, 0, date('m', $time), date('j', $time), date('Y', $time)); $endtime = mktime($i + 1, 0, 0, date('m', $time), date('j', $time), date('Y', $time)) - 1; $fq['time_created'] = "time_created:[{$starttime} TO {$endtime}]"; $indexed = elgg_solr_get_indexed_count("type:{$type}", $fq); $system = elgg_get_annotations(array('annotation_name' => 'generic_comment', 'annotation_created_time_lower' => $starttime, 'annotation_created_time_upper' => $endtime, 'count' => true)); $stats[date('H', $starttime)] = array('count' => $system, 'indexed' => $indexed, 'starttime' => $starttime, 'endtime' => $endtime, 'block' => false); } break; case 'month': for ($i = 1; $i < date('t', $time) + 1; $i++) { $starttime = mktime(0, 0, 0, date('m', $time), $i, date('Y', $time)); $endtime = mktime(0, 0, 0, date('m', $time), $i + 1, date('Y', $time)) - 1; $fq['time_created'] = "time_created:[{$starttime} TO {$endtime}]"; $indexed = elgg_solr_get_indexed_count("type:{$type}", $fq); $system = elgg_get_annotations(array('annotation_name' => 'generic_comment', 'annotation_created_time_lower' => $starttime, 'annotation_created_time_upper' => $endtime, 'count' => true)); $stats[date('d', $starttime)] = array('count' => $system, 'indexed' => $indexed, 'starttime' => $starttime, 'endtime' => $endtime, 'block' => 'day'); } break; case 'year': for ($i = 1; $i < 13; $i++) { $starttime = mktime(0, 0, 0, $i, 1, date('Y', $time)); $endtime = mktime(0, 0, 0, $i + 1, 1, date('Y', $time)) - 1; $fq['time_created'] = "time_created:[{$starttime} TO {$endtime}]"; $indexed = elgg_solr_get_indexed_count("type:{$type}", $fq); $system = elgg_get_annotations(array('annotation_name' => 'generic_comment', 'annotation_created_time_lower' => $starttime, 'annotation_created_time_upper' => $endtime, 'count' => true)); $stats[date('F', $starttime)] = array('count' => $system, 'indexed' => $indexed, 'starttime' => $starttime, 'endtime' => $endtime, 'block' => 'month'); } break; case 'all': default: $startyear = date('Y', elgg_get_site_entity()->time_created); $currentyear = date('Y'); for ($i = $currentyear; $i > $startyear - 1; $i--) { $starttime = mktime(0, 0, 0, 1, 1, $i); $endtime = mktime(0, 0, 0, 1, 1, $i + 1) - 1; $fq['time_created'] = "time_created:[{$starttime} TO {$endtime}]"; $indexed = elgg_solr_get_indexed_count("type:{$type}", $fq); $system = elgg_get_annotations(array('annotation_name' => 'generic_comment', 'annotation_created_time_lower' => $starttime, 'annotation_created_time_upper' => $endtime, 'count' => true)); $stats[$i] = array('count' => $system, 'indexed' => $indexed, 'starttime' => $starttime, 'endtime' => $endtime, 'block' => 'year'); } break; } return $stats; }
<?php /** * Accept an email invitation */ $invitecode = get_input("invitecode"); $user = elgg_get_logged_in_user_entity(); $forward_url = REFERER; if (!empty($invitecode)) { $forward_url = elgg_get_site_url() . "groups/invitations/" . $user->username; $group = group_tools_check_group_email_invitation($invitecode); if (!empty($group)) { if (groups_join_group($group, $user)) { $invitecode = sanitise_string($invitecode); $options = array("guid" => $group->getGUID(), "annotation_name" => "email_invitation", "wheres" => array("(v.string = '" . $invitecode . "' OR v.string LIKE '" . $invitecode . "|%')"), "annotation_owner_guid" => $group->getGUID(), "limit" => 1); $annotations = elgg_get_annotations($options); if (!empty($annotations)) { // ignore access in order to cleanup the invitation $ia = elgg_set_ignore_access(true); $annotations[0]->delete(); // restore access elgg_set_ignore_access($ia); } $forward_url = $group->getURL(); system_message(elgg_echo("group_tools:action:groups:email_invitation:success")); } else { register_error(elgg_echo("group_tools:action:groups:email_invitation:error:join", array($group->name))); } } else { register_error(elgg_echo("group_tools:action:groups:email_invitation:error:code")); }