Exemple #1
0
 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;
 }
Exemple #2
0
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;
}
Exemple #3
0
/**
 * 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);
}
Exemple #4
0
/**
 * 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;
}
 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));
     }
 }
Exemple #6
0
 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;
 }
Exemple #7
0
 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));
     }
 }
Exemple #8
0
/**
 * 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;
}
Exemple #9
0
<?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);
Exemple #10
0
/**
 * 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;
}
/**
 * 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;
}
Exemple #12
0
/**
 * 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);
}
Exemple #13
0
/**
 * 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;
}
Exemple #14
0
/**
 * 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;
}
" 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>&nbsp;>
				<?php 
}
?>
				<a href="javascript:void(0);" id="qID<?php 
echo $faq->guid;
?>
" onClick="$('#aID<?php 
echo $faq->guid;
?>
').toggle();"><?php 
 function get_entities_from_metadata_by_value($meta_array, $entity_type = "", $entity_subtype = "", $count = false, $owner_guid = 0, $container_guid = 0, $limit = 10, $offset = 0, $order_by = "", $site_guid = 0)
 {
     global $CONFIG;
     // ORDER BY
     if ($order_by == "") {
         $order_by = "e.time_created desc";
     }
     $order_by = sanitise_string($order_by);
     $where = array();
     // Filetr by metadata
     $mindex = 1;
     // Starting index of joined metadata/metastring tables
     $join_meta = "";
     $query_access = "";
     foreach ($meta_array as $meta) {
         $join_meta .= "JOIN {$CONFIG->dbprefix}metadata m{$mindex} on e.guid = m{$mindex}.entity_guid ";
         $join_meta .= "JOIN {$CONFIG->dbprefix}metastrings v{$mindex} on v{$mindex}.id = m{$mindex}.value_id ";
         $meta_n = get_metastring_id($meta['name']);
         $where[] = "m{$mindex}.name_id='{$meta_n}'";
         if (strtolower($meta['operand']) == "like") {
             // "LIKE" search
             $where[] = "v{$mindex}.string LIKE ('" . $meta['value'] . "') ";
         } elseif (strtolower($meta['operand']) == "in") {
             // TO DO - "IN" search
         } elseif ($meta['operand'] != '') {
             // Simple operand search
             $where[] = "v{$mindex}.string" . $meta['operand'] . "'" . $meta['value'] . "'";
         }
         $query_access .= ' and ' . get_access_sql_suffix("m{$mindex}");
         // Add access controls
         $mindex++;
     }
     $limit = (int) $limit;
     $offset = (int) $offset;
     if (is_array($owner_guid) && count($owner_guid)) {
         foreach ($owner_guid as $key => $guid) {
             $owner_guid[$key] = (int) $guid;
         }
     } else {
         $owner_guid = (int) $owner_guid;
     }
     if (is_array($container_guid) && count($container_guid)) {
         foreach ($container_guid as $key => $guid) {
             $container_guid[$key] = (int) $guid;
         }
     } else {
         $container_guid = (int) $container_guid;
     }
     $site_guid = (int) $site_guid;
     if ($site_guid == 0) {
         $site_guid = $CONFIG->site_guid;
     }
     $entity_type = sanitise_string($entity_type);
     if ($entity_type != "") {
         $where[] = "e.type='{$entity_type}'";
     }
     $entity_subtype = get_subtype_id($entity_type, $entity_subtype);
     if ($entity_subtype) {
         $where[] = "e.subtype={$entity_subtype}";
     }
     if ($site_guid > 0) {
         $where[] = "e.site_guid = {$site_guid}";
     }
     if (is_array($owner_guid)) {
         $where[] = "e.owner_guid in (" . implode(",", $owner_guid) . ")";
     } else {
         if ($owner_guid > 0) {
             $where[] = "e.owner_guid = {$owner_guid}";
         }
     }
     if (is_array($container_guid)) {
         $where[] = "e.container_guid in (" . implode(",", $container_guid) . ")";
     } else {
         if ($container_guid > 0) {
             $where[] = "e.container_guid = {$container_guid}";
         }
     }
     if (!$count) {
         $query = "SELECT distinct e.* ";
     } else {
         $query = "SELECT count(distinct e.guid) as total ";
     }
     $query .= "FROM {$CONFIG->dbprefix}entities e ";
     $query .= $join_meta;
     $query .= "  WHERE ";
     foreach ($where as $w) {
         $query .= " {$w} and ";
     }
     $query .= get_access_sql_suffix("e");
     // Add access controls
     $query .= $query_access;
     if (!$count) {
         $query .= " order by {$order_by} limit {$offset}, {$limit}";
         // Add order and limit
         return get_data($query, "entity_row_to_elggstar");
     } else {
         $row = get_data_row($query);
         //echo $query.mysql_error().__FILE__.__LINE__;
         if ($row) {
             return $row->total;
         }
     }
     return false;
 }
    }
}
// meta_data_exact_search_criteria
if (!empty($meta_data_exact_search_criteria)) {
    foreach ($meta_data_exact_search_criteria as $field_name => $field_value) {
        if (!empty($field_value)) {
            $meta_name_id = get_metastring_id(sanitise_string($field_name));
            $meta_array[$meta_name_id] = "= '" . sanitise_string($field_value) . "'";
        }
    }
}
// meta_data_between_search_criteria
if (!empty($meta_data_between_search_criteria)) {
    foreach ($meta_data_between_search_criteria as $field_name => $field_value) {
        if (!empty($field_value) && (!empty($field_value['FROM']) || !empty($field_value['TO']))) {
            $meta_name_id = get_metastring_id(sanitise_string($field_name));
            $from = sanitise_string($field_value['FROM']);
            $to = sanitise_string($field_value['TO']);
            if (!empty($from) && !empty($to)) {
                $record_filter = "BETWEEN " . $from . " AND " . $to;
            } elseif (!empty($from)) {
                $record_filter = ">= " . $from;
            } else {
                $record_filter = "<= " . $to;
            }
            $meta_array[$meta_name_id] = $record_filter;
        }
    }
}
$mindex = 1;
$join = "";
Exemple #18
0
<?php

$ha = access_get_show_hidden_status();
access_show_hidden_entities(true);
$name_id = get_metastring_id('msgHash');
if (!$name_id) {
    $name_id = add_metastring('msgHash');
}
$dbprefix = elgg_get_config('dbprefix');
$messages = elgg_get_entities(array('types' => 'object', 'subtypes' => array('messages'), 'wheres' => array("NOT EXISTS (SELECT 1 FROM {$dbprefix}metadata md WHERE md.entity_guid = e.guid\n            AND md.name_id = {$name_id})"), 'order_by' => 'e.guid ASC', 'count' => true));
access_show_hidden_entities($ha);
if ($messages) {
    echo elgg_view('framework/inbox/admin/import', array('count' => $messages));
}
Exemple #19
0
<?php

/**
 * Pull admin metadata setting into users_entity table column
 */
$siteadmin = get_metastring_id('siteadmin');
$admin = get_metastring_id('admin');
$yes = get_metastring_id('yes');
$one = get_metastring_id('1');
$qs = array();
$qs[] = "ALTER TABLE {$CONFIG->dbprefix}users_entity DISABLE KEYS";
$qs[] = "ALTER TABLE {$CONFIG->dbprefix}users_entity\n\tADD admin ENUM('yes', 'no') NOT NULL DEFAULT 'no' AFTER `banned`";
$qs[] = "UPDATE {$CONFIG->dbprefix}users_entity SET admin = 'yes' where guid IN (select x.guid FROM(\nSELECT * FROM {$CONFIG->dbprefix}users_entity as e,\n\t{$CONFIG->dbprefix}metadata as md\n\tWHERE (\n\t\tmd.name_id IN ('{$admin}', '{$siteadmin}')\n\t\tAND md.value_id IN ('{$yes}', '{$one}')\n\t\tAND e.guid = md.entity_guid\n\t\tAND e.banned = 'no'\n\t)) as x)";
$qs[] = "ALTER TABLE {$CONFIG->dbprefix}users_entity ADD KEY admin (admin)";
$qs[] = "ALTER TABLE {$CONFIG->dbprefix}users_entity ENABLE KEYS";
$qs[] = "DELETE FROM {$CONFIG->dbprefix}metadata\n\tWHERE (\n\t\tname_id IN ('{$admin}', '{$siteadmin}')\n\t\tAND value_id IN ('{$yes}', '{$one}')\n\t)";
foreach ($qs as $q) {
    update_data($q);
}
            if ($oldCat == "newCat" && !empty($newCat)) {
                $cat = ucfirst(strtolower($newCat));
            } else {
                $cat = ucfirst(strtolower($oldCat));
            }
            if (!empty($cat)) {
                $faq->question = $question;
                $faq->answer = $answer;
                $faq->category = $cat;
                $faq->access_id = $access;
                $faq->owner_guid = elgg_get_config('site_guid');
                $faq->container_guid = elgg_get_config('site_guid');
                if ($faq->save()) {
                    system_message(elgg_echo("faq:edit:success"));
                } else {
                    register_error(elgg_echo("faq:edit:error:save"));
                }
            } else {
                register_error(elgg_echo("faq:edit:error:invalid_category"));
            }
        } else {
            register_error(elgg_echo("faq:edit:error:invalid_input"));
        }
    } else {
        register_error(elgg_echo("faq:edit:error:invalid_object"));
    }
} else {
    register_error(elgg_echo("faq:edit:error:invalid_input"));
}
forward(elgg_get_site_url() . "faq/list?categoryId=" . get_metastring_id($faq->category));
<?php

exit;
/**
 * Find groups which don't have icontime but have an icon
 * 
 * Legacy from Elgg 1.5
 */
require_once dirname(dirname(dirname(dirname(dirname(__FILE__))))) . "/engine/start.php";
admin_gatekeeper();
$icontime_id = get_metastring_id("icontime");
$options = array("type" => "group", "limit" => false, "site_guids" => false, "wheres" => array("NOT EXISTS (\n\t\t\tSELECT 1 FROM " . elgg_get_config("dbprefix") . "metadata md\n\t\t\tWHERE md.entity_guid = e.guid\n\t\t\t\tAND md.name_id = {$icontime_id})"));
if ($groups = elgg_get_entities($options)) {
    echo "found: " . count($groups) . " groups to check<br />";
    foreach ($groups as $group) {
        $fh = new ElggFile();
        $fh->owner_guid = $group->getOwnerGUID();
        $fh->setFilename("groups/" . $group->getGUID() . ".jpg");
        if ($fh->exists()) {
            echo "found and icon for " . $group->name . "<br />";
            $group->icontime = time();
        }
    }
}
echo "done";
Exemple #22
0
/**
 * Get Last Conversation
 * 
 * @param int $user_guid    User GUID
 * @param int $limit        Limit of Conversations
 * @param int $offset       Offset
 * @param int $count        Count
 *
 * @return SuccessResult|ErrorResult
 */
function ws_pack_get_last_conversations($user_guid, $limit = 100, $offset = 0, $count = false)
{
    $result = false;
    $user = elgg_get_logged_in_user_entity();
    $api_application = ws_pack_get_current_api_application();
    if (!empty($user) && !empty($api_application)) {
        if (!$user_guid) {
            $user_guid = elgg_get_logged_in_user_guid();
        }
        $db_prefix = elgg_get_config('dbprefix');
        $strings = array('toId', $user_guid, 'msg', 1, 'fromId', $fromto_guid);
        $map = array();
        foreach ($strings as $string) {
            $id = get_metastring_id($string);
            $map[$string] = $id;
        }
        $options = array('selects' => array("MAX(e.guid) as guid", "MAX(e.time_created) as time_created"), 'joins' => array("JOIN {$db_prefix}metadata msg_toId on e.guid = msg_toId.entity_guid", "JOIN {$db_prefix}metadata msg_msg on e.guid = msg_msg.entity_guid", "JOIN {$db_prefix}metadata msg_fromId on e.guid = msg_fromId.entity_guid"), 'owner_guid' => $user_guid, 'limit' => $limit, 'offset' => $offset, 'count' => $count);
        $options["wheres"] = array("msg_msg.name_id='{$map['msg']}' AND msg_msg.value_id='{$map[1]}'");
        $options["group_by"] = "msg_fromId.value_id, msg_toId.value_id";
        $messages = elgg_get_entities_from_metadata($options);
        if ($messages === false) {
            $result = new ErrorResult(elgg_echo("ws_pack:error:notfound"));
        } else {
            $messages["entities"] = ws_pack_export_entities($messages);
            $guids = array();
            foreach ($messages["entities"] as $key => $message) {
                $message_guid = $message["guid"];
                if (!in_array($message_guid, $guids)) {
                    $guids[] = $message_guid;
                    $message_entity = get_entity($message_guid);
                    $recipient_id = $message_entity->toId;
                    if ($recipient_id === $user_guid) {
                        $recipient_id = $message_entity->fromId;
                    }
                    $recipient = get_entity($recipient_id);
                    $message["recipient"] = ws_pack_export_entity($recipient);
                    $messages["entities"][$key] = $message;
                } else {
                    unset($messages["entities"][$key]);
                }
            }
            $result = new SuccessResult($messages);
        }
    }
    if ($result === false) {
        $result = new ErrorResult(elgg_echo("ws_pack:error:notfound"));
    }
    return $result;
}
Exemple #23
0
/**
 * Clear all the annotations for a given entity, assuming you have access to that metadata.
 * 
 * @param int $guid
 */
function clear_annotations($guid, $name = "")
{
    global $CONFIG;
    $guid = (int) $guid;
    if (!empty($name)) {
        $name = get_metastring_id($name);
    }
    $entity_guid = (int) $guid;
    if ($entity = get_entity($entity_guid)) {
        if ($entity->canEdit()) {
            $where = array();
            if ($name != "") {
                $where[] = " name_id='{$name}'";
            }
            $query = "DELETE from {$CONFIG->dbprefix}annotations where entity_guid={$guid} ";
            foreach ($where as $w) {
                $query .= " and {$w}";
            }
            return delete_data($query);
        }
    }
}
Exemple #24
0
<?php

/**
 * Register the ElggWebinar class for the object/webinar subtype
 */
global $CONFIG;
$subtype_old = get_subtype_id('object', 'meeting');
if ($subtype_old) {
    $subtype_new = add_subtype("object", "webinar", "ElggWebinar");
    update_data("UPDATE {$CONFIG->dbprefix}entities\r\n\tSET subtype = '{$subtype_new}'\r\n\tWHERE subtype = '{$subtype_old}'\r\n\t");
    update_data("DELETE FROM {$CONFIG->dbprefix}entity_subtypes\r\n\tWHERE id = '{$subtype_old}'\r\n\t");
} else {
    add_subtype("object", "webinar", "ElggWebinar");
}
//change metastrings (webinar object's attributes)
$metastrings = array('serverSalt' => 'server_salt', 'serverURL' => 'server_url', 'logoutURL' => 'logout_url', 'welcomeString' => 'welcome_msg', 'adminPwd' => 'admin_pwd', 'userPwd' => 'user_pwd');
foreach (array_keys($metastrings) as $string_old) {
    $id = get_metastring_id($string_old);
    if ($id) {
        $string_new = $metastrings[$string_old];
        update_data("UPDATE {$CONFIG->dbprefix}metastrings\r\n\t\t\t\t\t SET string = '{$string_new}'\r\n\t\t\t\t\t WHERE id = '{$id}'\r\n\t\t\t\t\t");
    }
}
return $this->includeFile('bbb_api_conf.php');
Exemple #25
0
/**
 * Return the notable entities for a given time period based on an item of metadata.
 *
 * @param int    $start_time     The start time as a unix timestamp.
 * @param int    $end_time       The end time as a unix timestamp.
 * @param mixed  $meta_name      Metadata name
 * @param mixed  $meta_value     Metadata value
 * @param string $entity_type    The type of entity to look for, eg 'site' or 'object'
 * @param string $entity_subtype The subtype of the entity.
 * @param int    $owner_guid     Owner GUID
 * @param int    $limit          Limit
 * @param int    $offset         Offset
 * @param string $order_by       Optional ordering.
 * @param int    $site_guid      Site to get entities for. Default 0 = current site. -1 = any.
 * @param bool   $count          If true, returns count instead of entities. (Default: false)
 *
 * @return int|array A list of entities, or a count if $count is set to true
 * @access private
 * @deprecated 1.9
 */
function get_notable_entities_from_metadata($start_time, $end_time, $meta_name, $meta_value = "", $entity_type = "", $entity_subtype = "", $owner_guid = 0, $limit = 10, $offset = 0, $order_by = "", $site_guid = 0, $count = false)
{
    elgg_deprecated_notice('get_notable_entities_from_metadata() has been deprecated', 1.9);
    global $CONFIG;
    $meta_n = get_metastring_id($meta_name);
    $meta_v = get_metastring_id($meta_value);
    $start_time = (int) $start_time;
    $end_time = (int) $end_time;
    $entity_type = sanitise_string($entity_type);
    $entity_subtype = get_subtype_id($entity_type, $entity_subtype);
    $limit = (int) $limit;
    $offset = (int) $offset;
    if ($order_by == "") {
        $order_by = "e.time_created desc";
    }
    $order_by = sanitise_string($order_by);
    $site_guid = (int) $site_guid;
    if (is_array($owner_guid) && count($owner_guid)) {
        foreach ($owner_guid as $key => $guid) {
            $owner_guid[$key] = (int) $guid;
        }
    } else {
        $owner_guid = (int) $owner_guid;
    }
    if ($site_guid == 0) {
        $site_guid = $CONFIG->site_guid;
    }
    //$access = get_access_list();
    $where = array();
    if ($entity_type != "") {
        $where[] = "e.type='{$entity_type}'";
    }
    if ($entity_subtype) {
        $where[] = "e.subtype={$entity_subtype}";
    }
    if ($meta_name != "") {
        $where[] = "m.name_id='{$meta_n}'";
    }
    if ($meta_value != "") {
        $where[] = "m.value_id='{$meta_v}'";
    }
    if ($site_guid > 0) {
        $where[] = "e.site_guid = {$site_guid}";
    }
    if (is_array($owner_guid)) {
        $where[] = "e.container_guid in (" . implode(",", $owner_guid) . ")";
    } else {
        if ($owner_guid > 0) {
            $where[] = "e.container_guid = {$owner_guid}";
        }
    }
    // Add the calendar stuff
    $cal_join = "\n\t\tJOIN {$CONFIG->dbprefix}metadata cal_start on e.guid=cal_start.entity_guid\n\t\tJOIN {$CONFIG->dbprefix}metastrings cal_start_name on cal_start.name_id=cal_start_name.id\n\t\tJOIN {$CONFIG->dbprefix}metastrings cal_start_value on cal_start.value_id=cal_start_value.id\n\n\t\tJOIN {$CONFIG->dbprefix}metadata cal_end on e.guid=cal_end.entity_guid\n\t\tJOIN {$CONFIG->dbprefix}metastrings cal_end_name on cal_end.name_id=cal_end_name.id\n\t\tJOIN {$CONFIG->dbprefix}metastrings cal_end_value on cal_end.value_id=cal_end_value.id\n\t";
    $where[] = "cal_start_name.string='calendar_start'";
    $where[] = "cal_start_value.string>={$start_time}";
    $where[] = "cal_end_name.string='calendar_end'";
    $where[] = "cal_end_value.string <= {$end_time}";
    if (!$count) {
        $query = "SELECT distinct e.* ";
    } else {
        $query = "SELECT count(distinct e.guid) as total ";
    }
    $query .= "from {$CONFIG->dbprefix}entities e" . " JOIN {$CONFIG->dbprefix}metadata m on e.guid = m.entity_guid {$cal_join} where";
    foreach ($where as $w) {
        $query .= " {$w} and ";
    }
    // Add access controls
    $query .= get_access_sql_suffix("e");
    $query .= ' and ' . get_access_sql_suffix("m");
    if (!$count) {
        // Add order and limit
        $query .= " order by {$order_by} limit {$offset}, {$limit}";
        return get_data($query, "entity_row_to_elggstar");
    } else {
        if ($row = get_data_row($query)) {
            return $row->total;
        }
    }
    return false;
}
function getCategories()
{
    $result = array();
    $metadatas = elgg_get_metadata(array('annotation_name' => "category", 'type' => "object", 'subtype' => "faq", 'limit' => getFaqCount()));
    foreach ($metadatas as $metadata) {
        $cat = $metadata['value'];
        $id = get_metastring_id($cat);
        if (!in_array($id, $result)) {
            $result[$id] = $cat;
        }
    }
    natcasesort($result);
    return $result;
}
/**
 * As get_entities_from_metadata_groups() but with multiple entities.
 *
 * @param int    $group_guid     The ID of the group.
 * @param array  $meta_array     Array of 'name' => 'value' pairs
 * @param string $entity_type    The type of entity to look for, eg 'site' or 'object'
 * @param string $entity_subtype The subtype of the entity.
 * @param int    $owner_guid     Owner GUID
 * @param int    $limit          Limit
 * @param int    $offset         Offset
 * @param string $order_by       Optional ordering.
 * @param int    $site_guid      Site GUID. 0 for current, -1 for any
 * @param bool   $count          Return count of entities instead of entities
 *
 * @return int|array List of ElggEntities, or the total number if count is set to false
 * @deprecated 1.8 Use elgg_get_entities_from_metadata()
 */
function get_entities_from_metadata_groups_multi($group_guid, $meta_array, $entity_type = "", $entity_subtype = "", $owner_guid = 0, $limit = 10, $offset = 0, $order_by = "", $site_guid = 0, $count = false)
{
    elgg_deprecated_notice("get_entities_from_metadata_groups_multi was deprecated in 1.8.", 1.8);
    global $CONFIG;
    if (!is_array($meta_array) || sizeof($meta_array) == 0) {
        return false;
    }
    $where = array();
    $mindex = 1;
    $join = "";
    foreach ($meta_array as $meta_name => $meta_value) {
        $meta_n = get_metastring_id($meta_name);
        $meta_v = get_metastring_id($meta_value);
        $join .= " JOIN {$CONFIG->dbprefix}metadata m{$mindex} on e.guid = m{$mindex}.entity_guid" . " JOIN {$CONFIG->dbprefix}objects_entity o on e.guid = o.guid ";
        if ($meta_name != "") {
            $where[] = "m{$mindex}.name_id='{$meta_n}'";
        }
        if ($meta_value != "") {
            $where[] = "m{$mindex}.value_id='{$meta_v}'";
        }
        $mindex++;
    }
    $entity_type = sanitise_string($entity_type);
    $entity_subtype = get_subtype_id($entity_type, $entity_subtype);
    $limit = (int) $limit;
    $offset = (int) $offset;
    if ($order_by == "") {
        $order_by = "e.time_created desc";
    }
    $order_by = sanitise_string($order_by);
    $owner_guid = (int) $owner_guid;
    $site_guid = (int) $site_guid;
    if ($site_guid == 0) {
        $site_guid = $CONFIG->site_guid;
    }
    //$access = get_access_list();
    if ($entity_type != "") {
        $where[] = "e.type = '{$entity_type}'";
    }
    if ($entity_subtype) {
        $where[] = "e.subtype = {$entity_subtype}";
    }
    if ($site_guid > 0) {
        $where[] = "e.site_guid = {$site_guid}";
    }
    if ($owner_guid > 0) {
        $where[] = "e.owner_guid = {$owner_guid}";
    }
    if ($group_guid > 0) {
        $where[] = "e.container_guid = {$group_guid}";
    }
    if ($count) {
        $query = "SELECT count(e.guid) as total ";
    } else {
        $query = "SELECT distinct e.* ";
    }
    $query .= " from {$CONFIG->dbprefix}entities e {$join} where";
    foreach ($where as $w) {
        $query .= " {$w} and ";
    }
    $query .= get_access_sql_suffix("e");
    // Add access controls
    if (!$count) {
        $query .= " order by {$order_by} 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;
}
Exemple #28
0
function tp_get_entities_from_annotations_calculate_x($sum = "sum", $entity_type = "", $entity_subtype = "", $name = "", $mdname = '', $mdvalue = '', $owner_guid = 0, $limit = 10, $offset = 0, $orderdir = 'desc', $count = false)
{
    global $CONFIG;
    $sum = sanitise_string($sum);
    $entity_type = sanitise_string($entity_type);
    $entity_subtype = get_subtype_id($entity_type, $entity_subtype);
    $name = get_metastring_id($name);
    $limit = (int) $limit;
    $offset = (int) $offset;
    $owner_guid = (int) $owner_guid;
    if (!empty($mdname) && !empty($mdvalue)) {
        $meta_n = get_metastring_id($mdname);
        $meta_v = get_metastring_id($mdvalue);
    }
    if (empty($name)) {
        return 0;
    }
    $where = array();
    if ($entity_type != "") {
        $where[] = "e.type='{$entity_type}'";
    }
    if ($owner_guid > 0) {
        $where[] = "e.owner_guid = {$owner_guid}";
    }
    if ($entity_subtype) {
        $where[] = "e.subtype={$entity_subtype}";
    }
    if ($name != "") {
        $where[] = "a.name_id='{$name}'";
    }
    if (!empty($mdname) && !empty($mdvalue)) {
        if ($mdname != "") {
            $where[] = "m.name_id='{$meta_n}'";
        }
        if ($mdvalue != "") {
            $where[] = "m.value_id='{$meta_v}'";
        }
    }
    if ($sum != "count") {
        $where[] = "a.value_type='integer'";
    }
    // Limit on integer types
    if (!$count) {
        $query = "SELECT distinct e.*, {$sum}(ms.string) as sum ";
    } else {
        $query = "SELECT count(distinct e.guid) as num, {$sum}(ms.string) as sum ";
    }
    $query .= " from {$CONFIG->dbprefix}entities e JOIN {$CONFIG->dbprefix}annotations a on a.entity_guid = e.guid JOIN {$CONFIG->dbprefix}metastrings ms on a.value_id=ms.id ";
    if (!empty($mdname) && !empty($mdvalue)) {
        $query .= " JOIN {$CONFIG->dbprefix}metadata m on m.entity_guid = e.guid ";
    }
    $query .= " WHERE ";
    foreach ($where as $w) {
        $query .= " {$w} and ";
    }
    $query .= get_access_sql_suffix("a");
    // now add access
    $query .= ' and ' . get_access_sql_suffix("e");
    // now add access
    if (!$count) {
        $query .= ' group by e.guid';
    }
    if (!$count) {
        $query .= ' order by sum ' . $orderdir;
        $query .= ' limit ' . $offset . ' , ' . $limit;
        return get_data($query, "entity_row_to_elggstar");
    } else {
        if ($row = get_data_row($query)) {
            return $row->num;
        }
    }
    return false;
}
Exemple #29
0
}
if ($topic == "mine") {
    $interests = rijkshuisstijl_get_interests($user);
    if ($interests) {
        $options['container_guids'] = $interests;
    }
} else {
    $topic = (int) $topic;
    if ($topic) {
        $options['container_guid'] = $topic;
    }
}
$category = get_input('category', null);
if ($category) {
    $tags = get_metastring_id("tags");
    $juris = get_metastring_id("juris");
    if ($tags && $juris) {
        $options['joins'] = "LEFT JOIN elgg_metadata md ON e.guid = md.entity_guid AND md.name_id = {$tags} AND md.value_id = {$juris}";
        switch ($category) {
            case "news":
                $options['wheres'] = "md.value_id IS NULL";
                break;
            case "jurisprudence":
                $options['wheres'] = "md.value_id IS NOT NULL";
                break;
        }
    }
}
$title = elgg_echo('news');
$body = elgg_view_layout('content', array('title' => '', 'filter' => '', 'content' => elgg_view('news/pages/all', array('entities' => elgg_list_entities($options)))));
echo elgg_view_page($title, $body);
    }
}
// meta_data_exact_search_criteria
if (!empty($meta_data_exact_search_criteria)) {
    foreach ($meta_data_exact_search_criteria as $field_name => $field_value) {
        if (!empty($field_value)) {
            $meta_name_id = get_metastring_id($field_name);
            $meta_array[$meta_name_id] = "= '" . $field_value . "'";
        }
    }
}
// meta_data_between_search_criteria
if (!empty($meta_data_between_search_criteria)) {
    foreach ($meta_data_between_search_criteria as $field_name => $field_value) {
        if (!empty($field_value) && (!empty($field_value['FROM']) || !empty($field_value['TO']))) {
            $meta_name_id = get_metastring_id($field_name);
            $from = $field_value['FROM'];
            $to = $field_value['TO'];
            if (!empty($from) && !empty($to)) {
                $record_filter = "BETWEEN " . $from . " AND " . $to;
            } elseif (!empty($from)) {
                $record_filter = ">= " . $from;
            } else {
                $record_filter = "<= " . $to;
            }
            $meta_array[$meta_name_id] = $record_filter;
        }
    }
}
$mindex = 1;
$join = "";