Elgg  Version 3.0
ElggEntity.php
Go to the documentation of this file.
1 <?php
2 
5 
44 abstract class ElggEntity extends \ElggData implements
45  Locatable, // Geocoding interface
46  EntityIcon // Icon interface
47 {
48 
49  public static $primary_attr_names = [
50  'guid',
51  'type',
52  'subtype',
53  'owner_guid',
54  'container_guid',
55  'access_id',
56  'time_created',
57  'time_updated',
58  'last_action',
59  'enabled',
60  ];
61 
62  protected static $integer_attr_names = [
63  'guid',
64  'owner_guid',
65  'container_guid',
66  'access_id',
67  'time_created',
68  'time_updated',
69  'last_action',
70  ];
71 
77  protected $temp_metadata = [];
78 
84  protected $temp_annotations = [];
85 
91  protected $temp_private_settings = [];
92 
98  protected $volatile = [];
99 
104  protected $orig_attributes = [];
105 
109  protected $_is_cacheable = true;
110 
121  protected $_cached_metadata;
122 
137  public function __construct(stdClass $row = null) {
138  $this->initializeAttributes();
139 
140  if ($row && !$this->load($row)) {
141  $msg = "Failed to load new " . get_class() . " for GUID:" . $row->guid;
142  throw new \IOException($msg);
143  }
144  }
145 
153  protected function initializeAttributes() {
154  parent::initializeAttributes();
155 
156  $this->attributes['guid'] = null;
157  $this->attributes['type'] = $this->getType();
158  $this->attributes['subtype'] = null;
159 
160  $this->attributes['owner_guid'] = _elgg_services()->session->getLoggedInUserGuid();
161  $this->attributes['container_guid'] = _elgg_services()->session->getLoggedInUserGuid();
162 
163  $this->attributes['access_id'] = ACCESS_PRIVATE;
164  $this->attributes['time_updated'] = null;
165  $this->attributes['last_action'] = null;
166  $this->attributes['enabled'] = "yes";
167  }
168 
179  public function __clone() {
180  $orig_entity = get_entity($this->guid);
181  if (!$orig_entity) {
182  _elgg_services()->logger->error("Failed to clone entity with GUID $this->guid");
183  return;
184  }
185 
186  $metadata_array = elgg_get_metadata([
187  'guid' => $this->guid,
188  'limit' => 0
189  ]);
190 
191  $this->attributes['guid'] = null;
192  $this->attributes['time_created'] = null;
193  $this->attributes['time_updated'] = null;
194  $this->attributes['last_action'] = null;
195 
196  $this->attributes['subtype'] = $orig_entity->getSubtype();
197 
198  // copy metadata over to new entity - slightly convoluted due to
199  // handling of metadata arrays
200  if (is_array($metadata_array)) {
201  // create list of metadata names
202  $metadata_names = [];
203  foreach ($metadata_array as $metadata) {
204  $metadata_names[] = $metadata->name;
205  }
206  // arrays are stored with multiple enties per name
207  $metadata_names = array_unique($metadata_names);
208 
209  // move the metadata over
210  foreach ($metadata_names as $name) {
211  $this->__set($name, $orig_entity->$name);
212  }
213  }
214  }
215 
229  public function __set($name, $value) {
230  if ($this->$name === $value) {
231  // quick return if value is not changing
232  return;
233  }
234 
235  if (array_key_exists($name, $this->attributes)) {
236  // if an attribute is 1 (integer) and it's set to "1" (string), don't consider that a change.
237  if (is_int($this->attributes[$name])
238  && is_string($value)
239  && ((string) $this->attributes[$name] === $value)) {
240  return;
241  }
242 
243  // keep original values
244  if ($this->guid && !array_key_exists($name, $this->orig_attributes)) {
245  $this->orig_attributes[$name] = $this->attributes[$name];
246  }
247 
248  // Certain properties should not be manually changed!
249  switch ($name) {
250  case 'guid':
251  case 'time_updated':
252  case 'last_action':
253  return;
254  case 'access_id':
255  case 'owner_guid':
256  case 'container_guid':
257  if ($value !== null) {
258  $this->attributes[$name] = (int) $value;
259  } else {
260  $this->attributes[$name] = null;
261  }
262  break;
263  default:
264  $this->attributes[$name] = $value;
265  break;
266  }
267  return;
268  }
269 
270  $this->setMetadata($name, $value);
271  }
272 
278  public function getOriginalAttributes() {
279  return $this->orig_attributes;
280  }
281 
294  public function __get($name) {
295  if (array_key_exists($name, $this->attributes)) {
296  return $this->attributes[$name];
297  }
298 
299  return $this->getMetadata($name);
300  }
301 
307  public function getDisplayName() {
308  return $this->name;
309  }
310 
317  public function setDisplayName($display_name) {
318  $this->name = $display_name;
319  }
320 
328  public function getMetadata($name) {
329  $metadata = $this->getAllMetadata();
330  return elgg_extract($name, $metadata);
331  }
332 
338  public function getAllMetadata() {
339  if (!$this->guid) {
340  return array_map(function($values) {
341  return count($values) > 1 ? $values : $values[0];
343  }
344 
345  $this->_cached_metadata = _elgg_services()->metadataCache->getAll($this->guid);
346 
348  }
349 
366  public function setMetadata($name, $value, $value_type = '', $multiple = false) {
367 
368  if ($value === null) {
369  return $this->deleteMetadata($name);
370  }
371 
372  // normalize value to an array that we will loop over
373  // remove indexes if value already an array.
374  if (is_array($value)) {
375  $value = array_values($value);
376  } else {
377  $value = [$value];
378  }
379 
380  // strip null values from array
381  $value = array_filter($value, function($var) {
382  return !is_null($var);
383  });
384 
385  if (empty($this->guid)) {
386  // unsaved entity. store in temp array
387  return $this->setTempMetadata($name, $value, $multiple);
388  }
389 
390  // saved entity. persist md to db.
391  if (!$multiple) {
392  $current_metadata = $this->getMetadata($name);
393 
394  if ((is_array($current_metadata) || count($value) > 1 || $value === []) && isset($current_metadata)) {
395  // remove current metadata if needed
396  // need to remove access restrictions right now to delete
397  // because this is the expected behavior
398  $delete_result = elgg_call(ELGG_IGNORE_ACCESS, function() use ($name) {
399  return elgg_delete_metadata([
400  'guid' => $this->guid,
401  'metadata_name' => $name,
402  'limit' => false,
403  ]);
404  });
405 
406  if (false === $delete_result) {
407  return false;
408  }
409  }
410 
411  if (count($value) > 1) {
412  // new value is a multiple valued metadata
413  $multiple = true;
414  }
415  }
416 
417  // create new metadata
418  foreach ($value as $value_tmp) {
419  $metadata = new ElggMetadata();
420  $metadata->entity_guid = $this->guid;
421  $metadata->name = $name;
422  $metadata->value_type = $value_type;
423  $metadata->value = $value_tmp;
424  $md_id = _elgg_services()->metadataTable->create($metadata, $multiple);
425  if ($md_id === false) {
426  return false;
427  }
428  }
429 
430  return true;
431  }
432 
443  protected function setTempMetadata($name, $value, $multiple = false) {
444  // if overwrite, delete first
445  if (!$multiple) {
446  unset($this->temp_metadata[$name]);
447  if (count($value)) {
448  // only save if value array contains data
449  $this->temp_metadata[$name] = $value;
450  }
451  return true;
452  }
453 
454  if (!isset($this->temp_metadata[$name])) {
455  $this->temp_metadata[$name] = [];
456  }
457 
458  $this->temp_metadata[$name] = array_merge($this->temp_metadata[$name], $value);
459 
460  return true;
461  }
462 
463 
464 
475  public function deleteMetadata($name = null) {
476 
477  if (!$this->guid) {
478  // remove from temp_metadata
479  if ($name) {
480  if (!isset($this->temp_metadata[$name])) {
481  return null;
482  } else {
483  unset($this->temp_metadata[$name]);
484  return true;
485  }
486  } else {
487  $this->temp_metadata = [];
488  return true;
489  }
490  }
491 
492  $options = [
493  'guid' => $this->guid,
494  'limit' => 0
495  ];
496  if ($name) {
497  $options['metadata_name'] = $name;
498  }
499 
501  }
502 
510  public function getVolatileData($name) {
511  return array_key_exists($name, $this->volatile) ? $this->volatile[$name] : null;
512  }
513 
522  public function setVolatileData($name, $value) {
523  $this->volatile[$name] = $value;
524  }
525 
539  public function deleteRelationships($relationship = null) {
540  $relationship = (string) $relationship;
541  $result = remove_entity_relationships($this->getGUID(), $relationship);
542  return $result && remove_entity_relationships($this->getGUID(), $relationship, true);
543  }
544 
557  public function addRelationship($guid_two, $relationship) {
558  return add_entity_relationship($this->getGUID(), $relationship, $guid_two);
559  }
560 
571  public function removeRelationship($guid_two, $relationship) {
572  return remove_entity_relationship($this->getGUID(), $relationship, $guid_two);
573  }
574 
589  public function setPrivateSetting($name, $value) {
590 
591  if ($value === null) {
592  return $this->removePrivateSetting($name);
593  }
594 
595  if (is_bool($value)) {
596  $value = (int) $value;
597  }
598 
599  // checking if string value matches saved value (as get privatesettings does not know value type) and db column is a string
600  if (strval($value) === $this->getPrivateSetting($name)) {
601  // no need to update value
602  return true;
603  }
604 
605  if (!$this->guid) {
606  $this->temp_private_settings[$name] = $value;
607 
608  return true;
609  }
610 
611  return _elgg_services()->privateSettings->set($this, $name, $value);
612  }
613 
625  public function getPrivateSetting($name) {
626  if (!$this->guid) {
627  return elgg_extract($name, $this->temp_private_settings);
628  }
629 
630  return _elgg_services()->privateSettings->get($this, $name);
631  }
632 
639  public function getAllPrivateSettings() {
640  if (!$this->guid) {
642  }
643 
644  return _elgg_services()->privateSettings->getAllForEntity($this);
645  }
646 
655  public function removePrivateSetting($name) {
656  if (!$this->guid) {
657  unset($this->temp_private_settings[$name]);
658  return true;
659  }
660 
661  return _elgg_services()->privateSettings->remove($this, $name);
662  }
663 
670  public function removeAllPrivateSettings() {
671  if (!$this->guid) {
672  $this->temp_private_settings = [];
673  return true;
674  }
675 
676  return _elgg_services()->privateSettings->removeAllForEntity($this);
677  }
678 
684  public function removeAllRelatedRiverItems() {
685  elgg_delete_river(['subject_guid' => $this->guid, 'limit' => false]);
686  elgg_delete_river(['object_guid' => $this->guid, 'limit' => false]);
687  elgg_delete_river(['target_guid' => $this->guid, 'limit' => false]);
688  }
689 
700  public function deleteAnnotations($name = null) {
701  if ($this->guid) {
702  $options = [
703  'guid' => $this->guid,
704  'limit' => 0
705  ];
706  if ($name) {
707  $options['annotation_name'] = $name;
708  }
709 
711  }
712 
713  if ($name) {
714  unset($this->temp_annotations[$name]);
715  } else {
716  $this->temp_annotations = [];
717  }
718 
719  return true;
720  }
721 
730  public function deleteOwnedAnnotations($name = null) {
731  // access is turned off for this because they might
732  // no longer have access to an entity they created annotations on
733 
734  $flags = ELGG_IGNORE_ACCESS;
735  $callback = function() use ($name) {
736  return elgg_delete_annotations([
737  'annotation_owner_guid' => $this->guid,
738  'limit' => 0,
739  'annotation_name' => $name,
740  ]);
741  };
742 
743  return elgg_call($flags, $callback);
744  }
745 
753  public function disableAnnotations($name = '') {
754  $options = [
755  'guid' => $this->guid,
756  'limit' => 0
757  ];
758  if ($name) {
759  $options['annotation_name'] = $name;
760  }
761 
763  }
764 
774  public function enableAnnotations($name = '') {
775  $options = [
776  'guid' => $this->guid,
777  'limit' => 0
778  ];
779  if ($name) {
780  $options['annotation_name'] = $name;
781  }
782 
784  }
785 
793  private function getAnnotationCalculation($name, $calculation) {
794  $options = [
795  'guid' => $this->getGUID(),
796  'distinct' => false,
797  'annotation_name' => $name,
798  'annotation_calculation' => $calculation
799  ];
800 
802  }
803 
823  public function annotate($name, $value, $access_id = ACCESS_PRIVATE, $owner_guid = 0, $value_type = "") {
824  if ($this->guid) {
825  if (!$owner_guid) {
826  $owner_guid = _elgg_services()->session->getLoggedInUserGuid();
827  }
828  $annotation = new ElggAnnotation();
829  $annotation->entity_guid = $this->guid;
830  $annotation->name = $name;
831  $annotation->value_type = $value_type;
832  $annotation->value = $value;
833  $annotation->owner_guid = $owner_guid;
834  $annotation->access_id = $access_id;
835  return $annotation->save();
836  } else {
837  $this->temp_annotations[$name] = $value;
838  }
839  return true;
840  }
841 
853  public function getAnnotations(array $options = []) {
854  if ($this->guid) {
855  $options['guid'] = $this->guid;
856 
858  } else {
859  $name = elgg_extract('annotation_name', $options, '');
860 
861  if (isset($this->temp_annotations[$name])) {
862  return [$this->temp_annotations[$name]];
863  }
864  }
865 
866  return [];
867  }
868 
876  public function countAnnotations($name = "") {
877  return $this->getAnnotationCalculation($name, 'count');
878  }
879 
887  public function getAnnotationsAvg($name) {
888  return $this->getAnnotationCalculation($name, 'avg');
889  }
890 
898  public function getAnnotationsSum($name) {
899  return $this->getAnnotationCalculation($name, 'sum');
900  }
901 
909  public function getAnnotationsMin($name) {
910  return $this->getAnnotationCalculation($name, 'min');
911  }
912 
920  public function getAnnotationsMax($name) {
921  return $this->getAnnotationCalculation($name, 'max');
922  }
923 
930  public function countComments() {
931  $params = ['entity' => $this];
932  $num = _elgg_services()->hooks->trigger('comments:count', $this->getType(), $params);
933 
934  if (is_int($num)) {
935  return $num;
936  }
937 
938  return elgg_get_entities([
939  'type' => 'object',
940  'subtype' => 'comment',
941  'container_guid' => $this->getGUID(),
942  'count' => true,
943  'distinct' => false,
944  ]);
945  }
946 
957  public function getOwnedAccessCollections($options = []) {
958  $options['owner_guid'] = $this->guid;
959  return _elgg_services()->accessCollections->getEntityCollections($options);
960  }
961 
972  if (!is_string($subtype) || $subtype === '') {
973  return false;
974  }
975 
976  $acls = $this->getOwnedAccessCollections([
977  'subtype' => $subtype,
978  ]);
979 
980  return elgg_extract(0, $acls, false);
981  }
982 
993  public function getEntitiesFromRelationship(array $options = []) {
994  $options['relationship_guid'] = $this->guid;
995  return elgg_get_entities($options);
996  }
997 
1006  public function countEntitiesFromRelationship($relationship, $inverse_relationship = false) {
1007  return elgg_get_entities([
1008  'relationship' => $relationship,
1009  'relationship_guid' => $this->getGUID(),
1010  'inverse_relationship' => $inverse_relationship,
1011  'count' => true
1012  ]);
1013  }
1014 
1025  public function canEdit($user_guid = 0) {
1026  return _elgg_services()->userCapabilities->canEdit($this, $user_guid);
1027  }
1028 
1040  public function canDelete($user_guid = 0) {
1041  return _elgg_services()->userCapabilities->canDelete($this, $user_guid);
1042  }
1043 
1057  public function canEditMetadata($metadata = null, $user_guid = 0) {
1058  return _elgg_services()->userCapabilities->canEditMetadata($this, $user_guid, $metadata);
1059  }
1060 
1071  public function canWriteToContainer($user_guid = 0, $type = 'all', $subtype = 'all') {
1072  return _elgg_services()->userCapabilities->canWriteToContainer($this, $user_guid, $type, $subtype);
1073  }
1074 
1086  public function canComment($user_guid = 0, $default = null) {
1087  return _elgg_services()->userCapabilities->canComment($this, $user_guid, $default);
1088  }
1089 
1104  public function canAnnotate($user_guid = 0, $annotation_name = '') {
1105  return _elgg_services()->userCapabilities->canAnnotate($this, $user_guid, $annotation_name);
1106  }
1107 
1113  public function getAccessID() {
1114  return $this->access_id;
1115  }
1116 
1122  public function getGUID() {
1123  return $this->guid;
1124  }
1125 
1131  public function getType() {
1132  // this is just for the PHPUnit mocking framework
1133  return $this->type;
1134  }
1135 
1141  public function getSubtype() {
1142  return $this->attributes['subtype'];
1143  }
1144 
1150  public function getOwnerGUID() {
1151  return (int) $this->owner_guid;
1152  }
1153 
1159  public function getOwnerEntity() {
1160  return get_entity($this->owner_guid);
1161  }
1162 
1171  return $this->container_guid = (int) $container_guid;
1172  }
1173 
1179  public function getContainerGUID() {
1180  return (int) $this->container_guid;
1181  }
1182 
1189  public function getContainerEntity() {
1190  return get_entity($this->getContainerGUID());
1191  }
1192 
1198  public function getTimeUpdated() {
1199  return $this->time_updated;
1200  }
1201 
1210  public function getURL() {
1211  $url = elgg_generate_entity_url($this, 'view');
1212 
1213  $url = _elgg_services()->hooks->trigger('entity:url', $this->getType(), ['entity' => $this], $url);
1214 
1215  if (empty($url)) {
1216  return '';
1217  }
1218 
1219  return elgg_normalize_url($url);
1220  }
1221 
1230  public function saveIconFromUploadedFile($input_name, $type = 'icon', array $coords = []) {
1231  return _elgg_services()->iconService->saveIconFromUploadedFile($this, $input_name, $type, $coords);
1232  }
1233 
1242  public function saveIconFromLocalFile($filename, $type = 'icon', array $coords = []) {
1243  return _elgg_services()->iconService->saveIconFromLocalFile($this, $filename, $type, $coords);
1244  }
1245 
1254  public function saveIconFromElggFile(\ElggFile $file, $type = 'icon', array $coords = []) {
1255  return _elgg_services()->iconService->saveIconFromElggFile($this, $file, $type, $coords);
1256  }
1257 
1266  public function getIcon($size, $type = 'icon') {
1267  return _elgg_services()->iconService->getIcon($this, $size, $type);
1268  }
1269 
1276  public function deleteIcon($type = 'icon') {
1277  return _elgg_services()->iconService->deleteIcon($this, $type);
1278  }
1279 
1288  public function getIconLastChange($size, $type = 'icon') {
1289  return _elgg_services()->iconService->getIconLastChange($this, $size, $type);
1290  }
1291 
1299  public function hasIcon($size, $type = 'icon') {
1300  return _elgg_services()->iconService->hasIcon($this, $size, $type);
1301  }
1302 
1314  public function getIconURL($params = []) {
1315  return _elgg_services()->iconService->getIconURL($this, $params);
1316  }
1317 
1323  public function save() {
1324  $guid = $this->guid;
1325  if ($guid > 0) {
1326  $guid = $this->update();
1327  } else {
1328  $guid = $this->create();
1329  if ($guid !== false && !_elgg_services()->events->trigger('create', $this->type, $this)) {
1330  // plugins that return false to event don't need to override the access system
1331  elgg_call(ELGG_IGNORE_ACCESS, function() {
1332  return $this->delete();
1333  });
1334  return false;
1335  }
1336  }
1337 
1338  if ($guid) {
1339  $this->cache();
1340  }
1341 
1342  return $guid;
1343  }
1344 
1355  protected function create() {
1356 
1357  $type = $this->attributes['type'];
1358  if (!in_array($type, \Elgg\Config::getEntityTypes())) {
1359  throw new \InvalidParameterException('Entity type must be one of the allowed types: '
1360  . implode(', ', \Elgg\Config::getEntityTypes()));
1361  }
1362 
1363  $subtype = $this->attributes['subtype'];
1364  if (!$subtype) {
1365  throw new \InvalidParameterException("All entities must have a subtype");
1366  }
1367 
1368  $owner_guid = (int) $this->attributes['owner_guid'];
1369  $access_id = (int) $this->attributes['access_id'];
1370  $now = $this->getCurrentTime()->getTimestamp();
1371  $time_created = isset($this->attributes['time_created']) ? (int) $this->attributes['time_created'] : $now;
1372 
1373  $container_guid = $this->attributes['container_guid'];
1374  if ($container_guid == 0) {
1376  $this->attributes['container_guid'] = $container_guid;
1377  }
1379 
1380  if ($access_id == ACCESS_DEFAULT) {
1381  throw new \InvalidParameterException('ACCESS_DEFAULT is not a valid access level. See its documentation in constants.php');
1382  }
1383 
1384  if ($access_id == ACCESS_FRIENDS) {
1385  throw new \InvalidParameterException('ACCESS_FRIENDS is not a valid access level. See its documentation in constants.php');
1386  }
1387 
1388  $user_guid = _elgg_services()->session->getLoggedInUserGuid();
1389 
1390  // If given an owner, verify it can be loaded
1391  if ($owner_guid) {
1392  $owner = $this->getOwnerEntity();
1393  if (!$owner) {
1394  _elgg_services()->logger->error("User $user_guid tried to create a ($type, $subtype), but the given"
1395  . " owner $owner_guid could not be loaded.");
1396  return false;
1397  }
1398 
1399  // If different owner than logged in, verify can write to container.
1400 
1401  if ($user_guid != $owner_guid && !$owner->canEdit() && !$owner->canWriteToContainer($user_guid, $type, $subtype)) {
1402  _elgg_services()->logger->error("User $user_guid tried to create a ($type, $subtype) with owner"
1403  . " $owner_guid, but the user wasn't permitted to write to the owner's container.");
1404  return false;
1405  }
1406  }
1407 
1408  // If given a container, verify it can be loaded and that the current user can write to it
1409  if ($container_guid) {
1410  $container = $this->getContainerEntity();
1411  if (!$container) {
1412  _elgg_services()->logger->error("User $user_guid tried to create a ($type, $subtype), but the given"
1413  . " container $container_guid could not be loaded.");
1414  return false;
1415  }
1416 
1417  if (!$container->canWriteToContainer($user_guid, $type, $subtype)) {
1418  _elgg_services()->logger->error("User $user_guid tried to create a ($type, $subtype), but was not"
1419  . " permitted to write to container $container_guid.");
1420  return false;
1421  }
1422  }
1423 
1424  // Create primary table row
1425  $guid = _elgg_services()->entityTable->insertRow((object) [
1426  'type' => $type,
1427  'subtype' => $subtype,
1428  'owner_guid' => $owner_guid,
1429  'container_guid' => $container_guid,
1430  'access_id' => $access_id,
1431  'time_created' => $time_created,
1432  'time_updated' => $now,
1433  'last_action' => $now,
1434  ], $this->attributes);
1435 
1436  if (!$guid) {
1437  throw new \IOException("Unable to save new object's base entity information!");
1438  }
1439 
1440  $this->attributes['subtype'] = $subtype;
1441  $this->attributes['guid'] = (int) $guid;
1442  $this->attributes['time_created'] = (int) $time_created;
1443  $this->attributes['time_updated'] = (int) $now;
1444  $this->attributes['last_action'] = (int) $now;
1445  $this->attributes['container_guid'] = (int) $container_guid;
1446 
1447  // We are writing this new entity to cache to make sure subsequent calls
1448  // to get_entity() load the entity from cache and not from the DB. This
1449  // MUST come before the metadata and annotation writes below!
1450  $this->cache();
1451 
1452  // Save any unsaved metadata
1453  if (sizeof($this->temp_metadata) > 0) {
1454  foreach ($this->temp_metadata as $name => $value) {
1455  if (count($value) == 1) {
1456  // temp metadata is always an array, but if there is only one value return just the value
1457  $this->$name = $value[0];
1458  } else {
1459  $this->$name = $value;
1460  }
1461  }
1462 
1463  $this->temp_metadata = [];
1464  }
1465 
1466  // Save any unsaved annotations.
1467  if (sizeof($this->temp_annotations) > 0) {
1468  foreach ($this->temp_annotations as $name => $value) {
1469  $this->annotate($name, $value);
1470  }
1471 
1472  $this->temp_annotations = [];
1473  }
1474 
1475  // Save any unsaved private settings.
1476  if (sizeof($this->temp_private_settings) > 0) {
1477  foreach ($this->temp_private_settings as $name => $value) {
1478  $this->setPrivateSetting($name, $value);
1479  }
1480 
1481  $this->temp_private_settings = [];
1482  }
1483 
1484  return $guid;
1485  }
1486 
1494  protected function update() {
1495 
1496  if (!$this->canEdit()) {
1497  return false;
1498  }
1499 
1500  // give old update event a chance to stop the update
1501  if (!_elgg_services()->events->trigger('update', $this->type, $this)) {
1502  return false;
1503  }
1504 
1505  $this->invalidateCache();
1506 
1507  // See #6225. We copy these after the update event in case a handler changed one of them.
1508  $guid = (int) $this->guid;
1509  $owner_guid = (int) $this->owner_guid;
1510  $access_id = (int) $this->access_id;
1511  $container_guid = (int) $this->container_guid;
1512  $time_created = (int) $this->time_created;
1513  $time = $this->getCurrentTime()->getTimestamp();
1514 
1515  if ($access_id == ACCESS_DEFAULT) {
1516  throw new \InvalidParameterException('ACCESS_DEFAULT is not a valid access level. See its documentation in constants.php');
1517  }
1518 
1519  if ($access_id == ACCESS_FRIENDS) {
1520  throw new \InvalidParameterException('ACCESS_FRIENDS is not a valid access level. See its documentation in constants.php');
1521  }
1522 
1523  // Update primary table
1524  $ret = _elgg_services()->entityTable->updateRow($guid, (object) [
1525  'owner_guid' => $owner_guid,
1526  'container_guid' => $container_guid,
1527  'access_id' => $access_id,
1528  'time_created' => $time_created,
1529  'time_updated' => $time,
1530  'guid' => $guid,
1531  ]);
1532  if ($ret === false) {
1533  return false;
1534  }
1535 
1536  $this->attributes['time_updated'] = $time;
1537 
1538  _elgg_services()->events->triggerAfter('update', $this->type, $this);
1539 
1540  $this->orig_attributes = [];
1541 
1542  $this->cache();
1543 
1544  // Handle cases where there was no error BUT no rows were updated!
1545  return true;
1546  }
1547 
1555  protected function load(stdClass $row) {
1556  $attributes = array_merge($this->attributes, (array) $row);
1557 
1558  if (array_diff(self::$primary_attr_names, array_keys($attributes)) !== []) {
1559  // Some primary attributes are missing
1560  return false;
1561  }
1562 
1563  foreach ($attributes as $name => $value) {
1564  if (!in_array($name, self::$primary_attr_names)) {
1565  $this->setVolatileData("select:$name", $value);
1566  unset($attributes[$name]);
1567  continue;
1568  }
1569 
1570  if (in_array($name, self::$integer_attr_names)) {
1571  $attributes[$name] = (int) $value;
1572  }
1573  }
1574 
1575  $this->attributes = $attributes;
1576 
1577  $this->cache();
1578 
1579  return true;
1580  }
1581 
1595  public function refresh(stdClass $row) {
1596  return $this->load($row);
1597  }
1598 
1618  public function disable($reason = "", $recursive = true) {
1619  if (!$this->guid) {
1620  return false;
1621  }
1622 
1623  if (!_elgg_services()->events->trigger('disable', $this->type, $this)) {
1624  return false;
1625  }
1626 
1627  if (!$this->canEdit()) {
1628  return false;
1629  }
1630 
1631  if ($this instanceof ElggUser && !$this->isBanned()) {
1632  // temporarily ban to prevent using the site during disable
1633  $this->ban();
1634  $unban_after = true;
1635  } else {
1636  $unban_after = false;
1637  }
1638 
1639  if ($reason) {
1640  $this->disable_reason = $reason;
1641  }
1642 
1643  $dbprefix = _elgg_config()->dbprefix;
1644 
1645  $guid = (int) $this->guid;
1646 
1647  if ($recursive) {
1649  $callback = function () use ($guid, $reason) {
1650  $base_options = [
1651  'wheres' => [
1652  function(QueryBuilder $qb, $main_alias) use ($guid) {
1653  return $qb->compare("{$main_alias}.guid", '!=', $guid, ELGG_VALUE_GUID);
1654  },
1655  ],
1656  'limit' => false,
1657  ];
1658 
1659  foreach (['owner_guid', 'container_guid'] as $db_column) {
1660  $options = $base_options;
1661  $options[$db_column] = $guid;
1662 
1663  $subentities = new \ElggBatch('elgg_get_entities', $options);
1664  $subentities->setIncrementOffset(false);
1665 
1666  foreach ($subentities as $subentity) {
1667  /* @var $subentity \ElggEntity */
1668  if (!$subentity->isEnabled()) {
1669  continue;
1670  }
1671  add_entity_relationship($subentity->guid, 'disabled_with', $guid);
1672  $subentity->disable($reason);
1673  }
1674  }
1675  };
1676 
1677  elgg_call($flags, $callback);
1678  }
1679 
1680  $this->disableAnnotations();
1681 
1682  $sql = "
1683  UPDATE {$dbprefix}entities
1684  SET enabled = 'no'
1685  WHERE guid = :guid
1686  ";
1687  $params = [
1688  ':guid' => $guid,
1689  ];
1690  $disabled = $this->getDatabase()->updateData($sql, false, $params);
1691 
1692  if ($unban_after) {
1693  $this->unban();
1694  }
1695 
1696  if ($disabled) {
1697  $this->invalidateCache();
1698 
1699  $this->attributes['enabled'] = 'no';
1700  _elgg_services()->events->triggerAfter('disable', $this->type, $this);
1701  }
1702 
1703  return (bool) $disabled;
1704  }
1705 
1716  public function enable($recursive = true) {
1717  $guid = (int) $this->guid;
1718  if (!$guid) {
1719  return false;
1720  }
1721 
1722  if (!_elgg_services()->events->trigger('enable', $this->type, $this)) {
1723  return false;
1724  }
1725 
1726  if (!$this->canEdit()) {
1727  return false;
1728  }
1729 
1730  $flags = ELGG_SHOW_DISABLED_ENTITIES;
1731  $callback = function() use ($guid, $recursive) {
1732  $db = $this->getDatabase();
1733  $result = $db->updateData("
1734  UPDATE {$db->prefix}entities
1735  SET enabled = 'yes'
1736  WHERE guid = $guid
1737  ");
1738 
1739  $this->deleteMetadata('disable_reason');
1740  $this->enableAnnotations();
1741 
1742  if ($recursive) {
1743  $disabled_with_it = elgg_get_entities([
1744  'relationship' => 'disabled_with',
1745  'relationship_guid' => $guid,
1746  'inverse_relationship' => true,
1747  'limit' => 0,
1748  ]);
1749 
1750  foreach ($disabled_with_it as $e) {
1751  $e->enable();
1752  remove_entity_relationship($e->guid, 'disabled_with', $guid);
1753  }
1754  }
1755 
1756  return $result;
1757  };
1758 
1759  $result = elgg_call($flags, $callback);
1760 
1761  if ($result) {
1762  $this->attributes['enabled'] = 'yes';
1763  _elgg_services()->events->triggerAfter('enable', $this->type, $this);
1764  }
1765 
1766  return $result;
1767  }
1768 
1774  public function isEnabled() {
1775  return $this->enabled == 'yes';
1776  }
1777 
1795  public function delete($recursive = true) {
1796  // first check if we can delete this entity
1797  // NOTE: in Elgg <= 1.10.3 this was after the delete event,
1798  // which could potentially remove some content if the user didn't have access
1799  if (!$this->canDelete()) {
1800  return false;
1801  }
1802 
1803  try {
1804  return _elgg_services()->entityTable->delete($this, $recursive);
1805  } catch (DatabaseException $ex) {
1806  elgg_log($ex, 'ERROR');
1807  return false;
1808  }
1809  }
1810 
1817  public function toObject(array $params = []) {
1818  $object = $this->prepareObject(new \Elgg\Export\Entity());
1819 
1820  $params['entity'] = $this;
1821 
1822  return _elgg_services()->hooks->trigger('to:object', 'entity', $params, $object);
1823  }
1824 
1831  protected function prepareObject(\Elgg\Export\Entity $object) {
1832  $object->guid = $this->guid;
1833  $object->type = $this->getType();
1834  $object->subtype = $this->getSubtype();
1835  $object->owner_guid = $this->getOwnerGUID();
1836  $object->container_guid = $this->getContainerGUID();
1837  $object->time_created = date('c', $this->getTimeCreated());
1838  $object->time_updated = date('c', $this->getTimeUpdated());
1839  $object->url = $this->getURL();
1840  $object->read_access = (int) $this->access_id;
1841  return $object;
1842  }
1843 
1844  /*
1845  * LOCATABLE INTERFACE
1846  */
1847 
1853  public function getLocation() {
1854  return $this->location;
1855  }
1856 
1864  public function setLocation($location) {
1865  $this->location = $location;
1866  }
1867 
1877  public function setLatLong($lat, $long) {
1878  $this->{"geo:lat"} = $lat;
1879  $this->{"geo:long"} = $long;
1880  }
1881 
1888  public function getLatitude() {
1889  return (float) $this->{"geo:lat"};
1890  }
1891 
1898  public function getLongitude() {
1899  return (float) $this->{"geo:long"};
1900  }
1901 
1902  /*
1903  * SYSTEM LOG INTERFACE
1904  */
1905 
1912  public function getSystemLogID() {
1913  return $this->getGUID();
1914  }
1915 
1923  public function getObjectFromID($id) {
1924  return get_entity($id);
1925  }
1926 
1936  public function getTags($tag_names = null) {
1937  if ($tag_names && !is_array($tag_names)) {
1938  $tag_names = [$tag_names];
1939  }
1940 
1942  $entity_tags = [];
1943 
1944  foreach ($valid_tags as $tag_name) {
1945  if (is_array($tag_names) && !in_array($tag_name, $tag_names)) {
1946  continue;
1947  }
1948 
1949  if ($tags = $this->$tag_name) {
1950  // if a single tag, metadata returns a string.
1951  // if multiple tags, metadata returns an array.
1952  if (is_array($tags)) {
1953  $entity_tags = array_merge($entity_tags, $tags);
1954  } else {
1955  $entity_tags[] = $tags;
1956  }
1957  }
1958  }
1959 
1960  return $entity_tags;
1961  }
1962 
1970 
1971  if (!$this->guid) {
1972  return false;
1973  }
1974 
1975  if ($this->type !== 'user') {
1976  return true;
1977  }
1978 
1979  $ac = _elgg_services()->accessCollections;
1980 
1981  $collections = $ac->getCollectionsByMember($this->guid);
1982  if (empty($collections)) {
1983  return true;
1984  }
1985 
1986  $result = true;
1987  foreach ($collections as $collection) {
1988  $result &= $ac->removeUser($this->guid, $collection->id);
1989  }
1990 
1991  return $result;
1992  }
1993 
2000  public function deleteOwnedAccessCollections() {
2001 
2002  if (!$this->guid) {
2003  return false;
2004  }
2005 
2006  $collections = $this->getOwnedAccessCollections();
2007  if (empty($collections)) {
2008  return true;
2009  }
2010 
2011  $result = true;
2012  foreach ($collections as $collection) {
2013  $result = $result & $collection->delete();
2014  }
2015 
2016  return $result;
2017  }
2018 
2029  public function updateLastAction($posted = null) {
2030  $posted = _elgg_services()->entityTable->updateLastAction($this, $posted);
2031  if ($posted) {
2032  $this->attributes['last_action'] = $posted;
2033  $this->cache();
2034  }
2035  return $posted;
2036  }
2037 
2044  public function disableCaching() {
2045  $this->_is_cacheable = false;
2046  if ($this->guid) {
2047  _elgg_services()->entityCache->delete($this->guid);
2048  }
2049  }
2050 
2057  public function enableCaching() {
2058  $this->_is_cacheable = true;
2059  }
2060 
2067  public function isCacheable() {
2068  if (!$this->guid) {
2069  return false;
2070  }
2071 
2072  if (_elgg_services()->session->getIgnoreAccess()) {
2073  return false;
2074  }
2075  return $this->_is_cacheable;
2076  }
2077 
2086  public function cache($persist = true) {
2087  if (!$this->isCacheable()) {
2088  return;
2089  }
2090 
2091  _elgg_services()->entityCache->save($this);
2092 
2093  if (!$persist) {
2094  return;
2095  }
2096 
2097  $tmp = $this->volatile;
2098 
2099  // don't store volatile data
2100  $this->volatile = [];
2101 
2102  _elgg_services()->dataCache->entities->save($this->guid, $this);
2103 
2104  $this->volatile = $tmp;
2105  }
2106 
2113  public function invalidateCache() {
2114  if (!$this->guid) {
2115  return;
2116  }
2117 
2118  _elgg_services()->entityCache->delete($this->guid);
2119 
2120  $namespaces = [
2121  'entities',
2122  'metadata',
2123  'private_settings',
2124  ];
2125 
2126  foreach ($namespaces as $namespace) {
2127  _elgg_services()->dataCache->get($namespace)->delete($this->guid);
2128  }
2129  }
2130 }
elgg_call(int $flags, Closure $closure)
Calls a callable autowiring the arguments using public DI services and applying logic based on flags...
Definition: elgglib.php:1176
saveIconFromUploadedFile($input_name, $type= 'icon', array $coords=[])
Saves icons using an uploaded file as the source.
deleteOwnedAccessCollections()
Remove all access collections owned by this entity.
enable($recursive=true)
Enable the entity.
removeAllPrivateSettings()
Removes all private settings.
Definition: ElggEntity.php:670
getSubtype()
Get the entity subtype.
$display_name
Definition: delete.php:19
canEditMetadata($metadata=null, $user_guid=0)
Can a user edit metadata on this entity?
getDatabase()
Provides a pointer to the database object.
Definition: ElggData.php:50
elgg_get_registered_tag_metadata_names()
Returns an array of valid metadata names for tags.
Definition: tags.php:90
if(!$item instanceof ElggRiverItem) $object
Definition: responses.php:23
if(!$user||!$user->canDelete()) $name
Definition: delete.php:22
getOwnerGUID()
Get the guid of the entity&#39;s owner.
getTimeCreated()
Returns the UNIX epoch time that this entity was created.
Definition: ElggData.php:106
if(!array_key_exists($filename, $text_files)) $file
Entities that support icons should implement this interface.
Definition: EntityIcon.php:7
__clone()
Clone an entity.
Definition: ElggEntity.php:179
deleteIcon($type= 'icon')
Removes all icon files and metadata for the passed type of icon.
$params
Saves global plugin settings.
Definition: save.php:13
getAllPrivateSettings()
Returns all private settings.
Definition: ElggEntity.php:639
$annotation
Elgg default annotation view.
Definition: default.php:10
__get($name)
Get an attribute or metadata value.
Definition: ElggEntity.php:294
getOwnerEntity()
Gets the that owns this entity.
add_entity_relationship($guid_one, $relationship, $guid_two)
Create a relationship between two entities.
const ACCESS_DEFAULT
Definition: constants.php:11
elgg_normalize_url($url)
Definition: output.php:186
setTempMetadata($name, $value, $multiple=false)
Set temp metadata on this entity.
Definition: ElggEntity.php:443
setLatLong($lat, $long)
Set latitude and longitude metadata tags for a given entity.
removePrivateSetting($name)
Removes private setting.
Definition: ElggEntity.php:655
disableAnnotations($name= '')
Disables annotations for this entity, optionally based on name.
Definition: ElggEntity.php:753
remove_entity_relationship($guid_one, $relationship, $guid_two)
Delete a relationship between two entities.
deleteMetadata($name=null)
Deletes all metadata on this object (metadata.entity_guid = $this->guid).
Definition: ElggEntity.php:475
elgg_delete_annotations(array $options)
Deletes annotations based on $options.
Definition: annotations.php:87
countAnnotations($name="")
Count annotations.
Definition: ElggEntity.php:876
deleteAnnotations($name=null)
Deletes all annotations on this object (annotations.entity_guid = $this->guid).
Definition: ElggEntity.php:700
invalidateCache()
Invalidate cache for entity.
$access_id
Definition: access.php:11
setPrivateSetting($name, $value)
Adds a private setting to this entity.
Definition: ElggEntity.php:589
initializeAttributes()
Initialize the attributes array.
Definition: ElggEntity.php:153
canWriteToContainer($user_guid=0, $type= 'all', $subtype= 'all')
Can a user add an entity to this container.
const ACCESS_FRIENDS
Definition: constants.php:15
refresh(stdClass $row)
Load new data from database into existing entity.
getPrivateSetting($name)
Returns a private setting value.
Definition: ElggEntity.php:625
elgg_get_annotations(array $options=[])
Fetch annotations or perform a calculation on them.
Definition: annotations.php:52
getAnnotationsMax($name)
Get the maximum of integer type annotations of a given name.
Definition: ElggEntity.php:920
countComments()
Count the number of comments attached to this entity.
Definition: ElggEntity.php:930
save()
Save an entity.
$size
Definition: remove.php:24
elgg_delete_river(array $options=[])
Delete river items based on $options.
Definition: river.php:220
deleteOwnedAnnotations($name=null)
Deletes all annotations owned by this object (annotations.owner_guid = $this->guid).
Definition: ElggEntity.php:730
const ELGG_VALUE_GUID
Definition: constants.php:140
$subtype
Definition: delete.php:22
prepareObject(\Elgg\Export\Entity $object)
Prepare an object copy for toObject()
Database abstraction query builder.
getGUID()
Returns the guid.
getCurrentTime($modifier= '')
Get the (cloned) time.
Definition: TimeUsing.php:27
$guid
Removes an admin notice.
getContainerGUID()
Gets the container GUID for this entity.
getTimeUpdated()
Returns the UNIX epoch time that this entity was last updated.
$type
Definition: delete.php:21
enableAnnotations($name= '')
Enables annotations for this entity, optionally based on name.
Definition: ElggEntity.php:774
enableCaching()
Enable runtime caching for entity.
cache($persist=true)
Cache the entity in a session and persisted caches.
canEdit($user_guid=0)
Can a user edit this entity?
getIcon($size, $type= 'icon')
Returns entity icon as an ElggIcon object The icon file may or may not exist on filestore.
remove_entity_relationships($guid, $relationship="", $inverse_relationship=false, $type= '')
Removes all relationships originating from a particular entity.
getAnnotationsSum($name)
Get the sum of integer type annotations of a given name.
Definition: ElggEntity.php:898
$options
Elgg admin footer.
Definition: footer.php:6
getEntitiesFromRelationship(array $options=[])
Gets an array of entities with a relationship to this entity.
Definition: ElggEntity.php:993
setVolatileData($name, $value)
Set a piece of volatile (non-persisted) data on this entity.
Definition: ElggEntity.php:522
$metadata
Outputs object metadata $vars[&#39;metadata&#39;] Metadata/menu $vars[&#39;show_entity_menu&#39;] Show the entity m...
Definition: metadata.php:10
setContainerGUID($container_guid)
Set the container for this object.
removeRelationship($guid_two, $relationship)
Remove a relationship.
Definition: ElggEntity.php:571
elgg_disable_annotations(array $options)
Disables annotations based on $options.
countEntitiesFromRelationship($relationship, $inverse_relationship=false)
Gets the number of entities from a specific relationship type.
$user_guid
Validate a user.
Definition: validate.php:6
getMetadata($name)
Return the value of a piece of metadata.
Definition: ElggEntity.php:328
const ELGG_IGNORE_ACCESS
elgg_call() flags
Definition: constants.php:156
$owner_guid
$namespaces
Definition: default.php:34
deleteRelationships($relationship=null)
Remove all relationships to and from this entity.
Definition: ElggEntity.php:539
saveIconFromElggFile(\ElggFile $file, $type= 'icon', array $coords=[])
Saves icons using a file located in the data store as the source.
getTags($tag_names=null)
Returns tags for this entity.
Configuration exception.
disableCaching()
Disable runtime caching for entity.
$id
River item delete action.
Definition: delete.php:6
static $primary_attr_names
Definition: ElggEntity.php:49
getVolatileData($name)
Get a piece of volatile (non-persisted) data on this entity.
Definition: ElggEntity.php:510
if(!$entity instanceof ElggEntity) $input_name
Definition: default.php:14
const ACCESS_PRIVATE
Definition: constants.php:12
const ELGG_SHOW_DISABLED_ENTITIES
Definition: constants.php:158
removeAllRelatedRiverItems()
Removes all river items related to this entity.
Definition: ElggEntity.php:684
$owner
Definition: crop.php:7
$container
Definition: delete.php:23
elgg_get_entities(array $options=[])
Fetches/counts entities or performs a calculation on their properties.
Definition: entities.php:545
static $integer_attr_names
Definition: ElggEntity.php:62
if(!$entity instanceof ElggEntity) $time
Definition: time.php:21
getAnnotationsAvg($name)
Get the average of an integer type annotation.
Definition: ElggEntity.php:887
load(stdClass $row)
Loads attributes from the entities table into the object.
elgg_log($message, $level=\Psr\Log\LogLevel::NOTICE)
Log a message.
Definition: elgglib.php:786
setLocation($location)
Sets the &#39;location&#39; metadata for the entity.
$time_created
Definition: online.php:19
compare($x, $comparison, $y=null, $type=null, $case_sensitive=null)
Build value comparison clause.
__set($name, $value)
Set an attribute or metadata value for this entity.
Definition: ElggEntity.php:229
$url
Definition: default.php:33
canAnnotate($user_guid=0, $annotation_name= '')
Can a user annotate an entity?
toObject(array $params=[])
Export an entity.
elgg_enable_annotations(array $options)
Enables annotations based on $options.
getAnnotations(array $options=[])
Gets an array of annotations.
Definition: ElggEntity.php:853
getOwnedAccessCollections($options=[])
Returns the ACLs owned by the entity.
Definition: ElggEntity.php:957
$attributes
The main attributes of an entity.
Definition: ElggData.php:27
deleteAccessCollectionMemberships()
Remove the membership of all access collections for this entity (if the entity is a user) ...
$default
Definition: checkbox.php:35
isEnabled()
Is this entity enabled?
elgg_extract($key, $array, $default=null, $strict=true)
Checks for $array[$key] and returns its value if it exists, else returns $default.
Definition: elgglib.php:1131
getIconURL($params=[])
Get the URL for this entity&#39;s icon.
addRelationship($guid_two, $relationship)
Add a relationship between this an another entity.
Definition: ElggEntity.php:557
setMetadata($name, $value, $value_type= '', $multiple=false)
Set metadata on this entity.
Definition: ElggEntity.php:366
update()
Update the entity in the database.
getAccessID()
Returns the access_id.
elgg_get_metadata(array $options=[])
Fetch metadata or perform a calculation on them.
Definition: metadata.php:49
$posted
Definition: comment.php:64
$comment access_id
Definition: save.php:47
$temp_private_settings
Definition: ElggEntity.php:91
elgg_delete_metadata(array $options)
Deletes metadata based on $options.
Definition: metadata.php:64
_elgg_config()
Get the Elgg config service.
$value
Definition: debugging.php:7
canDelete($user_guid=0)
Can a user delete this entity?
setDisplayName($display_name)
Sets the title or name of this entity.
Definition: ElggEntity.php:317
$site name
hasIcon($size, $type= 'icon')
Returns if the entity has an icon of the passed type.
getOwnedAccessCollection($subtype)
Returns the first ACL owned by the entity with a given subtype.
Definition: ElggEntity.php:971
getType()
Returns the entity type.
annotate($name, $value, $access_id=ACCESS_PRIVATE, $owner_guid=0, $value_type="")
Adds an annotation to an entity.
Definition: ElggEntity.php:823
$location
Definition: default.php:42
$filename
create()
Create a new entry in the entities table.
getAllMetadata()
Get all entity metadata.
Definition: ElggEntity.php:338
getIconLastChange($size, $type= 'icon')
Returns the timestamp of when the icon was changed.
_elgg_services()
Get the global service provider.
Definition: elgglib.php:1292
getOriginalAttributes()
Get the original values of attribute(s) that have been modified since the entity was persisted...
Definition: ElggEntity.php:278
updateLastAction($posted=null)
Update the last_action column in the entities table.
getLocation()
Gets the &#39;location&#39; metadata for the entity.
isCacheable()
Is entity cacheable in the runtime cache.
getLatitude()
Return the entity&#39;s latitude.
__construct(stdClass $row=null)
Create a new entity.
Definition: ElggEntity.php:137
$container_guid
getContainerEntity()
Get the container entity for this object.
$tags
Output object tags.
Definition: tags.php:9
canComment($user_guid=0, $default=null)
Can a user comment on an entity?
getSystemLogID()
Return an identification for the object for storage in the system log.
disable($reason="", $recursive=true)
Disable this entity.
if(!$owner||!$owner->canEdit()) if(!$owner->hasIcon('master')) $coords
Definition: crop.php:18
elgg_generate_entity_url(ElggEntity $entity, $resource= 'view', $subresource=null, array $parameters=[])
Generate entity URL from a named route.
Definition: pagehandler.php:84
getURL()
Gets the URL for this entity.
getDisplayName()
Get the entity&#39;s display name.
Definition: ElggEntity.php:307
getAnnotationsMin($name)
Get the minimum of integer type annotations of given name.
Definition: ElggEntity.php:909
$comment owner_guid
Definition: save.php:45
getLongitude()
Return the entity&#39;s longitude.
get_entity($guid)
Loads and returns an entity object from a guid.
Definition: entities.php:87
getObjectFromID($id)
For a given ID, return the object associated with it.
saveIconFromLocalFile($filename, $type= 'icon', array $coords=[])
Saves icons using a local file as the source.
$comment container_guid
Definition: save.php:46