49 'private_setting_name_value_pairs_operator' =>
'AND',
50 'private_setting_name_prefix' =>
'',
55 $singulars = array(
'private_setting_name',
'private_setting_value',
56 'private_setting_name_value_pair');
61 $options[
'private_setting_values'],
$options[
'private_setting_name_value_pairs'],
62 $options[
'private_setting_name_value_pairs_operator'],
$options[
'private_setting_name_prefix']);
68 } elseif (!isset(
$options[
'wheres'])) {
77 } elseif (!isset(
$options[
'joins'])) {
101 $pairs = null, $pair_operator =
'AND', $name_prefix =
'') {
112 $return[
'joins'][] =
"JOIN {$CONFIG->dbprefix}private_settings ps on 113 {$table}.guid = ps.entity_guid";
119 if ($names !== null) {
120 if (!is_array($names)) {
121 $names = array($names);
124 $sanitised_names = array();
125 foreach ($names as
$name) {
126 $name = $name_prefix .
$name;
130 $names_str = implode(
',', $sanitised_names);
132 $names_where =
"(ps.name IN ($names_str))";
138 if ($values !== null) {
139 if (!is_array($values)) {
140 $values = array($values);
143 $sanitised_values = array();
144 foreach ($values as
$value) {
152 $values_str = implode(
',', $sanitised_values);
154 $values_where =
"(ps.value IN ($values_str))";
158 if ($names_where && $values_where) {
159 $wheres[] =
"($names_where AND $values_where)";
160 } elseif ($names_where) {
161 $wheres[] =
"($names_where)";
162 } elseif ($values_where) {
163 $wheres[] =
"($values_where)";
167 if (is_array($pairs)) {
172 if (isset($pairs[
'name']) || isset($pairs[
'value'])) {
173 $pairs = array($pairs);
176 $pair_wheres = array();
178 foreach ($pairs as $index => $pair) {
181 if (!is_array($pair)) {
189 if (!isset($pair[
'name']) || !isset($pair[
'value'])) {
194 if (isset($pair[
'operand'])) {
201 $trimmed_operand = trim(strtolower($operand));
205 if (is_numeric($pair[
'value'])) {
207 }
else if (is_array($pair[
'value'])) {
208 $values_array = array();
210 foreach ($pair[
'value'] as $pair_value) {
211 if (is_numeric($pair_value)) {
219 $value =
'(' . implode(
', ', $values_array) .
')';
225 }
else if ($trimmed_operand ==
'in') {
226 $value =
"({$pair['value']})";
234 $return[
'joins'][] =
"JOIN {$CONFIG->dbprefix}private_settings ps{$i} 235 on {$table}.guid = ps{$i}.entity_guid";
237 $pair_wheres[] =
"(ps{$i}.name = '$name' AND ps{$i}.value 243 $where = implode(
" $pair_operator ", $pair_wheres);
245 $wheres[] =
"($where)";
249 $where = implode(
' AND ', $wheres);
251 $return[
'wheres'][] =
"($where)";
285 $query =
"SELECT value from {$CONFIG->dbprefix}private_settings 286 where name = '{$name}' and entity_guid = {$entity_guid}";
290 return $setting->value;
315 $query =
"SELECT * from {$CONFIG->dbprefix}private_settings where entity_guid = {$entity_guid}";
350 (entity_guid, name, value) VALUES 351 ($entity_guid, '$name', '$value') 352 ON DUPLICATE KEY UPDATE value='$value'");
381 return delete_data(
"DELETE from {$CONFIG->dbprefix}private_settings 382 WHERE name = '{$name}' 383 AND entity_guid = {$entity_guid}");
407 return delete_data(
"DELETE from {$CONFIG->dbprefix}private_settings 408 WHERE entity_guid = {$entity_guid}");
get_data_row($query, $callback="")
Retrieve a single row from the database.
remove_all_private_settings($entity_guid)
Deletes all private settings for an entity.
if($guid==elgg_get_logged_in_user_guid()) $name
elgg_get_entity_private_settings_where_sql($table, $names=null, $values=null, $pairs=null, $pair_operator= 'AND', $name_prefix= '')
Returns private setting name and value SQL where/join clauses for entities.
elgg_get_entities_from_private_settings(array $options=array())
Returns entities based upon private settings.
delete_data($query)
Remove a row from the database.
insert_data($query)
Insert a row into the database.
remove_private_setting($entity_guid, $name)
Deletes a private setting for an entity.
sanitise_string($string)
Wrapper function for alternate English spelling (.
const ELGG_ENTITIES_ANY_VALUE
elgg_get_entities(array $options=array())
Returns an array of entities with optional filtering.
elgg global
Pointer to the global context.
get_data($query, $callback="")
Retrieve rows from the database.
set_private_setting($entity_guid, $name, $value)
Sets a private setting for an entity.
get_private_setting($entity_guid, $name)
Gets a private setting for an entity.
_elgg_normalize_plural_options_array($options, $singulars)
Normalise the singular keys in an options array to plural keys.
get_all_private_settings($entity_guid)
Return an array of all private settings.
get_entity($guid)
Loads and returns an entity object from a guid.