Elgg  Version 4.3
deprecated-4.3.php
Go to the documentation of this file.
1 <?php
25 function get_access_array(int $user_guid = 0): array {
26  elgg_deprecated_notice(__METHOD__ . ' has been deprecated. Use elgg_get_access_array()', '4.3');
27 
28  return _elgg_services()->accessCollections->getAccessArray($user_guid);
29 }
30 
44 function get_default_access(ElggUser $user = null, array $input_params = []): int {
45  elgg_deprecated_notice(__METHOD__ . ' has been deprecated. Use elgg_get_default_access()', '4.3');
46 
48 }
49 
66  elgg_deprecated_notice(__METHOD__ . ' has been deprecated. Use \ElggEnity->hasAccess() or elgg_has_access_to_entity()', '4.3');
67 
68  return _elgg_services()->accessCollections->hasAccessToEntity($entity, $user ? $user->guid : 0);
69 }
70 
98 function get_write_access_array(int $user_guid = 0, $ignored = 0, bool $flush = false, array $input_params = []): array {
99  elgg_deprecated_notice(__METHOD__ . ' has been deprecated. Use elgg_get_write_access_array()', '4.3');
100 
101  return _elgg_services()->accessCollections->getWriteAccessArray($user_guid, $flush, $input_params);
102 }
103 
120 function can_edit_access_collection(int $collection_id, int $user_guid = null): bool {
121  elgg_deprecated_notice(__METHOD__ . ' has been deprecated. Use \ElggAccessCollection->canEdit()', '4.3');
122 
123  return _elgg_services()->accessCollections->canEdit($collection_id, $user_guid);
124 }
125 
144 function create_access_collection(string $name, int $owner_guid = 0, $subtype = null) {
145  elgg_deprecated_notice(__METHOD__ . ' has been deprecated. Use elgg_create_access_collection()', '4.3');
146 
147  return _elgg_services()->accessCollections->create($name, $owner_guid, (string) $subtype) ?? false;
148 }
149 
159 function delete_access_collection(int $collection_id): bool {
160  elgg_deprecated_notice(__METHOD__ . ' has been deprecated. Use \ElggAccessCollection->delete()', '4.3');
161 
162  return _elgg_services()->accessCollections->delete($collection_id);
163 }
164 
178 function get_access_collection(int $collection_id) {
179  elgg_deprecated_notice(__METHOD__ . ' has been deprecated. Use elgg_get_access_collection()', '4.3');
180 
181  return _elgg_services()->accessCollections->get($collection_id) ?? false;
182 }
183 
195 function add_user_to_access_collection(int $user_guid, int $collection_id): bool {
196  elgg_deprecated_notice(__METHOD__ . ' has been deprecated. Use \ElggAccessCollection->addMember()', '4.3');
197 
198  return _elgg_services()->accessCollections->addUser($user_guid, $collection_id);
199 }
200 
212 function remove_user_from_access_collection(int $user_guid, int $collection_id): bool {
213  elgg_deprecated_notice(__METHOD__ . ' has been deprecated. Use \ElggAccessCollection->removeMember()', '4.3');
214 
215  return _elgg_services()->accessCollections->removeUser($user_guid, $collection_id);
216 }
217 
228 function get_members_of_access_collection(int $collection_id, bool $guids_only = false, array $options = []) {
229  elgg_deprecated_notice(__METHOD__ . ' has been deprecated. Use \ElggAccessCollection->getMembers()', '4.3');
230 
231  if (!isset($options['limit'])) {
232  $options['limit'] = false;
233  }
234 
235  if (!$guids_only) {
236  return _elgg_services()->accessCollections->getMembers($collection_id, $options);
237  }
238 
239  $options['callback'] = function($row) {
240  return (int) $row->guid;
241  };
242 
243  return _elgg_services()->accessCollections->getMembers($collection_id, $options);
244 }
245 
264 function get_readable_access_level(int $entity_access_id): string {
265  elgg_deprecated_notice(__METHOD__ . ' has been deprecated. Use elgg_get_readable_access_level()', '4.3');
266 
267  return _elgg_services()->accessCollections->getReadableAccessLevel($entity_access_id);
268 }
269 
278 function get_entity_statistics(int $owner_guid = 0): array {
279  elgg_deprecated_notice(__METHOD__ . ' has been deprecated. Use elgg_get_entity_statistics()', '4.3');
280 
282 }
283 
293  elgg_deprecated_notice(__METHOD__ . ' has been deprecated. Use elgg_get_relationship()', '4.3');
294 
295  return _elgg_services()->relationshipsTable->get((int) $id) ?? false;
296 }
297 
307  elgg_deprecated_notice(__METHOD__ . ' has been deprecated. Use \ElggRelationship->delete()', '4.3');
308 
309  return _elgg_services()->relationshipsTable->delete((int) $id);
310 }
311 
326 function add_entity_relationship($guid_one, $relationship, $guid_two) {
327  elgg_deprecated_notice(__METHOD__ . ' has been deprecated. Use \ElggEntity->addRelationship()', '4.3');
328 
329  return _elgg_services()->relationshipsTable->add((int) $guid_one, (string) $relationship, (int) $guid_two);
330 }
331 
344 function check_entity_relationship($guid_one, $relationship, $guid_two) {
345  elgg_deprecated_notice(__METHOD__ . ' has been deprecated. Use \ElggEntity->hasRelationship() or \ElggEntity->hasRelationship()', '4.3');
346 
347  return _elgg_services()->relationshipsTable->check((int) $guid_one, (string) $relationship, (int) $guid_two);
348 }
349 
362 function remove_entity_relationship($guid_one, $relationship, $guid_two) {
363  elgg_deprecated_notice(__METHOD__ . ' has been deprecated. Use \ElggEntity->removeRelationship()', '4.3');
364 
365  return _elgg_services()->relationshipsTable->remove((int) $guid_one, (string) $relationship, (int) $guid_two);
366 }
367 
380 function remove_entity_relationships($guid, $relationship = "", $inverse_relationship = false, $type = '') {
381  elgg_deprecated_notice(__METHOD__ . ' has been deprecated. Use \ElggEntity->removeAllRelationships()', '4.3');
382 
383  return _elgg_services()->relationshipsTable->removeAll($guid, $relationship, $inverse_relationship, $type);
384 }
385 
396 function get_entity_relationships($guid, $inverse_relationship = false) {
397  elgg_deprecated_notice(__METHOD__ . ' has been deprecated. Use elgg_get_relationships()', '4.3');
398 
399  return _elgg_services()->relationshipsTable->getAll($guid, $inverse_relationship);
400 }
401 
419 function register_pam_handler($handler, $importance = 'sufficient', $policy = 'user') {
420  elgg_deprecated_notice(__METHOD__ . ' has been deprecated. Use elgg_register_pam_handler()', '4.3');
421 
422  return elgg_register_pam_handler($handler, $importance, $policy);
423 }
424 
435 function unregister_pam_handler($handler, $policy = 'user') {
436  elgg_deprecated_notice(__METHOD__ . ' has been deprecated. Use elgg_unregister_pam_handler()', '4.3');
437 
439 }
440 
457  elgg_deprecated_notice(__METHOD__ . ' has been deprecated. Use elgg_pam_authenticate()', '4.3');
458 
459  $pam = new \ElggPAM('user');
460  $credentials = ['username' => $username, 'password' => $password];
461  $result = $pam->authenticate($credentials);
462  if (!$result) {
463  return $pam->getFailureMessage();
464  }
465 
466  return true;
467 }
468 
479  elgg_deprecated_notice(__METHOD__ . ' has been deprecated. Use elgg_generate_invite_code()', '4.3');
480 
481  return elgg_generate_invite_code((string) $username);
482 }
483 
494 function elgg_get_loaded_external_files(string $type, string $location): array {
495  elgg_deprecated_notice(__METHOD__ . ' has been deprecated. Use elgg_get_loaded_external_resources()', '4.3');
496 
497  return _elgg_services()->externalFiles->getLoadedFiles($type, $location);
498 }
499 
510 function get_dir_size($dir, $total_size = 0, $show_deprecation_notice = true) {
511  if ($show_deprecation_notice) {
512  elgg_deprecated_notice(__METHOD__ . ' has been deprecated', '4.3');
513  }
514  if (!is_dir($dir)) {
515  return $total_size;
516  }
517 
518  $handle = opendir($dir);
519  while (($file = readdir($handle)) !== false) {
520  if (in_array($file, ['.', '..'])) {
521  continue;
522  }
523  if (is_dir($dir . $file)) {
524  $total_size = get_dir_size($dir . $file . "/", $total_size, false);
525  } else {
526  $total_size += filesize($dir . $file);
527  }
528  }
529  closedir($handle);
530 
531  return($total_size);
532 }
533 
544 function filter_tags($var) {
545  elgg_deprecated_notice(__METHOD__ . ' has been deprecated. Use elgg_sanitize_input().', '4.3');
546 
547  return elgg_sanitize_input($var);
548 }
549 
559 function parse_urls($text) {
560  elgg_deprecated_notice(__METHOD__ . ' has been deprecated. Use elgg_parse_urls().', '4.3');
561 
562  return _elgg_services()->html_formatter->parseUrls($text);
563 }
564 
575 function current_page_url() {
576  elgg_deprecated_notice(__METHOD__ . ' has been deprecated. Use elgg_get_current_url().', '4.3');
577 
578  return _elgg_services()->request->getCurrentURL();
579 }
580 
590 function is_email_address($address) {
591  elgg_deprecated_notice(__METHOD__ . ' has been deprecated. Use elgg_is_valid_email().', '4.3');
592 
593  return _elgg_services()->accounts->isValidEmail($address);
594 }
595 
606 function string_to_tag_array($string) {
607  elgg_deprecated_notice(__METHOD__ . ' has been deprecated. Use elgg_string_to_array().', '4.3');
608 
609  if (!is_string($string)) {
610  return $string;
611  }
612 
613  return elgg_string_to_array($string);
614 }
615 
631 function add_translation($country_code, $language_array) {
632  elgg_deprecated_notice(__METHOD__ . ' has been deprecated. Use elgg()->translator->addTranslation().', '4.3');
633 
634  return _elgg_services()->translator->addTranslation($country_code, $language_array);
635 }
636 
645  elgg_deprecated_notice(__METHOD__ . ' has been deprecated. Use elgg_get_current_language().', '4.3');
646 
647  return _elgg_services()->translator->getCurrentLanguage();
648 }
649 
657 function logout() {
658  elgg_deprecated_notice(__METHOD__ . ' has been deprecated. Use elgg_logout().', '4.3');
659 
660  return _elgg_services()->session->logout();
661 }
662 
677 function login(\ElggUser $user, $persistent = false) {
678  elgg_deprecated_notice(__METHOD__ . ' has been deprecated. Use elgg_login().', '4.3');
679 
680  _elgg_services()->session->login($user, (bool) $persistent);
681  return true;
682 }
683 
694  elgg_deprecated_notice(__METHOD__ . ' has been deprecated. Use elgg_register_authentication_failure().', '4.3');
695 
697  $user_guid = (int) $user_guid;
699 
700  if ($user instanceof \ElggUser) {
701  _elgg_services()->accounts->registerAuthenticationFailure($user);
702  return true;
703  }
704 
705  return false;
706  });
707 }
708 
719  elgg_deprecated_notice(__METHOD__ . ' has been deprecated. Use elgg_reset_authentication_failures().', '4.3');
720 
722  $user_guid = (int) $user_guid;
724 
725  if ($user instanceof \ElggUser) {
726  _elgg_services()->accounts->resetAuthenticationFailures($user);
727  return true;
728  }
729 
730  return false;
731  });
732 }
733 
744  elgg_deprecated_notice(__METHOD__ . ' has been deprecated. Use elgg_is_authentication_failure_limit_reached().', '4.3');
745 
747  $user_guid = (int) $user_guid;
749 
750  if ($user instanceof \ElggUser) {
751  // 5 failures in 5 minutes causes temporary block on logins
752  return _elgg_services()->accounts->isAuthenticationFailureLimitReached($user, 5, 300);
753  }
754 
755  return false;
756  });
757 }
758 
772 function find_active_users(array $options = []) {
773  elgg_deprecated_notice(__METHOD__ . ' has been deprecated', '4.3');
774 
775  return _elgg_services()->usersTable->findActive($options);
776 }
777 
790 function get_online_users(array $options = []) {
791  $options = array_merge([
792  'seconds' => 600,
793  ], $options);
794 
795  return elgg_list_entities($options, 'find_active_users');
796 }
797 
806  elgg_deprecated_notice(__METHOD__ . ' has been deprecated. Use elgg_generate_password().', '4.3');
807 
808  return _elgg_services()->passwordGenerator->generatePassword();
809 }
810 
822  elgg_deprecated_notice(__METHOD__ . ' has been deprecated. Use \ElggUser->setPassword().', '4.3');
823 
824  return _elgg_services()->passwords->forcePasswordReset($user_guid, $password);
825 }
826 
837  elgg_deprecated_notice(__METHOD__ . ' has been deprecated. Use elgg_request_new_password().', '4.3');
838 
839  return _elgg_services()->passwords->sendNewPasswordRequest($user_guid);
840 }
841 
853 function execute_new_password_request($user_guid, $conf_code, $password = null) {
854  elgg_deprecated_notice(__METHOD__ . ' has been deprecated. Use elgg_save_new_password().', '4.3');
855 
857  if (!$user instanceof \ElggUser) {
858  return false;
859  }
860 
861  if (isset($password) && !is_string($password)) {
862  $password = (string) $password;
863  }
864 
865  return _elgg_services()->passwords->saveNewPassword($user, (string) $conf_code, $password);
866 }
867 
885 function register_user($username, $password, $name, $email, $allow_multiple_emails = false, $subtype = null, array $params = []) {
886  elgg_deprecated_notice(__METHOD__ . ' has been deprecated. Use elgg_register_user().', '4.3');
887 
888  $params['username'] = $username;
889  $params['password'] = $password;
890  $params['name'] = $name;
891  $params['email'] = $email;
892  $params['allow_multiple_emails'] = $allow_multiple_emails;
893  $params['subtype'] = $subtype;
894 
895  return _elgg_services()->accounts->register($params)->guid;
896 }
897 
905  elgg_deprecated_notice(__METHOD__ . ' has been deprecated.', '4.3');
906 
908 }
909 
919  elgg_deprecated_notice(__METHOD__ . ' has been deprecated. Use \ElggMetadata->delete().', '4.3');
920 
922  if (!$metadata) {
923  return false;
924  }
925  return $metadata->delete();
926 }
927 
938 function elgg_clear_sticky_value($form_name, $variable): void {
939  elgg_deprecated_notice(__METHOD__ . ' has been deprecated.', '4.3');
940 
941  _elgg_services()->stickyForms->clearStickyValue((string) $form_name, (string) $variable);
942 }
943 
954 function elgg_register_external_view($view, $cacheable = false) {
955  elgg_deprecated_notice(__METHOD__ . ' has been deprecated. Use elgg_register_ajax_view() and elgg_register_simplecache_view().', '4.3');
956 
957  _elgg_services()->ajax->registerView($view);
958 
959  if ($cacheable) {
960  _elgg_services()->views->registerCacheableView($view);
961  }
962 }
963 
974  elgg_deprecated_notice(__METHOD__ . ' has been deprecated. Use elgg_unregister_ajax_view().', '4.3');
975 
976  _elgg_services()->ajax->unregisterView($view);
977 }
add_entity_relationship($guid_one, $relationship, $guid_two)
Create a relationship between two entities.
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:592
remove_entity_relationships($guid, $relationship="", $inverse_relationship=false, $type= '')
Removes all relationships originating from a particular entity.
current_page_url()
Returns the current page&#39;s complete URL.
elgg_get_default_access(\ElggUser $user=null, array $input_params=[])
Gets the default access permission.
Definition: access.php:56
$user_guid
Definition: login_as.php:10
get_entity_statistics(int $owner_guid=0)
Return an array reporting the number of various entities in the system.
elgg_get_entity_statistics(int $owner_guid=0)
Return an array reporting the number of various entities in the system.
Definition: entities.php:697
$params
Saves global plugin settings.
Definition: save.php:13
get_user($guid)
Get a user object from a GUID.
Definition: users.php:20
get_write_access_array(int $user_guid=0, $ignored=0, bool $flush=false, array $input_params=[])
Returns an array of access permissions that the user is allowed to save content with.
can_edit_access_collection(int $collection_id, int $user_guid=null)
Can the user change this access collection?
elgg_deprecated_notice(string $msg, string $dep_version)
Log a notice about deprecated use of a function, view, etc.
Definition: deprecation.php:52
if(!$user||!$user->canDelete()) $name
Definition: delete.php:22
parse_urls($text)
Takes a string and turns any URLs into formatted links.
get_entity_relationships($guid, $inverse_relationship=false)
Get all the relationships for a given GUID.
add_translation($country_code, $language_array)
Add a translation.
c Accompany it with the information you received as to the offer to distribute corresponding source complete source code means all the source code for all modules it plus any associated interface definition plus the scripts used to control compilation and installation of the executable as a special the source code distributed need not include anything that is normally and so on of the operating system on which the executable unless that component itself accompanies the executable If distribution of executable or object code is made by offering access to copy from a designated then offering equivalent access to copy the source code from the same place counts as distribution of the source even though third parties are not compelled to copy the source along with the object code You may not or distribute the Program except as expressly provided under this License Any attempt otherwise to sublicense or distribute the Program is void
Definition: LICENSE.txt:215
$relationship
Elgg default relationship view.
Definition: default.php:10
$email
Definition: change_email.php:7
$username
Definition: delete.php:23
$input_params
Definition: livesearch.php:14
generate_random_cleartext_password()
Generate a random 12 character clear text password.
$type
Definition: delete.php:21
elgg_sanitize_input($input)
Filter input from a given string based on registered hooks.
Definition: input.php:78
filter_tags($var)
Filter tags from a given string based on registered hooks.
elgg_string_to_array(string $string)
Takes in a comma-separated string and returns an array of uniquely trimmed and stripped strings...
Definition: input.php:262
elgg_get_engine_path()
/path/to/elgg/engine with no trailing slash.
check_entity_relationship($guid_one, $relationship, $guid_two)
Check if a relationship exists between two entities.
elgg_get_metadata_from_id($id)
Elgg metadata Functions to manage entity metadata.
Definition: metadata.php:16
elgg_list_entities(array $options=[], $getter= 'elgg_get_entities', $viewer= 'elgg_view_entity_list')
Returns a string of rendered entities.
Definition: entities.php:589
$options
Elgg admin footer.
Definition: footer.php:6
get_default_access(ElggUser $user=null, array $input_params=[])
Gets the default access permission.
log_login_failure($user_guid)
Log a failed login for $user_guid.
elgg_unregister_external_view($view)
Unregister a view for ajax calls.
string_to_tag_array($string)
Takes in a comma-separated string and returns an array of tags which have been trimmed.
reset_login_failure_count($user_guid)
Resets the fail login count for $user_guid.
elgg_register_external_view($view, $cacheable=false)
Registers a view as being available externally (i.e.
get_members_of_access_collection(int $collection_id, bool $guids_only=false, array $options=[])
Get all of members of an access collection.
const ELGG_IGNORE_ACCESS
elgg_call() flags
Definition: constants.php:146
create_access_collection(string $name, int $owner_guid=0, $subtype=null)
Creates a new access collection.
$owner_guid
register_user($username, $password, $name, $email, $allow_multiple_emails=false, $subtype=null, array $params=[])
Registers a user, returning false if the username already exists.
if(!$user||!$user->canEdit()) $password
send_new_password_request($user_guid)
Generate and send a password request email to a given user&#39;s registered email address.
execute_new_password_request($user_guid, $conf_code, $password=null)
Validate and change password for a user.
elgg_delete_metadata_by_id($id)
Deletes metadata using its ID.
$entity
Definition: reset.php:8
const ELGG_SHOW_DISABLED_ENTITIES
Definition: constants.php:148
if(!empty($avatar)&&!$avatar->isValid()) elseif(empty($avatar)) if(!$owner->saveIconFromUploadedFile('avatar')) if(!elgg_trigger_event('profileiconupdate', $owner->type, $owner)) $view
Definition: upload.php:39
elgg_clear_sticky_value($form_name, $variable)
Remove one value of form submission data from the session.
get_readable_access_level(int $entity_access_id)
Return the name of an ACCESS_* constant or an access collection, but only if the logged in user has w...
is_email_address($address)
Validates an email address.
add_user_to_access_collection(int $user_guid, int $collection_id)
Adds a user to an access collection.
$user
Definition: ban.php:7
generate_invite_code($username)
Generates a unique invite code for a user.
get_access_array(int $user_guid=0)
Bundle all functions which have been deprecated in Elgg 4.3.
get_access_collection(int $collection_id)
Get a specified access collection.
remove_user_from_access_collection(int $user_guid, int $collection_id)
Removes a user from an access collection.
remove_entity_relationship($guid_one, $relationship, $guid_two)
Delete a relationship between two entities.
find_active_users(array $options=[])
Return users (or the number of them) who have been active within a recent period. ...
elgg_generate_invite_code(string $username)
Generates a unique invite code for a user.
Definition: users.php:141
check_rate_limit_exceeded($user_guid)
Checks if the rate limit of failed logins has been exceeded for $user_guid.
$location
Definition: member.php:29
elgg_authenticate($username, $password)
Perform user authentication with a given username and password.
$metadata
Output annotation metadata.
Definition: metadata.php:9
get_relationship($id)
Get a relationship by its ID.
$subtype
Definition: delete.php:22
delete_access_collection(int $collection_id)
Deletes a specified access collection and its membership.
_elgg_services()
Get the global service provider.
Definition: elgglib.php:638
$persistent
Definition: login_as.php:21
force_user_password_reset($user_guid, $password)
Low level function to reset a given user&#39;s password.
delete_relationship($id)
Delete a relationship by its ID.
elgg_get_loaded_external_files(string $type, string $location)
Get external resource descriptors.
elgg_unregister_pam_handler($handler, string $policy= 'user')
Unregisters a PAM handler.
Definition: pam.php:44
$handler
Definition: add.php:7
has_access_to_entity(\ElggEntity $entity,\ElggUser $user=null)
Can a user access an entity.
$text
Definition: button.php:32
get_current_language()
Get the current system/user language or "en".
get_online_users(array $options=[])
Render a list of currently online users.
$id
Generic annotation delete action.
Definition: delete.php:6
unregister_pam_handler($handler, $policy= 'user')
Unregisters a PAM handler.
logout()
Log the current user out.
register_pam_handler($handler, $importance= 'sufficient', $policy= 'user')
Register a PAM handler.
elgg_register_pam_handler($handler, string $importance= 'sufficient', string $policy= 'user')
Elgg Simple PAM library Contains functions for managing authentication.
Definition: pam.php:31
var elgg
Definition: elgglib.js:4
$guid
Reset an ElggUpgrade.
Definition: reset.php:6
get_entity($guid)
Loads and returns an entity object from a guid.
Definition: entities.php:69
get_dir_size($dir, $total_size=0, $show_deprecation_notice=true)
Get the size of the specified directory.
login(\ElggUser $user, $persistent=false)
Logs in a specified .