本文整理汇总了PHP中ElggObject::getOwnerEntity方法的典型用法代码示例。如果您正苦于以下问题:PHP ElggObject::getOwnerEntity方法的具体用法?PHP ElggObject::getOwnerEntity怎么用?PHP ElggObject::getOwnerEntity使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ElggObject
的用法示例。
在下文中一共展示了ElggObject::getOwnerEntity方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: createObject
/**
* 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());
}
示例2: crud_url_handler
/**
* Format and return the URL for crud object.
*
* @param ElggObject $entity Assembly object
* @return string URL of crud object.
*/
function crud_url_handler($entity)
{
if (!$entity->getOwnerEntity()) {
// default to a standard view if no owner.
return FALSE;
}
/*if (!$entity->testAssembly()) {
return FALSE;
}*/
//$friendly_title = elgg_get_friendly_title($entity->title);
return $entity->getSubtype() . "/view/{$entity->guid}";
}
示例3: event_create_object
function event_create_object($event, $type, \ElggObject $object)
{
if (!is_on_probation($object->getOwnerEntity())) {
return true;
}
$object->{QUARANTINED} = '1';
if (elgg_get_plugin_setting(QUARANTINE_PRIVATE, PLUGIN_ID)) {
system_message(elgg_echo('probation:moderated:private'));
} else {
system_message(elgg_echo('probation:moderated'));
}
State::$entities_quarantined[$object->guid] = $object;
}
示例4: tgswire_save_post
/**
* Create a new wire post, the TGS way
*
* @param string $text The post text
* @param int $userid The user's guid
* @param int $access_id Public/private etc
* @param int $parent_guid Parent post guid (if any)
* @param string $method The method (default: 'site')
* @param int $container_guid Container guid (for group wire posts)
* @return guid or false if failure
*/
function tgswire_save_post($text, $userid, $access_id, $parent_guid = 0, $method = "site", $container_guid = NULL)
{
$post = new ElggObject();
$post->subtype = "thewire";
$post->owner_guid = $userid;
$post->access_id = $access_id;
// Check if we're removing the limit
if (elgg_get_plugin_setting('limit_wire_chars', 'wire-extender') == 'yes') {
// only 200 characters allowed
$text = elgg_substr($text, 0, 200);
}
// If supplied with a container_guid, use it
if ($container_guid) {
$post->container_guid = $container_guid;
}
// no html tags allowed so we escape
$post->description = htmlspecialchars($text, ENT_NOQUOTES, 'UTF-8');
$post->method = $method;
//method: site, email, api, ...
$tags = thewire_get_hashtags($text);
if ($tags) {
$post->tags = $tags;
}
// must do this before saving so notifications pick up that this is a reply
if ($parent_guid) {
$post->reply = true;
}
$guid = $post->save();
// set thread guid
if ($parent_guid) {
$post->addRelationship($parent_guid, 'parent');
// name conversation threads by guid of first post (works even if first post deleted)
$parent_post = get_entity($parent_guid);
$post->wire_thread = $parent_post->wire_thread;
} else {
// first post in this thread
$post->wire_thread = $guid;
}
if ($guid) {
add_to_river('river/object/thewire/create', 'create', $post->owner_guid, $post->guid);
// let other plugins know we are setting a user status
$params = array('entity' => $post, 'user' => $post->getOwnerEntity(), 'message' => $post->description, 'url' => $post->getURL(), 'origin' => 'thewire');
elgg_trigger_plugin_hook('status', 'user', $params);
}
return $guid;
}
示例5: createCommentOnAnswer
/**
* 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());
}
示例6: shoutout_url_handler
/**
* Format and return the URL for shoutouts.
*
* @param ElggObject $entity Shoutout object
* @return string URL of shoutout.
*/
function shoutout_url_handler($entity)
{
if (!$entity->getOwnerEntity()) {
// default to a standard view if no owner.
return FALSE;
}
return "shoutout/view/{$entity->guid}";
}
示例7: thewire_tools_save_post
/**
* Save a wire post, overrules the default function because we need to support groups
*
* @param string $text the text of the post
* @param int $userid the owner of the post
* @param int $access_id the access level of the post
* @param int $parent_guid is this a reply on another post
* @param string $method which method was used
*
* @return bool|int the GUID of the new wire post or false
*/
function thewire_tools_save_post($text, $userid, $access_id, $parent_guid = 0, $method = "site")
{
// set correct container
$container_guid = $userid;
// check the access id
if ($access_id == ACCESS_PRIVATE) {
// private wire posts aren"t allowed
$access_id = ACCESS_LOGGED_IN;
} elseif (thewire_tools_groups_enabled()) {
// allow the saving of a wire post in a group (if enabled)
if (!in_array($access_id, array(ACCESS_FRIENDS, ACCESS_LOGGED_IN, ACCESS_PUBLIC))) {
// try to find a group with access_id
$group_options = array("type" => "group", "limit" => 1, "metadata_name_value_pairs" => array("group_acl" => $access_id));
$groups = elgg_get_entities_from_metadata($group_options);
if (!empty($groups)) {
$group = $groups[0];
if ($group->thewire_enable == "no") {
// not allowed to post in this group
register_error(elgg_echo("thewire_tools:groups:error:not_enabled"));
// let creation of object fail
return false;
} else {
$container_guid = $group->getGUID();
}
}
}
}
// create the new post
$post = new ElggObject();
$post->subtype = "thewire";
$post->owner_guid = $userid;
$post->container_guid = $container_guid;
$post->access_id = $access_id;
// only xxx characters allowed (see plugin setting)
$text = elgg_substr($text, 0, thewire_tools_get_wire_length());
// no html tags allowed so we escape
$post->description = htmlspecialchars($text, ENT_NOQUOTES, "UTF-8");
$post->method = $method;
//method: site, email, api, ...
$tags = thewire_get_hashtags($text);
if (!empty($tags)) {
$post->tags = $tags;
}
// must do this before saving so notifications pick up that this is a reply
if ($parent_guid) {
$post->reply = true;
}
$guid = $post->save();
// set thread guid
if ($parent_guid) {
$post->addRelationship($parent_guid, "parent");
// name conversation threads by guid of first post (works even if first post deleted)
$parent_post = get_entity($parent_guid);
$post->wire_thread = $parent_post->wire_thread;
} else {
// first post in this thread
$post->wire_thread = $guid;
}
if ($guid) {
add_to_river("river/object/thewire/create", "create", $post->getOwnerGUID(), $post->getGUID());
// let other plugins know we are setting a user status
$params = array("entity" => $post, "user" => $post->getOwnerEntity(), "message" => $post->description, "url" => $post->getURL(), "origin" => "thewire");
elgg_trigger_plugin_hook("status", "user", $params);
}
return $guid;
}
示例8: thewire_save_post
/**
* Create a new wire post.
*
* @param string $text The post text
* @param int $userid The user's guid
* @param int $access_id Public/private etc
* @param int $parent_guid Parent post guid (if any)
* @param string $method The method (default: 'site')
* @return guid or false if failure
*/
function thewire_save_post($text, $userid, $access_id, $parent_guid = 0, $method = "site")
{
$post = new ElggObject();
$post->subtype = "thewire";
$post->owner_guid = $userid;
$post->access_id = $access_id;
// Character limit is now from config
$limit = elgg_get_plugin_setting('limit', 'thewire');
if ($limit > 0) {
$text = elgg_substr($text, 0, $limit);
}
// no html tags allowed so we escape
$post->description = htmlspecialchars($text, ENT_NOQUOTES, 'UTF-8');
$post->method = $method;
//method: site, email, api, ...
$tags = thewire_get_hashtags($text);
if ($tags) {
$post->tags = $tags;
}
// must do this before saving so notifications pick up that this is a reply
if ($parent_guid) {
$post->reply = true;
}
$guid = $post->save();
// set thread guid
if ($parent_guid) {
$post->addRelationship($parent_guid, 'parent');
// name conversation threads by guid of first post (works even if first post deleted)
$parent_post = get_entity($parent_guid);
$post->wire_thread = $parent_post->wire_thread;
} else {
// first post in this thread
$post->wire_thread = $guid;
}
if ($guid) {
elgg_create_river_item(array('view' => 'river/object/thewire/create', 'action_type' => 'create', 'subject_guid' => $post->owner_guid, 'object_guid' => $post->guid));
// let other plugins know we are setting a user status
$params = array('entity' => $post, 'user' => $post->getOwnerEntity(), 'message' => $post->description, 'url' => $post->getURL(), 'origin' => 'thewire');
elgg_trigger_plugin_hook('status', 'user', $params);
}
return $guid;
}
示例9: golfscore_post
function golfscore_post($user, $score, $golf_course)
{
$body = elgg_view('output/url', array('href' => "profile/{$user->username}", 'text' => $user->name, 'is_trusted' => true));
$body .= ' shot an ';
$body .= elgg_view('output/url', array('href' => "golfscore/view?golf_score_id={$score->golf_score_id}", 'text' => $score->total_score, 'is_trusted' => true));
$body .= " at ";
$body .= elgg_view('output/url', array('href' => "golfscore/all?golf_course_id={$golf_course->golf_course_id}", 'text' => $golf_course->course_name, 'is_trusted' => true));
$body .= " Course";
$access_id = ACCESS_PUBLIC;
$method = 'site';
$post = new ElggObject();
$post->subtype = "thewire";
$post->owner_guid = $user->guid;
$post->access_id = $access_id;
// only 200 characters allowed
// $text = elgg_substr($body, 0, 200);
$text = $body;
// no html tags allowed so we escape
$post->description = $text;
//htmlspecialchars($text, ENT_NOQUOTES, 'UTF-8');
$post->method = $method;
//method: site, email, api, ...
$tags = thewire_get_hashtags($text);
if ($tags) {
$post->tags = $tags;
}
$guid = $post->save();
// first post in this thread
$post->wire_thread = $guid;
if ($guid) {
add_to_river('river/object/thewire/create', 'create', $post->owner_guid, $post->guid);
// let other plugins know we are setting a user status
$params = array('entity' => $post, 'user' => $post->getOwnerEntity(), 'message' => $post->description, 'url' => $post->getURL(), 'origin' => 'thewire');
elgg_trigger_plugin_hook('status', 'user', $params);
}
//elgg_trigger_plugin_hook('thewire','post', array('body' => $body), false);
}
示例10: blog_url_handler
/**
* Format and return the URL for blogs.
*
* @param ElggObject $entity Blog object
* @return string URL of blog.
*/
function blog_url_handler($entity)
{
if (!$entity->getOwnerEntity()) {
// default to a standard view if no owner.
return FALSE;
}
$friendly_title = elgg_get_friendly_title($entity->title);
return "blog/view/{$entity->guid}/{$friendly_title}";
}
示例11: wire_save_post
/**
* Create a new wire post.
*
* @param string $text The post text
* @param int $userid The user's guid
* @param int $access_id Public/private etc
* @param int $parent_guid Parent post guid (if any)
* @param string $method The method (default: 'site')
* @return guid or false if failure
*/
function wire_save_post($text, $userid, $entity_guid, $access_id, $parent_guid = 0, $method = "site")
{
$post = new ElggObject();
$post->subtype = "wire";
$post->owner_guid = $userid;
$post->access_id = $access_id;
$post->entity_guid = $entity_guid;
// only 200 characters allowed
$text = elgg_substr($text, 0, 200);
// no html tags allowed so we escape
$post->description = htmlspecialchars($text, ENT_NOQUOTES, 'UTF-8');
$post->method = $method;
//method: site, email, api, ...
$tags = wire_get_hashtags($text);
if ($tags) {
$post->tags = $tags;
}
// must do this before saving so notifications pick up that this is a reply
if ($parent_guid) {
$post->reply = true;
}
$guid = $post->save();
// set thread guid
if ($parent_guid) {
$post->addRelationship($parent_guid, 'parent');
// name conversation threads by guid of first post (works even if first post deleted)
$parent_post = get_entity($parent_guid);
$post->wire_thread = $parent_post->wire_thread;
} else {
// first post in this thread
$post->wire_thread = $guid;
}
if ($guid) {
add_to_river('river/object/wire/create', 'create', $post->owner_guid, $post->guid);
// let other plugins know we are setting a user status
$params = array('entity' => $post, 'user' => $post->getOwnerEntity(), 'message' => $post->description, 'url' => $post->getURL(), 'origin' => 'wire');
elgg_trigger_plugin_hook('status', 'user', $params);
}
//fordebug register_error("in save entity_guid {$post->entity_guid}");
return $guid;
}
示例12: thewire_tools_save_post
/**
* Save a wire post, overrules the default function because we need to support groups
*
* @param string $text the text of the post
* @param int $userid the owner of the post
* @param int $access_id the access level of the post
* @param int $parent_guid is this a reply on another post
* @param string $method which method was used
* @param int $reshare_guid is the a (re)share of some content item
*
* @return bool|int the GUID of the new wire post or false
*/
function thewire_tools_save_post($text, $userid, $access_id, $parent_guid = 0, $method = "site", $reshare_guid = 0)
{
// set correct container
$container_guid = $userid;
// check the access id
if ($access_id == ACCESS_PRIVATE) {
// private wire posts aren't allowed
$access_id = ACCESS_LOGGED_IN;
} elseif (thewire_tools_groups_enabled()) {
// allow the saving of a wire post in a group (if enabled)
if (!in_array($access_id, [ACCESS_FRIENDS, ACCESS_LOGGED_IN, ACCESS_PUBLIC])) {
// try to find a group with access_id
$group_options = ['type' => 'group', 'limit' => 1, 'metadata_name_value_pairs' => ['group_acl' => $access_id]];
$groups = elgg_get_entities_from_metadata($group_options);
if (!empty($groups)) {
$group = $groups[0];
if ($group->thewire_enable == 'no') {
// not allowed to post in this group
register_error(elgg_echo('thewire_tools:groups:error:not_enabled'));
// let creation of object fail
return false;
} else {
$container_guid = $group->getGUID();
}
}
}
}
// create the new post
$post = new ElggObject();
$post->subtype = 'thewire';
$post->owner_guid = $userid;
$post->container_guid = $container_guid;
$post->access_id = $access_id;
// only xxx characters allowed (see plugin setting of thewire, 0 is unlimited)
$max_length = thewire_tools_get_wire_length();
if ($max_length) {
$text = elgg_substr($text, 0, $max_length);
}
// no html tags allowed so we escape
$post->description = htmlspecialchars($text, ENT_NOQUOTES, 'UTF-8');
$post->method = $method;
//method: site, email, api, ...
$tags = thewire_get_hashtags($text);
if (!empty($tags)) {
$post->tags = $tags;
}
// must do this before saving so notifications pick up that this is a reply
if ($parent_guid) {
$post->reply = true;
}
$guid = $post->save();
if ($guid) {
// set thread guid
if ($parent_guid) {
$post->addRelationship($parent_guid, 'parent');
// name conversation threads by guid of first post (works even if first post deleted)
$parent_post = get_entity($parent_guid);
$post->wire_thread = $parent_post->wire_thread;
} else {
// first post in this thread
$post->wire_thread = $guid;
}
// add reshare
if ($reshare_guid) {
$post->addRelationship($reshare_guid, 'reshare');
}
// add to river
elgg_create_river_item(['view' => 'river/object/thewire/create', 'action_type' => 'create', 'subject_guid' => $post->getOwnerGUID(), 'object_guid' => $post->getGUID()]);
// let other plugins know we are setting a user status
$params = ['entity' => $post, 'user' => $post->getOwnerEntity(), 'message' => $post->description, 'url' => $post->getURL(), 'origin' => 'thewire'];
elgg_trigger_plugin_hook('status', 'user', $params);
}
return $guid;
}