本文整理汇总了PHP中get_metastring_id函数的典型用法代码示例。如果您正苦于以下问题:PHP get_metastring_id函数的具体用法?PHP get_metastring_id怎么用?PHP get_metastring_id使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_metastring_id函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: filterObject
public function filterObject($object)
{
global $CONFIG;
$dbprefix = $CONFIG->dbprefix;
$subtype = get_subtype_from_id($object->subtype);
// do not index specific types of content
if (in_array($subtype, array('messages', 'plugin', 'widget', 'custom_profile_field', 'custom_profile_field_category', 'reported_content', 'custom_group_field', 'custom_profile_type', 'gruop_widget', 'multi_dashboard'))) {
return false;
}
$return = array();
foreach (self::$entity_fields as $field) {
$return[$field] = $object->{$field};
}
$return['title'] = $object->title;
$return['description'] = elgg_strip_tags($object->description);
// remove HTML
$metastring_id = get_metastring_id('tags');
if (!$metastring_id) {
throw new Exception("No metastring id for tags found");
}
$metadata = get_data("SELECT md.access_id, v.string AS value FROM {$dbprefix}metadata md JOIN {$dbprefix}metastrings v ON md.value_id = v.id WHERE md.entity_guid = {$object->guid} AND md.name_id = {$metastring_id} AND md.enabled = 'yes'");
if (count($metadata) > 0) {
$return['tags'] = array();
foreach ($metadata as $item) {
if ($item->value) {
$return['tags'][] = $item->value;
}
}
}
return $return;
}
示例2: birthdays_get_upcoming_user_guids
function birthdays_get_upcoming_user_guids()
{
$site = elgg_get_site_entity();
$today = (int) date("z");
$field = birthdays_get_configured_birthday_field();
if (!$field) {
return false;
}
if (date("w") == 1) {
// Mondays
$today -= 2;
} elseif (date("w") == 2) {
// Tuesdays
$today -= 1;
}
$dbprefix = elgg_get_config('dbprefix');
$field_id = (int) get_metastring_id($field);
$sql = "SELECT\n\t\te.guid,\n\t\tDAYOFYEAR(DATE(msv.string)) AS birthday\n\t\tFROM {$dbprefix}entities e\n\t\tJOIN {$dbprefix}entity_relationships r ON r.guid_one = e.guid\n\t\tJOIN {$dbprefix}metadata m ON e.guid = m.entity_guid\n\t\tJOIN {$dbprefix}metastrings msv ON m.value_id = msv.id\n\t\tWHERE\n\t\te.type = 'user' AND\n\t\tr.relationship = 'member_of_site' AND\n\t\tr.guid_two = {$site->guid} AND\n\t\tm.name_id = {$field_id}\n\t\tHAVING birthday >= {$today}\n\t\tORDER BY birthday\n\t\tLIMIT 25";
$users = get_data($sql);
$return = array();
foreach ($users as $user) {
$return[] = $user->guid;
}
return $return;
}
示例3: get_tags
/**
* Get an array of tags with weights for use with the output/tagcloud view.
*
* @param int $threshold Get the threshold of minimum number of each tags to bother with (ie only show tags where there are more than $threshold occurances)
* @param int $limit Number of tags to return
* @param string $metadata_name Optionally, the name of the field you want to grab for
* @param string $entity_type Optionally, the entity type ('object' etc)
* @param string $entity_subtype The entity subtype, optionally
* @param int $owner_guid The GUID of the tags owner, optionally
* @param int $site_guid Optionally, the site to restrict to (default is the current site)
* @return array|false Array of objects with ->tag and ->total values, or false on failure
*/
function get_tags($threshold = 1, $limit = 10, $metadata_name = "", $entity_type = "object", $entity_subtype = "", $owner_guid = "", $site_guid = -1)
{
global $CONFIG;
$threshold = (int) $threshold;
$limit = (int) $limit;
if (!empty($metadata_name)) {
$metadata_name = (int) get_metastring_id($metadata_name);
} else {
$metadata_name = 0;
}
$entity_subtype = get_subtype_id($entity_type, $entity_subtype);
$entity_type = sanitise_string($entity_type);
if ($owner_guid != "") {
if (is_array($owner_guid)) {
foreach ($owner_guid as $key => $val) {
$owner_guid[$key] = (int) $val;
}
} else {
$owner_guid = (int) $owner_guid;
}
}
if ($site_guid < 0) {
$site_guid = $CONFIG->site_id;
}
//$access = get_access_list();
$query = "SELECT msvalue.string as tag, count(msvalue.id) as total ";
$query .= "FROM {$CONFIG->dbprefix}entities e join {$CONFIG->dbprefix}metadata md on md.entity_guid = e.guid ";
$query .= " join {$CONFIG->dbprefix}entity_subtypes subtype on subtype.id = e.subtype ";
$query .= " join {$CONFIG->dbprefix}metastrings msvalue on msvalue.id = md.value_id ";
$query .= " where msvalue.string != '' ";
if ($metadata_name > 0) {
$query .= " and md.name_id = {$metadata_name} ";
}
if ($site_guid > 0) {
$query .= " and e.site_guid = {$site_guid} ";
}
if ($entity_subtype > 0) {
$query .= " and e.subtype = {$entity_subtype} ";
}
if ($entity_type != "") {
$query .= " and e.type = '{$entity_type}' ";
}
if (is_array($owner_guid)) {
$query .= " and e.container_guid in (" . implode(",", $owner_guid) . ")";
} else {
if (is_int($owner_guid)) {
$query .= " and e.container_guid = {$owner_guid} ";
}
}
//$userid = get_loggedin_userid();
//$query .= " and (e.access_id in {$access} or (e.access_id = " . ACCESS_PRIVATE . " and e.owner_guid = {$userid}))";
$query .= ' and ' . get_access_sql_suffix("e");
// Add access controls
$query .= " group by msvalue.string having total > {$threshold} order by total desc limit {$limit} ";
return get_data($query);
}
示例4: uservalidationbyemail_get_unvalidated_users_sql_where
/**
* Return a where clause to get entities
*
* "Unvalidated" means metadata of validated is not set or not truthy.
* We can't use elgg_get_entities_from_metadata() because you can't say
* "where the entity has metadata set OR it's not equal to 1".
*
* @return array
*/
function uservalidationbyemail_get_unvalidated_users_sql_where()
{
global $CONFIG;
$validated_id = get_metastring_id('validated');
$one_id = get_metastring_id(1);
// thanks to daveb@freenode for the SQL tips!
$wheres = array();
$wheres[] = "e.enabled='no'";
$wheres[] = "NOT EXISTS (\n\t\t\tSELECT 1 FROM {$CONFIG->dbprefix}metadata md\n\t\t\tWHERE md.entity_guid = e.guid\n\t\t\t\tAND md.name_id = {$validated_id}\n\t\t\t\tAND md.value_id = {$one_id})";
return $wheres;
}
示例5: testGetMetastringById
public function testGetMetastringById()
{
foreach (array('metaUnitTest', 'metaunittest', 'METAUNITTEST') as $string) {
$this->create_metastring($string);
}
// lookup metastring id
$cs_ids = get_metastring_id('metaUnitTest', TRUE);
$this->assertEqual($cs_ids, $this->metastrings['metaUnitTest']);
// lookup all metastrings, ignoring case
$cs_ids = get_metastring_id('metaUnitTest', FALSE);
$this->assertEqual(count($cs_ids), 3);
$this->assertEqual(count($cs_ids), count($this->metastrings));
foreach ($cs_ids as $string) {
$this->assertTrue(in_array($string, $this->metastrings));
}
}
示例6: filterObject
public function filterObject($object)
{
global $CONFIG;
$dbprefix = $CONFIG->dbprefix;
$subtype = get_subtype_from_id($object->subtype);
// do not index specific types of content
if (in_array($subtype, array('messages', 'plugin', 'widget', 'custom_profile_field', 'custom_profile_field_category', 'reported_content', 'custom_group_field', 'custom_profile_type', 'gruop_widget', 'multi_dashboard'))) {
return false;
}
$return = array();
foreach (self::$entity_fields as $field) {
$return[$field] = $object->{$field};
}
$return['title'] = html_entity_decode($object->title);
$return['description'] = html_entity_decode(elgg_strip_tags($object->description));
// remove HTML
$metastring_id = get_metastring_id('tags');
if (!$metastring_id) {
throw new Exception("No metastring id for tags found");
}
$metadata = get_data("SELECT md.access_id, v.string AS value FROM {$dbprefix}metadata md JOIN {$dbprefix}metastrings v ON md.value_id = v.id WHERE md.entity_guid = {$object->guid} AND md.name_id = {$metastring_id} AND md.enabled = 'yes'");
if (count($metadata) > 0) {
$return['tags'] = array();
foreach ($metadata as $item) {
if ($item->value) {
$return['tags'][] = $item->value;
}
}
}
if (in_array($subtype, array('question', 'cafe', 'news', 'blog'))) {
if ($subtype == "question") {
$comment_subtype = "answer";
} else {
$comment_subtype = "comment";
}
$options = array("type" => "object", "subtype" => $comment_subtype, "container_guid" => $object->guid, "site_guids" => null, "limit" => false);
$return['comments'] = array();
foreach (elgg_get_entities($options) as $comment) {
$return['comments'][] = html_entity_decode(elgg_strip_tags($comment->description));
}
}
return $return;
}
示例7: testGetMetastringById
public function testGetMetastringById()
{
foreach (array('metaUnitTest', 'metaunittest', 'METAUNITTEST') as $string) {
// since there is no guarantee that metastrings are garbage collected
// between unit test runs, we delete before testing
$this->delete_metastrings($string);
$this->create_metastring($string);
}
// lookup metastring id
$cs_ids = get_metastring_id('metaUnitTest', TRUE);
$this->assertEqual($cs_ids, $this->metastrings['metaUnitTest']);
// lookup all metastrings, ignoring case
$cs_ids = get_metastring_id('metaUnitTest', FALSE);
$this->assertEqual(count($cs_ids), 3);
$this->assertEqual(count($cs_ids), count($this->metastrings));
foreach ($cs_ids as $string) {
$this->assertTrue(in_array($string, $this->metastrings));
}
}
示例8: deyan_get_unread_messages
/**
* Gets the unread messages
*
* @return array
*/
function deyan_get_unread_messages() {
$user_guid = elgg_get_logged_in_user_guid();
$db_prefix = elgg_get_config('dbprefix');
// denormalize the md to speed things up.
// seriously, 10 joins if you don't.
$strings = array('toId', $user_guid, 'readYet', 0, 'msg', 1);
$map = array();
foreach ($strings as $string) {
$id = get_metastring_id($string);
$map[$string] = $id;
}
$options = array(
// 'metadata_name_value_pairs' => array(
// 'toId' => elgg_get_logged_in_user_guid(),
// 'readYet' => 0,
// 'msg' => 1
// ),
'joins' => array(
"JOIN {$db_prefix}metadata msg_toId on e.guid = msg_toId.entity_guid",
"JOIN {$db_prefix}metadata msg_readYet on e.guid = msg_readYet.entity_guid",
"JOIN {$db_prefix}metadata msg_msg on e.guid = msg_msg.entity_guid",
),
'wheres' => array(
"msg_toId.name_id='{$map['toId']}' AND msg_toId.value_id='{$map[$user_guid]}'",
"msg_readYet.name_id='{$map['readYet']}' AND msg_readYet.value_id='{$map[0]}'",
"msg_msg.name_id='{$map['msg']}' AND msg_msg.value_id='{$map[1]}'",
),
'owner_guid' => $user_guid,
'full_view' => false,
'limit' => 0
);
$messages = elgg_list_entities_from_metadata($options);
return $messages;
}
示例9: get_input
<?php
/**
* Action for combining two plugin projects
*/
global $CONFIG;
$old_guid = (int) get_input('old_guid');
$new_guid = (int) get_input('new_guid');
$old_project = get_entity($old_guid);
$new_project = get_entity($new_guid);
if (!$old_project instanceof PluginProject || !$new_project instanceof PluginProject) {
register_error('The GUIDs must be for 2 plugin projects');
forward(REFERER);
}
$old_name = $old_project->title;
// move releases for the old project to the new project
$params = array('types' => 'object', 'subtypes' => 'plugin_release', 'container_guids' => $old_project->guid, 'limit' => 0);
$releases = elgg_get_entities($params);
foreach ($releases as $release) {
$release->container_guid = $new_project->guid;
$release->save();
}
// move download count to new project
$annotation_name = get_metastring_id('download', TRUE);
if ($annotation_name) {
$query = "UPDATE {$CONFIG->dbprefix}annotations\n\t\tSET entity_guid={$new_project->guid}\n\t\tWHERE entity_guid={$old_project->guid} AND name_id={$annotation_name}";
update_data($query);
}
$old_project->delete();
system_message("{$old_name} has been combined into the project {$new_project->title}");
forward(REFERER);
示例10: elgg_is_admin_user
/**
* Check if the given user has full access.
*
* @todo: Will always return full access if the user is an admin.
*
* @param int $user_guid The user to check
*
* @return bool
* @since 1.7.1
*/
function elgg_is_admin_user($user_guid)
{
global $CONFIG;
// cannot use magic metadata here because of recursion
// must support the old way of getting admin from metadata
// in order to run the upgrade to move it into the users table.
$version = (int) datalist_get('version');
if ($version < 2010040201) {
$admin = get_metastring_id('admin');
$yes = get_metastring_id('yes');
$one = get_metastring_id('1');
$query = "SELECT * FROM {$CONFIG->dbprefix}users_entity as e,\n\t\t\t{$CONFIG->dbprefix}metadata as md\n\t\t\tWHERE (\n\t\t\t\tmd.name_id = '{$admin}'\n\t\t\t\tAND md.value_id IN ('{$yes}', '{$one}')\n\t\t\t\tAND e.guid = md.entity_guid\n\t\t\t\tAND e.guid = {$user_guid}\n\t\t\t\tAND e.banned = 'no'\n\t\t\t)";
} else {
$query = "SELECT * FROM {$CONFIG->dbprefix}users_entity as e\n\t\t\tWHERE (\n\t\t\t\te.guid = {$user_guid}\n\t\t\t\tAND e.admin = 'yes'\n\t\t\t)";
}
// normalizing the results from get_data()
// See #1242
$info = get_data($query);
if (!(is_array($info) && count($info) < 1 || $info === FALSE)) {
return TRUE;
}
return FALSE;
}
示例11: get_entities_by_views_counter
/**
* Return an array of entities ordered by the number of views
*
* @param $options
*/
function get_entities_by_views_counter($options)
{
global $CONFIG;
// Select the sum of the views counter returned by the JOIN
$select = 'sum(ms.string) as views_counter';
if (is_array($options['selects'])) {
$options['selects'][] = $select;
} else {
if ($options['selects']) {
$options['selects'] = array($options['selects'], $select);
} else {
$options['selects'] = array($select);
}
}
// Get the annotations "views_counter" for each entity
$metastring_id = get_metastring_id('views_counter');
$join = ' LEFT JOIN ' . $CONFIG->dbprefix . 'annotations a ON ((a.entity_guid=e.guid)AND(a.name_id=' . $metastring_id . '))';
if (is_array($options['joins'])) {
$options['joins'][] = $join;
} else {
if ($options['joins']) {
$options['joins'] = array($options['joins'], $join);
} else {
$options['joins'] = array($join);
}
}
// JOIN the value of the annotations. The value of each views counter...
$options['joins'][] = ' LEFT JOIN ' . $CONFIG->dbprefix . 'metastrings ms ON ((a.entity_guid=e.guid)AND(a.name_id=' . $metastring_id . ')AND(a.value_id=ms.id))';
// Check if the user does not want to list by best average any value different of: 'desc'
if ($options['order_by'] != 'asc') {
$options['order_by'] = ' views_counter desc, e.time_created desc';
} else {
$options['order_by'] = ' views_counter asc, e.time_created desc';
}
// Group the result of JOIN annotations by entity because each entity may have infinite annotations "generic_rate"
$options['group_by'] .= ' e.guid ';
// Let the elgg_get_entities() function make do work for us :)
$entities = elgg_get_entities($options);
return $entities;
}
示例12: messages_count_unread
/**
* Count the unread messages in a user's inbox
*
* @return int
*/
function messages_count_unread()
{
$user_guid = elgg_get_logged_in_user_guid();
$db_prefix = elgg_get_config('dbprefix');
// denormalize the md to speed things up.
// seriously, 10 joins if you don't.
$strings = array('toId', $user_guid, 'readYet', 0, 'msg', 1);
$map = array();
foreach ($strings as $string) {
$id = get_metastring_id($string);
$map[$string] = $id;
}
$options = array('joins' => array("JOIN {$db_prefix}metadata msg_toId on e.guid = msg_toId.entity_guid", "JOIN {$db_prefix}metadata msg_readYet on e.guid = msg_readYet.entity_guid", "JOIN {$db_prefix}metadata msg_msg on e.guid = msg_msg.entity_guid"), 'wheres' => array("msg_toId.name_id='{$map['toId']}' AND msg_toId.value_id='{$map[$user_guid]}'", "msg_readYet.name_id='{$map['readYet']}' AND msg_readYet.value_id='{$map[0]}'", "msg_msg.name_id='{$map['msg']}' AND msg_msg.value_id='{$map[1]}'"), 'owner_guid' => $user_guid, 'count' => true);
return elgg_get_entities_from_metadata($options);
}
示例13: add_metastring
/**
* Add a metastring.
* It returns the id of the tag, whether by creating it or updating it.
*
* @param string $string The value (whatever that is) to be stored
* @param bool $case_sensitive Do we want to make the query case sensitive?
*
* @return mixed Integer tag or false.
*/
function add_metastring($string, $case_sensitive = true)
{
global $CONFIG, $METASTRINGS_CACHE, $METASTRINGS_DEADNAME_CACHE;
$sanstring = sanitise_string($string);
$id = get_metastring_id($string, $case_sensitive);
if ($id) {
return $id;
}
$result = insert_data("INSERT into {$CONFIG->dbprefix}metastrings (string) values ('{$sanstring}')");
if ($result) {
$METASTRINGS_CACHE[$result] = $string;
if (isset($METASTRINGS_DEADNAME_CACHE[$string])) {
unset($METASTRINGS_DEADNAME_CACHE[$string]);
}
}
return $result;
}
示例14: get_entities_from_relationships_and_meta
/**
* Gets the number of entities by a the number of entities related to them in a particular way also constrained by
* metadata
*
* @param string $relationship The relationship eg "friends_of"
* @param int $relationship_guid The guid of the entity to use query
* @param bool $inverse_relationship Reverse the normal function of the query to instead say "give me all entities for whome $relationship_guid is a $relationship of" (default: true)
* @param String $meta_name The metadata name
* @param String $meta_value The metadata value
* @param string $type The type of entity (default: all)
* @param string $subtype The entity subtype (default: all)
* @param int $owner_guid The owner of the entities (default: none)
* @param int $limit
* @param int $offset
* @param boolean $count Set to true if you want to count the number of entities instead (default false)
* @param int $site_guid The site to get entities for. Leave as 0 (default) for the current site; -1 for all sites.
* @return array|int|false An array of entities, or the number of entities, or false on failure
*/
function get_entities_from_relationships_and_meta($relationship, $relationship_guid, $inverse_relationship = false, $meta_name = "", $meta_value = "", $type = "", $subtype = "", $owner_guid = 0, $limit = 10, $offset = 0, $count = false, $site_guid = 0)
{
global $CONFIG;
$relationship = sanitise_string($relationship);
$inverse_relationship = (bool) $inverse_relationship;
$relationship_guid = (int) $relationship_guid;
$type = sanitise_string($type);
if ($subtype and !($subtype = get_subtype_id($type, $subtype))) {
return false;
}
$owner_guid = (int) $owner_guid;
$order_by = sanitise_string($order_by);
$limit = (int) $limit;
$offset = (int) $offset;
$site_guid = (int) $site_guid;
if ($site_guid == 0) {
$site_guid = $CONFIG->site_guid;
}
$meta_n = get_metastring_id($meta_name);
$meta_v = get_metastring_id($meta_value);
//$access = get_access_list();
$where = array();
if ($relationship != "") {
$where[] = "r.relationship='{$relationship}'";
}
$on = "e.guid = r.guid_one";
if (!$inverse_relationship) {
$on = "e.guid = r.guid_two";
}
if ($type != "") {
$where[] = "e.type='{$type}'";
}
if ($subtype) {
$where[] = "e.subtype={$subtype}";
}
if ($owner_guid != "") {
$where[] = "e.container_guid='{$owner_guid}'";
}
if ($site_guid > 0) {
$where[] = "e.site_guid = {$site_guid}";
}
if ($relationship_guid) {
$where[] = $inverse_relationship ? "r.guid_two='{$relationship_guid}'" : "r.guid_one='{$relationship_guid}'";
}
$metajoin = "";
if ($meta_name !== "" || $meta_value !== "") {
$metajoin = " JOIN {$CONFIG->dbprefix}metadata m on e.guid=m.entity_guid";
if ($meta_name !== "") {
$where[] = "m.name_id='{$meta_n}'";
}
if ($meta_value !== "") {
$where[] = "m.value_id='{$meta_v}'";
}
}
if ($count) {
$query = "SELECT count(distinct e.guid) as total ";
} else {
$query = "SELECT distinct e.*, count(e.guid) as total ";
}
$query .= " from {$CONFIG->dbprefix}entity_relationships r JOIN {$CONFIG->dbprefix}entities e on {$on} {$metajoin} where ";
if (!empty($where)) {
foreach ($where as $w) {
$query .= " {$w} and ";
}
}
$query .= get_access_sql_suffix("e");
// Add access controls
if ($meta_name !== "" || $meta_value !== "") {
$query .= ' and ' . get_access_sql_suffix("m");
}
// Add access controls
if (!$count) {
$query .= " group by e.guid ";
$query .= " order by total desc limit {$offset}, {$limit}";
// Add order and limit
return get_data($query, "entity_row_to_elggstar");
} else {
if ($count = get_data_row($query)) {
return $count->total;
}
}
return false;
//.........这里部分代码省略.........
示例15: elgg_get_site_url
" value="<?php
echo $faq->guid;
?>
" /></div></td>
<?php
}
?>
<td width="100%">
<?php
if (!empty($hitcount)) {
?>
<a href="<?php
elgg_get_site_url();
?>
faq/list?categoryId=<?php
echo get_metastring_id($faq->category);
?>
"><?php
echo $faq->category;
?>
</a> >
<?php
}
?>
<a href="javascript:void(0);" id="qID<?php
echo $faq->guid;
?>
" onClick="$('#aID<?php
echo $faq->guid;
?>
').toggle();"><?php