本文整理汇总了PHP中ElggEntity::getSubtype方法的典型用法代码示例。如果您正苦于以下问题:PHP ElggEntity::getSubtype方法的具体用法?PHP ElggEntity::getSubtype怎么用?PHP ElggEntity::getSubtype使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ElggEntity
的用法示例。
在下文中一共展示了ElggEntity::getSubtype方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: canReshareEntity
/**
* Check if resharing of this entity is allowed
*
* @param \ElggEntity $entity the entity to check
*
* @return bool
*/
protected static function canReshareEntity(\ElggEntity $entity)
{
if (!$entity instanceof \ElggEntity) {
return false;
}
// only allow objects and groups
if (!$entity instanceof \ElggObject && !$entity instanceof \ElggGroup) {
return false;
}
// comments and discussion replies are never allowed
$blocked_subtypes = ['comment', 'discussion_reply'];
if (in_array($entity->getSubtype(), $blocked_subtypes)) {
return false;
}
// by default allow searchable entities
$reshare_allowed = false;
if ($entity instanceof \ElggGroup) {
$reshare_allowed = true;
} else {
$searchable_entities = get_registered_entity_types($entity->getType());
if (!empty($searchable_entities)) {
$reshare_allowed = in_array($entity->getSubtype(), $searchable_entities);
}
}
// trigger hook to allow others to change
$params = ['entity' => $entity, 'user' => elgg_get_logged_in_user_entity()];
return (bool) elgg_trigger_plugin_hook('reshare', $entity->getType(), $params, $reshare_allowed);
}
示例2: testGetSubtype
public function testGetSubtype()
{
$guid = $this->entity->guid;
$this->assertEqual($this->entity->getSubtype(), 'elgg_entity_test_subtype');
_elgg_invalidate_cache_for_entity($guid);
$this->entity = null;
$this->entity = get_entity($guid);
$this->assertEqual($this->entity->getSubtype(), 'elgg_entity_test_subtype');
}
示例3: actions_feature_is_allowed_type
/**
* Check if entity type is registered for feature/unfeature
*
* @param ElggEntity $entity Entity to be featured
* @return bool
*/
function actions_feature_is_allowed_type(ElggEntity $entity)
{
$type = $entity->getType();
$subtype = $entity->getSubtype();
$hook_type = implode(':', array_filter([$type, $subtype]));
return elgg_trigger_plugin_hook('feature', $hook_type, ['entity' => $entity], false);
}
示例4: advanced_notifications_is_registered_notification_entity
/**
* Checks if the given $entity is registered for notifications by
* register_notification_object()
*
* @param ElggEntity $entity the entity to check
* @param bool $subject return the subject string (default=false)
*
* @return bool|string
*/
function advanced_notifications_is_registered_notification_entity(ElggEntity $entity, $subject = false)
{
$result = false;
if (!empty($entity) && $entity instanceof ElggEntity) {
$type = $entity->getType();
if (empty($type)) {
$type = "__BLANK__";
}
$subtype = $entity->getSubtype();
if (empty($subtype)) {
$subtype = "__BLANK__";
}
// get the registered entity -> type/subtype
$notifications = elgg_get_config("register_objects");
if (!empty($notifications) && is_array($notifications)) {
if (isset($notifications[$type]) && isset($notifications[$type][$subtype])) {
if ($subject) {
$result = $notifications[$type][$subtype];
} else {
$result = true;
}
}
}
}
return $result;
}
示例5: testSimpleGetters
public function testSimpleGetters()
{
$this->obj->type = 'foo';
$this->obj->subtype = 'subtype';
$this->obj->owner_guid = 77;
$this->obj->access_id = 2;
$this->obj->time_created = 123456789;
$this->assertEquals($this->obj->getGUID(), $this->obj->guid);
$this->assertEquals($this->obj->getType(), $this->obj->type);
// Note: before save() subtype returns string, int after
// see https://github.com/Elgg/Elgg/issues/5920#issuecomment-25246298
$this->assertEquals($this->obj->getSubtype(), $this->obj->subtype);
$this->assertEquals($this->obj->getOwnerGUID(), $this->obj->owner_guid);
$this->assertEquals($this->obj->getAccessID(), $this->obj->access_id);
$this->assertEquals($this->obj->getTimeCreated(), $this->obj->time_created);
$this->assertEquals($this->obj->getTimeUpdated(), $this->obj->time_updated);
}
示例6: Build
/**
* @param \ElggEntity $entity
* @return bool|notification
*/
public function Build($entity)
{
switch ($entity->getSubtype()) {
case 'sub_comment_notification':
return new \WizmassNotifier\Notifications\SubCommentNotification($entity);
case 'rate_comment_notification':
return new \WizmassNotifier\Notifications\RateCommentNotification($entity);
default:
return false;
}
}
示例7: getObjectType
/**
* Prepares object type string
* @return string
*/
public function getObjectType()
{
$type = $this->object->getType();
$subtype = $this->object->getSubtype() ?: 'default';
$keys = ["interactions:{$type}:{$subtype}", $this->object instanceof Comment ? "interactions:comment" : "interactions:post"];
foreach ($keys as $key) {
if (elgg_language_key_exists($key, $this->language)) {
return elgg_echo($key, array(), $this->language);
}
}
return elgg_echo('interactions:post', $this->language);
}
示例8: hj_framework_set_entity_priority
/**
* Set priority of an element in a list
*
* @see ElggEntity::$priority
*
* @param ElggEntity $entity
* @return bool
*/
function hj_framework_set_entity_priority($entity, $priority = null)
{
if ($priority) {
$entity->priority = $priority;
return true;
}
$count = elgg_get_entities(array('type' => $entity->getType(), 'subtype' => $entity->getSubtype(), 'owner_guid' => $entity->owner_guid, 'container_guid' => $entity->container_guid, 'count' => true));
if (!$entity->priority) {
$entity->priority = $count + 1;
}
return true;
}
示例9: testSimpleGetters
/**
* @requires PHP 5.3.2
*/
public function testSimpleGetters()
{
$this->obj->type = 'foo';
$this->obj->subtype = 'subtype';
$this->obj->owner_guid = 77;
$this->obj->access_id = 2;
$this->obj->time_created = 123456789;
$this->assertEquals($this->obj->getGUID(), $this->obj->guid);
$this->assertEquals($this->obj->getType(), $this->obj->type);
$this->assertEquals($this->obj->getSubtype(), $this->obj->subtype);
$this->assertEquals($this->obj->getOwnerGUID(), $this->obj->owner_guid);
$this->assertEquals($this->obj->getAccessID(), $this->obj->access_id);
$this->assertEquals($this->obj->getTimeCreated(), $this->obj->time_created);
$this->assertEquals($this->obj->getTimeUpdated(), $this->obj->time_updated);
}
示例10: getValues
/**
* {@inheritdoc}
*/
public function getValues(\ElggEntity $entity)
{
$sticky = $this->getStickyValue();
if ($sticky) {
return $sticky;
}
$name = $this->getShortname();
switch ($name) {
default:
return $entity->{$name} ?: $this->getDefaultValue();
case 'type':
return $entity->getType();
case 'subtype':
return $entity->getSubtype();
}
}
示例11: events
/**
* Track certain events on ElggEntity's
*
* @param string $event the event
* @param string $type the type of the ElggEntity
* @param \ElggEntity $object the entity for the event
*
* @return void
*/
public static function events($event, $type, $object)
{
if (!$object instanceof \ElggEntity) {
return;
}
if (!analytics_google_track_events_enabled()) {
return;
}
switch ($object->getType()) {
case 'object':
analytics_track_event($object->getSubtype(), $event, $object->title);
break;
case 'group':
case 'user':
analytics_track_event($object->getType(), $event, $object->name);
break;
}
}
示例12: evan_user_can
function evan_user_can($verb, Entity $object, Entity $target = NULL)
{
switch ($verb) {
case 'post':
if (!$target) {
$target = elgg_get_logged_in_user_entity();
}
$result = $target->canWriteToContainer(0, $object->getType(), $object->getSubtype());
break;
case 'update':
$result = $object->canEdit();
break;
default:
$result = false;
break;
}
return elgg_trigger_plugin_hook("permission", $verb, array('actor' => elgg_get_logged_in_user_entity(), 'verb' => $verb, 'object' => $object, 'target' => $target), $result);
}
示例13: send_custom_notifications
/**
* Listen to the 'publish','object' event and send out notifications
* to interested users, as well as anyone tagged
*
* @param string $event Equals 'publish'
* @param string $entity_type Equals 'object'
* @param ElggEntity $entity Published entity
*/
function send_custom_notifications($event, $entity_type, $entity)
{
if ($entity->origin !== 'wall') {
return true;
}
// We only want to notify about wire posts and wall posts, all content created therewith is implied
$accepted_subtypes = array('hjwall', 'thewire');
if (!in_array($entity->getSubtype(), $accepted_subtypes)) {
return true;
}
$poster = $entity->getOwnerEntity();
$container = $entity->getContainerEntity();
$message = format_wall_message($entity, true);
$sent = array(elgg_get_logged_in_user_guid(), $poster->guid, $container->guid);
// Notify wall owner
if ($poster->guid !== $container->guid && elgg_instanceof($container, 'user')) {
$to = $container->guid;
$from = $poster->guid;
$target = elgg_echo("wall:target:{$entity->getSubtype()}");
$ownership = elgg_echo('wall:ownership:your', array($target));
$subject = elgg_echo('wall:new:notification:subject', array($poster->name, $ownership));
$summary = elgg_view('output/url', array('text' => $subject, 'href' => $entity->getURL()));
$body = elgg_echo('wall:new:notification:message', array($poster->name, $ownership, $message, $entity->getURL()));
notify_user($to, $from, $subject, $body, array('summary' => $summary, 'object' => $entity, 'action' => 'received'));
}
// Notify tagged users
$tagged_friends = get_tagged_friends($entity);
foreach ($tagged_friends as $tagged_friend) {
// user tagged herself or the wall owner
if ($tagged_friend->guid == $poster->guid || $tagged_friend->guid == $container->guid || in_array($tagged_friend->guid, $sent)) {
continue;
}
$sent[] = $tagged_friend->guid;
$to = $tagged_friend->guid;
$from = $poster->guid;
$subject = elgg_echo('wall:tagged:notification:subject', array($poster->name));
$summary = elgg_view('output/url', array('text' => $subject, 'href' => $entity->getURL()));
$body = elgg_echo('wall:tagged:notification:message', array($poster->name, $message, $entity->getURL()));
notify_user($to, $from, $subject, $body, array('summary' => $summary, 'object' => $entity, 'action' => 'tagged'));
}
return true;
}
示例14: content_subscriptions_can_subscribe
/**
* Checks if a user can subscribe to a content item
*
* @param ElggEntity $entity the entity to check
* @param int $user_guid the user to check (default: current user)
*
* @return bool
*/
function content_subscriptions_can_subscribe(ElggEntity $entity, $user_guid = 0)
{
$user_guid = sanitise_int($user_guid, false);
if (empty($user_guid)) {
$user_guid = elgg_get_logged_in_user_guid();
}
if (empty($user_guid) || !$entity instanceof ElggEntity) {
return false;
}
if ($entity->getOwnerGUID() === $user_guid) {
// owner cant subscribe to own content
return false;
}
$supported_entity_types = content_subscriptions_get_supported_entity_types();
if (empty($supported_entity_types)) {
return false;
}
$type = $entity->getType();
if (!isset($supported_entity_types[$type])) {
return false;
}
$subtype = $entity->getSubtype();
if (!empty($subtype)) {
return in_array($subtype, $supported_entity_types[$type]);
}
return true;
}
示例15: _elgg_create_default_widgets
/**
* Creates default widgets
*
* This plugin hook handler is registered for events based on what kinds of
* default widgets have been registered. See elgg_default_widgets_init() for
* information on registering new default widget contexts.
*
* @param string $event The event
* @param string $type The type of object
* @param \ElggEntity $entity The entity being created
* @return void
* @access private
*/
function _elgg_create_default_widgets($event, $type, $entity)
{
$default_widget_info = elgg_get_config('default_widget_info');
if (!$default_widget_info || !$entity) {
return;
}
$type = $entity->getType();
$subtype = $entity->getSubtype();
// event is already guaranteed by the hook registration.
// need to check subtype and type.
foreach ($default_widget_info as $info) {
if ($info['entity_type'] == $type) {
if ($info['entity_subtype'] == ELGG_ENTITIES_ANY_VALUE || $info['entity_subtype'] == $subtype) {
// need to be able to access everything
$old_ia = elgg_set_ignore_access(true);
elgg_push_context('create_default_widgets');
// pull in by widget context with widget owners as the site
// not using elgg_get_widgets() because it sorts by columns and we don't care right now.
$options = array('type' => 'object', 'subtype' => 'widget', 'owner_guid' => elgg_get_site_entity()->guid, 'private_setting_name' => 'context', 'private_setting_value' => $info['widget_context'], 'limit' => 0);
$widgets = elgg_get_entities_from_private_settings($options);
/* @var \ElggWidget[] $widgets */
foreach ($widgets as $widget) {
// change the container and owner
$new_widget = clone $widget;
$new_widget->container_guid = $entity->guid;
$new_widget->owner_guid = $entity->guid;
// pull in settings
$settings = get_all_private_settings($widget->guid);
foreach ($settings as $name => $value) {
$new_widget->{$name} = $value;
}
$new_widget->save();
}
elgg_set_ignore_access($old_ia);
elgg_pop_context();
}
}
}
}