public function testElggEntityDisableAndEnable() { global $CONFIG; // add annotations and metadata to check if they're disabled. $annotation_id = create_annotation($this->entity->guid, 'test_annotation_' . rand(), 'test_value_' . rand()); $metadata_id = create_metadata($this->entity->guid, 'test_metadata_' . rand(), 'test_value_' . rand()); $this->assertTrue($this->entity->disable()); // ensure disabled by comparing directly with database $entity = get_data_row("SELECT * FROM {$CONFIG->dbprefix}entities WHERE guid = '{$this->entity->guid}'"); $this->assertIdentical($entity->enabled, 'no'); $annotation = get_data_row("SELECT * FROM {$CONFIG->dbprefix}annotations WHERE id = '{$annotation_id}'"); $this->assertIdentical($annotation->enabled, 'no'); $metadata = get_data_row("SELECT * FROM {$CONFIG->dbprefix}metadata WHERE id = '{$metadata_id}'"); $this->assertIdentical($metadata->enabled, 'no'); // re-enable for deletion to work $this->assertTrue($this->entity->enable()); // check enabled // check annotations and metadata enabled. $entity = get_data_row("SELECT * FROM {$CONFIG->dbprefix}entities WHERE guid = '{$this->entity->guid}'"); $this->assertIdentical($entity->enabled, 'yes'); $annotation = get_data_row("SELECT * FROM {$CONFIG->dbprefix}annotations WHERE id = '{$annotation_id}'"); $this->assertIdentical($annotation->enabled, 'yes'); $metadata = get_data_row("SELECT * FROM {$CONFIG->dbprefix}metadata WHERE id = '{$metadata_id}'"); $this->assertIdentical($metadata->enabled, 'yes'); $this->assertTrue($this->entity->delete()); $this->entity = null; }
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(); }
public function createAnnotations($max = 1) { $annotations = array(); for ($i = 0; $i < $max; $i++) { $name = 'test_annotation_name' . rand(); $value = 'test_annotation_value' . rand(); $id = create_annotation($this->object->guid, $name, $value); $annotations[] = $id; } return $annotations; }
function like_post_API($entity_guid) { $params = array('types' => 'object', 'subtypes' => 'thewire', 'guid' => $entity_guid); $latest_wire = elgg_get_entities($params); if (elgg_annotation_exists($entity_guid, 'likes')) { //delete like if ($entity_guid) { $like = elgg_get_annotation_from_id($entity_guid); } if (!$like) { $likes = elgg_get_annotations(array('guid' => $entity_guid, 'annotation_owner_guid' => elgg_get_logged_in_user_guid(), 'annotation_name' => 'likes')); $like = $likes[0]; } if ($latest_wire) { if ($like && $like->canEdit()) { $like->delete(); //echo elgg_echo("likes:deleted"); return '3'; //return 'delete'; } else { //echo elgg_echo("likes:notdeleted"); //return 'notdelete'; return '4'; } } else { return '6'; } } else { // Let's see if we can get an entity with the specified GUID $entity = get_entity($entity_guid); if (!$entity) { //echo elgg_echo("likes:notfound"); //return'not found'; return '5'; } if ($latest_wire) { $user = elgg_get_logged_in_user_entity(); $annotation_id = create_annotation($entity->guid, 'likes', "likes", "", $user->guid, $entity->access_id); // tell user annotation didn't work if that is the case if (!$annotation_id) { //echo elgg_echo("likes:failure"); //return 'like failure'; return '2'; } // notify if poster wasn't owner return '1'; //echo elgg_echo("likes:likes"); //return 'like'; } else { return '6'; } } }
/** * Save this instance * * @return int an object id */ function save() { if ($this->id > 0) { return update_annotation($this->id, $this->name, $this->value, $this->value_type, $this->owner_guid, $this->access_id); } else { $this->id = create_annotation($this->entity_guid, $this->name, $this->value, $this->value_type, $this->owner_guid, $this->access_id); if (!$this->id) { throw new IOException(sprintf(elgg_new('IOException:UnableToSaveNew'), get_class())); } return $this->id; } }
/** * Save this instance * * @return int an object id * * @throws IOException */ public function save() { if ($this->id > 0) { return update_annotation($this->id, $this->name, $this->value, $this->value_type, $this->owner_guid, $this->access_id); } else { $this->id = create_annotation($this->entity_guid, $this->name, $this->value, $this->value_type, $this->owner_guid, $this->access_id); if (!$this->id) { throw new IOException("Unable to save new " . get_class()); } return $this->id; } }
public function testElggApiGettersEntitiesFromAnnotation() { // grab a few different users to annotation // there will always be at least 2 here because of the construct. $users = elgg_get_entities(array('type' => 'user', 'limit' => 2)); // create some test annotations $subtypes = $this->getRandomValidSubtypes(array('object'), 1); $subtype = $subtypes[0]; $annotation_name = 'test_annotation_name_' . rand(); $annotation_value = rand(1000, 9999); $annotation_name2 = 'test_annotation_name_' . rand(); $annotation_value2 = rand(1000, 9999); $guids = array(); // our targets $valid = new \ElggObject(); $valid->subtype = $subtype; $valid->save(); $guids[] = $valid->getGUID(); create_annotation($valid->getGUID(), $annotation_name, $annotation_value, 'integer', $users[0]->getGUID()); $valid2 = new \ElggObject(); $valid2->subtype = $subtype; $valid2->save(); $guids[] = $valid2->getGUID(); create_annotation($valid2->getGUID(), $annotation_name2, $annotation_value2, 'integer', $users[1]->getGUID()); $options = array('annotation_owner_guid' => $users[0]->getGUID(), 'annotation_name' => $annotation_name); $entities = elgg_get_entities_from_annotations($options); foreach ($entities as $entity) { $this->assertTrue(in_array($entity->getGUID(), $guids)); $annotations = $entity->getAnnotations(array('annotation_name' => $annotation_name)); $this->assertEqual(count($annotations), 1); $this->assertEqual($annotations[0]->name, $annotation_name); $this->assertEqual($annotations[0]->value, $annotation_value); $this->assertEqual($annotations[0]->owner_guid, $users[0]->getGUID()); } foreach ($guids as $guid) { if ($e = get_entity($guid)) { $e->delete(); } } }
public function save($create_elgg_annotation = true) { if (parent::save()) { if (!$this->river_id && $create_elgg_annotation) { $container = $this->getContainerEntity(); if (!elgg_instanceof($container, 'object', 'hjannotation')) { $container = $this->findOriginalContainer(); } if ($container->getType() != 'river') { if ($id = create_annotation($container->guid, $this->annotation_name, $this->annotation_value, '', $this->owner_guid, $this->access_id)) { $this->annotation_id = $id; } } } $notify_settings = elgg_trigger_plugin_hook('hj:notification:setting', 'annotation', null, ''); if ($notify_settings && in_array($this->annotation_name, $notify_settings)) { $this->sendNotification(); } return $this->guid; } return false; }
/** * {@inheritdoc} */ public function post(ParameterBag $params) { $entity_guid = (int) $params->guid; //check to see if the user has already liked the item if (elgg_annotation_exists($entity_guid, 'likes')) { throw new GraphException(elgg_echo("likes:alreadyliked"), HttpResponse::HTTP_NOT_MODIFIED); } // Let's see if we can get an entity with the specified GUID $entity = get_entity($entity_guid); if (!$entity) { throw new GraphException(elgg_echo("likes:notfound"), HttpResponse::HTTP_NOT_FOUND); } // limit likes through a plugin hook (to prevent liking your own content for example) if (!$entity->canAnnotate(0, 'likes')) { // plugins should register the error message to explain why liking isn't allowed throw new GraphException(elgg_echo("likes:notallowed"), HttpResponse::HTTP_FORBIDDEN); } $user = elgg_get_logged_in_user_entity(); $annotation_id = create_annotation($entity->guid, 'likes', "likes", "", $user->guid, $entity->access_id); // tell user annotation didn't work if that is the case if (!$annotation_id) { throw new GraphException(elgg_echo("likes:failure")); } // notify if poster wasn't owner if ($entity->owner_guid != $user->guid) { $owner = $entity->getOwnerEntity(); $annotation = elgg_get_annotation_from_id($annotation_id); $title_str = $entity->getDisplayName(); if (!$title_str) { $title_str = elgg_get_excerpt($entity->description); } $site = elgg_get_site_entity(); $subject = elgg_echo('likes:notifications:subject', array($user->name, $title_str), $owner->language); $body = elgg_echo('likes:notifications:body', array($owner->name, $user->name, $title_str, $site->name, $entity->getURL(), $user->getURL()), $owner->language); notify_user($entity->owner_guid, $user->guid, $subject, $body, array('action' => 'create', 'object' => $annotation)); } return array('nodes' => array(elgg_get_annotation_from_id($annotation_id))); }
/** * Web service to like an entity * * @param string $entity_guid guid of object to like * * @return bool */ function likes_add($entity_guid) { if (elgg_annotation_exists($entity_guid, 'likes')) { return elgg_echo("likes:alreadyliked"); } // Let's see if we can get an entity with the specified GUID $entity = get_entity($entity_guid); if (!$entity) { return elgg_echo("likes:notfound"); } // limit likes through a plugin hook (to prevent liking your own content for example) if (!$entity->canAnnotate(0, 'likes')) { return elgg_echo("likes:notallowed"); } $user = elgg_get_logged_in_user_entity(); $annotation = create_annotation($entity->guid, 'likes', "likes", "", $user->guid, $entity->access_id); // tell user annotation didn't work if that is the case if (!$annotation) { return elgg_echo("likes:failure"); } elgg_create_river_item('annotation/annotatelike', 'likes', $user->guid, $entity->guid, "", 0, $annotation); return elgg_echo("likes:likes"); }
/** * Update the last view time for this entity to the current time * * @param $entity_guid * @param $user_guid */ function update_last_view_time($entity_guid, $user_guid) { $entity = get_entity($entity_guid); if (!($user = get_entity($user_guid))) { $user = elgg_get_logged_in_user_entity(); } if ($entity && $user) { // Get the last view annotation that has the last view time saved $options = array('types' => array($entity->type), 'guids' => array($entity_guid), 'annotation_owner_guids' => array($user->guid), 'annotation_names' => array('last_view_time')); if ($entity->getSubtype()) { $options['subtypes'] = array($entity->getSubtype()); } $last_view_time = elgg_get_annotations($options); // It should exists only one annotation that has the last view time $last_view_time = $last_view_time[0]; if ($last_view_time) { // Update the value of last view time with the current time return update_annotation($last_view_time->id, 'last_view_time', time(), 'integer', $user->guid, 2); } else { // Create one annotation with the current time that means the last view time return create_annotation($entity->guid, 'last_view_time', time(), 'integer', $user->guid, 2); } } }
* @subpackage Comments */ $entity_guid = (int) get_input('entity_guid'); $comment_text = get_input('generic_comment'); if (empty($comment_text)) { register_error(elgg_echo("generic_comment:blank")); forward(REFERER); } // Let's see if we can get an entity with the specified GUID $entity = get_entity($entity_guid); if (!$entity) { register_error(elgg_echo("generic_comment:notfound")); forward(REFERER); } $user = elgg_get_logged_in_user_entity(); $annotation = create_annotation($entity->guid, 'generic_comment', $comment_text, "", $user->guid, $entity->access_id); // tell user annotation posted if (!$annotation) { register_error(elgg_echo("generic_comment:failure")); forward(REFERER); } // notify if poster wasn't owner if ($entity->owner_guid != $user->guid) { notify_user($entity->owner_guid, $user->guid, elgg_echo('generic_comment:email:subject'), elgg_echo('generic_comment:email:body', array($entity->title, $user->name, $comment_text, $entity->getURL(), $user->name, $user->getURL()))); } // list the last comment $options = array('guid' => $entity_guid, 'annotation_name' => 'generic_comment', 'pagination' => false, 'reverse_order_by' => true, 'limit' => 1); echo elgg_list_annotations($options); system_message(elgg_echo("generic_comment:posted")); if ($entity->getSubtype() !== 'videolist') { //add to river
function blog_post_comment2($guid, $text) { $entity = get_entity($guid); $user = elgg_get_logged_in_user_entity(); $annotation = create_annotation($entity->guid, 'generic_comment', $text, "", $user->guid, $entity->access_id); if ($annotation) { // notify if poster wasn't owner if ($entity->owner_guid != $user->guid) { notify_user($entity->owner_guid, $user->guid, elgg_echo('generic_comment:email:subject'), elgg_echo('generic_comment:email:body', array($entity->title, $user->name, $text, $user->name))); } //$return['success']['message'] = elgg_echo('generic_comment:posted'); $return = "posted"; } else { //$msg = elgg_echo('generic_comment:failure'); //throw new InvalidParameterException($msg); $return = " not posted"; } return $return; }
$error_nouser++; continue; } if (!$user->canEdit()) { $error_canedit++; continue; } if ($user->guid == elgg_get_logged_in_user_guid()) { $error++; continue; } if ($user->isBanned()) { $banned++; } else { if ($user->ban(get_input('approval_message', 'admin decision'))) { create_annotation($user->guid, 'ban', get_input('approval_message', true), '', elgg_get_logged_in_user_guid(), ACCESS_PUBLIC); $subject = elgg_echo("db_explorer:ban:email:subject"); if (get_input('notify_users', false)) { $body = elgg_view('framework/db_explorer/notifications/ban', array('entity' => $user, 'setter' => elgg_get_logged_in_user_entity(), 'note' => get_input('notify_users_message'))); try { elgg_send_email(elgg_get_site_entity()->email, $user->email, $subject, $body); } catch (Exception $e) { register_error($e->getMessage()); } } $success++; } else { $error++; } } }
if (sizeof($input) > 0) { foreach ($input as $name => $value) { $markdown_wiki->{$name} = $value; } } if ($markdown_wiki->save()) { elgg_clear_sticky_form('markdown_wiki'); elgg_load_library('markdown_wiki:fineDiff'); // set diff $compare = new FineDiff($old_description, $markdown_wiki->description, array(FineDiff::wordDelimiters)); $compared['word'] = calc_diff_markdown_wiki($compare->renderDiffToHTML()); $compare = new FineDiff($old_description, $markdown_wiki->description, array(FineDiff::sentenceDelimiters)); $compared['sentence'] = calc_diff_markdown_wiki($compare->renderDiffToHTML()); $compare = new FineDiff($old_description, $markdown_wiki->description, array(FineDiff::paragraphDelimiters)); $compared['paragraph'] = calc_diff_markdown_wiki($compare->renderDiffToHTML()); $array_change = array('text' => $markdown_wiki->description, 'diff' => $compared, 'summary' => get_input('summary')); // Now save description as an annotation $annotation_id = create_annotation($markdown_wiki->guid, 'markdown_wiki', serialize($array_change), '', 0, $markdown_wiki->access_id); system_message(elgg_echo('markdown_wiki:saved')); if ($new_markdown_wiki) { add_to_river('river/object/markdown_wiki/create', 'create', $user_guid, $markdown_wiki->guid); } else { if (!get_input('minorchange', false)) { add_to_river('river/object/markdown_wiki/update', 'update', $user_guid, $markdown_wiki->guid, '', 0, $annotation_id); } } forward($markdown_wiki->getURL()); } else { register_error(elgg_echo('markdown_wiki:error:no_save')); forward(REFERER); }
function event_poll_vote($event, $message = '', $schedule_slot = '') { if (elgg_instanceof($event, 'object', 'event_calendar')) { if ($event->canEdit()) { if ($schedule_slot) { @(list($iso, $time) = explode('__', $schedule_slot)); $event->start_time = $time; $event->end_time = $time + $event->event_length; $event->end_date = strtotime($iso); $event->start_date = strtotime("+ {$time} minutes", strtotime($iso)); $event->real_end_time = strtotime("+ " . $event->event_length . " minutes", $event->start_date); $event->is_event_poll = 0; } $event_calendar_personal_manage = elgg_get_plugin_setting('personal_manage', 'event_calendar'); if ($event_calendar_personal_manage == 'by_event') { $event->personal_manage = get_input('personal_manage'); } $event->access_id = get_input('access_id'); $event->send_reminder = get_input('send_reminder'); $event->reminder_number = get_input('reminder_number'); $event->reminder_interval = get_input('reminder_interval'); $event->save(); } $current_user = elgg_get_logged_in_user_entity(); if ((check_entity_relationship($current_user->guid, 'event_poll_invitation', $event->guid) || $current_user->guid == $event->owner_guid) && $event->event_poll) { elgg_delete_annotations(array('guid' => $event->guid, 'annotation_name' => 'event_poll_vote', 'annotation_owner_guid' => $current_user->guid, 'limit' => false)); $poll_options = event_poll_get_options($event); foreach ($poll_options as $option) { $tick = get_input($option); if ($tick) { create_annotation($event->guid, 'event_poll_vote', $option, null, $current_user->guid, ACCESS_PUBLIC); } } add_entity_relationship($current_user->guid, 'event_poll_voted', $event->guid); if ($message && $message != elgg_echo('event_poll:vote_message:explanation')) { $sender_guid = elgg_get_logged_in_user_guid(); $subject = elgg_echo('event_poll:vote_message:subject', array($event->title)); $message = elgg_echo('event_poll:vote_message:top', array($current_user->name)) . "\n\n" . $message; notify_user($event->owner_guid, $sender_guid, $subject, $message, array(), 'email'); messages_send($subject, $message, $event->owner_guid, $sender_guid, 0, false, false); } } return true; } else { return false; } }
if ($have_participants_yet) { $new_state = $entity->status; } } if ($state_action == 'deactivate') { $have_participants_yet = elgg_get_entities_from_relationship(array('relationship' => 'is_doing', 'relationship_guid' => $entity->guid, 'inverse_relationship' => true, 'count' => true)); if ($have_participants_yet) { $new_state = $entity->status; } } if ($state_action == 'assign' && $entity->status == 'active') { $new_state = $entity->status; } if ($new_state) { $entity->status = $new_state; create_annotation($entity->guid, 'task_state_changed', $state_action, "", $user->guid, $entity->access_id); } // notify if poster wasn't owner if ($entity->owner_guid != $user->guid) { if ($new_state) { notify_user($entity->owner_guid, $user->guid, elgg_echo('tasks:email:subject'), elgg_echo('tasks:email:body', array($user->name, $entity->title, $new_state, $comment_text, $entity->getURL(), $user->name, $user->getURL()))); } else { notify_user($entity->owner_guid, $user->guid, elgg_echo('generic_comment:email:subject'), elgg_echo('generic_comment:email:body', array($entity->title, $user->name, $comment_text, $entity->getURL(), $user->name, $user->getURL()))); } } if ($new_state) { system_message(elgg_echo("tasks:status:changed")); $action = $state_action; } else { system_message(elgg_echo("generic_comment:posted")); $action = 'comment';
public function testGetMetastringBasedObjectWithDisabledAnnotation() { $name = 'test_annotation_name' . rand(); $value = 'test_annotation_value' . rand(); $id = create_annotation($this->object->guid, $name, $value); $annotation = elgg_get_annotation_from_id($id); $this->assertTrue($annotation->disable()); $test = elgg_get_metastring_based_objects(array('metastring_type' => 'annotations', 'guid' => $this->object->guid)); $this->assertEqual(array(), $test); }
function pleio_api_add_comment($guid, $comment) { $user = elgg_get_logged_in_user_entity(); $user_id = $user !== false ? $user->guid : 0; if (!$user_id) { return new ErrorResult(elgg_echo("generic_comment:failure")); } if (empty($comment)) { return new ErrorResult(elgg_echo("generic_comment:blank")); } $entity = get_entity((int) $guid); if ($entity) { $annotation = create_annotation($entity->guid, 'generic_comment', $comment, "", $user_id, $entity->access_id); if (!$annotation) { return new ErrorResult(elgg_echo("generic_comment:failure")); } if ($entity->owner_guid != $user_id) { notify_user($entity->owner_guid, $user->guid, elgg_echo('generic_comment:email:subject'), elgg_echo('generic_comment:email:body', array($entity->title, $user->name, $comment, $entity->getURL(), $user->name, $user->getURL()))); } add_to_river('river/annotation/generic_comment/create', 'comment', $user->guid, $entity->guid, "", 0, $annotation); return new SuccessResult(elgg_echo("generic_comment:posted")); } else { $swordfish_name = pleio_api_swordfish_username($user->username); $url = pleio_api_swordfish_baseurl() . "get-page?id=" . $guid; $result = pleio_api_call_swordfish_api($swordfish_name, $url, "GET"); $wiki = pleio_api_swordfish_parse_get_page($result); if ($wiki) { $params = array("comment" => $comment, "wikiId" => $guid); $url = pleio_api_swordfish_baseurl() . "post-comment"; $result = pleio_api_call_swordfish_api($swordfish_name, $url, "POST", $params); if ($result->ok) { return new SuccessResult(elgg_echo("generic_comment:posted")); } else { return new ErrorResult(elgg_echo("generic_comment:failure")); } } return $result; return new ErrorResult(elgg_echo("swordfish_comment:notfound:swordfish")); } return new ErrorResult(elgg_echo("generic_comment:notfound")); }
public function testGetMetastringBasedObjectWithDisabledAnnotation() { $name = 'test_annotation_name' . rand(); $value = 'test_annotation_value' . rand(); $id = create_annotation($this->object->guid, $name, $value); $annotation = elgg_get_annotation_from_id($id); $this->assertTrue($annotation->disable()); $test = _elgg_get_metastring_based_objects(array('metastring_type' => 'annotations', 'guid' => $this->object->guid)); $this->assertEqual(array(), $test); $prev = access_get_show_hidden_status(); access_show_hidden_entities(true); $this->assertTrue(_elgg_delete_metastring_based_object_by_id($id, 'annotation')); access_show_hidden_entities($prev); }
} $list_guid = $input['list_guid']; if ($list_guid) { $task->list_guid = $list_guid; } else { $task->list_guid = 0; } $task->container_guid = $container_guid; if ($task->save()) { elgg_clear_sticky_form('task'); // Now save description as an annotation $task->annotate('task', $task->description, $task->access_id); system_message(elgg_echo('tasks:saved')); if ($new_task) { add_to_river('river/object/task/create', 'create', elgg_get_logged_in_user_guid(), $task->guid); } if ($new_task && $referer_guid && ($referer_entity = get_entity($referer_guid))) { $link = elgg_view('output/url', array('href' => $task->getURL(), 'text' => $task->title)); $annotation = create_annotation($referer_entity->guid, 'generic_comment', elgg_echo('tasks:this:referer:comment', array($link)), "", elgg_get_logged_in_user_guid(), $referer_entity->access_id); } $task_json = array(); foreach ($task->getExportableValues() as $v) { $task_json[$v] = $task->{$v}; } $task_json['list_guid'] = $task->list_guid; echo json_encode($task_json); forward($task->getURL()); } else { register_error(elgg_echo('tasks:error:no_save')); forward(REFERER); }
public function updateDownloadCount() { create_annotation($this->guid, 'download', 1, 'integer', 0, ACCESS_PUBLIC); }
//check to see if the user has already liked the item if (elgg_annotation_exists($entity_guid, 'likes')) { returnAjaxResult(false, elgg_echo("likes:alreadyliked"), $entity); exit; } // Let's see if we can get an entity with the specified GUID $entity = get_entity($entity_guid); if (!$entity) { returnAjaxResult(false, elgg_echo("likes:notfound"), $entity); exit; } // limit likes through a plugin hook (to prevent liking your own content for example) if (!$entity->canAnnotate(0, 'likes')) { // plugins should register the error message to explain why liking isn't allowed returnAjaxResult(false); exit; } $user = elgg_get_logged_in_user_entity(); $annotation = create_annotation($entity->guid, 'likes', "likes", "", $user->guid, $entity->access_id); // tell user annotation didn't work if that is the case if (!$annotation) { returnAjaxResult(false, elgg_echo("likes:failure"), $entity); exit; } // notify if poster wasn't owner if ($entity->owner_guid != $user->guid) { likes_notify_user($entity->getOwnerEntity(), $user, $entity); } //system_message(elgg_echo("likes:likes")); returnAjaxResult(true, elgg_echo("likes:likes"), $entity); exit;
/** * Add a view to this image * * @param $viewer_guid * @return void */ public function addView($viewer_guid = 0) { if ($viewer_guid == 0) { $viewer_guid = elgg_get_logged_in_user_guid(); } if ($viewer_guid != $this->owner_guid && tp_is_person()) { create_annotation($this->getGUID(), "tp_view", "1", "integer", $viewer_guid, ACCESS_PUBLIC); } }
$error_nouser = $error_canedit = $error = $success = $validated = 0; foreach ($guids as $guid) { $user = get_entity($guid); if (!elgg_instanceof($user, 'user')) { $error_nouser++; continue; } if (!$user->canEdit()) { $error_canedit++; continue; } if (elgg_get_user_validation_status($user->guid)) { $validated++; } else { if (elgg_set_user_validation_status($user->guid, true, 'manual')) { create_annotation($user->guid, 'validate', true, '', elgg_get_logged_in_user_guid(), ACCESS_PUBLIC); $success++; } else { $error++; } } } $msg[] = elgg_echo('db_explorer:success:validate', array((int) $success, $count)); if ($validated > 0) { $msg[] = elgg_echo('db_explorer:error:already_validated', array($validated)); } if ($error_nouser > 0) { $msg[] = elgg_echo('db_explorer:error:nouser', array($error_nouser)); } if ($error_canedit > 0) { $msg[] = elgg_echo('db_explorer:error:canedit', array($error_canedit));
<?php $guid = get_input('guid', false); $entity = get_entity($guid); if (!elgg_instanceof($entity)) { register_error(elgg_echo('stars:rate:error')); forward(REFERER); } $owner = elgg_get_logged_in_user_entity(); $annotation_names = get_input('annotation_names'); foreach ($annotation_names as $annotation_name) { $annotation_value = get_input($annotation_name); if ($entity->canAnnotate(0, $annotation_name) && elgg_stars_is_valid_rating($annotation_value)) { $id = create_annotation($guid, $annotation_name, (double) $annotation_value, '', $owner->guid, $entity->access_id); if ($id) { add_to_river('stars/river/rating', "stream:rating", elgg_get_logged_in_user_guid(), $entity->guid, $entity->access_id, time(), $id); } else { register_error(elgg_echo('stars:rate:error')); } } $entity_ratings = elgg_stars_get_entity_rating_values($entity, $annotation_name); $response[$guid][$annotation_name] = $entity_ratings; } if (elgg_is_xhr()) { system_message(elgg_echo('stars:rate:success')); print json_encode($response); } forward(REFERER);
<?php /** * Digital suicide action * * @package ElggSuicide */ elgg_load_library('elgg:suicide'); $me = get_entity(sanitize_int(get_input('guid'))); if (!$me) { register_error(elgg_echo('suicide:fail')); forward(REFERER); } $belongings = elgg_get_entities(array('owner_guid' => $me->guid, 'limit' => 0)); foreach ($belongings as $belonging) { if ($inherator_guid = suicide_find_inherator($belonging)) { $belonging->owner_guid = $inherator_guid; $belonging->save(); } } $friends = elgg_get_entities_from_relationship(array('relationship' => 'friend', 'relationship_guid' => $guid, 'types' => 'user', 'subtypes' => $subtype, 'limit' => $limit, 'offset' => $offset, 'count' => true)); $annotation_id = create_annotation(elgg_get_config('site_guid'), 'suicide', $me->name . "," . $friends, 'text', elgg_get_config('site_guid'), get_default_access($me)); add_to_river('river/suicide', 'suicide', elgg_get_config('site_guid'), elgg_get_config('site_guid'), ACCESS_LOGGED_IN, 0, $annotation_id); if ($me->delete()) { system_message(elgg_echo('suicide:success')); } else { register_error(elgg_echo('suicide:fail')); } forward();
<?php // staff only action user_support_staff_gatekeeper(); $guid = (int) get_input("guid"); $user = elgg_get_logged_in_user_entity(); if (!empty($guid) && ($entity = get_entity($guid))) { if (elgg_instanceof($entity, "object", UserSupportTicket::SUBTYPE, "UserSupportTicket")) { create_annotation($entity->getGUID(), 'generic_comment', elgg_echo("user_support:support_ticket:closed"), "", $user->getGUID(), $entity->access_id); if ($entity->setStatus(UserSupportTicket::CLOSED)) { notify_user($entity->getOwnerGUID(), $user->getGUID(), elgg_echo('generic_comment:email:subject'), elgg_echo('generic_comment:email:body', array($entity->title, $user->name, elgg_echo("user_support:support_ticket:closed"), $entity->getURL(), $user->name, $user->getURL()))); system_message(elgg_echo("user_support:action:ticket:close:success")); } else { register_error(elgg_echo("user_support:action:ticket:close:error:disable")); } } else { register_error(elgg_echo("InvalidClassException:NotValidElggStar", array($guid, "UserSupportTicket"))); } } else { register_error(elgg_echo("InvalidParameterException:MissingParameter")); } forward(REFERER);
/** * Adds an annotation to an entity. * * @warning By default, annotations are private. * * @warning Annotating an unsaved entity more than once with the same name * will only save the last annotation. * * @param string $name Annotation name * @param mixed $value Annotation value * @param int $access_id Access ID * @param int $owner_guid GUID of the annotation owner * @param string $vartype The type of annotation value * * @return bool|int Returns int if an annotation is saved */ public function annotate($name, $value, $access_id = ACCESS_PRIVATE, $owner_guid = 0, $vartype = "") { if ((int) $this->guid > 0) { return create_annotation($this->getGUID(), $name, $value, $vartype, $owner_guid, $access_id); } else { $this->temp_annotations[$name] = $value; } return true; }
* @subpackage Comments */ $entity_guid = (int) get_input("entity_guid"); $comment_text = get_input("generic_comment"); if (empty($comment_text)) { register_error(elgg_echo("generic_comment:blank")); forward(REFERER); } // Let's see if we can get an entity with the specified GUID $entity = get_entity($entity_guid); if (!$entity) { register_error(elgg_echo("generic_comment:notfound")); forward(REFERER); } $user = elgg_get_logged_in_user_entity(); $annotation = create_annotation($entity->getGUID(), "generic_comment", $comment_text, "", $user->getGUID(), $entity->access_id); // tell user annotation posted if (!$annotation) { register_error(elgg_echo("generic_comment:failure")); forward(REFERER); } // notify if poster wasn't owner if ($entity->getOwnerGUID() != $user->getGUID()) { // get the notification settings for the owner $notification_settings = (array) get_user_notification_settings($entity->getOwnerGUID()); if (!empty($notification_settings)) { // loop through the preferences foreach ($notification_settings as $method => $enabled) { if ($enabled) { if ($method == "email") { // send special (short) message