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


PHP elgg_get_metadata函数代码示例

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


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

示例1: izapMarkVisitor

/**
 *funtion to mark the visitor
 */
function izapMarkVisitor()
{
    $ProfileEntity = elgg_get_page_owner_entity();
    $ProfileName = $ProfileEntity->name;
    $ProfileGuid = $ProfileEntity->guid;
    $ProfileOwner = $ProfileEntity->owner_guid;
    $ProfileAccess = $ProfileEntity->access_id;
    $VisitorEntity = elgg_get_logged_in_user_entity();
    $VisitorName = $VisitorEntity->name;
    $VisitorGuid = $VisitorEntity->guid;
    $VisitorsArray = array();
    if ($VisitorGuid != $ProfileGuid && $VisitorEntity && $ProfileEntity) {
        $md = elgg_get_metadata(array('guid' => $ProfileGuid, 'metadata_name' => 'izapProfileVisitor', 'limit' => false));
        $Metadata = array();
        if ($md && count($md) == 1) {
            $Metadata = $md[0];
        } else {
            $Metadata = $md;
        }
        if ($Metadata) {
            $Id = $Metadata->id;
            $VisitorsArray = unserialize($Metadata->value);
            array_unshift($VisitorsArray, $VisitorGuid);
            $InsertArray = array_slice(array_unique($VisitorsArray), 0, 10);
            $InsertArray = serialize($InsertArray);
            izap_update_metadata($Id, 'izapProfileVisitor', $InsertArray, 'text', $ProfileOwner, ACCESS_PUBLIC);
        } else {
            array_unshift($VisitorsArray, $VisitorGuid);
            $InsertArray = serialize($VisitorsArray);
            create_metadata($ProfileGuid, 'izapProfileVisitor', $InsertArray, 'text', $ProfileOwner, ACCESS_PUBLIC);
        }
    }
}
开发者ID:Daltonmedia,项目名称:izap_profile_visitors,代码行数:36,代码来源:izap_profile_visitors_lib.php

示例2: testEGMCanUsePreloader

 public function testEGMCanUsePreloader()
 {
     $options = array('limit' => 3);
     elgg_get_metadata($options);
     $this->assertNull($this->mockPreloader->preloaded);
     $options['preload_owners'] = true;
     elgg_get_metadata($options);
     $this->assertEqual(3, count($this->mockPreloader->preloaded));
 }
开发者ID:gzachos,项目名称:elgg_ellak,代码行数:9,代码来源:ElggEntityPreloaderIntegrationTest.php

示例3: search

 /**
  * Callback function for token input search
  *
  * @param string $term    Search term
  * @param array  $options Options
  * @return array
  */
 public function search($term, $options = array())
 {
     $term = sanitize_string($term);
     $query = str_replace(array('_', '%'), array('\\_', '\\%'), $term);
     $options['metadata_names'] = array('location', 'temp_location');
     $options['group_by'] = "v.string";
     $options['wheres'] = array("v.string LIKE '%{$query}%'");
     return elgg_get_metadata($options);
 }
开发者ID:justangel,项目名称:hypeWall,代码行数:16,代码来源:Geopositioning.php

示例4: getCorrectAnswerMetadata

 /**
  * Get the metadata object for the correct answer
  *
  * @return false|ElggMetadata
  */
 public function getCorrectAnswerMetadata()
 {
     $result = false;
     $options = ['metadata_name' => 'correct_answer', 'guid' => $this->getGUID()];
     $metadata = elgg_get_metadata($options);
     if ($metadata) {
         $result = $metadata[0];
     }
     return $result;
 }
开发者ID:coldtrick,项目名称:questions,代码行数:15,代码来源:ElggAnswer.php

示例5: handle

 /**
  * {@inheritdoc}
  */
 public function handle(ElggEntity $entity)
 {
     $value = get_input($this->getShortname());
     if (!$entity->guid) {
         return $entity;
     }
     $old_owner_guid = $entity->owner_guid;
     $new_owner_guid = $value === null ? $old_owner_guid : (int) $value;
     $owner_has_changed = false;
     $old_icontime = null;
     if (!$new_owner_guid || $new_owner_guid == $old_owner_guid) {
         return $entity;
     }
     $user = elgg_get_logged_in_user_entity();
     // verify new owner is member and old owner/admin is logged in
     if ($entity->isMember(get_user($new_owner_guid)) && ($old_owner_guid == $user->guid || $user->isAdmin())) {
         $entity->owner_guid = $new_owner_guid;
         if ($entity->container_guid == $old_owner_guid) {
             // Even though this action defaults container_guid to the logged in user guid,
             // the group may have initially been created with a custom script that assigned
             // a different container entity. We want to make sure we preserve the original
             // container if it the group is not contained by the original owner.
             $entity->container_guid = $new_owner_guid;
         }
         $metadata = elgg_get_metadata(['guid' => $entity->guid, 'limit' => false]);
         if ($metadata) {
             foreach ($metadata as $md) {
                 if ($md->owner_guid == $old_owner_guid) {
                     $md->owner_guid = $new_owner_guid;
                     $md->save();
                 }
             }
         }
         // @todo Remove this when #4683 fixed
         $owner_has_changed = true;
         $old_icontime = $entity->icontime;
     }
     $must_move_icons = $owner_has_changed && $old_icontime;
     if ($must_move_icons) {
         $filehandler = new ElggFile();
         $filehandler->setFilename('groups');
         $filehandler->owner_guid = $old_owner_guid;
         $old_path = $filehandler->getFilenameOnFilestore();
         $icon_sizes = hypeApps()->iconFactory->getSizes($entity);
         $sizes = array_keys($icon_sizes);
         array_unshift($sizes, '');
         // move existing to new owner
         $filehandler->owner_guid = $entity->owner_guid;
         $new_path = $filehandler->getFilenameOnFilestore();
         foreach ($sizes as $size) {
             rename("{$old_path}/{$entity->guid}{$size}.jpg", "{$new_path}/{$entity->guid}{$size}.jpg");
         }
     }
     return $entity;
 }
开发者ID:hypeJunction,项目名称:Elgg-prototyper_group,代码行数:58,代码来源:OwnerField.php

示例6: testElggGetMetadataCount

 public function testElggGetMetadataCount()
 {
     $this->object->title = 'Meta Unit Test';
     $this->object->save();
     $guid = $this->object->getGUID();
     create_metadata($guid, 'tested', 'tested1', 'text', 0, ACCESS_PUBLIC, true);
     create_metadata($guid, 'tested', 'tested2', 'text', 0, ACCESS_PUBLIC, true);
     $count = (int) elgg_get_metadata(array('metadata_names' => array('tested'), 'guid' => $guid, 'count' => true));
     $this->assertIdentical($count, 2);
     $this->object->delete();
 }
开发者ID:redvabel,项目名称:Vabelgg,代码行数:11,代码来源:metadata.php

示例7: load

 protected function load($guid)
 {
     if (!parent::load($guid)) {
         return false;
     }
     $metadata_options = array('guid' => $guid, 'limit' => false);
     if ($metadata = elgg_get_metadata($metadata_options)) {
         if (!is_array($this->meta_cache)) {
             $this->meta_cache = array();
         }
         foreach ($metadata as $md) {
             $this->meta_cache[$md->name] = $md->value;
         }
     }
     return true;
 }
开发者ID:rijojoy,项目名称:MyIceBerg,代码行数:16,代码来源:ProfileManagerCustomFieldCategory.php

示例8: elggpg_import_key

function elggpg_import_key($public_key, $user)
{
    $gpg = new gnupg();
    $info = $gpg->import($public_key);
    $new_fp = $info['fingerprint'];
    $user_fp = current(elgg_get_metadata(array('guid' => $user->guid, 'metadata_name' => 'openpgp_publickey')));
    $access_id = ACCESS_LOGGED_IN;
    if ($user_fp && $user_fp->value != $new_fp) {
        update_metadata($user_fp->id, $user_fp->name, $new_fp, 'text', $user->guid, $access_id);
        $info['imported'] = 1;
    } elseif (!$user_fp) {
        create_metadata($user->guid, "openpgp_publickey", $new_fp, 'text', $user->guid, $access_id);
        $info['imported'] = 1;
    }
    $info['key_id'] = elggpg_fp2keyid($new_fp);
    return $info;
}
开发者ID:lorea,项目名称:Hydra-dev,代码行数:17,代码来源:elggpg.php

示例9: tu_spam_report_spammer_menu

/**
 * add 'not spammer' and 'delete' links to entity menuy of listed spammers
 * 
 * @param type $hook
 * @param type $type
 * @param type $return
 * @param type $params
 */
function tu_spam_report_spammer_menu($hook, $type, $return, $params)
{
    if (!elgg_instanceof($params['entity'], 'user') || elgg_get_context() != 'reported_spammers') {
        return $return;
    }
    // delete (requires new action due to it being deactivated)
    $href = elgg_add_action_tokens_to_url('action/reported_spam/delete?guid=' . $params['entity']->guid);
    $delete = new ElggMenuItem('delete', elgg_view_icon('delete'), $href);
    $delete->setLinkClass('elgg-requires-confirmation');
    // unspam - will unmark this as spam and reactivate it
    $href = elgg_add_action_tokens_to_url('action/reported_spam/notspammer?guid=' . $params['entity']->guid);
    $unspam = new ElggMenuItem('unspam', elgg_echo('tu_spam_report:notspammer'), $href);
    $unspam->setLinkClass('elgg-requires-confirmation');
    $metadata = elgg_get_metadata(array('guid' => $params['entity']->guid, 'metadata_name' => 'disable_reason', 'metadata_value' => 'content_marked_spam', 'limit' => false));
    $href = false;
    $reported = new ElggMenuItem('reported', elgg_echo('tu_spam_report:reported', array(date('m/d/Y', $metadata[0]->time_created))), $href);
    $return[] = $reported;
    $return[] = $unspam;
    $return[] = $delete;
    return $return;
}
开发者ID:ewinslow,项目名称:trusted_user_spam_report,代码行数:29,代码来源:hooks.php

示例10: entityMetadataToObject

 /**
  * Hook to export entity metadata for search
  *
  * @param string $hook        the name of the hook
  * @param string $type        the type of the hook
  * @param string $returnvalue current return value
  * @param array  $params      supplied params
  *
  * @return void
  */
 public static function entityMetadataToObject($hook, $type, $returnvalue, $params)
 {
     if (!elgg_in_context('search:index')) {
         return;
     }
     $entity = elgg_extract('entity', $params);
     if (!$entity) {
         return;
     }
     $metadata_names = elgg_trigger_plugin_hook('export:metadata_names', 'elasticsearch', $params, []);
     if (empty($metadata_names)) {
         return;
     }
     $metadata = elgg_get_metadata(['guid' => $entity->getGUID(), 'metadata_names' => $metadata_names, 'limit' => false]);
     if (empty($metadata)) {
         return;
     }
     $result = [];
     foreach ($metadata as $data) {
         $result[] = ['time_created' => date('c', $data->time_created), 'owner_guid' => (int) $data->owner_guid, 'access_id' => (int) $data->access_id, 'name' => $data->name, 'value' => $data->value];
     }
     $returnvalue->metadata = $result;
     return $returnvalue;
 }
开发者ID:ColdTrick,项目名称:elasticsearch,代码行数:34,代码来源:Export.php

示例11: elggpg_2012022501

/**
 * Sets the opengpg_publickey for users having a public key
 *
 * @param ElggObject $item
 * @return bool
 */
function elggpg_2012022501($user)
{
    // it is necessary to load the gpg library to make sure gpg path is set.
    global $MIGRATED;
    $MIGRATED += 1;
    if ($MIGRATED % 100 == 0) {
        error_log(" * elggpg {$user->guid}");
    }
    elgg_load_library('elggpg');
    $user_fp = current(elgg_get_metadata(array('guid' => $user->guid, 'metadata_name' => 'openpgp_publickey')));
    $gnupg = new gnupg();
    if (!$user_fp && $user->email) {
        try {
            $info = $gnupg->keyinfo($user->email);
            $fingerprint = $info[0]['subkeys'][0]['fingerprint'];
            if ($fingerprint) {
                create_metadata($user->guid, "openpgp_publickey", $fingerprint, 'text', $user->guid, ACCESS_LOGGEDIN);
            }
        } catch (Exception $e) {
            // no encryption key
        }
    }
    return true;
}
开发者ID:lorea,项目名称:Hydra-dev,代码行数:30,代码来源:2012022501.php

示例12: static_is_moderator_in_container

/**
 * 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);
}
开发者ID:coldtrick,项目名称:static,代码行数:24,代码来源:functions.php

示例13: get_input

// Group membership - should these be treated with same constants as access permissions?
$is_public_membership = get_input('membership') == ACCESS_PUBLIC;
$group->membership = $is_public_membership ? ACCESS_PUBLIC : ACCESS_PRIVATE;
if ($is_new_group) {
    $group->access_id = ACCESS_PUBLIC;
}
$old_owner_guid = $is_new_group ? 0 : $group->owner_guid;
$new_owner_guid = (int) get_input('owner_guid');
$owner_has_changed = false;
$old_icontime = null;
if (!$is_new_group && $new_owner_guid && $new_owner_guid != $old_owner_guid) {
    // verify new owner is member and old owner/admin is logged in
    if (is_group_member($group_guid, $new_owner_guid) && ($old_owner_guid == $user->guid || $user->isAdmin())) {
        $group->owner_guid = $new_owner_guid;
        $group->container_guid = $new_owner_guid;
        $metadata = elgg_get_metadata(array('guid' => $group_guid, 'limit' => false));
        if ($metadata) {
            foreach ($metadata as $md) {
                if ($md->owner_guid == $old_owner_guid) {
                    $md->owner_guid = $new_owner_guid;
                    $md->save();
                }
            }
        }
        // @todo Remove this when #4683 fixed
        $owner_has_changed = true;
        $old_icontime = $group->icontime;
    }
}
$must_move_icons = $owner_has_changed && $old_icontime;
$group->save();
开发者ID:duanhv,项目名称:mdg-social,代码行数:31,代码来源:edit.php

示例14: export_metadata_plugin_hook

/**
 * Handler called by trigger_plugin_hook on the "export" event.
 *
 * @param string $hook        export
 * @param string $entity_type all
 * @param mixed  $returnvalue Value returned from previous hook
 * @param mixed  $params      Params
 *
 * @return array
 * @access private
 */
function export_metadata_plugin_hook($hook, $entity_type, $returnvalue, $params)
{
    // Sanity check values
    if (!is_array($params) && !isset($params['guid'])) {
        throw new InvalidParameterException(elgg_echo('InvalidParameterException:GUIDNotForExport'));
    }
    if (!is_array($returnvalue)) {
        throw new InvalidParameterException(elgg_echo('InvalidParameterException:NonArrayReturnValue'));
    }
    $guid = (int) $params['guid'];
    $name = $params['name'];
    $result = elgg_get_metadata(array('guid' => $guid, 'limit' => 0));
    if ($result) {
        foreach ($result as $r) {
            $returnvalue[] = $r->export();
        }
    }
    return $returnvalue;
}
开发者ID:rcolomoc,项目名称:Master-Red-Social,代码行数:30,代码来源:metadata.php

示例15: foreach

 }
 $list_content .= '<div class="elgg-body">';
 $list_content .= '<fieldset>';
 // display each field for currect category
 $visible_fields = 0;
 foreach ($fields[$cat_guid] as $field) {
     if ($field->user_editable == 'no') {
         // non editable fields should not be on the form
         continue;
     }
     $valtype = $field->metadata_type;
     $metadata_name = $field->metadata_name;
     // get options
     $options = $field->getOptions();
     // get value
     $metadata = elgg_get_metadata(['guid' => $user->guid, 'metadata_name' => $metadata_name, 'limit' => false]);
     if ($metadata) {
         $metadata = $metadata[0];
         $value = $user->{$metadata_name};
         $access_id = $metadata->access_id;
     } else {
         $value = '';
         $access_id = get_default_access($user);
     }
     $visible_fields++;
     $field_result = '<div>';
     $field_result .= elgg_format_element('label', [], $field->getTitle(true));
     $hint = $field->getHint();
     if ($hint) {
         $field_result .= elgg_view('output/pm_hint', ['id' => "more_info_{$metadata_name}", 'text' => $hint]);
     }
开发者ID:coldtrick,项目名称:profile_manager,代码行数:31,代码来源:edit.php


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