Elgg  Version 2.3
deprecated-2.1.php
Go to the documentation of this file.
1 <?php
2 
12  elgg_deprecated_notice(__FUNCTION__ . " is deprecated.", 2.1);
13  return _elgg_services()->relationshipsTable->rowToElggRelationship($row);
14 }
15 
43 function system_messages($message = null, $register = "success", $count = false) {
44  elgg_deprecated_notice(__FUNCTION__ . ' is deprecated', '2.1');
45 
46  $svc = _elgg_services()->systemMessages;
47  if ($count) {
48  return $svc->count($register);
49  }
50  if ($message === null) {
51  return $svc->dumpRegister($register);
52  }
53  if (!$register) {
54  return false;
55  }
56  $set = $svc->loadRegisters();
57  if (!isset($set->{$register})) {
58  $set->{$register} = [];
59  }
60  foreach ((array)$message as $str) {
61  $set->{$register}[] = $str;
62  }
63  $svc->saveRegisters($set);
64  return true;
65 }
66 
75 function _elgg_delete_river(array $options = []) {
76  $options['__bypass_notice'] = true;
78 }
79 
106 function elgg_delete_river(array $options = array()) {
107  global $CONFIG;
108 
109  // allow core to use this in 2.x w/o warnings
110  if (empty($options['__bypass_notice'])) {
111  $msg = __FUNCTION__ . ' is deprecated. Use elgg_get_river() and call delete() on the returned item(s)';
112  if (isset($options['view']) || isset($options['views'])) {
113  $msg .= '. You must use the "wheres" option to specify value(s) for the "rv.view" column.';
114  }
115  elgg_deprecated_notice($msg, '2.3');
116  }
117 
118  $defaults = array(
119  'ids' => ELGG_ENTITIES_ANY_VALUE,
120 
121  'subject_guids' => ELGG_ENTITIES_ANY_VALUE,
122  'object_guids' => ELGG_ENTITIES_ANY_VALUE,
123  'target_guids' => ELGG_ENTITIES_ANY_VALUE,
124  'annotation_ids' => ELGG_ENTITIES_ANY_VALUE,
125 
126  'views' => ELGG_ENTITIES_ANY_VALUE,
127  'action_types' => ELGG_ENTITIES_ANY_VALUE,
128 
129  'types' => ELGG_ENTITIES_ANY_VALUE,
130  'subtypes' => ELGG_ENTITIES_ANY_VALUE,
131  'type_subtype_pairs' => ELGG_ENTITIES_ANY_VALUE,
132 
133  'posted_time_lower' => ELGG_ENTITIES_ANY_VALUE,
134  'posted_time_upper' => ELGG_ENTITIES_ANY_VALUE,
135 
136  'wheres' => array(),
137  'joins' => array(),
138 
139  );
140 
141  $options = array_merge($defaults, $options);
142 
143  $singulars = array('id', 'subject_guid', 'object_guid', 'target_guid', 'annotation_id', 'action_type', 'view', 'type', 'subtype');
145 
146  $wheres = $options['wheres'];
147 
148  $wheres[] = _elgg_get_guid_based_where_sql('rv.id', $options['ids']);
149  $wheres[] = _elgg_get_guid_based_where_sql('rv.subject_guid', $options['subject_guids']);
150  $wheres[] = _elgg_get_guid_based_where_sql('rv.object_guid', $options['object_guids']);
151  $wheres[] = _elgg_get_guid_based_where_sql('rv.target_guid', $options['target_guids']);
152  $wheres[] = _elgg_get_guid_based_where_sql('rv.annotation_id', $options['annotation_ids']);
153  $wheres[] = _elgg_river_get_action_where_sql($options['action_types']);
154  $wheres[] = _elgg_river_get_view_where_sql($options['views']);
155  $wheres[] = _elgg_get_river_type_subtype_where_sql('rv', $options['types'],
156  $options['subtypes'], $options['type_subtype_pairs']);
157 
158  if ($options['posted_time_lower'] && is_int($options['posted_time_lower'])) {
159  $wheres[] = "rv.posted >= {$options['posted_time_lower']}";
160  }
161 
162  if ($options['posted_time_upper'] && is_int($options['posted_time_upper'])) {
163  $wheres[] = "rv.posted <= {$options['posted_time_upper']}";
164  }
165 
166  // see if any functions failed
167  // remove empty strings on successful functions
168  foreach ($wheres as $i => $where) {
169  if ($where === false) {
170  return false;
171  } elseif (empty($where)) {
172  unset($wheres[$i]);
173  }
174  }
175 
176  // remove identical where clauses
177  $wheres = array_unique($wheres);
178 
179  $query = "DELETE rv.* FROM {$CONFIG->dbprefix}river rv ";
180 
181  // remove identical join clauses
182  $joins = array_unique($options['joins']);
183 
184  // add joins
185  foreach ($joins as $j) {
186  $query .= " $j ";
187  }
188 
189  // add wheres
190  $query .= ' WHERE ';
191 
192  foreach ($wheres as $w) {
193  $query .= " $w AND ";
194  }
195  $query .= "1=1";
196 
197  return delete_data($query);
198 }
_elgg_river_get_action_where_sql($types)
Get the where clause based on river action type strings.
Definition: river.php:595
row_to_elggrelationship($row)
Convert a database row to a new .
_elgg_river_get_view_where_sql($views)
Get the where clause based on river view strings.
Definition: river.php:624
delete_data($query, array $params=[])
Remove a row from the database.
Definition: database.php:116
$defaults
_elgg_delete_river(array $options=[])
Alias of elgg_delete_river() that doesn&#39;t raise notices.
_elgg_get_guid_based_where_sql($column, $guids)
Returns SQL where clause for owner and containers.
Definition: entities.php:341
$options
Elgg admin footer.
Definition: footer.php:6
global $CONFIG
const ELGG_ENTITIES_ANY_VALUE
Definition: elgglib.php:2095
elgg_deprecated_notice($msg, $dep_version, $backtrace_level=1)
Log a notice about deprecated use of a function, view, etc.
Definition: elgglib.php:1098
elgg global
Pointer to the global context.
Definition: elgglib.js:12
system_messages($message=null, $register="success", $count=false)
Queues a message to be displayed.
_elgg_services(\Elgg\Di\ServiceProvider $services=null)
Get the global service provider.
Definition: autoloader.php:17
if(elgg_in_context('widget')) $count
Definition: pagination.php:21
$row
_elgg_normalize_plural_options_array($options, $singulars)
Normalise the singular keys in an options array to plural keys.
Definition: elgglib.php:1528
elgg_delete_river(array $options=array())
Delete river items.
_elgg_get_river_type_subtype_where_sql($table, $types, $subtypes, $pairs)
Returns SQL where clause for type and subtype on river table.
Definition: river.php:517