本文整理汇总了PHP中add_metastring函数的典型用法代码示例。如果您正苦于以下问题:PHP add_metastring函数的具体用法?PHP add_metastring怎么用?PHP add_metastring使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了add_metastring函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: import_to_stormpath
function import_to_stormpath()
{
$dbprefix = elgg_get_config('dbprefix');
$subject = elgg_get_plugin_setting('import_subject', PLUGIN_ID);
$message = elgg_get_plugin_setting('import_message', PLUGIN_ID);
$site = elgg_get_site_entity();
$site_url = elgg_get_site_url();
if (!$subject || !$message) {
error_log('no subject/message');
return true;
}
if (is_elgg18()) {
$name_id = add_metastring('__stormpath_user');
$value_id = add_metastring(1);
} else {
$name_id = elgg_get_metastring_id('__stormpath_user');
$value_id = elgg_get_metastring_id(1);
}
$options = array('type' => 'user', 'joins' => array("LEFT JOIN {$dbprefix}metadata md ON md.entity_guid = e.guid AND md.name_id = {$name_id}"), 'wheres' => array('md.name_id IS NULL'), 'limit' => false);
$batch = new \ElggBatch('elgg_get_entities', $options);
$batch->setIncrementOffset(false);
foreach ($batch as $user) {
// search stormpath for a matching account
$application = get_application();
$accts = $application->getAccounts(array('email' => $user->email));
$already_exists = false;
foreach ($accts as $a) {
$user->__stormpath_user = $a->href;
error_log('set user ' . $user->username . ': ' . $a->href);
$already_exists = true;
break;
}
if ($already_exists) {
continue;
}
// change it locally
$password = generate_random_cleartext_password();
$user->salt = _elgg_generate_password_salt();
$user->password = generate_user_password($user, $password);
$user->save();
error_log('adding to stormpath ' . $user->email);
$result = add_to_stormpath($user, $password);
if ($result) {
// notify them of the change
// replace tokens in the message
$message_m = str_replace('{{password}}', $password, $message);
$message_m = str_replace('{{name}}', $user->name, $message_m);
$message_m = str_replace('{{username}}', $user->username, $message_m);
$message_m = str_replace('{{email}}', $user->email, $message_m);
$message_m = str_replace('{{forgot_password}}', $site_url . 'forgotpassword', $message_m);
$message_m = str_replace('{{site_email}}', $site->email, $message_m);
$message_m = str_replace('{{site_url}}', $site_url, $message_m);
notify_user($user->guid, $site->guid, $subject, $message_m, null, 'email');
}
}
}
示例2: 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');
if ($validated_id === false) {
$validated_id = add_metastring('validated');
}
$one_id = get_metastring_id('1');
if ($one_id === false) {
$one_id = add_metastring('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;
}
示例3: wizard_check_wizards
/**
* Make sure users follow the wizard
*
* @return void
*/
function wizard_check_wizards()
{
$user = elgg_get_logged_in_user_entity();
if (empty($user)) {
// only logged in users
return;
}
if (elgg_in_context('wizard') || elgg_in_context('admin')) {
// deadloop prevention and /admin is allowed
return;
}
if (!empty($_SESSION['wizards'])) {
if ($_SESSION['wizards'] === true) {
return;
} else {
foreach ($_SESSION['wizards'] as $index => $guid) {
$wizard = get_entity($guid);
if (empty($wizard) || !elgg_instanceof($wizard, 'object', Wizard::SUBTYPE)) {
unset($_SESSION['wizards'][$index]);
continue;
}
forward($wizard->getURL());
}
if (empty($_SESSION['wizards'])) {
$_SESSION['wizards'] = true;
}
}
}
$dbprefix = elgg_get_config('dbprefix');
$endtime_id = add_metastring('endtime');
$options = array('type' => 'object', 'subtype' => Wizard::SUBTYPE, 'limit' => false, 'metadata_name_value_pairs' => array(array('name' => 'starttime', 'value' => time(), 'operand' => '<=')), 'joins' => array("JOIN {$dbprefix}metadata mde ON e.guid = mde.entity_guid", "JOIN {$dbprefix}metastrings mse ON mde.value_id = mse.id"), 'wheres' => array("(e.guid NOT IN (SELECT guid_one\n\t\t\t\tFROM {$dbprefix}entity_relationships\n\t\t\t\tWHERE relationship = 'done'\n\t\t\t\tAND guid_two = {$user->getGUID()}\n\t\t\t))", "(mde.name_id = {$endtime_id} AND mse.string = 0 OR mse.string > " . time() . ")"));
$entities = elgg_get_entities_from_metadata($options);
if (empty($entities)) {
$_SESSION['wizards'] = true;
return;
}
$_SESSION['wizards'] = array();
foreach ($entities as $e) {
$_SESSION['wizards'][] = $e->getGUID();
}
forward($entities[0]->getURL());
}
示例4: elgg_load_library
<?php
// this is a perfect action for the vroom plugin...
elgg_load_library('simplekaltura');
elgg_load_library('KalturaClient');
set_time_limit(0);
$dbprefix = elgg_get_config('dbprefix');
$name_metastring_id = add_metastring('simplekaltura_cannot_import');
$value_metastring_id = add_metastring('1');
$options = array('type' => 'object', 'subtype' => 'kaltura_video', 'wheres' => array("NOT EXISTS ( SELECT 1 FROM {$dbprefix}metadata md WHERE md.entity_guid = e.guid AND md.name_id = {$name_metastring_id} AND md.value_id = {$value_metastring_id})"), 'limit' => false);
// inc_offset = false because we take them out of the query results
$videos = new ElggBatch('elgg_get_entities', $options, '', 25, false);
$new = get_subtype_id('object', 'simplekaltura_video');
if (!$new) {
$new = add_subtype('object', 'simplekaltura_video');
}
$old = get_subtype_id('object', 'kaltura_video');
foreach ($videos as $v) {
if ($v->simplekaltura_cannot_import) {
// we can't import this for some reason...
continue;
}
// note the old plugin made mixes which are deprecated and don't play properly
// we can get the associated source video id instead which works correctly
$entry_id = false;
// check if it's a mix (most of them are)
try {
$client = simplekaltura_create_client(true);
$entry = $client->mixing->get($v->kaltura_video_id);
$xml = new SimpleXMLElement($entry->dataContent);
$assets = $xml->VideoAssets->vidAsset[0];
示例5: getAllEvents
/**
* analog of Calendar::getAllEvents but doesn't limit to a specific calendar
*
* @param type $starttime
* @param type $endtime
*/
public static function getAllEvents($starttime, $endtime)
{
$starttime = sanitize_int($starttime);
$endtime = sanitize_int($endtime);
$dbprefix = elgg_get_config('dbprefix');
$mds_name = add_metastring('start_timestamp');
$mdre_name = add_metastring('repeat_end_timestamp');
$options = array('type' => 'object', 'subtype' => Event::SUBTYPE, 'joins' => array("JOIN {$dbprefix}metadata mds ON mds.entity_guid = e.guid", "JOIN {$dbprefix}metastrings mss ON mss.id = mds.value_id", "JOIN {$dbprefix}metadata mdre ON mdre.entity_guid = e.guid", "JOIN {$dbprefix}metastrings msre ON msre.id = mdre.value_id"), 'wheres' => array("mds.name_id = {$mds_name}", "mdre.name_id = {$mdre_name}", "((CAST(mss.string AS SIGNED) < {$endtime}) AND (CAST(msre.string AS SIGNED) > {$starttime} OR CAST(msre.string AS SIGNED) = 0))"), 'limit' => false);
return new ElggBatch('elgg_get_entities', $options);
}
示例6: group_tools_get_invited_groups_by_email
/**
* Get all the groups this email address is invited for
*
* @param string $email the email address
* @param int $site_guid (optional) site_guid
*
* @return boolean|ElggGroup[] array of groups or false on failure
*/
function group_tools_get_invited_groups_by_email($email, $site_guid = 0)
{
$result = false;
if (!empty($email)) {
$dbprefix = elgg_get_config("dbprefix");
$site_secret = get_site_secret();
$email = sanitise_string(strtolower($email));
$email_invitation_id = add_metastring("email_invitation");
if ($site_guid === 0) {
$site_guid = elgg_get_site_entity()->getGUID();
}
$options = array("type" => "group", "limit" => false, "site_guids" => $site_guid, "joins" => array("JOIN " . $dbprefix . "annotations a ON a.owner_guid = e.guid", "JOIN " . $dbprefix . "metastrings msv ON a.value_id = msv.id"), "wheres" => array("(a.name_id = " . $email_invitation_id . " AND\n\t\t\t\t\t(msv.string = md5(CONCAT('" . $site_secret . $email . "', e.guid))\n\t\t\t\t\tOR msv.string LIKE CONCAT(md5(CONCAT('" . $site_secret . $email . "', e.guid)), '|%')\n\t\t\t\t\t)\n\t\t\t\t)"));
// make sure we can see all groups
$ia = elgg_set_ignore_access(true);
$groups = elgg_get_entities($options);
if (!empty($groups)) {
$result = $groups;
}
// restore access
elgg_set_ignore_access($ia);
}
return $result;
}
示例7: get_input
<?php
$limit = get_input('limit', 20);
$offset = get_input('offset', 0);
$user = elgg_get_page_owner_entity();
$message_type = elgg_extract('message_type', $vars, 'all');
$read = elgg_extract('read', $vars, 'all');
if (!in_array($read, array(0, 1))) {
$read = 'all';
}
$strings = array('toId', $user->guid, 'readYet', $read, 'msgType', $message_type, 'msgHash');
$map = array();
foreach ($strings as $string) {
$id = get_metastring_id($string);
if (!$id) {
$id = add_metastring($string);
}
$map[$string] = $id;
}
$dbprefix = elgg_get_config('dbprefix');
$access = get_access_sql_suffix('e', $user->guid);
$subtype_id = get_subtype_id('object', 'messages');
if (!$subtype_id) {
$subtype_id = add_subtype('object', 'messages');
}
$query = "SELECT COUNT(DISTINCT md.value_id) AS count\n\t\t\tFROM {$dbprefix}metadata md\n\t\t\tJOIN {$dbprefix}entities e ON e.guid = md.entity_guid\n\t\t\tJOIN {$dbprefix}metadata md2 ON md2.entity_guid = md.entity_guid AND md2.name_id = {$map['msgType']}\n\t\t\tWHERE e.type = 'object' AND e.subtype = {$subtype_id}\n\t\t\t\tAND md.name_id = {$map['msgHash']}\n\t\t\t\tAND md2.value_id = {$map[$message_type]}\n\t\t\t\tAND e.owner_guid = {$user->guid}\n\t\t\t\tAND {$access}";
$count = get_data($query);
$count = $count[0]->count;
if (!$count) {
echo elgg_autop(elgg_echo('hj:inbox:nomessages'));
return;
示例8: array
$featured_options = array("type" => "group", "limit" => $num_display, "full_view" => false, "pagination" => false, "metadata_name_value_pairs" => array("featured_group" => "yes"), "order_by" => "RAND()");
if ($widget->show_members == "yes") {
$show_members = true;
} else {
$show_members = false;
}
if ($show_members) {
elgg_push_context("widgets_groups_show_members");
}
$featured = elgg_list_entities_from_metadata($featured_options);
if ($show_members) {
elgg_pop_context();
}
$random = "";
if ($show_random == "yes") {
$dbprefix = elgg_get_config("dbprefix");
$featured_id = add_metastring("featured_group");
$yes_id = add_metastring("yes");
$random_options = array("type" => "group", "limit" => 1, "order_by" => "RAND()", "wheres" => array("NOT EXISTS (\n\t\t\t\tSELECT 1 FROM {$dbprefix}metadata md\n\t\t\t\tWHERE md.entity_guid = e.guid\n\t\t\t\t\tAND md.name_id = {$featured_id}\n\t\t\t\t\tAND md.value_id = {$yes_id})"));
if ($random_groups = elgg_get_entities($random_options)) {
$group = $random_groups[0];
$title = elgg_view("output/url", array("text" => $group->name, "href" => $group->getURL()));
$icon = elgg_view_entity_icon($group, "large");
$random = elgg_view_module("main", $title, $icon, array("class" => "center"));
}
}
$list = $featured . $random;
if (empty($list)) {
$list = elgg_echo("notfound");
}
echo $list;
示例9: current_page_url
$action = current_page_url();
$action = elgg_http_remove_url_query_element($action, 'query');
$action = elgg_http_remove_url_query_element($action, 'simpletype');
$action = elgg_http_remove_url_query_element($action, 'limit');
$action = elgg_http_remove_url_query_element($action, 'offset');
echo elgg_view_form('embed/search_files', array('method' => 'get', 'disable_security' => true, 'action' => $action, 'class' => 'elgg-form-embed-search'), array('query' => $display_query, 'simpletype' => $simpletype));
$container_guids = array(elgg_get_logged_in_user_guid());
$page_owner = elgg_get_page_owner_entity();
if (elgg_instanceof($page_owner) && $page_owner->canWriteToContainer('object', 'file')) {
$container_guids[] = $page_owner->guid;
}
$dbprefix = elgg_get_config('dbprefix');
$options = array('types' => 'object', 'subtypes' => 'file', 'limit' => $limit, 'offset' => $offset, 'container_guids' => $container_guids, 'joins' => array(), 'wheres' => array(), 'count' => true);
if ($query) {
$string = sanitize_string($display_query);
$options['joins'][] = "JOIN {$dbprefix}objects_entity oe ON e.guid = oe.guid";
$options['wheres'][] = "oe.title LIKE '%{$string}%'";
}
if ($simpletype) {
$simpletype_id = add_metastring($simpletype);
$md_name_id = add_metastring('simpletype');
$options['joins'][] = "JOIN {$dbprefix}metadata md ON e.guid = md.entity_guid AND md.name_id = {$md_name_id} AND md.value_id = {$simpletype_id}";
}
$count = elgg_get_entities($options);
if (!$count) {
echo elgg_autop(elgg_echo('embed:tab:file:empty'));
return;
}
$options['count'] = false;
$files = elgg_get_entities($options);
echo elgg_view('embed/list', array('items' => $files, 'count' => $count, 'limit' => $limit, 'offset' => $offset));
示例10: update_metadata
/**
* Update an item of metadata.
*
* @param int $id
* @param string $name
* @param string $value
* @param string $value_type
* @param int $owner_guid
* @param int $access_id
*/
function update_metadata($id, $name, $value, $value_type, $owner_guid, $access_id)
{
global $CONFIG;
$id = (int) $id;
if (!($md = get_metadata($id))) {
return false;
}
if (!$md->canEdit()) {
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}");
}
//$name = sanitise_string(trim($name));
//$value = sanitise_string(trim($value));
$value_type = detect_extender_valuetype($value, sanitise_string(trim($value_type)));
$owner_guid = (int) $owner_guid;
if ($owner_guid == 0) {
$owner_guid = get_loggedin_userid();
}
$access_id = (int) $access_id;
$access = get_access_sql_suffix();
// Support boolean types (as integers)
if (is_bool($value)) {
if ($value) {
$value = 1;
} else {
$value = 0;
}
}
// Add the metastring
$value = add_metastring($value);
if (!$value) {
return false;
}
$name = add_metastring($name);
if (!$name) {
return false;
}
// If ok then add it
$result = update_data("UPDATE {$CONFIG->dbprefix}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 = get_metadata($id);
if (trigger_elgg_event('update', 'metadata', $obj)) {
return true;
} else {
delete_metadata($id);
}
}
return $result;
}
示例11: advanced_statistics_get_groups_data
function advanced_statistics_get_groups_data($chart_id)
{
$result = array("data" => array(), "options" => array());
$dbprefix = elgg_get_config("dbprefix");
$current_site_guid = elgg_get_site_entity()->getGUID();
switch ($chart_id) {
case "popular":
$data = array();
$query = "SELECT ge.name, count(*) AS total";
$query .= " FROM " . $dbprefix . "groups_entity ge";
$query .= " JOIN " . $dbprefix . "entity_relationships r ON ge.guid = r.guid_two";
$query .= " JOIN " . $dbprefix . "entities e ON ge.guid = e.guid";
$query .= " JOIN " . $dbprefix . "entities eu ON r.guid_one = eu.guid";
$query .= " JOIN " . $dbprefix . "users_entity ue ON eu.guid = ue.guid";
$query .= " WHERE r.relationship = 'member' AND eu.type = 'user'";
$query .= " AND eu.enabled = 'yes' AND ue.banned = 'no'";
$query .= " AND e.site_guid = " . $current_site_guid . " AND e.enabled = 'yes'";
$query .= " GROUP BY ge.name";
$query .= " ORDER BY total DESC";
$query .= " LIMIT 0, 10";
if ($query_result = get_data($query)) {
foreach ($query_result as $row) {
$total = (int) $row->total;
$data[] = array(elgg_get_excerpt($row->name, 25), $total);
}
}
$result["data"] = array($data);
$options = advanced_statistics_get_default_chart_options("bar");
$options["axes"]["xaxis"]["tickRenderer"] = "\$.jqplot.CanvasAxisTickRenderer";
$options["axes"]["xaxis"]["tickOptions"] = array("angle" => "-30", "fontSize" => "8pt");
$result["options"] = $options;
break;
case "popular-tools":
if ($group_tools = elgg_get_config("group_tool_options")) {
$yes_id = add_metastring("yes");
$data = array();
$order = array();
foreach ($group_tools as $key => $tool) {
$tool_id = add_metastring($tool->name . "_enable");
$query = "SELECT md.name_id, count(*) AS total";
$query .= " FROM " . $dbprefix . "metadata md";
$query .= " JOIN " . $dbprefix . "entities e ON md.entity_guid = e.guid";
$query .= " WHERE md.name_id = " . $tool_id;
$query .= " AND e.type = 'group' AND e.enabled = 'yes'";
$query .= " AND md.value_id = " . $yes_id;
if ($query_result = get_data_row($query)) {
$total = (int) $query_result->total;
$order[$key] = $total;
$data[$key] = array($tool->name . " [" . $total . "]", $total);
}
}
array_multisort($order, $data);
$result["data"] = array($data);
$result["options"] = advanced_statistics_get_default_chart_options("pie");
}
break;
case "most-active":
$data = array();
$week_ago = time() - 7 * 24 * 60 * 60;
$query = "SELECT ge.name, count(*) AS total";
$query .= " FROM " . $dbprefix . "river r";
$query .= " JOIN " . $dbprefix . "entities e ON r.object_guid = e.guid";
$query .= " JOIN " . $dbprefix . "entities eg ON e.container_guid = eg.guid";
$query .= " JOIN " . $dbprefix . "groups_entity ge ON eg.guid = ge.guid";
$query .= " WHERE e.enabled = 'yes' AND e.site_guid = " . $current_site_guid;
$query .= " AND eg.type = 'group' AND eg.enabled = 'yes' AND eg.site_guid = " . $current_site_guid;
$query .= " AND r.posted > " . $week_ago;
$query .= " GROUP BY ge.name";
$query .= " ORDER BY total DESC";
$query .= " LIMIT 0, 10";
if ($query_result = get_data($query)) {
foreach ($query_result as $row) {
$total = (int) $row->total;
$data[] = array(elgg_get_excerpt($row->name, 25), $total);
}
$result["data"] = array($data);
$options = advanced_statistics_get_default_chart_options("bar");
$options["axes"]["xaxis"]["tickRenderer"] = "\$.jqplot.CanvasAxisTickRenderer";
$options["axes"]["xaxis"]["tickOptions"] = array("angle" => "-30", "fontSize" => "8pt");
$result["options"] = $options;
}
break;
case "least-active":
$data = array();
$week_ago = time() - 7 * 24 * 60 * 60;
$query = "SELECT ge.name, count(*) AS total";
$query .= " FROM " . $dbprefix . "river r";
$query .= " JOIN " . $dbprefix . "entities e ON r.object_guid = e.guid";
$query .= " JOIN " . $dbprefix . "entities eg ON e.container_guid = eg.guid";
$query .= " JOIN " . $dbprefix . "groups_entity ge ON eg.guid = ge.guid";
$query .= " WHERE e.enabled = 'yes' AND e.site_guid = " . $current_site_guid;
$query .= " AND eg.type = 'group' AND eg.enabled = 'yes' AND eg.site_guid = " . $current_site_guid;
$query .= " GROUP BY ge.name";
$query .= " ORDER BY total ASC";
$query .= " LIMIT 0, 10";
if ($query_result = get_data($query)) {
foreach ($query_result as $row) {
$total = (int) $row->total;
$data[] = array(elgg_get_excerpt($row->name, 25), $total);
}
//.........这里部分代码省略.........
示例12: switch
switch ($widget->context) {
case "profile":
$options["owner_guid"] = $widget->getOwnerGUID();
break;
case "dashboard":
$type = $widget->content_type;
if ($type == "todo" && !questions_is_expert()) {
$type = "mine";
}
// user shows owned
switch ($type) {
case "todo":
$getter = "elgg_get_entities_from_metadata";
// prepare options
$dbprefix = elgg_get_config("dbprefix");
$correct_answer_id = add_metastring("correct_answer");
$site = elgg_get_site_entity();
$user = elgg_get_logged_in_user_entity();
$container_where = array();
$options["wheres"] = array("NOT EXISTS (\n\t\t\t\t\t\t\tSELECT 1\n\t\t\t\t\t\t\tFROM " . $dbprefix . "entities e2\n\t\t\t\t\t\t\tJOIN " . $dbprefix . "metadata md ON e2.guid = md.entity_guid\n\t\t\t\t\t\t\tWHERE e2.container_guid = e.guid\n\t\t\t\t\t\t\tAND md.name_id = " . $correct_answer_id . ")");
$options["order_by_metadata"] = array("name" => "solution_time");
if (check_entity_relationship($user->getGUID(), QUESTIONS_EXPERT_ROLE, $site->getGUID())) {
$container_where[] = "(e.container_guid NOT IN (\n\t\t\t\t\t\tSELECT ge.guid\n\t\t\t\t\t\tFROM " . $dbprefix . "entities ge\n\t\t\t\t\t\tWHERE ge.type = 'group'\n\t\t\t\t\t\tAND ge.site_guid = " . $site->getGUID() . "\n\t\t\t\t\t\tAND ge.enabled = 'yes'\n\t\t\t\t\t))";
}
$group_options = array("type" => "group", "limit" => false, "relationship" => QUESTIONS_EXPERT_ROLE, "relationship_guid" => $user->getGUID(), "callback" => "questions_row_to_guid");
$groups = elgg_get_entities_from_relationship($group_options);
if (!empty($groups)) {
$container_where[] = "(e.container_guid IN (" . implode(",", $groups) . "))";
}
$container_where = "(" . implode(" OR ", $container_where) . ")";
$options["wheres"][] = $container_where;
示例13: get_object_total
/**
* Get total score that was collected on an object by a given user with a given rule in given time frame
*
* @param object $object
* @param ElggUser $user
* @param string $rule
* @param int $time_lower
* @param int $time_upper
* @return int
*/
function get_object_total($object, $user = null, $rule = null, $time_lower = null, $time_upper = null)
{
if (!is_object($object)) {
return 0;
}
$object_id = isset($object->guid) ? $object->guid : $object->id;
$object_type = $object->getType();
$dbprefix = elgg_get_config('dbprefix');
$msn_id = add_metastring('object_ref');
$msv_id = add_metastring("{$object_type}:{$object_id}");
$options = array('type' => 'object', 'subtype' => HYPEGAMEMECHANICS_SCORE_SUBTYPE, 'container_guid' => $user->guid, 'metadata_names' => 'annotation_value', 'metadata_calculation' => 'sum', 'metadata_created_time_lower' => $time_lower, 'metadata_created_time_upper' => $time_upper, 'joins' => array("JOIN {$dbprefix}metadata objmd ON n_table.entity_guid = objmd.entity_guid"), 'wheres' => array("(objmd.name_id = {$msn_id} AND objmd.value_id = {$msv_id})"));
if (!empty($rule)) {
$msn_id = add_metastring('rule');
$msv_id = add_metastring($rule);
$options['joins'][] = "JOIN {$dbprefix}metadata rulemd ON n_table.entity_guid = rulemd.entity_guid";
$options['wheres'][] = "(rulemd.name_id = {$msn_id} AND rulemd.value_id = {$msv_id})";
}
return (int) elgg_get_metadata($options);
}
示例14: elgg_get_plugin_setting
<?php
// Get search-specific settings
$serialized_settings = elgg_get_plugin_setting('search-settings', 'community_plugins');
$settings = unserialize($serialized_settings);
if (!is_array($settings)) {
$settings = array();
}
$offset = get_input('offset', 0);
$limit = get_input('limit', 10);
$options = array('type' => 'object', 'subtype' => 'plugin_project', 'preload_owners' => true);
$list_type = get_input('type');
$dbprefix = elgg_get_config('dbprefix');
switch ($list_type) {
case 'recommended':
$digg_id = add_metastring('plugin_digg', true);
$options['selects'] = array("count(a.entity_guid) as recommendations");
$options['joins'][] = "LEFT JOIN {$dbprefix}annotations a on (e.guid = a.entity_guid AND a.name_id = {$digg_id})";
$group_bys = array('e.guid', 'a.entity_guid');
$options['group_by'] = implode(',', $group_bys);
$options['order_by'] = "recommendations DESC";
break;
case 'popular':
$options['selects'] = array("a.downloads");
$options['joins'][] = "LEFT JOIN {$dbprefix}plugin_downloads a on (e.guid = a.guid)";
$group_bys = array('e.guid', 'a.guid');
$options['group_by'] = implode(',', $group_bys);
$options['order_by'] = "a.downloads DESC";
break;
case 'newest':
default:
示例15: array
if (!empty($profile_fields)) {
$params["joins"] = array("JOIN {$db_prefix}groups_entity ge ON e.guid = ge.guid", "JOIN {$db_prefix}metadata md on e.guid = md.entity_guid", "JOIN {$db_prefix}metastrings msv ON md.value_id = msv.id");
} else {
$params["joins"] = array("JOIN {$db_prefix}groups_entity ge ON e.guid = ge.guid");
}
$where = "ge.name LIKE '%{$query}%' OR ge.description LIKE '%{$query}%'";
if (!empty($profile_fields)) {
// get the where clauses for the md names
// can't use egef_metadata() because the n_table join comes too late.
// $clauses = elgg_entities_get_metastrings_options("metadata", array(
// "metadata_names" => $profile_fields,
// ));
// $params["joins"] = array_merge($clauses["joins"], $params["joins"]);
$tag_name_ids = array();
foreach ($profile_fields as $field) {
$tag_name_ids[] = add_metastring($field);
}
$md_where = "((md.name_id IN (" . implode(",", $tag_name_ids) . ")) AND (msv.string LIKE '%{$query}%'))";
$params["wheres"] = array("(({$where}) OR ({$md_where}))");
} else {
$params["wheres"] = array($where);
}
$content = elgg_list_entities($params);
}
if (empty($content)) {
$content = elgg_echo("groups:search:none");
}
$sidebar = elgg_view("groups/sidebar/find");
$sidebar .= elgg_view("groups/sidebar/featured");
$params = array("content" => $content, "sidebar" => $sidebar, "filter" => false, "title" => $title);
$body = elgg_view_layout("content", $params);