本文整理汇总了PHP中elgg_get_entities_from_private_settings函数的典型用法代码示例。如果您正苦于以下问题:PHP elgg_get_entities_from_private_settings函数的具体用法?PHP elgg_get_entities_from_private_settings怎么用?PHP elgg_get_entities_from_private_settings使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了elgg_get_entities_from_private_settings函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: factory
/**
* Initialize a consumer from API key
*
* @param string $api_key API Key
* @return Consumer|void
*/
public static function factory($api_key)
{
if (!$api_key) {
return;
}
$ia = elgg_set_ignore_access(true);
$consumers = elgg_get_entities_from_private_settings(array('types' => 'object', 'subtypes' => self::SUBTYPE, 'private_setting_name_value_pairs' => array('name' => 'api_key', 'value' => $api_key), 'limit' => 1));
$consumer = !empty($consumers) ? $consumers[0] : null;
elgg_set_ignore_access($ia);
return $consumer;
}
示例2: testElggApiGettersEntitiesFromPrivateSettings
public function testElggApiGettersEntitiesFromPrivateSettings()
{
// create some test private settings
$setting_name = 'test_setting_name_' . rand();
$setting_value = rand(1000, 9999);
$setting_name2 = 'test_setting_name_' . rand();
$setting_value2 = rand(1000, 9999);
$subtypes = $this->getRandomValidSubtypes(array('object'), 1);
$subtype = $subtypes[0];
$guids = array();
// our targets
$valid = new ElggObject();
$valid->subtype = $subtype;
$valid->save();
$guids[] = $valid->getGUID();
set_private_setting($valid->getGUID(), $setting_name, $setting_value);
set_private_setting($valid->getGUID(), $setting_name2, $setting_value2);
$valid2 = new ElggObject();
$valid2->subtype = $subtype;
$valid2->save();
$guids[] = $valid2->getGUID();
set_private_setting($valid2->getGUID(), $setting_name, $setting_value);
set_private_setting($valid2->getGUID(), $setting_name2, $setting_value2);
// simple test with name
$options = array('private_setting_name' => $setting_name);
$entities = elgg_get_entities_from_private_settings($options);
foreach ($entities as $entity) {
$this->assertTrue(in_array($entity->getGUID(), $guids));
$value = get_private_setting($entity->getGUID(), $setting_name);
$this->assertEqual($value, $setting_value);
}
// simple test with value
$options = array('private_setting_value' => $setting_value);
$entities = elgg_get_entities_from_private_settings($options);
foreach ($entities as $entity) {
$this->assertTrue(in_array($entity->getGUID(), $guids));
$value = get_private_setting($entity->getGUID(), $setting_name);
$this->assertEqual($value, $setting_value);
}
// test pairs
$options = array('type' => 'object', 'subtype' => $subtype, 'private_setting_name_value_pairs' => array(array('name' => $setting_name, 'value' => $setting_value), array('name' => $setting_name2, 'value' => $setting_value2)));
$entities = elgg_get_entities_from_private_settings($options);
$this->assertEqual(2, count($entities));
foreach ($entities as $entity) {
$this->assertTrue(in_array($entity->getGUID(), $guids));
}
foreach ($guids as $guid) {
if ($e = get_entity($guid)) {
$e->delete();
}
}
}
开发者ID:nooshin-mirzadeh,项目名称:web_2.0_benchmark,代码行数:52,代码来源:ElggCoreGetEntitiesFromPrivateSettingsTest.php
示例3: getWidgets
public function getWidgets($context = 'framework')
{
$owner = $this->getOwnerEntity();
$options = array('type' => 'object', 'subtype' => 'widget', 'owner_guid' => $owner->guid, 'private_setting_name' => 'context', 'private_setting_value' => $context, 'limit' => 0);
$widgets = elgg_get_entities_from_private_settings($options);
foreach ($widgets as $widget) {
if ($widget->container_guid == $this->guid) {
$segment_widgets[] = $widget;
}
}
if (!$segment_widgets) {
return array();
}
return $segment_widgets;
}
示例4: widget_favorites_has_widget
function widget_favorites_has_widget($owner_guid = 0)
{
$result = false;
if (empty($owner_guid)) {
if ($user_guid = elgg_get_logged_in_user_guid()) {
$owner_guid = $user_guid;
}
}
if (!empty($owner_guid)) {
$options = array("type" => "object", "subtype" => "widget", "private_setting_name_value_pairs" => array("handler" => "favorites"), "count" => true, "owner_guid" => $owner_guid);
if (elgg_get_entities_from_private_settings($options)) {
$result = true;
}
}
return $result;
}
示例5: elgg_modifications_reportedcontent_hook
function elgg_modifications_reportedcontent_hook($hook, $type, $return_value, $params)
{
if (!empty($params) && is_array($params)) {
$report = elgg_extract("report", $params);
$site = elgg_get_site_entity();
if (!subsite_manager_check_global_plugin_setting("reportedcontent", "use_global_usersettings")) {
$setting = ELGG_PLUGIN_USER_SETTING_PREFIX . "reportedcontent:" . $site->getGUID() . ":notify";
} else {
$setting = ELGG_PLUGIN_USER_SETTING_PREFIX . "reportedcontent:notify";
}
// get users with setting
$options = array("type" => "user", "limit" => false, "site_guids" => false, "private_setting_name" => $setting, "private_setting_value" => "yes");
if ($users = elgg_get_entities_from_private_settings($options)) {
$filtered_users = array();
if (elgg_instanceof($site, "site", Subsite::SUBTYPE, "Subsite")) {
foreach ($users as $user) {
if ($user->getGUID() != $report->getOwner() && ($user->isAdmin() || $site->isAdmin($user->getGUID()))) {
$filtered_users[] = $user;
}
}
} else {
foreach ($users as $user) {
if ($user->getGUID() != $report->getOwner() && $user->isAdmin()) {
$filtered_users[] = $user;
}
}
}
if (!empty($filtered_users)) {
$subject = elgg_echo("elgg_modifications:usersettings:reportedcontent:notify:subject");
$message = elgg_echo("elgg_modifications:usersettings:reportedcontent:notify:message", array($report->getOwnerEntity()->name, $site->url . "admin/administer_utilities/reportedcontent"));
foreach ($filtered_users as $user) {
notify_user($user->getGUID(), $report->getOwner(), $subject, $message);
}
}
}
}
}
示例6: getWidgets
/**
* @see elgg_get_widgets
* @access private
* @since 1.9.0
*/
public function getWidgets($owner_guid, $context)
{
$widget_cache_key = "{$context}-{$owner_guid}";
if (isset($this->widgetCache[$widget_cache_key])) {
return $this->widgetCache[$widget_cache_key];
}
$options = array('type' => 'object', 'subtype' => 'widget', 'owner_guid' => $owner_guid, 'private_setting_name' => 'context', 'private_setting_value' => $context, 'limit' => 0);
$widgets = elgg_get_entities_from_private_settings($options);
if (!$widgets) {
return array();
}
$sorted_widgets = array();
foreach ($widgets as $widget) {
if (!isset($sorted_widgets[(int) $widget->column])) {
$sorted_widgets[(int) $widget->column] = array();
}
$sorted_widgets[(int) $widget->column][$widget->order] = $widget;
}
foreach ($sorted_widgets as $col => $widgets) {
ksort($sorted_widgets[$col]);
}
$this->widgetCache[$widget_cache_key] = $sorted_widgets;
return $sorted_widgets;
}
示例7: elgg_get_entities_from_private_settings
<?php
/**
* Lists pending upgrades
*/
$upgrades = elgg_get_entities_from_private_settings(array('type' => 'object', 'subtype' => 'elgg_upgrade', 'private_setting_name' => 'is_completed', 'private_setting_value' => false));
if (!$upgrades) {
echo elgg_echo('admin:upgrades:none');
} else {
echo elgg_view_entity_list($upgrades);
}
示例8: elgg_get_entities_from_plugin_user_settings
/**
* Returns entities based upon plugin settings.
* Takes all the options for {@see elgg_get_entities_from_private_settings()}
* in addition to the ones below.
*
* @param array $options Array in the format:
*
* plugin_id => NULL|STR The plugin id. Defaults to calling plugin
*
* plugin_user_setting_names => NULL|ARR private setting names
*
* plugin_user_setting_values => NULL|ARR metadata values
*
* plugin_user_setting_name_value_pairs => NULL|ARR (
* name => 'name',
* value => 'value',
* 'operand' => '=',
* )
* Currently if multiple values are sent via
* an array (value => array('value1', 'value2')
* the pair's operand will be forced to "IN".
*
* plugin_user_setting_name_value_pairs_operator => NULL|STR The operator to use for combining
* (name = value) OPERATOR (name = value); default AND
*
* @return mixed int If count, int. If not count, array. false on errors.
*/
function elgg_get_entities_from_plugin_user_settings(array $options = array())
{
// if they're passing it don't bother
if (!isset($options['plugin_id'])) {
$options['plugin_id'] = elgg_get_calling_plugin_id();
}
$singulars = array('plugin_user_setting_name', 'plugin_user_setting_value', 'plugin_user_setting_name_value_pair');
$options = elgg_normalise_plural_options_array($options, $singulars);
// rewrite plugin_user_setting_name_* to the right PS ones.
$map = array('plugin_user_setting_names' => 'private_setting_names', 'plugin_user_setting_values' => 'private_setting_values', 'plugin_user_setting_name_value_pairs' => 'private_setting_name_value_pairs', 'plugin_user_setting_name_value_pairs_operator' => 'private_setting_name_value_pairs_operator');
foreach ($map as $plugin => $private) {
if (!isset($options[$plugin])) {
continue;
}
if (isset($options[$private])) {
if (!is_array($options[$private])) {
$options[$private] = array($options[$private]);
}
$options[$private] = array_merge($options[$private], $options[$plugin]);
} else {
$options[$private] = $options[$plugin];
}
}
$plugin_id = $options['plugin_id'];
$prefix = elgg_namespace_plugin_private_setting('user_setting', '', $plugin_id);
$options['private_setting_name_prefix'] = $prefix;
return elgg_get_entities_from_private_settings($options);
}
示例9: move
/**
* Move the widget
*
* @param int $column The widget column
* @param int $rank Zero-based rank from the top of the column
* @return void
* @since 1.8.0
*/
public function move($column, $rank)
{
$options = array('type' => 'object', 'subtype' => 'widget', 'container_guid' => $this->container_guid, 'limit' => false, 'private_setting_name_value_pairs' => array(array('name' => 'context', 'value' => $this->getContext()), array('name' => 'column', 'value' => $column)));
$widgets = elgg_get_entities_from_private_settings($options);
if (!$widgets) {
$this->column = (int) $column;
$this->order = 0;
return;
}
usort($widgets, create_function('$a,$b', 'return (int)$a->order > (int)$b->order;'));
// remove widgets from inactive plugins
$widget_types = elgg_get_widget_types($this->context);
$inactive_widgets = array();
foreach ($widgets as $index => $widget) {
if (!array_key_exists($widget->handler, $widget_types)) {
$inactive_widgets[] = $widget;
unset($widgets[$index]);
}
}
if ($rank == 0) {
// top of the column
$this->order = reset($widgets)->order - 10;
} elseif ($rank == count($widgets) - 1) {
// bottom of the column of active widgets
$this->order = end($widgets)->order + 10;
} else {
// reorder widgets
// remove the widget that's being moved from the array
foreach ($widgets as $index => $widget) {
if ($widget->guid == $this->guid) {
unset($widgets[$index]);
}
}
// split the array in two and recombine with the moved widget in middle
$before = array_slice($widgets, 0, $rank);
array_push($before, $this);
$after = array_slice($widgets, $rank);
$widgets = array_merge($before, $after);
ksort($widgets);
$order = 0;
foreach ($widgets as $widget) {
$widget->order = $order;
$order += 10;
}
}
// put inactive widgets at the bottom
if ($inactive_widgets) {
$bottom = 0;
foreach ($widgets as $widget) {
if ($widget->order > $bottom) {
$bottom = $widget->order;
}
}
$bottom += 10;
foreach ($inactive_widgets as $widget) {
$widget->order = $bottom;
$bottom += 10;
}
}
$this->column = $column;
}
示例10: getEntitiesFromUserSettings
/**
* Returns entities based upon plugin user settings.
* Takes all the options for {@link elgg_get_entities_from_private_settings()}
* in addition to the ones below.
*
* @param array $options Array in the format:
*
* plugin_id => STR The plugin id. Required.
*
* plugin_user_setting_names => null|ARR private setting names
*
* plugin_user_setting_values => null|ARR metadata values
*
* plugin_user_setting_name_value_pairs => null|ARR (
* name => 'name',
* value => 'value',
* 'operand' => '=',
* )
* Currently if multiple values are sent via
* an array (value => array('value1', 'value2')
* the pair's operand will be forced to "IN".
*
* plugin_user_setting_name_value_pairs_operator => null|STR The operator to use for combining
* (name = value) OPERATOR (name = value); default AND
*
* @return mixed int If count, int. If not count, array. false on errors.
*/
function getEntitiesFromUserSettings(array $options = array())
{
if (!isset($options['plugin_id'])) {
elgg_deprecated_notice("'plugin_id' is now required for elgg_get_entities_from_plugin_user_settings()", 1.9);
$options['plugin_id'] = elgg_get_calling_plugin_id();
}
$singulars = array('plugin_user_setting_name', 'plugin_user_setting_value', 'plugin_user_setting_name_value_pair');
$options = _elgg_normalize_plural_options_array($options, $singulars);
// rewrite plugin_user_setting_name_* to the right PS ones.
$map = array('plugin_user_setting_names' => 'private_setting_names', 'plugin_user_setting_values' => 'private_setting_values', 'plugin_user_setting_name_value_pairs' => 'private_setting_name_value_pairs', 'plugin_user_setting_name_value_pairs_operator' => 'private_setting_name_value_pairs_operator');
foreach ($map as $plugin => $private) {
if (!isset($options[$plugin])) {
continue;
}
if (isset($options[$private])) {
if (!is_array($options[$private])) {
$options[$private] = array($options[$private]);
}
$options[$private] = array_merge($options[$private], $options[$plugin]);
} else {
$options[$private] = $options[$plugin];
}
}
$prefix = _elgg_namespace_plugin_private_setting('user_setting', '', $options['plugin_id']);
$options['private_setting_name_prefix'] = $prefix;
return elgg_get_entities_from_private_settings($options);
}
示例11: elgg_echo
$list = "<table class='elgg-table'>";
$list .= "<tr>";
$list .= "<th>" . elgg_echo("widget") . "</th>";
foreach ($stats_context as $context) {
$list .= "<th class='center'>" . elgg_echo($context) . "</th>";
}
$list .= "<th class='center'>" . elgg_echo("total") . "</th>";
$list .= "</tr>";
$widgets = $CONFIG->widgets->handlers;
widget_manager_sort_widgets($widgets);
foreach ($widgets as $handler => $widget) {
$widget_counts = array();
$widget_options = array("type" => "object", "subtype" => "widget", "count" => true, "private_setting_name_value_pairs" => array("handler" => $handler));
foreach ($stats_context as $context) {
$widget_options["private_setting_name_value_pairs"]["context"] = $context;
$widget_total = elgg_get_entities_from_private_settings($widget_options);
$widget_counts[$context] = $widget_total;
// keep track of context totals
$context_totals[$context] += $widget_total;
}
$widget_counts["total"] = array_sum($widget_counts);
$list .= "<tr>";
$list .= "<td><span title='[" . $handler . "] " . $widget->description . "'>" . $widget->name . "</span></td>";
foreach ($stats_context as $context) {
$list .= "<td class='center'>";
if ($widget_counts[$context] === 0) {
$list .= " ";
} else {
$list .= $widget_counts["total"];
}
$list .= "</td>";
示例12: elgg_get_site_entity
<?php
if (subsite_manager_on_subsite()) {
$site = elgg_get_site_entity();
if ($admins = $site->getAdminGuids()) {
$options = array("type" => "user", "limit" => false, "site_guids" => false, "joins" => array("JOIN " . get_config("dbprefix") . "users_entity ue ON ue.guid = e.guid"), "wheres" => array("(e.guid IN (" . implode(",", $admins) . "))"), "order_by" => "ue.name", "full_view" => false, "pagination" => false, "view_type_toggle" => false);
$body = elgg_list_entities($options);
}
} else {
$options = array("type" => "user", "limit" => false, "private_setting_name_value_pairs" => array("name" => "superadmin", "value" => true), "joins" => array("JOIN " . get_config("dbprefix") . "users_entity ue ON ue.guid = e.guid"), "wheres" => array("ue.admin = 'yes'"), "order_by" => "ue.name", "full_view" => false, "pagination" => false, "view_type_toggle" => false);
if ($users = elgg_get_entities_from_private_settings($options)) {
$body = elgg_view_entity_list($users, $options);
}
}
if (empty($body)) {
$body = elgg_echo("notfound");
}
echo elgg_view_module("inline", "", $body);
示例13: array
<?php
/**
* Shows the main admins and all Subsite admins per Subsite
*/
// get main admins
$main_options = array("type" => "user", "limit" => false, "site_guids" => false, "private_setting_name_value_pairs" => array("name" => "superadmin", "value" => true), "joins" => array("JOIN " . get_config("dbprefix") . "users_entity ue ON ue.guid = e.guid"), "wheres" => array("ue.admin = 'yes'"), "order_by" => "ue.name", "full_view" => false, "pagination" => false, "view_type_toggle" => false);
if ($main_admins = elgg_get_entities_from_private_settings($main_options)) {
$main_list = elgg_view_entity_list($main_admins, $main_options);
} else {
$main_list = elgg_echo("notfound");
}
// list main admins
echo elgg_view_module("inline", elgg_echo("subsite_manager:subsites:admins:main_admins"), $main_list);
// get all subsites
$limit = (int) max(get_input('limit', 50), 0);
$offset = (int) max(get_input('offset', 0), 0);
$subsite_options = array("type" => "site", "subtype" => Subsite::SUBTYPE, "limit" => $limit, "offset" => $offset, "joins" => array("JOIN " . get_config("dbprefix") . "sites_entity se ON se.guid = e.guid"), "order_by" => "se.name ASC");
$export_button = "";
if ($subsites = elgg_get_entities($subsite_options)) {
// create export button
$export_button = elgg_view("output/url", array("text" => elgg_echo("export"), "href" => "action/subsites/export_admins", "is_action" => true, "class" => "elgg-button elgg-button-action float-alt"));
// add pagination
$subsite_options["count"] = true;
$count = elgg_get_entities($subsite_options);
$pagination = elgg_view("navigation/pagination", array("limit" => $limit, "offset" => $offset, "count" => $count));
$subsite_list = $pagination;
foreach ($subsites as $subsite) {
// some stats
$temp_list = "<div class='elgg-subtext'>";
$temp_list .= elgg_echo("members") . ": " . $subsite->getMembers(array("count" => true)) . "<br />";
示例14: group_tools_get_domain_based_groups
/**
* Get all groups based on the email domain of the user from the group settings
*
* @param ElggUser $user The user used to base the search
* @param int $site_guid (optional) the site guid to limit the search to, defaults to current site
*
* @return bool|ElggGroup[] false or an array of found groups
*/
function group_tools_get_domain_based_groups(ElggUser $user, $site_guid = 0)
{
$result = false;
if (group_tools_domain_based_groups_enabled()) {
if (empty($site_guid)) {
$site_guid = elgg_get_site_entity()->getGUID();
}
if (!empty($user) && elgg_instanceof($user, "user")) {
list(, $domain) = explode("@", strtolower($user->email));
$options = array("type" => "group", "limit" => false, "site_guids" => $site_guid, "private_setting_name_value_pairs" => array("name" => "domain_based", "value" => "%|" . $domain . "|%", "operand" => "LIKE"));
$groups = elgg_get_entities_from_private_settings($options);
if (!empty($groups)) {
$result = $groups;
}
}
}
return $result;
}
示例15: _elgg_create_default_widgets
/**
* Creates default widgets
*
* This plugin hook handler is registered for events based on what kinds of
* default widgets have been registered. See elgg_default_widgets_init() for
* information on registering new default widget contexts.
*
* @param string $event The event
* @param string $type The type of object
* @param \ElggEntity $entity The entity being created
* @return void
* @access private
*/
function _elgg_create_default_widgets($event, $type, $entity)
{
$default_widget_info = elgg_get_config('default_widget_info');
if (!$default_widget_info || !$entity) {
return;
}
$type = $entity->getType();
$subtype = $entity->getSubtype();
// event is already guaranteed by the hook registration.
// need to check subtype and type.
foreach ($default_widget_info as $info) {
if ($info['entity_type'] == $type) {
if ($info['entity_subtype'] == ELGG_ENTITIES_ANY_VALUE || $info['entity_subtype'] == $subtype) {
// need to be able to access everything
$old_ia = elgg_set_ignore_access(true);
elgg_push_context('create_default_widgets');
// pull in by widget context with widget owners as the site
// not using elgg_get_widgets() because it sorts by columns and we don't care right now.
$options = array('type' => 'object', 'subtype' => 'widget', 'owner_guid' => elgg_get_site_entity()->guid, 'private_setting_name' => 'context', 'private_setting_value' => $info['widget_context'], 'limit' => 0);
$widgets = elgg_get_entities_from_private_settings($options);
/* @var \ElggWidget[] $widgets */
foreach ($widgets as $widget) {
// change the container and owner
$new_widget = clone $widget;
$new_widget->container_guid = $entity->guid;
$new_widget->owner_guid = $entity->guid;
// pull in settings
$settings = get_all_private_settings($widget->guid);
foreach ($settings as $name => $value) {
$new_widget->{$name} = $value;
}
$new_widget->save();
}
elgg_set_ignore_access($old_ia);
elgg_pop_context();
}
}
}
}