getGUID() public method

Returns the guid.
public getGUID ( ) : integer | null
return integer | null GUID
コード例 #1
0
 /**
  * Creates random annotations on $entity
  *
  * @param \ElggEntity $entity
  * @param int        $max
  */
 protected function createRandomAnnotations($entity, $max = 1)
 {
     $annotations = array();
     for ($i = 0; $i < $max; $i++) {
         $name = 'test_annotation_name_' . rand();
         $value = rand();
         $id = create_annotation($entity->getGUID(), $name, $value, 'integer', $entity->getGUID());
         $annotations[] = elgg_get_annotation_from_id($id);
     }
     return $annotations;
 }
コード例 #2
0
ファイル: Enqueue.php プロジェクト: coldtrick/tag_tools
 /**
  * After an entity is done with ->save() check if we need to enqueue it
  *
  * @param string      $event  the name of the event
  * @param string      $type   the type of the event
  * @param \ElggEntity $entity supplied param
  *
  * @return void
  */
 public static function afterEntityUpdate($event, $type, $entity)
 {
     if (!$entity instanceof \ElggEntity) {
         // not an entity, since we listen to 'all'
         return;
     }
     if (!isset($entity->tags)) {
         // no tags
         return;
     }
     if (!self::validateEntity($entity->getGUID())) {
         return;
     }
     self::enqueueEntity($entity->getGUID());
 }
コード例 #3
0
ファイル: pages.php プロジェクト: nogsus/Elgg
/**
 * Register the navigation menu
 * 
 * @param ElggEntity $container Container entity for the pages
 */
function pages_register_navigation_tree($container)
{
    if (!$container) {
        return;
    }
    $top_pages = elgg_get_entities(array('type' => 'object', 'subtype' => 'page_top', 'container_guid' => $container->getGUID(), 'limit' => 0));
    if (!$top_pages) {
        return;
    }
    foreach ($top_pages as $page) {
        elgg_register_menu_item('pages_nav', array('name' => $page->getGUID(), 'text' => $page->title, 'href' => $page->getURL()));
        $stack = array();
        array_push($stack, $page);
        while (count($stack) > 0) {
            $parent = array_pop($stack);
            $children = elgg_get_entities_from_metadata(array('type' => 'object', 'subtype' => 'page', 'metadata_name' => 'parent_guid', 'metadata_value' => $parent->getGUID(), 'limit' => 0));
            if ($children) {
                foreach ($children as $child) {
                    elgg_register_menu_item('pages_nav', array('name' => $child->getGUID(), 'text' => $child->title, 'href' => $child->getURL(), 'parent_name' => $parent->getGUID()));
                    array_push($stack, $child);
                }
            }
        }
    }
}
コード例 #4
0
ファイル: pages.php プロジェクト: tjcaverly/Elgg
/**
 * Produce the navigation tree
 * 
 * @param ElggEntity $container Container entity for the pages
 *
 * @return array
 */
function pages_get_navigation_tree($container)
{
    if (!$container) {
        return;
    }
    $top_pages = elgg_get_entities(array('type' => 'object', 'subtype' => 'page_top', 'container_guid' => $container->getGUID(), 'limit' => 0));
    if (!$top_pages) {
        return;
    }
    /* @var ElggObject[] $top_pages */
    $tree = array();
    $depths = array();
    foreach ($top_pages as $page) {
        $tree[] = array('guid' => $page->getGUID(), 'title' => $page->title, 'url' => $page->getURL(), 'depth' => 0);
        $depths[$page->guid] = 0;
        $stack = array();
        array_push($stack, $page);
        while (count($stack) > 0) {
            $parent = array_pop($stack);
            $children = elgg_get_entities_from_metadata(array('type' => 'object', 'subtype' => 'page', 'metadata_name' => 'parent_guid', 'metadata_value' => $parent->getGUID(), 'limit' => 0));
            if ($children) {
                foreach ($children as $child) {
                    $tree[] = array('guid' => $child->getGUID(), 'title' => $child->title, 'url' => $child->getURL(), 'parent_guid' => $parent->getGUID(), 'depth' => $depths[$parent->guid] + 1);
                    $depths[$child->guid] = $depths[$parent->guid] + 1;
                    array_push($stack, $child);
                }
            }
        }
    }
    return $tree;
}
コード例 #5
0
ファイル: Admin.php プロジェクト: coldtrick/admin_tools
 /**
  * listen to the remove admin event to unset the toggle admin flag
  *
  * @param string     $event  the event
  * @param string     $type   the type of the event
  * @param ElggEntity $entity the affected entity
  *
  * @return void
  */
 public static function removeAdmin($event, $type, $entity)
 {
     if (!$entity instanceof \ElggUser) {
         return;
     }
     elgg_unset_plugin_user_setting('switched_admin', $entity->getGUID(), 'admin_tools');
 }
コード例 #6
0
ファイル: ElggEntityTest.php プロジェクト: Twizanex/GuildWoW
 public function testElggEntityRecursiveDisableAndEnable()
 {
     global $CONFIG;
     $obj1 = new \ElggObject();
     $obj1->container_guid = $this->entity->getGUID();
     $obj1->save();
     $obj2 = new \ElggObject();
     $obj2->container_guid = $this->entity->getGUID();
     $obj2->save();
     // disable $obj2 before disabling the container
     $this->assertTrue($obj2->disable());
     // disable entities container by $this->entity
     $this->assertTrue($this->entity->disable());
     $entity = get_data_row("SELECT * FROM {$CONFIG->dbprefix}entities WHERE guid = '{$obj1->guid}'");
     $this->assertIdentical($entity->enabled, 'no');
     // enable entities that were disabled with the container (but not $obj2)
     $this->assertTrue($this->entity->enable());
     $entity = get_data_row("SELECT * FROM {$CONFIG->dbprefix}entities WHERE guid = '{$obj1->guid}'");
     $this->assertIdentical($entity->enabled, 'yes');
     $entity = get_data_row("SELECT * FROM {$CONFIG->dbprefix}entities WHERE guid = '{$obj2->guid}'");
     $this->assertIdentical($entity->enabled, 'no');
     // cleanup
     $this->assertTrue($obj2->enable());
     $this->assertTrue($obj2->delete());
     $this->assertTrue($obj1->delete());
 }
コード例 #7
0
ファイル: ElggEntityTest.php プロジェクト: ibou77/elgg
 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);
 }
コード例 #8
0
ファイル: ItemCollection.php プロジェクト: n8b/VMN
 /**
  * Get guids from an entity attribute
  *
  * @param ElggEntity|int $entity Entity or GUID
  * @return int
  */
 protected function toGUID($entity = null)
 {
     if ($entity instanceof ElggEntity) {
         return (int) $entity->getGUID();
     } else {
         if ($this->exists($entity)) {
             return (int) $entity;
         }
     }
     return false;
 }
コード例 #9
0
ファイル: ElggEntityTest.php プロジェクト: tjcaverly/Elgg
 /**
  * @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
0
ファイル: Event.php プロジェクト: thehereward/Elgg
 /**
  * Create a notification event
  *
  * @param \ElggData   $object The object of the event (\ElggEntity)
  * @param string      $action The name of the action (default: create)
  * @param \ElggEntity $actor  The entity that caused the event (default: logged in user)
  * 
  * @throws \InvalidArgumentException
  */
 public function __construct(\ElggData $object, $action, \ElggEntity $actor = null)
 {
     if (elgg_instanceof($object)) {
         $this->object_type = $object->getType();
         $this->object_subtype = $object->getSubtype();
         $this->object_id = $object->getGUID();
     } else {
         $this->object_type = $object->getType();
         $this->object_subtype = $object->getSubtype();
         $this->object_id = $object->id;
     }
     if ($actor == null) {
         $this->actor_guid = _elgg_services()->session->getLoggedInUserGuid();
     } else {
         $this->actor_guid = $actor->getGUID();
     }
     $this->action = $action;
 }
コード例 #11
0
ファイル: functions.php プロジェクト: pleio/subsite_manager
/**
 * Move an entity to a new site (can anly be call by subsite_manager_move_group_to_site())
 *
 * @param ElggEntity $entity            the entity to move
 * @param ElggSite   $target_site       the target site
 * @param array      $access_conversion array with group and site access levels
 *
 * @access private
 *
 * @return bool
 */
function subsite_manager_move_entity_to_site(ElggEntity $entity, ElggSite $target_site, array $access_conversion)
{
    static $newentity_cache;
    $backtrace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 2);
    if (!isset($backtrace[1])) {
        return false;
    }
    $function = elgg_extract("function", $backtrace[1]);
    if (empty($function) || !in_array($function, array("subsite_manager_move_group_to_site", "subsite_manager_move_entity_to_site"))) {
        // because this is a dangerous function only allow it to be called the correct way
        return false;
    }
    if (empty($entity) || !$entity instanceof ElggEntity) {
        return false;
    }
    if (empty($target_site) || !elgg_instanceof($target_site, "site")) {
        return false;
    }
    if ($entity->site_guid == $target_site->getGUID()) {
        return false;
    }
    // check for access conversion rules
    if (empty($access_conversion) || !is_array($access_conversion)) {
        return false;
    }
    $group_acl = (int) elgg_extract("group_acl", $access_conversion);
    if (empty($group_acl)) {
        return false;
    }
    $old_site_acl = (int) elgg_extract("site_acl", $access_conversion);
    $affected_access = array(ACCESS_PUBLIC, ACCESS_LOGGED_IN);
    if (!empty($old_site_acl)) {
        $affected_access[] = $old_site_acl;
    }
    // ignore access and show hidden entities
    $ia = elgg_set_ignore_access(true);
    $hidden = access_get_show_hidden_status();
    access_show_hidden_entities(true);
    // first move sub entities (eg blogs in group, event registrations, etc)
    $options = array("type" => "object", "container_guid" => $entity->getGUID(), "limit" => false);
    $batch = new ElggBatch("elgg_get_entities", $options);
    $batch->setIncrementOffset(false);
    foreach ($batch as $sub_entity) {
        if (!subsite_manager_move_entity_to_site($sub_entity, $target_site, $access_conversion)) {
            elgg_set_ignore_access($ia);
            access_show_hidden_entities($hidden);
            return false;
        }
    }
    // also move owned (sub) entities
    $options = array("type" => "object", "owner_guid" => $entity->getGUID(), "wheres" => array("(e.guid <> {$entity->getGUID()})"), "limit" => false);
    $batch = new ElggBatch("elgg_get_entities", $options);
    $batch->setIncrementOffset(false);
    foreach ($batch as $sub_entity) {
        if (!subsite_manager_move_entity_to_site($sub_entity, $target_site, $access_conversion)) {
            elgg_set_ignore_access($ia);
            access_show_hidden_entities($hidden);
            return false;
        }
    }
    $dbprefix = elgg_get_config("dbprefix");
    // move access collections
    $query = "UPDATE {$dbprefix}access_collections";
    $query .= " SET site_guid = {$target_site->getGUID()}";
    $query .= " WHERE owner_guid = {$entity->getGUID()}";
    try {
        update_data($query);
    } catch (Exception $e) {
        elgg_log("Subsite manager move entity({$entity->getGUID()}) access collections: " . $e->getMessage(), "ERROR");
        elgg_set_ignore_access($ia);
        access_show_hidden_entities($hidden);
        return false;
    }
    // move annotations
    $query = "UPDATE {$dbprefix}annotations";
    $query .= " SET site_guid = {$target_site->getGUID()}";
    $query .= " WHERE entity_guid = {$entity->getGUID()}";
    try {
        update_data($query);
    } catch (Exception $e) {
        elgg_log("Subsite manager move entity({$entity->getGUID()}) annotations: " . $e->getMessage(), "ERROR");
        elgg_set_ignore_access($ia);
        access_show_hidden_entities($hidden);
        return false;
    }
    // change annotation access
    $query = "UPDATE {$dbprefix}annotations";
    $query .= " SET access_id = {$group_acl}";
    $query .= " WHERE entity_guid = {$entity->getGUID()}";
    $query .= " AND access_id IN (" . implode(", ", $affected_access) . ")";
    try {
        update_data($query);
    } catch (Exception $e) {
        elgg_log("Subsite manager change entity({$entity->getGUID()}) annotation access: " . $e->getMessage(), "ERROR");
        elgg_set_ignore_access($ia);
        access_show_hidden_entities($hidden);
        return false;
    }
    // move river
    $query = "UPDATE {$dbprefix}river";
    $query .= " SET site_guid = {$target_site->getGUID()}";
    $query .= " WHERE subject_guid = {$entity->getGUID()}";
    $query .= " OR object_guid = {$entity->getGUID()}";
    try {
        update_data($query);
    } catch (Exception $e) {
        elgg_log("Subsite manager move entity({$entity->getGUID()}) river: " . $e->getMessage(), "ERROR");
        elgg_set_ignore_access($ia);
        access_show_hidden_entities($hidden);
        return false;
    }
    // change river access
    $query = "UPDATE {$dbprefix}river";
    $query .= " SET access_id = {$group_acl}";
    $query .= " WHERE (subject_guid = {$entity->getGUID()}";
    $query .= " OR object_guid = {$entity->getGUID()})";
    $query .= " AND access_id IN (" . implode(", ", $affected_access) . ")";
    try {
        update_data($query);
    } catch (Exception $e) {
        elgg_log("Subsite manager change entity({$entity->getGUID()}) river access: " . $e->getMessage(), "ERROR");
        elgg_set_ignore_access($ia);
        access_show_hidden_entities($hidden);
        return false;
    }
    // move metadata
    $query = "UPDATE {$dbprefix}metadata";
    $query .= " SET site_guid = {$target_site->getGUID()}";
    $query .= " WHERE entity_guid = {$entity->getGUID()}";
    try {
        update_data($query);
    } catch (Exception $e) {
        elgg_log("Subsite manager move entity({$entity->getGUID()}) metadata: " . $e->getMessage(), "ERROR");
        elgg_set_ignore_access($ia);
        access_show_hidden_entities($hidden);
        return false;
    }
    // change metadata access
    $query = "UPDATE {$dbprefix}metadata";
    $query .= " SET access_id = {$group_acl}";
    $query .= " WHERE entity_guid = {$entity->getGUID()}";
    $query .= " AND access_id IN (" . implode(", ", $affected_access) . ")";
    try {
        update_data($query);
    } catch (Exception $e) {
        elgg_log("Subsite manager change entity({$entity->getGUID()}) metadata access: " . $e->getMessage(), "ERROR");
        elgg_set_ignore_access($ia);
        access_show_hidden_entities($hidden);
        return false;
    }
    // move entity
    $query = "UPDATE {$dbprefix}entities";
    $query .= " SET site_guid = {$target_site->getGUID()}";
    $query .= " WHERE guid = {$entity->getGUID()}";
    try {
        update_data($query);
    } catch (Exception $e) {
        elgg_log("Subsite manager move entity({$entity->getGUID()}) entity: " . $e->getMessage(), "ERROR");
        elgg_set_ignore_access($ia);
        access_show_hidden_entities($hidden);
        return false;
    }
    // change entity access
    $query = "UPDATE {$dbprefix}entities";
    $query .= " SET access_id = {$group_acl}";
    $query .= " WHERE guid = {$entity->getGUID()}";
    $query .= " AND access_id IN (" . implode(", ", $affected_access) . ")";
    try {
        update_data($query);
    } catch (Exception $e) {
        elgg_log("Subsite manager change entity({$entity->getGUID()}) entity access: " . $e->getMessage(), "ERROR");
        elgg_set_ignore_access($ia);
        access_show_hidden_entities($hidden);
        return false;
    }
    // cache cleanup
    _elgg_invalidate_cache_for_entity($entity->getGUID());
    if (!$newentity_cache && is_memcache_available()) {
        $newentity_cache = new ElggMemcache('new_entity_cache');
    }
    if ($newentity_cache) {
        $newentity_cache->delete($entity->getGUID());
    }
    elgg_set_ignore_access($ia);
    access_show_hidden_entities($hidden);
    return true;
}
コード例 #12
0
ファイル: functions.php プロジェクト: coldtrick/pages_tools
/**
 * Clears tree html cache
 *
 * @param ElggEntity $entity the root entity to flush the cache for
 *
 * @return void
 */
function pages_tools_flush_tree_html_cache(ElggEntity $entity)
{
    if (!$entity instanceof ElggEntity) {
        return;
    }
    $locator = new Elgg_EntityDirLocator($entity->getGUID());
    $cache_dir = elgg_get_data_path() . $locator->getPath() . 'tree_cache/';
    $dh = opendir($cache_dir);
    if (empty($dh)) {
        return;
    }
    while (($filename = readdir($dh)) !== false) {
        // make sure we have a file
        if (!is_file($cache_dir . $filename)) {
            continue;
        }
        unlink($cache_dir . $filename);
    }
}
コード例 #13
0
ファイル: start.php プロジェクト: nogsus/Elgg
/**
 * Populates the ->getUrl() method for file objects
 *
 * @param ElggEntity $entity File entity
 * @return string File URL
 */
function file_url_override($entity)
{
    $title = $entity->title;
    $title = elgg_get_friendly_title($title);
    return "file/view/" . $entity->getGUID() . "/" . $title;
}
コード例 #14
0
ファイル: elgglib.php プロジェクト: eokyere/elgg
/**
 * Count the number of comments attached to an entity
 *
 * @param ElggEntity $entity
 * @return int Number of comments
 */
function elgg_count_comments($entity)
{
    if ($commentno = trigger_plugin_hook('comments:count', $entity->getType(), array('entity' => $entity), false)) {
        return $commentno;
    } else {
        return count_annotations($entity->getGUID(), "", "", "generic_comment");
    }
}
コード例 #15
0
ファイル: access.php プロジェクト: remy40/gvrs
/**
 * Can a user access an entity.
 *
 * @warning If a logged in user doesn't have access to an entity, the
 * core engine will not load that entity.
 *
 * @tip This is mostly useful for checking if a user other than the logged in
 * user has access to an entity that is currently loaded.
 *
 * @todo This function would be much more useful if we could pass the guid of the
 * entity to test access for. We need to be able to tell whether the entity exists
 * and whether the user has access to the entity.
 *
 * @param ElggEntity $entity The entity to check access for.
 * @param ElggUser   $user   Optionally user to check access for. Defaults to
 *                           logged in user (which is a useless default).
 *
 * @return bool
 * @link http://docs.elgg.org/Access
 */
function has_access_to_entity($entity, $user = null)
{
    global $CONFIG;
    if (!isset($user)) {
        $access_bit = get_access_sql_suffix("e");
    } else {
        $access_bit = get_access_sql_suffix("e", $user->getGUID());
    }
    $query = "SELECT guid from {$CONFIG->dbprefix}entities e WHERE e.guid = " . $entity->getGUID();
    // Add access controls
    $query .= " AND " . $access_bit;
    if (get_data($query)) {
        return true;
    } else {
        return false;
    }
}
コード例 #16
0
ファイル: MetadataTable.php プロジェクト: gzachos/elgg_ellak
 /**
  * When an entity is updated, resets the access ID on all of its child metadata
  *
  * @param string      $event       The name of the event
  * @param string      $object_type The type of object
  * @param \ElggEntity $object      The entity itself
  *
  * @return true
  * @access private Set as private in 1.9.0
  */
 function handleUpdate($event, $object_type, $object)
 {
     if ($object instanceof \ElggEntity) {
         if (!$this->isMetadataIndependent($object->getType(), $object->getSubtype())) {
             $access_id = (int) $object->access_id;
             $guid = (int) $object->getGUID();
             $query = "update {$this->table} set access_id = {$access_id} where entity_guid = {$guid}";
             $this->db->updateData($query);
         }
     }
     return true;
 }
コード例 #17
0
ファイル: tasks.php プロジェクト: epsylon/Hydra-dev
/**
 * Register the navigation menu
 * 
 * @param ElggEntity $container Container entity for the tasks
 */
function tasks_register_navigation_tree($container)
{
    if (!$container) {
        return;
    }
    $tasklists_top = elgg_get_entities_from_metadata(array('type' => 'object', 'subtype' => 'task', 'container_guid' => $container->getGUID(), 'metadata_name' => 'list_guid', 'metadata_value' => 0, 'limit' => 0));
    if (!$tasklists_top) {
        return;
    }
    foreach ($tasklists_top as $tasklist) {
        elgg_register_menu_item('tasks_nav', array('name' => $tasklist->getGUID(), 'text' => $tasklist->title, 'href' => $tasklist->getURL()));
        $stack = array();
        array_push($stack, $tasklist);
        while (count($stack) > 0) {
            $list = array_pop($stack);
            $tasklists = elgg_get_entities_from_metadata(array('type' => 'object', 'subtype' => 'task', 'metadata_name' => 'list_guid', 'metadata_value' => $list->guid, 'container_guid' => $container->getGUID(), 'limit' => 0));
            if ($tasklists) {
                foreach ($tasklists as $tasklist) {
                    elgg_register_menu_item('tasks_nav', array('name' => $tasklist->getGUID(), 'text' => $tasklist->title, 'href' => $tasklist->getURL(), 'parent_name' => $list->getGUID()));
                    array_push($stack, $tasklist);
                }
            }
        }
    }
}
コード例 #18
0
ファイル: functions.php プロジェクト: coldtrick/static
/**
 * Checks if the user is a moderator of any item in the given container
 *
 * @param ElggEntity $container_entity container entity to check in
 * @param ElggUser   $user             user to check
 *
 * @return boolean
 */
function static_is_moderator_in_container(ElggEntity $container_entity, ElggUser $user)
{
    if (empty($container_entity) || empty($user)) {
        return false;
    }
    $dbprefix = elgg_get_config('dbprefix');
    $ia = elgg_set_ignore_access(true);
    $md = elgg_get_metadata(['selects' => ['msv.string as value'], 'metadata_names' => ['moderators'], 'limit' => false, 'joins' => ["JOIN {$dbprefix}metastrings msv ON n_table.value_id = msv.id", "JOIN {$dbprefix}entities e ON n_table.entity_guid = e.guid"], 'wheres' => ['msv.string <> ""', 'e.type = "object" AND e.subtype = ' . get_subtype_id('object', 'static'), 'e.container_guid = ' . $container_entity->getGUID()], 'callback' => function ($row) {
        $value = $row->value;
        if (!empty($value)) {
            return $value;
        }
    }]);
    elgg_set_ignore_access($ia);
    return in_array($user->getGUID(), $md);
}
コード例 #19
0
ファイル: functions.php プロジェクト: pleio/event_manager
/**
 * Send registration validation email
 * 
 * @param Event      $event  event
 * @param ElggEntity $entity object or user to send mail to
 * 
 * @return void
 */
function event_manager_send_registration_validation_email(Event $event, ElggEntity $entity)
{
    $subject = elgg_echo("event_manager:registration:confirm:subject", array($event->title));
    $message = elgg_echo("event_manager:registration:confirm:message", array($entity->name, $event->title, event_manager_get_registration_validation_url($event->getGUID(), $entity->getGUID())));
    $site = elgg_get_site_entity();
    // send confirmation mail
    if (elgg_instanceof($entity, "user")) {
        notify_user($entity->getGUID(), $event->getOwnerGUID(), $subject, $message, null, "email");
    } else {
        $from = $site->email;
        if (empty($from)) {
            $from = "noreply@" . $site->getDomain();
        }
        if (!empty($site->name)) {
            $site_name = $site->name;
            if (strstr($site_name, ',')) {
                $site_name = '"' . $site_name . '"';
                // Protect the name with quotations if it contains a comma
            }
            $site_name = '=?UTF-8?B?' . base64_encode($site_name) . '?=';
            // Encode the name. If may content nos ASCII chars.
            $from = $site_name . " <" . $from . ">";
        }
        elgg_send_email($from, $entity->email, $subject, $message);
    }
}
コード例 #20
0
ファイル: Cache.php プロジェクト: coldtrick/static
 /**
  * Reads cached menu items from file for give root entity
  *
  * @param \ElggEntity $root_entity root entity to fetch the cache from
  *
  * @return array
  */
 public static function getMenuItemsCache(\ElggEntity $root_entity)
 {
     $static_items = [];
     $file = new \ElggFile();
     $file->owner_guid = $root_entity->getGUID();
     $file->setFilename('static_menu_item_cache');
     if ($file->exists()) {
         $static_items = unserialize($file->grabFile());
     }
     return $static_items;
 }
コード例 #21
0
ファイル: start.php プロジェクト: redvabel/Vabelgg
/**
 * Populates the ->getUrl() method for bookmarked objects
 *
 * @param ElggEntity $entity The bookmarked object
 * @return string bookmarked item URL
 */
function bookmark_url($entity)
{
    global $CONFIG;
    $title = $entity->title;
    $title = elgg_get_friendly_title($title);
    return $CONFIG->url . "bookmarks/view/" . $entity->getGUID() . "/" . $title;
}
コード例 #22
0
ファイル: start.php プロジェクト: hejosadi/PiGo-LMS
/**
 * Override the default URL for question object
 *
 * @param ElggEntity $question
 * @return string
 */
function question_url($question)
{
    $title = $question->title;
    $title = elgg_get_friendly_title($title);
    return elgg_get_site_url() . "answers/view/" . $question->getGUID() . "/" . $title;
}
コード例 #23
0
ファイル: entities.php プロジェクト: n8b/VMN
/**
 * Cache an entity.
 *
 * Stores an entity in $ENTITY_CACHE;
 *
 * @param \ElggEntity $entity Entity to cache
 *
 * @return void
 * @see _elgg_retrieve_cached_entity()
 * @see _elgg_invalidate_cache_for_entity()
 * @access private
 * @todo Use an \ElggCache object
 */
function _elgg_cache_entity(\ElggEntity $entity)
{
    global $ENTITY_CACHE, $ENTITY_CACHE_DISABLED_GUIDS;
    // Don't cache non-plugin entities while access control is off, otherwise they could be
    // exposed to users who shouldn't see them when control is re-enabled.
    if (!$entity instanceof \ElggPlugin && elgg_get_ignore_access()) {
        return;
    }
    $guid = $entity->getGUID();
    if (isset($ENTITY_CACHE_DISABLED_GUIDS[$guid])) {
        return;
    }
    // Don't store too many or we'll have memory problems
    // @todo Pick a less arbitrary limit
    if (count($ENTITY_CACHE) > 256) {
        _elgg_invalidate_cache_for_entity(array_rand($ENTITY_CACHE));
    }
    $ENTITY_CACHE[$guid] = $entity;
}
コード例 #24
0
ファイル: start.php プロジェクト: eokyere/elgg
/**
 * Populates the ->getUrl() method for blog objects
 *
 * @param ElggEntity $blogpost Blog post entity
 * @return string Blog post URL
 */
function blog_url($blogpost)
{
    global $CONFIG;
    $title = $blogpost->title;
    $title = friendly_title($title);
    return $CONFIG->url . "pg/blog/" . $blogpost->getOwnerEntity()->username . "/read/" . $blogpost->getGUID() . "/" . $title;
}
コード例 #25
0
ファイル: start.php プロジェクト: eokyere/elgg
/**
 * Populates the ->getUrl() method for file objects
 *
 * @param ElggEntity $entity File entity
 * @return string File URL
 */
function file_url($entity)
{
    global $CONFIG;
    $title = $entity->title;
    $title = friendly_title($title);
    return $CONFIG->url . "pg/file/" . $entity->getOwnerEntity()->username . "/read/" . $entity->getGUID() . "/" . $title;
}
コード例 #26
0
/**
 * Check if the user gets notifications from the group, based on notification settings
 *
 * @param ElggEntity $container           the container to check (only act on ElggGroups)
 * @param int        $user_guid           the user to check (defaults to current user)
 * @param bool       $return_subscription return the subscription settings
 *
 * @return bool
 */
function content_subscriptions_check_notification_settings(ElggEntity $container, $user_guid = 0, $return_subscription = false)
{
    static $user_cache;
    $user_guid = sanitise_int($user_guid, false);
    if (empty($user_guid)) {
        $user_guid = elgg_get_logged_in_user_guid();
    }
    // only check groups
    if ($container instanceof ElggGroup && !empty($user_guid)) {
        if (!isset($user_cache[$container->getGUID()])) {
            $user_cache[$container->getGUID()] = elgg_get_subscriptions_for_container($container->getGUID());
        }
        if ($return_subscription) {
            return $user_cache[$container->getGUID()][$user_guid];
        } else {
            return isset($user_cache[$container->getGUID()][$user_guid]);
        }
    }
    return false;
}
コード例 #27
0
ファイル: comments.php プロジェクト: Twizanex/GuildWoW
/**
 * Update comment access to match that of the container
 * 
 * @param string     $event  'update:after'
 * @param string     $type   'all'
 * @param ElggEntity $entity The updated entity
 * @return bool
 * 
 * @access private
 */
function _elgg_comments_access_sync($event, $type, $entity)
{
    if (!$entity instanceof \ElggEntity) {
        return true;
    }
    // need to override access in case comments ended up with ACCESS_PRIVATE
    // and to ensure write permissions
    $ia = elgg_set_ignore_access(true);
    $options = array('type' => 'object', 'subtype' => 'comment', 'container_guid' => $entity->getGUID(), 'wheres' => array("e.access_id != {$entity->access_id}"), 'limit' => 0);
    $batch = new \ElggBatch('elgg_get_entities', $options, null, 25, false);
    foreach ($batch as $comment) {
        // Update comment access_id
        $comment->access_id = $entity->access_id;
        $comment->save();
    }
    elgg_set_ignore_access($ia);
    return true;
}
コード例 #28
0
ファイル: functions.php プロジェクト: coldtrick/event_manager
/**
 * Send registration validation email
 *
 * @param Event      $event  event
 * @param ElggEntity $entity object or user to send mail to
 *
 * @return void
 */
function event_manager_send_registration_validation_email(Event $event, ElggEntity $entity)
{
    $subject = elgg_echo('event_manager:registration:confirm:subject', [$event->title]);
    $message = elgg_echo('event_manager:registration:confirm:message', [$entity->name, $event->title, event_manager_get_registration_validation_url($event->getGUID(), $entity->getGUID())]);
    $site = elgg_get_site_entity();
    // send confirmation mail
    if (elgg_instanceof($entity, 'user')) {
        notify_user($entity->getGUID(), $event->getOwnerGUID(), $subject, $message, null, 'email');
    } else {
        $from = $site->email;
        if (empty($from)) {
            $from = 'noreply@' . $site->getDomain();
        }
        if (!empty($site->name)) {
            $site_name = $site->name;
            if (strstr($site_name, ',')) {
                $site_name = '"' . $site_name . '"';
                // Protect the name with quotations if it contains a comma
            }
            $from = $site_name . " <" . $from . ">";
        }
        elgg_send_email($from, $entity->email, $subject, $message);
    }
}
コード例 #29
0
/**
 * When an entity is updated, resets the access ID on all of its child metadata
 *
 * @param string     $event       The name of the event
 * @param string     $object_type The type of object
 * @param ElggEntity $object      The entity itself
 *
 * @return true
 * @access private Set as private in 1.9.0
 */
function metadata_update($event, $object_type, $object)
{
    if ($object instanceof ElggEntity) {
        if (!is_metadata_independent($object->getType(), $object->getSubtype())) {
            $db_prefix = elgg_get_config('dbprefix');
            $access_id = (int) $object->access_id;
            $guid = (int) $object->getGUID();
            $query = "update {$db_prefix}metadata set access_id = {$access_id} where entity_guid = {$guid}";
            update_data($query);
        }
    }
    return true;
}
コード例 #30
0
ファイル: start.php プロジェクト: nohup/community_plugins
/**
 * Handles plugin project URLs
 *
 * @param ElggEntity $entity
 * @return string
 */
function plugins_project_url_handler($entity)
{
    global $CONFIG;
    $title = $entity->title;
    $title = friendly_title($title);
    return $CONFIG->url . "pg/plugins/project/{$entity->getGUID()}/developer/{$entity->getOwnerEntity()->username}/{$title}";
}