本文整理汇总了PHP中elgg_get_metastring_id函数的典型用法代码示例。如果您正苦于以下问题:PHP elgg_get_metastring_id函数的具体用法?PHP elgg_get_metastring_id怎么用?PHP elgg_get_metastring_id使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了elgg_get_metastring_id函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: bulk_user_admin_get_sql_where_not_enqueued
function bulk_user_admin_get_sql_where_not_enqueued()
{
$db_prefix = get_config('dbprefix');
$name_id = elgg_get_metastring_id(\BulkUserAdmin\DeleteService::PENDING_DELETE_MD);
$value_id = elgg_get_metastring_id(true);
return "NOT EXISTS (\n\t\t\tSELECT 1 FROM {$db_prefix}metadata md\n\t\t\tWHERE md.entity_guid = e.guid\n\t\t\t\tAND md.name_id = {$name_id}\n\t\t\t\tAND md.value_id = {$value_id})";
}
示例2: getOptions
protected function getOptions()
{
$options = parent::getOptions();
if ($this->banned === true) {
$options['wheres'][] = "u.banned = 'yes'";
} elseif ($this->banned === false) {
$options['wheres'][] = "u.banned = 'no'";
}
if ($this->admin === true) {
$options['wheres'][] = "u.admin = 'yes'";
} elseif ($this->admin === false) {
$options['wheres'][] = "u.admin = 'no'";
}
if ($this->search) {
$q = sanitize_string($this->search);
$where = "u.name LIKE \"%{$q}%\" OR u.username LIKE \"%{$q}%\"";
if (\elgg_is_admin_logged_in()) {
$where .= " u.email LIKE \"%{$q}%\"";
}
$options['wheres'][] = "({$where})";
}
/*
* "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".
*/
if ($this->validated === false) {
$validated_id = \elgg_get_metastring_id('validated');
$one_id = \elgg_get_metastring_id('1');
$options['wheres'][] = "NOT EXISTS (\n\t\t\t\tSELECT 1 FROM {$this->getDB()->getPrefix()}metadata validated_md\n\t\t\t\tWHERE validated_md.entity_guid = e.guid\n\t\t\t\t\tAND validated_md.name_id = {$validated_id}\n\t\t\t\t\tAND validated_md.value_id = {$one_id})";
}
return $options;
}
示例3: getSubcategoriesQueryOptions
/**
* Prepares ege* options for querying subcategories
*
* @param mixed $containers Containers (guids or entities)
* @param array $options ege* options
* @return ElggBatch
*/
public function getSubcategoriesQueryOptions($containers, array $options = array())
{
$dbprefix = elgg_get_config('dbprefix');
$nid = elgg_get_metastring_id('priority');
$defaults = array('selects' => array('CAST(msv.string AS SIGNED) AS priority'), 'types' => 'object', 'subtypes' => $this->config->getCategorySubtypes(), 'joins' => array("JOIN {$dbprefix}metadata md ON md.entity_guid = e.guid AND md.name_id = {$nid}", "JOIN {$dbprefix}metastrings msv ON msv.id = md.value_id"), 'order_by' => 'priority = 0, priority ASC');
$options = array_merge($defaults, $options);
$options['container_guids'] = ItemCollection::create($containers)->guids();
return $options;
}
示例4: addSortQuery
/**
* {@inheritdoc}
*/
public static function addSortQuery(array $options = [], $field = 'time_created', $direction = 'DESC')
{
$dbprefix = elgg_get_config('dbprefix');
$order_by = explode(',', elgg_extract('order_by', $options, ''));
array_walk($order_by, 'trim');
$options['joins']['objects_entity'] = "\n\t\t\tJOIN {$dbprefix}objects_entity AS objects_entity\n\t\t\t\tON objects_entity.guid = e.guid\n\t\t\t";
switch ($field) {
case 'type':
case 'subtype':
case 'guid':
case 'owner_guid':
case 'container_guid':
case 'site_guid':
case 'enabled':
case 'time_created':
case 'time_updated':
case 'access_id':
array_unshift($order_by, "e.{$field} {$direction}");
break;
case 'title':
case 'description':
array_unshift($order_by, "objects_entity.{$field} {$direction}");
break;
case 'last_action':
$options['selects']['last_action'] = "\n\t\t\t\t\tGREATEST (e.time_created, e.last_action, e.time_updated) AS last_action\n\t\t\t\t\t";
array_unshift($order_by, "last_action {$direction}");
break;
case 'likes_count':
$name_id = elgg_get_metastring_id('likes');
$options['joins']['likes_count'] = "\n\t\t\t\t\tLEFT JOIN {$dbprefix}annotations AS likes\n\t\t\t\t\t\tON likes.entity_guid = e.guid AND likes.name_id = {$name_id}\n\t\t\t\t\t";
$options['selects']['likes_count'] = "COUNT(likes.id) as likes_count";
$options['group_by'] = 'e.guid';
array_unshift($order_by, "likes_count {$direction}");
$order_by[] = 'e.time_created DESC';
// show newest first if count is the same
break;
case 'responses_count':
$ids = array();
$ids[] = (int) get_subtype_id('object', 'comment');
$ids[] = (int) get_subtype_id('object', 'discussion_reply');
$ids_in = implode(',', $ids);
$options['joins']['responses_count'] = "\n\t\t\t\t\tLEFT JOIN {$dbprefix}entities AS responses\n\t\t\t\t\t\tON responses.container_guid = e.guid\n\t\t\t\t\t\tAND responses.type = 'object'\n\t\t\t\t\t\tAND responses.subtype IN ({$ids_in})\n\t\t\t\t\t";
$options['selects']['responses_count'] = "COUNT(responses.guid) as responses_count";
$options['group_by'] = 'e.guid';
array_unshift($order_by, "responses_count {$direction}");
$order_by[] = 'e.time_created DESC';
// show newest first if count is the same
break;
}
if ($field == 'alpha') {
array_unshift($order_by, "objects_entity.title {$direction}");
}
$options['order_by'] = implode(', ', array_unique(array_filter($order_by)));
$params = array('field' => $field, 'direction' => $direction);
return elgg_trigger_plugin_hook('sort_options', 'object', $params, $options);
}
示例5: 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');
}
}
}
示例6: 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()
{
$db_prefix = elgg_get_config('dbprefix');
$validated_id = elgg_get_metastring_id('validated');
$one_id = elgg_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 {$db_prefix}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;
}
示例7: daily
/**
* Publish blogs based on advanced publication options
*
* @param string $hook 'cron'
* @param string $type 'daily'
* @param string $return_value optional stdout text
* @param array $params supplied params
*
* @return void
*/
public static function daily($hook, $type, $return_value, $params)
{
// only do if this is configured
if (!blog_tools_use_advanced_publication_options()) {
return $return_value;
}
$dbprefix = elgg_get_config("dbprefix");
$publication_id = elgg_get_metastring_id("publication_date");
$expiration_id = elgg_get_metastring_id("expiration_date");
$time = elgg_extract("time", $params, time());
$publish_options = array("type" => "object", "subtype" => "blog", "limit" => false, "joins" => array("JOIN " . $dbprefix . "metadata mdtime ON e.guid = mdtime.entity_guid", "JOIN " . $dbprefix . "metastrings mstime ON mdtime.value_id = mstime.id"), "metadata_name_value_pairs" => array(array("name" => "status", "value" => "draft")), "wheres" => array("((mdtime.name_id = " . $publication_id . ") AND (DATE(mstime.string) = DATE(NOW())))"));
$unpublish_options = array("type" => "object", "subtype" => "blog", "limit" => false, "joins" => array("JOIN " . $dbprefix . "metadata mdtime ON e.guid = mdtime.entity_guid", "JOIN " . $dbprefix . "metastrings mstime ON mdtime.value_id = mstime.id"), "metadata_name_values_pairs" => array(array("name" => "status", "value" => "published")), "wheres" => array("((mdtime.name_id = " . $expiration_id . ") AND (DATE(mstime.string) = DATE(NOW())))"));
// ignore access
$ia = elgg_set_ignore_access(true);
// get unpublished blogs that need to be published
$entities = new \ElggBatch("elgg_get_entities_from_metadata", $publish_options);
foreach ($entities as $entity) {
// add river item
elgg_create_river_item(array("view" => "river/object/blog/create", "action_type" => "create", "subject_guid" => $entity->getOwnerGUID(), "object_guid" => $entity->getGUID()));
// set correct time created
$entity->time_created = $time;
// publish blog
$entity->status = "published";
// revert access
$entity->access_id = $entity->future_access;
unset($entity->future_access);
// send notifications when post published
elgg_trigger_event('publish', 'object', $entity);
// notify owner
notify_user($entity->getOwnerGUID(), $entity->site_guid, elgg_echo("blog_tools:notify:publish:subject"), elgg_echo("blog_tools:notify:publish:message", array($entity->title, $entity->getURL())));
// save everything
$entity->save();
}
// get published blogs that need to be unpublished
$entities = new \ElggBatch("elgg_get_entities_from_metadata", $unpublish_options);
foreach ($entities as $entity) {
// remove river item
elgg_delete_river(array("object_guid" => $entity->getGUID(), "action_type" => "create"));
// unpublish blog
$entity->status = "draft";
// notify owner
notify_user($entity->getOwnerGUID(), $entity->site_guid, elgg_echo("blog_tools:notify:expire:subject"), elgg_echo("blog_tools:notify:expire:message", array($entity->title, $entity->getURL())));
// save everything
$entity->save();
}
// reset access
elgg_set_ignore_access($ia);
}
示例8: unpublishBlogs
/**
* Unpublish blogs based on advanced publication settings
*
* @return void
*/
protected static function unpublishBlogs()
{
$dbprefix = elgg_get_config('dbprefix');
$expiration_id = elgg_get_metastring_id('expiration_date');
$unpublish_options = ['type' => 'object', 'subtype' => 'blog', 'limit' => false, 'joins' => ["JOIN {$dbprefix}metadata mdtime ON e.guid = mdtime.entity_guid", "JOIN {$dbprefix}metastrings mstime ON mdtime.value_id = mstime.id"], 'metadata_name_values_pairs' => [['name' => 'status', 'value' => 'published']], 'wheres' => ["((mdtime.name_id = {$expiration_id}) AND (DATE(mstime.string) = DATE(NOW())))"]];
// get published blogs that need to be unpublished
$entities = new \ElggBatch('elgg_get_entities_from_metadata', $unpublish_options);
foreach ($entities as $entity) {
// remove river item
elgg_delete_river(['object_guid' => $entity->getGUID(), 'action_type' => 'create']);
// unpublish blog
$entity->status = 'draft';
// notify owner
notify_user($entity->getOwnerGUID(), $entity->site_guid, elgg_echo('blog_tools:notify:expire:subject'), elgg_echo('blog_tools:notify:expire:message', [$entity->title, $entity->getURL()]));
// save everything
$entity->save();
}
}
示例9: 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 = elgg_get_metastring_id('metaUnitTest', true);
$this->assertEqual($cs_ids, $this->metastrings['metaUnitTest']);
// lookup all metastrings, ignoring case
$cs_ids = elgg_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));
}
}
示例10: pages_tools_get_publication_wheres
/**
* Get the where selector for advanced publications
*
* @return array
*/
function pages_tools_get_publication_wheres()
{
static $result;
if (!isset($result)) {
$result = array();
if (pages_tools_use_advanced_publication_options()) {
$unpublished_id = elgg_get_metastring_id("unpublished");
$dbprefix = elgg_get_config("dbprefix");
$query = "(e.guid NOT IN (";
$query .= "SELECT entity_guid";
$query .= " FROM {$dbprefix}metadata";
$query .= " WHERE name_id = {$unpublished_id}";
$query .= "))";
$result[] = $query;
}
}
return $result;
}
示例11: elgg_pop_breadcrumb
// all groups doesn't get link to self
elgg_pop_breadcrumb();
elgg_push_breadcrumb(elgg_echo('groups'));
// only register title button if allowed
if (elgg_get_plugin_setting('limited_groups', 'groups') != 'yes' || elgg_is_admin_logged_in()) {
elgg_register_title_button();
}
$selected_tab = get_input('filter');
//system_message("selected tab " . $selected_tab);
// default group options
$group_options = ['type' => 'group', 'full_view' => false];
$dbprefix = elgg_get_config('dbprefix');
//system_message("teranga selected tab es ... " . $selected_tab);
switch ($selected_tab) {
case 'ordered':
$order_id = elgg_get_metastring_id('order');
$group_options['limit'] = false;
$group_options['pagination'] = false;
$group_options['selects'] = ["IFNULL((SELECT order_ms.string as order_val\n\t\t\tFROM {$dbprefix}metadata mo\n\t\t\tJOIN {$dbprefix}metastrings order_ms ON mo.value_id = order_ms.id\n\t\t\tWHERE e.guid = mo.entity_guid\n\t\t\tAND mo.name_id = {$order_id}), 99999) AS order_val"];
$group_options['order_by'] = 'CAST(order_val AS SIGNED) ASC, e.time_created DESC';
if (elgg_is_admin_logged_in()) {
elgg_require_js('fuzzy_filter/ordered_list');
$group_options['list_class'] = 'fuzzy-filter-list-ordered';
}
break;
case 'yours':
elgg_gatekeeper();
$group_options['relationship'] = 'member';
$group_options['relationship_guid'] = elgg_get_logged_in_user_guid();
$group_options['inverse_relationship'] = false;
break;
示例12: get_input
$oldCat = get_input("oldCat");
$newCat = get_input("newCat");
$access = (int) get_input("access");
if (!empty($question) && !empty($answer) && !empty($access) && (!empty($oldCat) || !empty($newCat))) {
$cat = "";
if ($oldCat == "newCat" && !empty($newCat)) {
$cat = ucfirst(strtolower($newCat));
} else {
$cat = ucfirst(strtolower($oldCat));
}
if (!empty($cat)) {
$faq = new FAQObject();
$faq->container_guid = elgg_get_config('site_guid');
$faq->owner_guid = elgg_get_config('site_guid');
$faq->category = $cat;
$faq->question = $question;
$faq->answer = $answer;
$faq->access_id = $access;
if ($faq->save()) {
system_message(elgg_echo("faq:add:success"));
} else {
register_error(elgg_echo("faq:add:error:save"));
}
} else {
register_error(elgg_echo("faq:add:error:invalid_input"));
}
} else {
register_error(elgg_echo("faq:add:error:invalid_input"));
}
forward(elgg_get_site_url() . "faq/list?categoryId=" . elgg_get_metastring_id($faq->category));
示例13: elgg_view_entity
$answers = '';
// add the answer marked as the correct answer first
$marked_answer = $question->getMarkedAnswer();
if (!empty($marked_answer)) {
$answers .= elgg_view_entity($marked_answer);
}
// add the rest of the answers
$options = ['type' => 'object', 'subtype' => 'answer', 'container_guid' => $question->getGUID(), 'count' => true, 'limit' => false];
if (!empty($marked_answer)) {
// do not include the marked answer as it already added to the output before
$options['wheres'] = ["e.guid <> {$marked_answer->getGUID()}"];
}
if (elgg_is_active_plugin('likes')) {
// order answers based on likes
$dbprefix = elgg_get_config('dbprefix');
$likes_id = elgg_get_metastring_id('likes');
$options['selects'] = ["(SELECT count(a.name_id) AS likes_count\n\t\tFROM {$dbprefix}annotations a\n\t\tWHERE a.entity_guid = e.guid\n\t\tAND a.name_id = {$likes_id}) AS likes_count"];
$options['order_by'] = 'likes_count desc, e.time_created asc';
}
$answers .= elgg_list_entities($options);
$count = elgg_get_entities($options);
if (!empty($marked_answer)) {
$count++;
}
if (!empty($answers)) {
$content .= elgg_view_module('info', "{$count} " . elgg_echo('answers'), $answers, ['class' => 'mtm', 'id' => 'question-answers']);
}
// add answer form
if ($question->getStatus() === 'open' && $question->canWriteToContainer(0, 'object', 'answer')) {
$add_form = elgg_view_form('object/answer/add', [], ['container_guid' => $question->getGUID()]);
$content .= elgg_view_module('info', elgg_echo('answers:addyours'), $add_form);
示例14: 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;
$user_guid = (int) $user_guid;
// 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 = elgg_get_metastring_id('admin');
$yes = elgg_get_metastring_id('yes');
$one = elgg_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;
}
示例15: elgg_get_config
<?php
// Get all received messages fromId != owner_guid
$dbprefix = elgg_get_config('dbprefix');
$fromId = elgg_get_metastring_id('fromId');
echo elgg_view('admin/inbox/search');
$query = get_input('query');
$options = array('types' => 'object', 'subtypes' => 'messages', 'joins' => array("JOIN {$dbprefix}metadata md ON md.entity_guid = e.guid AND md.name_id = {$fromId}", "JOIN {$dbprefix}metastrings fromId ON fromId.id = md.value_id"), 'wheres' => array('fromId.string != e.owner_guid'), 'preload_owners' => true, 'no_results' => elgg_echo('inbox:monitor:no_results'), 'item_view' => 'object/messages/admin');
if ($query) {
$query = sanitize_string($query);
$options['query'] = $query;
$options['joins'][] = "JOIN {$dbprefix}objects_entity oe ON e.guid = oe.guid";
$fields = array('title', 'description');
$where = search_get_where_sql('oe', $fields, $options);
$options['wheres'][] = $where;
}
$module = elgg_view('object/messages/controls');
$module .= elgg_list_entities($options);
echo elgg_format_element('div', array('class' => 'inbox-monitor-module'), $module);