当前位置: 首页>>代码示例>>PHP>>正文


PHP elgg_get_metadata_from_id函数代码示例

本文整理汇总了PHP中elgg_get_metadata_from_id函数的典型用法代码示例。如果您正苦于以下问题:PHP elgg_get_metadata_from_id函数的具体用法?PHP elgg_get_metadata_from_id怎么用?PHP elgg_get_metadata_from_id使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了elgg_get_metadata_from_id函数的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: unserialize

 /**
  * Unserializes the event object stored in the database
  *
  * @param string $serialized Serialized string
  * @return string
  */
 public function unserialize($serialized)
 {
     $data = unserialize($serialized);
     if (isset($data->action)) {
         $this->action = $data->action;
     }
     if (isset($data->object_id) && isset($data->object_type)) {
         switch ($data->object_type) {
             case 'object':
             case 'user':
             case 'group':
             case 'site':
                 $this->object = get_entity($data->object_id);
                 break;
             case 'annotation':
                 $this->object = elgg_get_annotation_from_id($data->object_id);
                 break;
             case 'metadata':
                 $this->object = elgg_get_metadata_from_id($data->object_id);
                 break;
             case 'relationship':
                 $this->object = get_relationship($data->object_id);
         }
     }
     if (isset($data->actor_guid)) {
         $this->actor = get_entity($data->actor_guid);
     }
 }
开发者ID:elgg,项目名称:elgg,代码行数:34,代码来源:EventSerialization.php

示例2: get

 /**
  * {@inheritdoc}
  */
 public function get($uid = '')
 {
     switch ($uid) {
         case 'me':
             $uid = "ue" . elgg_get_logged_in_user_guid();
             break;
         case 'site':
             $uid = "se" . elgg_get_site_entity()->guid;
             break;
     }
     $abbr = substr($uid, 0, 2);
     switch ($abbr) {
         case 'an':
             $id = (int) substr($uid, 2);
             $object = elgg_get_annotation_from_id($id);
             break;
         case 'md':
             $id = (int) substr($uid, 2);
             $object = elgg_get_metadata_from_id($id);
             break;
         case 'rl':
             $id = (int) substr($uid, 2);
             $object = get_relationship($id);
             break;
         case 'rv':
             $id = (int) substr($uid, 2);
             $river = elgg_get_river(array('ids' => sanitize_int($id)));
             $object = $river ? $river[0] : false;
             break;
         case 'ue':
         case 'se':
         case 'oe':
         case 'ge':
             $id = (int) substr($uid, 2);
             $object = get_entity($id);
             break;
         default:
             $object = get_user_by_username($uid);
             if (!$object && is_numeric($uid)) {
                 $object = get_entity($uid);
             }
     }
     if (!$this->isExportable($object)) {
         return false;
     }
     return $object;
 }
开发者ID:hypejunction,项目名称:hypeapps,代码行数:50,代码来源:Graph.php

示例3: get_metadata

/**
 * Get a specific metadata object.
 *
 * @param int $id The id of the metadata being retrieved.
 *
 * @return mixed False on failure or ElggMetadata
 * @deprecated 1.8 Use elgg_get_metadata_from_id()
 */
function get_metadata($id)
{
    elgg_deprecated_notice('get_metadata() is deprecated by elgg_get_metadata_from_id()', 1.8);
    return elgg_get_metadata_from_id($id);
}
开发者ID:elainenaomi,项目名称:labxp2014,代码行数:13,代码来源:deprecated-1.8.php

示例4: getObjectFromID

 /**
  * For a given ID, return the object associated with it.
  * This is used by the river functionality primarily.
  * This is useful for checking access permissions etc on objects.
  *
  * @param int $id Metadata ID
  *
  * @return ElggMetadata
  */
 public function getObjectFromID($id)
 {
     return elgg_get_metadata_from_id($id);
 }
开发者ID:redvabel,项目名称:Vabelgg,代码行数:13,代码来源:ElggMetadata.php

示例5: get_metadata_url

/**
 * Get the URL for this metadata
 *
 * By default this links to the export handler in the current view.
 *
 * @param int $id Metadata ID
 *
 * @return mixed
 */
function get_metadata_url($id)
{
    $id = (int) $id;
    if ($extender = elgg_get_metadata_from_id($id)) {
        return $extender->getURL();
    }
    return false;
}
开发者ID:nooshin-mirzadeh,项目名称:web_2.0_benchmark,代码行数:17,代码来源:metadata.php

示例6: elgg_get_metadata_from_id

         if (!$v) {
             $msg = "Sorry, '" . $id_or_name . "' does not exist for guid:" . $guid;
             throw new \InvalidParameterException($msg);
         }
         $m = new \ElggMetadata();
         $m->value = $v;
         $m->name = $id_or_name;
         $m->entity_guid = $guid;
         $m->time_created = $entity->time_created;
         $m->time_updated = $entity->time_updated;
         $m->owner_guid = $entity->owner_guid;
         $m->id = $id_or_name;
         $m->type = "attr";
         break;
     case 'metadata':
         $m = elgg_get_metadata_from_id($id_or_name);
         break;
     case 'annotation':
         $m = elgg_get_annotation_from_id($id_or_name);
         break;
     case 'relationship':
         $r = get_relationship($id_or_name);
         break;
     case 'volatile':
         $m = elgg_trigger_plugin_hook('volatile', 'metadata', array('guid' => $guid, 'varname' => $id_or_name));
         break;
     default:
         $msg = "Sorry, I don't know how to export '" . $type . "'";
         throw new \InvalidParameterException($msg);
 }
 // Render metadata or relationship
开发者ID:ibou77,项目名称:elgg,代码行数:31,代码来源:export_handler.php

示例7: test_elgg_metadata_multiple_values

 public function test_elgg_metadata_multiple_values()
 {
     $u1 = new ElggUser();
     $u1->username = rand();
     $u1->save();
     $u2 = new ElggUser();
     $u2->username = rand();
     $u2->save();
     $obj = new ElggObject();
     $obj->owner_guid = $u1->guid;
     $obj->container_guid = $u1->guid;
     $obj->access_id = ACCESS_PUBLIC;
     $obj->save();
     $md_values = array('one', 'two', 'three');
     // need to fake different logins.
     // good times without mocking.
     $original_user = elgg_get_logged_in_user_entity();
     $_SESSION['user'] = $u1;
     elgg_set_ignore_access(false);
     // add metadata as one user
     $obj->test = $md_values;
     // check only these md exists
     $db_prefix = elgg_get_config('dbprefix');
     $q = "SELECT * FROM {$db_prefix}metadata WHERE entity_guid = {$obj->guid}";
     $data = get_data($q);
     $this->assertEqual(count($md_values), count($data));
     foreach ($data as $md_row) {
         $md = elgg_get_metadata_from_id($md_row->id);
         $this->assertTrue(in_array($md->value, $md_values));
         $this->assertEqual('test', $md->name);
     }
     // add md w/ same name as a different user
     $_SESSION['user'] = $u2;
     $md_values2 = array('four', 'five', 'six', 'seven');
     $obj->test = $md_values2;
     $q = "SELECT * FROM {$db_prefix}metadata WHERE entity_guid = {$obj->guid}";
     $data = get_data($q);
     $this->assertEqual(count($md_values2), count($data));
     foreach ($data as $md_row) {
         $md = elgg_get_metadata_from_id($md_row->id);
         $this->assertTrue(in_array($md->value, $md_values2));
         $this->assertEqual('test', $md->name);
     }
     $_SESSION['user'] = $original_user;
     $obj->delete();
     $u1->delete();
     $u2->delete();
 }
开发者ID:elainenaomi,项目名称:labxp2014,代码行数:48,代码来源:metadata.php

示例8: izap_update_metadata

/**
*function to update the metadata
*same as the update_metadata, only made metadata editable
*/
function izap_update_metadata($id, $name, $value, $value_type, $owner_guid, $access_id)
{
    $id = (int) $id;
    if (!($md = elgg_get_metadata_from_id($id))) {
        return false;
    }
    // If memcached then we invalidate the cache for this entry
    static $metabyname_memcache;
    if (!$metabyname_memcache && is_memcache_available()) {
        $metabyname_memcache = new ElggMemcache('metabyname_memcache');
    }
    if ($metabyname_memcache) {
        $metabyname_memcache->delete("{$md->entity_guid}:{$md->name_id}");
    }
    $value_type = detect_extender_valuetype($value, sanitise_string(trim($value_type)));
    $owner_guid = (int) $owner_guid;
    if ($owner_guid == 0) {
        $owner_guid = elgg_get_logged_in_user_guid();
    }
    $access_id = (int) $access_id;
    // Support boolean types (as integers)
    if (is_bool($value)) {
        if ($value) {
            $value = 1;
        } else {
            $value = 0;
        }
    }
    // Add the metastring
    $value = elgg_get_metastring_id($value);
    if (!$value) {
        return false;
    }
    $name = elgg_get_metastring_id($name);
    if (!$name) {
        return false;
    }
    // If ok then add it
    $db_prefix = elgg_get_config('dbprefix');
    $result = update_data("UPDATE {$db_prefix}metadata set value_id='{$value}', value_type='{$value_type}', access_id={$access_id}, owner_guid={$owner_guid} where id={$id} and name_id='{$name}'");
    if ($result !== false) {
        $obj = elgg_get_metadata_from_id($id);
        if (elgg_trigger_event('update', 'metadata', $obj)) {
            return true;
        } else {
            elgg_delete_metadata(array('metadata_id' => $id));
        }
    }
    return $result;
}
开发者ID:Daltonmedia,项目名称:izap_profile_visitors,代码行数:54,代码来源:izap_profile_visitors_lib.php

示例9: system_message

    }
}
if (count($images)) {
    system_message(elgg_echo('gallery:upload:imagesuploaded', array(count($images))));
}
if ($failed) {
    system_message(elgg_echo('gallery:upload:unsupportedtype', array($failed)));
}
if (count($images_pending)) {
    system_message(elgg_echo('gallery:upload:pending', array(count($images_pending))));
}
$metadata_id = create_metadata($album->guid, "river_{$posted}", serialize($images), '', $album->owner_guid, $album->access_id, true);
if (count($images) && !$requires_approval) {
    elgg_create_river_item(array('view' => 'river/object/hjalbum/update', 'action_type' => 'update', 'subject_guid' => elgg_get_logged_in_user_guid(), 'object_guid' => $album->guid, 'access_id' => $album->access_id, 'posted' => $posted));
} else {
    $metadata = elgg_get_metadata_from_id($metadata_id);
    // make sure we have sufficient privileges
    $ia = elgg_set_ignore_access(true);
    $metadata->disable();
    elgg_set_ignore_access($ia);
}
if (count($images_pending)) {
    $to = $album->owner_guid;
    $from = elgg_get_logged_in_user_guid();
    $subject = elgg_echo('gallery:upload:pending', array(count($images_pending)));
    $album_link = elgg_view('output/url', array('text' => $album->title, 'href' => $album->getURL(), 'is_trusted' => true));
    $manage_link = elgg_view('output/url', array('text' => elgg_echo('gallery:manage:album'), 'href' => "gallery/manage/{$album->guid}", 'is_trusted' => true));
    $message = elgg_echo('gallery:upload:pending:message', array(count($images_pending), $album_link, $manage_link));
    notify_user($to, $from, $subject, $message);
}
if (elgg_is_xhr()) {
开发者ID:juho-jaakkola,项目名称:hypeGallery,代码行数:31,代码来源:handle.php

示例10: get

 /**
  * Returns a node from it's uid
  *
  * @param string $uid UID of the resource
  * @return mixed
  */
 public function get($uid = '')
 {
     switch ($uid) {
         case 'me':
             $uid = "ue" . elgg_get_logged_in_user_guid();
             break;
         case 'site':
             $uid = "se" . elgg_get_site_entity()->guid;
             break;
     }
     if (substr($uid, 0, 2) == 'an') {
         $id = (int) substr($uid, 2);
         $node = elgg_get_annotation_from_id($id);
     } else {
         if (substr($uid, 0, 2) == 'md') {
             $id = (int) substr($uid, 2);
             $node = elgg_get_metadata_from_id($id);
         } else {
             if (substr($uid, 0, 2) == 'rl') {
                 $id = (int) substr($uid, 2);
                 $node = get_relationship($id);
             } else {
                 if (substr($uid, 0, 2) == 'rv') {
                     $id = (int) substr($uid, 2);
                     $river = elgg_get_river(array('ids' => sanitize_int($id)));
                     $node = $river ? $river[0] : false;
                 } else {
                     if (in_array(substr($uid, 0, 2), array('ue', 'se', 'oe', 'ge'))) {
                         $id = (int) substr($uid, 2);
                         $node = get_entity($id);
                     } else {
                         if (is_numeric($uid)) {
                             $node = get_entity($uid);
                         } else {
                             $node = get_user_by_username($uid);
                         }
                     }
                 }
             }
         }
     }
     if (!$this->isExportable($node)) {
         return false;
     }
     return $node;
 }
开发者ID:hypejunction,项目名称:hypegraph,代码行数:52,代码来源:Graph.php

示例11: testCanDisableMetadata

 public function testCanDisableMetadata()
 {
     $owner = $this->mocks()->getUser();
     _elgg_services()->session->setLoggedInUser($owner);
     $object = $this->mocks()->getObject(['owner_guid' => $owner->guid]);
     $id = create_metadata($object->guid, 'foo', 'bar', '', $owner->guid);
     $metadata = elgg_get_metadata_from_id($id);
     $this->assertTrue($metadata->disable());
     $this->assertEquals('no', $metadata->enabled);
     $this->assertTrue($metadata->enable());
     $this->assertEquals('yes', $metadata->enabled);
     _elgg_services()->session->removeLoggedInUser();
 }
开发者ID:elgg,项目名称:elgg,代码行数:13,代码来源:ElggMetadataTest.php

示例12: prepareTestObjects

 public function prepareTestObjects()
 {
     $this->setupServices();
     $object = $this->mocks()->getObject(['owner_guid' => $this->actor->guid, 'container_guid' => $this->actor->guid, 'access_id' => ACCESS_LOGGED_IN, 'subtype' => 'test_subtype']);
     $group = $this->mocks()->getGroup(['owner_guid' => $this->actor->guid, 'container_guid' => $this->actor->guid, 'access_id' => ACCESS_LOGGED_IN]);
     $user = $this->actor;
     $metadata_id = create_metadata($object->guid, 'test_metadata_name', 'test_metadata_value', 'text', $this->actor->guid, ACCESS_PUBLIC);
     $metadata = elgg_get_metadata_from_id($metadata_id);
     $annotation_id = $object->annotate('test_annotation_name', 'test_annotation_value', 'text', $this->actor->guid, ACCESS_PUBLIC);
     $annotation = elgg_get_annotation_from_id($annotation_id);
     add_entity_relationship($object->guid, 'test_relationship', $user->guid);
     $relationship = check_entity_relationship($object->guid, 'test_relationship', $user->guid);
     return [$object, $group, $user, $metadata, $annotation, $relationship];
 }
开发者ID:elgg,项目名称:elgg,代码行数:14,代码来源:NotificationsServiceTestCase.php


注:本文中的elgg_get_metadata_from_id函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。