/** * Change the tidypics_batch's access_id to container's access_id (album object) * * @param ElggObject $entity * @param string $getter * @param array $options */ function tidypics_2012111901($entity, $getter, $options) { $album = $entity->getContainerEntity(); if ($guid = tidypics_adjust_batch_access_id($entity, $album)) { return $guid; } }
/** * Make sure we can autosubscribe the user to further updates * * @param string $event the name of the event * @param string $type the type of the event * @param ElggObject $object the created comment * * @return void */ public static function createObject($event, $type, \ElggObject $object) { if (!$object instanceof \ElggComment) { return; } $owner = $object->getOwnerEntity(); $entity = $object->getContainerEntity(); // add auto subscription for this user content_subscriptions_autosubscribe($entity->getGUID(), $owner->getGUID()); }
/** * Subscribe to a question when you create a comment on an answer * * @param string $event * @param string $type * @param \ElggObject $object * * @return void */ public static function createCommentOnAnswer($event, $type, \ElggObject $object) { if (!elgg_is_active_plugin('content_subscriptions')) { return; } if (!$object instanceof \ElggComment) { return; } $answer = $object->getContainerEntity(); if (!$answer instanceof \ElggAnswer) { return; } $owner = $object->getOwnerEntity(); $question = $answer->getContainerEntity(); if (!content_subscriptions_can_subscribe($question, $owner->getGUID())) { return; } // subscribe to the question content_subscriptions_autosubscribe($question->getGUID(), $owner->getGUID()); }
function file_tools_get_parent_url(ElggObject $folder) { if ($folder->parent_guid !== 0) { $parent = get_entity($folder->parent_guid); return file_tools_folder_url_handler($parent); } else { $container = $folder->getContainerEntity(); if (elgg_instanceof($container, "group")) { return "file/group/" . $container->getGUID() . "/all"; } else { return "file/owner/" . $container->username; } } }
if ($guid) { $entity = get_entity($guid); if (!elgg_instanceof($entity, 'object', 'chat_message') || !$entity->canEdit()) { register_error(elgg_echo('noaccess')); forward(REFERER); } } else { $entity = new ElggObject(); $entity->subtype = 'chat_message'; $entity->access_id = ACCESS_LOGGED_IN; $entity->container_guid = $container_guid; } $entity->description = $message; if ($entity->save()) { elgg_clear_sticky_form('chat_message'); $chat = $entity->getContainerEntity(); $members = $chat->getMemberEntities(); foreach ($members as $member) { // No unread annotations for user's own message if ($member->getGUID() === $user->getGUID()) { continue; } // Mark the message as unread $entity->addRelationship($member->getGUID(), 'unread'); // Add number of unread messages also to the chat object $chat->increaseUnreadMessageCount($member); } // @todo Should we update the container chat so we can order chats by // time_updated? Or is it possible to order by "unread_messages" annotation? //$chat->time_updated = time(); } else {
/** * Push breadcrumbs from the given crud object going up in the parent hirarchy * * @param ElggObject $last Ending object * @param ElggObject $entity Current object * @param CrudTemplate $crud Crud template object */ function crud_push_breadcrumb($last, $entity, $crud = NULL) { if (empty($crud)) { $crud = crud_get_handler($entity->getSubtype()); } if ($entity->parent_guid) { $parent = get_entity($entity->parent_guid); crud_push_breadcrumb($last, $parent); } else { $group = $entity->getContainerEntity(); elgg_push_breadcrumb($group->name, "{$crud->crud_type}/owner/{$entity->container_guid}"); } $title = $entity->title; if (empty($title)) { $title = elgg_echo("{$crud->module}:{$crud->crud_type}"); } if ($entity == $last) { elgg_push_breadcrumb($title); } else { elgg_push_breadcrumb($title, "{$crud->crud_type}/view/{$entity->guid}"); } }
/** * * {@inheritDoc} * * @return \APIApplication */ public function getContainerEntity() { return parent::getContainerEntity(); }