From ff635b511407d2ab1d5122654d718e70bb6bbf1a Mon Sep 17 00:00:00 2001 From: Evan Winslow Date: Fri, 28 Nov 2014 22:24:09 +0000 Subject: [PATCH] chore(style): Remove trailing whitespace from 1.x branch --- .scripts/move_namespaces_to_top.php | 20 +- .scripts/validate_commit_msg.php | 8 +- .travis.yml | 14 +- CONTRIBUTING.md | 6 +- COPYRIGHT.txt | 2 +- README.md | 2 +- actions/admin/site/unlock_upgrade.php | 2 +- actions/admin/upgrades/upgrade_comments.php | 4 +- actions/admin/upgrades/upgrade_datadirs.php | 2 +- actions/profile/edit.php | 6 +- actions/profile/fields/delete.php | 2 +- actions/widgets/add.php | 2 +- actions/widgets/save.php | 2 +- actions/widgets/upgrade.php | 2 +- docs/admin/cron.rst | 2 +- docs/admin/performance.rst | 2 +- docs/admin/plugins.rst | 2 +- docs/admin/upgrading.rst | 2 +- docs/appendix/faqs.rst | 2 +- docs/design/database.rst | 2 +- docs/design/index.rst | 2 +- docs/examples/advanced/exceptions.php | 8 +- docs/guides/actions.rst | 2 +- docs/guides/events-list.rst | 2 +- docs/guides/menus.rst | 6 +- docs/guides/notifications.rst | 4 +- docs/guides/river.rst | 2 +- docs/guides/upgrading.rst | 2 +- docs/guides/views.rst | 6 +- docs/guides/web-services.rst | 18 +- docs/guides/widgets.rst | 14 +- docs/info/config.php | 8 +- docs/info/manifest.xml | 2 +- docs/intro/features.rst | 2 +- docs/intro/index.rst | 2 +- docs/intro/install.rst | 16 +- docs/intro/license.rst | 4 +- docs/tutorials/blog.rst | 4 +- docs/tutorials/hello_world.rst | 2 +- docs/tutorials/widget.rst | 22 +- docs/tutorials/wysiwyg.rst | 6 +- engine/classes/Elgg/ActionsService.php | 72 ++-- engine/classes/Elgg/Amd/Config.php | 2 +- engine/classes/Elgg/Amd/ViewFilter.php | 24 +- engine/classes/Elgg/Assets/ExternalFiles.php | 76 ++--- engine/classes/Elgg/AttributeLoader.php | 2 +- engine/classes/Elgg/AutoloadManager.php | 10 +- engine/classes/Elgg/Cache/LRUCache.php | 10 +- engine/classes/Elgg/Cache/MemoryPool.php | 10 +- engine/classes/Elgg/Cache/NullPool.php | 2 +- engine/classes/Elgg/Cache/Pool.php | 22 +- engine/classes/Elgg/Cache/SimpleCache.php | 44 +-- engine/classes/Elgg/Cache/StashPool.php | 8 +- engine/classes/Elgg/Cache/SystemCache.php | 62 ++-- engine/classes/Elgg/ClassLoader.php | 6 +- engine/classes/Elgg/ClassMap.php | 6 +- engine/classes/Elgg/CommitMessage.php | 24 +- engine/classes/Elgg/Config.php | 62 ++-- engine/classes/Elgg/Context.php | 20 +- engine/classes/Elgg/Database.php | 8 +- .../Elgg/Database/AccessCollections.php | 258 +++++++-------- engine/classes/Elgg/Database/AdminNotices.php | 26 +- engine/classes/Elgg/Database/Annotations.php | 130 ++++---- engine/classes/Elgg/Database/ConfigTable.php | 90 ++--- engine/classes/Elgg/Database/Datalist.php | 38 +-- engine/classes/Elgg/Database/EntityTable.php | 310 +++++++++--------- .../classes/Elgg/Database/MetadataTable.php | 222 ++++++------- .../Elgg/Database/MetastringsTable.php | 30 +- engine/classes/Elgg/Database/Plugins.php | 264 +++++++-------- .../Elgg/Database/RelationshipsTable.php | 142 ++++---- engine/classes/Elgg/Database/SiteSecret.php | 12 +- engine/classes/Elgg/Database/SubtypeTable.php | 92 +++--- engine/classes/Elgg/Database/UsersTable.php | 242 +++++++------- engine/classes/Elgg/DeprecationWrapper.php | 14 +- engine/classes/Elgg/Di/DiContainer.php | 8 +- .../Elgg/Di/FactoryUncallableException.php | 4 +- .../classes/Elgg/Di/MissingValueException.php | 4 +- engine/classes/Elgg/Di/ServiceProvider.php | 20 +- engine/classes/Elgg/EntityDirLocator.php | 6 +- engine/classes/Elgg/EventsService.php | 4 +- engine/classes/Elgg/Filesystem/File.php | 30 +- engine/classes/Elgg/Filesystem/Filesystem.php | 108 +++--- engine/classes/Elgg/Forms/StickyForms.php | 24 +- .../classes/Elgg/HooksRegistrationService.php | 28 +- .../Elgg/Http/DatabaseSessionHandler.php | 8 +- engine/classes/Elgg/Http/Input.php | 28 +- .../classes/Elgg/Http/MockSessionHandler.php | 2 +- .../classes/Elgg/Http/MockSessionStorage.php | 2 +- .../Elgg/Http/NativeSessionStorage.php | 8 +- engine/classes/Elgg/Http/Request.php | 4 +- engine/classes/Elgg/Http/SessionHandler.php | 4 +- engine/classes/Elgg/Http/SessionStorage.php | 4 +- .../Elgg/Http/WebAppManifestResource.php | 8 +- engine/classes/Elgg/I18n/Translator.php | 128 ++++---- engine/classes/Elgg/Logger.php | 6 +- engine/classes/Elgg/Notifications/Event.php | 8 +- .../Elgg/Notifications/Notification.php | 6 +- .../Notifications/NotificationsService.php | 22 +- .../Notifications/SubscriptionsService.php | 10 +- .../classes/Elgg/PersistentLoginService.php | 24 +- engine/classes/Elgg/PluginHooksService.php | 10 +- engine/classes/Elgg/Queue/DatabaseQueue.php | 4 +- engine/classes/Elgg/Queue/MemoryQueue.php | 4 +- engine/classes/Elgg/Queue/Queue.php | 4 +- engine/classes/Elgg/Router.php | 2 +- .../classes/Elgg/Structs/ArrayCollection.php | 26 +- engine/classes/Elgg/Structs/Collection.php | 30 +- engine/classes/Elgg/UpgradeService.php | 10 +- engine/classes/Elgg/ViewsService.php | 26 +- engine/classes/ElggAutoP.php | 12 +- engine/classes/ElggBatch.php | 2 +- engine/classes/ElggComment.php | 4 +- engine/classes/ElggCookie.php | 18 +- engine/classes/ElggData.php | 4 +- engine/classes/ElggDiskFilestore.php | 4 +- engine/classes/ElggEntity.php | 100 +++--- engine/classes/ElggExtender.php | 4 +- engine/classes/ElggFile.php | 6 +- engine/classes/ElggGroup.php | 20 +- engine/classes/ElggInstaller.php | 44 +-- engine/classes/ElggMemcache.php | 2 +- engine/classes/ElggMenuBuilder.php | 2 +- engine/classes/ElggMenuItem.php | 22 +- engine/classes/ElggMetadata.php | 2 +- engine/classes/ElggObject.php | 8 +- engine/classes/ElggPAM.php | 4 +- engine/classes/ElggPlugin.php | 10 +- engine/classes/ElggPluginManifest.php | 8 +- engine/classes/ElggPluginPackage.php | 6 +- engine/classes/ElggPriorityList.php | 14 +- engine/classes/ElggRelationship.php | 4 +- engine/classes/ElggRewriteTester.php | 14 +- engine/classes/ElggRiverItem.php | 16 +- engine/classes/ElggSession.php | 22 +- engine/classes/ElggSite.php | 2 +- engine/classes/ElggUser.php | 14 +- engine/classes/ElggVolatileMetadataCache.php | 20 +- engine/classes/ElggWidget.php | 6 +- engine/classes/ElggXMLElement.php | 6 +- engine/lib/access.php | 48 +-- engine/lib/actions.php | 6 +- engine/lib/admin.php | 28 +- engine/lib/autoloader.php | 2 +- engine/lib/cache.php | 20 +- engine/lib/comments.php | 6 +- engine/lib/configuration.php | 32 +- engine/lib/deprecated-1.8.php | 26 +- engine/lib/deprecated-1.9.php | 22 +- engine/lib/elgglib.php | 12 +- engine/lib/filestore.php | 2 +- engine/lib/friends.php | 8 +- engine/lib/input.php | 2 +- engine/lib/metadata.php | 2 +- engine/lib/metastrings.php | 2 +- engine/lib/navigation.php | 12 +- engine/lib/notification.php | 38 +-- engine/lib/output.php | 20 +- engine/lib/pagehandler.php | 12 +- engine/lib/pageowner.php | 4 +- engine/lib/plugins.php | 6 +- engine/lib/relationships.php | 2 +- engine/lib/river.php | 20 +- engine/lib/sites.php | 4 +- engine/lib/system_log.php | 4 +- engine/lib/upgrades/2010010501.php | 2 +- engine/lib/upgrades/2010111501.php | 2 +- engine/lib/upgrades/2010121601.php | 2 +- ...dont_filter_passwords-c0ca4a18b38ae2bc.php | 2 +- ...-comments_to_entities-faba94768b055b08.php | 2 +- ...d_missing_group_index-52a63a3a3ffaced2.php | 2 +- ...ev-site-notifications-0aae171afb7a00d8.php | 2 +- ...c.3-river_enabled_col-bef9e6f0533ac338.php | 2 +- engine/lib/user_settings.php | 8 +- engine/lib/users.php | 4 +- engine/lib/views.php | 14 +- engine/lib/widgets.php | 4 +- engine/load.php | 6 +- engine/settings.example.php | 14 +- .../tests/ElggCoreAccessCollectionsTest.php | 10 +- engine/tests/ElggCoreAccessSQLTest.php | 8 +- engine/tests/ElggCoreConfigTest.php | 4 +- engine/tests/ElggCoreFilestoreTest.php | 16 +- .../ElggCoreGetEntitiesFromMetadataTest.php | 16 +- ...lggCoreGetEntitiesFromRelationshipTest.php | 14 +- engine/tests/ElggCoreHelpersTest.php | 14 +- engine/tests/ElggCoreMetadataAPITest.php | 2 +- engine/tests/ElggCoreOutputAutoPTest.php | 4 +- engine/tests/ElggCorePluginsAPITest.php | 24 +- engine/tests/ElggCoreRiverAPITest.php | 20 +- engine/tests/ElggCoreSkeletonTest.php | 2 +- engine/tests/ElggObjectTest.php | 2 +- engine/tests/README.md | 2 +- .../tests/phpunit/Elgg/ActionsServiceTest.php | 40 +-- engine/tests/phpunit/Elgg/Amd/ConfigTest.php | 16 +- .../tests/phpunit/Elgg/Amd/ViewFilterTest.php | 10 +- .../phpunit/Elgg/Cache/MemoryPoolTest.php | 6 +- .../tests/phpunit/Elgg/Cache/NullPoolTest.php | 14 +- .../tests/phpunit/Elgg/Cache/PoolTestCase.php | 2 +- .../phpunit/Elgg/Cache/StashPoolTest.php | 10 +- .../phpunit/Elgg/CommitMessageGitHookTest.php | 8 +- .../tests/phpunit/Elgg/CommitMessageTest.php | 18 +- engine/tests/phpunit/Elgg/ContextTest.php | 48 +-- engine/tests/phpunit/Elgg/DatabaseTest.php | 14 +- .../tests/phpunit/Elgg/Di/DiContainerTest.php | 12 +- .../phpunit/Elgg/Di/ServiceProviderTest.php | 2 +- .../phpunit/Elgg/Filesystem/FileTest.php | 6 +- .../Elgg/Filesystem/FilesystemTest.php | 34 +- .../tests/phpunit/Elgg/Forms/StickyForms.php | 4 +- .../phpunit/Elgg/HooksRegistrationService.php | 6 +- engine/tests/phpunit/Elgg/Http/InputTest.php | 12 +- .../Elgg/Http/NativeSessionStorageTest.php | 2 +- .../phpunit/Elgg/PluginHooksServiceTest.php | 14 +- engine/tests/phpunit/Elgg/RouterTest.php | 22 +- .../Elgg/Structs/ArrayCollectionTest.php | 26 +- .../Elgg/TravisValidateCommitMsgTest.php | 2 +- .../tests/phpunit/Elgg/ViewsServiceTest.php | 34 +- .../tests/phpunit/Elgg/WidgetsServiceTest.php | 40 +-- engine/tests/phpunit/ElggEntityTest.php | 8 +- engine/tests/phpunit/ElggExtenderTest.php | 2 +- engine/tests/phpunit/ElggPriorityListTest.php | 6 +- engine/tests/phpunit/ElggUpgradeTest.php | 2 +- engine/tests/phpunit/ElggUserTest.php | 6 +- .../test_files/commit_messages/valid.txt | 2 +- .../views/default/js/interpreted.js.php | 2 +- .../tests/test_files/plugin_18/manifest.xml | 2 +- install/css/install.css | 10 +- install/languages/en.php | 2 +- js/classes/ElggEntity.js | 4 +- js/classes/ElggPriorityList.js | 2 +- js/lib/comments.js | 2 +- js/lib/configuration.js | 2 +- js/lib/elgglib.js | 4 +- js/lib/hooks.js | 2 +- js/lib/security.js | 6 +- js/lib/session.js | 20 +- js/lib/ui.autocomplete.js | 2 +- js/lib/ui.friends_picker.js | 12 +- js/lib/ui.js | 10 +- js/lib/ui.widgets.js | 2 +- js/tests/ElggAjaxTest.js | 74 ++--- js/tests/ElggHooksTest.js | 18 +- js/tests/ElggLanguagesTest.js | 18 +- js/tests/ElggLibTest.js | 72 ++-- js/tests/ElggPriorityListTest.js | 26 +- js/tests/ElggSecurityTest.js | 40 +-- js/tests/ElggSessionTest.js | 32 +- js/tests/karma.conf.js | 2 +- languages/en.php | 32 +- mod/aalborg_theme/start.php | 4 +- .../views/default/aalborg_theme/css.php | 4 +- .../views/default/css/elements/buttons.php | 2 +- .../views/default/css/elements/components.php | 4 +- .../views/default/css/elements/forms.php | 2 +- .../views/default/css/maintenance.php | 10 +- .../views/default/page/default.php | 2 +- .../views/default/page/elements/navbar.php | 2 +- .../default/page/layouts/one_sidebar.php | 6 +- .../default/page/layouts/two_sidebar.php | 4 +- mod/blog/classes/ElggBlog.php | 6 +- mod/blog/languages/en.php | 2 +- mod/blog/lib/blog.php | 4 +- .../views/default/blog/sidebar/archives.php | 2 +- mod/bookmarks/languages/en.php | 2 +- mod/bookmarks/start.php | 8 +- .../views/default/object/bookmarks.php | 2 +- mod/categories/pages/categories/listing.php | 2 +- mod/ckeditor/README.md | 2 +- mod/ckeditor/views/default/ckeditor/init.php | 2 +- .../views/default/js/elgg/ckeditor.js | 8 +- .../js/elgg/ckeditor/blockimagepaste.js | 16 +- mod/custom_index/index.php | 2 +- mod/custom_index/languages/en.php | 2 +- mod/custom_index/start.php | 4 +- .../default/page/layouts/custom_index.php | 6 +- .../views/default/dashboard/blurb.php | 2 +- mod/developers/classes/ElggInspector.php | 26 +- mod/developers/classes/ElggLogCache.php | 6 +- mod/developers/languages/en.php | 2 +- mod/developers/start.php | 16 +- .../admin/develop_tools/unit_tests.php | 2 +- .../default/admin/developers/settings.php | 2 +- mod/developers/views/default/js/elgg/dev.js | 6 +- .../default/theme_sandbox/icons/avatars.php | 2 +- .../default/theme_sandbox/icons/sprites.php | 2 +- .../views/default/theme_sandbox/intro.php | 2 +- .../default/theme_sandbox/modules/modules.php | 2 +- .../theme_sandbox/navigation/default.php | 2 +- .../theme_sandbox/navigation/extras.php | 2 +- .../theme_sandbox/navigation/filter.php | 4 +- .../theme_sandbox/navigation/horizontal.php | 2 +- .../default/theme_sandbox/navigation/page.php | 2 +- .../default/theme_sandbox/navigation/site.php | 2 +- mod/embed/start.php | 10 +- .../views/default/embed/addcontentjs.php | 2 +- mod/embed/views/default/embed/css.php | 2 +- mod/embed/views/default/js/embed/embed.php | 2 +- .../views/default/expages/menu.php | 2 +- .../views/default/forms/expages/edit.php | 4 +- mod/file/actions/file/delete.php | 2 +- mod/file/actions/file/upload.php | 10 +- mod/file/download.php | 2 +- mod/file/start.php | 6 +- mod/file/views/default/file/css.php | 4 +- mod/file/views/default/forms/file/upload.php | 2 +- mod/garbagecollector/start.php | 8 +- .../plugins/garbagecollector/settings.php | 2 +- mod/groups/actions/groups/delete.php | 2 +- mod/groups/actions/groups/edit.php | 22 +- mod/groups/actions/groups/featured.php | 2 +- mod/groups/classes/ElggDiscussionReply.php | 2 +- mod/groups/start.php | 30 +- mod/groups/topicposts.php | 2 +- mod/groups/views/default/group/default.php | 4 +- mod/groups/views/default/groups/css.php | 4 +- .../groups/profile/activity_module.php | 2 +- .../groups/profile/closed_membership.php | 2 +- .../views/default/groups/profile/summary.php | 2 +- .../views/default/groups/profile/widgets.php | 6 +- .../views/default/js/discussion/discussion.js | 2 +- .../views/default/js/elgg/groups/edit.js | 2 +- .../widgets/group_activity/content.php | 2 +- .../views/json/groups/profile/layout.php | 2 +- mod/htmlawed/start.php | 4 +- mod/htmlawed/tests/tags.php | 4 +- mod/invitefriends/languages/en.php | 8 +- mod/invitefriends/start.php | 4 +- .../views/default/invitefriends/formitems.php | 2 +- mod/legacy_urls/start.php | 14 +- .../views/default/legacy_urls/message.php | 2 +- .../default/plugins/legacy_urls/settings.php | 2 +- mod/likes/languages/en.php | 2 +- mod/likes/start.php | 8 +- mod/logbrowser/start.php | 6 +- .../admin/administer_utilities/logbrowser.php | 2 +- mod/logrotate/languages/en.php | 4 +- .../views/default/messageboard/css.php | 2 +- mod/messages/actions/messages/send.php | 8 +- mod/messages/pages/messages/read.php | 2 +- mod/messages/start.php | 10 +- .../views/default/forms/messages/process.php | 2 +- .../views/default/forms/messages/send.php | 2 +- mod/messages/views/default/messages/css.php | 4 +- .../views/default/object/messages.php | 8 +- mod/notifications/index.php | 2 +- mod/notifications/start.php | 2 +- .../forms/notificationsettings/groupsave.php | 10 +- .../views/default/notifications/css.php | 4 +- .../subscriptions/collections.php | 10 +- .../subscriptions/forminternals.php | 54 +-- .../subscriptions/groupsform.php | 2 +- .../notifications/subscriptions/jsfuncs.php | 12 +- .../notifications/subscriptions/personal.php | 2 +- mod/pages/actions/pages/edit.php | 2 +- mod/pages/lib/pages.php | 4 +- mod/pages/pages/pages/edit.php | 2 +- mod/pages/start.php | 8 +- mod/pages/views/default/forms/pages/edit.php | 2 +- mod/profile/icondirect.php | 8 +- mod/profile/views/default/profile/css.php | 12 +- mod/profile/views/default/profile/layout.php | 2 +- .../views/default/profile/owner_block.php | 2 +- mod/profile/views/json/profile/layout.php | 2 +- .../actions/reportedcontent/add.php | 2 +- .../actions/reportedcontent/archive.php | 2 +- .../actions/reportedcontent/delete.php | 4 +- mod/reportedcontent/start.php | 6 +- .../default/forms/reportedcontent/add.php | 2 +- .../views/default/reportedcontent/css.php | 2 +- mod/search/README.md | 58 ++-- mod/search/pages/search/index.php | 2 +- mod/search/search_hooks.php | 24 +- mod/search/start.php | 16 +- mod/search/views/default/search/css.php | 4 +- mod/search/views/default/search/entity.php | 2 +- .../actions/site_notifications/delete.php | 2 +- .../classes/SiteNotification.php | 12 +- mod/site_notifications/start.php | 10 +- .../views/default/js/site_notifications.php | 2 +- .../default/object/site_notification.php | 4 +- mod/tagcloud/start.php | 4 +- .../views/default/output/tagcloud.php | 8 +- mod/thewire/actions/add.php | 2 +- mod/thewire/actions/delete.php | 2 +- mod/thewire/classes/ElggWire.php | 4 +- mod/thewire/pages/thewire/everyone.php | 2 +- mod/thewire/pages/thewire/owner.php | 2 +- mod/thewire/start.php | 8 +- mod/thewire/tests/regex.php | 2 +- mod/thewire/views/default/object/thewire.php | 2 +- mod/twitter_api/lib/twitter_api.php | 8 +- mod/uservalidationbyemail/languages/en.php | 4 +- mod/uservalidationbyemail/start.php | 4 +- mod/web_services/README.md | 2 +- mod/web_services/lib/client.php | 2 +- mod/web_services/start.php | 4 +- .../tests/ElggCoreWebServicesApiTest.php | 96 +++--- pages/account/forgotten_password.php | 2 +- pages/friends/collections/add.php | 2 +- upgrade.php | 4 +- .../admin/appearance/profile_fields/list.php | 2 +- views/default/admin/header.php | 4 +- .../admin/statistics/overview/numentities.php | 4 +- views/default/admin/users/admins.php | 2 +- views/default/admin/users/online.php | 2 +- views/default/core/account/login_dropdown.php | 6 +- views/default/core/settings/account.php | 2 +- views/default/core/settings/tools.php | 4 +- views/default/css/admin.php | 24 +- views/default/css/elements/components.php | 4 +- views/default/css/elements/core.php | 10 +- views/default/css/elements/forms.php | 6 +- views/default/css/elements/grid.php | 2 +- views/default/css/elements/helpers.php | 2 +- views/default/css/elements/icons.php | 8 +- views/default/css/elements/misc.php | 2 +- views/default/css/elements/modules.php | 8 +- views/default/css/elements/navigation.php | 6 +- views/default/css/elements/typography.php | 4 +- views/default/css/elgg.php | 2 +- .../forms/admin/site/update_advanced.php | 2 +- views/default/forms/avatar/upload.php | 2 +- views/default/forms/login.php | 6 +- .../forms/plugins/usersettings/save.php | 2 +- views/default/forms/useradd.php | 4 +- views/default/forms/widgets/save.php | 2 +- views/default/icon/default.php | 2 +- views/default/input/autocomplete.php | 2 +- views/default/input/checkbox.php | 4 +- views/default/input/checkboxes.php | 4 +- views/default/input/reset.php | 2 +- views/default/js/admin.php | 2 +- views/default/js/initialize_elgg.php | 2 +- views/default/js/lightbox.php | 14 +- views/default/js/lightbox/settings.php | 2 +- views/default/navigation/menu/site.php | 6 +- views/default/navigation/menu/user_hover.php | 8 +- views/default/navigation/topbar_tools.php | 2 +- views/default/navigation/viewtype.php | 2 +- .../object/plugin/elements/contributors.php | 10 +- views/default/object/plugin/full.php | 10 +- views/default/object/plugin/invalid.php | 2 +- views/default/output/friendlytitle.php | 2 +- views/default/output/url.php | 6 +- views/default/page/admin.php | 2 +- views/default/page/components/image_block.php | 2 +- views/default/page/components/list.php | 8 +- views/default/page/default.php | 2 +- views/default/page/elements/comments.php | 2 +- views/default/page/elements/head.php | 2 +- views/default/page/elements/sidebar_alt.php | 2 +- views/default/page/error.php | 2 +- views/default/page/layouts/one_column.php | 2 +- views/default/page/upgrade.php | 2 +- views/default/river/elements/responses.php | 2 +- views/installation/forms/install/template.php | 2 +- views/installation/install/pages/database.php | 8 +- views/json/page/layouts/default.php | 2 +- views/rss/output/url.php | 2 +- 458 files changed, 3050 insertions(+), 3050 deletions(-) diff --git a/.scripts/move_namespaces_to_top.php b/.scripts/move_namespaces_to_top.php index 44cc1e19694..9abb6aa2b25 100644 --- a/.scripts/move_namespaces_to_top.php +++ b/.scripts/move_namespaces_to_top.php @@ -14,26 +14,26 @@ function moveNamespaceToTop($file) { if (!is_file($file)) { return; } - + $contents = file_get_contents($file); $lines = explode("\n", $contents); - + $nsDeclarationPosition = findPositionOfNamespaceDeclaration($lines); - + if ($nsDeclarationPosition == -1) { return; } - + $declaration = $lines[$nsDeclarationPosition]; - + // echo "$declaration\n"; - + unset($lines[$nsDeclarationPosition]); - + array_splice($lines, 1, 0, $declaration); - + $newContents = implode("\n", $lines) . "\n"; - + file_put_contents($file, $newContents); } @@ -44,7 +44,7 @@ function findPositionOfNamespaceDeclaration($lines) { $position = $pos; } } - + return $position; } diff --git a/.scripts/validate_commit_msg.php b/.scripts/validate_commit_msg.php index e6dc3266104..3e9f5828e02 100755 --- a/.scripts/validate_commit_msg.php +++ b/.scripts/validate_commit_msg.php @@ -15,9 +15,9 @@ * copy or symlink to .git/hooks/commit-msg. * */ - + $rootDir = dirname(__DIR__); - + require_once "$rootDir/vendor/autoload.php"; $is_file = false; @@ -25,7 +25,7 @@ if ($argc === 2) { // check file or msg itself $arg = $argv[1]; - + if (file_exists($arg)) { $is_file = true; $msg_tmp = file_get_contents($arg); @@ -88,7 +88,7 @@ output($error, 'error'); } $arg = escapeshellarg($msg); - + $cmd = "printf '%s' $arg | nl -ba"; $output = shell_exec($cmd); output($output, 'error', false); diff --git a/.travis.yml b/.travis.yml index 70cb8649274..dde49033a15 100644 --- a/.travis.yml +++ b/.travis.yml @@ -27,7 +27,7 @@ matrix: - composer validate after_script: - php ocular.phar code-coverage:upload --format=php-clover coverage.clover - + # Build and test javascript - php: 5.6 env: VARIA=true @@ -35,22 +35,22 @@ matrix: - npm install script: - npm test - + # Build docs and check for errors # Flags used here, not in `make html`: # -n Run in nit-picky mode. Currently, this generates warnings for all missing references. # -W Turn warnings into errors. This means that the build stops at the first warning and sphinx-build exits with exit status 1. - php: 5.6 env: VARIA=true - install: + install: - sudo easy_install "Sphinx==1.2.2" script: - sphinx-build -b html -nW docs docs/_build/html - -services: + +services: - mysql -install: +install: - composer install - mysql -e 'create database elgg;' - echo "USE mysql; UPDATE user SET password=PASSWORD('password') WHERE user='root'; FLUSH PRIVILEGES;" | mysql -u root @@ -60,7 +60,7 @@ install: script: - phpunit - php -f ./engine/tests/suite.php - + notifications: email: secure: exC/ws07lLOj3Y43C89jiaKpyB8Yt7DPGSCShV4R3Wkw/hVVzjxt1BinPxzsyL5DC7APUMcTHGOhDB2oCE4ynDE6o6L9bH79fc+V8IYAiNaEIGL0AOuHdnRdGN9GMrr2jv78cZ5MctuUTkeYLaoOEyDGHmkMhqa6SufIDAY8b58= diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 6cc93c1b035..37a96eb6070 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,8 +1,8 @@ ## DISCLAIMERS * **SECURITY ISSUES SHOULD BE REPORTED TO security @ elgg . org!** Please do not post any security issues on github. - * Support requests belong on the [Community site][2]. Tickets with support requests will be closed. - * We cannot make any guarantees as to when your ticket will be resolved or your PR merged. + * Support requests belong on the [Community site][2]. Tickets with support requests will be closed. + * We cannot make any guarantees as to when your ticket will be resolved or your PR merged. ## Pull requests @@ -62,5 +62,5 @@ Good feature request checklist: [4]: http://en.wikipedia.org/wiki/MIT_License [6]: https://github.com/Elgg/Elgg/issues/new [7]: http://docs.elgg.org/wiki/Development/Contributing/Patches - [8]: http://docs.elgg.org/wiki/Plugin_development + [8]: http://docs.elgg.org/wiki/Plugin_development [9]: https://github.com/Elgg/Elgg/tree/master/docs/coding_standards diff --git a/COPYRIGHT.txt b/COPYRIGHT.txt index 26251538646..6c3d28e97f9 100644 --- a/COPYRIGHT.txt +++ b/COPYRIGHT.txt @@ -1,4 +1,4 @@ -The follow individuals, companies, or entities have contributed significant +The follow individuals, companies, or entities have contributed significant code to the Elgg project and share the copyright. (In alphabetical order.) Organizations: diff --git a/README.md b/README.md index 5552ad697a9..36bdc559b9f 100644 --- a/README.md +++ b/README.md @@ -18,7 +18,7 @@ The Elgg project was started in 2004 by - Dave Tosh (). Elgg is released under the GNU General Public License (GPL) Version 2 and the -Massachusetts Institute of Technology (MIT-X11) License. See LICENSE.txt +Massachusetts Institute of Technology (MIT-X11) License. See LICENSE.txt in the root of the package you downloaded. For installation instructions, see INSTALL.txt. diff --git a/actions/admin/site/unlock_upgrade.php b/actions/admin/site/unlock_upgrade.php index 497375cede0..1eab623738e 100644 --- a/actions/admin/site/unlock_upgrade.php +++ b/actions/admin/site/unlock_upgrade.php @@ -1,6 +1,6 @@ events = $original_events; _elgg_services()->hooks = $original_hooks; -// remove the admin notice +// remove the admin notice elgg_delete_admin_notice('comment_upgrade_needed'); // Give some feedback for the UI diff --git a/actions/admin/upgrades/upgrade_datadirs.php b/actions/admin/upgrades/upgrade_datadirs.php index 1cd9e828b43..e0b040161a1 100644 --- a/actions/admin/upgrades/upgrade_datadirs.php +++ b/actions/admin/upgrades/upgrade_datadirs.php @@ -1,7 +1,7 @@ false ); elgg_delete_metadata($options); - + if (!is_null($value) && ($value !== '')) { // only create metadata for non empty values (0 is allowed) to prevent metadata records // with empty string values #4858 - + if (isset($accesslevel[$shortname])) { $access_id = (int) $accesslevel[$shortname]; } else { diff --git a/actions/profile/fields/delete.php b/actions/profile/fields/delete.php index 9879feb3f2d..35f3e92c24e 100644 --- a/actions/profile/fields/delete.php +++ b/actions/profile/fields/delete.php @@ -19,7 +19,7 @@ unset_config("admin_defined_profile_$id") && unset_config("admin_defined_profile_type_$id") && elgg_save_config('profile_custom_fields', $fieldlist)) { - + system_message(elgg_echo('profile:editdefault:delete:success')); } else { register_error(elgg_echo('profile:editdefault:delete:fail')); diff --git a/actions/widgets/add.php b/actions/widgets/add.php index ffa055c2958..da749f4b3af 100644 --- a/actions/widgets/add.php +++ b/actions/widgets/add.php @@ -35,7 +35,7 @@ echo elgg_view_entity($widget, array('show_access' => $show_access)); forward(REFERER); - } + } } register_error(elgg_echo('widgets:add:failure')); diff --git a/actions/widgets/save.php b/actions/widgets/save.php index c559352d664..06cfbf3176d 100644 --- a/actions/widgets/save.php +++ b/actions/widgets/save.php @@ -34,7 +34,7 @@ if ($context) { elgg_push_context($context); } - + if (!$default_widgets) { if (elgg_view_exists("widgets/$widget->handler/content")) { $view = "widgets/$widget->handler/content"; diff --git a/actions/widgets/upgrade.php b/actions/widgets/upgrade.php index 0a5cf8d48b8..a66d7686941 100644 --- a/actions/widgets/upgrade.php +++ b/actions/widgets/upgrade.php @@ -4,7 +4,7 @@ * * Pre-1.8, default widgets were stored as metadata on a defaultwidgets object. * Now they are stored as widget objects owned by the site. - * + * * @package Elgg.Core * @subpackage Widgets.Management */ diff --git a/docs/admin/cron.rst b/docs/admin/cron.rst index cd77c791b80..b14b572b002 100644 --- a/docs/admin/cron.rst +++ b/docs/admin/cron.rst @@ -37,7 +37,7 @@ How does it work? ================= Elgg activates its cron handler when particular cron pages are loaded. -As an example, loading http://example.com/cron/hourly/ in a web browser +As an example, loading http://example.com/cron/hourly/ in a web browser activates the hourly hook. To automate this, cron jobs are setup to hit those pages at certain times. This is done by setting up a ``crontab`` which is a configuration file that determines what cron jobs do and at what interval. diff --git a/docs/admin/performance.rst b/docs/admin/performance.rst index f06304d31fb..377b7211ebe 100644 --- a/docs/admin/performance.rst +++ b/docs/admin/performance.rst @@ -12,7 +12,7 @@ People often ask whether Elgg can scale to large installations. First, we might stop and ask, "where are you planning to get all those users?" Seriously, though, this is a really interesting problem. Making Elgg scale is, if anything, an issue of technical engineering. -It's interesting but more or less a solved problem. +It's interesting but more or less a solved problem. Computer science doesn't work differently for Elgg than for Google, for example. Getting millions of users? That's like the Holy Grail of the entire tech industry. diff --git a/docs/admin/plugins.rst b/docs/admin/plugins.rst index 1b792eda804..1a9e7e070b9 100644 --- a/docs/admin/plugins.rst +++ b/docs/admin/plugins.rst @@ -31,7 +31,7 @@ Language Packs Language packs are plugins that provide support for other languages. -Language packs can extend and include translations for language strings +Language packs can extend and include translations for language strings found in the core, core plugins and/or third-party plugins. Some of the language packs are already included in the core, and can be found in diff --git a/docs/admin/upgrading.rst b/docs/admin/upgrading.rst index f11aa1acb85..e238108b891 100644 --- a/docs/admin/upgrading.rst +++ b/docs/admin/upgrading.rst @@ -33,7 +33,7 @@ Basic instructions .. note:: Any modifications should have been written within plugins, so that they are not lost on overwriting. - If this is not the case, take care to maintain your modifications. + If this is not the case, take care to maintain your modifications. .. note:: diff --git a/docs/appendix/faqs.rst b/docs/appendix/faqs.rst index af7e9a78fb4..286cc6367b9 100644 --- a/docs/appendix/faqs.rst +++ b/docs/appendix/faqs.rst @@ -101,7 +101,7 @@ To quickly check if PHP and an MTA are correctly configured, create a file on yo Be sure to replace "your_email@your_host.com" with your actual email address. Take care to keep quotes around it! When you access this page through your web browser, it will attempt to send a test email. This test will let you know that PHP and your MTA are correctly configured. If it fails--either you get an error or you never receive the email--you will need to do more investigating and possibly contact your service provider. -Fully configuring an MTA and PHP's email functionality is beyond the scope of this FAQ and you should search the Internet for more resources on this. Some basic information on php parameters can be found on `PHP's site`__ +Fully configuring an MTA and PHP's email functionality is beyond the scope of this FAQ and you should search the Internet for more resources on this. Some basic information on php parameters can be found on `PHP's site`__ __ http://php.net/manual/en/mail.configuration.php diff --git a/docs/design/database.rst b/docs/design/database.rst index 43b2ab45328..ba5b6dfc44d 100644 --- a/docs/design/database.rst +++ b/docs/design/database.rst @@ -30,7 +30,7 @@ You can extend entities with extra information in two ways: For example, tags, an ISBN number, a file location, or source language is metadata. ``Annotations``: This is information about the entity, usually - added by a third party after the entity is created. + added by a third party after the entity is created. For example, ratings, likes, and votes are annotations. (Comments were before 1.9.) diff --git a/docs/design/index.rst b/docs/design/index.rst index 3cb08fb7450..6ea2952a1e0 100644 --- a/docs/design/index.rst +++ b/docs/design/index.rst @@ -1,7 +1,7 @@ Design Docs ########### -Gain a deep understanding of how Elgg works +Gain a deep understanding of how Elgg works and why it's built the way it is. .. toctree:: diff --git a/docs/examples/advanced/exceptions.php b/docs/examples/advanced/exceptions.php index 0dd4e17e41e..1fe7a9772ce 100644 --- a/docs/examples/advanced/exceptions.php +++ b/docs/examples/advanced/exceptions.php @@ -4,13 +4,13 @@ * This is an optional script used to override Elgg's default handling of * uncaught exceptions. * This is defined in the global $CONFIG->exception_include in settings.php - * + * * The script will have access to the following variables as part of the scope * global $CONFIG * $exception - the unhandled exception - * + * * @warning - the database may not be available - * + * */ // notify some important people that a problem has occurred @@ -24,7 +24,7 @@ $url = $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; $subject = "Exception: $url"; $message = $exception->getMessage(); - + foreach ($emails as $email) { mail($email, $subject, $message); } diff --git a/docs/guides/actions.rst b/docs/guides/actions.rst index cb35a14c4ef..2d759964c12 100644 --- a/docs/guides/actions.rst +++ b/docs/guides/actions.rst @@ -310,7 +310,7 @@ Similarly, ``mod/bookmarks/pages/edit.php`` uses the same function, but passes t The library file defines ``bookmarks_prepare_form_vars()``. This function accepts an ``ElggEntity`` as an argument and does 3 things: 1. Defines the input names and default values for form inputs. - 2. Extracts the values from a bookmark object if it's passed. + 2. Extracts the values from a bookmark object if it's passed. 3. Extracts the values from a sticky form if it exists. TODO: Include directly from lib/bookmarks.php diff --git a/docs/guides/events-list.rst b/docs/guides/events-list.rst index 70ecfadaf74..0699acfc6bb 100644 --- a/docs/guides/events-list.rst +++ b/docs/guides/events-list.rst @@ -36,7 +36,7 @@ System events the ``system_log`` table. **upgrade, system** - Triggered after a system upgrade has finished. All upgrade scripts have run, but the caches + Triggered after a system upgrade has finished. All upgrade scripts have run, but the caches are not cleared. **upgrade, upgrade** diff --git a/docs/guides/menus.rst b/docs/guides/menus.rst index 6d9c7db915f..b6538cda874 100644 --- a/docs/guides/menus.rst +++ b/docs/guides/menus.rst @@ -68,7 +68,7 @@ Examples * Initialize the plugin */ function my_plugin_init() { - // Register a plugin hook handler for the owner_block menu + // Register a plugin hook handler for the owner_block menu elgg_register_plugin_hook_handler('register', 'menu:owner_block', 'my_owner_block_menu_handler'); } @@ -110,7 +110,7 @@ Examples * Initialize the plugin */ function my_plugin_init() { - // Register a plugin hook handler for the entity menu + // Register a plugin hook handler for the entity menu elgg_register_plugin_hook_handler('register', 'menu:entity', 'my_entity_menu_handler'); } @@ -154,7 +154,7 @@ where you want to menu to be displayed. __ http://reference.elgg.org/views_8php.html#ac2d475d3efbbec30603537013ac34e22 -**Example:** Display a menu called "my_menu" that displays it's menu items +**Example:** Display a menu called "my_menu" that displays it's menu items in alphapetical order: .. code-block:: php diff --git a/docs/guides/notifications.rst b/docs/guides/notifications.rst index 1f606d9f4bc..b76fec2bebc 100644 --- a/docs/guides/notifications.rst +++ b/docs/guides/notifications.rst @@ -198,7 +198,7 @@ Example: /** * Send an SMS notification - * + * * @param string $hook Hook name * @param string $type Hook type * @param bool $result Has anyone sent a message yet? @@ -216,7 +216,7 @@ Example: return false; } - // (A pseudo SMS API class) + // (A pseudo SMS API class) $sms = new SmsApi(); return $sms->send($recipient->mobile, $message->body); diff --git a/docs/guides/river.rst b/docs/guides/river.rst index 68c9d13b5e7..5a88bc8a00c 100644 --- a/docs/guides/river.rst +++ b/docs/guides/river.rst @@ -3,7 +3,7 @@ River Elgg natively supports the "river", an activity stream containing descriptions of activities performed by site members. This page gives an overview of adding -events to the river in an Elgg plugin. +events to the river in an Elgg plugin. Pushing river items =================== diff --git a/docs/guides/upgrading.rst b/docs/guides/upgrading.rst index 864c537b35a..001817b2d76 100644 --- a/docs/guides/upgrading.rst +++ b/docs/guides/upgrading.rst @@ -455,7 +455,7 @@ Use standardized page handlers and scripts The ``object/:subtype`` view ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * Make sure there are views for ``$vars['full_view'] == true`` and ``$vars['full_view'] == false``. ``$vars['full_view']`` replaced ``$vars['full]``. -* Check for the object in ``$vars['entity']``. Use ``elgg_instance_of()`` to make sure it's the type of entity you want. +* Check for the object in ``$vars['entity']``. Use ``elgg_instance_of()`` to make sure it's the type of entity you want. * Return ``true`` to short circuit the view if the entity is missing or wrong. * Use ``elgg_view(‘object/elements/summary’, array(‘entity’ => $entity));`` and ``elgg_view_menu(‘entity’, array(‘entity’ => $entity));`` to help format. You should use very little markup in these views. diff --git a/docs/guides/views.rst b/docs/guides/views.rst index ec3ba66d08b..d3c571f8ac8 100644 --- a/docs/guides/views.rst +++ b/docs/guides/views.rst @@ -4,7 +4,7 @@ Views Introduction ============ -Elgg follows a MVC pattern and Views are the V in MVC. Views are responsible for creating the output. Generally, this will be HTML sent to a web browser, but it could also be RSS, JSON or any number of other data formats. +Elgg follows a MVC pattern and Views are the V in MVC. Views are responsible for creating the output. Generally, this will be HTML sent to a web browser, but it could also be RSS, JSON or any number of other data formats. The Views system handles everything from the layout of pages and chunks of presentation output (like a footer or a toolbar) down to individual links and form inputs. It also allows for advanced features like automatic RSS generation, a swift-to-develop mobile interface, and the alternative interfaces suggested below. @@ -73,7 +73,7 @@ Again, the best way to override views is to place them in the appropriate place .. note:: - When considering long-term maintenance, overriding views in the core and bundled plugins has a cost: Upgrades may bring changes in views, and if you have overridden them, you will not get those changes. You may want to use `post processing `__ if the change you're making can be easily made with string replacement methods. + When considering long-term maintenance, overriding views in the core and bundled plugins has a cost: Upgrades may bring changes in views, and if you have overridden them, you will not get those changes. You may want to use `post processing `__ if the change you're making can be easily made with string replacement methods. .. note:: @@ -221,7 +221,7 @@ This is then used in the provided listing functions. To automatically display a 'subtype' => 'blog', )); -This function checks to see if there are any entities; if there are, it first displays the ``navigation/pagination`` view in order to display a way to move from page to page. It then repeatedly calls ``elgg_view_entity`` on each entity, before returning the result. +This function checks to see if there are any entities; if there are, it first displays the ``navigation/pagination`` view in order to display a way to move from page to page. It then repeatedly calls ``elgg_view_entity`` on each entity, before returning the result. Because it does this, Elgg knows that it can automatically supply an RSS feed - it extends the ``metatags`` view (which is called by the header) in order to provide RSS autodiscovery, which is why you can see the orange RSS icon on those pages. diff --git a/docs/guides/web-services.rst b/docs/guides/web-services.rst index 6f78e6b95b9..f96689e115a 100644 --- a/docs/guides/web-services.rst +++ b/docs/guides/web-services.rst @@ -39,8 +39,8 @@ API framework: .. code:: php - elgg_ws_expose_function("test.echo", - "my_echo", + elgg_ws_expose_function("test.echo", + "my_echo", array("string" => array('type' => 'string')), 'A testing method which echos back a string', 'GET', @@ -110,8 +110,8 @@ parameter: .. code:: php - elgg_ws_expose_function("users.active", - "count_active_users", + elgg_ws_expose_function("users.active", + "count_active_users", array("minutes" => array('type' => 'int', 'required' => false)), 'Number of users who have used the site in the past x minutes', @@ -182,7 +182,7 @@ Let's write our wire posting function: $access = ACCESS_PUBLIC; // returns guid of wire post - return thewire_save_post($text, $access, "api"); + return thewire_save_post($text, $access, "api"); } Exposing this function is the same as the previous except we require @@ -191,8 +191,8 @@ GET HTTP requests. .. code:: php - elgg_ws_expose_function("thewire.post", - "my_post_to_wire", + elgg_ws_expose_function("thewire.post", + "my_post_to_wire", array("text" => array('type' => 'string')), 'Post to the wire. 140 characters or less', 'POST', @@ -247,11 +247,11 @@ use: // user token can also be used for user authentication register_pam_handler('pam_auth_usertoken'); - // simple API key check + // simple API key check register_pam_handler('api_auth_key', "sufficient", "api"); // override the default pams - return true; + return true; } When testing, you may find it useful to register the diff --git a/docs/guides/widgets.rst b/docs/guides/widgets.rst index 5b0288c85f5..a0aecb32788 100644 --- a/docs/guides/widgets.rst +++ b/docs/guides/widgets.rst @@ -20,7 +20,7 @@ The edit.php file contains any extra edit functions you wish to present to the u You do not need to add access level as this comes as part of the widget framework. NOTE: using HTML checkboxes to set widget flags is problematic because if unchecked, -the checkbox input is omitted from form submission. +the checkbox input is omitted from form submission. The effect is that you can only set and not clear flags. The "input/checkboxes" view will not work properly in a widget's edit panel. @@ -138,7 +138,7 @@ Widget edit page:

- +

@@ -182,14 +182,14 @@ Widget view page: diff --git a/docs/info/config.php b/docs/info/config.php index 1e94244df00..d10c7611462 100644 --- a/docs/info/config.php +++ b/docs/info/config.php @@ -343,16 +343,16 @@ /** * This is an optional script used to override Elgg's default handling of * uncaught exceptions. - * + * * This should be an absolute file path to a php script that will be called * any time an uncaught exception is thrown. - * + * * The script will have access to the following variables as part of the scope * global $CONFIG * $exception - the unhandled exception - * + * * @warning - the database may not be available - * + * * @global string $CONFIG->exception_include */ $CONFIG->exception_include = ''; \ No newline at end of file diff --git a/docs/info/manifest.xml b/docs/info/manifest.xml index 86b21376c3d..cf8b197ef59 100644 --- a/docs/info/manifest.xml +++ b/docs/info/manifest.xml @@ -58,7 +58,7 @@ short_open_tag off - + php_version 5.6 diff --git a/docs/intro/features.rst b/docs/intro/features.rst index ea76707d431..8de98aebc5c 100644 --- a/docs/intro/features.rst +++ b/docs/intro/features.rst @@ -27,7 +27,7 @@ For admins * Responsive, mobile-friendly design * RSS support * Activity stream - * Plugins for common content types like blogs, bookmarks, files, microblogging, private messages, documents, message boards, discussion + * Plugins for common content types like blogs, bookmarks, files, microblogging, private messages, documents, message boards, discussion * User authentication and administration If you need more functionality than what Elgg offers out-of-the-box there are a couple of options: diff --git a/docs/intro/index.rst b/docs/intro/index.rst index e7f1cc53338..2f615ceb840 100644 --- a/docs/intro/index.rst +++ b/docs/intro/index.rst @@ -7,6 +7,6 @@ Discover if Elgg is right for your community. :maxdepth: 1 features - license + license install development diff --git a/docs/intro/install.rst b/docs/intro/install.rst index 13d996b42c2..fabbdaef209 100644 --- a/docs/intro/install.rst +++ b/docs/intro/install.rst @@ -88,7 +88,7 @@ selecting 'properties' or 'Get Info'. .. note:: - Directories must be executable to be read and written to. The + Directories must be executable to be read and written to. The suggested permissions depend upon the exact server and user configuration. If the data directory is owned by the web server user, the recommended permissions are 770. @@ -145,7 +145,7 @@ Other Configurations Lighttpd -------- -Have you installed Elgg on a server running lighttpd? +Have you installed Elgg on a server running lighttpd? We are looking for someone to share any configuration and installation steps involved in setting this up. @@ -208,7 +208,7 @@ XAMPP These intructions are provided in case you want to test your Elgg installation on your local computer running Windows. -- Download and install XAMPP to your computer from +- Download and install XAMPP to your computer from http://www.apachefriends.org/en/xampp.html - Once the installation is completed, it will prompt you to start the XAMPP controller panel. Leave it for now. @@ -264,7 +264,7 @@ EasyPHP 2. Download and install the latest Easy PHP from http://www.easyphp.org (16MB download) -3. Set up the database and point the web server to your Elgg folder (all done from the EasyPHP tray icon) +3. Set up the database and point the web server to your Elgg folder (all done from the EasyPHP tray icon) - Right click EasyPHP tray icon, select "Administration" - A new tab is created in your browser for managing Easy PHP - Add your Elgg folder to Apache in "Alias" section @@ -276,7 +276,7 @@ EasyPHP #LoadModule rewrite_module modules/mod_rewrite.so 5. (Ignore this step for v5.3 or later) Change ``AllowOverride None`` to ``AllowOverride All`` - in the relevant directory entry in Configuration/Apache + in the relevant directory entry in Configuration/Apache 6. (Ignore this step for v5.3 or later) From the tray icon fo Configuration/PHP and uncomment this line:: @@ -394,7 +394,7 @@ this page to them. The ``.htaccess``, if not generated automatically (that happens when you have problem with ``mod_rewrite``), you can create it by renaming ``htaccess_dist`` file you find with elgg package to ``.htaccess``. Also -if you find a ``.htaccess`` file inside the installation path, but you +if you find a ``.htaccess`` file inside the installation path, but you are still getting 404 error, make sure the contents of ``.htaccess`` are same as that of ``htaccess_dist``. @@ -418,7 +418,7 @@ reads: ``AllowOverride all`` -This will tell Apache to pick up the ``mod_rewrite`` rules from +This will tell Apache to pick up the ``mod_rewrite`` rules from ``.htaccess``. **Elgg is not installed in the root of your web directory (ex: @@ -559,7 +559,7 @@ have broken something else. Try doing a clean install: - delete the Elgg source files - start over -If that fails, seek the help of the `Elgg community`_. +If that fails, seek the help of the `Elgg community`_. Be sure to mention what version of Elgg you are installing, details of your server platform, and any error messages that you may have received including ones in the error log of your server. diff --git a/docs/intro/license.rst b/docs/intro/license.rst index 3cb1d7ff693..a709d047f65 100644 --- a/docs/intro/license.rst +++ b/docs/intro/license.rst @@ -22,7 +22,7 @@ __ http://www.gnu.org/licenses/gpl-faq.html How much does Elgg cost? ------------------------ -Elgg is free to download, install, and use. +Elgg is free to download, install, and use. If you’d like to donate, we do appreciate our `financial supporters`__! __ http://elgg.org/supporter.php @@ -58,7 +58,7 @@ What’s the difference between the MIT and GPL versions? ------------------------------------------------------- Plugins are not included with the MIT version. -You can distribute a commercial product based on Elgg using the MIT version without making your modifications available. +You can distribute a commercial product based on Elgg using the MIT version without making your modifications available. With the GPL licensed version, you have to include make your modifications of the framework public if you redistribute the framework. diff --git a/docs/tutorials/blog.rst b/docs/tutorials/blog.rst index 52986ec0add..bfcd094ad9a 100644 --- a/docs/tutorials/blog.rst +++ b/docs/tutorials/blog.rst @@ -28,7 +28,7 @@ Create the file ``add.php`` in ``/mod/my_blog/pages/my_blog/``. .. code:: php title); echo elgg_view('output/longtext', array('value' => $vars['entity']->description)); - echo elgg_view('output/tags', array('tags' => $vars['entity']->tags)); + echo elgg_view('output/tags', array('tags' => $vars['entity']->tags)); The last line takes the tags on the my\_blog post and automatically displays them as a series of clickable links. Search is handled diff --git a/docs/tutorials/hello_world.rst b/docs/tutorials/hello_world.rst index 94a6c18a999..309b732f13a 100644 --- a/docs/tutorials/hello_world.rst +++ b/docs/tutorials/hello_world.rst @@ -120,4 +120,4 @@ You can now go to the address http://www.mysite.com/hello/ and you should see th :align: center :width: 60% - Elgg is now routing the URL http://www.mysite.com/hello/ to the page you created. + Elgg is now routing the URL http://www.mysite.com/hello/ to the page you created. diff --git a/docs/tutorials/widget.rst b/docs/tutorials/widget.rst index 0bd2bfa70ac..f8a5ca5894d 100644 --- a/docs/tutorials/widget.rst +++ b/docs/tutorials/widget.rst @@ -3,7 +3,7 @@ Basic Widget Create a widget that will display “Hello, World!” and optionally any text the user wants. -In Elgg, widgets are those components that you can drag onto your profile or admin dashboard. +In Elgg, widgets are those components that you can drag onto your profile or admin dashboard. This tutorial assumes you are familiar with basic Elgg concepts such as: @@ -63,11 +63,11 @@ Edit ``/mod/hello/start.php``. In it add these lines: - - Message: + 'params[message]', + 'name' => 'params[message]', 'value' => $widget->message, 'class' => 'hello-input-text', - )); + )); ?> Notice the relationship between the values passed to the 'name' and the -'value' fields of input/text. +'value' fields of input/text. The name of the input text box is ``params[message]`` because Elgg will automatically handle widget variables put in the array ``params``. The actual php variable name will be ``message``. @@ -123,11 +123,11 @@ Edit content.php and change it to: .. code:: php - $widget->message)); + echo elgg_view('output/text', array('value' => $widget->message)); You should now be able to enter a message in the text box and see it appear in the widget. diff --git a/docs/tutorials/wysiwyg.rst b/docs/tutorials/wysiwyg.rst index 079f8570c4b..187f745099b 100644 --- a/docs/tutorials/wysiwyg.rst +++ b/docs/tutorials/wysiwyg.rst @@ -52,10 +52,10 @@ Create a view tinymce/longtext and add the following code: /** * Elgg long text input with the tinymce text editor intacts * Displays a long text input field - * + * * @package ElggTinyMCE - * - * + * + * */ ?> diff --git a/engine/classes/Elgg/ActionsService.php b/engine/classes/Elgg/ActionsService.php index f29d4e2cdb5..84d7b6a3fcb 100644 --- a/engine/classes/Elgg/ActionsService.php +++ b/engine/classes/Elgg/ActionsService.php @@ -7,25 +7,25 @@ * Use the elgg_* versions instead. * * @access private - * + * * @package Elgg.Core * @subpackage Actions * @since 1.9.0 */ class ActionsService { - + /** * Registered actions storage * @var array */ private $actions = array(); - /** + /** * The current action being processed - * @var string + * @var string */ private $currentAction = null; - + /** * @see action * @access private @@ -33,7 +33,7 @@ class ActionsService { public function execute($action, $forwarder = "") { $action = rtrim($action, '/'); $this->currentAction = $action; - + // @todo REMOVE THESE ONCE #1509 IS IN PLACE. // Allow users to disable plugins without a token in order to // remove plugins that are incompatible. @@ -44,19 +44,19 @@ public function execute($action, $forwarder = "") { 'logout', 'file/download', ); - + if (!in_array($action, $exceptions)) { // All actions require a token. action_gatekeeper($action); } - + $forwarder = str_replace(_elgg_services()->config->getSiteUrl(), "", $forwarder); $forwarder = str_replace("http://", "", $forwarder); $forwarder = str_replace("@", "", $forwarder); if (substr($forwarder, 0, 1) == "/") { $forwarder = substr($forwarder, 1); } - + if (!isset($this->actions[$action])) { register_error(_elgg_services()->translator->translate('actionundefined', array($action))); } elseif (!_elgg_services()->session->isAdminLoggedIn() && ($this->actions[$action]['access'] === 'admin')) { @@ -72,11 +72,11 @@ public function execute($action, $forwarder = "") { } } } - + $forwarder = empty($forwarder) ? REFERER : $forwarder; forward($forwarder); } - + /** * @see elgg_register_action * @access private @@ -85,24 +85,24 @@ public function register($action, $filename = "", $access = 'logged_in') { // plugins are encouraged to call actions with a trailing / to prevent 301 // redirects but we store the actions without it $action = rtrim($action, '/'); - + if (empty($filename)) { - + $path = _elgg_services()->config->get('path'); if ($path === null) { $path = ""; } - + $filename = $path . "actions/" . $action . ".php"; } - + $this->actions[$action] = array( 'file' => $filename, 'access' => $access, ); return true; } - + /** * @see elgg_unregister_action * @access private @@ -124,17 +124,17 @@ public function validateActionToken($visible_errors = true, $token = null, $ts = if (!$token) { $token = get_input('__elgg_token'); } - + if (!$ts) { $ts = get_input('__elgg_ts'); } $session_id = _elgg_services()->session->getId(); - + if (($token) && ($ts) && ($session_id)) { // generate token, check with input and forward if invalid $required_token = generate_action_token($ts); - + // Validate token if ($token == $required_token) { if ($this->validateTokenTimestamp($ts)) { @@ -189,9 +189,9 @@ public function validateActionToken($visible_errors = true, $token = null, $ts = /** * Is the token timestamp within acceptable range? - * + * * @param int $ts timestamp from the CSRF token - * + * * @return bool */ protected function validateTokenTimestamp($ts) { @@ -228,7 +228,7 @@ public function gatekeeper($action) { $token = get_input('__elgg_token'); $ts = (int)get_input('__elgg_ts'); if ($token && $this->validateTokenTimestamp($ts)) { - // The tokens are present and the time looks valid: this is probably a mismatch due to the + // The tokens are present and the time looks valid: this is probably a mismatch due to the // login form being on a different domain. register_error(_elgg_services()->translator->translate('actiongatekeeper:crosssitelogin')); @@ -243,7 +243,7 @@ public function gatekeeper($action) { forward(REFERER, 'csrf'); } - + /** * @see generate_action_token * @access private @@ -253,14 +253,14 @@ public function generateActionToken($timestamp) { $session_id = _elgg_services()->session->getId(); // Session token $st = _elgg_services()->session->get('__elgg_session'); - + if (($site_secret) && ($session_id)) { return md5($site_secret . $timestamp . $session_id . $st); } - + return false; } - + /** * @see elgg_action_exists * @access private @@ -268,7 +268,7 @@ public function generateActionToken($timestamp) { public function exists($action) { return (isset($this->actions[$action]) && file_exists($this->actions[$action]['file'])); } - + /** * @see ajax_forward_hook * @access private @@ -284,10 +284,10 @@ public function ajaxForwardHook($hook, $reason, $return, $params) { 'success' => array() ) )); - + //grab any data echo'd in the action $output = ob_get_clean(); - + //Avoid double-encoding in case data is json $json = json_decode($output); if (isset($json)) { @@ -295,14 +295,14 @@ public function ajaxForwardHook($hook, $reason, $return, $params) { } else { $params['output'] = $output; } - + //Grab any system messages so we can inject them via ajax too $system_messages = system_messages(null, ""); - + if (isset($system_messages['success'])) { $params['system_messages']['success'] = $system_messages['success']; } - + if (isset($system_messages['error'])) { $params['system_messages']['error'] = $system_messages['error']; $params['status'] = -1; @@ -310,7 +310,7 @@ public function ajaxForwardHook($hook, $reason, $return, $params) { $context = array('action' => $this->currentAction); $params = _elgg_services()->hooks->trigger('output', 'ajax', $context, $params); - + // Check the requester can accept JSON responses, if not fall back to // returning JSON in a plain-text response. Some libraries request // JSON in an invisible iframe which they then read from the iframe, @@ -321,12 +321,12 @@ public function ajaxForwardHook($hook, $reason, $return, $params) { } else { header("Content-type: application/json"); } - + echo json_encode($params); exit; } } - + /** * @see ajax_action_hook * @access private @@ -339,7 +339,7 @@ public function ajaxActionHook() { /** * Get all actions - * + * * @return array */ public function getAllActions() { diff --git a/engine/classes/Elgg/Amd/Config.php b/engine/classes/Elgg/Amd/Config.php index dea21aaf51d..b32ed912dd1 100644 --- a/engine/classes/Elgg/Amd/Config.php +++ b/engine/classes/Elgg/Amd/Config.php @@ -6,7 +6,7 @@ * * @package Elgg.Core * @subpackage JavaScript - * + * * @access private */ class Config { diff --git a/engine/classes/Elgg/Amd/ViewFilter.php b/engine/classes/Elgg/Amd/ViewFilter.php index aeed413fc32..ede64c9b8a9 100644 --- a/engine/classes/Elgg/Amd/ViewFilter.php +++ b/engine/classes/Elgg/Amd/ViewFilter.php @@ -3,21 +3,21 @@ /** * WARNING: API IN FLUX. DO NOT USE DIRECTLY. - * + * * This filter adds AMD names to anonymous AMD modules defined in views. - * + * * @package Elgg.Core * @subpackage JavaScript * @since 1.9 - * + * * @access private */ class ViewFilter { /** * Given the view name, returns the AMD name. - * + * * @param string $name The name of the view (e.g., 'js/elgg/module.js') - * + * * @return string The AMD name (e.g., 'elgg/module'), or blank for no AMD name. */ private function getAmdName($name) { @@ -25,29 +25,29 @@ private function getAmdName($name) { if (count($pieces) <= 1 || $pieces[0] != 'js') { return ''; } - + array_shift($pieces); // [elgg, module.js] $basename = basename(array_pop($pieces), ".js"); // module array_push($pieces, $basename); // [elgg, module] - + return implode("/", $pieces); // elgg/module } - + /** * Inserts the AMD name into `$content` and returns the new value. - * + * * @param string $viewName The name of the view. * @param string $content The output of the view to be filtered. - * + * * @return string The new content with the AMD name inserted, if applicable. */ public function filter($viewName, $content) { $amdName = $this->getAmdName($viewName); - + if (!empty($amdName)) { $content = preg_replace('/^define\(([^\'"])/m', "define(\"$amdName\", \$1", $content, 1); } - + return $content; } } diff --git a/engine/classes/Elgg/Assets/ExternalFiles.php b/engine/classes/Elgg/Assets/ExternalFiles.php index acc4af970a9..96fdf9775b1 100644 --- a/engine/classes/Elgg/Assets/ExternalFiles.php +++ b/engine/classes/Elgg/Assets/ExternalFiles.php @@ -14,7 +14,7 @@ class ExternalFiles { /** * Global Elgg configuration - * + * * @var \stdClass */ private $CONFIG; @@ -26,7 +26,7 @@ public function __construct() { global $CONFIG; $this->CONFIG = $CONFIG; } - + /** * Core registration function for external files * @@ -39,35 +39,35 @@ public function __construct() { * @return bool */ function register($type, $name, $url, $location, $priority = 500) { - - + + if (empty($name) || empty($url)) { return false; } - + $url = elgg_format_url($url); $url = elgg_normalize_url($url); - + _elgg_bootstrap_externals_data_structure($type); - + $name = trim(strtolower($name)); - + // normalize bogus priorities, but allow empty, null, and false to be defaults. if (!is_numeric($priority)) { $priority = 500; } - + // no negative priorities right now. $priority = max((int)$priority, 0); - + $item = elgg_extract($name, $this->CONFIG->externals_map[$type]); - + if ($item) { // updating a registered item // don't update loaded because it could already be set $item->url = $url; $item->location = $location; - + // if loaded before registered, that means it hasn't been added to the list yet if ($this->CONFIG->externals[$type]->contains($item)) { $priority = $this->CONFIG->externals[$type]->move($item, $priority); @@ -79,15 +79,15 @@ function register($type, $name, $url, $location, $priority = 500) { $item->loaded = false; $item->url = $url; $item->location = $location; - + $priority = $this->CONFIG->externals[$type]->add($item, $priority); } - + $this->CONFIG->externals_map[$type][$name] = $item; - + return $priority !== false; } - + /** * Unregister an external file * @@ -97,21 +97,21 @@ function register($type, $name, $url, $location, $priority = 500) { * @return bool */ function unregister($type, $name) { - - + + _elgg_bootstrap_externals_data_structure($type); - + $name = trim(strtolower($name)); $item = elgg_extract($name, $this->CONFIG->externals_map[$type]); - + if ($item) { unset($this->CONFIG->externals_map[$type][$name]); return $this->CONFIG->externals[$type]->remove($item); } - + return false; } - + /** * Load an external resource for use on this page * @@ -121,14 +121,14 @@ function unregister($type, $name) { * @return void */ function load($type, $name) { - - + + _elgg_bootstrap_externals_data_structure($type); - + $name = trim(strtolower($name)); - + $item = elgg_extract($name, $this->CONFIG->externals_map[$type]); - + if ($item) { // update a registered item $item->loaded = true; @@ -137,12 +137,12 @@ function load($type, $name) { $item->loaded = true; $item->url = ''; $item->location = ''; - + $this->CONFIG->externals[$type]->add($item); $this->CONFIG->externals_map[$type][$name] = $item; } } - + /** * Get external resource descriptors * @@ -152,11 +152,11 @@ function load($type, $name) { * @return array */ function getLoadedFiles($type, $location) { - - + + if (isset($this->CONFIG->externals) && $this->CONFIG->externals[$type] instanceof \ElggPriorityList) { $items = $this->CONFIG->externals[$type]->getElements(); - + $callback = "return \$v->loaded == true && \$v->location == '$location';"; $items = array_filter($items, create_function('$v', $callback)); if ($items) { @@ -166,7 +166,7 @@ function getLoadedFiles($type, $location) { } return array(); } - + /** * Bootstraps the externals data structure in $CONFIG. * @@ -174,20 +174,20 @@ function getLoadedFiles($type, $location) { * @access private */ function bootstrap($type) { - - + + if (!isset($this->CONFIG->externals)) { $this->CONFIG->externals = array(); } - + if (!isset($this->CONFIG->externals[$type]) || !$this->CONFIG->externals[$type] instanceof \ElggPriorityList) { $this->CONFIG->externals[$type] = new \ElggPriorityList(); } - + if (!isset($this->CONFIG->externals_map)) { $this->CONFIG->externals_map = array(); } - + if (!isset($this->CONFIG->externals_map[$type])) { $this->CONFIG->externals_map[$type] = array(); } diff --git a/engine/classes/Elgg/AttributeLoader.php b/engine/classes/Elgg/AttributeLoader.php index b37840c5b7c..724fc193f1e 100644 --- a/engine/classes/Elgg/AttributeLoader.php +++ b/engine/classes/Elgg/AttributeLoader.php @@ -169,7 +169,7 @@ protected function checkType($row) { public function getAdditionalSelectValues() { return $this->additional_select_values; } - + /** * Get all required attributes for the entity, validating any that are passed in. Returns empty array * if can't be loaded (Check $failure_reason). diff --git a/engine/classes/Elgg/AutoloadManager.php b/engine/classes/Elgg/AutoloadManager.php index 3b687cbef29..9eea4cdcf3f 100644 --- a/engine/classes/Elgg/AutoloadManager.php +++ b/engine/classes/Elgg/AutoloadManager.php @@ -4,7 +4,7 @@ * Manages core autoloading and caching of class maps * * @access private - * + * * @package Elgg.Core * @subpackage Autoloader */ @@ -36,7 +36,7 @@ class AutoloadManager { /** * Constructor - * + * * @param \Elgg\ClassLoader $loader Class loader object */ public function __construct(\Elgg\ClassLoader $loader) { @@ -146,7 +146,7 @@ public function loadCache() { /** * Some method that does something - * + * * @todo what is a spec? * @return bool|array */ @@ -177,7 +177,7 @@ public function deleteCache() { /** * Get the class loader - * + * * @return \Elgg\ClassLoader */ public function getLoader() { @@ -186,7 +186,7 @@ public function getLoader() { /** * Set the cache storage object - * + * * @param \ElggCache $storage Cache object * @return void */ diff --git a/engine/classes/Elgg/Cache/LRUCache.php b/engine/classes/Elgg/Cache/LRUCache.php index 9c0670005a6..08d422e43dd 100644 --- a/engine/classes/Elgg/Cache/LRUCache.php +++ b/engine/classes/Elgg/Cache/LRUCache.php @@ -6,11 +6,11 @@ * * A fixed sized cache that removes the element used last when it reaches its * size limit. - * + * * Based on https://github.com/cash/LRUCache - * + * * @access private - * + * * @package Elgg.Core * @subpackage Cache */ @@ -112,7 +112,7 @@ public function remove($key) { /** * Clear the cache - * + * * @return void */ public function clear() { @@ -121,7 +121,7 @@ public function clear() { /** * Moves the element from current position to end of array - * + * * @param int|string $key The key * @return void */ diff --git a/engine/classes/Elgg/Cache/MemoryPool.php b/engine/classes/Elgg/Cache/MemoryPool.php index f3f33b0525a..3cfc8542e96 100644 --- a/engine/classes/Elgg/Cache/MemoryPool.php +++ b/engine/classes/Elgg/Cache/MemoryPool.php @@ -5,9 +5,9 @@ /** * An in-memory implementation of a cache pool. - * + * * NB: Data put into this cache is not persisted between requests. - * + * * WARNING: API IN FLUX. DO NOT USE DIRECTLY. * * @package Elgg @@ -19,7 +19,7 @@ final class MemoryPool implements Pool { /** @var Pool */ private $pool; - + /** * Happens to use Stash for the in-memory caching, but this * should be considered just an implementation detail. @@ -27,12 +27,12 @@ final class MemoryPool implements Pool { public function __construct() { $this->pool = StashPool::createEphemeral(); } - + /** @inheritDoc */ public function get($key, callable $callback) { return $this->pool->get($key, $callback); } - + /** @inheritDoc */ public function invalidate($key) { $this->pool->invalidate($key); diff --git a/engine/classes/Elgg/Cache/NullPool.php b/engine/classes/Elgg/Cache/NullPool.php index f80048adc04..6b5a5905e7a 100644 --- a/engine/classes/Elgg/Cache/NullPool.php +++ b/engine/classes/Elgg/Cache/NullPool.php @@ -19,7 +19,7 @@ final class NullPool implements Pool { public function get($key, callable $callback) { return call_user_func($callback); } - + /** @inheritDoc */ public function invalidate($key) { // values are always expired, so nothing to do diff --git a/engine/classes/Elgg/Cache/Pool.php b/engine/classes/Elgg/Cache/Pool.php index 688e8917050..fc9f6afba91 100644 --- a/engine/classes/Elgg/Cache/Pool.php +++ b/engine/classes/Elgg/Cache/Pool.php @@ -4,10 +4,10 @@ /** * Represents a group of key-value pairs whose values can be invalidated, * forcing a recalculation of the value. - * + * * Exactly how/when the values are invalidated is not specified by this API, * except that specific values can be forcefully invalidated with ::invalidate(). - * + * * WARNING: API IN FLUX. DO NOT USE DIRECTLY. * * @package Elgg @@ -19,37 +19,37 @@ interface Pool { /** * Fetches a value from the cache, calculating on miss via $callback. - * + * * @param string|int $key A plain string ID for the cache entry * @param callable $callback Logic for calculating the cache entry on miss - * + * * @return mixed The cache value */ public function get($key, callable $callback); - + /** * Forcefully invalidates the value associated with the given key. - * + * * Implementations must: * * Immediately consider the value stale * * Recalculate the value at the next opportunity - * + * * @param string|int $key A plain string ID for the cache entry to invalidate. - * + * * @return void */ public function invalidate($key); /** * Prime the cache to a specific value. - * + * * This is useful when the value was calculated by some out-of-band means. * For example, when a list of rows is fetched from the database, you can * prime the cache for each individual result. - * + * * @param string|int $key A plain string ID for the cache entry * @param mixed $value The cache value - * + * * @return void */ public function put($key, $value); diff --git a/engine/classes/Elgg/Cache/SimpleCache.php b/engine/classes/Elgg/Cache/SimpleCache.php index 58167b653fa..a92fc6691ed 100644 --- a/engine/classes/Elgg/Cache/SimpleCache.php +++ b/engine/classes/Elgg/Cache/SimpleCache.php @@ -11,10 +11,10 @@ * @since 1.10.0 */ class SimpleCache { - + /** * Global Elgg configuration - * + * * @var \stdClass */ private $CONFIG; @@ -47,12 +47,12 @@ public function __construct() { function registerView($view_name) { elgg_register_external_view($view_name, true); } - + /** * Get the URL for the cached file - * + * * This automatically registers the view with Elgg's simplecache. - * + * * @example * $blog_js = elgg_get_simplecache_url('js', 'blog/save_draft'); * elgg_register_js('elgg.blog', $blog_js); @@ -67,15 +67,15 @@ function getUrl($type, $view) { if (($type === 'js' || $type === 'css') && 0 === strpos($view, $type . '/')) { $view = substr($view, strlen($type) + 1); } - + elgg_register_simplecache_view("$type/$view"); return _elgg_get_simplecache_root() . "$type/$view"; } - - + + /** * Get the base url for simple cache requests - * + * * @return string The simplecache root url for the current viewtype. * @access private */ @@ -87,10 +87,10 @@ function getRoot() { } else { $lastcache = 0; } - + return elgg_normalize_url("/cache/$lastcache/$viewtype/"); } - + /** * Is simple cache enabled * @@ -99,7 +99,7 @@ function getRoot() { function isEnabled() { return (bool) _elgg_services()->config->get('simplecache_enabled'); } - + /** * Enables the simple cache. * @@ -111,7 +111,7 @@ function enable() { _elgg_services()->config->set('simplecache_enabled', 1); elgg_invalidate_simplecache(); } - + /** * Disables the simple cache. * @@ -124,12 +124,12 @@ function disable() { if (_elgg_services()->config->get('simplecache_enabled')) { _elgg_services()->datalist->set('simplecache_enabled', 0); _elgg_services()->config->set('simplecache_enabled', 0); - + // purge simple cache _elgg_rmdir(_elgg_services()->config->getDataPath() . "views_simplecache"); } } - + /** * Deletes all cached views in the simplecache and sets the lastcache and * lastupdate time to 0 for every valid viewtype. @@ -137,19 +137,19 @@ function disable() { * @return bool */ function invalidate() { - - + + if (!isset($this->CONFIG->views->simplecache) || !is_array($this->CONFIG->views->simplecache)) { return false; } - + _elgg_rmdir("{$this->CONFIG->dataroot}views_simplecache"); mkdir("{$this->CONFIG->dataroot}views_simplecache"); - + $time = time(); _elgg_services()->datalist->set("simplecache_lastupdate", $time); $this->CONFIG->lastcache = $time; - + return true; } @@ -159,10 +159,10 @@ function invalidate() { * @return void */ function init() { - + if (!defined('UPGRADING') && empty($this->CONFIG->lastcache)) { $this->CONFIG->lastcache = (int)_elgg_services()->datalist->get('simplecache_lastupdate'); } - } + } } \ No newline at end of file diff --git a/engine/classes/Elgg/Cache/StashPool.php b/engine/classes/Elgg/Cache/StashPool.php index 8fc28bab03a..7fb796fa60d 100644 --- a/engine/classes/Elgg/Cache/StashPool.php +++ b/engine/classes/Elgg/Cache/StashPool.php @@ -5,7 +5,7 @@ /** * Defers to Stash for the meat of the caching logic. - * + * * WARNING: API IN FLUX. DO NOT USE DIRECTLY. * * @package Elgg @@ -50,17 +50,17 @@ public function get($key, callable $callback) { /** @inheritDoc */ public function invalidate($key) { assert(is_string($key) || is_int($key)); - + $this->stash->getItem((string)$key)->clear(); } - + /** @inheritDoc */ public function put($key, $value) { assert(is_string($key) || is_int($key)); $this->stash->getItem((string)$key)->set($value); } - + /** * Create an in-memory implementation of the pool. * diff --git a/engine/classes/Elgg/Cache/SystemCache.php b/engine/classes/Elgg/Cache/SystemCache.php index 3e8b95eb088..e0a62bdfad2 100644 --- a/engine/classes/Elgg/Cache/SystemCache.php +++ b/engine/classes/Elgg/Cache/SystemCache.php @@ -13,7 +13,7 @@ class SystemCache { /** * Global Elgg configuration - * + * * @var \stdClass */ private $CONFIG; @@ -35,20 +35,20 @@ public function __construct() { * @return \ElggFileCache */ function get() { - - + + /** * A default filestore cache using the dataroot. */ static $FILE_PATH_CACHE; - + if (!$FILE_PATH_CACHE) { $FILE_PATH_CACHE = new \ElggFileCache($this->CONFIG->dataroot . 'system_cache/'); } - + return $FILE_PATH_CACHE; } - + /** * Reset the system cache by deleting the caches * @@ -58,7 +58,7 @@ function reset() { $cache = elgg_get_system_cache(); $cache->clear(); } - + /** * Saves a system cache. * @@ -67,16 +67,16 @@ function reset() { * @return bool */ function save($type, $data) { - - + + if ($this->CONFIG->system_cache_enabled) { $cache = elgg_get_system_cache(); return $cache->save($type, $data); } - + return false; } - + /** * Retrieve the contents of a system cache. * @@ -84,20 +84,20 @@ function save($type, $data) { * @return string */ function load($type) { - - + + if ($this->CONFIG->system_cache_enabled) { $cache = elgg_get_system_cache(); $cached_data = $cache->load($type); - + if ($cached_data) { return $cached_data; } } - + return null; } - + /** * Enables the system disk cache. * @@ -107,13 +107,13 @@ function load($type) { * @return void */ function enable() { - - + + _elgg_services()->datalist->set('system_cache_enabled', 1); $this->CONFIG->system_cache_enabled = 1; elgg_reset_system_cache(); } - + /** * Disables the system disk cache. * @@ -123,44 +123,44 @@ function enable() { * @return void */ function disable() { - - + + _elgg_services()->datalist->set('system_cache_enabled', 0); $this->CONFIG->system_cache_enabled = 0; elgg_reset_system_cache(); } - + /** * Loads the system cache during engine boot - * + * * @see elgg_reset_system_cache() * @access private */ function loadAll() { - - + + $this->CONFIG->system_cache_loaded = false; - + $this->CONFIG->views = new \stdClass(); $data = elgg_load_system_cache('view_locations'); if (!is_string($data)) { return; } $this->CONFIG->views->locations = unserialize($data); - + $data = elgg_load_system_cache('view_types'); if (!is_string($data)) { return; } $this->CONFIG->view_types = unserialize($data); - + $this->CONFIG->system_cache_loaded = true; } - + /** * Initializes the simplecache lastcache variable and creates system cache files * when appropriate. - * + * * @access private */ function init() { @@ -169,7 +169,7 @@ function init() { elgg_save_system_cache('view_locations', serialize($this->CONFIG->views->locations)); elgg_save_system_cache('view_types', serialize($this->CONFIG->view_types)); } - + if ($this->CONFIG->system_cache_enabled && !$this->CONFIG->i18n_loaded_from_cache) { _elgg_services()->translator->reloadAllTranslations(); foreach ($this->CONFIG->translations as $lang => $map) { diff --git a/engine/classes/Elgg/ClassLoader.php b/engine/classes/Elgg/ClassLoader.php index 62ed2d1f8e8..3d4a76940ba 100644 --- a/engine/classes/Elgg/ClassLoader.php +++ b/engine/classes/Elgg/ClassLoader.php @@ -59,7 +59,7 @@ class ClassLoader { /** * Constructor - * + * * @param \Elgg\ClassMap $map Class map */ public function __construct(\Elgg\ClassMap $map) { @@ -68,7 +68,7 @@ public function __construct(\Elgg\ClassMap $map) { /** * Get the class map - * + * * @return \Elgg\ClassMap */ public function getClassMap() { @@ -151,7 +151,7 @@ public function addFallback($path) { /** * Registers this instance as an autoloader. - * + * * @return void */ public function register() { diff --git a/engine/classes/Elgg/ClassMap.php b/engine/classes/Elgg/ClassMap.php index b47a7f10231..5ca4c15e472 100644 --- a/engine/classes/Elgg/ClassMap.php +++ b/engine/classes/Elgg/ClassMap.php @@ -4,7 +4,7 @@ * A map of class names to absolute file paths * * @access private - * + * * @package Elgg.Core * @subpackage Autoloader */ @@ -60,7 +60,7 @@ public function getAltered() { /** * Set the altered flag - * + * * @param bool $altered Whether the class map has been altered * @return \Elgg\ClassMap */ @@ -92,7 +92,7 @@ public function setMap(array $map) { /** * Merge a class map with the current map - * + * * @param array $map array with keys being class/interface/trait names and * values the absolute file paths that define them * @return \Elgg\ClassMap diff --git a/engine/classes/Elgg/CommitMessage.php b/engine/classes/Elgg/CommitMessage.php index a5e7d19c4f5..413b6812ea5 100644 --- a/engine/classes/Elgg/CommitMessage.php +++ b/engine/classes/Elgg/CommitMessage.php @@ -6,10 +6,10 @@ /** * Provides a structured format for parsing and examining our commit messages. - * + * * @package Elgg.Core * @since 1.9 - * + * * @access private */ class CommitMessage { @@ -116,7 +116,7 @@ class CommitMessage { /** * Regex to extract the message parts - * + * * type(component): message * with an optional body following * @@ -152,9 +152,9 @@ public function __construct($msg = null) { /** * Sets the active message - * + * * @param string $msg The message content - * + * * @return void */ public function setMsg($msg) { @@ -199,7 +199,7 @@ public function shouldIgnore() { */ private function processMsg() { $matches = array(); - + preg_match($this->formatRegex, $this->msg, $matches); foreach ($this->validMsgParts as $i => $part) { $this->$part = isset($matches[$i]) ? $matches[$i] : ''; @@ -218,10 +218,10 @@ public function isValid() { $this->isValidLineLength() && $this->isValidType(); } - + /** * Whether the message format conforms to our standards. - * + * * @return boolean */ public function isValidFormat() { @@ -280,7 +280,7 @@ public function getMaxLineLength() { * Defaults to 160. * * @param int $len The maximum length. - * + * * @return void */ public function setMaxLineLength($len) { @@ -291,7 +291,7 @@ public function setMaxLineLength($len) { * Get part of the message * * @param string $part One section of the message. - * + * * @return string * @throws UnexpectedValueException */ @@ -307,7 +307,7 @@ public function getPart($part) { * Removes all lines that start with # * * @param string $msg The msg body of the commit - * + * * @return string */ public static function removeComments($msg) { @@ -326,7 +326,7 @@ public static function removeComments($msg) { * * @param string $msg The content to parse * @param int $max_len Maximum length between \n in the $msg - * + * * @return array */ public static function findLengthyLines($msg, $max_len) { diff --git a/engine/classes/Elgg/Config.php b/engine/classes/Elgg/Config.php index 7323dba72b8..7c1508c470e 100644 --- a/engine/classes/Elgg/Config.php +++ b/engine/classes/Elgg/Config.php @@ -14,7 +14,7 @@ class Config { /** * Global Elgg configuration - * + * * @var \stdClass */ private $CONFIG; @@ -35,50 +35,50 @@ public function __construct() { */ function getSiteUrl($site_guid = 0) { if ($site_guid == 0) { - + return $this->CONFIG->wwwroot; } - + $site = get_entity($site_guid); - + if (!$site instanceof \ElggSite) { return false; } /* @var \ElggSite $site */ - + return $site->url; } - + /** * Get the plugin path for this installation * * @return string */ function getPluginsPath() { - + return $this->CONFIG->pluginspath; } - + /** * Get the data directory path for this installation * * @return string */ function getDataPath() { - + return $this->CONFIG->dataroot; } - + /** * Get the root directory path for this installation * * @return string */ function getRootPath() { - + return $this->CONFIG->path; } - + /** * Get an Elgg configuration value * @@ -88,15 +88,15 @@ function getRootPath() { * @return mixed Configuration value or null if it does not exist */ function get($name, $site_guid = 0) { - - + + $name = trim($name); - + // do not return $CONFIG value if asking for non-current site if (($site_guid === 0 || $site_guid === null || $site_guid == $this->CONFIG->site_guid) && isset($this->CONFIG->$name)) { return $this->CONFIG->$name; } - + if ($site_guid === null) { // installation wide setting $value = _elgg_services()->datalist->get($name); @@ -104,7 +104,7 @@ function get($name, $site_guid = 0) { if ($site_guid == 0) { $site_guid = (int) $this->CONFIG->site_guid; } - + // hit DB only if we're not sure if value isn't already loaded if (!isset($this->CONFIG->site_config_loaded) || $site_guid != $this->CONFIG->site_guid) { // site specific setting @@ -113,19 +113,19 @@ function get($name, $site_guid = 0) { $value = null; } } - + // @todo document why we don't cache false if ($value === false) { return null; } - + if ($site_guid == $this->CONFIG->site_guid || $site_guid === null) { $this->CONFIG->$name = $value; } - + return $value; } - + /** * Set an Elgg configuration value * @@ -137,13 +137,13 @@ function get($name, $site_guid = 0) { * @return void */ function set($name, $value) { - - + + $name = trim($name); - + $this->CONFIG->$name = $value; } - + /** * Save a configuration setting * @@ -154,15 +154,15 @@ function set($name, $value) { * @return bool */ function save($name, $value, $site_guid = 0) { - - + + $name = trim($name); - + if (strlen($name) > 255) { _elgg_services()->logger->error("The name length for configuration variables cannot be greater than 255"); return false; } - + if ($site_guid === null) { if (is_array($value) || is_object($value)) { return false; @@ -174,11 +174,11 @@ function save($name, $value, $site_guid = 0) { } $result = _elgg_services()->configTable->set($name, $value, $site_guid); } - + if ($site_guid === null || $site_guid == $this->CONFIG->site_guid) { _elgg_services()->config->set($name, $value); } - + return $result; } } \ No newline at end of file diff --git a/engine/classes/Elgg/Context.php b/engine/classes/Elgg/Context.php index c76318211c7..681f94ffd6c 100644 --- a/engine/classes/Elgg/Context.php +++ b/engine/classes/Elgg/Context.php @@ -3,15 +3,15 @@ /** * PRIVATE CLASS. API IN FLUX. DO NOT USE DIRECTLY. - * + * * PLUGIN DEVELOPERS SHOULD USE elgg_*_context FUNCTIONS INSTEAD. - * + * * Views can modify their output based on the local context. You may want to * display a list of blogs on a blog page or in a small widget. The rendered * output could be different for those two contexts ('blog' vs 'widget'). * * Pages that pass through the page handling system set the context to the - * first string after the root url. Example: http://example.org/elgg/bookmarks/ + * first string after the root url. Example: http://example.org/elgg/bookmarks/ * results in the initial context being set to 'bookmarks'. * * The context is a stack so that for a widget on a profile, the context stack @@ -19,15 +19,15 @@ * * @warning The context is not available until the page_handler runs (after * the 'init, system' event processing has completed). - * + * * @package Elgg.Core * @access private * @since 1.10.0 */ final class Context { - + private $stack = array(); - + /** * Get the most recently pushed context value. * @@ -35,7 +35,7 @@ final class Context { */ public function peek() { $topPos = count($this->stack) - 1; - + if ($topPos >= 0) { return $this->stack[$topPos]; } else { @@ -43,7 +43,7 @@ public function peek() { } } - + /** * Push a context onto the top of the stack * @@ -53,7 +53,7 @@ public function peek() { public function push($context) { array_push($this->stack, $context); } - + /** * Removes and returns the top context string from the stack * @@ -62,7 +62,7 @@ public function push($context) { public function pop() { return array_pop($this->stack); } - + /** * Sets the page context * diff --git a/engine/classes/Elgg/Database.php b/engine/classes/Elgg/Database.php index f8c2f12957d..9daea6181a6 100644 --- a/engine/classes/Elgg/Database.php +++ b/engine/classes/Elgg/Database.php @@ -536,9 +536,9 @@ public function executeDelayedQueries() { /** * Enable the query cache - * + * * This does not take precedence over the \Elgg\Database\Config setting. - * + * * @return void */ public function enableQueryCache() { @@ -550,10 +550,10 @@ public function enableQueryCache() { /** * Disable the query cache - * + * * This is useful for special scripts that pull large amounts of data back * in single queries. - * + * * @return void */ public function disableQueryCache() { diff --git a/engine/classes/Elgg/Database/AccessCollections.php b/engine/classes/Elgg/Database/AccessCollections.php index 18307998d9a..c5ff6dfc71d 100644 --- a/engine/classes/Elgg/Database/AccessCollections.php +++ b/engine/classes/Elgg/Database/AccessCollections.php @@ -14,7 +14,7 @@ class AccessCollections { /** * Global Elgg configuration - * + * * @var \stdClass */ private $CONFIG; @@ -45,37 +45,37 @@ public function __construct() { function getAccessList($user_guid = 0, $site_guid = 0, $flush = false) { global $init_finished; $cache = _elgg_get_access_cache(); - + if ($flush) { $cache->clear(); } - + if ($user_guid == 0) { $user_guid = _elgg_services()->session->getLoggedInUserGuid(); } - + if (($site_guid == 0) && (isset($this->CONFIG->site_id))) { $site_guid = $this->CONFIG->site_id; } $user_guid = (int) $user_guid; $site_guid = (int) $site_guid; - + $hash = $user_guid . $site_guid . 'get_access_list'; - + if ($cache[$hash]) { return $cache[$hash]; } - + $access_array = get_access_array($user_guid, $site_guid, $flush); $access = "(" . implode(",", $access_array) . ")"; - + if ($init_finished) { $cache[$hash] = $access; } - + return $access; } - + /** * Returns an array of access IDs a user is permitted to see. * @@ -103,41 +103,41 @@ function getAccessList($user_guid = 0, $site_guid = 0, $flush = false) { */ function getAccessArray($user_guid = 0, $site_guid = 0, $flush = false) { global $init_finished; - + $cache = _elgg_get_access_cache(); - + if ($flush) { $cache->clear(); } - + if ($user_guid == 0) { $user_guid = _elgg_services()->session->getLoggedInUserGuid(); } - + if (($site_guid == 0) && (isset($this->CONFIG->site_guid))) { $site_guid = $this->CONFIG->site_guid; } - + $user_guid = (int) $user_guid; $site_guid = (int) $site_guid; - + $hash = $user_guid . $site_guid . 'get_access_array'; - + if ($cache[$hash]) { $access_array = $cache[$hash]; } else { $access_array = array(ACCESS_PUBLIC); - + // The following can only return sensible data for a known user. if ($user_guid) { $access_array[] = ACCESS_LOGGED_IN; - + // Get ACL memberships $query = "SELECT am.access_collection_id" . " FROM {$this->CONFIG->dbprefix}access_collection_membership am" . " LEFT JOIN {$this->CONFIG->dbprefix}access_collections ag ON ag.id = am.access_collection_id" . " WHERE am.user_guid = $user_guid AND (ag.site_guid = $site_guid OR ag.site_guid = 0)"; - + $collections = _elgg_services()->db->getData($query); if ($collections) { foreach ($collections as $collection) { @@ -146,11 +146,11 @@ function getAccessArray($user_guid = 0, $site_guid = 0, $flush = false) { } } } - + // Get ACLs owned. $query = "SELECT ag.id FROM {$this->CONFIG->dbprefix}access_collections ag "; $query .= "WHERE ag.owner_guid = $user_guid AND (ag.site_guid = $site_guid OR ag.site_guid = 0)"; - + $collections = _elgg_services()->db->getData($query); if ($collections) { foreach ($collections as $collection) { @@ -159,33 +159,33 @@ function getAccessArray($user_guid = 0, $site_guid = 0, $flush = false) { } } } - + $ignore_access = elgg_check_access_overrides($user_guid); - + if ($ignore_access == true) { $access_array[] = ACCESS_PRIVATE; } } - + if ($init_finished) { $cache[$hash] = $access_array; } } - + $options = array( 'user_id' => $user_guid, 'site_id' => $site_guid ); - + // see the warning in the docs for this function about infinite loop potential return _elgg_services()->hooks->trigger('access:collections:read', 'user', $options, $access_array); } - + /** * Returns the SQL where clause for enforcing read access to data. * * Note that if this code is executed in privileged mode it will return (1=1). - * + * * Otherwise it returns a where clause to retrieve the data that a user has * permission to read. * @@ -199,30 +199,30 @@ function getAccessArray($user_guid = 0, $site_guid = 0, $flush = false) { * * The results will be combined into an SQL where clause in the form: * ((or1 OR or2 OR orN) AND (and1 AND and2 AND andN)) - * + * * @param array $options Array in format: * * table_alias => STR Optional table alias. This is based on the select and join clauses. - * Default is 'e'. + * Default is 'e'. * * user_guid => INT Optional GUID for the user that we are retrieving data for. * Defaults to the logged in user. - * - * use_enabled_clause => BOOL Optional. Should we append the enabled clause? The default + * + * use_enabled_clause => BOOL Optional. Should we append the enabled clause? The default * is set by access_show_hidden_entities(). - * + * * access_column => STR Optional access column name. Default is 'access_id'. - * + * * owner_guid_column => STR Optional owner_guid column. Default is 'owner_guid'. - * + * * guid_column => STR Optional guid_column. Default is 'guid'. - * + * * @return string * @access private */ function getWhereSql(array $options = array()) { global $ENTITY_SHOW_HIDDEN_OVERRIDE; - + $defaults = array( 'table_alias' => 'e', 'user_guid' => _elgg_services()->session->getLoggedInUserGuid(), @@ -231,27 +231,27 @@ function getWhereSql(array $options = array()) { 'owner_guid_column' => 'owner_guid', 'guid_column' => 'guid', ); - + $options = array_merge($defaults, $options); - + // just in case someone passes a . at the end $options['table_alias'] = rtrim($options['table_alias'], '.'); - + foreach (array('table_alias', 'access_column', 'owner_guid_column', 'guid_column') as $key) { $options[$key] = sanitize_string($options[$key]); } $options['user_guid'] = sanitize_int($options['user_guid'], false); - + // only add dot if we have an alias or table name $table_alias = $options['table_alias'] ? $options['table_alias'] . '.' : ''; - + $options['ignore_access'] = elgg_check_access_overrides($options['user_guid']); - + $clauses = array( 'ors' => array(), 'ands' => array() ); - + if ($options['ignore_access']) { $clauses['ors'][] = '1 = 1'; } else if ($options['user_guid']) { @@ -261,38 +261,38 @@ function getWhereSql(array $options = array()) { SELECT guid_one FROM {$this->CONFIG->dbprefix}entity_relationships WHERE relationship = 'friend' AND guid_two = {$options['user_guid']} )"; - + // include user's content $clauses['ors'][] = "$table_alias{$options['owner_guid_column']} = {$options['user_guid']}"; } - + // include standard accesses (public, logged in, access collections) if (!$options['ignore_access']) { $access_list = get_access_list($options['user_guid']); $clauses['ors'][] = "$table_alias{$options['access_column']} IN {$access_list}"; } - + if ($options['use_enabled_clause']) { $clauses['ands'][] = "{$table_alias}enabled = 'yes'"; } - + $clauses = _elgg_services()->hooks->trigger('get_sql', 'access', $options, $clauses); - + $clauses_str = ''; if (is_array($clauses['ors']) && $clauses['ors']) { $clauses_str = '(' . implode(' OR ', $clauses['ors']) . ')'; } - + if (is_array($clauses['ands']) && $clauses['ands']) { if ($clauses_str) { $clauses_str .= ' AND '; } $clauses_str .= '(' . implode(' AND ', $clauses['ands']) . ')'; } - + return "($clauses_str)"; } - + /** * Can a user access an entity. * @@ -313,19 +313,19 @@ function getWhereSql(array $options = array()) { * @return bool */ function hasAccessToEntity($entity, $user = null) { - - + + // See #7159. Must not allow ignore access to affect query $ia = elgg_set_ignore_access(false); - + if (!isset($user)) { $access_bit = _elgg_get_access_where_sql(); } else { $access_bit = _elgg_get_access_where_sql(array('user_guid' => $user->getGUID())); } - + elgg_set_ignore_access($ia); - + $query = "SELECT guid from {$this->CONFIG->dbprefix}entities e WHERE e.guid = " . $entity->getGUID(); // Add access controls $query .= " AND " . $access_bit; @@ -335,7 +335,7 @@ function hasAccessToEntity($entity, $user = null) { return false; } } - + /** * Returns an array of access permissions that the user is allowed to save content with. * Permissions returned are of the form (id => 'name'). @@ -364,24 +364,24 @@ function hasAccessToEntity($entity, $user = null) { function getWriteAccessArray($user_guid = 0, $site_guid = 0, $flush = false) { global $init_finished; $cache = _elgg_get_access_cache(); - + if ($flush) { $cache->clear(); } - + if ($user_guid == 0) { $user_guid = _elgg_services()->session->getLoggedInUserGuid(); } - + if (($site_guid == 0) && (isset($this->CONFIG->site_id))) { $site_guid = $this->CONFIG->site_id; } - + $user_guid = (int) $user_guid; $site_guid = (int) $site_guid; - + $hash = $user_guid . $site_guid . 'get_write_access_array'; - + if ($cache[$hash]) { $access_array = $cache[$hash]; } else { @@ -392,23 +392,23 @@ function getWriteAccessArray($user_guid = 0, $site_guid = 0, $flush = false) { ACCESS_LOGGED_IN => _elgg_services()->translator->translate("LOGGED_IN"), ACCESS_PUBLIC => _elgg_services()->translator->translate("PUBLIC") ); - + $query = "SELECT ag.* FROM {$this->CONFIG->dbprefix}access_collections ag "; $query .= " WHERE (ag.site_guid = $site_guid OR ag.site_guid = 0)"; $query .= " AND (ag.owner_guid = $user_guid)"; - + $collections = _elgg_services()->db->getData($query); if ($collections) { foreach ($collections as $collection) { $access_array[$collection->id] = $collection->name; } } - + if ($init_finished) { $cache[$hash] = $access_array; } } - + $options = array( 'user_id' => $user_guid, 'site_id' => $site_guid @@ -437,15 +437,15 @@ function canEdit($collection_id, $user_guid = null) { } else { $user = _elgg_services()->session->getLoggedInUser(); } - + $collection = get_access_collection($collection_id); - + if (!($user instanceof \ElggUser) || !$collection) { return false; } - + $write_access = get_write_access_array($user->getGUID(), 0, true); - + // don't ignore access when checking users. if ($user_guid) { return array_key_exists($collection_id, $write_access); @@ -453,7 +453,7 @@ function canEdit($collection_id, $user_guid = null) { return elgg_get_ignore_access() || array_key_exists($collection_id, $write_access); } } - + /** * Creates a new access collection. * @@ -472,13 +472,13 @@ function canEdit($collection_id, $user_guid = null) { * @return int|false The collection ID if successful and false on failure. */ function create($name, $owner_guid = 0, $site_guid = 0) { - - + + $name = trim($name); if (empty($name)) { return false; } - + if ($owner_guid == 0) { $owner_guid = _elgg_services()->session->getLoggedInUserGuid(); } @@ -486,7 +486,7 @@ function create($name, $owner_guid = 0, $site_guid = 0) { $site_guid = $this->CONFIG->site_guid; } $name = sanitise_string($name); - + $q = "INSERT INTO {$this->CONFIG->dbprefix}access_collections SET name = '{$name}', owner_guid = {$owner_guid}, @@ -495,18 +495,18 @@ function create($name, $owner_guid = 0, $site_guid = 0) { if (!$id) { return false; } - + $params = array( 'collection_id' => $id ); - + if (!_elgg_services()->hooks->trigger('access:collections:addcollection', 'collection', $params, true)) { return false; } - + return $id; } - + /** * Updates the membership in an access collection. * @@ -523,31 +523,31 @@ function create($name, $owner_guid = 0, $site_guid = 0) { */ function update($collection_id, $members) { $acl = get_access_collection($collection_id); - + if (!$acl) { return false; } $members = (is_array($members)) ? $members : array(); - + $cur_members = get_members_of_access_collection($collection_id, true); $cur_members = (is_array($cur_members)) ? $cur_members : array(); - + $remove_members = array_diff($cur_members, $members); $add_members = array_diff($members, $cur_members); - + $result = true; - + foreach ($add_members as $guid) { $result = $result && add_user_to_access_collection($guid, $collection_id); } - + foreach ($remove_members as $guid) { $result = $result && remove_user_from_access_collection($guid, $collection_id); } - + return $result; } - + /** * Deletes a specified access collection and its membership. * @@ -556,27 +556,27 @@ function update($collection_id, $members) { * @return bool */ function delete($collection_id) { - - + + $collection_id = (int) $collection_id; $params = array('collection_id' => $collection_id); - + if (!_elgg_services()->hooks->trigger('access:collections:deletecollection', 'collection', $params, true)) { return false; } - + // Deleting membership doesn't affect result of deleting ACL. $q = "DELETE FROM {$this->CONFIG->dbprefix}access_collection_membership WHERE access_collection_id = {$collection_id}"; _elgg_services()->db->deleteData($q); - + $q = "DELETE FROM {$this->CONFIG->dbprefix}access_collections WHERE id = {$collection_id}"; $result = _elgg_services()->db->deleteData($q); - + return (bool)$result; } - + /** * Get a specified access collection * @@ -590,15 +590,15 @@ function delete($collection_id) { * @return object|false */ function get($collection_id) { - + $collection_id = (int) $collection_id; - + $query = "SELECT * FROM {$this->CONFIG->dbprefix}access_collections WHERE id = {$collection_id}"; $get_collection = _elgg_services()->db->getDataRow($query); - + return $get_collection; } - + /** * Adds a user to an access collection. * @@ -610,37 +610,37 @@ function get($collection_id) { * @return bool */ function addUser($user_guid, $collection_id) { - - + + $collection_id = (int) $collection_id; $user_guid = (int) $user_guid; $user = get_user($user_guid); - + $collection = get_access_collection($collection_id); - + if (!($user instanceof \ElggUser) || !$collection) { return false; } - + $params = array( 'collection_id' => $collection_id, 'user_guid' => $user_guid ); - + $result = _elgg_services()->hooks->trigger('access:collections:add_user', 'collection', $params, true); if ($result == false) { return false; } - + // if someone tries to insert the same data twice, we do a no-op on duplicate key $q = "INSERT INTO {$this->CONFIG->dbprefix}access_collection_membership SET access_collection_id = $collection_id, user_guid = $user_guid ON DUPLICATE KEY UPDATE user_guid = user_guid"; $result = _elgg_services()->db->insertData($q); - + return $result !== false; } - + /** * Removes a user from an access collection. * @@ -652,34 +652,34 @@ function addUser($user_guid, $collection_id) { * @return bool */ function removeUser($user_guid, $collection_id) { - - + + $collection_id = (int) $collection_id; $user_guid = (int) $user_guid; $user = get_user($user_guid); - + $collection = get_access_collection($collection_id); - + if (!($user instanceof \ElggUser) || !$collection) { return false; } - + $params = array( 'collection_id' => $collection_id, 'user_guid' => $user_guid ); - + if (!_elgg_services()->hooks->trigger('access:collections:remove_user', 'collection', $params, true)) { return false; } - + $q = "DELETE FROM {$this->CONFIG->dbprefix}access_collection_membership WHERE access_collection_id = {$collection_id} AND user_guid = {$user_guid}"; - + return (bool)_elgg_services()->db->deleteData($q); } - + /** * Returns an array of database row objects of the access collections owned by $owner_guid. * @@ -689,24 +689,24 @@ function removeUser($user_guid, $collection_id) { * @return array|false */ function getUserCollections($owner_guid, $site_guid = 0) { - + $owner_guid = (int) $owner_guid; $site_guid = (int) $site_guid; - + if (($site_guid == 0) && (isset($this->CONFIG->site_guid))) { $site_guid = $this->CONFIG->site_guid; } - + $query = "SELECT * FROM {$this->CONFIG->dbprefix}access_collections WHERE owner_guid = {$owner_guid} AND site_guid = {$site_guid} ORDER BY name ASC"; - + $collections = _elgg_services()->db->getData($query); - + return $collections; } - + /** * Get all of members of an access collection * @@ -716,9 +716,9 @@ function getUserCollections($owner_guid, $site_guid = 0) { * @return \ElggUser[]|int[]|false guids or entities if successful, false if not */ function getMembers($collection, $idonly = false) { - + $collection = (int)$collection; - + if (!$idonly) { $query = "SELECT e.* FROM {$this->CONFIG->dbprefix}access_collection_membership m" . " JOIN {$this->CONFIG->dbprefix}entities e ON e.guid = m.user_guid" @@ -736,7 +736,7 @@ function getMembers($collection, $idonly = false) { $collection_members[$key] = $val->guid; } } - + return $collection_members; - } + } } \ No newline at end of file diff --git a/engine/classes/Elgg/Database/AdminNotices.php b/engine/classes/Elgg/Database/AdminNotices.php index cd645b38513..9b6e44dac8a 100644 --- a/engine/classes/Elgg/Database/AdminNotices.php +++ b/engine/classes/Elgg/Database/AdminNotices.php @@ -3,9 +3,9 @@ /** * WARNING: API IN FLUX. DO NOT USE DIRECTLY. - * + * * Controls all admin notices in the system. - * + * * @access private * * @package Elgg.Core @@ -33,27 +33,27 @@ function add($id, $message) { if (elgg_admin_notice_exists($id)) { return false; } - + // need to handle when no one is logged in $old_ia = elgg_set_ignore_access(true); - + $admin_notice = new \ElggObject(); $admin_notice->subtype = 'admin_notice'; // admins can see ACCESS_PRIVATE but no one else can. $admin_notice->access_id = ACCESS_PRIVATE; $admin_notice->admin_notice_id = $id; $admin_notice->description = $message; - + $result = $admin_notice->save(); - + elgg_set_ignore_access($old_ia); - + return (bool)$result; } - + return false; } - + /** * Remove an admin notice by ID. * @@ -75,7 +75,7 @@ function delete($id) { 'metadata_name' => 'admin_notice_id', 'metadata_value' => $id )); - + if ($notices) { // in case a bad plugin adds many, let it remove them all at once. foreach ($notices as $notice) { @@ -85,7 +85,7 @@ function delete($id) { } return false; } - + /** * Get admin notices. An admin must be logged in since the notices are private. * @@ -100,7 +100,7 @@ function find($limit = 10) { 'limit' => $limit )); } - + /** * Check if an admin notice is currently active. * @@ -117,7 +117,7 @@ function exists($id) { 'metadata_name_value_pair' => array('name' => 'admin_notice_id', 'value' => $id) )); elgg_set_ignore_access($old_ia); - + return ($notice) ? true : false; } } \ No newline at end of file diff --git a/engine/classes/Elgg/Database/Annotations.php b/engine/classes/Elgg/Database/Annotations.php index 4945d03c910..c9324e90b9e 100644 --- a/engine/classes/Elgg/Database/Annotations.php +++ b/engine/classes/Elgg/Database/Annotations.php @@ -13,7 +13,7 @@ class Annotations { /** * Global Elgg configuration - * + * * @var \stdClass */ private $CONFIG; @@ -38,7 +38,7 @@ public function __construct() { function get($id) { return _elgg_get_metastring_based_object_from_id($id, 'annotation'); } - + /** * Deletes an annotation using its ID. * @@ -52,7 +52,7 @@ function delete($id) { } return $annotation->delete(); } - + /** * Create a new annotation. * @@ -66,41 +66,41 @@ function delete($id) { * @return int|bool id on success or false on failure */ function create($entity_guid, $name, $value, $value_type = '', $owner_guid = 0, $access_id = ACCESS_PRIVATE) { - - + + $result = false; - + $entity_guid = (int)$entity_guid; $name = trim($name); $value_type = detect_extender_valuetype($value, $value_type); - + $owner_guid = (int)$owner_guid; if ($owner_guid == 0) { $owner_guid = _elgg_services()->session->getLoggedInUserGuid(); } - + $access_id = (int)$access_id; $time = time(); - + $value_id = elgg_get_metastring_id($value); if (!$value_id) { return false; } - + $name_id = elgg_get_metastring_id($name); if (!$name_id) { return false; } - + // @todo we don't check that the entity is loaded which means the user may // not have access to the entity $entity = get_entity($entity_guid); - + if (_elgg_services()->events->trigger('annotate', $entity->type, $entity)) { $result = _elgg_services()->db->insertData("INSERT INTO {$this->CONFIG->dbprefix}annotations (entity_guid, name_id, value_id, value_type, owner_guid, time_created, access_id) VALUES ($entity_guid, $name_id, $value_id, '$value_type', $owner_guid, $time, $access_id)"); - + if ($result !== false) { $obj = elgg_get_annotation_from_id($result); if (_elgg_services()->events->trigger('create', 'annotation', $obj)) { @@ -112,10 +112,10 @@ function create($entity_guid, $name, $value, $value_type = '', $owner_guid = 0, } } } - + return $result; } - + /** * Update an annotation. * @@ -129,10 +129,10 @@ function create($entity_guid, $name, $value, $value_type = '', $owner_guid = 0, * @return bool */ function update($annotation_id, $name, $value, $value_type, $owner_guid, $access_id) { - - + + $annotation_id = (int)$annotation_id; - + $annotation = elgg_get_annotation_from_id($annotation_id); if (!$annotation) { return false; @@ -140,41 +140,41 @@ function update($annotation_id, $name, $value, $value_type, $owner_guid, $access if (!$annotation->canEdit()) { return false; } - + $name = trim($name); $value_type = detect_extender_valuetype($value, $value_type); - + $owner_guid = (int)$owner_guid; if ($owner_guid == 0) { $owner_guid = _elgg_services()->session->getLoggedInUserGuid(); } - + $access_id = (int)$access_id; - + $value_id = elgg_get_metastring_id($value); if (!$value_id) { return false; } - + $name_id = elgg_get_metastring_id($name); if (!$name_id) { return false; } - + $result = _elgg_services()->db->updateData("UPDATE {$this->CONFIG->dbprefix}annotations SET name_id = $name_id, value_id = $value_id, value_type = '$value_type', access_id = $access_id, owner_guid = $owner_guid WHERE id = $annotation_id"); - + if ($result !== false) { // @todo add plugin hook that sends old and new annotation information before db access $obj = elgg_get_annotation_from_id($annotation_id); _elgg_services()->events->trigger('update', 'annotation', $obj); } - + return $result; } - + /** * Returns annotations. Accepts all elgg_get_entities() options for entity * restraints. @@ -204,7 +204,7 @@ function update($annotation_id, $name, $value, $value_type, $owner_guid, $access * @return \ElggAnnotation[]|mixed */ function find(array $options = array()) { - + // @todo remove support for count shortcut - see #4393 if (isset($options['__egefac']) && $options['__egefac']) { unset($options['__egefac']); @@ -215,11 +215,11 @@ function find(array $options = array()) { unset($options['count']); } } - + $options['metastring_type'] = 'annotations'; return _elgg_get_metastring_based_objects($options); } - + /** * Deletes annotations based on $options. * @@ -234,11 +234,11 @@ function deleteAll(array $options) { if (!_elgg_is_valid_options_for_batch_operation($options, 'annotation')) { return false; } - + $options['metastring_type'] = 'annotations'; return _elgg_batch_metastring_based_objects($options, 'elgg_batch_delete_callback', false); } - + /** * Disables annotations based on $options. * @@ -251,15 +251,15 @@ function disableAll(array $options) { if (!_elgg_is_valid_options_for_batch_operation($options, 'annotation')) { return false; } - + // if we can see hidden (disabled) we need to use the offset // otherwise we risk an infinite loop if there are more than 50 $inc_offset = access_get_show_hidden_status(); - + $options['metastring_type'] = 'annotations'; return _elgg_batch_metastring_based_objects($options, 'elgg_batch_disable_callback', $inc_offset); } - + /** * Enables annotations based on $options. * @@ -275,11 +275,11 @@ function enableAll(array $options) { if (!$options || !is_array($options)) { return false; } - + $options['metastring_type'] = 'annotations'; return _elgg_batch_metastring_based_objects($options, 'elgg_batch_enable_callback'); } - + /** * Returns entities based upon annotations. Also accepts all options available * to elgg_get_entities() and elgg_get_entities_from_metadata(). @@ -320,47 +320,47 @@ function getEntities(array $options = array()) { 'annotation_names' => ELGG_ENTITIES_ANY_VALUE, 'annotation_values' => ELGG_ENTITIES_ANY_VALUE, 'annotation_name_value_pairs' => ELGG_ENTITIES_ANY_VALUE, - + 'annotation_name_value_pairs_operator' => 'AND', 'annotation_case_sensitive' => true, 'order_by_annotation' => array(), - + 'annotation_created_time_lower' => ELGG_ENTITIES_ANY_VALUE, 'annotation_created_time_upper' => ELGG_ENTITIES_ANY_VALUE, - + 'annotation_owner_guids' => ELGG_ENTITIES_ANY_VALUE, - + 'order_by' => 'maxtime DESC', 'group_by' => 'a.entity_guid' ); - + $options = array_merge($defaults, $options); - + $singulars = array('annotation_name', 'annotation_value', 'annotation_name_value_pair', 'annotation_owner_guid'); - + $options = _elgg_normalize_plural_options_array($options, $singulars); $options = _elgg_entities_get_metastrings_options('annotation', $options); - + if (!$options) { return false; } - + // special sorting for annotations //@todo overrides other sorting $options['selects'][] = "MAX(n_table.time_created) AS maxtime"; $options['group_by'] = 'n_table.entity_guid'; - + $time_wheres = _elgg_get_entity_time_where_sql('a', $options['annotation_created_time_upper'], $options['annotation_created_time_lower']); - + if ($time_wheres) { $options['wheres'] = array_merge($options['wheres'], $time_wheres); } - + return elgg_get_entities_from_metadata($options); } - + /** * Get entities ordered by a mathematical calculation on annotation values * @@ -388,31 +388,31 @@ function getEntitiesFromCalculation($options) { 'calculation' => 'sum', 'order_by' => 'annotation_calculation desc' ); - + $options = array_merge($defaults, $options); - + $function = sanitize_string(elgg_extract('calculation', $options, 'sum', false)); - + // you must cast this as an int or it sorts wrong. $options['selects'][] = 'e.*'; $options['selects'][] = "$function(CAST(a_msv.string AS signed)) AS annotation_calculation"; - + // need our own join to get the values because the lower level functions don't // add all the joins if it's a different callback. $options['joins'][] = "JOIN {$db_prefix}metastrings a_msv ON n_table.value_id = a_msv.id"; - + // don't need access control because it's taken care of by elgg_get_annotations. $options['group_by'] = 'n_table.entity_guid'; - + $options['callback'] = 'entity_row_to_elggstar'; - + // see #4393 // @todo remove after the 'count' shortcut is removed from elgg_get_annotations() $options['__egefac'] = true; - + return elgg_get_annotations($options); } - + /** * Check to see if a user has already created an annotation on an object * @@ -423,25 +423,25 @@ function getEntitiesFromCalculation($options) { * @return bool */ function exists($entity_guid, $annotation_type, $owner_guid = null) { - - + + if (!$owner_guid && !($owner_guid = _elgg_services()->session->getLoggedInUserGuid())) { return false; } - + $entity_guid = sanitize_int($entity_guid); $owner_guid = sanitize_int($owner_guid); $annotation_type = sanitize_string($annotation_type); - + $sql = "SELECT a.id FROM {$this->CONFIG->dbprefix}annotations a" . " JOIN {$this->CONFIG->dbprefix}metastrings m ON a.name_id = m.id" . " WHERE a.owner_guid = $owner_guid AND a.entity_guid = $entity_guid" . " AND m.string = '$annotation_type'"; - + if (_elgg_services()->db->getDataRow($sql)) { return true; } - + return false; } } \ No newline at end of file diff --git a/engine/classes/Elgg/Database/ConfigTable.php b/engine/classes/Elgg/Database/ConfigTable.php index c66117de732..8993207fa77 100644 --- a/engine/classes/Elgg/Database/ConfigTable.php +++ b/engine/classes/Elgg/Database/ConfigTable.php @@ -2,9 +2,9 @@ namespace Elgg\Database; /** - * These settings are stored in the dbprefix_config table and read + * These settings are stored in the dbprefix_config table and read * during system boot into $CONFIG. - * + * * WARNING: API IN FLUX. DO NOT USE DIRECTLY. * * @access private @@ -14,10 +14,10 @@ * @since 1.10.0 */ class ConfigTable { - + /** * Global Elgg configuration - * + * * @var \stdClass */ private $CONFIG; @@ -39,38 +39,38 @@ public function __construct() { * @return bool Success or failure */ function remove($name, $site_guid = 0) { - - + + $name = trim($name); - + $site_guid = (int) $site_guid; if ($site_guid == 0) { $site_guid = (int) $this->CONFIG->site_guid; } - + if ($site_guid == $this->CONFIG->site_guid && isset($this->CONFIG->$name)) { unset($this->CONFIG->$name); } - + $escaped_name = sanitize_string($name); $query = "DELETE FROM {$this->CONFIG->dbprefix}config WHERE name = '$escaped_name' AND site_guid = $site_guid"; - + return _elgg_services()->db->deleteData($query) !== false; } - + /** * Add or update a config setting. - * + * * Plugin authors should use elgg_set_config(). * * If the config name already exists, it will be updated to the new value. * * @warning Names should be selected so as not to collide with the names for the * datalist (application configuration) - * - * @internal These settings are stored in the dbprefix_config table and read + * + * @internal These settings are stored in the dbprefix_config table and read * during system boot into $CONFIG. - * + * * @internal The value is serialized so we maintain type information. * * @param string $name The name of the configuration value @@ -80,40 +80,40 @@ function remove($name, $site_guid = 0) { * @return bool */ function set($name, $value, $site_guid = 0) { - - + + $name = trim($name); - + // cannot store anything longer than 255 characters in db, so catch before we set if (elgg_strlen($name) > 255) { _elgg_services()->logger->error("The name length for configuration variables cannot be greater than 255"); return false; } - + $site_guid = (int) $site_guid; if ($site_guid == 0) { $site_guid = (int) $this->CONFIG->site_guid; } - + if ($site_guid == $this->CONFIG->site_guid) { $this->CONFIG->$name = $value; } - + $escaped_name = sanitize_string($name); $escaped_value = sanitize_string(serialize($value)); $result = _elgg_services()->db->insertData("INSERT INTO {$this->CONFIG->dbprefix}config SET name = '$escaped_name', value = '$escaped_value', site_guid = $site_guid ON DUPLICATE KEY UPDATE value = '$escaped_value'"); - + return $result !== false; } - + /** * Gets a configuration value - * + * * Plugin authors should use elgg_get_config(). * - * @internal These settings are stored in the dbprefix_config table and read + * @internal These settings are stored in the dbprefix_config table and read * during system boot into $CONFIG. * * @param string $name The name of the config value @@ -122,12 +122,12 @@ function set($name, $value, $site_guid = 0) { * @return mixed|null */ function get($name, $site_guid = 0) { - - + + $name = trim($name); - + $site_guid = (int) $site_guid; - + // check for deprecated values. // @todo might be a better spot to define this? $new_name = false; @@ -135,16 +135,16 @@ function get($name, $site_guid = 0) { case 'viewpath': $new_name = 'view_path'; break; - + case 'pluginspath': $new_name = 'plugins_path'; break; - + case 'sitename': $new_name = 'site_name'; break; } - + // @todo these haven't really been implemented in Elgg 1.8. Complete in 1.9. // show dep message if ($new_name) { @@ -152,33 +152,33 @@ function get($name, $site_guid = 0) { $name = $new_name; // elgg_deprecated_notice($msg, $dep_version); } - + if ($site_guid == 0) { $site_guid = (int) $this->CONFIG->site_guid; } - + // decide from where to return the value if ($site_guid == $this->CONFIG->site_guid && isset($this->CONFIG->$name)) { return $this->CONFIG->$name; } - + $escaped_name = sanitize_string($name); $result = _elgg_services()->db->getDataRow("SELECT value FROM {$this->CONFIG->dbprefix}config WHERE name = '$escaped_name' AND site_guid = $site_guid"); - + if ($result) { $result = unserialize($result->value); - + if ($site_guid == $this->CONFIG->site_guid) { $this->CONFIG->$name = $result; } - + return $result; } - + return null; } - + /** * Loads all configuration values from the dbprefix_config table into $CONFIG. * @@ -187,21 +187,21 @@ function get($name, $site_guid = 0) { * @return bool */ function loadAll($site_guid = 0) { - - + + $site_guid = (int) $site_guid; - + if ($site_guid == 0) { $site_guid = (int) $this->CONFIG->site_guid; } - + if ($result = _elgg_services()->db->getData("SELECT * FROM {$this->CONFIG->dbprefix}config WHERE site_guid = $site_guid")) { foreach ($result as $r) { $name = $r->name; $value = $r->value; $this->CONFIG->$name = unserialize($value); } - + return true; } return false; diff --git a/engine/classes/Elgg/Database/Datalist.php b/engine/classes/Elgg/Database/Datalist.php index 2d9ce44ee97..84da520d165 100644 --- a/engine/classes/Elgg/Database/Datalist.php +++ b/engine/classes/Elgg/Database/Datalist.php @@ -7,7 +7,7 @@ /** * Persistent, installation-wide key-value storage. - * + * * WARNING: API IN FLUX. DO NOT USE DIRECTLY. * * @access private @@ -17,7 +17,7 @@ * @since 1.10.0 */ class Datalist { - + /** @var Pool */ private $cache; @@ -32,7 +32,7 @@ class Datalist { /** * Constructor - * + * * @param Pool $cache Some kind of caching implementation * @param Database $db The database * @param Logger $logger A logger @@ -44,10 +44,10 @@ public function __construct(Pool $cache, Database $db, Logger $logger, $table) { $this->logger = $logger; $this->table = $table; } - + /** * Get the value of a datalist element. - * + * * Plugin authors should use elgg_get_config() and pass null for the site GUID. * * @internal Datalists are stored in the datalist table. @@ -60,7 +60,7 @@ public function __construct(Pool $cache, Database $db, Logger $logger, $table) { */ function get($name) { $name = trim($name); - + // cannot store anything longer than 255 characters in db, so catch here if (elgg_strlen($name) > 255) { $this->logger->error("The name length for configuration variables cannot be greater than 255"); @@ -73,15 +73,15 @@ function get($name) { return $result ? $result->value : null; }); } - + /** * Set the value for a datalist element. - * + * * Plugin authors should use elgg_save_config() and pass null for the site GUID. - * + * * @warning Names should be selected so as not to collide with the names for the * site config. - * + * * @warning Values set here are not available in $CONFIG until next page load. * * @param string $name The name of the datalist @@ -92,14 +92,14 @@ function get($name) { */ function set($name, $value) { $name = trim($name); - + // cannot store anything longer than 255 characters in db, so catch before we set if (elgg_strlen($name) > 255) { $this->logger->error("The name length for configuration variables cannot be greater than 255"); return false; } - - + + $escaped_name = $this->db->sanitizeString($name); $escaped_value = $this->db->sanitizeString($value); $success = $this->db->insertData("INSERT INTO {$this->table}" @@ -107,17 +107,17 @@ function set($name, $value) { . " ON DUPLICATE KEY UPDATE value = '$escaped_value'"); $this->cache->put($name, $value); - + return $success !== false; } - + /** * Load entire datalist in memory. - * + * * This could cause OOM problems if the datalists table is large. - * + * * @todo make a list of datalists that we want to get in one grab - * + * * @return array * @access private */ @@ -133,7 +133,7 @@ function loadAll() { return $map; } - + /** * Run a function one time per installation. * diff --git a/engine/classes/Elgg/Database/EntityTable.php b/engine/classes/Elgg/Database/EntityTable.php index a90fb2b0344..08e79666ac4 100644 --- a/engine/classes/Elgg/Database/EntityTable.php +++ b/engine/classes/Elgg/Database/EntityTable.php @@ -15,7 +15,7 @@ class EntityTable { /** * Global Elgg configuration - * + * * @var \stdClass */ private $CONFIG; @@ -43,18 +43,18 @@ public function __construct() { * @access private */ function getRow($guid) { - - + + if (!$guid) { return false; } - + $guid = (int) $guid; $access = _elgg_get_access_where_sql(array('table_alias' => '')); - + return _elgg_services()->db->getDataRow("SELECT * from {$this->CONFIG->dbprefix}entities where guid=$guid and $access"); } - + /** * Create an Elgg* object from a given entity row. * @@ -74,13 +74,13 @@ function rowToElggStar($row) { if (!($row instanceof \stdClass)) { return $row; } - + if ((!isset($row->guid)) || (!isset($row->subtype))) { return $row; } - + $new_entity = false; - + // Create a memcache cache if we can static $newentity_cache; if ((!$newentity_cache) && (is_memcache_available())) { @@ -92,13 +92,13 @@ function rowToElggStar($row) { if ($new_entity) { return $new_entity; } - + // load class for entity if one is registered $classname = get_subtype_class_from_id($row->subtype); if ($classname != "") { if (class_exists($classname)) { $new_entity = new $classname($row); - + if (!($new_entity instanceof \ElggEntity)) { $msg = $classname . " is not a " . '\ElggEntity' . "."; throw new \ClassException($msg); @@ -107,7 +107,7 @@ function rowToElggStar($row) { error_log("Class '" . $classname . "' was not found, missing plugin?"); } } - + if (!$new_entity) { //@todo Make this into a function switch ($row->type) { @@ -128,15 +128,15 @@ function rowToElggStar($row) { throw new \InstallationException($msg); } } - + // Cache entity if we have a cache available if (($newentity_cache) && ($new_entity)) { $newentity_cache->save($new_entity->guid, $new_entity); } - + return $new_entity; } - + /** * Loads and returns an entity object from a guid. * @@ -149,20 +149,20 @@ function get($guid) { // different instance outside this function. // @todo We need a single Memcache instance with a shared pool of namespace wrappers. This function would pull an instance from the pool. static $shared_cache; - + // We could also use: if (!(int) $guid) { return false }, // but that evaluates to a false positive for $guid = true. // This is a bit slower, but more thorough. if (!is_numeric($guid) || $guid === 0 || $guid === '0') { return false; } - + // Check local cache first $new_entity = _elgg_retrieve_cached_entity($guid); if ($new_entity) { return $new_entity; } - + // Check shared memory cache, if available if (null === $shared_cache) { if (is_memcache_available()) { @@ -171,13 +171,13 @@ function get($guid) { $shared_cache = false; } } - + // until ACLs in memcache, DB query is required to determine access $entity_row = get_entity_as_row($guid); if (!$entity_row) { return false; } - + if ($shared_cache) { $cached_entity = $shared_cache->load($guid); // @todo store ACLs in memcache https://github.com/elgg/elgg/issues/3018#issuecomment-13662617 @@ -186,20 +186,20 @@ function get($guid) { return $cached_entity; } } - + // don't let incomplete entities cause fatal exceptions try { $new_entity = entity_row_to_elggstar($entity_row); } catch (IncompleteEntityException $e) { return false; } - + if ($new_entity) { _elgg_cache_entity($new_entity); } return $new_entity; } - + /** * Does an entity exist? * @@ -213,10 +213,10 @@ function get($guid) { * @return bool */ function exists($guid) { - - + + $guid = sanitize_int($guid); - + $query = "SELECT count(*) as total FROM {$this->CONFIG->dbprefix}entities WHERE guid = $guid"; $result = _elgg_services()->db->getDataRow($query); if ($result->total == 0) { @@ -225,7 +225,7 @@ function exists($guid) { return true; } } - + /** * Enable an entity. * @@ -235,21 +235,21 @@ function exists($guid) { * @return bool */ function enable($guid, $recursive = true) { - + // Override access only visible entities $old_access_status = access_get_show_hidden_status(); access_show_hidden_entities(true); - + $result = false; $entity = get_entity($guid); if ($entity) { $result = $entity->enable($recursive); } - + access_show_hidden_entities($old_access_status); return $result; } - + /** * Returns an array of entities with optional filtering. * @@ -319,23 +319,23 @@ function enable($guid, $recursive = true) { * @see elgg_list_entities() */ function getEntities(array $options = array()) { - - + + $defaults = array( 'types' => ELGG_ENTITIES_ANY_VALUE, 'subtypes' => ELGG_ENTITIES_ANY_VALUE, 'type_subtype_pairs' => ELGG_ENTITIES_ANY_VALUE, - + 'guids' => ELGG_ENTITIES_ANY_VALUE, 'owner_guids' => ELGG_ENTITIES_ANY_VALUE, 'container_guids' => ELGG_ENTITIES_ANY_VALUE, 'site_guids' => $this->CONFIG->site_guid, - + 'modified_time_lower' => ELGG_ENTITIES_ANY_VALUE, 'modified_time_upper' => ELGG_ENTITIES_ANY_VALUE, 'created_time_lower' => ELGG_ENTITIES_ANY_VALUE, 'created_time_upper' => ELGG_ENTITIES_ANY_VALUE, - + 'reverse_order_by' => false, 'order_by' => 'e.time_created desc', 'group_by' => ELGG_ENTITIES_ANY_VALUE, @@ -345,16 +345,16 @@ function getEntities(array $options = array()) { 'selects' => array(), 'wheres' => array(), 'joins' => array(), - + 'preload_owners' => false, 'callback' => 'entity_row_to_elggstar', - + // private API '__ElggBatch' => null, ); - + $options = array_merge($defaults, $options); - + // can't use helper function with type_subtype_pair because // it's already an array...just need to merge it if (isset($options['type_subtype_pair'])) { @@ -365,28 +365,28 @@ function getEntities(array $options = array()) { $options['type_subtype_pairs'] = $options['type_subtype_pair']; } } - + $singulars = array('type', 'subtype', 'guid', 'owner_guid', 'container_guid', 'site_guid'); $options = _elgg_normalize_plural_options_array($options, $singulars); - + // evaluate where clauses if (!is_array($options['wheres'])) { $options['wheres'] = array($options['wheres']); } - + $wheres = $options['wheres']; - + $wheres[] = _elgg_get_entity_type_subtype_where_sql('e', $options['types'], $options['subtypes'], $options['type_subtype_pairs']); - + $wheres[] = _elgg_get_guid_based_where_sql('e.guid', $options['guids']); $wheres[] = _elgg_get_guid_based_where_sql('e.owner_guid', $options['owner_guids']); $wheres[] = _elgg_get_guid_based_where_sql('e.container_guid', $options['container_guids']); $wheres[] = _elgg_get_guid_based_where_sql('e.site_guid', $options['site_guids']); - + $wheres[] = _elgg_get_entity_time_where_sql('e', $options['created_time_upper'], $options['created_time_lower'], $options['modified_time_upper'], $options['modified_time_lower']); - + // see if any functions failed // remove empty strings on successful functions foreach ($wheres as $i => $where) { @@ -396,18 +396,18 @@ function getEntities(array $options = array()) { unset($wheres[$i]); } } - + // remove identical where clauses $wheres = array_unique($wheres); - + // evaluate join clauses if (!is_array($options['joins'])) { $options['joins'] = array($options['joins']); } - + // remove identical join clauses $joins = array_unique($options['joins']); - + foreach ($joins as $i => $join) { if ($join === false) { return false; @@ -415,7 +415,7 @@ function getEntities(array $options = array()) { unset($joins[$i]); } } - + // evalutate selects if ($options['selects']) { $selects = ''; @@ -425,54 +425,54 @@ function getEntities(array $options = array()) { } else { $selects = ''; } - + if (!$options['count']) { $query = "SELECT DISTINCT e.*{$selects} FROM {$this->CONFIG->dbprefix}entities e "; } else { $query = "SELECT count(DISTINCT e.guid) as total FROM {$this->CONFIG->dbprefix}entities e "; } - + // add joins foreach ($joins as $j) { $query .= " $j "; } - + // add wheres $query .= ' WHERE '; - + foreach ($wheres as $w) { $query .= " $w AND "; } - + // Add access controls $query .= _elgg_get_access_where_sql(); - + // reverse order by if ($options['reverse_order_by']) { $options['order_by'] = _elgg_sql_reverse_order_by_clause($options['order_by']); } - + if (!$options['count']) { if ($options['group_by']) { $query .= " GROUP BY {$options['group_by']}"; } - + if ($options['order_by']) { $query .= " ORDER BY {$options['order_by']}"; } - + if ($options['limit']) { $limit = sanitise_int($options['limit'], false); $offset = sanitise_int($options['offset'], false); $query .= " LIMIT $offset, $limit"; } - + if ($options['callback'] === 'entity_row_to_elggstar') { $dt = _elgg_fetch_entities_from_sql($query, $options['__ElggBatch']); } else { $dt = _elgg_services()->db->getData($query, $options['callback']); } - + if ($dt) { // populate entity and metadata caches, and prepare $entities for preloader $guids = array(); @@ -488,11 +488,11 @@ function getEntities(array $options = array()) { } // @todo Without this, recursive delete fails. See #4568 reset($dt); - + if ($guids) { _elgg_get_metadata_cache()->populateFromEntities($guids); } - + if ($options['preload_owners'] && count($dt) > 1) { _elgg_services()->ownerPreloader->preload($dt); } @@ -503,7 +503,7 @@ function getEntities(array $options = array()) { return (int)$total->total; } } - + /** * Return entities from an SQL query generated by elgg_get_entities. * @@ -519,7 +519,7 @@ function fetchFromSql($sql, \ElggBatch $batch = null) { if (null === $plugin_subtype) { $plugin_subtype = get_subtype_id('object', 'plugin'); } - + // Keys are types, values are columns that, if present, suggest that the secondary // table is already JOINed $types_to_optimize = array( @@ -527,14 +527,14 @@ function fetchFromSql($sql, \ElggBatch $batch = null) { 'user' => 'password', 'group' => 'name', ); - + $rows = _elgg_services()->db->getData($sql); - + // guids to look up in each type $lookup_types = array(); // maps GUIDs to the $rows key $guid_to_key = array(); - + if (isset($rows[0]->type, $rows[0]->subtype) && $rows[0]->type === 'object' && $rows[0]->subtype == $plugin_subtype) { @@ -543,7 +543,7 @@ function fetchFromSql($sql, \ElggBatch $batch = null) { // but abandon the extra queries. $types_to_optimize = array(); } - + // First pass: use cache where possible, gather GUIDs that we're optimizing foreach ($rows as $i => $row) { if (empty($row->guid) || empty($row->type)) { @@ -569,7 +569,7 @@ function fetchFromSql($sql, \ElggBatch $batch = null) { // Do secondary queries and merge rows if ($lookup_types) { $dbprefix = _elgg_services()->config->get('dbprefix'); - + foreach ($lookup_types as $type => $guids) { $set = "(" . implode(',', $guids) . ")"; $sql = "SELECT * FROM {$dbprefix}{$type}s_entity WHERE guid IN $set"; @@ -593,7 +593,7 @@ function fetchFromSql($sql, \ElggBatch $batch = null) { } catch (IncompleteEntityException $e) { // don't let incomplete entities throw fatal errors unset($rows[$i]); - + // report incompletes to the batch process that spawned this query if ($batch) { $batch->reportIncompleteEntity($row); @@ -603,7 +603,7 @@ function fetchFromSql($sql, \ElggBatch $batch = null) { } return $rows; } - + /** * Returns SQL where clause for type and subtype on main entity table * @@ -621,26 +621,26 @@ function getEntityTypeSubtypeWhereSql($table, $types, $subtypes, $pairs) { _elgg_services()->logger->warn("Cannot set subtypes without type."); return false; } - + // short circuit if nothing is requested if (!$types && !$subtypes && !$pairs) { return ''; } - + // these are the only valid types for entities in elgg $valid_types = _elgg_services()->config->get('entity_types'); - + // pairs override $wheres = array(); if (!is_array($pairs)) { if (!is_array($types)) { $types = array($types); } - + if ($subtypes && !is_array($subtypes)) { $subtypes = array($subtypes); } - + // decrementer for valid types. Return false if no valid types $valid_types_count = count($types); $valid_subtypes_count = 0; @@ -660,12 +660,12 @@ function getEntityTypeSubtypeWhereSql($table, $types, $subtypes, $pairs) { $valid_subtypes_count += count($subtypes); } } - + // return false if nothing is valid. if (!$valid_types_count) { return false; } - + // subtypes are based upon types, so we need to look at each // type individually to get the right subtype id. foreach ($types as $type) { @@ -682,7 +682,7 @@ function getEntityTypeSubtypeWhereSql($table, $types, $subtypes, $pairs) { continue; } else { $subtype_id = get_subtype_id($type, $subtype); - + if ($subtype_id) { $subtype_ids[] = $subtype_id; } else { @@ -692,13 +692,13 @@ function getEntityTypeSubtypeWhereSql($table, $types, $subtypes, $pairs) { } } } - + // return false if we're all invalid subtypes in the only valid type if ($valid_subtypes_count <= 0) { return false; } } - + if (is_array($subtype_ids) && count($subtype_ids)) { $subtype_ids_str = implode(',', $subtype_ids); $wheres[] = "({$table}.type = '$type' AND {$table}.subtype IN ($subtype_ids_str))"; @@ -710,7 +710,7 @@ function getEntityTypeSubtypeWhereSql($table, $types, $subtypes, $pairs) { // using type/subtype pairs $valid_pairs_count = count($pairs); $valid_pairs_subtypes_count = 0; - + // same deal as above--we need to know how many valid types // and subtypes we have before hitting the subtype section. // also normalize the subtypes into arrays here. @@ -725,7 +725,7 @@ function getEntityTypeSubtypeWhereSql($table, $types, $subtypes, $pairs) { $valid_pairs_subtypes_count += count($paired_subtypes); } } - + if ($valid_pairs_count <= 0) { return false; } @@ -737,7 +737,7 @@ function getEntityTypeSubtypeWhereSql($table, $types, $subtypes, $pairs) { foreach ($paired_subtypes as $paired_subtype) { if (ELGG_ENTITIES_NO_VALUE === $paired_subtype || ($paired_subtype_id = get_subtype_id($paired_type, $paired_subtype))) { - + $paired_subtype_ids[] = (ELGG_ENTITIES_NO_VALUE === $paired_subtype) ? ELGG_ENTITIES_NO_VALUE : $paired_subtype_id; } else { @@ -747,13 +747,13 @@ function getEntityTypeSubtypeWhereSql($table, $types, $subtypes, $pairs) { continue; } } - + // return false if there are no valid subtypes. if ($valid_pairs_subtypes_count <= 0) { return false; } - - + + if ($paired_subtype_ids_str = implode(',', $paired_subtype_ids)) { $wheres[] = "({$table}.type = '$paired_type'" . " AND {$table}.subtype IN ($paired_subtype_ids_str))"; @@ -763,16 +763,16 @@ function getEntityTypeSubtypeWhereSql($table, $types, $subtypes, $pairs) { } } } - + // pairs override the above. return false if they don't exist. if (is_array($wheres) && count($wheres)) { $where = implode(' OR ', $wheres); return "($where)"; } - + return ''; } - + /** * Returns SQL where clause for owner and containers. * @@ -789,35 +789,35 @@ function getGuidBasedWhereSql($column, $guids) { if (!$guids && $guids !== 0) { return ''; } - + // normalize and sanitise owners if (!is_array($guids)) { $guids = array($guids); } - + $guids_sanitized = array(); foreach ($guids as $guid) { if ($guid !== ELGG_ENTITIES_NO_VALUE) { $guid = sanitise_int($guid); - + if (!$guid) { return false; } } $guids_sanitized[] = $guid; } - + $where = ''; $guid_str = implode(',', $guids_sanitized); - + // implode(',', 0) returns 0. if ($guid_str !== false && $guid_str !== '') { $where = "($column IN ($guid_str))"; } - + return $where; } - + /** * Returns SQL where clause for entity time limits. * @@ -833,34 +833,34 @@ function getGuidBasedWhereSql($column, $guids) { */ function getEntityTimeWhereSql($table, $time_created_upper = null, $time_created_lower = null, $time_updated_upper = null, $time_updated_lower = null) { - + $wheres = array(); - + // exploit PHP's loose typing (quack) to check that they are INTs and not str cast to 0 if ($time_created_upper && $time_created_upper == sanitise_int($time_created_upper)) { $wheres[] = "{$table}.time_created <= $time_created_upper"; } - + if ($time_created_lower && $time_created_lower == sanitise_int($time_created_lower)) { $wheres[] = "{$table}.time_created >= $time_created_lower"; } - + if ($time_updated_upper && $time_updated_upper == sanitise_int($time_updated_upper)) { $wheres[] = "{$table}.time_updated <= $time_updated_upper"; } - + if ($time_updated_lower && $time_updated_lower == sanitise_int($time_updated_lower)) { $wheres[] = "{$table}.time_updated >= $time_updated_lower"; } - + if (is_array($wheres) && count($wheres) > 0) { $where_str = implode(' AND ', $wheres); return "($where_str)"; } - + return ''; } - + /** * Gets entities based upon attributes in secondary tables. * Also accepts all options available to elgg_get_entities(), @@ -897,14 +897,14 @@ function getEntitiesFromAttributes(array $options = array()) { 'attribute_name_value_pairs' => ELGG_ENTITIES_ANY_VALUE, 'attribute_name_value_pairs_operator' => 'AND', ); - + $options = array_merge($defaults, $options); - + $singulars = array('type', 'attribute_name_value_pair'); $options = _elgg_normalize_plural_options_array($options, $singulars); - + $clauses = _elgg_get_entity_attribute_where_sql($options); - + if ($clauses) { // merge wheres to pass to elgg_get_entities() if (isset($options['wheres']) && !is_array($options['wheres'])) { @@ -912,22 +912,22 @@ function getEntitiesFromAttributes(array $options = array()) { } elseif (!isset($options['wheres'])) { $options['wheres'] = array(); } - + $options['wheres'] = array_merge($options['wheres'], $clauses['wheres']); - + // merge joins to pass to elgg_get_entities() if (isset($options['joins']) && !is_array($options['joins'])) { $options['joins'] = array($options['joins']); } elseif (!isset($options['joins'])) { $options['joins'] = array(); } - + $options['joins'] = array_merge($options['joins'], $clauses['joins']); } - + return elgg_get_entities_from_relationship($options); } - + /** * Get the join and where clauses for working with entity attributes * @@ -936,64 +936,64 @@ function getEntitiesFromAttributes(array $options = array()) { * @throws InvalidArgumentException */ function getEntityAttributeWhereSql(array $options = array()) { - + if (!isset($options['types'])) { throw new \InvalidArgumentException("The entity type must be defined for elgg_get_entities_from_attributes()"); } - + if (is_array($options['types']) && count($options['types']) !== 1) { throw new \InvalidArgumentException("Only one type can be passed to elgg_get_entities_from_attributes()"); } - + // type can be passed as string or array $type = $options['types']; if (is_array($type)) { $type = $type[0]; } - + // @todo the types should be defined somewhere (as constant on \ElggEntity?) if (!in_array($type, array('group', 'object', 'site', 'user'))) { throw new \InvalidArgumentException("Invalid type '$type' passed to elgg_get_entities_from_attributes()"); } - - + + $type_table = "{$this->CONFIG->dbprefix}{$type}s_entity"; - + $return = array( 'joins' => array(), 'wheres' => array(), ); - + // short circuit if nothing requested if ($options['attribute_name_value_pairs'] == ELGG_ENTITIES_ANY_VALUE) { return $return; } - + if (!is_array($options['attribute_name_value_pairs'])) { throw new \InvalidArgumentException("attribute_name_value_pairs must be an array for elgg_get_entities_from_attributes()"); } - + $wheres = array(); - + // check if this is an array of pairs or just a single pair. $pairs = $options['attribute_name_value_pairs']; if (isset($pairs['name']) || isset($pairs['value'])) { $pairs = array($pairs); } - + $pair_wheres = array(); foreach ($pairs as $index => $pair) { // must have at least a name and value if (!isset($pair['name']) || !isset($pair['value'])) { continue; } - + if (isset($pair['operand'])) { $operand = sanitize_string($pair['operand']); } else { $operand = '='; } - + if (is_numeric($pair['value'])) { $value = sanitize_string($pair['value']); } else if (is_array($pair['value'])) { @@ -1005,36 +1005,36 @@ function getEntityAttributeWhereSql(array $options = array()) { $values_array[] = "'" . sanitize_string($pair_value) . "'"; } } - + $operand = 'IN'; if ($values_array) { $value = '(' . implode(', ', $values_array) . ')'; } - + } else { $value = "'" . sanitize_string($pair['value']) . "'"; } - + $name = sanitize_string($pair['name']); - + // case sensitivity can be specified per pair $pair_binary = ''; if (isset($pair['case_sensitive'])) { $pair_binary = ($pair['case_sensitive']) ? 'BINARY ' : ''; } - + $pair_wheres[] = "({$pair_binary}type_table.$name $operand $value)"; } - + if ($where = implode(" {$options['attribute_name_value_pairs_operator']} ", $pair_wheres)) { $return['wheres'][] = "($where)"; - + $return['joins'][] = "JOIN $type_table type_table ON e.guid = type_table.guid"; } - + return $return; } - + /** * Returns a list of months in which entities were updated or created. * @@ -1054,20 +1054,20 @@ function getEntityAttributeWhereSql(array $options = array()) { */ function getDates($type = '', $subtype = '', $container_guid = 0, $site_guid = 0, $order_by = 'time_created') { - - - + + + $site_guid = (int) $site_guid; if ($site_guid == 0) { $site_guid = $this->CONFIG->site_guid; } $where = array(); - + if ($type != "") { $type = sanitise_string($type); $where[] = "type='$type'"; } - + if (is_array($subtype)) { $tempwhere = ""; if (sizeof($subtype)) { @@ -1100,7 +1100,7 @@ function getDates($type = '', $subtype = '', $container_guid = 0, $site_guid = 0 } } } - + if ($container_guid !== 0) { if (is_array($container_guid)) { foreach ($container_guid as $key => $val) { @@ -1112,20 +1112,20 @@ function getDates($type = '', $subtype = '', $container_guid = 0, $site_guid = 0 $where[] = "container_guid = {$container_guid}"; } } - + if ($site_guid > 0) { $where[] = "site_guid = {$site_guid}"; } - + $where[] = _elgg_get_access_where_sql(array('table_alias' => '')); - + $sql = "SELECT DISTINCT EXTRACT(YEAR_MONTH FROM FROM_UNIXTIME(time_created)) AS yearmonth FROM {$this->CONFIG->dbprefix}entities where "; - + foreach ($where as $w) { $sql .= " $w and "; } - + $sql .= "1=1 ORDER BY $order_by"; if ($result = _elgg_services()->db->getData($sql)) { $endresult = array(); @@ -1136,7 +1136,7 @@ function getDates($type = '', $subtype = '', $container_guid = 0, $site_guid = 0 } return false; } - + /** * Update the last_action column in the entities table for $guid. * @@ -1150,14 +1150,14 @@ function getDates($type = '', $subtype = '', $container_guid = 0, $site_guid = 0 * @access private */ function updateLastAction($guid, $posted = null) { - + $guid = (int)$guid; $posted = (int)$posted; - + if (!$posted) { $posted = time(); } - + if ($guid) { //now add to the river updated table $query = "UPDATE {$this->CONFIG->dbprefix}entities SET last_action = {$posted} WHERE guid = {$guid}"; diff --git a/engine/classes/Elgg/Database/MetadataTable.php b/engine/classes/Elgg/Database/MetadataTable.php index b8374dc1435..5767b23c4e7 100644 --- a/engine/classes/Elgg/Database/MetadataTable.php +++ b/engine/classes/Elgg/Database/MetadataTable.php @@ -14,7 +14,7 @@ class MetadataTable { /** * Global Elgg configuration - * + * * @var \stdClass */ private $CONFIG; @@ -39,7 +39,7 @@ public function __construct() { function get($id) { return _elgg_get_metastring_based_object_from_id($id, 'metadata'); } - + /** * Deletes metadata using its ID. * @@ -53,7 +53,7 @@ function delete($id) { } return $metadata->delete(); } - + /** * Create a new metadata object, or update an existing one. * @@ -72,9 +72,9 @@ function delete($id) { */ function create($entity_guid, $name, $value, $value_type = '', $owner_guid = 0, $access_id = ACCESS_PRIVATE, $allow_multiple = false) { - - - + + + $entity_guid = (int)$entity_guid; // name and value are encoded in add_metastring() //$name = sanitise_string(trim($name)); @@ -83,25 +83,25 @@ function create($entity_guid, $name, $value, $value_type = '', $owner_guid = 0, $time = time(); $owner_guid = (int)$owner_guid; $allow_multiple = (boolean)$allow_multiple; - + if (!isset($value)) { return false; } - + if ($owner_guid == 0) { $owner_guid = _elgg_services()->session->getLoggedInUserGuid(); } - + $access_id = (int)$access_id; - + $query = "SELECT * from {$this->CONFIG->dbprefix}metadata" . " WHERE entity_guid = $entity_guid and name_id=" . elgg_get_metastring_id($name) . " limit 1"; - + $existing = _elgg_services()->db->getDataRow($query); if ($existing && !$allow_multiple) { $id = (int)$existing->id; $result = update_metadata($id, $name, $value, $value_type, $owner_guid, $access_id); - + if (!$result) { return false; } @@ -110,41 +110,41 @@ function create($entity_guid, $name, $value, $value_type = '', $owner_guid = 0, if (is_bool($value)) { $value = (int) $value; } - + // Add the metastrings $value_id = elgg_get_metastring_id($value); if (!$value_id) { return false; } - + $name_id = elgg_get_metastring_id($name); if (!$name_id) { return false; } - + // If ok then add it $query = "INSERT into {$this->CONFIG->dbprefix}metadata" . " (entity_guid, name_id, value_id, value_type, owner_guid, time_created, access_id)" . " VALUES ($entity_guid, '$name_id','$value_id','$value_type', $owner_guid, $time, $access_id)"; - + $id = _elgg_services()->db->insertData($query); - + if ($id !== false) { $obj = elgg_get_metadata_from_id($id); if (_elgg_services()->events->trigger('create', 'metadata', $obj)) { - + _elgg_get_metadata_cache()->save($entity_guid, $name, $value, $allow_multiple); - + return $id; } else { elgg_delete_metadata_by_id($id); } } } - + return $id; } - + /** * Update a specific piece of metadata. * @@ -158,72 +158,72 @@ function create($entity_guid, $name, $value, $value_type = '', $owner_guid = 0, * @return bool */ function update($id, $name, $value, $value_type, $owner_guid, $access_id) { - - + + $id = (int)$id; - + if (!$md = elgg_get_metadata_from_id($id)) { return false; } if (!$md->canEdit()) { return false; } - + // If memcached then we invalidate the cache for this entry static $metabyname_memcache; if ((!$metabyname_memcache) && (is_memcache_available())) { $metabyname_memcache = new \ElggMemcache('metabyname_memcache'); } - + if ($metabyname_memcache) { // @todo fix memcache (name_id is not a property of \ElggMetadata) $metabyname_memcache->delete("{$md->entity_guid}:{$md->name_id}"); } - + $value_type = detect_extender_valuetype($value, sanitise_string(trim($value_type))); - + $owner_guid = (int)$owner_guid; if ($owner_guid == 0) { $owner_guid = _elgg_services()->session->getLoggedInUserGuid(); } - + $access_id = (int)$access_id; - + // Support boolean types (as integers) if (is_bool($value)) { $value = (int) $value; } - + $value_id = elgg_get_metastring_id($value); if (!$value_id) { return false; } - + $name_id = elgg_get_metastring_id($name); if (!$name_id) { return false; } - + // If ok then add it $query = "UPDATE {$this->CONFIG->dbprefix}metadata" . " set name_id='$name_id', value_id='$value_id', value_type='$value_type', access_id=$access_id," . " owner_guid=$owner_guid where id=$id"; - + $result = _elgg_services()->db->updateData($query); if ($result !== false) { - + _elgg_get_metadata_cache()->save($md->entity_guid, $name, $value); - + // @todo this event tells you the metadata has been updated, but does not // let you do anything about it. What is needed is a plugin hook before // the update that passes old and new values. $obj = elgg_get_metadata_from_id($id); _elgg_services()->events->trigger('update', 'metadata', $obj); } - + return $result; } - + /** * This function creates metadata from an associative array of "key => value" pairs. * @@ -242,7 +242,7 @@ function update($id, $name, $value, $value_type, $owner_guid, $access_id) { */ function createFromArray($entity_guid, array $name_and_values, $value_type, $owner_guid, $access_id = ACCESS_PRIVATE, $allow_multiple = false) { - + foreach ($name_and_values as $k => $v) { $result = create_metadata($entity_guid, $k, $v, $value_type, $owner_guid, $access_id, $allow_multiple); @@ -252,7 +252,7 @@ function createFromArray($entity_guid, array $name_and_values, $value_type, $own } return true; } - + /** * Returns metadata. Accepts all elgg_get_entities() options for entity * restraints. @@ -283,18 +283,18 @@ function createFromArray($entity_guid, array $name_and_values, $value_type, $own * @return \ElggMetadata[]|mixed */ function getAll(array $options = array()) { - + // @todo remove support for count shortcut - see #4393 // support shortcut of 'count' => true for 'metadata_calculation' => 'count' if (isset($options['count']) && $options['count']) { $options['metadata_calculation'] = 'count'; unset($options['count']); } - + $options['metastring_type'] = 'metadata'; return _elgg_get_metastring_based_objects($options); } - + /** * Deletes metadata based on $options. * @@ -311,14 +311,14 @@ function deleteAll(array $options) { } $options['metastring_type'] = 'metadata'; $result = _elgg_batch_metastring_based_objects($options, 'elgg_batch_delete_callback', false); - + // This moved last in case an object's constructor sets metadata. Currently the batch // delete process has to create the entity to delete its metadata. See #5214 _elgg_get_metadata_cache()->invalidateByOptions('delete', $options); - + return $result; } - + /** * Disables metadata based on $options. * @@ -331,17 +331,17 @@ function disableAll(array $options) { if (!_elgg_is_valid_options_for_batch_operation($options, 'metadata')) { return false; } - + _elgg_get_metadata_cache()->invalidateByOptions('disable', $options); - + // if we can see hidden (disabled) we need to use the offset // otherwise we risk an infinite loop if there are more than 50 $inc_offset = access_get_show_hidden_status(); - + $options['metastring_type'] = 'metadata'; return _elgg_batch_metastring_based_objects($options, 'elgg_batch_disable_callback', $inc_offset); } - + /** * Enables metadata based on $options. * @@ -357,13 +357,13 @@ function enableAll(array $options) { if (!$options || !is_array($options)) { return false; } - + _elgg_get_metadata_cache()->invalidateByOptions('enable', $options); - + $options['metastring_type'] = 'metadata'; return _elgg_batch_metastring_based_objects($options, 'elgg_batch_enable_callback'); } - + /** * Returns entities based upon metadata. Also accepts all * options available to elgg_get_entities(). Supports @@ -404,7 +404,7 @@ function enableAll(array $options) { * Currently if multiple values are sent via * an array (value => array('value1', 'value2') * the pair's operand will be forced to "IN". - * If passing "IN" as the operand and a string as the value, + * If passing "IN" as the operand and a string as the value, * the value must be a properly quoted and escaped string. * * metadata_name_value_pairs_operator => null|STR The operator to use for combining @@ -428,28 +428,28 @@ function getEntities(array $options = array()) { 'metadata_names' => ELGG_ENTITIES_ANY_VALUE, 'metadata_values' => ELGG_ENTITIES_ANY_VALUE, 'metadata_name_value_pairs' => ELGG_ENTITIES_ANY_VALUE, - + 'metadata_name_value_pairs_operator' => 'AND', 'metadata_case_sensitive' => true, 'order_by_metadata' => array(), - + 'metadata_owner_guids' => ELGG_ENTITIES_ANY_VALUE, ); - + $options = array_merge($defaults, $options); - + $singulars = array('metadata_name', 'metadata_value', 'metadata_name_value_pair', 'metadata_owner_guid'); - + $options = _elgg_normalize_plural_options_array($options, $singulars); - + if (!$options = _elgg_entities_get_metastrings_options('metadata', $options)) { return false; } - + return elgg_get_entities($options); } - + /** * Returns metadata name and value SQL where for entities. * NB: $names and $values are not paired. Use $pairs for this. @@ -475,9 +475,9 @@ function getEntities(array $options = array()) { function getEntityMetadataWhereSql($e_table, $n_table, $names = null, $values = null, $pairs = null, $pair_operator = 'AND', $case_sensitive = true, $order_by_metadata = null, $owner_guids = null) { - - - + + + // short circuit if nothing requested // 0 is a valid (if not ill-conceived) metadata name. // 0 is also a valid metadata value for false, null, or 0 @@ -489,36 +489,36 @@ function getEntityMetadataWhereSql($e_table, $n_table, $names = null, $values = && !$order_by_metadata) { return ''; } - + // join counter for incremental joins. $i = 1; - + // binary forces byte-to-byte comparision of strings, making // it case- and diacritical-mark- sensitive. // only supported on values. $binary = ($case_sensitive) ? ' BINARY ' : ''; - + $access = _elgg_get_access_where_sql(array('table_alias' => 'n_table')); - + $return = array ( 'joins' => array (), 'wheres' => array(), 'orders' => array() ); - + // will always want to join these tables if pulling metastrings. $return['joins'][] = "JOIN {$this->CONFIG->dbprefix}{$n_table} n_table on {$e_table}.guid = n_table.entity_guid"; - + $wheres = array(); - + // get names wheres and joins $names_where = ''; if ($names !== null) { if (!is_array($names)) { $names = array($names); } - + $sanitised_names = array(); foreach ($names as $name) { // normalise to 0. @@ -527,20 +527,20 @@ function getEntityMetadataWhereSql($e_table, $n_table, $names = null, $values = } $sanitised_names[] = '\'' . sanitise_string($name) . '\''; } - + if ($names_str = implode(',', $sanitised_names)) { $return['joins'][] = "JOIN {$this->CONFIG->dbprefix}metastrings msn on n_table.name_id = msn.id"; $names_where = "(msn.string IN ($names_str))"; } } - + // get values wheres and joins $values_where = ''; if ($values !== null) { if (!is_array($values)) { $values = array($values); } - + $sanitised_values = array(); foreach ($values as $value) { // normalize to 0 @@ -549,13 +549,13 @@ function getEntityMetadataWhereSql($e_table, $n_table, $names = null, $values = } $sanitised_values[] = '\'' . sanitise_string($value) . '\''; } - + if ($values_str = implode(',', $sanitised_values)) { $return['joins'][] = "JOIN {$this->CONFIG->dbprefix}metastrings msv on n_table.value_id = msv.id"; $values_where = "({$binary}msv.string IN ($values_str))"; } } - + if ($names_where && $values_where) { $wheres[] = "($names_where AND $values_where AND $access)"; } elseif ($names_where) { @@ -563,7 +563,7 @@ function getEntityMetadataWhereSql($e_table, $n_table, $names = null, $values = } elseif ($values_where) { $wheres[] = "($values_where AND $access)"; } - + // add pairs // pairs must be in arrays. if (is_array($pairs)) { @@ -571,12 +571,12 @@ function getEntityMetadataWhereSql($e_table, $n_table, $names = null, $values = if (isset($pairs['name']) || isset($pairs['value'])) { $pairs = array($pairs); } - + $pair_wheres = array(); - + // @todo when the pairs are > 3 should probably split the query up to // denormalize the strings table. - + foreach ($pairs as $index => $pair) { // @todo move this elsewhere? // support shortcut 'n' => 'v' method. @@ -586,13 +586,13 @@ function getEntityMetadataWhereSql($e_table, $n_table, $names = null, $values = 'value' => $pair ); } - + // must have at least a name and value if (!isset($pair['name']) || !isset($pair['value'])) { // @todo should probably return false. continue; } - + // case sensitivity can be specified per pair. // default to higher level setting. if (isset($pair['case_sensitive'])) { @@ -600,16 +600,16 @@ function getEntityMetadataWhereSql($e_table, $n_table, $names = null, $values = } else { $pair_binary = $binary; } - + if (isset($pair['operand'])) { $operand = sanitise_string($pair['operand']); } else { $operand = ' = '; } - + // for comparing $trimmed_operand = trim(strtolower($operand)); - + $access = _elgg_get_access_where_sql(array('table_alias' => "n_table{$i}")); // certain operands can't work well with strings that can be interpreted as numbers @@ -618,14 +618,14 @@ function getEntityMetadataWhereSql($e_table, $n_table, $names = null, $values = // see https://github.com/Elgg/Elgg/issues/7009 $num_safe_operands = array('>', '<', '>=', '<='); $num_test_operand = trim(strtoupper($operand)); - + if (is_numeric($pair['value']) && in_array($num_test_operand, $num_safe_operands)) { $value = sanitize_string($pair['value']); } else if (is_bool($pair['value'])) { $value = (int) $pair['value']; } else if (is_array($pair['value'])) { $values_array = array(); - + foreach ($pair['value'] as $pair_value) { if (is_numeric($pair_value) && !in_array($num_test_operand, $num_safe_operands)) { $values_array[] = sanitise_string($pair_value); @@ -633,11 +633,11 @@ function getEntityMetadataWhereSql($e_table, $n_table, $names = null, $values = $values_array[] = "'" . sanitise_string($pair_value) . "'"; } } - + if ($values_array) { $value = '(' . implode(', ', $values_array) . ')'; } - + // @todo allow support for non IN operands with array of values. // will have to do more silly joins. $operand = 'IN'; @@ -646,9 +646,9 @@ function getEntityMetadataWhereSql($e_table, $n_table, $names = null, $values = } else { $value = "'" . sanitise_string($pair['value']) . "'"; } - + $name = sanitise_string($pair['name']); - + // @todo The multiple joins are only needed when the operator is AND $return['joins'][] = "JOIN {$this->CONFIG->dbprefix}{$n_table} n_table{$i} on {$e_table}.guid = n_table{$i}.entity_guid"; @@ -656,18 +656,18 @@ function getEntityMetadataWhereSql($e_table, $n_table, $names = null, $values = on n_table{$i}.name_id = msn{$i}.id"; $return['joins'][] = "JOIN {$this->CONFIG->dbprefix}metastrings msv{$i} on n_table{$i}.value_id = msv{$i}.id"; - + $pair_wheres[] = "(msn{$i}.string = '$name' AND {$pair_binary}msv{$i}.string $operand $value AND $access)"; - + $i++; } - + if ($where = implode(" $pair_operator ", $pair_wheres)) { $wheres[] = "($where)"; } } - + // add owner_guids if ($owner_guids) { if (is_array($owner_guids)) { @@ -676,14 +676,14 @@ function getEntityMetadataWhereSql($e_table, $n_table, $names = null, $values = } else { $owner_str = sanitise_int($owner_guids); } - + $wheres[] = "(n_table.owner_guid IN ($owner_str))"; } - + if ($where = implode(' AND ', $wheres)) { $return['wheres'][] = "($where)"; } - + if (is_array($order_by_metadata)) { if ((count($order_by_metadata) > 0) && !isset($order_by_metadata[0])) { // singleton, so fix @@ -703,9 +703,9 @@ function getEntityMetadataWhereSql($e_table, $n_table, $names = null, $values = on n_table{$i}.name_id = msn{$i}.id"; $return['joins'][] = "JOIN {$this->CONFIG->dbprefix}metastrings msv{$i} on n_table{$i}.value_id = msv{$i}.id"; - + $access = _elgg_get_access_where_sql(array('table_alias' => "n_table{$i}")); - + $return['wheres'][] = "(msn{$i}.string = '$name' AND $access)"; if (isset($order_by['as']) && $order_by['as'] == 'integer') { $return['orders'][] = "CAST(msv{$i}.string AS SIGNED) $direction"; @@ -716,10 +716,10 @@ function getEntityMetadataWhereSql($e_table, $n_table, $names = null, $values = } } } - + return $return; } - + /** * Get the URL for this metadata * @@ -731,13 +731,13 @@ function getEntityMetadataWhereSql($e_table, $n_table, $names = null, $values = */ function getUrl($id) { $id = (int)$id; - + if ($extender = elgg_get_metadata_from_id($id)) { return $extender->getURL(); } return false; } - + /** * Mark entities with a particular type and subtype as having access permissions * that can be changed independently from their parent entity @@ -748,13 +748,13 @@ function getUrl($id) { * @return void */ function registerMetadataAsIndependent($type, $subtype = '*') { - + if (!isset($this->CONFIG->independents)) { $this->CONFIG->independents = array(); } $this->CONFIG->independents[$type][$subtype] = true; } - + /** * Determines whether entities of a given type and subtype should not change * their metadata in line with their parent entity @@ -765,7 +765,7 @@ function registerMetadataAsIndependent($type, $subtype = '*') { * @return bool */ function isMetadataIndependent($type, $subtype) { - + if (empty($this->CONFIG->independents)) { return false; } @@ -775,7 +775,7 @@ function isMetadataIndependent($type, $subtype) { } return false; } - + /** * When an entity is updated, resets the access ID on all of its child metadata * @@ -798,5 +798,5 @@ function handleUpdate($event, $object_type, $object) { } return true; } - + } \ No newline at end of file diff --git a/engine/classes/Elgg/Database/MetastringsTable.php b/engine/classes/Elgg/Database/MetastringsTable.php index a6927cf93d3..a3e04527fb8 100644 --- a/engine/classes/Elgg/Database/MetastringsTable.php +++ b/engine/classes/Elgg/Database/MetastringsTable.php @@ -12,7 +12,7 @@ /** * Normalization for strings used in metadata and annoations tables. - * + * * WARNING: API IN FLUX. DO NOT USE DIRECTLY. * * @access private @@ -20,7 +20,7 @@ * @package Elgg.Core * @subpackage Database * @since 1.10.0 - * + * * @access private */ class MetastringsTable { @@ -40,15 +40,15 @@ class MetastringsTable { */ function getId($string, $case_sensitive = true) { global $CONFIG, $METASTRINGS_CACHE; - + // caching doesn't work for case insensitive requests if ($case_sensitive) { $result = array_search($string, $METASTRINGS_CACHE, true); - + if ($result !== false) { return $result; } - + // Experimental memcache $msfc = null; static $metastrings_memcache; @@ -62,14 +62,14 @@ function getId($string, $case_sensitive = true) { return $msfc; } } - + $escaped_string = sanitise_string($string); if ($case_sensitive) { $query = "SELECT * FROM {$CONFIG->dbprefix}metastrings WHERE string = BINARY '$escaped_string' LIMIT 1"; } else { $query = "SELECT * FROM {$CONFIG->dbprefix}metastrings WHERE string = '$escaped_string'"; } - + $id = false; $results = get_data($query); if (is_array($results)) { @@ -84,20 +84,20 @@ function getId($string, $case_sensitive = true) { $id = $results[0]->id; } } - + if (!$id) { $id = _elgg_add_metastring($string); } - + $METASTRINGS_CACHE[$id] = $string; - + if ($metastrings_memcache) { $metastrings_memcache->save($string, $id); } - + return $id; - } - + } + /** * Add a metastring. * @@ -108,9 +108,9 @@ function getId($string, $case_sensitive = true) { */ function add($string) { global $CONFIG; - + $escaped_string = sanitise_string($string); - + return insert_data("INSERT INTO {$CONFIG->dbprefix}metastrings (string) VALUES ('$escaped_string')"); } } \ No newline at end of file diff --git a/engine/classes/Elgg/Database/Plugins.php b/engine/classes/Elgg/Database/Plugins.php index dd6ea5dc2ea..58a05341f1c 100644 --- a/engine/classes/Elgg/Database/Plugins.php +++ b/engine/classes/Elgg/Database/Plugins.php @@ -12,7 +12,7 @@ /** * Persistent, installation-wide key-value storage. - * + * * WARNING: API IN FLUX. DO NOT USE DIRECTLY. * * @access private @@ -35,10 +35,10 @@ function getDirsInDir($dir = null) { if (!$dir) { $dir = elgg_get_plugins_path(); } - + $plugin_dirs = array(); $handle = opendir($dir); - + if ($handle) { while ($plugin_dir = readdir($handle)) { // must be directory and not begin with a . @@ -47,12 +47,12 @@ function getDirsInDir($dir = null) { } } } - + sort($plugin_dirs); - + return $plugin_dirs; } - + /** * Discovers plugins in the plugins_path setting and creates \ElggPlugin * entities for them if they don't exist. If there are plugins with entities @@ -63,17 +63,17 @@ function getDirsInDir($dir = null) { * @access private */ function generateEntities() { - + $mod_dir = elgg_get_plugins_path(); $db_prefix = elgg_get_config('dbprefix'); - + // ignore access in case this is called with no admin logged in - needed for creating plugins perhaps? $old_ia = elgg_set_ignore_access(true); - + // show hidden entities so that we can enable them if appropriate $old_access = access_get_show_hidden_status(); access_show_hidden_entities(true); - + $options = array( 'type' => 'object', 'subtype' => 'plugin', @@ -83,11 +83,11 @@ function generateEntities() { ); $known_plugins = elgg_get_entities_from_relationship($options); /* @var \ElggPlugin[] $known_plugins */ - + if (!$known_plugins) { $known_plugins = array(); } - + // map paths to indexes $id_map = array(); foreach ($known_plugins as $i => $plugin) { @@ -100,13 +100,13 @@ function generateEntities() { } $id_map[$plugin->getID()] = $i; } - + $physical_plugins = _elgg_get_plugin_dirs_in_dir($mod_dir); - + if (!$physical_plugins) { return false; } - + // check real plugins against known ones foreach ($physical_plugins as $plugin_id) { // is this already in the db? @@ -119,7 +119,7 @@ function generateEntities() { $plugin->deactivate(); $plugin->setPriority('last'); } - + // remove from the list of plugins to disable unset($known_plugins[$index]); } else { @@ -129,7 +129,7 @@ function generateEntities() { $plugin->save(); } } - + // everything remaining in $known_plugins needs to be disabled // because they are entities, but their dirs were removed. // don't delete the entities because they hold settings. @@ -144,20 +144,20 @@ function generateEntities() { $plugin->disable(); } } - + access_show_hidden_entities($old_access); elgg_set_ignore_access($old_ia); - + _elgg_reindex_plugin_priorities(); - + return true; } - + /** * Cache a reference to this plugin by its ID - * + * * @param \ElggPlugin $plugin - * + * * @access private */ function cache(\ElggPlugin $plugin) { @@ -165,7 +165,7 @@ function cache(\ElggPlugin $plugin) { $map[$plugin->getID()] = $plugin; elgg_set_config('plugins_by_id_map', $map); } - + /** * Returns an \ElggPlugin object with the path $path. * @@ -177,10 +177,10 @@ function get($plugin_id) { if (isset($map[$plugin_id])) { return $map[$plugin_id]; } - + $plugin_id = sanitize_string($plugin_id); $db_prefix = get_config('dbprefix'); - + $options = array( 'type' => 'object', 'subtype' => 'plugin', @@ -189,16 +189,16 @@ function get($plugin_id) { 'wheres' => array("oe.title = '$plugin_id'"), 'limit' => 1, ); - + $plugins = elgg_get_entities($options); - + if ($plugins) { return $plugins[0]; } - + return null; } - + /** * Returns if a plugin exists in the system. * @@ -211,10 +211,10 @@ function get($plugin_id) { */ function exists($id) { $plugin = elgg_get_plugin_from_id($id); - + return ($plugin) ? true : false; } - + /** * Returns the highest priority of the plugins * @@ -225,24 +225,24 @@ function getMaxPriority() { $db_prefix = get_config('dbprefix'); $priority = _elgg_namespace_plugin_private_setting('internal', 'priority'); $plugin_subtype = get_subtype_id('object', 'plugin'); - + $q = "SELECT MAX(CAST(ps.value AS unsigned)) as max FROM {$db_prefix}entities e, {$db_prefix}private_settings ps WHERE ps.name = '$priority' AND ps.entity_guid = e.guid AND e.type = 'object' and e.subtype = $plugin_subtype"; - + $data = get_data($q); if ($data) { $max = $data[0]->max; } else { $max = 1; } - + // can't have a priority of 0. return ($max) ? $max : 1; } - + /** * Returns if a plugin is active for a current site. * @@ -256,20 +256,20 @@ function isActive($plugin_id, $site_guid = null) { } else { $site = elgg_get_site_entity(); } - + if (!($site instanceof \ElggSite)) { return false; } - + $plugin = elgg_get_plugin_from_id($plugin_id); - + if (!$plugin) { return false; } - + return $plugin->isActive($site->guid); } - + /** * Loads all active plugins in the order specified in the tool admin panel. * @@ -286,11 +286,11 @@ function load() { ELGG_PLUGIN_REGISTER_VIEWS | ELGG_PLUGIN_REGISTER_LANGUAGES | ELGG_PLUGIN_REGISTER_CLASSES; - + if (!$plugins_path) { return false; } - + // temporary disable all plugins if there is a file called 'disabled' in the plugin dir if (file_exists("$plugins_path/disabled")) { if (elgg_is_admin_logged_in() && elgg_in_context('admin')) { @@ -298,15 +298,15 @@ function load() { } return false; } - + if (elgg_get_config('system_cache_loaded')) { $start_flags = $start_flags & ~ELGG_PLUGIN_REGISTER_VIEWS; } - + if (elgg_get_config('i18n_loaded_from_cache')) { $start_flags = $start_flags & ~ELGG_PLUGIN_REGISTER_LANGUAGES; } - + $return = true; $plugins = elgg_get_plugins('active'); if ($plugins) { @@ -319,15 +319,15 @@ function load() { array($plugin->getID(), $plugin->guid, $e->getMessage())); elgg_add_admin_notice('cannot_start' . $plugin->getID(), $msg); $return = false; - + continue; } } } - + return $return; } - + /** * Returns an ordered list of plugins * @@ -338,12 +338,12 @@ function load() { function find($status = 'active', $site_guid = null) { $db_prefix = get_config('dbprefix'); $priority = _elgg_namespace_plugin_private_setting('internal', 'priority'); - + if (!$site_guid) { $site = get_config('site'); $site_guid = $site->guid; } - + // grab plugins $options = array( 'type' => 'object', @@ -357,14 +357,14 @@ function find($status = 'active', $site_guid = null) { 'wheres' => array("ps.name = '$priority'"), 'order_by' => "CAST(ps.value as unsigned), e.guid" ); - + switch ($status) { case 'active': $options['relationship'] = 'active_plugin'; $options['relationship_guid'] = $site_guid; $options['inverse_relationship'] = true; break; - + case 'inactive': $options['wheres'][] = "NOT EXISTS ( SELECT 1 FROM {$db_prefix}entity_relationships active_er @@ -372,19 +372,19 @@ function find($status = 'active', $site_guid = null) { AND active_er.relationship = 'active_plugin' AND active_er.guid_two = $site_guid)"; break; - + case 'all': default: break; } - + $old_ia = elgg_set_ignore_access(true); $plugins = elgg_get_entities_from_relationship($options); elgg_set_ignore_access($old_ia); - + return $plugins; } - + /** * Reorder plugins to an order specified by the array. * Plugins not included in this array will be appended to the end. @@ -399,37 +399,37 @@ function find($status = 'active', $site_guid = null) { */ function setPriorities(array $order) { $name = _elgg_namespace_plugin_private_setting('internal', 'priority'); - + $plugins = elgg_get_plugins('any'); if (!$plugins) { return false; } - + $return = true; - + // reindex to get standard counting. no need to increment by 10. // though we do start with 1 $order = array_values($order); - + $missing_plugins = array(); /* @var \ElggPlugin[] $missing_plugins */ - + foreach ($plugins as $plugin) { $plugin_id = $plugin->getID(); - + if (!in_array($plugin_id, $order)) { $missing_plugins[] = $plugin; continue; } - + $priority = array_search($plugin_id, $order) + 1; - + if (!$plugin->setPrivateSetting($name, $priority)) { $return = false; break; } } - + // set the missing plugins' priorities if ($return && $missing_plugins) { if (!isset($priority)) { @@ -443,10 +443,10 @@ function setPriorities(array $order) { } } } - + return $return; } - + /** * Reindexes all plugin priorities starting at 1. * @@ -457,7 +457,7 @@ function setPriorities(array $order) { function reindexPriorities() { return _elgg_set_plugin_priorities(array()); } - + /** * Namespaces a string to be used as a private setting name for a plugin. * @@ -478,7 +478,7 @@ function namespacePrivateSetting($type, $name, $id = null) { //case 'setting': // $name = ELGG_PLUGIN_SETTING_PREFIX . $name; // break; - + case 'user_setting': if (!$id) { elgg_deprecated_notice("You must pass the plugin id to _elgg_namespace_plugin_private_setting() for user settings", 1.9); @@ -486,16 +486,16 @@ function namespacePrivateSetting($type, $name, $id = null) { } $name = ELGG_PLUGIN_USER_SETTING_PREFIX . "$id:$name"; break; - + case 'internal': $name = ELGG_PLUGIN_INTERNAL_PREFIX . $name; break; } - + return $name; } - - + + /** * Returns an array of all provides from all active plugins. * @@ -518,9 +518,9 @@ function getProvides($type = null, $name = null) { global $ELGG_PLUGINS_PROVIDES_CACHE; if (!isset($ELGG_PLUGINS_PROVIDES_CACHE)) { $active_plugins = elgg_get_plugins('active'); - + $provides = array(); - + foreach ($active_plugins as $plugin) { $plugin_provides = array(); $manifest = $plugin->getManifest(); @@ -536,10 +536,10 @@ function getProvides($type = null, $name = null) { } } } - + $ELGG_PLUGINS_PROVIDES_CACHE = $provides; } - + if ($type && $name) { if (isset($ELGG_PLUGINS_PROVIDES_CACHE[$type][$name])) { return $ELGG_PLUGINS_PROVIDES_CACHE[$type][$name]; @@ -553,13 +553,13 @@ function getProvides($type = null, $name = null) { return false; } } - + return $ELGG_PLUGINS_PROVIDES_CACHE; } - + /** * Deletes all cached data on plugins being provided. - * + * * @return boolean * @access private */ @@ -568,7 +568,7 @@ function invalidateProvidesCache() { $ELGG_PLUGINS_PROVIDES_CACHE = null; return true; } - + /** * Checks if a plugin is currently providing $type and $name, and optionally * checking a version. @@ -592,19 +592,19 @@ function checkProvides($type, $name, $version = null, $comparison = 'ge') { 'value' => '' ); } - + if ($version) { $status = version_compare($provided['version'], $version, $comparison); } else { $status = true; } - + return array( 'status' => $status, 'value' => $provided['version'] ); } - + /** * Returns an array of parsed strings for a dependency in the * format: array( @@ -624,11 +624,11 @@ function getDependencyStrings($dep) { $dep_system = elgg_extract('type', $dep); $info = elgg_extract('dep', $dep); $type = elgg_extract('type', $info); - + if (!$dep_system || !$info || !$type) { return false; } - + // rewrite some of these to be more readable $comparison = elgg_extract('comparison', $info); switch($comparison) { @@ -648,7 +648,7 @@ function getDependencyStrings($dep) { //keep $comparison value intact break; } - + /* 'requires' 'plugin oauth_lib' <1.3 1.3 'downgrade' 'requires' 'php setting bob' >3 3 'change it' @@ -659,7 +659,7 @@ function getDependencyStrings($dep) { */ $strings = array(); $strings['type'] = $translator->translate('ElggPlugin:Dependencies:' . ucwords($dep_system)); - + switch ($type) { case 'elgg_version': case 'elgg_release': @@ -669,7 +669,7 @@ function getDependencyStrings($dep) { $strings['local_value'] = $dep['value']; $strings['comment'] = ''; break; - + case 'php_version': // 'PHP version' $strings['name'] = $translator->translate('ElggPlugin:Dependencies:PhpVersion'); @@ -677,7 +677,7 @@ function getDependencyStrings($dep) { $strings['local_value'] = $dep['value']; $strings['comment'] = ''; break; - + case 'php_extension': // PHP Extension %s [version] $strings['name'] = $translator->translate('ElggPlugin:Dependencies:PhpExtension', array($info['name'])); @@ -690,14 +690,14 @@ function getDependencyStrings($dep) { } $strings['comment'] = ''; break; - + case 'php_ini': $strings['name'] = $translator->translate('ElggPlugin:Dependencies:PhpIni', array($info['name'])); $strings['expected_value'] = "$comparison {$info['value']}"; $strings['local_value'] = $dep['value']; $strings['comment'] = ''; break; - + case 'plugin': $strings['name'] = $translator->translate('ElggPlugin:Dependencies:Plugin', array($info['name'])); $expected = $info['version'] ? "$comparison {$info['version']}" : $translator->translate('any'); @@ -705,7 +705,7 @@ function getDependencyStrings($dep) { $strings['local_value'] = $dep['value'] ? $dep['value'] : '--'; $strings['comment'] = ''; break; - + case 'priority': $expected_priority = ucwords($info['priority']); $real_priority = ucwords($dep['value']); @@ -715,7 +715,7 @@ function getDependencyStrings($dep) { $strings['comment'] = ''; break; } - + if ($dep['type'] == 'suggests') { if ($dep['status']) { $strings['comment'] = $translator->translate('ok'); @@ -729,10 +729,10 @@ function getDependencyStrings($dep) { $strings['comment'] = $translator->translate('error'); } } - + return $strings; } - + /** * Returns an array of all plugin user settings for a user. * @@ -750,26 +750,26 @@ function getAllUserSettings($user_guid = 0, $plugin_id = null, $return_obj = fal elgg_deprecated_notice('elgg_get_all_plugin_user_settings() requires plugin_id to be set', 1.9); $plugin = elgg_get_calling_plugin_entity(); } - + if (!$plugin instanceof \ElggPlugin) { return false; } - + $settings = $plugin->getAllUserSettings((int)$user_guid); - + if ($settings && $return_obj) { $return = new \stdClass; - + foreach ($settings as $k => $v) { $return->$k = $v; } - + return $return; } else { return $settings; } } - + /** * Set a user specific setting for a plugin. * @@ -788,14 +788,14 @@ function setUserSettings($name, $value, $user_guid = 0, $plugin_id = null) { elgg_deprecated_notice('elgg_set_plugin_user_setting() requires plugin_id to be set', 1.9); $plugin = elgg_get_calling_plugin_entity(); } - + if (!$plugin) { return false; } - + return $plugin->setUserSetting($name, $value, (int)$user_guid); } - + /** * Unsets a user-specific plugin setting * @@ -813,14 +813,14 @@ function unsetUserSetting($name, $user_guid = 0, $plugin_id = null) { elgg_deprecated_notice('elgg_unset_plugin_user_setting() requires plugin_id to be set', 1.9); $plugin = elgg_get_calling_plugin_entity(); } - + if (!$plugin) { return false; } - + return $plugin->unsetUserSetting($name, (int)$user_guid); } - + /** * Get a user specific setting for a plugin. * @@ -839,14 +839,14 @@ function getUserSetting($name, $user_guid = 0, $plugin_id = null, $default = nul elgg_deprecated_notice('elgg_get_plugin_user_setting() requires plugin_id to be set', 1.9); $plugin = elgg_get_calling_plugin_entity(); } - + if (!$plugin) { return false; } - + return $plugin->getUserSetting($name, (int)$user_guid, $default); } - + /** * Set a setting for a plugin. * @@ -864,14 +864,14 @@ function setSetting($name, $value, $plugin_id = null) { elgg_deprecated_notice('elgg_set_plugin_setting() requires plugin_id to be set', 1.9); $plugin = elgg_get_calling_plugin_entity(); } - + if (!$plugin) { return false; } - + return $plugin->setSetting($name, $value); } - + /** * Get setting for a plugin. * @@ -889,14 +889,14 @@ function getSetting($name, $plugin_id = null, $default = null) { elgg_deprecated_notice('elgg_get_plugin_setting() requires plugin_id to be set', 1.9); $plugin = elgg_get_calling_plugin_entity(); } - + if (!$plugin) { return false; } - + return $plugin->getSetting($name, $default); } - + /** * Unsets a plugin setting. * @@ -913,14 +913,14 @@ function unsetSetting($name, $plugin_id = null) { elgg_deprecated_notice('elgg_unset_plugin_setting() requires plugin_id to be set', 1.9); $plugin = elgg_get_calling_plugin_entity(); } - + if (!$plugin) { return false; } - + return $plugin->unsetSetting($name); } - + /** * Unsets all plugin settings for a plugin. * @@ -936,14 +936,14 @@ function unsetAllSettings($plugin_id = null) { elgg_deprecated_notice('elgg_unset_all_plugin_settings() requires plugin_id to be set', 1.9); $plugin = elgg_get_calling_plugin_entity(); } - + if (!$plugin) { return false; } - + return $plugin->unsetAllSettings(); } - + /** * Returns entities based upon plugin user settings. * Takes all the options for {@link elgg_get_entities_from_private_settings()} @@ -976,12 +976,12 @@ function getEntitiesFromUserSettings(array $options = array()) { 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', @@ -989,26 +989,26 @@ function getEntitiesFromUserSettings(array $options = array()) { '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); } } diff --git a/engine/classes/Elgg/Database/RelationshipsTable.php b/engine/classes/Elgg/Database/RelationshipsTable.php index f4181a36051..f8216574b62 100644 --- a/engine/classes/Elgg/Database/RelationshipsTable.php +++ b/engine/classes/Elgg/Database/RelationshipsTable.php @@ -13,7 +13,7 @@ class RelationshipsTable { /** * Global Elgg configuration - * + * * @var \stdClass */ private $CONFIG; @@ -38,10 +38,10 @@ function get($id) { if (!$row) { return false; } - + return new \ElggRelationship($row); } - + /** * Get a database row from the relationship table * @@ -51,13 +51,13 @@ function get($id) { * @access private */ function getRow($id) { - - + + $id = (int)$id; - + return _elgg_services()->db->getDataRow("SELECT * FROM {$this->CONFIG->dbprefix}entity_relationships WHERE id = $id"); } - + /** * Delete a relationship by its ID * @@ -66,19 +66,19 @@ function getRow($id) { * @return bool */ function delete($id) { - - + + $id = (int)$id; - + $relationship = get_relationship($id); - + if (_elgg_services()->events->trigger('delete', 'relationship', $relationship)) { return _elgg_services()->db->deleteData("DELETE FROM {$this->CONFIG->dbprefix}entity_relationships WHERE id = $id"); } - + return false; } - + /** * Create a relationship between two entities. E.g. friendship, group membership, site membership. * @@ -93,33 +93,33 @@ function delete($id) { * @throws InvalidArgumentException */ function add($guid_one, $relationship, $guid_two) { - - + + if (strlen($relationship) > \ElggRelationship::RELATIONSHIP_LIMIT) { $msg = "relationship name cannot be longer than " . \ElggRelationship::RELATIONSHIP_LIMIT; throw InvalidArgumentException($msg); } - + $guid_one = (int)$guid_one; $relationship = sanitise_string($relationship); $guid_two = (int)$guid_two; $time = time(); - + // Check for duplicates if (check_entity_relationship($guid_one, $relationship, $guid_two)) { return false; } - + $id = _elgg_services()->db->insertData("INSERT INTO {$this->CONFIG->dbprefix}entity_relationships (guid_one, relationship, guid_two, time_created) VALUES ($guid_one, '$relationship', $guid_two, $time)"); - + if ($id !== false) { $obj = get_relationship($id); - + // this event has been deprecated in 1.9. Use 'create', 'relationship' $result_old = _elgg_services()->events->trigger('create', $relationship, $obj); - + $result = _elgg_services()->events->trigger('create', 'relationship', $obj); if ($result && $result_old) { return true; @@ -127,10 +127,10 @@ function add($guid_one, $relationship, $guid_two) { delete_relationship($result); } } - + return false; } - + /** * Check if a relationship exists between two entities. If so, the relationship object is returned. * @@ -143,25 +143,25 @@ function add($guid_one, $relationship, $guid_two) { * @return \ElggRelationship|false Depending on success */ function check($guid_one, $relationship, $guid_two) { - - + + $guid_one = (int)$guid_one; $relationship = sanitise_string($relationship); $guid_two = (int)$guid_two; - + $query = "SELECT * FROM {$this->CONFIG->dbprefix}entity_relationships WHERE guid_one=$guid_one AND relationship='$relationship' AND guid_two=$guid_two limit 1"; - + $row = row_to_elggrelationship(_elgg_services()->db->getDataRow($query)); if ($row) { return $row; } - + return false; } - + /** * Delete a relationship between two entities. * @@ -174,33 +174,33 @@ function check($guid_one, $relationship, $guid_two) { * @return bool */ function remove($guid_one, $relationship, $guid_two) { - - + + $guid_one = (int)$guid_one; $relationship = sanitise_string($relationship); $guid_two = (int)$guid_two; - + $obj = check_entity_relationship($guid_one, $relationship, $guid_two); if ($obj == false) { return false; } - + // this event has been deprecated in 1.9. Use 'delete', 'relationship' $result_old = _elgg_services()->events->trigger('delete', $relationship, $obj); - + $result = _elgg_services()->events->trigger('delete', 'relationship', $obj); if ($result && $result_old) { $query = "DELETE FROM {$this->CONFIG->dbprefix}entity_relationships WHERE guid_one = $guid_one AND relationship = '$relationship' AND guid_two = $guid_two"; - + return (bool)_elgg_services()->db->deleteData($query); } else { return false; } } - + /** * Removes all relationships originating from a particular entity * @@ -213,17 +213,17 @@ function remove($guid_one, $relationship, $guid_two) { * @return true */ function removeAll($guid, $relationship = "", $inverse_relationship = false, $type = '') { - - + + $guid = (int) $guid; - + if (!empty($relationship)) { $relationship = sanitize_string($relationship); $where = "AND er.relationship = '$relationship'"; } else { $where = ""; } - + if (!empty($type)) { $type = sanitize_string($type); if (!$inverse_relationship) { @@ -236,19 +236,19 @@ function removeAll($guid, $relationship = "", $inverse_relationship = false, $ty } else { $join = ""; } - + $guid_col = $inverse_relationship ? "guid_two" : "guid_one"; - + _elgg_services()->db->deleteData(" DELETE er FROM {$this->CONFIG->dbprefix}entity_relationships AS er $join WHERE $guid_col = $guid $where "); - + return true; } - + /** * Get all the relationships for a given GUID. * @@ -259,17 +259,17 @@ function removeAll($guid, $relationship = "", $inverse_relationship = false, $ty * @return \ElggRelationship[] */ function getAll($guid, $inverse_relationship = false) { - - + + $guid = (int)$guid; - + $where = ($inverse_relationship ? "guid_two='$guid'" : "guid_one='$guid'"); - + $query = "SELECT * from {$this->CONFIG->dbprefix}entity_relationships where {$where}"; - + return _elgg_services()->db->getData($query, "row_to_elggrelationship"); } - + /** * Return entities matching a given query joining against a relationship. * Also accepts all options available to elgg_get_entities() and @@ -295,7 +295,7 @@ function getAll($guid, $inverse_relationship = false) { * * inverse_relationship => false|BOOL Is relationship_guid is the target entity of the relationship? By default, * relationship_guid is the subject. - * + * * relationship_join_on => null|STR How the entities relate: guid (default), container_guid, or owner_guid * Add in Elgg 1.9.0. Examples using the relationship 'friend': * 1. use 'guid' if you want the user's friends @@ -311,13 +311,13 @@ function getEntities($options) { 'inverse_relationship' => false, 'relationship_join_on' => 'guid', ); - + $options = array_merge($defaults, $options); - + $join_column = "e.{$options['relationship_join_on']}"; $clauses = elgg_get_entity_relationship_where_sql($join_column, $options['relationship'], $options['relationship_guid'], $options['inverse_relationship']); - + if ($clauses) { // merge wheres to pass to get_entities() if (isset($options['wheres']) && !is_array($options['wheres'])) { @@ -325,36 +325,36 @@ function getEntities($options) { } elseif (!isset($options['wheres'])) { $options['wheres'] = array(); } - + $options['wheres'] = array_merge($options['wheres'], $clauses['wheres']); - + // merge joins to pass to get_entities() if (isset($options['joins']) && !is_array($options['joins'])) { $options['joins'] = array($options['joins']); } elseif (!isset($options['joins'])) { $options['joins'] = array(); } - + $options['joins'] = array_merge($options['joins'], $clauses['joins']); - + if (isset($options['selects']) && !is_array($options['selects'])) { $options['selects'] = array($options['selects']); } elseif (!isset($options['selects'])) { $options['selects'] = array(); } - + $select = array('r.id'); - + $options['selects'] = array_merge($options['selects'], $select); - + if (!isset($options['group_by'])) { $options['group_by'] = $clauses['group_by']; } } - + return elgg_get_entities_from_metadata($options); } - + /** * Returns SQL appropriate for relationship joins and wheres * @@ -371,7 +371,7 @@ function getEntities($options) { */ function getEntityRelationshipWhereSql($column, $relationship = null, $relationship_guid = null, $inverse_relationship = false) { - + if ($relationship == null && $relationship_guid == null) { return ''; } @@ -379,17 +379,17 @@ function getEntityRelationshipWhereSql($column, $relationship = null, $wheres = array(); $joins = array(); $group_by = ''; - + if ($inverse_relationship) { $joins[] = "JOIN {$this->CONFIG->dbprefix}entity_relationships r on r.guid_one = $column"; } else { $joins[] = "JOIN {$this->CONFIG->dbprefix}entity_relationships r on r.guid_two = $column"; } - + if ($relationship) { $wheres[] = "r.relationship = '" . sanitise_string($relationship) . "'"; } - + if ($relationship_guid) { if ($inverse_relationship) { $wheres[] = "r.guid_two = '$relationship_guid'"; @@ -401,15 +401,15 @@ function getEntityRelationshipWhereSql($column, $relationship = null, // otherwise the result set is not unique $group_by = $column; } - + if ($where_str = implode(' AND ', $wheres)) { - + return array('wheres' => array("($where_str)"), 'joins' => $joins, 'group_by' => $group_by); } - + return ''; } - + /** * Gets the number of entities by a the number of entities related to them in a particular way. * This is a good way to get out the users with the most friends, or the groups with the diff --git a/engine/classes/Elgg/Database/SiteSecret.php b/engine/classes/Elgg/Database/SiteSecret.php index c652dd0e12e..680f9edf9de 100644 --- a/engine/classes/Elgg/Database/SiteSecret.php +++ b/engine/classes/Elgg/Database/SiteSecret.php @@ -23,14 +23,14 @@ class SiteSecret { */ function init() { $secret = 'z' . _elgg_services()->crypto->getRandomString(31); - + if (_elgg_services()->datalist->set('__site_secret__', $secret)) { return $secret; } - + return false; } - + /** * Returns the site secret. * @@ -44,10 +44,10 @@ function get() { if (!$secret) { $secret = init_site_secret(); } - + return $secret; } - + /** * Get the strength of the site secret * @@ -67,5 +67,5 @@ function getStrength() { } return 'strong'; } - + } \ No newline at end of file diff --git a/engine/classes/Elgg/Database/SubtypeTable.php b/engine/classes/Elgg/Database/SubtypeTable.php index 55ecc895bdc..fabdb3b0507 100644 --- a/engine/classes/Elgg/Database/SubtypeTable.php +++ b/engine/classes/Elgg/Database/SubtypeTable.php @@ -23,7 +23,7 @@ class SubtypeTable { /** * Global Elgg configuration - * + * * @var \stdClass */ private $CONFIG; @@ -58,24 +58,24 @@ public function __construct() { */ function getId($type, $subtype) { global $SUBTYPE_CACHE; - + if (!$subtype) { return false; } - + if ($SUBTYPE_CACHE === null) { _elgg_populate_subtype_cache(); } - + // use the cache before hitting database $result = _elgg_retrieve_cached_subtype($type, $subtype); if ($result !== null) { return $result->id; } - + return false; } - + /** * Gets the denormalized string for a given subtype ID. * @@ -86,22 +86,22 @@ function getId($type, $subtype) { */ function getSubtype($subtype_id) { global $SUBTYPE_CACHE; - + if (!$subtype_id) { return ''; } - + if ($SUBTYPE_CACHE === null) { _elgg_populate_subtype_cache(); } - + if (isset($SUBTYPE_CACHE[$subtype_id])) { return $SUBTYPE_CACHE[$subtype_id]->subtype; } - + return false; } - + /** * Retrieve subtype from the cache. * @@ -113,11 +113,11 @@ function getSubtype($subtype_id) { */ function retrieveFromCache($type, $subtype) { global $SUBTYPE_CACHE; - + if ($SUBTYPE_CACHE === null) { _elgg_populate_subtype_cache(); } - + foreach ($SUBTYPE_CACHE as $obj) { if ($obj->type === $type && $obj->subtype === $subtype) { return $obj; @@ -125,7 +125,7 @@ function retrieveFromCache($type, $subtype) { } return null; } - + /** * Fetch all suptypes from DB to local cache. * @@ -133,15 +133,15 @@ function retrieveFromCache($type, $subtype) { */ function populateCache() { global $SUBTYPE_CACHE; - + $results = _elgg_services()->db->getData("SELECT * FROM {$this->CONFIG->dbprefix}entity_subtypes"); - + $SUBTYPE_CACHE = array(); foreach ($results as $row) { $SUBTYPE_CACHE[$row->id] = $row; } } - + /** * Return the class name for a registered type and subtype. * @@ -159,20 +159,20 @@ function populateCache() { */ function getClass($type, $subtype) { global $SUBTYPE_CACHE; - + if ($SUBTYPE_CACHE === null) { _elgg_populate_subtype_cache(); } - + // use the cache before going to the database $obj = _elgg_retrieve_cached_subtype($type, $subtype); if ($obj) { return $obj->class; } - + return null; } - + /** * Returns the class name for a subtype id. * @@ -185,22 +185,22 @@ function getClass($type, $subtype) { */ function getClassFromId($subtype_id) { global $SUBTYPE_CACHE; - + if (!$subtype_id) { return null; } - + if ($SUBTYPE_CACHE === null) { _elgg_populate_subtype_cache(); } - + if (isset($SUBTYPE_CACHE[$subtype_id])) { return $SUBTYPE_CACHE[$subtype_id]->class; } - + return null; } - + /** * Register \ElggEntities with a certain type and subtype to be loaded as a specific class. * @@ -223,13 +223,13 @@ function getClassFromId($subtype_id) { */ function add($type, $subtype, $class = "") { global $SUBTYPE_CACHE; - + if (!$subtype) { return 0; } - + $id = get_subtype_id($type, $subtype); - + if (!$id) { // In cache we store non-SQL-escaped strings because that's what's returned by query $cache_obj = (object) array( @@ -237,22 +237,22 @@ function add($type, $subtype, $class = "") { 'subtype' => $subtype, 'class' => $class, ); - + $type = sanitise_string($type); $subtype = sanitise_string($subtype); $class = sanitise_string($class); - + $id = _elgg_services()->db->insertData("INSERT INTO {$this->CONFIG->dbprefix}entity_subtypes" . " (type, subtype, class) VALUES ('$type', '$subtype', '$class')"); - + // add entry to cache $cache_obj->id = $id; $SUBTYPE_CACHE[$id] = $cache_obj; } - + return $id; } - + /** * Removes a registered \ElggEntity type, subtype, and classname. * @@ -269,21 +269,21 @@ function add($type, $subtype, $class = "") { */ function remove($type, $subtype) { global $SUBTYPE_CACHE; - + $type = sanitise_string($type); $subtype = sanitise_string($subtype); - + $success = _elgg_services()->db->deleteData("DELETE FROM {$this->CONFIG->dbprefix}entity_subtypes" . " WHERE type = '$type' AND subtype = '$subtype'"); - + if ($success) { // invalidate the cache $SUBTYPE_CACHE = null; } - + return (bool) $success; } - + /** * Update a registered \ElggEntity type, subtype, and class name * @@ -295,31 +295,31 @@ function remove($type, $subtype) { */ function update($type, $subtype, $class = '') { global $SUBTYPE_CACHE; - + $id = get_subtype_id($type, $subtype); if (!$id) { return false; } - + if ($SUBTYPE_CACHE === null) { _elgg_populate_subtype_cache(); } - + $unescaped_class = $class; - + $type = sanitise_string($type); $subtype = sanitise_string($subtype); $class = sanitise_string($class); - + $success = _elgg_services()->db->updateData("UPDATE {$this->CONFIG->dbprefix}entity_subtypes SET type = '$type', subtype = '$subtype', class = '$class' WHERE id = $id "); - + if ($success && isset($SUBTYPE_CACHE[$id])) { $SUBTYPE_CACHE[$id]->class = $unescaped_class; } - + return $success; } } \ No newline at end of file diff --git a/engine/classes/Elgg/Database/UsersTable.php b/engine/classes/Elgg/Database/UsersTable.php index 5b9c95b8da4..47e5c891d79 100644 --- a/engine/classes/Elgg/Database/UsersTable.php +++ b/engine/classes/Elgg/Database/UsersTable.php @@ -21,7 +21,7 @@ class UsersTable { /** * Global Elgg configuration - * + * * @var \stdClass */ private $CONFIG; @@ -43,12 +43,12 @@ public function __construct() { * @access private */ function getRow($guid) { - - + + $guid = (int)$guid; return _elgg_services()->db->getDataRow("SELECT * from {$this->CONFIG->dbprefix}users_entity where guid=$guid"); } - + /** * Disables all of a user's entities * @@ -57,7 +57,7 @@ function getRow($guid) { * @return bool Depending on success */ function disableEntities($owner_guid) { - + $owner_guid = (int) $owner_guid; if ($entity = get_entity($owner_guid)) { if (_elgg_services()->events->trigger('disable', $entity->type, $entity)) { @@ -65,16 +65,16 @@ function disableEntities($owner_guid) { $query = "UPDATE {$this->CONFIG->dbprefix}entities set enabled='no' where owner_guid={$owner_guid} or container_guid = {$owner_guid}"; - + $res = _elgg_services()->db->updateData($query); return $res; } } } - + return false; } - + /** * Ban a user * @@ -84,40 +84,40 @@ function disableEntities($owner_guid) { * @return bool */ function ban($user_guid, $reason = "") { - - + + $user_guid = (int)$user_guid; - + $user = get_entity($user_guid); - + if (($user) && ($user->canEdit()) && ($user instanceof \ElggUser)) { if (_elgg_services()->events->trigger('ban', 'user', $user)) { // Add reason if ($reason) { create_metadata($user_guid, 'ban_reason', $reason, '', 0, ACCESS_PUBLIC); } - + // invalidate memcache for this user static $newentity_cache; if ((!$newentity_cache) && (is_memcache_available())) { $newentity_cache = new \ElggMemcache('new_entity_cache'); } - + if ($newentity_cache) { $newentity_cache->delete($user_guid); } - + // Set ban flag $query = "UPDATE {$this->CONFIG->dbprefix}users_entity set banned='yes' where guid=$user_guid"; return _elgg_services()->db->updateData($query); } - + return false; } - + return false; } - + /** * Unban a user. * @@ -126,37 +126,37 @@ function ban($user_guid, $reason = "") { * @return bool */ function unban($user_guid) { - - + + $user_guid = (int)$user_guid; - + $user = get_entity($user_guid); - + if (($user) && ($user->canEdit()) && ($user instanceof \ElggUser)) { if (_elgg_services()->events->trigger('unban', 'user', $user)) { create_metadata($user_guid, 'ban_reason', '', '', 0, ACCESS_PUBLIC); - + // invalidate memcache for this user static $newentity_cache; if ((!$newentity_cache) && (is_memcache_available())) { $newentity_cache = new \ElggMemcache('new_entity_cache'); } - + if ($newentity_cache) { $newentity_cache->delete($user_guid); } - - + + $query = "UPDATE {$this->CONFIG->dbprefix}users_entity set banned='no' where guid=$user_guid"; return _elgg_services()->db->updateData($query); } - + return false; } - + return false; } - + /** * Makes user $guid an admin. * @@ -165,34 +165,34 @@ function unban($user_guid) { * @return bool */ function makeAdmin($user_guid) { - - + + $user = get_entity((int)$user_guid); - + if (($user) && ($user instanceof \ElggUser) && ($user->canEdit())) { if (_elgg_services()->events->trigger('make_admin', 'user', $user)) { - + // invalidate memcache for this user static $newentity_cache; if ((!$newentity_cache) && (is_memcache_available())) { $newentity_cache = new \ElggMemcache('new_entity_cache'); } - + if ($newentity_cache) { $newentity_cache->delete($user_guid); } - + $r = _elgg_services()->db->updateData("UPDATE {$this->CONFIG->dbprefix}users_entity set admin='yes' where guid=$user_guid"); _elgg_invalidate_cache_for_entity($user_guid); return $r; } - + return false; } - + return false; } - + /** * Removes user $guid's admin flag. * @@ -201,34 +201,34 @@ function makeAdmin($user_guid) { * @return bool */ function removeAdmin($user_guid) { - - + + $user = get_entity((int)$user_guid); - + if (($user) && ($user instanceof \ElggUser) && ($user->canEdit())) { if (_elgg_services()->events->trigger('remove_admin', 'user', $user)) { - + // invalidate memcache for this user static $newentity_cache; if ((!$newentity_cache) && (is_memcache_available())) { $newentity_cache = new \ElggMemcache('new_entity_cache'); } - + if ($newentity_cache) { $newentity_cache->delete($user_guid); } - + $r = _elgg_services()->db->updateData("UPDATE {$this->CONFIG->dbprefix}users_entity set admin='no' where guid=$user_guid"); _elgg_invalidate_cache_for_entity($user_guid); return $r; } - + return false; } - + return false; } - + /** * Get a user object from a GUID. * @@ -243,18 +243,18 @@ function get($guid) { if (!empty($guid)) { $result = get_entity($guid); } - + if ((!empty($result)) && (!($result instanceof \ElggUser))) { return false; } - + if (!empty($result)) { return $result; } - + return false; } - + /** * Get user by username * @@ -264,35 +264,35 @@ function get($guid) { */ function getByUsername($username) { global $USERNAME_TO_GUID_MAP_CACHE; - + // Fixes #6052. Username is frequently sniffed from the path info, which, // unlike $_GET, is not URL decoded. If the username was not URL encoded, // this is harmless. $username = rawurldecode($username); - + $username = sanitise_string($username); $access = _elgg_get_access_where_sql(); - + // Caching if ((isset($USERNAME_TO_GUID_MAP_CACHE[$username])) && (_elgg_retrieve_cached_entity($USERNAME_TO_GUID_MAP_CACHE[$username]))) { return _elgg_retrieve_cached_entity($USERNAME_TO_GUID_MAP_CACHE[$username]); } - + $query = "SELECT e.* FROM {$this->CONFIG->dbprefix}users_entity u JOIN {$this->CONFIG->dbprefix}entities e ON e.guid = u.guid WHERE u.username = '$username' AND $access"; - + $entity = _elgg_services()->db->getDataRow($query, 'entity_row_to_elggstar'); if ($entity) { $USERNAME_TO_GUID_MAP_CACHE[$username] = $entity->guid; } else { $entity = false; } - + return $entity; } - + /** * Get an array of users from an email address * @@ -301,19 +301,19 @@ function getByUsername($username) { * @return array */ function getByEmail($email) { - - + + $email = sanitise_string($email); - + $access = _elgg_get_access_where_sql(); - + $query = "SELECT e.* FROM {$this->CONFIG->dbprefix}entities e JOIN {$this->CONFIG->dbprefix}users_entity u ON e.guid = u.guid WHERE email = '$email' AND $access"; - + return _elgg_services()->db->getData($query, 'entity_row_to_elggstar'); } - + /** * Return users (or the number of them) who have been active within a recent period. * @@ -333,9 +333,9 @@ function getByEmail($email) { * @return \ElggUser[]|int */ function findActive($options = array(), $limit = 10, $offset = 0, $count = false) { - + $seconds = 600; //default value - + if (!is_array($options)) { elgg_deprecated_notice("find_active_users() now accepts an \$options array", 1.9); if (!$options) { @@ -343,20 +343,20 @@ function findActive($options = array(), $limit = 10, $offset = 0, $count = false } $options = array('seconds' => $options); } - + $options = array_merge(array( 'seconds' => $seconds, 'limit' => $limit, 'offset' => $offset, 'count' => $count, ), $options); - + // cast options we're sending to hook foreach (array('seconds', 'limit', 'offset') as $key) { $options[$key] = (int)$options[$key]; } $options['count'] = (bool)$options['count']; - + // allow plugins to override $params = array( 'seconds' => $options['seconds'], @@ -370,7 +370,7 @@ function findActive($options = array(), $limit = 10, $offset = 0, $count = false if ($data !== null) { return $data; } - + $dbprefix = _elgg_services()->config->get('dbprefix'); $time = time() - $options['seconds']; return elgg_get_entities(array( @@ -383,7 +383,7 @@ function findActive($options = array(), $limit = 10, $offset = 0, $count = false 'order_by' => "u.last_action desc", )); } - + /** * Generate and send a password request email to a given user's registered email address. * @@ -393,28 +393,28 @@ function findActive($options = array(), $limit = 10, $offset = 0, $count = false */ function sendNewPasswordRequest($user_guid) { $user_guid = (int)$user_guid; - + $user = get_entity($user_guid); if ($user instanceof \ElggUser) { // generate code $code = generate_random_cleartext_password(); $user->setPrivateSetting('passwd_conf_code', $code); $user->setPrivateSetting('passwd_conf_time', time()); - + // generate link $link = _elgg_services()->config->getSiteUrl() . "changepassword?u=$user_guid&c=$code"; - + // generate email $ip_address = _elgg_services()->request->getClientIp(); $email = _elgg_services()->translator->translate('email:changereq:body', array($user->name, $ip_address, $link)); - + return notify_user($user->guid, elgg_get_site_entity()->guid, _elgg_services()->translator->translate('email:changereq:subject'), $email, array(), 'email'); } - + return false; } - + /** * Low level function to reset a given user's password. * @@ -429,20 +429,20 @@ function forcePasswordReset($user_guid, $password) { $user = get_entity($user_guid); if ($user instanceof \ElggUser) { $ia = elgg_set_ignore_access(); - + $user->salt = _elgg_generate_password_salt(); $hash = generate_user_password($user, $password); $user->password = $hash; $result = (bool)$user->save(); - + elgg_set_ignore_access($ia); - + return $result; } - + return false; } - + /** * Validate and change password for a user. * @@ -453,39 +453,39 @@ function forcePasswordReset($user_guid, $password) { * @return bool True on success */ function executeNewPasswordReset($user_guid, $conf_code, $password = null) { - + $user_guid = (int)$user_guid; $user = get_entity($user_guid); - + if ($password === null) { $password = generate_random_cleartext_password(); $reset = true; } - + if (!elgg_instanceof($user, 'user')) { return false; } - + $saved_code = $user->getPrivateSetting('passwd_conf_code'); $code_time = (int) $user->getPrivateSetting('passwd_conf_time'); - + if (!$saved_code || $saved_code != $conf_code) { return false; } - + // Discard for security if it is 24h old if (!$code_time || $code_time < time() - 24 * 60 * 60) { return false; } - + if (force_user_password_reset($user_guid, $password)) { remove_private_setting($user_guid, 'passwd_conf_code'); remove_private_setting($user_guid, 'passwd_conf_time'); // clean the logins failures reset_login_failure_count($user_guid); - + $ns = $reset ? 'resetpassword' : 'changepassword'; - + notify_user($user->guid, elgg_get_site_entity()->guid, _elgg_services()->translator->translate("email:$ns:subject"), @@ -493,13 +493,13 @@ function executeNewPasswordReset($user_guid, $conf_code, $password = null) { array(), 'email' ); - + return true; } - + return false; } - + /** * Hash a password for storage. Currently salted MD5. * @@ -511,7 +511,7 @@ function executeNewPasswordReset($user_guid, $conf_code, $password = null) { function generatePassword(\ElggUser $user, $password) { return md5($password . $user->salt); } - + /** * Registers a user, returning false if the username already exists * @@ -526,12 +526,12 @@ function generatePassword(\ElggUser $user, $password) { * @throws RegistrationException */ function register($username, $password, $name, $email, $allow_multiple_emails = false) { - + // no need to trim password. $username = trim($username); $name = trim(strip_tags($name)); $email = trim($email); - + // A little sanity checking if (empty($username) || empty($password) @@ -539,33 +539,33 @@ function register($username, $password, $name, $email, $allow_multiple_emails = || empty($email)) { return false; } - + // Make sure a user with conflicting details hasn't registered and been disabled $access_status = access_get_show_hidden_status(); access_show_hidden_entities(true); - + if (!validate_email_address($email)) { throw new \RegistrationException(_elgg_services()->translator->translate('registration:emailnotvalid')); } - + if (!validate_password($password)) { throw new \RegistrationException(_elgg_services()->translator->translate('registration:passwordnotvalid')); } - + if (!validate_username($username)) { throw new \RegistrationException(_elgg_services()->translator->translate('registration:usernamenotvalid')); } - + if ($user = get_user_by_username($username)) { throw new \RegistrationException(_elgg_services()->translator->translate('registration:userexists')); } - + if ((!$allow_multiple_emails) && (get_user_by_email($email))) { throw new \RegistrationException(_elgg_services()->translator->translate('registration:dupeemail')); } - + access_show_hidden_entities($access_status); - + // Create user $user = new \ElggUser(); $user->username = $username; @@ -580,13 +580,13 @@ function register($username, $password, $name, $email, $allow_multiple_emails = if ($user->save() === false) { return false; } - + // Turn on email notifications by default set_user_notification_setting($user->getGUID(), 'email', true); - + return $user->getGUID(); } - + /** * Generates a unique invite code for a user * @@ -598,7 +598,7 @@ function generateInviteCode($username) { $secret = _elgg_services()->datalist->get('__site_secret__'); return md5($username . $secret); } - + /** * Set the validation status for a user. * @@ -616,7 +616,7 @@ function setValidationStatus($user_guid, $status, $method = '') { return false; } } - + /** * Gets the validation status of a user. * @@ -631,14 +631,14 @@ function getValidationStatus($user_guid) { if ($md == false) { return null; } - + if ($md[0]->value) { return true; } - + return false; } - + /** * Sets the last action time of the given user to right now. * @@ -648,16 +648,16 @@ function getValidationStatus($user_guid) { */ function setLastAction($user_guid) { $user_guid = (int) $user_guid; - + $time = time(); - + $query = "UPDATE {$this->CONFIG->dbprefix}users_entity set prev_last_action = last_action, last_action = {$time} where guid = {$user_guid}"; - + execute_delayed_write_query($query); } - + /** * Sets the last logon time of the given user to right now. * @@ -667,13 +667,13 @@ function setLastAction($user_guid) { */ function setLastLogin($user_guid) { $user_guid = (int) $user_guid; - + $time = time(); - + $query = "UPDATE {$this->CONFIG->dbprefix}users_entity set prev_last_login = last_login, last_login = {$time} where guid = {$user_guid}"; - + execute_delayed_write_query($query); } - + } \ No newline at end of file diff --git a/engine/classes/Elgg/DeprecationWrapper.php b/engine/classes/Elgg/DeprecationWrapper.php index c156525ed29..7c0c073ea2b 100644 --- a/engine/classes/Elgg/DeprecationWrapper.php +++ b/engine/classes/Elgg/DeprecationWrapper.php @@ -19,7 +19,7 @@ * config object in ElggPlugin::includeFile * * @access private - * + * * @package Elgg.Core */ class DeprecationWrapper implements \ArrayAccess { @@ -40,7 +40,7 @@ class DeprecationWrapper implements \ArrayAccess { /** * Create the wrapper - * + * * @param mixed $object The object or string to wrap * @param string $message The deprecation message to display when used * @param string $version The Elgg version this was deprecated @@ -59,7 +59,7 @@ public function __construct($object, $message, $version, $reporter = 'elgg_depre /** * Get a property on the object - * + * * @param string $name Property name * @return mixed */ @@ -70,7 +70,7 @@ public function __get($name) { /** * Set a property on the object - * + * * @param string $name Property name * @param mixed $value Property value * @return void @@ -82,7 +82,7 @@ public function __set($name, $value) { /** * Call a method on the object - * + * * @param string $name Method name * @param array $arguments Method arguments * @return mixed @@ -94,7 +94,7 @@ public function __call($name, $arguments) { /** * Get the object as string - * + * * @return string */ public function __toString() { @@ -108,7 +108,7 @@ public function __toString() { /** * Display a warning - * + * * @return void */ protected function displayWarning() { diff --git a/engine/classes/Elgg/Di/DiContainer.php b/engine/classes/Elgg/Di/DiContainer.php index 0d9757cc9e8..b7724a12500 100644 --- a/engine/classes/Elgg/Di/DiContainer.php +++ b/engine/classes/Elgg/Di/DiContainer.php @@ -21,7 +21,7 @@ * * * @access private - * + * * @package Elgg.Core * @since 1.9 */ @@ -66,7 +66,7 @@ public function __get($name) { /** * Build a value - * + * * @param mixed $factory The factory for the value * @param string $name The name of the value * @return mixed @@ -144,7 +144,7 @@ public function setClassName($name, $class_name, $shared = true) { /** * Remove a value from the container - * + * * @param string $name The name of the value * @return \Elgg\Di\DiContainer */ @@ -156,7 +156,7 @@ public function remove($name) { /** * Does the container have this value - * + * * @param string $name The name of the value * @return bool */ diff --git a/engine/classes/Elgg/Di/FactoryUncallableException.php b/engine/classes/Elgg/Di/FactoryUncallableException.php index aecafe4915b..e28483ebb35 100644 --- a/engine/classes/Elgg/Di/FactoryUncallableException.php +++ b/engine/classes/Elgg/Di/FactoryUncallableException.php @@ -3,9 +3,9 @@ /** * Factory uncallable exception - * + * * @access private - * + * * @package Elgg.Core */ class FactoryUncallableException extends \Exception {} diff --git a/engine/classes/Elgg/Di/MissingValueException.php b/engine/classes/Elgg/Di/MissingValueException.php index 17639825e94..ee6d21f5bc9 100644 --- a/engine/classes/Elgg/Di/MissingValueException.php +++ b/engine/classes/Elgg/Di/MissingValueException.php @@ -3,9 +3,9 @@ /** * Missing value exception - * + * * @access private - * + * * @package Elgg.Core */ class MissingValueException extends \Exception {} diff --git a/engine/classes/Elgg/Di/ServiceProvider.php b/engine/classes/Elgg/Di/ServiceProvider.php index 7e6499817b9..2c411ad497d 100644 --- a/engine/classes/Elgg/Di/ServiceProvider.php +++ b/engine/classes/Elgg/Di/ServiceProvider.php @@ -7,7 +7,7 @@ * We extend the container because it allows us to document properties in the PhpDoc, which assists * IDEs to auto-complete properties and understand the types returned. Extension allows us to keep * the container generic. - * + * * @property-read \Elgg\ActionsService $actions * @property-read \Elgg\Amd\Config $amdConfig * @property-read \ElggAutoP $autoP @@ -42,7 +42,7 @@ * @property-read \Elgg\Database\UsersTable $usersTable * @property-read \Elgg\ViewsService $views * @property-read \Elgg\WidgetsService $widgets - * + * * @package Elgg.Core * @access private */ @@ -50,7 +50,7 @@ class ServiceProvider extends \Elgg\Di\DiContainer { /** * Constructor - * + * * @param \Elgg\AutoloadManager $autoload_manager Class autoloader */ public function __construct(\Elgg\AutoloadManager $autoload_manager) { @@ -127,7 +127,7 @@ protected function getEvents(\Elgg\Di\ServiceProvider $c) { /** * Logger factory - * + * * @param \Elgg\Di\ServiceProvider $c Dependency injection container * @return \Elgg\Logger */ @@ -167,7 +167,7 @@ protected function resolveLoggerDependencies($service_needed) { /** * Views service factory - * + * * @param \Elgg\Di\ServiceProvider $c Dependency injection container * @return \Elgg\ViewsService */ @@ -177,7 +177,7 @@ protected function getViews(\Elgg\Di\ServiceProvider $c) { /** * AMD Config factory - * + * * @param \Elgg\Di\ServiceProvider $c Dependency injection container * @return \Elgg\Amd\Config */ @@ -189,7 +189,7 @@ protected function getAmdConfig(\Elgg\Di\ServiceProvider $c) { /** * Session factory - * + * * @param \Elgg\Di\ServiceProvider $c Dependency injection container * @return \ElggSession */ @@ -214,7 +214,7 @@ protected function getSession(\Elgg\Di\ServiceProvider $c) { /** * Request factory - * + * * @param \Elgg\Di\ServiceProvider $c Dependency injection container * @return \Elgg\Http\Request */ @@ -224,7 +224,7 @@ protected function getRequest(\Elgg\Di\ServiceProvider $c) { /** * Router factory - * + * * @param \Elgg\Di\ServiceProvider $c Dependency injection container * @return \Elgg\Router */ @@ -235,7 +235,7 @@ protected function getRouter(\Elgg\Di\ServiceProvider $c) { /** * Notification service factory - * + * * @param \Elgg\Di\ServiceProvider $c Dependency injection container * @return \Elgg\Notifications\NotificationsService */ diff --git a/engine/classes/Elgg/EntityDirLocator.php b/engine/classes/Elgg/EntityDirLocator.php index 3580ce6b6b0..c9d1d12093f 100644 --- a/engine/classes/Elgg/EntityDirLocator.php +++ b/engine/classes/Elgg/EntityDirLocator.php @@ -10,7 +10,7 @@ * being used directly. * * @access private - * + * * @package Elgg.Core */ class EntityDirLocator { @@ -22,7 +22,7 @@ class EntityDirLocator { /** * Find an entity's data dir. - * + * * @param int $guid GUID of the entity. * * @throws \InvalidArgumentException @@ -37,7 +37,7 @@ public function __construct($guid) { $this->guid = $guid; } - + /** * Construct a file path matrix for an entity. * As of 1.9.0 matrixes are based on GUIDs and separated into dirs of 5000 entries diff --git a/engine/classes/Elgg/EventsService.php b/engine/classes/Elgg/EventsService.php index a3c8566692e..d77ca5432f4 100644 --- a/engine/classes/Elgg/EventsService.php +++ b/engine/classes/Elgg/EventsService.php @@ -5,7 +5,7 @@ * Service for Events * * @access private - * + * * @package Elgg.Core * @subpackage Hooks * @since 1.9.0 @@ -18,7 +18,7 @@ class EventsService extends \Elgg\HooksRegistrationService { /** * Triggers an Elgg event. - * + * * @see elgg_trigger_event * @see elgg_trigger_after_event * @access private diff --git a/engine/classes/Elgg/Filesystem/File.php b/engine/classes/Elgg/Filesystem/File.php index 9d84a706155..333ba440fab 100644 --- a/engine/classes/Elgg/Filesystem/File.php +++ b/engine/classes/Elgg/Filesystem/File.php @@ -3,24 +3,24 @@ /** * Represents a file that may or may not actually exist. - * + * * @package Elgg.Core * @subpackage Filesystem * @since 1.10.0 - * + * * @access private */ class File { - + /** @var Filesystem */ private $filesystem; - + /** @var string */ private $path; - + /** * Constructor - * + * * @param Filesystem $filesystem The filesystem * @param string $path The path to this file in the filesystem */ @@ -28,48 +28,48 @@ public function __construct(Filesystem $filesystem, $path) { $this->filesystem = $filesystem; $this->path = $path; } - + /** * @return boolean Whether this file exists. */ public function exists() { return $this->filesystem->isFile($this->path); } - + /** * @return string The file's extension. */ public function getExtension() { return pathinfo($this->path, PATHINFO_EXTENSION); } - + /** * @return string The file's basename. */ public function getBasename() { return pathinfo($this->path, PATHINFO_BASENAME); } - + /** * Get the text content of this file. Empty string if it doesn't exist. - * + * * @return string */ public function getContents() { return $this->filesystem->getFileContents($this->path); } - + /** * Do a PHP include of the file and return the result. - * + * * TODO: This may only work for local filesystem? - * + * * @return mixed */ public function includeFile() { return $this->filesystem->includeFile($this->path); } - + /** @inheritDoc */ public function __toString() { return $this->path; diff --git a/engine/classes/Elgg/Filesystem/Filesystem.php b/engine/classes/Elgg/Filesystem/Filesystem.php index e1fd6f64863..c5255431d22 100644 --- a/engine/classes/Elgg/Filesystem/Filesystem.php +++ b/engine/classes/Elgg/Filesystem/Filesystem.php @@ -7,31 +7,31 @@ /** * A simple filesystem abstraction. - * + * * We've worked really hard to privatize the fact that this uses Gaufrette under the hood. * This allows us to switch it out with something later if we need to. * Changes to this class should maintain this level of privacy. - * + * * @package Elgg.Core * @subpackage Filesystem * @since 1.10.0 - * + * * @access private */ final class Filesystem { - + /** @var Gaufrette */ private $gaufrette; - + /** @var string */ private $localPath; - + /** @var string Path relative to the gaufrette filesystem's root */ private $chroot; - + /** * Use one of the static factory functions to create an instance. - * + * * @param Gaufrette $gaufrette The underlying filesystem implementation. * @param string $localPath Only applicable for local filesystem. * @param string $chroot Path relative to the gaufrette filesystem's root. @@ -41,53 +41,53 @@ private function __construct(Gaufrette $gaufrette, $localPath = '', $chroot = '' $this->localPath = rtrim($localPath, "/\\"); $this->chroot = $this->normalize($chroot); } - + /** * Whether this filesystem has an existing file at the given location. - * + * * @param string $path The relative path within this filesystem - * + * * @return boolean */ public function isFile($path) { return !$this->isDirectory($path) && $this->gaufrette->has($this->getGaufrettePath($path)); } - + /** * Whether this filesystem has an existing directory at the given path. - * + * * @param string $path The path to the directory, relative to this filesystem. - * + * * @return boolean */ private function isDirectory($path) { $adapter = $this->gaufrette->getAdapter(); return $adapter->isDirectory($this->getGaufrettePath($path)); } - + /** * A reference to the file at the given path, even if it doesn't exist yet. - * + * * However, will throw an exception if the file is already a directory. - * + * * @param string $path The path to the file, relative to this filesystem. - * + * * @return File */ public function getFile($path) { if ($this->isDirectory($path)) { throw new \RuntimeException("There is already a directory at that location: $path"); } - + return new File($this, $path); } - + /** * Read the file off the filesystem. - * + * * @param string $path The filesyste-relative path to the target file. - * + * * @return string Empty string if the file doesn't exist. */ public function getFileContents($path) { @@ -97,17 +97,17 @@ public function getFileContents($path) { return ''; } } - + /** * Recursively list the files in the given directory path. - * + * * @param string $path The directory path on this filesystem - * - * @return File[] + * + * @return File[] */ public function getFiles($path = '') { $keys = $this->gaufrette->listKeys($this->getGaufrettePath($path)); - + $filesystem = $this; return array_map(function($path) use ($filesystem) { return new File($filesystem, $path); @@ -116,100 +116,100 @@ public function getFiles($path = '') { /** * Get a path suitable for passing to the underlying gaufrette filesystem. - * + * * @param string $path The path relative to this filesystem. - * + * * @return string */ private function getGaufrettePath($path) { return $this->normalize("$this->chroot/$path"); } - + /** * Get the absolute path to the given filesystem-relative path. - * + * * @param string $path A file/directory path within this filesystem. - * + * * @return string */ private function getFullPath($path = '') { $gaufrettePath = $this->normalize($this->getGaufrettePath($path)); return "$this->localPath/$gaufrettePath"; } - - + + /** * Do a PHP include of the file and return the result. * This only really works with local filesystems amirite? - * + * * @param string $path Filesystem-relative path for the file to include. - * + * * @return mixed */ public function includeFile($path) { return include $this->getFullPath($path); } - + /** * Whether there is a file or directory at the given path. - * + * * @param string $path Filesystem-relative path to check for existence. - * + * * @return boolean */ private function exists($path) { return $this->gaufrette->has($this->getGaufrettePath($path)); } - + /** * Write a file, overwriting if necessary. - * + * * @param string $path The path to the file. * @param string $content The literal text content of the file. - * + * * @return void */ public function put($path, $content) { $this->gaufrette->write($this->getGaufrettePath($path), $content, true); } - + /** * Returns a new filesystem with access limited to the given directory. - * + * * @param string $path The path relative to this filesystem to chroot to. - * + * * @return Filesystem A new filesystem instance. */ public function chroot($path) { return new Filesystem($this->gaufrette, $this->localPath, $this->getGaufrettePath($path)); } - - + + /** * Get a standardized form of the given path to work with internally. - * + * * @param string $path A relative path within this filesystem - * + * * @return string */ private function normalize($path) { return trim($path, "/"); } - + /** * Shorthand for generating a new local filesystem. - * + * * @param string $path absolute path to directory on local filesystem. - * + * * @return Filesystem */ public static function createLocal($path) { return new Filesystem(new Gaufrette(new Local($path)), $path); } - + /** * Shorthand for generating a new in-memory-only filesystem. - * + * * @return Filesystem */ public static function createInMemory() { diff --git a/engine/classes/Elgg/Forms/StickyForms.php b/engine/classes/Elgg/Forms/StickyForms.php index 848daa1e3c8..49b6cb6cc52 100644 --- a/engine/classes/Elgg/Forms/StickyForms.php +++ b/engine/classes/Elgg/Forms/StickyForms.php @@ -11,7 +11,7 @@ * @access private */ class StickyForms { - + /** * Load all the GET and POST variables into the sticky form cache * @@ -23,20 +23,20 @@ class StickyForms { * @return void */ public function makeStickyForm($form_name) { - + elgg_clear_sticky_form($form_name); - + $session = _elgg_services()->session; $data = $session->get('sticky_forms', array()); $req = _elgg_services()->request; - + // will go through XSS filtering in elgg_get_sticky_value() $vars = array_merge($req->query->all(), $req->request->all()); $data[$form_name] = $vars; - + $session->set('sticky_forms', $data); } - + /** * Clear the sticky form cache * @@ -54,7 +54,7 @@ function clearStickyForm($form_name) { unset($data[$form_name]); $session->set('sticky_forms', $data); } - + /** * Has this form been made sticky? * @@ -67,7 +67,7 @@ function isStickyForm($form_name) { $data = $session->get('sticky_forms', array()); return isset($data[$form_name]); } - + /** * Get a specific sticky variable * @@ -93,7 +93,7 @@ function getStickyValue($form_name, $variable = '', $default = null, $filter_res } return $default; } - + /** * Get all the values in a sticky form in an array * @@ -108,7 +108,7 @@ function getStickyValues($form_name, $filter_result = true) { if (!isset($data[$form_name])) { return array(); } - + $values = $data[$form_name]; if ($filter_result) { foreach ($values as $key => $value) { @@ -118,7 +118,7 @@ function getStickyValues($form_name, $filter_result = true) { } return $values; } - + /** * Clear a specific sticky variable * @@ -133,5 +133,5 @@ function clearStickyValue($form_name, $variable) { unset($data[$form_name][$variable]); $session->set('sticky_forms', $data); } - + } \ No newline at end of file diff --git a/engine/classes/Elgg/HooksRegistrationService.php b/engine/classes/Elgg/HooksRegistrationService.php index b4de9909c05..77c00b9c934 100644 --- a/engine/classes/Elgg/HooksRegistrationService.php +++ b/engine/classes/Elgg/HooksRegistrationService.php @@ -3,17 +3,17 @@ /** * WARNING: API IN FLUX. DO NOT USE DIRECTLY. - * + * * Use the elgg_* versions instead. - * + * * @access private - * + * * @package Elgg.Core * @subpackage Hooks * @since 1.9.0 */ abstract class HooksRegistrationService { - + private $handlers = array(); /** @@ -31,7 +31,7 @@ public function setLogger(\Elgg\Logger $logger = null) { $this->logger = $logger; return $this; } - + /** * Registers a handler. * @@ -44,28 +44,28 @@ public function registerHandler($name, $type, $callback, $priority = 500) { if (empty($name) || empty($type) || !is_callable($callback, true)) { return false; } - + if (!isset($this->handlers[$name])) { $this->handlers[$name] = array(); } - + if (!isset($this->handlers[$name][$type])) { $this->handlers[$name][$type] = array(); } - + // Priority cannot be lower than 0 $priority = max((int) $priority, 0); - + while (isset($this->handlers[$name][$type][$priority])) { $priority++; } - + $this->handlers[$name][$type][$priority] = $callback; ksort($this->handlers[$name][$type]); return true; } - + /** * Unregister a handler * @@ -96,7 +96,7 @@ public function unregisterHandler($name, $type, $callback) { * $priority => callback, ... * ) * ) - * + * * @access private * @return array */ @@ -106,7 +106,7 @@ public function getAllHandlers() { /** * Does the hook have a handler? - * + * * @param string $name The name of the hook * @param string $type The type of the hook * @return boolean @@ -125,7 +125,7 @@ public function hasHandler($name, $type) { */ protected function getOrderedHandlers($name, $type) { $handlers = array(); - + if (isset($this->handlers[$name][$type])) { if ($name != 'all' && $type != 'all') { $handlers = array_merge($handlers, array_values($this->handlers[$name][$type])); diff --git a/engine/classes/Elgg/Http/DatabaseSessionHandler.php b/engine/classes/Elgg/Http/DatabaseSessionHandler.php index 8449979a188..a00b19d1874 100644 --- a/engine/classes/Elgg/Http/DatabaseSessionHandler.php +++ b/engine/classes/Elgg/Http/DatabaseSessionHandler.php @@ -5,7 +5,7 @@ * Database session handler * * @access private - * + * * @package Elgg.Core * @subpackage Http */ @@ -34,7 +34,7 @@ public function open($save_path, $name) { * {@inheritDoc} */ public function read($session_id) { - + $id = sanitize_string($session_id); $query = "SELECT * FROM {$this->db->getTablePrefix()}users_sessions WHERE session='$id'"; $result = $this->db->getDataRow($query); @@ -75,7 +75,7 @@ public function close() { * {@inheritDoc} */ public function destroy($session_id) { - + $id = sanitize_string($session_id); $query = "DELETE FROM {$this->db->getTablePrefix()}users_sessions WHERE session='$id'"; return (bool) $this->db->deleteData($query); @@ -85,7 +85,7 @@ public function destroy($session_id) { * {@inheritDoc} */ public function gc($max_lifetime) { - + $life = time() - $max_lifetime; $query = "DELETE FROM {$this->db->getTablePrefix()}users_sessions WHERE ts < '$life'"; return (bool) $this->db->deleteData($query); diff --git a/engine/classes/Elgg/Http/Input.php b/engine/classes/Elgg/Http/Input.php index a6b8f878172..4fb4afa407e 100644 --- a/engine/classes/Elgg/Http/Input.php +++ b/engine/classes/Elgg/Http/Input.php @@ -3,7 +3,7 @@ /** * WARNING: API IN FLUX. DO NOT USE DIRECTLY. - * + * * Provides unified access to the $_GET and $_POST inputs. * * @package Elgg.Core @@ -14,7 +14,7 @@ class Input { /** * Global Elgg configuration - * + * * @var \stdClass */ private $CONFIG; @@ -38,11 +38,11 @@ public function __construct() { * @return void */ public function set($variable, $value) { - + if (!isset($this->CONFIG->input)) { $this->CONFIG->input = array(); } - + if (is_array($value)) { array_walk_recursive($value, create_function('&$v, $k', '$v = trim($v);')); $this->CONFIG->input[trim($variable)] = $value; @@ -50,8 +50,8 @@ public function set($variable, $value) { $this->CONFIG->input[trim($variable)] = trim($value); } } - - + + /** * Get some input from variables passed submitted through GET or POST. * @@ -70,13 +70,13 @@ public function set($variable, $value) { * @return mixed */ function get($variable, $default = null, $filter_result = true) { - - - + + + $result = $default; - + elgg_push_context('input'); - + if (isset($this->CONFIG->input[$variable])) { // a plugin has already set this variable $result = $this->CONFIG->input[$variable]; @@ -92,15 +92,15 @@ function get($variable, $default = null, $filter_result = true) { // @todo why trim $result = trim($result); } - + if ($filter_result) { $result = filter_tags($result); } } } - + elgg_pop_context(); - + return $result; } diff --git a/engine/classes/Elgg/Http/MockSessionHandler.php b/engine/classes/Elgg/Http/MockSessionHandler.php index 37d6df6a6b0..8d25dbab4e6 100644 --- a/engine/classes/Elgg/Http/MockSessionHandler.php +++ b/engine/classes/Elgg/Http/MockSessionHandler.php @@ -5,7 +5,7 @@ * Mock session handler * * @access private - * + * * @package Elgg.Core * @subpackage Http */ diff --git a/engine/classes/Elgg/Http/MockSessionStorage.php b/engine/classes/Elgg/Http/MockSessionStorage.php index bcc65204535..13e16cde678 100644 --- a/engine/classes/Elgg/Http/MockSessionStorage.php +++ b/engine/classes/Elgg/Http/MockSessionStorage.php @@ -29,7 +29,7 @@ * Mock for unit tests. * * @access private - * + * * @package Elgg.Core * @subpackage Http */ diff --git a/engine/classes/Elgg/Http/NativeSessionStorage.php b/engine/classes/Elgg/Http/NativeSessionStorage.php index a76246cbce6..f3b04d8a6e3 100644 --- a/engine/classes/Elgg/Http/NativeSessionStorage.php +++ b/engine/classes/Elgg/Http/NativeSessionStorage.php @@ -29,7 +29,7 @@ * PHP Session Storage * * @access private - * + * * @package Elgg.Core * @subpackage Http */ @@ -43,7 +43,7 @@ class NativeSessionStorage implements \Elgg\Http\SessionStorage { /** * Constructor - * + * * List of options for $options array with their defaults. * @see http://php.net/session.configuration for options * but we omit 'session.' from the beginning of the keys for convenience. @@ -75,7 +75,7 @@ class NativeSessionStorage implements \Elgg\Http\SessionStorage { * upload_progress.name, "PHP_SESSION_UPLOAD_PROGRESS" * upload_progress.freq, "1%" * upload_progress.min-freq, "1" - * + * * @param array $options Session config options * @param \Elgg\Http\SessionHandler $handler Session handler */ @@ -277,7 +277,7 @@ protected function setOptions(array $options) { /** * Set the session handler class with PHP - * + * * @param \Elgg\Http\SessionHandler $handler Handler object * @return void */ diff --git a/engine/classes/Elgg/Http/Request.php b/engine/classes/Elgg/Http/Request.php index cbb4a6c70d2..acde8c043a0 100644 --- a/engine/classes/Elgg/Http/Request.php +++ b/engine/classes/Elgg/Http/Request.php @@ -29,7 +29,7 @@ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. - * + * * @package Elgg.Core * @subpackage Http * @since 1.9.0 @@ -118,7 +118,7 @@ protected function initialize(array $query = array(), array $request = array(), // Symfony uses FileBag so this will change in next Elgg version $this->files = new \Elgg\Http\ParameterBag($files); $this->server = new \Elgg\Http\ParameterBag($server); - + $headers = $this->prepareHeaders(); // Symfony uses HeaderBag so this will change in next Elgg version $this->headers = new \Elgg\Http\ParameterBag($headers); diff --git a/engine/classes/Elgg/Http/SessionHandler.php b/engine/classes/Elgg/Http/SessionHandler.php index 4ce28067da2..8965beabcdc 100644 --- a/engine/classes/Elgg/Http/SessionHandler.php +++ b/engine/classes/Elgg/Http/SessionHandler.php @@ -5,9 +5,9 @@ * Session handler interface * * Use SessionHandlerInterface when minimum PHP version becomes 5.4 - * + * * @access private - * + * * @package Elgg.Core * @subpackage Http */ diff --git a/engine/classes/Elgg/Http/SessionStorage.php b/engine/classes/Elgg/Http/SessionStorage.php index d29b24690f2..4383404c101 100644 --- a/engine/classes/Elgg/Http/SessionStorage.php +++ b/engine/classes/Elgg/Http/SessionStorage.php @@ -29,7 +29,7 @@ * Interface for session storage * * @access private - * + * * @package Elgg.Core * @subpackage Http */ @@ -170,7 +170,7 @@ public function remove($name); /** * Clears all attributes. - * + * * @return void */ public function clear(); diff --git a/engine/classes/Elgg/Http/WebAppManifestResource.php b/engine/classes/Elgg/Http/WebAppManifestResource.php index 13ede92d6d9..d982f6b794f 100644 --- a/engine/classes/Elgg/Http/WebAppManifestResource.php +++ b/engine/classes/Elgg/Http/WebAppManifestResource.php @@ -18,19 +18,19 @@ class WebAppManifestResource { /** @var ElggSite */ private $site; - + /** * Constructor - * + * * @param ElggSite $site The site serving this manifest. */ public function __construct(ElggSite $site) { $this->site = $site; } - + /** * Behavior for HTTP GET method - * + * * @return array */ public function get() { diff --git a/engine/classes/Elgg/I18n/Translator.php b/engine/classes/Elgg/I18n/Translator.php index 2f3b2761838..c7dec28401d 100644 --- a/engine/classes/Elgg/I18n/Translator.php +++ b/engine/classes/Elgg/I18n/Translator.php @@ -11,10 +11,10 @@ * @since 1.10.0 */ class Translator { - + /** * Global Elgg configuration - * + * * @var \stdClass */ private $CONFIG; @@ -27,7 +27,7 @@ public function __construct() { $this->CONFIG = $CONFIG; $this->defaultPath = dirname(dirname(dirname(dirname(__DIR__)))) . "/languages/"; } - + /** * Given a message key, returns an appropriately translated full-text string * @@ -40,26 +40,26 @@ public function __construct() { * or the original language string. */ function translate($message_key, $args = array(), $language = "") { - - + + static $CURRENT_LANGUAGE; - + // old param order is deprecated if (!is_array($args)) { elgg_deprecated_notice( 'As of Elgg 1.8, the 2nd arg to elgg_echo() is an array of string replacements and the 3rd arg is the language.', 1.8 ); - + $language = $args; $args = array(); } - + if (!isset($this->CONFIG->translations)) { // this means we probably had an exception before translations were initialized $this->registerTranslations($this->defaultPath); } - + if (!$CURRENT_LANGUAGE) { $CURRENT_LANGUAGE = $this->getLanguage(); } @@ -84,16 +84,16 @@ function translate($message_key, $args = array(), $language = "") { $string = $message_key; _elgg_services()->logger->notice(sprintf('Missing English translation for "%s" language key', $message_key)); } - + // only pass through if we have arguments to allow backward compatibility // with manual sprintf() calls. if ($args) { $string = vsprintf($string, $args); } - + return $string; } - + /** * Add a translation. * @@ -108,11 +108,11 @@ function translate($message_key, $args = array(), $language = "") { * @return bool Depending on success */ function addTranslation($country_code, $language_array) { - + if (!isset($this->CONFIG->translations)) { $this->CONFIG->translations = array(); } - + $country_code = strtolower($country_code); $country_code = trim($country_code); if (is_array($language_array) && sizeof($language_array) > 0 && $country_code != "") { @@ -125,7 +125,7 @@ function addTranslation($country_code, $language_array) { } return false; } - + /** * Detect the current language being used by the current site or logged in user. * @@ -133,14 +133,14 @@ function addTranslation($country_code, $language_array) { */ function getCurrentLanguage() { $language = $this->getLanguage(); - + if (!$language) { $language = 'en'; } - + return $language; } - + /** * Gets the current language in use by the system or user. * @@ -149,28 +149,28 @@ function getCurrentLanguage() { function getLanguage() { $user = _elgg_services()->session->getLoggedInUser(); $language = false; - + if (($user) && ($user->language)) { $language = $user->language; } - + if ((!$language) && (isset($this->CONFIG->language)) && ($this->CONFIG->language)) { $language = $this->CONFIG->language; } - + if ($language) { return $language; } - + return false; } - + /** * @access private */ function loadTranslations() { - - + + if ($this->CONFIG->system_cache_enabled) { $loaded = true; $languages = array_unique(array('en', $this->getCurrentLanguage())); @@ -182,21 +182,21 @@ function loadTranslations() { $loaded = false; } } - + if ($loaded) { $this->CONFIG->i18n_loaded_from_cache = true; - // this is here to force + // this is here to force $this->CONFIG->language_paths[$this->defaultPath] = true; return; } } - + // load core translations from languages directory $this->registerTranslations($this->defaultPath); } - - - + + + /** * When given a full path, finds translation files and loads them * @@ -208,13 +208,13 @@ function loadTranslations() { */ function registerTranslations($path, $load_all = false) { $path = sanitise_filepath($path); - + // Make a note of this path just incase we need to register this language later if (!isset($this->CONFIG->language_paths)) { $this->CONFIG->language_paths = array(); } $this->CONFIG->language_paths[$path] = true; - + // Get the current language based on site defaults and user preference $current_language = $this->getCurrentLanguage(); _elgg_services()->logger->info("Translations loaded from: $path"); @@ -224,22 +224,22 @@ function registerTranslations($path, $load_all = false) { 'en.php', "$current_language.php" ); - + $load_language_files = array_unique($load_language_files); - + $handle = opendir($path); if (!$handle) { _elgg_services()->logger->error("Could not open language path: $path"); return false; } - + $return = true; while (false !== ($language = readdir($handle))) { // ignore bad files if (substr($language, 0, 1) == '.' || substr($language, -4) !== '.php') { continue; } - + if (in_array($language, $load_language_files) || $load_all) { $result = include_once($path . $language); if (!$result) { @@ -250,10 +250,10 @@ function registerTranslations($path, $load_all = false) { } } } - + return $return; } - + /** * Reload all translations from all registered paths. * @@ -264,13 +264,13 @@ function registerTranslations($path, $load_all = false) { * @return void */ function reloadAllTranslations() { - - + + static $LANG_RELOAD_ALL_RUN; if ($LANG_RELOAD_ALL_RUN) { return; } - + if ($this->CONFIG->i18n_loaded_from_cache) { $cache = elgg_get_system_cache(); $cache_dir = $cache->getVariable("cache_path"); @@ -292,10 +292,10 @@ function reloadAllTranslations() { $this->registerTranslations($path, true); } } - + $LANG_RELOAD_ALL_RUN = true; } - + /** * Return an array of installed translations as an associative * array "two letter code" => "native language name". @@ -303,13 +303,13 @@ function reloadAllTranslations() { * @return array */ function getInstalledTranslations() { - - + + // Ensure that all possible translations are loaded $this->reloadAllTranslations(); - + $installed = array(); - + foreach ($this->CONFIG->translations as $k => $v) { $installed[$k] = $this->translate($k, array(), $k); if (_elgg_services()->session->isAdminLoggedIn()) { @@ -319,10 +319,10 @@ function getInstalledTranslations() { } } } - + return $installed; } - + /** * Return the level of completeness for a given language code (compared to english) * @@ -331,28 +331,28 @@ function getInstalledTranslations() { * @return int */ function getLanguageCompleteness($language) { - - + + // Ensure that all possible translations are loaded $this->reloadAllTranslations(); - + $language = sanitise_string($language); - + $en = count($this->CONFIG->translations['en']); - + $missing = $this->getMissingLanguageKeys($language); if ($missing) { $missing = count($missing); } else { $missing = 0; } - + //$lang = count($this->CONFIG->translations[$language]); $lang = $en - $missing; - + return round(($lang / $en) * 100, 2); } - + /** * Return the translation keys missing from a given language, * or those that are identical to the english version. @@ -362,24 +362,24 @@ function getLanguageCompleteness($language) { * @return mixed */ function getMissingLanguageKeys($language) { - - + + // Ensure that all possible translations are loaded $this->reloadAllTranslations(); - + $missing = array(); - + foreach ($this->CONFIG->translations['en'] as $k => $v) { if ((!isset($this->CONFIG->translations[$language][$k])) || ($this->CONFIG->translations[$language][$k] == $this->CONFIG->translations['en'][$k])) { $missing[] = $k; } } - + if (count($missing)) { return $missing; } - + return false; } diff --git a/engine/classes/Elgg/Logger.php b/engine/classes/Elgg/Logger.php index 78efac7fdc8..dfe1c6a6df6 100644 --- a/engine/classes/Elgg/Logger.php +++ b/engine/classes/Elgg/Logger.php @@ -47,7 +47,7 @@ class Logger { */ public function __construct(\Elgg\PluginHooksService $hooks) { global $CONFIG; - + $this->CONFIG = $CONFIG; $this->hooks = $hooks; } @@ -69,7 +69,7 @@ public function setLevel($level) { /** * Get the current logging level - * + * * @return int */ public function getLevel() { @@ -176,7 +176,7 @@ public function dump($data, $display = true) { * @return void */ protected function process($data, $display, $level) { - + // plugin can return false to stop the default logging method $params = array( diff --git a/engine/classes/Elgg/Notifications/Event.php b/engine/classes/Elgg/Notifications/Event.php index 76fa0ce39b5..2f93a429e92 100644 --- a/engine/classes/Elgg/Notifications/Event.php +++ b/engine/classes/Elgg/Notifications/Event.php @@ -2,7 +2,7 @@ namespace Elgg\Notifications; /** * Notification event - * + * * @package Elgg.Core * @subpackage Notifications */ @@ -29,7 +29,7 @@ class Event { * @param \ElggData $object The object of the event (\ElggEntity) * @param string $action The name of the action (default: create) * @param \ElggUser $actor The user that caused the event (default: logged in user) - * + * * @throws \InvalidArgumentException */ public function __construct(\ElggData $object, $action, \ElggUser $actor = null) { @@ -63,7 +63,7 @@ public function getActor() { /** * Get the GUID of the actor - * + * * @return int */ public function getActorGUID() { @@ -114,7 +114,7 @@ public function getDescription() { /** * Notification event - * + * * @package Elgg.Core * @subpackage Notifications * @since 1.9.0 diff --git a/engine/classes/Elgg/Notifications/Notification.php b/engine/classes/Elgg/Notifications/Notification.php index bf7fb066922..56f2fd08fcc 100644 --- a/engine/classes/Elgg/Notifications/Notification.php +++ b/engine/classes/Elgg/Notifications/Notification.php @@ -3,7 +3,7 @@ /** * Notification container - * + * * @package Elgg.Core * @subpackage Notifications * @since 1.10 @@ -97,11 +97,11 @@ public function getRecipientGUID() { /** * Notification container - * + * * @package Elgg.Core * @subpackage Notifications * @since 1.9.0 - * + * * @deprecated 1.10 Use \Elgg\Notifications\Notification instead */ class Elgg_Notifications_Notification extends \Elgg\Notifications\Notification {} diff --git a/engine/classes/Elgg/Notifications/NotificationsService.php b/engine/classes/Elgg/Notifications/NotificationsService.php index 778b8b9f5de..0584d81c6ec 100644 --- a/engine/classes/Elgg/Notifications/NotificationsService.php +++ b/engine/classes/Elgg/Notifications/NotificationsService.php @@ -7,7 +7,7 @@ * WARNING: API IN FLUX. DO NOT USE DIRECTLY. * * @access private - * + * * @package Elgg.Core * @subpackage Notifications * @since 1.9.0 @@ -128,10 +128,10 @@ public function getMethods() { /** * Add a notification event to the queue - * + * * @param string $action Action name * @param string $type Type of the object of the action - * @param \ElggData $object The object of the action + * @param \ElggData $object The object of the action * @return void * @access private */ @@ -175,7 +175,7 @@ public function processQueue($stopTime) { $count = 0; // @todo grab mutex - + $ia = $this->access->setIgnoreAccess(true); while (time() < $stopTime) { @@ -307,7 +307,7 @@ protected function sendNotification(\Elgg\Notifications\Event $event, $guid, $me /** * Register a deprecated notification handler - * + * * @param string $method Method name * @param string $handler Handler callback * @return void @@ -318,7 +318,7 @@ public function registerDeprecatedHandler($method, $handler) { /** * Get a deprecated notification handler callback - * + * * @param string $method Method name * @return callback|null */ @@ -333,7 +333,7 @@ public function getDeprecatedHandler($method) { /** * Provides a way to incrementally wean Elgg's notifications code from the * global $NOTIFICATION_HANDLERS - * + * * @return array */ public function getMethodsAsDeprecatedGlobal() { @@ -346,7 +346,7 @@ public function getMethodsAsDeprecatedGlobal() { /** * Get the notification body using a pre-Elgg 1.9 plugin hook - * + * * @param \Elgg\Notifications\Notification $notification Notification * @param \Elgg\Notifications\Event $event Event * @param string $method Method @@ -373,7 +373,7 @@ protected function getDeprecatedNotificationBody(\Elgg\Notifications\Notificatio /** * Set message subject for deprecated notification code - * + * * @param string $type Entity type * @param string $subtype Entity subtype * @param string $subject Subject line @@ -396,7 +396,7 @@ public function setDeprecatedNotificationSubject($type, $subtype, $subject) { /** * Get the deprecated subject - * + * * @param string $type Entity type * @param string $subtype Entity subtype * @return string @@ -422,7 +422,7 @@ protected function getDeprecatedNotificationSubject($type, $subtype) { /** * Is someone using the deprecated override - * + * * @param \Elgg\Notifications\Event $event Event * @return boolean */ diff --git a/engine/classes/Elgg/Notifications/SubscriptionsService.php b/engine/classes/Elgg/Notifications/SubscriptionsService.php index 2b00bc892a8..a9572f869b4 100644 --- a/engine/classes/Elgg/Notifications/SubscriptionsService.php +++ b/engine/classes/Elgg/Notifications/SubscriptionsService.php @@ -18,7 +18,7 @@ class SubscriptionsService { const RELATIONSHIP_PREFIX = 'notify'; /** - * @var array Array of strings. Delivery names as registered with + * @var array Array of strings. Delivery names as registered with * elgg_register_notification_method() */ public $methods; @@ -105,9 +105,9 @@ public function getSubscriptionsForContainer($container_guid) { /** * Subscribe a user to notifications about a target entity - * + * * This method will return false if the subscription already exists. - * + * * @param int $userGuid The GUID of the user to subscribe to notifications * @param string $method The delivery method of the notifications * @param int $targetGuid The entity to receive notifications about @@ -123,7 +123,7 @@ public function addSubscription($userGuid, $method, $targetGuid) { /** * Unsubscribe a user to notifications about a target entity - * + * * @param int $userGuid The GUID of the user to unsubscribe to notifications * @param string $method The delivery method of the notifications to stop * @param int $targetGuid The entity to stop receiving notifications about @@ -165,7 +165,7 @@ protected function getSubscriptionRecords($container_guid) { /** * Get the relationship names for notifications - * + * * @return array */ protected function getMethodRelationships() { diff --git a/engine/classes/Elgg/PersistentLoginService.php b/engine/classes/Elgg/PersistentLoginService.php index 0a1ab550976..33e464266a5 100644 --- a/engine/classes/Elgg/PersistentLoginService.php +++ b/engine/classes/Elgg/PersistentLoginService.php @@ -57,7 +57,7 @@ public function __construct( * Make the user's login persistent * * @param \ElggUser $user The user who logged in - * + * * @return void */ public function makeLoginPersistent(\ElggUser $user) { @@ -71,7 +71,7 @@ public function makeLoginPersistent(\ElggUser $user) { /** * Remove the persisted login token from client and server - * + * * @return void */ public function removePersistentLogin() { @@ -89,7 +89,7 @@ public function removePersistentLogin() { * * @param \ElggUser $subject The user whose password changed * @param \ElggUser $modifier The user who changed the password - * + * * @return void */ public function handlePasswordChange(\ElggUser $subject, \ElggUser $modifier = null) { @@ -133,7 +133,7 @@ public function bootSession() { * Replace the user's token if it's a legacy hexadecimal token * * @param \ElggUser $logged_in_user The logged in user - * + * * @return void */ public function replaceLegacyToken(\ElggUser $logged_in_user) { @@ -150,7 +150,7 @@ public function replaceLegacyToken(\ElggUser $logged_in_user) { * Find a user with the given hash * * @param string $hash The hashed token - * + * * @return \ElggUser|null */ public function getUserFromHash($hash) { @@ -178,7 +178,7 @@ public function getUserFromHash($hash) { * * @param \ElggUser $user The user for whom we're storing the hash * @param string $hash The hashed token - * + * * @return void */ protected function storeHash(\ElggUser $user, $hash) { @@ -218,7 +218,7 @@ protected function removeHash($hash) { * * @param \DatabaseException $exception The exception to handle * @param string $default The value to return if the table doesn't exist yet - * + * * @return mixed * * @throws \DatabaseException @@ -236,7 +236,7 @@ protected function handleDbException(\DatabaseException $exception, $default = n * Remove all the hashes associated with a user * * @param \ElggUser $user The user for whom we're removing hashes - * + * * @return void */ protected function removeAllHashes(\ElggUser $user) { @@ -252,7 +252,7 @@ protected function removeAllHashes(\ElggUser $user) { * Create a hash from the token * * @param string $token The token to hash - * + * * @return string */ protected function hashToken($token) { @@ -265,7 +265,7 @@ protected function hashToken($token) { * Store the token in the client cookie (or remove the cookie) * * @param string $token Empty string to remove cookie - * + * * @return void */ protected function setCookie($token) { @@ -284,7 +284,7 @@ protected function setCookie($token) { * Store the token in the session (or remove it from the session) * * @param string $token The token to store in session. Empty string to remove. - * + * * @return void */ protected function setSession($token) { @@ -311,7 +311,7 @@ protected function generateToken() { * Is the given token a legacy MD5 hash? * * @param string $token The token to analyze - * + * * @return bool */ protected function isLegacyToken($token) { diff --git a/engine/classes/Elgg/PluginHooksService.php b/engine/classes/Elgg/PluginHooksService.php index 686bc669d12..f4fcee4883a 100644 --- a/engine/classes/Elgg/PluginHooksService.php +++ b/engine/classes/Elgg/PluginHooksService.php @@ -3,11 +3,11 @@ /** * WARNING: API IN FLUX. DO NOT USE DIRECTLY. - * + * * Use the elgg_* versions instead. - * + * * @access private - * + * * @package Elgg.Core * @subpackage Hooks * @since 1.9.0 @@ -22,7 +22,7 @@ class PluginHooksService extends \Elgg\HooksRegistrationService { */ public function trigger($hook, $type, $params = null, $returnvalue = null) { $hooks = $this->getOrderedHandlers($hook, $type); - + foreach ($hooks as $callback) { if (!is_callable($callback)) { if ($this->logger) { @@ -38,7 +38,7 @@ public function trigger($hook, $type, $params = null, $returnvalue = null) { $returnvalue = $temp_return_value; } } - + return $returnvalue; } } diff --git a/engine/classes/Elgg/Queue/DatabaseQueue.php b/engine/classes/Elgg/Queue/DatabaseQueue.php index d47681b6452..c049f2f8572 100644 --- a/engine/classes/Elgg/Queue/DatabaseQueue.php +++ b/engine/classes/Elgg/Queue/DatabaseQueue.php @@ -7,7 +7,7 @@ * WARNING: API IN FLUX. DO NOT USE DIRECTLY. * * @access private - * + * * @package Elgg.Core * @subpackage Queue * @since 1.9.0 @@ -52,7 +52,7 @@ public function enqueue($item) { */ public function dequeue() { $prefix = $this->db->getTablePrefix(); - $update = "UPDATE {$prefix}queue + $update = "UPDATE {$prefix}queue SET worker = '$this->workerId' WHERE name = '$this->name' AND worker IS NULL ORDER BY id ASC LIMIT 1"; diff --git a/engine/classes/Elgg/Queue/MemoryQueue.php b/engine/classes/Elgg/Queue/MemoryQueue.php index 4d71d86155f..ae942fbbc51 100644 --- a/engine/classes/Elgg/Queue/MemoryQueue.php +++ b/engine/classes/Elgg/Queue/MemoryQueue.php @@ -3,11 +3,11 @@ /** * FIFO queue that is memory based (not persistent) - * + * * WARNING: API IN FLUX. DO NOT USE DIRECTLY. * * @access private - * + * * @package Elgg.Core * @subpackage Queue * @since 1.9.0 diff --git a/engine/classes/Elgg/Queue/Queue.php b/engine/classes/Elgg/Queue/Queue.php index 3ef2c52cfbf..581442d5776 100644 --- a/engine/classes/Elgg/Queue/Queue.php +++ b/engine/classes/Elgg/Queue/Queue.php @@ -7,7 +7,7 @@ * WARNING: API IN FLUX. DO NOT USE DIRECTLY. * * @access private - * + * * @package Elgg.Core * @subpackage Queue * @since 1.9.0 @@ -30,7 +30,7 @@ public function dequeue(); /** * Clear all items from the queue - * + * * @return void */ public function clear(); diff --git a/engine/classes/Elgg/Router.php b/engine/classes/Elgg/Router.php index 6d8c499b915..9b4e58ee31c 100644 --- a/engine/classes/Elgg/Router.php +++ b/engine/classes/Elgg/Router.php @@ -114,7 +114,7 @@ public function unregisterPageHandler($identifier) { /** * Get page handlers as array of identifier => callback - * + * * @return array */ public function getPageHandlers() { diff --git a/engine/classes/Elgg/Structs/ArrayCollection.php b/engine/classes/Elgg/Structs/ArrayCollection.php index 4d9b1901676..e8eac2c4bbb 100644 --- a/engine/classes/Elgg/Structs/ArrayCollection.php +++ b/engine/classes/Elgg/Structs/ArrayCollection.php @@ -5,7 +5,7 @@ /** * Uses native PHP array to implement the Collection interface. - * + * * @package Elgg.Core * @subpackage Structs * @since 1.10 @@ -15,16 +15,16 @@ final class ArrayCollection implements Collection { /** @var array */ private $items; - + /** * Constructor - * + * * @param array $items The set of items in the collection */ public function __construct(array $items = array()) { $this->items = $items; } - + /** @inheritDoc */ public function contains($item) { return in_array($item, $this->items, true); @@ -34,30 +34,30 @@ public function contains($item) { public function count() { return count($this->items); } - + /** @inheritDoc */ public function current() { return current($this->items); } - + /** @inheritDoc */ public function filter(callable $filter) { $results = array(); - + foreach ($this->items as $item) { if ($filter($item)) { $results[] = $item; } } - + return new ArrayCollection($results); } - + /** @inheritDoc */ public function key() { return key($this->items); } - + /** @inheritDoc */ public function map(callable $mapper) { $results = array(); @@ -66,17 +66,17 @@ public function map(callable $mapper) { } return new ArrayCollection($results); } - + /** @inheritDoc */ public function next() { return next($this->items); } - + /** @inheritDoc */ public function rewind() { reset($this->items); } - + /** @inheritDoc */ public function valid() { return key($this->items) !== NULL; diff --git a/engine/classes/Elgg/Structs/Collection.php b/engine/classes/Elgg/Structs/Collection.php index f03ea361446..0356c5cfe26 100644 --- a/engine/classes/Elgg/Structs/Collection.php +++ b/engine/classes/Elgg/Structs/Collection.php @@ -6,19 +6,19 @@ /** * A read-only interface to a (possibly mutable) group of items. - * + * * Read-only provides some nice guarantees that can be harnessed for things * like caching, lazy evaluation, respecting HTTP semantics of GET/HEAD, etc. - * + * * We do not extend ArrayAccess, because: * * Collections aren't writable by default * * Collections don't have a defined order by default * * Collections aren't all Maps by default ;) - * + * * Extensions may provide one or more of these features. - * + * * TODO(ewinslow): If PHP had generics support, we'd add that here. - * + * * DO NOT EXTEND OR IMPLEMENT this interface outside of this package. * Doing so would cause additions to the API to be breaking changes, which is * not what we want. You have a couple of options for how to proceed: @@ -33,21 +33,21 @@ * @access private */ interface Collection extends Countable, Iterator { - + /** * Returns a new collection only containing the elements which pass the filter. - * + * * @param callable $filter Receives an item. Return true to keep the item. - * + * * @return Collection */ public function filter(callable $filter); - + /** * Returns true iff the item is in this collection at least once. - * - * @param mixed $item The object or value to check for - * + * + * @param mixed $item The object or value to check for + * * @return boolean */ public function contains($item); @@ -55,11 +55,11 @@ public function contains($item); /** * Take items of the collection and return a new collection * with all the items having the $mapper applied to them. - * + * * The callable is not guaranteed to execute immediately for each item. - * + * * @param callable $mapper Returns the mapped value - * + * * @return Collection */ public function map(callable $mapper); diff --git a/engine/classes/Elgg/UpgradeService.php b/engine/classes/Elgg/UpgradeService.php index 153e59f9aa7..01d92b2ee9f 100644 --- a/engine/classes/Elgg/UpgradeService.php +++ b/engine/classes/Elgg/UpgradeService.php @@ -16,7 +16,7 @@ class UpgradeService { /** * Global Elgg configuration - * + * * @var \stdClass */ private $CONFIG; @@ -335,7 +335,7 @@ protected function bootstrap17to18() { * @return bool */ protected function getUpgradeMutex() { - + if (!$this->isUpgradeLocked()) { // lock it @@ -354,7 +354,7 @@ protected function getUpgradeMutex() { * @return void */ public function releaseUpgradeMutex() { - + _elgg_services()->db->deleteData("drop table {$this->CONFIG->dbprefix}upgrade_lock"); _elgg_services()->logger->notice('Upgrade unlocked.'); } @@ -365,7 +365,7 @@ public function releaseUpgradeMutex() { * @return bool */ public function isUpgradeLocked() { - + $is_locked = count(_elgg_services()->db->getData("SHOW TABLES LIKE '{$this->CONFIG->dbprefix}upgrade_lock'")); @@ -395,7 +395,7 @@ public function isUpgradeLocked() { * @deprecated 1.8 Use PHP upgrades for sql changes. */ protected function dbUpgrade($version, $fromdir = "", $quiet = false) { - + $version = (int) $version; diff --git a/engine/classes/Elgg/ViewsService.php b/engine/classes/Elgg/ViewsService.php index dc79c9435f0..a4624f25945 100644 --- a/engine/classes/Elgg/ViewsService.php +++ b/engine/classes/Elgg/ViewsService.php @@ -30,7 +30,7 @@ class ViewsService { /** * Global Elgg configuration - * + * * @var \stdClass */ private $CONFIG; @@ -50,7 +50,7 @@ public function __construct(\Elgg\PluginHooksService $hooks, \Elgg\Logger $logge /** * Get the user object in a wrapper - * + * * @return \Elgg\DeprecationWrapper|null */ protected function getUserWrapper() { @@ -98,7 +98,7 @@ public function autoregisterViews($view_base, $folder, $base_location_path, $vie * @access private */ public function getViewLocation($view, $viewtype = '') { - + if (empty($viewtype)) { $viewtype = elgg_get_viewtype(); @@ -119,7 +119,7 @@ public function getViewLocation($view, $viewtype = '') { * @access private */ public function setViewLocation($view, $location, $viewtype = '') { - + if (empty($viewtype)) { $viewtype = 'default'; @@ -144,7 +144,7 @@ public function setViewLocation($view, $location, $viewtype = '') { * @access private */ public function registerViewtypeFallback($viewtype) { - + if (!isset($this->CONFIG->viewtype)) { $this->CONFIG->viewtype = new \stdClass; @@ -161,7 +161,7 @@ public function registerViewtypeFallback($viewtype) { * @access private */ public function doesViewtypeFallback($viewtype) { - + if (isset($this->CONFIG->viewtype) && isset($this->CONFIG->viewtype->fallback)) { return in_array($viewtype, $this->CONFIG->viewtype->fallback); @@ -195,7 +195,7 @@ public function renderDeprecatedView($view, array $vars, $suggestion, $version) * @access private */ public function renderView($view, array $vars = array(), $bypass = false, $viewtype = '', $issue_missing_notice = true) { - + if (!is_string($view) || !is_string($viewtype)) { $this->logger->log("View and Viewtype in views must be a strings: $view", 'NOTICE'); @@ -343,7 +343,7 @@ protected function fileExists($path) { /** * Includes view PHP or static file - * + * * @param string $view The view name * @param array $vars Variables passed to view * @param string $viewtype The viewtype @@ -377,7 +377,7 @@ private function renderViewFile($view, array $vars, $viewtype, $issue_missing_no * @access private */ public function viewExists($view, $viewtype = '', $recurse = true) { - + // Detect view type if ($viewtype === '' || !_elgg_is_valid_viewtype($viewtype)) { @@ -423,7 +423,7 @@ public function viewExists($view, $viewtype = '', $recurse = true) { * @access private */ public function extendView($view, $view_extension, $priority = 501, $viewtype = '') { - + if (!isset($this->CONFIG->views)) { $this->CONFIG->views = (object) array( @@ -450,7 +450,7 @@ public function extendView($view, $view_extension, $priority = 501, $viewtype = * @access private */ public function unextendView($view, $view_extension) { - + if (!isset($this->CONFIG->views)) { return false; @@ -478,7 +478,7 @@ public function unextendView($view, $view_extension) { * @access private */ public function registerCacheableView($view) { - + if (!isset($this->CONFIG->views)) { $this->CONFIG->views = new \stdClass; @@ -495,7 +495,7 @@ public function registerCacheableView($view) { * @access private */ public function isCacheableView($view) { - + if (!isset($this->CONFIG->views)) { $this->CONFIG->views = new \stdClass; diff --git a/engine/classes/ElggAutoP.php b/engine/classes/ElggAutoP.php index 0ca8401b9ee..d113c3fc4cb 100644 --- a/engine/classes/ElggAutoP.php +++ b/engine/classes/ElggAutoP.php @@ -7,7 +7,7 @@ * * In DIV elements, Ps are only added when there would be at * least two of them. - * + * * @package Elgg.Core * @subpackage Output */ @@ -25,8 +25,8 @@ class ElggAutoP { */ protected $_xpath = null; - protected $_blocks = 'address article area aside blockquote caption col colgroup dd - details div dl dt fieldset figure figcaption footer form h1 h2 h3 h4 h5 h6 header + protected $_blocks = 'address article area aside blockquote caption col colgroup dd + details div dl dt fieldset figure figcaption footer form h1 h2 h3 h4 h5 h6 header hr hgroup legend map math menu nav noscript p pre section select style summary table tbody td tfoot th thead tr ul ol option li'; @@ -95,7 +95,7 @@ public function process($html) { // Do not load entities. May be unnecessary, better safe than sorry $disable_load_entities = libxml_disable_entity_loader(true); - if (!$this->_doc->loadHTML("_doc->loadHTML("{$html}" . "")) { @@ -174,14 +174,14 @@ public function process($html) { $bodyStart = strpos($html, ''); $bodyEnd = strpos($html, '', $bodyStart + 6); $html = substr($html, $bodyStart + 6, $bodyEnd - $bodyStart - 6); - + // strip AUTOPs that should be removed $html = preg_replace('@(.*?)@', '\\1', $html); // commit to converting AUTOPs to Ps $html = str_replace('', "\n

", $html); $html = str_replace('', "

\n", $html); - + $html = str_replace('
', '
', $html); $html = str_replace($this->_unique . 'AMP', '&', $html); return $html; diff --git a/engine/classes/ElggBatch.php b/engine/classes/ElggBatch.php index 28c2e89224c..46053bb4ae6 100644 --- a/engine/classes/ElggBatch.php +++ b/engine/classes/ElggBatch.php @@ -186,7 +186,7 @@ class ElggBatch */ public function __construct($getter, $options, $callback = null, $chunk_size = 25, $inc_offset = true) { - + $this->getter = $getter; $this->options = $options; $this->callback = $callback; diff --git a/engine/classes/ElggComment.php b/engine/classes/ElggComment.php index 61b71a3c20f..fd12c57c814 100644 --- a/engine/classes/ElggComment.php +++ b/engine/classes/ElggComment.php @@ -1,7 +1,7 @@ getOwnerGUID() == $user->getGUID()) { $return = true; } - + if ($this->getContainerGUID() == $user->getGUID()) { $return = true; } - + if ($this->getGUID() == $user->getGUID()) { $return = true; } @@ -1323,7 +1323,7 @@ public function getTimeUpdated() { * @return string The URL of the entity */ public function getURL() { - + $url = ""; // @todo remove when elgg_register_entity_url_handler() has been removed @@ -1543,10 +1543,10 @@ public function save() { } } } - + return false; } - + /** * Create a new entry in the entities table. * @@ -1568,7 +1568,7 @@ protected function create() { if ($type == "") { throw new \InvalidParameterException("Entity type must be set."); } - + $subtype = $this->attributes['subtype']; $subtype_id = add_subtype($type, $subtype); $owner_guid = (int)$this->attributes['owner_guid']; @@ -1581,7 +1581,7 @@ protected function create() { $site_guid = $CONFIG->site_guid; } $site_guid = (int)$site_guid; - + $container_guid = $this->attributes['container_guid']; if ($container_guid == 0) { $container_guid = $owner_guid; @@ -1596,14 +1596,14 @@ protected function create() { if ($owner && !$owner->canWriteToContainer(0, $type, $subtype)) { return false; } - + if ($owner_guid != $container_guid) { $container = $this->getContainerEntity(); if ($container && !$container->canWriteToContainer(0, $type, $subtype)) { return false; } } - + $result = $this->getDatabase()->insertData("INSERT into {$CONFIG->dbprefix}entities (type, subtype, owner_guid, site_guid, container_guid, access_id, time_created, time_updated, last_action) @@ -1614,7 +1614,7 @@ protected function create() { if (!$result) { throw new \IOException("Unable to save new object's base entity information!"); } - + // for BC with 1.8, ->subtype always returns ID, ->getSubtype() the string $this->attributes['subtype'] = (int)$subtype_id; $this->attributes['guid'] = (int)$result; @@ -1629,7 +1629,7 @@ protected function create() { foreach ($this->temp_metadata as $name => $value) { $this->$name = $value; } - + $this->temp_metadata = array(); } @@ -1638,7 +1638,7 @@ protected function create() { foreach ($this->temp_annotations as $name => $value) { $this->annotate($name, $value); } - + $this->temp_annotations = array(); } @@ -1647,12 +1647,12 @@ protected function create() { foreach ($this->temp_private_settings as $name => $value) { $this->setPrivateSetting($name, $value); } - + $this->temp_private_settings = array(); } _elgg_cache_entity($this); - + return $result; } @@ -1700,7 +1700,7 @@ protected function update() { if ($access_id == ACCESS_DEFAULT) { throw new \InvalidParameterException('ACCESS_DEFAULT is not a valid access level. See its documentation in elgglib.php'); } - + $ret = $this->getDatabase()->updateData("UPDATE {$CONFIG->dbprefix}entities set owner_guid='$owner_guid', access_id='$access_id', container_guid='$container_guid', time_created='$time_created', @@ -1780,7 +1780,7 @@ protected function load($guid) { /** * Stores non-attributes from the loading of the entity as volatile data - * + * * @param array $data Key value array * @return void */ @@ -1789,7 +1789,7 @@ protected function loadAdditionalSelectValues(array $data) { $this->setVolatileData("select:$name", $value); } } - + /** * Load new data from database into existing entity. Overwrites data but * does not change values not included in the latest data. @@ -1797,7 +1797,7 @@ protected function loadAdditionalSelectValues(array $data) { * @internal This is used when the same entity is selected twice during a * request in case different select clauses were used to load different data * into volatile data. - * + * * @param \stdClass $row DB row with new entity data * @return bool * @access private @@ -1832,29 +1832,29 @@ public function disable($reason = "", $recursive = true) { if (!$this->guid) { return false; } - + if (!_elgg_services()->events->trigger('disable', $this->type, $this)) { return false; } - + if (!$this->canEdit()) { return false; } _elgg_invalidate_cache_for_entity($this->guid); - + if ($reason) { $this->disable_reason = $reason; } global $CONFIG; $guid = (int)$this->guid; - + if ($recursive) { $hidden = access_get_show_hidden_status(); access_show_hidden_entities(true); $ia = elgg_set_ignore_access(true); - + $sub_entities = $this->getDatabase()->getData("SELECT * FROM {$CONFIG->dbprefix}entities WHERE ( container_guid = $guid @@ -1868,7 +1868,7 @@ public function disable($reason = "", $recursive = true) { $e->disable($reason); } } - + access_show_hidden_entities($hidden); elgg_set_ignore_access($ia); } @@ -1903,21 +1903,21 @@ public function enable($recursive = true) { if (!$guid) { return false; } - + if (!_elgg_services()->events->trigger('enable', $this->type, $this)) { return false; } - + if (!$this->canEdit()) { return false; } - + global $CONFIG; - + // Override access only visible entities $old_access_status = access_get_show_hidden_status(); access_show_hidden_entities(true); - + $result = $this->getDatabase()->updateData("UPDATE {$CONFIG->dbprefix}entities SET enabled = 'yes' WHERE guid = $guid"); @@ -1939,9 +1939,9 @@ public function enable($recursive = true) { remove_entity_relationship($e->guid, 'disabled_with', $guid); } } - + access_show_hidden_entities($old_access_status); - + if ($result) { $this->attributes['enabled'] = 'yes'; _elgg_services()->events->trigger('enable:after', $this->type, $this); @@ -1983,17 +1983,17 @@ public function delete($recursive = true) { if (!$guid) { return false; } - + if (!_elgg_services()->events->trigger('delete', $this->type, $this)) { return false; } - + if (!$this->canEdit()) { return false; } _elgg_invalidate_cache_for_entity($guid); - + // If memcache is available then delete this entry from the cache static $newentity_cache; if ((!$newentity_cache) && (is_memcache_available())) { @@ -2035,7 +2035,7 @@ public function delete($recursive = true) { $entity_disable_override = access_get_show_hidden_status(); access_show_hidden_entities(true); $ia = elgg_set_ignore_access(true); - + // Now delete the entity itself $this->deleteMetadata(); $this->deleteOwnedMetadata(); @@ -2091,7 +2091,7 @@ public function toObject() { /** * Prepare an object copy for toObject() - * + * * @param \stdClass $object Object representation of the entity * @return \stdClass */ @@ -2214,7 +2214,7 @@ public function getCalendarStartTime() { /** * Returns the end timestamp. - * + * * @return int * @deprecated 1.9 */ diff --git a/engine/classes/ElggExtender.php b/engine/classes/ElggExtender.php index f15b4d340e7..f393129ebcc 100644 --- a/engine/classes/ElggExtender.php +++ b/engine/classes/ElggExtender.php @@ -11,7 +11,7 @@ * @subpackage DataModel.Extender * @see \ElggAnnotation * @see \ElggMetadata - * + * * @property string $type annotation or metadata (read-only after save) * @property int $id The unique identifier (read-only) * @property int $entity_guid The GUID of the entity that this extender describes @@ -59,7 +59,7 @@ public function __set($name, $value) { /** * Set the value of the extender - * + * * @param mixed $value The value being set * @param string $value_type The type of the : 'integer' or 'text' * @return void diff --git a/engine/classes/ElggFile.php b/engine/classes/ElggFile.php index 9b72b2c22c0..e744541eb82 100644 --- a/engine/classes/ElggFile.php +++ b/engine/classes/ElggFile.php @@ -273,13 +273,13 @@ public function close() { */ public function delete() { $fs = $this->getFilestore(); - + $result = $fs->delete($this); - + if ($this->getGUID() && $result) { $result = parent::delete(); } - + return $result; } diff --git a/engine/classes/ElggGroup.php b/engine/classes/ElggGroup.php index 6a5ddd7d56b..c800a39c290 100644 --- a/engine/classes/ElggGroup.php +++ b/engine/classes/ElggGroup.php @@ -5,7 +5,7 @@ * * @package Elgg.Core * @subpackage Groups - * + * * @property string $name A short name that captures the purpose of the group * @property string $description A longer body of content that gives more details about the group */ @@ -77,7 +77,7 @@ public function __construct($row = null) { public function getDisplayName() { return $this->name; } - + /** * {@inheritdoc} */ @@ -433,12 +433,12 @@ public function isMember(\ElggUser $user = null) { */ public function join(\ElggUser $user) { $result = add_entity_relationship($user->guid, 'member', $this->guid); - + if ($result) { $params = array('group' => $this, 'user' => $user); _elgg_services()->events->trigger('join', 'group', $params); } - + return $result; } @@ -487,27 +487,27 @@ protected function load($guid) { */ protected function update() { global $CONFIG; - + if (!parent::update()) { return false; } - + $guid = (int)$this->guid; $name = sanitize_string($this->name); $description = sanitize_string($this->description); - + $query = "UPDATE {$CONFIG->dbprefix}groups_entity set" . " name='$name', description='$description' where guid=$guid"; return $this->getDatabase()->updateData($query) !== false; } - + /** * {@inheritdoc} */ protected function create() { global $CONFIG; - + $guid = parent::create(); $name = sanitize_string($this->name); $description = sanitize_string($this->description); @@ -520,7 +520,7 @@ protected function create() { // TODO(evan): Throw an exception here? return false; } - + return $guid; } diff --git a/engine/classes/ElggInstaller.php b/engine/classes/ElggInstaller.php index 879dd53ff5e..a882083a8c6 100644 --- a/engine/classes/ElggInstaller.php +++ b/engine/classes/ElggInstaller.php @@ -28,7 +28,7 @@ * @subpackage Installer */ class ElggInstaller { - + protected $steps = array( 'welcome', 'requirements', @@ -51,7 +51,7 @@ class ElggInstaller { /** * Global Elgg configuration - * + * * @var \stdClass */ private $CONFIG; @@ -82,7 +82,7 @@ public function __construct() { _elgg_services()->translator->registerTranslations("{$this->getElggRoot()}/install/languages/", TRUE); } - + /** * @return string The absolute path to Elgg's root directory */ @@ -155,7 +155,7 @@ public function setAutoLogin($flag) { * @throws InstallationException */ public function batchInstall(array $params, $createHtaccess = FALSE) { - + restore_error_handler(); restore_exception_handler(); @@ -410,7 +410,7 @@ protected function database($submissionVars) { * @return void */ protected function settings($submissionVars) { - + $formVars = array( 'sitename' => array( @@ -511,7 +511,7 @@ protected function admin($submissionVars) { 'required' => TRUE, ), ); - + if ($this->isAction) { do { if (!$this->validateAdminVars($submissionVars, $formVars)) { @@ -530,7 +530,7 @@ protected function admin($submissionVars) { } // bit of a hack to get the password help to show right number of characters - + $lang = _elgg_services()->translator->getCurrentLanguage(); $this->CONFIG->translations[$lang]['install:admin:help:password1'] = sprintf($this->CONFIG->translations[$lang]['install:admin:help:password1'], @@ -618,7 +618,7 @@ protected function getNextStepUrl($currentStep) { * @throws InstallationException */ protected function setInstallStatus() { - + if (!is_readable("{$this->CONFIG->path}engine/settings.php")) { return; @@ -737,7 +737,7 @@ protected function resumeInstall($step) { * @return void */ protected function bootstrapEngine() { - + require_once $this->CONFIG->path . 'engine/load.php'; } @@ -771,7 +771,7 @@ protected function finishBootstraping($step) { if ($stepIndex > $dbIndex) { // once the database has been created, load rest of engine - + $lib_dir = $this->CONFIG->path . 'engine/lib/'; $this->loadSettingsFile(); @@ -856,7 +856,7 @@ protected function bootstrapConfig() { $this->CONFIG->sitename = ''; $this->CONFIG->sitedescription = ''; } - + /** * @return bool Whether the install process is encrypted. */ @@ -875,7 +875,7 @@ private function isHttps() { */ protected function getBaseUrl() { $protocol = $this->isHttps() ? 'https' : 'http'; - + if (isset($_SERVER["SERVER_PORT"])) { $port = ':' . $_SERVER["SERVER_PORT"]; } else { @@ -899,7 +899,7 @@ protected function getBaseUrl() { * @throws InstallationException */ protected function loadSettingsFile() { - + if (!include_once("{$this->CONFIG->path}engine/settings.php")) { throw new InstallationException(_elgg_services()->translator->translate('InstallationException:CannotLoadSettings')); @@ -954,7 +954,7 @@ protected function makeFormSticky($formVars, $submissionVars) { * @return bool */ protected function checkEngineDir(&$report) { - + $writable = is_writable("{$this->CONFIG->path}engine"); if (!$writable) { @@ -978,7 +978,7 @@ protected function checkEngineDir(&$report) { * @return bool */ protected function checkSettingsFile(&$report = array()) { - + if (!file_exists("{$this->CONFIG->path}engine/settings.php")) { return FALSE; @@ -1119,7 +1119,7 @@ protected function checkPhpDirectives(&$phpReport) { * @return void */ protected function checkRewriteRules(&$report) { - + $tester = new ElggRewriteTester(); $url = _elgg_services()->config->getSiteUrl() . "rewrite.php"; @@ -1246,7 +1246,7 @@ protected function checkDatabaseSettings($user, $password, $dbname, $host) { * @return bool */ protected function createSettingsFile($params) { - + $templateFile = "{$this->CONFIG->path}engine/settings.example.php"; $template = file_get_contents($templateFile); @@ -1275,7 +1275,7 @@ protected function createSettingsFile($params) { * @return bool */ protected function connectToDatabase() { - + if (!include_once("{$this->CONFIG->path}engine/settings.php")) { register_error('Elgg could not load the settings file. It does not exist or there is a file permissions issue.'); @@ -1303,7 +1303,7 @@ protected function connectToDatabase() { * @return bool */ protected function installDatabase() { - + try { _elgg_services()->db->runSqlScript("{$this->CONFIG->path}engine/schema/mysql.sql"); @@ -1328,7 +1328,7 @@ protected function installDatabase() { * * @param array &$submissionVars Submitted vars * @param array $formVars Variables in the form - * + * * @return bool */ protected function createDataDirectory(&$submissionVars, $formVars) { @@ -1366,7 +1366,7 @@ protected function createDataDirectory(&$submissionVars, $formVars) { * @return bool */ protected function validateSettingsVars($submissionVars, $formVars) { - + foreach ($formVars as $field => $info) { $submissionVars[$field] = trim($submissionVars[$field]); @@ -1436,7 +1436,7 @@ protected function validateSettingsVars($submissionVars, $formVars) { * @return bool */ protected function saveSiteSettings($submissionVars) { - + // ensure that file path, data path, and www root end in / $submissionVars['path'] = sanitise_filepath($submissionVars['path']); diff --git a/engine/classes/ElggMemcache.php b/engine/classes/ElggMemcache.php index 30239afb327..76c016f2bdd 100644 --- a/engine/classes/ElggMemcache.php +++ b/engine/classes/ElggMemcache.php @@ -8,7 +8,7 @@ class ElggMemcache extends \ElggSharedMemoryCache { /** * Global Elgg configuration - * + * * @var \stdClass */ private $CONFIG; diff --git a/engine/classes/ElggMenuBuilder.php b/engine/classes/ElggMenuBuilder.php index 71feffaf209..42066126076 100644 --- a/engine/classes/ElggMenuBuilder.php +++ b/engine/classes/ElggMenuBuilder.php @@ -82,7 +82,7 @@ protected function selectFromContext() { /** * Group the menu items into sections - * + * * @return void */ protected function setupSections() { diff --git a/engine/classes/ElggMenuItem.php b/engine/classes/ElggMenuItem.php index 637acd3c445..d400f0dde97 100644 --- a/engine/classes/ElggMenuItem.php +++ b/engine/classes/ElggMenuItem.php @@ -132,7 +132,7 @@ public static function factory($options) { $options['contexts'] = $options['context']; unset($options['context']); } - + // make sure contexts is set correctly if (isset($options['contexts'])) { $item->setContext($options['contexts']); @@ -157,7 +157,7 @@ public static function factory($options) { $item->setData($options['data']); unset($options['data']); } - + foreach ($options as $key => $value) { if (isset($item->data[$key])) { $item->data[$key] = $value; @@ -222,7 +222,7 @@ public function getName() { /** * Set the display text of the menu item - * + * * @param string $text The display text as HTML * @return void */ @@ -443,7 +443,7 @@ public function addItemClass($class) { // @codingStandardsIgnoreStart /** * Add additional classes - * + * * @param array $current The current array of classes * @param mixed $additional Additional classes (either array of string) * @return void @@ -540,7 +540,7 @@ public function getParentName() { /** * Set the parent menu item - * + * * This is reserved for the \ElggMenuBuilder. * * @param \ElggMenuItem $parent The parent of this menu item @@ -553,7 +553,7 @@ public function setParent($parent) { /** * Get the parent menu item - * + * * This is reserved for the \ElggMenuBuilder. * * @return \ElggMenuItem or null @@ -565,7 +565,7 @@ public function getParent() { /** * Add a child menu item - * + * * This is reserved for the \ElggMenuBuilder. * * @param \ElggMenuItem $item A child menu item @@ -578,7 +578,7 @@ public function addChild($item) { /** * Set the menu item's children - * + * * This is reserved for the \ElggMenuBuilder. * * @param array $children Array of \ElggMenuItems @@ -591,7 +591,7 @@ public function setChildren($children) { /** * Get the children menu items - * + * * This is reserved for the \ElggMenuBuilder. * * @return array @@ -603,7 +603,7 @@ public function getChildren() { /** * Sort the children - * + * * This is reserved for the \ElggMenuBuilder. * * @param string $sortFunction A function that is passed to usort() @@ -619,7 +619,7 @@ public function sortChildren($sortFunction) { /** * Get all the values for this menu item. Useful for rendering. - * + * * @return array * @since 1.9.0 */ diff --git a/engine/classes/ElggMetadata.php b/engine/classes/ElggMetadata.php index 1af41f392bc..d699ca63674 100644 --- a/engine/classes/ElggMetadata.php +++ b/engine/classes/ElggMetadata.php @@ -41,7 +41,7 @@ public function __construct($row = null) { // Create from db row if ($row instanceof \stdClass) { $metadata = $row; - + $objarray = (array) $metadata; foreach ($objarray as $key => $value) { $this->attributes[$key] = $value; diff --git a/engine/classes/ElggObject.php b/engine/classes/ElggObject.php index 280361ad8af..435cd92c852 100644 --- a/engine/classes/ElggObject.php +++ b/engine/classes/ElggObject.php @@ -14,7 +14,7 @@ * * @package Elgg.Core * @subpackage DataModel.Object - * + * * @property string $title The title, name, or summary of this object * @property string $description The body, description, or content of the object * @property array $tags Tags that describe the object (metadata) @@ -123,7 +123,7 @@ protected function create() { } $title = sanitize_string($this->title); $description = sanitize_string($this->description); - + $query = "INSERT into {$CONFIG->dbprefix}objects_entity (guid, title, description) values ($guid, '$title', '$description')"; @@ -132,7 +132,7 @@ protected function create() { // TODO(evan): Throw an exception here? return false; } - + return $guid; } @@ -145,7 +145,7 @@ protected function update() { if (!parent::update()) { return false; } - + $guid = (int)$this->guid; $title = sanitize_string($this->title); $description = sanitize_string($this->description); diff --git a/engine/classes/ElggPAM.php b/engine/classes/ElggPAM.php index 029db3b2e1c..1146c337ebf 100644 --- a/engine/classes/ElggPAM.php +++ b/engine/classes/ElggPAM.php @@ -18,7 +18,7 @@ class ElggPAM { /** * \ElggPAM constructor - * + * * @param string $policy PAM policy type: user, api, or plugin-defined policies */ public function __construct($policy) { @@ -89,7 +89,7 @@ public function authenticate($credentials = array()) { /** * Get a failure message to display to user - * + * * @return string */ public function getFailureMessage() { diff --git a/engine/classes/ElggPlugin.php b/engine/classes/ElggPlugin.php index 23db7110e27..0cea1996e34 100644 --- a/engine/classes/ElggPlugin.php +++ b/engine/classes/ElggPlugin.php @@ -58,7 +58,7 @@ public function __construct($path) { $this->path = _elgg_services()->config->getPluginsPath() . $this->getID(); } else { $this->initializeAttributes(); - + $mod_dir = _elgg_services()->config->getPluginsPath(); // not a full path, so assume a directory name and use the default path @@ -76,7 +76,7 @@ public function __construct($path) { // check if we're loading an existing plugin $existing_plugin = elgg_get_plugin_from_id($plugin_id); - + if ($existing_plugin) { $this->load($existing_plugin->guid); } @@ -97,7 +97,7 @@ public function save() { $this->attributes['site_guid'] = $site->guid; $this->attributes['owner_guid'] = $site->guid; $this->attributes['container_guid'] = $site->guid; - + if (parent::save()) { // make sure we have a priority $priority = $this->getPriority(); @@ -391,7 +391,7 @@ public function getUserSetting($name, $user_guid = 0, $default = null) { } $name = _elgg_namespace_plugin_private_setting('user_setting', $name, $this->getID()); - + $val = get_private_setting($user->guid, $name); return $val !== null ? $val : $default; } @@ -726,7 +726,7 @@ public function start($flags) { if ($flags & ELGG_PLUGIN_REGISTER_CLASSES) { $this->registerClasses(); } - + // include start file if ($flags & ELGG_PLUGIN_INCLUDE_START) { $this->includeFile('start.php'); diff --git a/engine/classes/ElggPluginManifest.php b/engine/classes/ElggPluginManifest.php index e3e57ff5e7e..b5581fdc495 100644 --- a/engine/classes/ElggPluginManifest.php +++ b/engine/classes/ElggPluginManifest.php @@ -57,7 +57,7 @@ class ElggPluginManifest { 'version' => '', 'comparison' => 'ge' ); - + /** * The expected structure of a requires php_version dependency element */ @@ -113,7 +113,7 @@ class ElggPluginManifest { 'description' => '', 'path' => '' ); - + /** * The expected structure of a contributor element */ @@ -423,7 +423,7 @@ public function getScreenshots() { return $normalized; } - + /** * Return the contributors listed. * @@ -559,7 +559,7 @@ private function normalizeDep($dep) { case 'php_version': $struct = $this->depsStructPhpVersion; break; - + case 'php_extension': $struct = $this->depsStructPhpExtension; break; diff --git a/engine/classes/ElggPluginPackage.php b/engine/classes/ElggPluginPackage.php index e6c9136024f..2d891514f2b 100644 --- a/engine/classes/ElggPluginPackage.php +++ b/engine/classes/ElggPluginPackage.php @@ -423,7 +423,7 @@ public function checkDependencies($full_report = false) { case 'php_version': $result = $this->checkDepPhpVersion($dep, $inverse); break; - + case 'php_extension': $result = $this->checkDepPhpExtension($dep, $inverse); break; @@ -431,7 +431,7 @@ public function checkDependencies($full_report = false) { case 'php_ini': $result = $this->checkDepPhpIni($dep, $inverse); break; - + default: $result = null;//skip further check break; @@ -685,7 +685,7 @@ public function getID() { /** * Returns the last error message. - * + * * @return string */ public function getError() { diff --git a/engine/classes/ElggPriorityList.php b/engine/classes/ElggPriorityList.php index ba60e15b237..1be7cd23319 100644 --- a/engine/classes/ElggPriorityList.php +++ b/engine/classes/ElggPriorityList.php @@ -42,7 +42,7 @@ * $pl->add('Element -10', -10); * * $priority = $pl->getPriority('Element -5'); - * + * * Or element lookups by priority. * $element = $pl->getElement(-5); * @@ -172,7 +172,7 @@ public function remove($element, $strict = false) { */ public function move($element, $new_priority, $strict = false) { $new_priority = (int) $new_priority; - + $current_priority = $this->getPriority($element, $strict); if ($current_priority === false) { return false; @@ -203,7 +203,7 @@ public function getElements() { * * If no user function is provided the elements are sorted by priority registered. * - * The callback function should accept the array of elements as the first + * The callback function should accept the array of elements as the first * argument and should return a sorted array. * * This function can be called multiple times. @@ -223,7 +223,7 @@ public function sort($callback = null) { $this->elements = $sorted; } - + $this->sorted = true; return true; } @@ -247,7 +247,7 @@ private function sortIfUnsorted() { */ public function getNextPriority($near = 0) { $near = (int) $near; - + while (array_key_exists($near, $this->elements)) { $near++; } @@ -257,7 +257,7 @@ public function getNextPriority($near = 0) { /** * Returns the priority of an element if it exists in the list. - * + * * @warning This can return 0 if the element's priority is 0. * * @param mixed $element The element to check for. @@ -289,7 +289,7 @@ public function contains($element, $strict = false) { return $this->getPriority($element, $strict) !== false; } - + /********************** * Interface methods * **********************/ diff --git a/engine/classes/ElggRelationship.php b/engine/classes/ElggRelationship.php index 9fe3bd614f7..948fdee751e 100644 --- a/engine/classes/ElggRelationship.php +++ b/engine/classes/ElggRelationship.php @@ -4,7 +4,7 @@ * * @package Elgg.Core * @subpackage Core - * + * * @property int $id The unique identifier (read-only) * @property int $guid_one The GUID of the subject of the relationship * @property string $relationship The type of the relationship (limit of 50 characters long) @@ -103,7 +103,7 @@ public function __get($name) { return null; } - + /** * Class member get overloading * diff --git a/engine/classes/ElggRewriteTester.php b/engine/classes/ElggRewriteTester.php index e49641f0ddd..2d8da79cbbf 100644 --- a/engine/classes/ElggRewriteTester.php +++ b/engine/classes/ElggRewriteTester.php @@ -66,7 +66,7 @@ public static function guessWebServer() { * * @param string $url Rewrite test URL * - * @return string|bool Subdirectory string with beginning and trailing slash or false if were unable to determine subdirectory + * @return string|bool Subdirectory string with beginning and trailing slash or false if were unable to determine subdirectory * or pointing at root of domain already */ public function guessSubdirectory($url) { @@ -121,10 +121,10 @@ public function runRewriteTest($url) { return true; } - + /** * Check whether the site homepage can be fetched via curl - * + * * @return boolean */ public function runLocalhostAccessTest() { @@ -146,7 +146,7 @@ public function runLocalhostAccessTest() { $response = curl_exec($ch); curl_close($ch); } - + return $response !== false; } @@ -192,7 +192,7 @@ public function createHtaccess($url, $path) { $this->htaccessIssue = 'cannot_copy'; return FALSE; } - + // does default RewriteBase work already? if (!$this->runRewriteTest($url)) { //try to rewrite to guessed subdirectory @@ -226,7 +226,7 @@ protected function returnStatus($url) { if ($this->serverSupportsRemoteRead == FALSE) { $msg = _elgg_services()->translator->translate('install:warning:rewrite:unknown', array($url)); $msg .= elgg_view('install/js_rewrite_check', array('url' => $url)); - + return array( 'severity' => 'warning', 'message' => $msg, @@ -239,7 +239,7 @@ protected function returnStatus($url) { if (!isset($this->htaccessIssue)) { $msg .= _elgg_services()->translator->translate('install:error:rewrite:allowoverride'); $msg .= elgg_view('install/js_rewrite_check', array('url' => $url)); - + return array( 'severity' => 'failure', 'message' => $msg, diff --git a/engine/classes/ElggRiverItem.php b/engine/classes/ElggRiverItem.php index 3992b5b8fbf..511817aa82a 100644 --- a/engine/classes/ElggRiverItem.php +++ b/engine/classes/ElggRiverItem.php @@ -4,7 +4,7 @@ * * @package Elgg.Core * @subpackage Core - * + * * @property-read int $id The unique identifier (read-only) * @property-read int $subject_guid The GUID of the actor * @property-read int $object_guid The GUID of the object @@ -55,7 +55,7 @@ public function __construct($object) { /** * Get the subject of this river item - * + * * @return \ElggEntity */ public function getSubjectEntity() { @@ -82,7 +82,7 @@ public function getTargetEntity() { /** * Get the Annotation for this river item - * + * * @return \ElggAnnotation */ public function getAnnotation() { @@ -100,7 +100,7 @@ public function getView() { /** * Get the time this activity was posted - * + * * @return int * @deprecated 1.9 Use getTimePosted() */ @@ -111,7 +111,7 @@ public function getPostedTime() { /** * Get the time this activity was posted - * + * * @return int */ public function getTimePosted() { @@ -120,7 +120,7 @@ public function getTimePosted() { /** * Get the type of the object - * + * * This is required for elgg_view_list_item(). All the other data types * (entities, extenders, relationships) have a type/subtype. * @@ -132,7 +132,7 @@ public function getType() { /** * Get the subtype of the object - * + * * This is required for elgg_view_list_item(). * * @return string 'item' @@ -143,7 +143,7 @@ public function getSubtype() { /** * Get a plain old object copy for public consumption - * + * * @return \stdClass */ public function toObject() { diff --git a/engine/classes/ElggSession.php b/engine/classes/ElggSession.php index 870cd056a87..880c10bec4d 100644 --- a/engine/classes/ElggSession.php +++ b/engine/classes/ElggSession.php @@ -5,8 +5,8 @@ * * Reserved keys: last_forward_from, msg, sticky_forms, user, guid, id, code, name, username * Deprecated keys: user, id, name, username - * - * \ArrayAccess was deprecated in Elgg 1.9. This means you should use + * + * \ArrayAccess was deprecated in Elgg 1.9. This means you should use * $session->get('foo') rather than $session['foo']. * Warning: You can not access multidimensional arrays through \ArrayAccess like * this $session['foo']['bar'] @@ -184,7 +184,7 @@ public function has($name) { /** * Sets the logged in user - * + * * @param \ElggUser $user The user who is logged in * @return void * @since 1.9 @@ -196,7 +196,7 @@ public function setLoggedInUser(\ElggUser $user) { /** * Gets the logged in user - * + * * @return \ElggUser * @since 1.9 */ @@ -215,10 +215,10 @@ public function getLoggedInUserGuid() { if ($user) { return $user->guid; } - + return 0; } - + /** * Returns whether or not the viewer is currently logged in and an admin user. * @@ -226,10 +226,10 @@ public function getLoggedInUserGuid() { */ public function isAdminLoggedIn() { $user = $this->getLoggedInUser(); - + return $user && $user->isAdmin(); } - + /** * Returns whether or not the user is currently logged in * @@ -241,7 +241,7 @@ public function isLoggedIn() { /** * Remove the logged in user - * + * * @return void * @since 1.9 */ @@ -252,9 +252,9 @@ public function removeLoggedInUser() { /** * Adds a token to the session - * + * * This is used in creation of CSRF token - * + * * @return void */ protected function generateSessionToken() { diff --git a/engine/classes/ElggSite.php b/engine/classes/ElggSite.php index c701c36ee9a..4d54297b232 100644 --- a/engine/classes/ElggSite.php +++ b/engine/classes/ElggSite.php @@ -208,7 +208,7 @@ public function disable($reason = "", $recursive = true) { return parent::disable($reason, $recursive); } - + /** * Returns the URL for this site * diff --git a/engine/classes/ElggUser.php b/engine/classes/ElggUser.php index 3bc5da55144..16feb708306 100644 --- a/engine/classes/ElggUser.php +++ b/engine/classes/ElggUser.php @@ -6,7 +6,7 @@ * * @package Elgg.Core * @subpackage DataModel.User - * + * * @property string $name The display name that the user will be known by in the network * @property string $username The short, reference name for the user in the network * @property string $email The email address to which Elgg will send email notifications @@ -124,7 +124,7 @@ protected function load($guid) { */ protected function create() { global $CONFIG; - + $guid = parent::create(); $name = sanitize_string($this->name); $username = sanitize_string($this->username); @@ -142,20 +142,20 @@ protected function create() { // TODO(evan): Throw an exception here? return false; } - + return $guid; } - + /** * {@inheritdoc} */ protected function update() { global $CONFIG; - + if (!parent::update()) { return false; } - + $guid = (int)$this->guid; $name = sanitize_string($this->name); $username = sanitize_string($this->username); @@ -748,7 +748,7 @@ public function getExportableValues() { * Can a user comment on this user? * * @see \ElggEntity::canComment() - * + * * @param int $user_guid User guid (default is logged in user) * @return bool * @since 1.8.0 diff --git a/engine/classes/ElggVolatileMetadataCache.php b/engine/classes/ElggVolatileMetadataCache.php index bdf1ab79d75..ddf328b9e8a 100644 --- a/engine/classes/ElggVolatileMetadataCache.php +++ b/engine/classes/ElggVolatileMetadataCache.php @@ -34,7 +34,7 @@ class ElggVolatileMetadataCache { /** * Cache metadata for an entity - * + * * @param int $entity_guid The GUID of the entity * @param array $values The metadata values to cache * @return void @@ -48,7 +48,7 @@ public function saveAll($entity_guid, array $values) { /** * Get the metadata for an entity - * + * * @param int $entity_guid The GUID of the entity * @return array */ @@ -73,7 +73,7 @@ public function markOutOfSync($entity_guid) { /** * Have all the metadata for this entity been cached? - * + * * @param int $entity_guid The GUID of the entity * @return bool */ @@ -83,11 +83,11 @@ public function isSynchronized($entity_guid) { /** * Cache a piece of metadata - * + * * @param int $entity_guid The GUID of the entity * @param string $name The metadata name - * @param array|int|string|null $value The metadata value. null means it is - * known that there is no fetch-able + * @param array|int|string|null $value The metadata value. null means it is + * known that there is no fetch-able * metadata under this name * @param bool $allow_multiple Can the metadata be an array * @return void @@ -187,7 +187,7 @@ public function clear($entity_guid) { /** * Clear entire cache and mark all entities as out of sync - * + * * @return void */ public function flush() { @@ -210,7 +210,7 @@ public function setIgnoreAccess($ignore) { /** * Tell the cache to call elgg_get_ignore_access() to determing access status. - * + * * @return void */ public function unsetIgnoreAccess() { @@ -219,7 +219,7 @@ public function unsetIgnoreAccess() { /** * Get the ignore access value - * + * * @return bool */ protected function getIgnoreAccess() { @@ -262,7 +262,7 @@ public function invalidateByOptions($action, array $options) { /** * Populate the cache from a set of entities - * + * * @param int|array $guids Array of or single GUIDs * @return void */ diff --git a/engine/classes/ElggWidget.php b/engine/classes/ElggWidget.php index a0f5ed3689f..b3298f4f72f 100644 --- a/engine/classes/ElggWidget.php +++ b/engine/classes/ElggWidget.php @@ -28,7 +28,7 @@ protected function initializeAttributes() { /** * Get a value from attributes or private settings - * + * * @param string $name The name of the value * @return mixed */ @@ -63,7 +63,7 @@ public function get($name) { /** * Set an attribute or private setting value - * + * * @param string $name The name of the value to set * @param mixed $value The value to set * @return void @@ -173,7 +173,7 @@ public function move($column, $rank) { if ($column == $this->column) { $bottom_rank--; } - + if ($rank == 0) { // top of the column $this->order = reset($widgets)->order - 10; diff --git a/engine/classes/ElggXMLElement.php b/engine/classes/ElggXMLElement.php index c8e01b9ac86..cada45807c2 100644 --- a/engine/classes/ElggXMLElement.php +++ b/engine/classes/ElggXMLElement.php @@ -13,7 +13,7 @@ class ElggXMLElement { /** * Creates an \ElggXMLParser from a string or existing SimpleXMLElement - * + * * @param string|SimpleXMLElement $xml The XML to parse */ public function __construct($xml) { @@ -83,7 +83,7 @@ public function getChildren() { /** * Override -> - * + * * @param string $name Property name * @return mixed */ @@ -107,7 +107,7 @@ public function __get($name) { /** * Override isset - * + * * @param string $name Property name * @return boolean */ diff --git a/engine/lib/access.php b/engine/lib/access.php index d52c311ca0e..50d439351e1 100644 --- a/engine/lib/access.php +++ b/engine/lib/access.php @@ -13,9 +13,9 @@ /** * Set if Elgg's access system should be ignored. * - * The access system will not return entities in any getter functions if the + * The access system will not return entities in any getter functions if the * user doesn't have access. This removes this restriction. - * + * * When the access system is being ignored, all checks for create, retrieve, * update, and delete should pass. This affects all the canEdit() and related * methods. @@ -25,11 +25,11 @@ * * @warning This will not show disabled entities. * Use {@link access_show_hidden_entities()} to access disabled entities. - * + * * @internal The access override is checked in elgg_override_permissions(). It is * registered for the 'permissions_check' hooks to override the access system for * the canEdit() and canWriteToContainer() methods. - * + * * @internal This clears the access cache. * * @internal For performance reasons this is done at the database access clause level. @@ -199,7 +199,7 @@ function access_get_show_hidden_status() { * Returns the SQL where clause for enforcing read access to data. * * Note that if this code is executed in privileged mode it will return (1=1). - * + * * Otherwise it returns a where clause to retrieve the data that a user has * permission to read. * @@ -213,24 +213,24 @@ function access_get_show_hidden_status() { * * The results will be combined into an SQL where clause in the form: * ((or1 OR or2 OR orN) AND (and1 AND and2 AND andN)) - * + * * @param array $options Array in format: * * table_alias => STR Optional table alias. This is based on the select and join clauses. - * Default is 'e'. + * Default is 'e'. * * user_guid => INT Optional GUID for the user that we are retrieving data for. * Defaults to the logged in user. - * - * use_enabled_clause => BOOL Optional. Should we append the enabled clause? The default + * + * use_enabled_clause => BOOL Optional. Should we append the enabled clause? The default * is set by access_show_hidden_entities(). - * + * * access_column => STR Optional access column name. Default is 'access_id'. - * + * * owner_guid_column => STR Optional owner_guid column. Default is 'owner_guid'. - * + * * guid_column => STR Optional guid_column. Default is 'guid'. - * + * * @return string * @access private */ @@ -441,7 +441,7 @@ function get_members_of_access_collection($collection, $idonly = false) { /** * Return entities based upon access id. - * + * * TODO(ewinslow): Move this logic into elgg_get_entities * * @param array $options Any options accepted by {@link elgg_get_entities()} and @@ -477,10 +477,10 @@ function elgg_get_entities_from_access_id(array $options = array()) { * Lists entities from an access collection * * @param array $options See elgg_list_entities() and elgg_get_entities_from_access_id() - * + * * @see elgg_list_entities() * @see elgg_get_entities_from_access_id() - * + * * @return string */ function elgg_list_entities_from_access_id(array $options = array()) { @@ -489,18 +489,18 @@ function elgg_list_entities_from_access_id(array $options = array()) { /** * Return the name of an ACCESS_* constant or an access collection, - * but only if the logged in user has write access to it. + * but only if the logged in user has write access to it. * Write access requirement prevents us from exposing names of access collections * that current user has been added to by other members and may contain * sensitive classification of the current user (e.g. close friends vs acquaintances). - * - * Returns a string in the language of the user for global access levels, e.g.'Public, 'Friends', 'Logged in', 'Public'; - * or a name of the owned access collection, e.g. 'My work colleagues'; + * + * Returns a string in the language of the user for global access levels, e.g.'Public, 'Friends', 'Logged in', 'Public'; + * or a name of the owned access collection, e.g. 'My work colleagues'; * or a name of the group or other access collection, e.g. 'Group: Elgg technical support'; * or 'Limited' if the user access is restricted to read-only, e.g. a friends collection the user was added to - * + * * @uses get_write_access_array() - * + * * @param int $entity_access_id The entity's access id * @return string * @since 1.7.0 @@ -606,11 +606,11 @@ function access_init() { * Allows admin users and calls after {@link elgg_set_ignore_access} to * bypass the access system. * - * Registered for the 'permissions_check', 'all' and the + * Registered for the 'permissions_check', 'all' and the * 'container_permissions_check', 'all' plugin hooks. * * Returns true to override the access system or null if no change is needed. - * + * * @internal comment upgrade depends on this * * @param string $hook diff --git a/engine/lib/actions.php b/engine/lib/actions.php index aba5bc3f8fb..6e8a8138cdb 100644 --- a/engine/lib/actions.php +++ b/engine/lib/actions.php @@ -10,7 +10,7 @@ /** * Handle a request for an action - * + * * @param array $segments URL segments that make up action name * * @return void @@ -126,7 +126,7 @@ function validate_action_token($visible_errors = true, $token = null, $ts = null * This function verifies form input for security features (like a generated token), * and forwards if they are invalid. * - * @param string $action The action being performed + * @param string $action The action being performed * * @return mixed True if valid or redirects. * @access private @@ -233,7 +233,7 @@ function elgg_is_xhr() { * } * * where "system_messages" is all message registers at the point of forwarding - * + * * @internal registered for the 'forward', 'all' plugin hook * * @param string $hook diff --git a/engine/lib/admin.php b/engine/lib/admin.php index c7a3911834f..5e8e6f7b099 100644 --- a/engine/lib/admin.php +++ b/engine/lib/admin.php @@ -27,7 +27,7 @@ */ /** - * Get the admin users + * Get the admin users * * @param array $options Options array, @see elgg_get_entities() for parameters * @@ -283,7 +283,7 @@ function _elgg_admin_init() { 'priority' => 10, 'section' => 'configure' )); - + // plugins elgg_register_menu_item('page', array( 'name' => 'plugins', @@ -325,7 +325,7 @@ function _elgg_admin_init() { 'section' => 'alt', )); } - + // widgets $widgets = array('online_users', 'new_users', 'content_stats', 'banned_users', 'admin_welcome', 'control_panel'); foreach ($widgets as $widget) { @@ -361,7 +361,7 @@ function _elgg_admin_pagesetup() { elgg_register_css('elgg.admin', $url); elgg_load_css('elgg.admin'); elgg_unregister_css('elgg'); - + $admin = elgg_get_logged_in_user_entity(); // setup header menu @@ -372,7 +372,7 @@ function _elgg_admin_pagesetup() { 'is_trusted' => true, 'priority' => 1000, )); - + elgg_register_menu_item('admin_header', array( 'name' => 'view_site', 'href' => elgg_get_site_url(), @@ -386,7 +386,7 @@ function _elgg_admin_pagesetup() { 'href' => false, 'text' => elgg_echo('admin:loggedin', array($admin->name)), 'priority' => 800, - )); + )); if (elgg_get_config('elgg_maintenance_mode', null)) { elgg_register_menu_item('admin_header', array( @@ -397,7 +397,7 @@ function _elgg_admin_pagesetup() { 'priority' => 700, )); } - + // setup footer menu elgg_register_menu_item('admin_footer', array( 'name' => 'faq', @@ -527,7 +527,7 @@ function _elgg_admin_page_handler($page) { // special page for plugin settings since we create the form for them if ($page[0] == 'plugin_settings') { - if (isset($page[1]) && (elgg_view_exists("settings/{$page[1]}/edit") || + if (isset($page[1]) && (elgg_view_exists("settings/{$page[1]}/edit") || elgg_view_exists("plugins/{$page[1]}/settings"))) { $view = 'admin/plugin_settings'; @@ -671,7 +671,7 @@ function _elgg_admin_markdown_page_handler($pages) { 'content' => '
' . $text . '
', 'title' => $title )); - + echo elgg_view_page($title, $body, 'admin'); return true; } @@ -721,7 +721,7 @@ function _elgg_admin_maintenance_allow_url($current_url) { /** * Handle requests when in maintenance mode - * + * * @access private */ function _elgg_admin_maintenance_handler($hook, $type, $info) { @@ -774,16 +774,16 @@ function _elgg_admin_maintenance_action_check($hook, $type) { if ($type == 'login') { $username = get_input('username'); - + $user = get_user_by_username($username); - + if (!$user) { $users = get_user_by_email($username); if ($users) { $user = $users[0]; } } - + if ($user && $user->isAdmin()) { return true; } @@ -821,7 +821,7 @@ function _elgg_add_admin_widgets($event, $type, $user) { 1 => array('control_panel', 'admin_welcome'), 2 => array('online_users', 'new_users', 'content_stats'), ); - + foreach ($adminWidgets as $column => $handlers) { foreach ($handlers as $position => $handler) { $guid = elgg_create_widget($user->getGUID(), $handler, 'admin'); diff --git a/engine/lib/autoloader.php b/engine/lib/autoloader.php index 07e06d7b2c5..00fa18b7530 100644 --- a/engine/lib/autoloader.php +++ b/engine/lib/autoloader.php @@ -8,7 +8,7 @@ */ $autoload_path = dirname(dirname(__DIR__)) . '/vendor/autoload.php'; -$autoload_available = include_once($autoload_path); +$autoload_available = include_once($autoload_path); if (!$autoload_available) { die("Couldn't include '$autoload_path'. Did you run `composer install`?"); } diff --git a/engine/lib/cache.php b/engine/lib/cache.php index 4f508054948..bed1b52bf6c 100644 --- a/engine/lib/cache.php +++ b/engine/lib/cache.php @@ -101,9 +101,9 @@ function elgg_register_simplecache_view($view_name) { /** * Get the URL for the cached file - * + * * This automatically registers the view with Elgg's simplecache. - * + * * @example * $blog_js = elgg_get_simplecache_url('js', 'blog/save_draft'); * elgg_register_js('elgg.blog', $blog_js); @@ -121,7 +121,7 @@ function elgg_get_simplecache_url($type, $view) { /** * Get the base url for simple cache requests - * + * * @return string The simplecache root url for the current viewtype. * @access private */ @@ -131,14 +131,14 @@ function _elgg_get_simplecache_root() { /** * Returns the type of output expected from the view. - * + * * css/* views always return "css" * js/* views always return "js" * * @todo why isn't this in the CacheHandler class? It is not used anywhere else. - * + * * @todo view/name.suffix returns "suffix" - * + * * Otherwise, returns "unknown" * * @param string $view The view name @@ -189,7 +189,7 @@ function elgg_disable_simplecache() { /** * Recursively deletes a directory, including all hidden files. - * + * * TODO(ewinslow): Move to filesystem package * * @param string $dir @@ -198,7 +198,7 @@ function elgg_disable_simplecache() { */ function _elgg_rmdir($dir) { $files = array_diff(scandir($dir), array('.', '..')); - + foreach ($files as $file) { if (is_dir("$dir/$file")) { _elgg_rmdir("$dir/$file"); @@ -206,7 +206,7 @@ function _elgg_rmdir($dir) { unlink("$dir/$file"); } } - + return rmdir($dir); } @@ -224,7 +224,7 @@ function elgg_invalidate_simplecache() { /** * Initializes the simplecache lastcache variable and creates system cache files * when appropriate. - * + * * @access private */ function _elgg_cache_init() { diff --git a/engine/lib/comments.php b/engine/lib/comments.php index f552e4c3b0f..d3536958918 100644 --- a/engine/lib/comments.php +++ b/engine/lib/comments.php @@ -175,7 +175,7 @@ function _elgg_comments_container_permissions_override($hook, $type, $return, $p /** * By default, only authors can edit their comments. - * + * * @param string $hook 'permissions_check' * @param string $type 'object' * @param boolean $return Can the given user edit the given entity? @@ -186,10 +186,10 @@ function _elgg_comments_container_permissions_override($hook, $type, $return, $p function _elgg_comments_permissions_override($hook, $type, $return, $params) { $entity = $params['entity']; $user = $params['user']; - + if (elgg_instanceof($entity, 'object', 'comment') && $user) { return $entity->getOwnerGUID() == $user->getGUID(); } - + return $return; } diff --git a/engine/lib/configuration.php b/engine/lib/configuration.php index 535823d4c42..d50eeec13dd 100644 --- a/engine/lib/configuration.php +++ b/engine/lib/configuration.php @@ -103,7 +103,7 @@ function elgg_save_config($name, $value, $site_guid = 0) { /** * Get the value of a datalist element. - * + * * Plugin authors should use elgg_get_config() and pass null for the site GUID. * * @internal Datalists are stored in the datalist table. @@ -120,12 +120,12 @@ function datalist_get($name) { /** * Set the value for a datalist element. - * + * * Plugin authors should use elgg_save_config() and pass null for the site GUID. - * + * * @warning Names should be selected so as not to collide with the names for the * site config. - * + * * @warning Values set through datalist_set() are not available in $CONFIG until * next page load. * @@ -173,7 +173,7 @@ function run_function_once($functionname, $timelastupdatedcheck = 0) { /** * Removes a config setting. * - * @internal These settings are stored in the dbprefix_config table and read + * @internal These settings are stored in the dbprefix_config table and read * during system boot into $CONFIG. * * @param string $name The name of the field. @@ -190,17 +190,17 @@ function unset_config($name, $site_guid = 0) { /** * Add or update a config setting. - * + * * Plugin authors should use elgg_set_config(). * * If the config name already exists, it will be updated to the new value. * * @warning Names should be selected so as not to collide with the names for the * datalist (application configuration) - * - * @internal These settings are stored in the dbprefix_config table and read + * + * @internal These settings are stored in the dbprefix_config table and read * during system boot into $CONFIG. - * + * * @internal The value is serialized so we maintain type information. * * @param string $name The name of the configuration value @@ -218,10 +218,10 @@ function set_config($name, $value, $site_guid = 0) { /** * Gets a configuration value - * + * * Plugin authors should use elgg_get_config(). * - * @internal These settings are stored in the dbprefix_config table and read + * @internal These settings are stored in the dbprefix_config table and read * during system boot into $CONFIG. * * @param string $name The name of the config value @@ -239,12 +239,12 @@ function get_config($name, $site_guid = 0) { /** * Loads configuration related to this site * - * This runs on engine boot and loads from the config database table and the + * This runs on engine boot and loads from the config database table and the * site entity. It runs after the application configuration is loaded by * _elgg_load_application_config(). - * + * * @see _elgg_engine_boot() - * + * * @access private */ function _elgg_load_site_config() { @@ -278,9 +278,9 @@ function _elgg_load_site_config() { * Loads configuration related to Elgg as an application * * This runs on the engine boot and loads from the datalists database table. - * + * * @see _elgg_engine_boot() - * + * * @access private */ function _elgg_load_application_config() { diff --git a/engine/lib/deprecated-1.8.php b/engine/lib/deprecated-1.8.php index 4ec7beaaddb..32ff382c155 100644 --- a/engine/lib/deprecated-1.8.php +++ b/engine/lib/deprecated-1.8.php @@ -267,7 +267,7 @@ function list_entities_from_annotation_count($entity_type = "", $entity_subtype * Adds an entry in $CONFIG[$register_name][$subregister_name]. * * @deprecated 1.8 Use the new menu system. - * + * * This is only used for the site-wide menu. See {@link add_menu()}. * * @param string $register_name The name of the top-level register @@ -410,7 +410,7 @@ function events($event = "", $object_type = "", $function = "", $priority = 500, * Alias function for events, that registers a function to a particular kind of event * * @deprecated 1.8 Use elgg_register_event_handler() instead - * + * * @param string $event The event type * @param string $object_type The object type * @param string $function The function name @@ -423,7 +423,7 @@ function register_elgg_event_handler($event, $object_type, $callback, $priority /** * Unregisters a function to a particular kind of event - * + * * @deprecated 1.8 Use elgg_unregister_event_handler instead * * @param string $event The event type @@ -440,7 +440,7 @@ function unregister_elgg_event_handler($event, $object_type, $callback) { * Alias function for events, that triggers a particular kind of event * * @deprecated 1.8 Use elgg_trigger_event() instead - * + * * @param string $event The event type * @param string $object_type The object type * @param string $function The function name @@ -455,7 +455,7 @@ function trigger_elgg_event($event, $object_type, $object = null) { * Register a function to a plugin hook for a particular entity type, with a given priority. * * @deprecated 1.8 Use elgg_register_plugin_hook_handler() instead - * + * * eg if you want the function "export_user" to be called when the hook "export" for "user" entities * is run, use: * @@ -485,7 +485,7 @@ function register_plugin_hook($hook, $type, $callback, $priority = 500) { * Unregister a function to a plugin hook for a particular entity type * * @deprecated 1.8 Use elgg_unregister_plugin_hook_handler() instead - * + * * @param string $hook The name of the hook * @param string $entity_type The name of the type of entity (eg "user", "object" etc) * @param string $function The name of a valid function to be run @@ -3927,7 +3927,7 @@ function register_page_handler($handler, $function){ * * @param string $handler The page type identifier * @since 1.7.2 - * + * * @deprecated 1.8 Use {@link elgg_unregister_page_handler()} */ function unregister_page_handler($handler) { @@ -3973,7 +3973,7 @@ function register_extender_url_handler($function, $type = "all", $name = "all") * @param string $type The type of entity (object, site, user, group) * @param string $subtype The subtype to register (may be blank) * @return true|false Depending on success - * + * * @deprecated 1.8 Use {@link elgg_register_entity_type()} */ function register_entity_type($type, $subtype = null) { @@ -3986,7 +3986,7 @@ function register_entity_type($type, $subtype = null) { * * @param string $function_name The function. * @param string $extender_name The name, default 'all'. - * + * * @deprecated 1.8 Use {@link elgg_register_metadata_url_handler()} */ function register_metadata_url_handler($function, $extender_name = "all") { @@ -3999,7 +3999,7 @@ function register_metadata_url_handler($function, $extender_name = "all") { * @param string $function_name The function to register * @param string $relationship_type The relationship type. * @return true|false Depending on success - * + * * @deprecated 1.8 Use {@link elgg_register_relationship_url_handler()} */ function register_relationship_url_handler($function_name, $relationship_type = "all") { @@ -4041,7 +4041,7 @@ function elgg_view_regenerate_simplecache($viewtype = NULL) { * Enables the simple cache. * * @see elgg_view_register_simplecache() - * + * * @deprecated 1.8 Use {@link elgg_enable_simplecache()} */ function elgg_view_enable_simplecache() { @@ -4053,7 +4053,7 @@ function elgg_view_enable_simplecache() { * Disables the simple cache. * * @see elgg_view_register_simplecache() - * + * * @deprecated 1.8 Use {@link elgg_disable_simplecache()} */ function elgg_view_disable_simplecache() { @@ -4564,7 +4564,7 @@ function using_widgets() { * * @param \ElggObject $widget The widget to display * @return string The HTML for the widget, including JavaScript wrapper - * + * * @deprecated 1.8 Use elgg_view_entity() */ function display_widget(\ElggObject $widget) { diff --git a/engine/lib/deprecated-1.9.php b/engine/lib/deprecated-1.9.php index 4e98f3ecf95..215cebd3fee 100644 --- a/engine/lib/deprecated-1.9.php +++ b/engine/lib/deprecated-1.9.php @@ -2159,7 +2159,7 @@ function delete_entity($guid, $recursive = true) { */ function enable_entity($guid, $recursive = true) { elgg_deprecated_notice('enable_entity has been deprecated in favor of elgg_enable_entity', '1.9'); - + $guid = (int)$guid; // Override access only visible entities @@ -2221,11 +2221,11 @@ function can_edit_entity_metadata($entity_guid, $user_guid = 0, $metadata = null */ function disable_entity($guid, $reason = "", $recursive = true) { elgg_deprecated_notice('disable_entity was deprecated in favor of \ElggEntity::disable', '1.9'); - + if ($entity = get_entity($guid)) { return $entity->disable($reason, $recursive); } - + return false; } @@ -2247,7 +2247,7 @@ function can_edit_entity($entity_guid, $user_guid = 0) { if ($entity = get_entity($entity_guid)) { return $entity->canEdit($user_guid); } - + return false; } @@ -2262,14 +2262,14 @@ function can_edit_entity($entity_guid, $user_guid = 0) { */ function join_group($group_guid, $user_guid) { elgg_deprecated_notice('join_group was deprecated in favor of \ElggGroup::join', '1.9'); - + $group = get_entity($group_guid); $user = get_entity($user_guid); - + if ($group instanceof \ElggGroup && $user instanceof \ElggUser) { return $group->join($user); } - + return false; } @@ -2286,7 +2286,7 @@ function leave_group($group_guid, $user_guid) { elgg_deprecated_notice('leave_group was deprecated in favor of \ElggGroup::leave', '1.9'); $group = get_entity($group_guid); $user = get_entity($user_guid); - + if ($group instanceof \ElggGroup && $user instanceof \ElggUser) { return $group->leave($user); } @@ -2308,7 +2308,7 @@ function autop($string) { /** * Register a function as a web service method - * + * * @deprecated 1.9 Enable the web services plugin and use elgg_ws_expose_function(). */ function expose_function($method, $function, array $parameters = NULL, $description = "", @@ -3288,7 +3288,7 @@ function get_site_domain($guid) { * @param string $language_name Its localized notification string (eg "New blog post") * * @return void - * @deprecated 1.9 Use elgg_register_notification_event(). The 3rd argument was used + * @deprecated 1.9 Use elgg_register_notification_event(). The 3rd argument was used * as the subject line in a notification. As of Elgg 1.9, it is now set by a callback * for a plugin hook. See the documentation at the top of the notifications library * titled "Adding a New Notification Event" for more details. @@ -3762,7 +3762,7 @@ function import_relationship_plugin_hook($hook, $entity_type, $returnvalue, $par /** * Returns the SQL where clause for a table with access_id and enabled columns. * - * This handles returning where clauses for ACCESS_FRIENDS in addition to using + * This handles returning where clauses for ACCESS_FRIENDS in addition to using * get_access_list() for access collections and the standard access levels. * * Note that if this code is executed in privileged mode it will return (1=1). diff --git a/engine/lib/elgglib.php b/engine/lib/elgglib.php index f01df8b67d7..b59f9ad9bb5 100644 --- a/engine/lib/elgglib.php +++ b/engine/lib/elgglib.php @@ -808,7 +808,7 @@ function _elgg_php_exception_handler($exception) { ob_start(); include $CONFIG->exception_include; $exception_output = ob_get_clean(); - + // if content is returned from the custom handler we will output // that instead of our default failsafe view if (!empty($exception_output)) { @@ -886,7 +886,7 @@ function _elgg_php_error_handler($errno, $errmsg, $filename, $linenum, $vars) { case E_WARNING : case E_USER_WARNING : case E_RECOVERABLE_ERROR: // (e.g. type hint violation) - + // check if the error wasn't suppressed by the error control operator (@) if (error_reporting()) { error_log("PHP WARNING: $error"); @@ -1571,7 +1571,7 @@ function _elgg_css_page_handler($page) { // default css $page[0] = 'elgg'; } - + return _elgg_cacheable_view_page_handler($page, 'css'); } @@ -1770,7 +1770,7 @@ function _elgg_walled_garden_index() { elgg_load_css('elgg.walled_garden'); elgg_load_js('elgg.walled_garden'); - + $content = elgg_view('core/walled_garden/login'); $params = array( @@ -1928,10 +1928,10 @@ function _elgg_init() { elgg_register_js('elgg.ui.river', 'js/lib/ui.river.js'); elgg_register_css('jquery.imgareaselect', 'vendors/jquery/jquery.imgareaselect/css/imgareaselect-deprecated.css'); - + // Trigger the shutdown:system event upon PHP shutdown. register_shutdown_function('_elgg_shutdown_hook'); - + // Sets a blacklist of words in the current language. // This is a comma separated list in word:blacklist. // @todo possibly deprecate diff --git a/engine/lib/filestore.php b/engine/lib/filestore.php index 8a0a003ac7f..0d0c205753a 100644 --- a/engine/lib/filestore.php +++ b/engine/lib/filestore.php @@ -473,7 +473,7 @@ function _elgg_filestore_init() { // Fix MIME type detection for Microsoft zipped formats elgg_register_plugin_hook_handler('mime_type', 'file', '_elgg_filestore_detect_mimetype'); - + // Parse category of file from MIME type elgg_register_plugin_hook_handler('simple_type', 'file', '_elgg_filestore_parse_simpletype'); diff --git a/engine/lib/friends.php b/engine/lib/friends.php index 73664f1ff2e..e2c43fa0f9c 100644 --- a/engine/lib/friends.php +++ b/engine/lib/friends.php @@ -156,7 +156,7 @@ function _elgg_collections_page_handler($page_elements) { switch ($page_elements[0]) { case 'add': elgg_set_page_owner_guid(elgg_get_logged_in_user_guid()); - + require_once "{$base}pages/friends/collections/add.php"; return true; break; @@ -164,7 +164,7 @@ function _elgg_collections_page_handler($page_elements) { $user = get_user_by_username($page_elements[1]); if ($user) { elgg_set_page_owner_guid($user->getGUID()); - + require_once "{$base}pages/friends/collections/view.php"; return true; } @@ -181,10 +181,10 @@ function _elgg_collections_page_handler($page_elements) { * @access private */ function _elgg_setup_collections_menu() { - + if (elgg_get_logged_in_user_guid() == elgg_get_page_owner_guid()) { $user = elgg_get_page_owner_entity(); - + elgg_register_menu_item('page', array( 'name' => 'friends:view:collections', 'text' => elgg_echo('friends:collections'), diff --git a/engine/lib/input.php b/engine/lib/input.php index ae538e0671e..6d12a794b02 100644 --- a/engine/lib/input.php +++ b/engine/lib/input.php @@ -56,7 +56,7 @@ function filter_tags($var) { /** * Returns the current page's complete URL. - * + * * It uses the configured site URL for the hostname rather than depending on * what the server uses to populate $_SERVER. * diff --git a/engine/lib/metadata.php b/engine/lib/metadata.php index 3960b1c44ed..0efa16f9dbb 100644 --- a/engine/lib/metadata.php +++ b/engine/lib/metadata.php @@ -232,7 +232,7 @@ function elgg_enable_metadata(array $options) { * Currently if multiple values are sent via * an array (value => array('value1', 'value2') * the pair's operand will be forced to "IN". - * If passing "IN" as the operand and a string as the value, + * If passing "IN" as the operand and a string as the value, * the value must be a properly quoted and escaped string. * * metadata_name_value_pairs_operator => null|STR The operator to use for combining diff --git a/engine/lib/metastrings.php b/engine/lib/metastrings.php index 1dcdf62886c..949e132b657 100644 --- a/engine/lib/metastrings.php +++ b/engine/lib/metastrings.php @@ -231,7 +231,7 @@ function _elgg_get_metastring_based_objects($options) { $custom_callback = ($options['callback'] == 'row_to_elggmetadata' || $options['callback'] == 'row_to_elggannotation'); $is_calculation = $options['metastring_calculation'] ? true : false; - + if ($custom_callback || $is_calculation) { $joins[] = "JOIN {$db_prefix}metastrings n on n_table.name_id = n.id"; $joins[] = "JOIN {$db_prefix}metastrings v on n_table.value_id = v.id"; diff --git a/engine/lib/navigation.php b/engine/lib/navigation.php index a5d8d5f9b06..dc1ea492682 100644 --- a/engine/lib/navigation.php +++ b/engine/lib/navigation.php @@ -143,7 +143,7 @@ function elgg_unregister_menu_item($menu_name, $item_name) { * * @param string $menu_name The name of the menu * @param string $item_name The unique identifier for this menu item - * + * * @return bool * @since 1.8.0 */ @@ -330,7 +330,7 @@ function _elgg_site_menu_setup($hook, $type, $return, $params) { $return['more'] = array_splice($return['default'], $max_display_items); } } - + // check if we have anything selected $selected = false; foreach ($return as $section) { @@ -343,7 +343,7 @@ function _elgg_site_menu_setup($hook, $type, $return, $params) { } } } - + if (!$selected) { // nothing selected, match name to context or match url $current_url = current_page_url(); @@ -390,7 +390,7 @@ function _elgg_river_menu_setup($hook, $type, $return, $params) { $return[] = \ElggMenuItem::factory($options); } } - + if (elgg_is_admin_logged_in()) { $options = array( 'name' => 'delete', @@ -415,7 +415,7 @@ function _elgg_entity_menu_setup($hook, $type, $return, $params) { if (elgg_in_context('widgets')) { return $return; } - + $entity = $params['entity']; /* @var \ElggEntity $entity */ $handler = elgg_extract('handler', $params, false); @@ -431,7 +431,7 @@ function _elgg_entity_menu_setup($hook, $type, $return, $params) { ); $return[] = \ElggMenuItem::factory($options); } - + if ($entity->canEdit() && $handler) { // edit link $options = array( diff --git a/engine/lib/notification.php b/engine/lib/notification.php index 72cebad5652..af9765b5e0c 100644 --- a/engine/lib/notification.php +++ b/engine/lib/notification.php @@ -3,39 +3,39 @@ * Adding a New Notification Event * =============================== * 1. Register the event with elgg_register_notification_event() - * + * * 2. Register for the notification message plugin hook: - * 'prepare', 'notification:[event name]'. The event name is of the form - * [action]:[type]:[subtype]. For example, the publish event for a blog + * 'prepare', 'notification:[event name]'. The event name is of the form + * [action]:[type]:[subtype]. For example, the publish event for a blog * would be named 'publish:object:blog'. - * + * * The parameter array for the plugin hook has the keys 'event', 'method', - * 'recipient', and 'language'. The event is an \Elgg\Notifications\Event - * object and can provide access to the original object of the event through + * 'recipient', and 'language'. The event is an \Elgg\Notifications\Event + * object and can provide access to the original object of the event through * the method getObject() and the original actor through getActor(). - * - * The plugin hook callback modifies and returns a + * + * The plugin hook callback modifies and returns a * \Elgg\Notifications\Notification object that holds the message content. * * * Adding a Delivery Method * ========================= * 1. Register the delivery method name with elgg_register_notification_method() - * + * * 2. Register for the plugin hook for sending notifications: - * 'send', 'notification:[method name]'. It receives the notification object + * 'send', 'notification:[method name]'. It receives the notification object * of the namespace Elgg\Notifications; -class Notification in the params array with the - * key 'notification'. The callback should return a boolean to indicate whether +class Notification in the params array with the + * key 'notification'. The callback should return a boolean to indicate whether * the message was sent. - * - * + * + * * Subscribing a User for Notifications * ==================================== * Users subscribe to receive notifications based on container and delivery method. - * - * + * + * * @package Elgg.Core * @subpackage Notifications */ @@ -76,7 +76,7 @@ function elgg_unregister_notification_event($object_type, $object_subtype) { /** * Register a delivery method for notifications - * + * * Register for the 'send', 'notification:[method name]' plugin hook to handle * sending a notification. A notification object is in the params array for the * hook with the key 'notification'. See \Elgg\Notifications\Notification. @@ -186,7 +186,7 @@ function _elgg_notifications_cron() { /** * Send an email notification - * + * * @param string $hook Hook name * @param string $type Hook type * @param bool $result Has anyone sent a message yet? @@ -355,7 +355,7 @@ function _elgg_notify_user($to, $from, $subject, $message, array $params = null, if ($methods) { // Deliver foreach ($methods as $method) { - + $handler = $notify_service->getDeprecatedHandler($method); /* @var callable $handler */ if (!$handler || !is_callable($handler)) { diff --git a/engine/lib/output.php b/engine/lib/output.php index f8aa56e46c5..c934cd71161 100644 --- a/engine/lib/output.php +++ b/engine/lib/output.php @@ -122,7 +122,7 @@ function elgg_format_bytes($size, $precision = 2) { } $base = log($size) / log(1024); - $suffixes = array('B', 'kB', 'MB', 'GB', 'TB'); + $suffixes = array('B', 'kB', 'MB', 'GB', 'TB'); return round(pow(1024, $base - floor($base)), $precision) . ' ' . $suffixes[floor($base)]; } @@ -335,7 +335,7 @@ function elgg_normalize_url($url) { // '//example.com' (Shortcut for protocol.) // '?query=test', #target return $url; - + } elseif (stripos($url, 'javascript:') === 0 || stripos($url, 'mailto:') === 0) { // 'javascript:' and 'mailto:' // Not covered in FILTER_VALIDATE_URL @@ -377,7 +377,7 @@ function elgg_get_friendly_title($title) { // titles are often stored HTML encoded $title = html_entity_decode($title, ENT_QUOTES, 'UTF-8'); - + $title = \Elgg\Translit::urlize($title); return $title; @@ -395,7 +395,7 @@ function elgg_get_friendly_title($title) { * @since 1.7.2 */ function elgg_get_friendly_time($time, $current_time = null) { - + if (!$current_time) { $current_time = time(); } @@ -416,7 +416,7 @@ function elgg_get_friendly_time($time, $current_time = null) { if ($diff < $minute) { return elgg_echo("friendlytime:justnow"); } - + if ($diff < $hour) { $granularity = ':minutes'; $diff = round($diff / $minute); @@ -431,7 +431,7 @@ function elgg_get_friendly_time($time, $current_time = null) { if ($diff == 0) { $diff = 1; } - + $future = ((int)$current_time - (int)$time < 0) ? ':future' : ''; $singular = ($diff == 1) ? ':singular' : ''; @@ -448,11 +448,11 @@ function elgg_get_friendly_upload_error($error_code) { switch ($error_code) { case UPLOAD_ERR_OK: return ''; - + case UPLOAD_ERR_INI_SIZE: $key = 'ini_size'; break; - + case UPLOAD_ERR_FORM_SIZE: $key = 'form_size'; break; @@ -476,7 +476,7 @@ function elgg_get_friendly_upload_error($error_code) { case UPLOAD_ERR_EXTENSION: $key = 'extension'; break; - + default: $key = 'unknown'; break; @@ -550,7 +550,7 @@ function _elgg_html_decode($string) { /** * Prepares query string for output to prevent CSRF attacks. - * + * * @param string $string * @return string * diff --git a/engine/lib/pagehandler.php b/engine/lib/pagehandler.php index fde41df833b..b0ceb29d170 100644 --- a/engine/lib/pagehandler.php +++ b/engine/lib/pagehandler.php @@ -65,7 +65,7 @@ function elgg_gatekeeper() { /** * Alias of elgg_gatekeeper() - * + * * Used at the top of a page to mark it as logged in users only. * * @return void @@ -195,7 +195,7 @@ function elgg_entity_gatekeeper($guid, $type = null, $subtype = null) { // user is logged in but still does not have access to it register_error(elgg_echo('limited_access')); forward(); - } + } } if ($type) { @@ -208,7 +208,7 @@ function elgg_entity_gatekeeper($guid, $type = null, $subtype = null) { /** * Front page handler - * + * * @return bool */ function elgg_front_page_handler() { @@ -255,13 +255,13 @@ function elgg_error_page_handler($hook, $type, $result, $params) { // use default if there is no title for this error type $title = elgg_echo("error:default:title"); } - + $content = elgg_view("errors/$type", $params); } else { $title = elgg_echo("error:default:title"); $content = elgg_view("errors/default", $params); } - + $httpCodes = array( '400' => 'Bad Request', '401' => 'Unauthorized', @@ -271,7 +271,7 @@ function elgg_error_page_handler($hook, $type, $result, $params) { '500' => 'Internal Server Error', '503' => 'Service Unavailable', ); - + if (isset($httpCodes[$type])) { header("HTTP/1.1 $type {$httpCodes[$type]}"); } diff --git a/engine/lib/pageowner.php b/engine/lib/pageowner.php index 8907395ecd7..5dc997ba024 100644 --- a/engine/lib/pageowner.php +++ b/engine/lib/pageowner.php @@ -178,7 +178,7 @@ function default_page_owner_handler($hook, $entity_type, $returnvalue, $params) * output could be different for those two contexts ('blog' vs 'widget'). * * Pages that pass through the page handling system set the context to the - * first string after the root url. Example: http://example.org/elgg/bookmarks/ + * first string after the root url. Example: http://example.org/elgg/bookmarks/ * results in the initial context being set to 'bookmarks'. * * The context is a stack so that for a widget on a profile, the context stack @@ -255,7 +255,7 @@ function elgg_in_context($context) { * @access private */ function page_owner_boot() { - + elgg_register_plugin_hook_handler('page_owner', 'system', 'default_page_owner_handler'); // Bootstrap the context stack by setting its first entry to the handler. diff --git a/engine/lib/plugins.php b/engine/lib/plugins.php index 8c731b09cbe..af797a8a3c7 100644 --- a/engine/lib/plugins.php +++ b/engine/lib/plugins.php @@ -78,9 +78,9 @@ function _elgg_generate_plugin_entities() { /** * Cache a reference to this plugin by its ID - * + * * @param \ElggPlugin $plugin - * + * * @access private */ function _elgg_cache_plugin_by_id(\ElggPlugin $plugin) { @@ -236,7 +236,7 @@ function _elgg_get_plugins_provides($type = null, $name = null) { /** * Deletes all cached data on plugins being provided. - * + * * @return boolean * @since 1.9.0 * @access private diff --git a/engine/lib/relationships.php b/engine/lib/relationships.php index 43b8e3af35d..84fd836dc5c 100644 --- a/engine/lib/relationships.php +++ b/engine/lib/relationships.php @@ -157,7 +157,7 @@ function get_entity_relationships($guid, $inverse_relationship = false) { * * inverse_relationship => false|BOOL Is relationship_guid is the target entity of the relationship? By default, * relationship_guid is the subject. - * + * * relationship_join_on => null|STR How the entities relate: guid (default), container_guid, or owner_guid * Add in Elgg 1.9.0. Examples using the relationship 'friend': * 1. use 'guid' if you want the user's friends diff --git a/engine/lib/river.php b/engine/lib/river.php index 1e24f8d09c2..627b6fc3b22 100644 --- a/engine/lib/river.php +++ b/engine/lib/river.php @@ -334,7 +334,7 @@ function elgg_get_river(array $options = array()) { if ($options['posted_time_upper'] && is_int($options['posted_time_upper'])) { $wheres[] = "rv.posted <= {$options['posted_time_upper']}"; } - + if (!access_get_show_hidden_status()) { $wheres[] = "rv.enabled = 'yes'"; } @@ -740,7 +740,7 @@ function _elgg_river_test($hook, $type, $value) { /** * Disable river entries that reference a disabled entity as subject/object/target - * + * * @param string $event The event 'disable' * @param string $type Type of entity being disabled 'all' * @param mixed $entity The entity being disabled @@ -748,18 +748,18 @@ function _elgg_river_test($hook, $type, $value) { * @access private */ function _elgg_river_disable($event, $type, $entity) { - + if (!elgg_instanceof($entity)) { return true; } - + $dbprefix = elgg_get_config('dbprefix'); $query = <<guid} OR rv.object_guid = {$entity->guid} OR rv.target_guid = {$entity->guid}); QUERY; - + update_data($query); return true; } @@ -767,7 +767,7 @@ function _elgg_river_disable($event, $type, $entity) { /** * Enable river entries that reference a re-enabled entity as subject/object/target - * + * * @param string $event The event 'enable' * @param string $type Type of entity being enabled 'all' * @param mixed $entity The entity being enabled @@ -775,11 +775,11 @@ function _elgg_river_disable($event, $type, $entity) { * @access private */ function _elgg_river_enable($event, $type, $entity) { - + if (!elgg_instanceof($entity)) { return true; } - + $dbprefix = elgg_get_config('dbprefix'); $query = <<guid} OR oe.guid = {$entity->guid} OR te.guid = {$entity->guid}); QUERY; diff --git a/engine/lib/sites.php b/engine/lib/sites.php index 6225f8ac930..468286c301a 100644 --- a/engine/lib/sites.php +++ b/engine/lib/sites.php @@ -19,13 +19,13 @@ function elgg_get_site_entity($site_guid = 0) { global $CONFIG; $result = false; - + if ($site_guid == 0) { $site = $CONFIG->site; } else { $site = get_entity($site_guid); } - + if ($site instanceof \ElggSite) { $result = $site; } diff --git a/engine/lib/system_log.php b/engine/lib/system_log.php index 70feaab058d..9215f20b920 100644 --- a/engine/lib/system_log.php +++ b/engine/lib/system_log.php @@ -41,7 +41,7 @@ function get_system_log($by_user = "", $event = "", $class = "", $type = "", $su } else { $by_user = (int)$by_user; } - + $event = sanitise_string($event); $class = sanitise_string($class); $type = sanitise_string($type); @@ -165,7 +165,7 @@ function get_object_from_log_entry($entry) { $object = new $class($entry->object_id); return $object; } catch (Exception $e) { - + } } diff --git a/engine/lib/upgrades/2010010501.php b/engine/lib/upgrades/2010010501.php index 1e83caa5566..6ec5585edbd 100644 --- a/engine/lib/upgrades/2010010501.php +++ b/engine/lib/upgrades/2010010501.php @@ -4,5 +4,5 @@ /** * Enable the search plugin - */ + */ enable_plugin('search', $CONFIG->site->guid); diff --git a/engine/lib/upgrades/2010111501.php b/engine/lib/upgrades/2010111501.php index c0b89c8c63c..775f50dfb11 100644 --- a/engine/lib/upgrades/2010111501.php +++ b/engine/lib/upgrades/2010111501.php @@ -1,6 +1,6 @@ dbprefix}river +$query = "UPDATE {$CONFIG->dbprefix}river SET view='river/relationship/friend/create', action_type='create' WHERE view='friends/river/create' AND action_type='friend'"; update_data($query); diff --git a/engine/lib/upgrades/2012041800-1.8.3-dont_filter_passwords-c0ca4a18b38ae2bc.php b/engine/lib/upgrades/2012041800-1.8.3-dont_filter_passwords-c0ca4a18b38ae2bc.php index b82ffbebfc9..c6020e177e9 100644 --- a/engine/lib/upgrades/2012041800-1.8.3-dont_filter_passwords-c0ca4a18b38ae2bc.php +++ b/engine/lib/upgrades/2012041800-1.8.3-dont_filter_passwords-c0ca4a18b38ae2bc.php @@ -3,7 +3,7 @@ * Elgg 1.8.3 upgrade 2012041800 * dont_filter_passwords * - * Add admin notice that password handling has changed and if + * Add admin notice that password handling has changed and if * users can't login to have them reset their passwords. */ elgg_add_admin_notice('dont_filter_passwords', 'Password handling has been updated to be more secure and flexible. ' diff --git a/engine/lib/upgrades/2013010400-1.9.0_dev-comments_to_entities-faba94768b055b08.php b/engine/lib/upgrades/2013010400-1.9.0_dev-comments_to_entities-faba94768b055b08.php index 69c3ea00279..4e1c4542ad6 100644 --- a/engine/lib/upgrades/2013010400-1.9.0_dev-comments_to_entities-faba94768b055b08.php +++ b/engine/lib/upgrades/2013010400-1.9.0_dev-comments_to_entities-faba94768b055b08.php @@ -6,7 +6,7 @@ * Convert comment annotations to entities. * * Register comment subtype and add \ElggUpgrade for ajax upgrade. - * + * * We do not migrate comments in this upgrade. See the comment * upgrade action in actions/admin/upgrades/upgrade_comments.php for that. */ diff --git a/engine/lib/upgrades/2013051700-1.8.15-add_missing_group_index-52a63a3a3ffaced2.php b/engine/lib/upgrades/2013051700-1.8.15-add_missing_group_index-52a63a3a3ffaced2.php index ee99bdbc8ed..c8cfebaf75d 100644 --- a/engine/lib/upgrades/2013051700-1.8.15-add_missing_group_index-52a63a3a3ffaced2.php +++ b/engine/lib/upgrades/2013051700-1.8.15-add_missing_group_index-52a63a3a3ffaced2.php @@ -20,7 +20,7 @@ } if ($full_text_index_exists == false) { - $query = "ALTER TABLE {$db_prefix}groups_entity + $query = "ALTER TABLE {$db_prefix}groups_entity ADD FULLTEXT name_2 (name, description)"; if (!update_data($query)) { elgg_log("Failed to add full text index to groups_entity table", 'ERROR'); diff --git a/engine/lib/upgrades/2014042500-1.9.0_dev-site-notifications-0aae171afb7a00d8.php b/engine/lib/upgrades/2014042500-1.9.0_dev-site-notifications-0aae171afb7a00d8.php index 45b488ff6c5..9d4506883a4 100644 --- a/engine/lib/upgrades/2014042500-1.9.0_dev-site-notifications-0aae171afb7a00d8.php +++ b/engine/lib/upgrades/2014042500-1.9.0_dev-site-notifications-0aae171afb7a00d8.php @@ -11,7 +11,7 @@ if (elgg_is_active_plugin('messages')) { // get the site_notifications plugin $site_notifications = elgg_get_plugin_from_id('site_notifications'); - + if (!empty($site_notifications)) { $site_notifications->activate(); } diff --git a/engine/lib/upgrades/2014070600-1.9.0_rc.3-river_enabled_col-bef9e6f0533ac338.php b/engine/lib/upgrades/2014070600-1.9.0_rc.3-river_enabled_col-bef9e6f0533ac338.php index d4b81d0cdb2..ea9e6ec5f99 100644 --- a/engine/lib/upgrades/2014070600-1.9.0_rc.3-river_enabled_col-bef9e6f0533ac338.php +++ b/engine/lib/upgrades/2014070600-1.9.0_rc.3-river_enabled_col-bef9e6f0533ac338.php @@ -20,5 +20,5 @@ SET rv.enabled = 'no' WHERE (se.enabled = 'no' OR te.enabled = 'no' OR oe.enabled = 'no'); Q2; - + update_data($q2); \ No newline at end of file diff --git a/engine/lib/user_settings.php b/engine/lib/user_settings.php index aaf5225aa59..e85ba68bd32 100644 --- a/engine/lib/user_settings.php +++ b/engine/lib/user_settings.php @@ -9,7 +9,7 @@ /** * Set a user's password - * + * * @return bool * @since 1.8.0 * @access private @@ -76,7 +76,7 @@ function _elgg_set_user_password() { /** * Set a user's display name - * + * * @return bool * @since 1.8.0 * @access private @@ -117,7 +117,7 @@ function _elgg_set_user_name() { /** * Set a user's language - * + * * @return bool * @since 1.8.0 * @access private @@ -342,7 +342,7 @@ function _elgg_user_settings_init() { elgg_register_plugin_hook_handler('usersettings:save', 'user', '_elgg_set_user_default_access'); elgg_register_plugin_hook_handler('usersettings:save', 'user', '_elgg_set_user_name'); elgg_register_plugin_hook_handler('usersettings:save', 'user', '_elgg_set_user_email'); - + elgg_register_action("usersettings/save"); // extend the account settings form diff --git a/engine/lib/users.php b/engine/lib/users.php index 9fc19720492..cf1eca10729 100644 --- a/engine/lib/users.php +++ b/engine/lib/users.php @@ -516,12 +516,12 @@ function elgg_user_hover_menu($hook, $type, $return, $params) { $item = new \ElggMenuItem('profile:edit', elgg_echo('profile:edit'), $url); $item->setSection('admin'); $return[] = $item; - + $url = "avatar/edit/$user->username"; $item = new \ElggMenuItem('avatar:edit', elgg_echo('avatar:edit'), $url); $item->setSection('admin'); $return[] = $item; - + $url = "settings/user/$user->username"; $item = new \ElggMenuItem('settings:edit', elgg_echo('settings:edit'), $url); $item->setSection('admin'); diff --git a/engine/lib/views.php b/engine/lib/views.php index 436ea0240c5..90dac9bf85d 100644 --- a/engine/lib/views.php +++ b/engine/lib/views.php @@ -464,7 +464,7 @@ function elgg_view_page($title, $body, $page_shell = 'default', $vars = array()) $vars['head'] = elgg_trigger_plugin_hook('head', 'page', $vars, $head_params); $vars = elgg_trigger_plugin_hook('output:before', 'page', null, $vars); - + // check for deprecated view if ($page_shell == 'default' && elgg_view_exists('pageshells/pageshell')) { elgg_deprecated_notice("pageshells/pageshell is deprecated by page/$page_shell", 1.8); @@ -507,12 +507,12 @@ function _elgg_views_prepare_head($title) { 'name' => 'description', 'content' => elgg_get_config('sitedescription') ); - + // https://developer.chrome.com/multidevice/android/installtohomescreen $data['metas'][] = array( 'name' => 'viewport', 'content' => 'width=device-width', - ); + ); $data['metas'][] = array( 'name' => 'mobile-web-app-capable', 'content' => 'yes', @@ -1047,9 +1047,9 @@ function elgg_view_annotation_list($annotations, array $vars = array()) { 'full_view' => true, 'offset_key' => 'annoff', ); - + $vars = array_merge($defaults, $vars); - + if (!$vars["limit"] && !$vars["offset"]) { // no need for pagination if listing is unlimited $vars["pagination"] = false; @@ -1369,9 +1369,9 @@ function elgg_view_icon($name, $class = '') { elgg_deprecated_notice("Using a boolean to float the icon is deprecated. Use the class float.", 1.9); $class = 'float'; } - + $icon_class = array("elgg-icon-$name" , $class); - + return elgg_view("output/icon", array("class" => $icon_class)); } diff --git a/engine/lib/widgets.php b/engine/lib/widgets.php index fa6d1add0d4..a4eaa82dbe3 100644 --- a/engine/lib/widgets.php +++ b/engine/lib/widgets.php @@ -122,7 +122,7 @@ function elgg_get_widget_types($context = "", $exact = false) { /** * Set the widget title on ajax return from save action - * + * * @param string $hook Hook name * @param string $type Hook type * @param array $results Array to be encoded as json @@ -162,7 +162,7 @@ function _elgg_widgets_init() { * register menu items for default widgets with the admin section. * * A plugin that wants to register a new context for default widgets should - * register for the plugin hook 'get_list', 'default_widgets'. The handler + * register for the plugin hook 'get_list', 'default_widgets'. The handler * can register the new type of default widgets by adding an associate array to * the return value array like this: * array( diff --git a/engine/load.php b/engine/load.php index 18fcc9fc1dd..8cf17801ddd 100644 --- a/engine/load.php +++ b/engine/load.php @@ -1,8 +1,8 @@ cookies */ // get the default parameters from php.ini @@ -196,16 +196,16 @@ /** * This is an optional script used to override Elgg's default handling of * uncaught exceptions. - * + * * This should be an absolute file path to a php script that will be called * any time an uncaught exception is thrown. - * + * * The script will have access to the following variables as part of the scope * global $CONFIG * $exception - the unhandled exception - * + * * @warning - the database may not be available - * + * * @global string $CONFIG->exception_include */ $CONFIG->exception_include = ''; diff --git a/engine/tests/ElggCoreAccessCollectionsTest.php b/engine/tests/ElggCoreAccessCollectionsTest.php index 3054f5e09b2..f02db753053 100644 --- a/engine/tests/ElggCoreAccessCollectionsTest.php +++ b/engine/tests/ElggCoreAccessCollectionsTest.php @@ -4,7 +4,7 @@ * * @package Elgg * @subpackage Test - * + * * TODO(ewinslow): Move this to Elgg\Database\AccessCollectionsTest */ class ElggCoreAccessCollectionsTest extends \ElggCoreUnitTest { @@ -41,7 +41,7 @@ public function __destruct() { } public function testCreateGetDeleteACL() { - + $acl_name = 'test access collection'; $acl_id = create_access_collection($acl_name); @@ -167,7 +167,7 @@ public function testCanEditACLHook() { 'acl_id' => $acl_id, 'user' => $this->user ); - + function test_acl_access_hook($hook, $type, $value, $params) { global $acl_test_info; if ($params['user_id'] == $acl_test_info['user']->guid) { @@ -198,7 +198,7 @@ public function testCreateDeleteGroupACL() { if (!elgg_is_active_plugin('groups')) { return; } - + $group = new \ElggGroup(); $group->name = 'Test group'; $group->save(); @@ -209,7 +209,7 @@ public function testCreateDeleteGroupACL() { // removing group and acl $this->assertTrue($group->delete()); - + $acl = get_access_collection($group->group_acl); $this->assertFalse($acl); diff --git a/engine/tests/ElggCoreAccessSQLTest.php b/engine/tests/ElggCoreAccessSQLTest.php index 08c1c76dc44..3ab2bac539d 100644 --- a/engine/tests/ElggCoreAccessSQLTest.php +++ b/engine/tests/ElggCoreAccessSQLTest.php @@ -9,7 +9,7 @@ class ElggCoreAccessSQLTest extends \ElggCoreUnitTest { /** @var \ElggUser */ protected $user; - + /** * Called before each test object. */ @@ -65,7 +65,7 @@ public function testAdminAccess() { public function testTurningEnabledOff() { $sql = _elgg_get_access_where_sql(array('use_enabled_clause' => false)); $ans = "((1 = 1))"; - $this->assertTrue($this->assertSqlEqual($ans, $sql), "$sql does not match $ans"); + $this->assertTrue($this->assertSqlEqual($ans, $sql), "$sql does not match $ans"); } public function testNonAdminUser() { @@ -156,7 +156,7 @@ public function removeOrsCallback($hook, $type, $clauses, $params) { $clauses['ors'] = array(); return $clauses; } - + public function testAccessPluginHookAddOr() { elgg_register_plugin_hook_handler('get_sql', 'access', array($this, 'addOrCallback')); $sql = _elgg_get_access_where_sql(); @@ -190,7 +190,7 @@ protected function assertSqlEqual($sql1, $sql2) { protected function getFriendsClause($user_guid, $table_alias, $owner_guid = 'owner_guid') { global $CONFIG; $table_alias = $table_alias ? $table_alias . '.' : ''; - + return "{$table_alias}access_id = " . ACCESS_FRIENDS . " AND {$table_alias}{$owner_guid} IN ( SELECT guid_one FROM {$CONFIG->dbprefix}entity_relationships diff --git a/engine/tests/ElggCoreConfigTest.php b/engine/tests/ElggCoreConfigTest.php index 0fb8338d6b8..eb1ae164acb 100644 --- a/engine/tests/ElggCoreConfigTest.php +++ b/engine/tests/ElggCoreConfigTest.php @@ -172,6 +172,6 @@ public function testElggGetConfigNonCurrentSiteConfig() { $value = 'test'; $this->assertTrue(elgg_save_config($name, $value, 17)); $this->assertIdentical($value, elgg_get_config($name, 17)); - $this->assertTrue(unset_config($name, 17)); - } + $this->assertTrue(unset_config($name, 17)); + } } diff --git a/engine/tests/ElggCoreFilestoreTest.php b/engine/tests/ElggCoreFilestoreTest.php index a4245b8d48e..8592bf8c4ba 100644 --- a/engine/tests/ElggCoreFilestoreTest.php +++ b/engine/tests/ElggCoreFilestoreTest.php @@ -20,14 +20,14 @@ public function setUp() { public function tearDown() { unset($this->filestore); } - + public function testFilenameOnFilestore() { global $CONFIG; - + // create a user to own the file $user = $this->createTestUser(); $dir = new \Elgg\EntityDirLocator($user->guid); - + // setup a test file $file = new \ElggFile(); $file->owner_guid = $user->guid; @@ -35,13 +35,13 @@ public function testFilenameOnFilestore() { $file->open('write'); $file->write('Testing!'); $this->assertTrue($file->close()); - + // ensure filename and path is expected $filename = $file->getFilenameOnFilestore($file); $filepath = $CONFIG->dataroot . $dir . 'testing/filestore.txt'; $this->assertIdentical($filename, $filepath); $this->assertTrue(file_exists($filepath)); - + // ensure file removed on user delete // deleting the user calls clear_user_files() $user->delete(); @@ -50,11 +50,11 @@ public function testFilenameOnFilestore() { function testElggFileDelete() { global $CONFIG; - + $user = $this->createTestUser(); $filestore = $this->filestore; $dir = new \Elgg\EntityDirLocator($user->guid); - + $file = new \ElggFile(); $file->owner_guid = $user->guid; $file->setFilename('testing/ElggFileDelete'); @@ -101,7 +101,7 @@ protected function createTestUser($username = 'fileTest') { $user = new \ElggUser(); $user->username = $username; $guid = $user->save(); - + // load user to have access to creation time return get_entity($guid); } diff --git a/engine/tests/ElggCoreGetEntitiesFromMetadataTest.php b/engine/tests/ElggCoreGetEntitiesFromMetadataTest.php index 0a0ef30510f..f0365f62358 100644 --- a/engine/tests/ElggCoreGetEntitiesFromMetadataTest.php +++ b/engine/tests/ElggCoreGetEntitiesFromMetadataTest.php @@ -1116,7 +1116,7 @@ function testElggApiGettersEntityMetadataNOrderByMDInt() { } } } - + // test getting by name sorting by value as integer with defined values function testElggApiGettersEntityMetadataNOrderByMDIntDefinedVals() { $subtypes = $this->getRandomValidSubtypes(array('object'), 1); @@ -1146,7 +1146,7 @@ function testElggApiGettersEntityMetadataNOrderByMDIntDefinedVals() { $valid3->save(); $guids[] = $valid->getGUID(); $valid_guids[] = $valid3->getGUID(); - + $num = array(1, 5, 15); $options = array( @@ -1176,7 +1176,7 @@ function testElggApiGettersEntityMetadataNOrderByMDIntDefinedVals() { } } } - + // test getting by name_value_pairs sorting by value as integer // because string comparison '5' > '15' function testElggApiGettersEntityMetadataNVPOrderByMDInt() { @@ -1207,7 +1207,7 @@ function testElggApiGettersEntityMetadataNVPOrderByMDInt() { $valid3->save(); $guids[] = $valid->getGUID(); $valid_guids[] = $valid3->getGUID(); - + $num = array(1, 5, 15); $options = array( @@ -1239,7 +1239,7 @@ function testElggApiGettersEntityMetadataNVPOrderByMDInt() { } } } - + // test getting by name sorting by value as integer with defined values function testElggApiGettersEntityMetadataNVPGreaterThanInt() { $subtypes = $this->getRandomValidSubtypes(array('object'), 1); @@ -1285,7 +1285,7 @@ function testElggApiGettersEntityMetadataNVPGreaterThanInt() { $this->assertIsA($entities, 'array'); $this->assertEqual(count($entities), 2); - + $num = array(5, 15); $i = 0; @@ -1302,7 +1302,7 @@ function testElggApiGettersEntityMetadataNVPGreaterThanInt() { } } } - + // test getting from string value interpreted as numeric // see https://github.com/Elgg/Elgg/issues/7009 function testElggApiGettersEntityMetadataNVPInvalidDouble() { @@ -1311,7 +1311,7 @@ function testElggApiGettersEntityMetadataNVPInvalidDouble() { $md_name = 'test_metadata_name_' . rand(); $guids = array(); $valid_guids = array(); - + $value = '052e866869'; // our targets diff --git a/engine/tests/ElggCoreGetEntitiesFromRelationshipTest.php b/engine/tests/ElggCoreGetEntitiesFromRelationshipTest.php index 1564bfc212c..8fd8768ac98 100644 --- a/engine/tests/ElggCoreGetEntitiesFromRelationshipTest.php +++ b/engine/tests/ElggCoreGetEntitiesFromRelationshipTest.php @@ -191,7 +191,7 @@ public function testElggGetEntitiesFromRelationshipCount() { } } } - + /** * Make sure elgg_get_entities_from_relationship() returns distinct (unique) results when relationship_guid is not set * See #5775 @@ -216,7 +216,7 @@ public function testElggApiGettersEntityRelationshipDistinctResult() { 'inverse_relationship' => false, 'count' => true, ); - + $count = elgg_get_entities_from_relationship($options); $this->assertIdentical($count, 1); @@ -224,19 +224,19 @@ public function testElggApiGettersEntityRelationshipDistinctResult() { $objects = elgg_get_entities_from_relationship($options); $this->assertTrue(is_array($objects)); $this->assertIdentical(count($objects), 1); - + $obj1->delete(); $obj2->delete(); $obj3->delete(); } - + /** * Make sure changes related to #5775 do not affect inverse relationship queries * @covers elgg_get_entities_from_relationship() */ public function testElggApiGettersEntityRelationshipDistinctResultInverse() { - + $obj1 = new ElggObject(); $obj1->save(); @@ -254,7 +254,7 @@ public function testElggApiGettersEntityRelationshipDistinctResultInverse() { 'inverse_relationship' => true, 'count' => true, ); - + $count = elgg_get_entities_from_relationship($options); $this->assertIdentical($count, 2); @@ -262,7 +262,7 @@ public function testElggApiGettersEntityRelationshipDistinctResultInverse() { $objects = elgg_get_entities_from_relationship($options); $this->assertTrue(is_array($objects)); $this->assertIdentical(count($objects), 2); - + $obj1->delete(); $obj2->delete(); $obj3->delete(); diff --git a/engine/tests/ElggCoreHelpersTest.php b/engine/tests/ElggCoreHelpersTest.php index 3341cefefc0..08146d39f2d 100644 --- a/engine/tests/ElggCoreHelpersTest.php +++ b/engine/tests/ElggCoreHelpersTest.php @@ -247,7 +247,7 @@ public function testElggRegisterJS() { */ public function testElggRegisterCSS() { global $CONFIG; - + // specify name $result = elgg_register_css('key', 'http://test1.com'); $this->assertTrue($result); @@ -272,7 +272,7 @@ public function testElggUnregisterJS() { $base = trim(elgg_get_site_url(), "/"); $urls = array('id1' => "$base/urla", 'id2' => "$base/urlb", 'id3' => "$base/urlc"); - + foreach ($urls as $id => $url) { elgg_register_js($id, $url); } @@ -283,7 +283,7 @@ public function testElggUnregisterJS() { $js = $CONFIG->externals['js']; $elements = $js->getElements(); $this->assertFalse(isset($CONFIG->externals_map['js']['id1'])); - + foreach ($elements as $element) { if (isset($element->name)) { $this->assertFalse($element->name == 'id1'); @@ -325,7 +325,7 @@ public function testElggLoadJS() { elgg_load_js('key'); $result = elgg_register_js('key', 'http://test1.com', 'footer'); $this->assertTrue($result); - + $js_urls = elgg_get_loaded_js('footer'); $this->assertIdentical(array(500 => 'http://test1.com'), $js_urls); } @@ -343,7 +343,7 @@ public function testElggGetJS() { 'id2' => "$base/urlb", 'id3' => "$base/urlc" ); - + foreach ($urls as $id => $url) { elgg_register_js($id, $url); elgg_load_js($id); @@ -358,7 +358,7 @@ public function testElggGetJS() { $js_urls = elgg_get_loaded_js('footer'); $this->assertIdentical(array(), $js_urls); } - + /** * Test elgg_get_friendly_time() */ @@ -374,7 +374,7 @@ public function testElggGetFriendlyTime() { '120' => elgg_echo('friendlytime:future:minutes', array('2')), '86400' => elgg_echo('friendlytime:future:days:singular'), ); - + foreach ($offsets as $num_seconds => $friendlytime) { $this->assertIdentical(elgg_get_friendly_time($current_time + $num_seconds, $current_time), $friendlytime); } diff --git a/engine/tests/ElggCoreMetadataAPITest.php b/engine/tests/ElggCoreMetadataAPITest.php index 3f455d41e44..fdd688bc557 100644 --- a/engine/tests/ElggCoreMetadataAPITest.php +++ b/engine/tests/ElggCoreMetadataAPITest.php @@ -163,7 +163,7 @@ public function test_elgg_metadata_multiple_values() { // good times without mocking. $original_user = elgg_get_logged_in_user_entity(); $_SESSION['user'] = $u1; - + elgg_set_ignore_access(false); // add metadata as one user diff --git a/engine/tests/ElggCoreOutputAutoPTest.php b/engine/tests/ElggCoreOutputAutoPTest.php index 2e7eafdee07..f557d42ee0b 100644 --- a/engine/tests/ElggCoreOutputAutoPTest.php +++ b/engine/tests/ElggCoreOutputAutoPTest.php @@ -12,7 +12,7 @@ class ElggCoreOutputAutoPTest extends \ElggCoreUnitTest { public function setUp() { $this->_autop = new \ElggAutoP(); } - + public function testDomRoundtrip() { $d = dir(dirname(__FILE__) . '/test_files/output/autop'); $in = file_get_contents($d->path . "/domdoc_in.html"); @@ -38,7 +38,7 @@ public function testProcess() { $exp = $this->flattenString($exp); $out = $this->_autop->process($in); $out = $this->flattenString($out); - + $this->assertEqual($exp, $out, "Equality case {$test}"); } } diff --git a/engine/tests/ElggCorePluginsAPITest.php b/engine/tests/ElggCorePluginsAPITest.php index 3e6b8daa006..f9ec38b9751 100644 --- a/engine/tests/ElggCorePluginsAPITest.php +++ b/engine/tests/ElggCorePluginsAPITest.php @@ -17,7 +17,7 @@ class ElggCorePluginsAPITest extends \ElggCoreUnitTest { // 1.7 package at test_files/plugin_17/ var $package17; - + public function __construct() { parent::__construct(); @@ -84,7 +84,7 @@ public function testElggPluginManifest18() { array('description' => 'Fun things to do 1', 'path' => 'graphics/plugin_ss1.png'), array('description' => 'Fun things to do 2', 'path' => 'graphics/plugin_ss2.png'), ), - + 'contributor' => array( array('name' => 'Evan Winslow', 'email' => 'evan@elgg.org', 'website' => 'http://evanwinslow.com/', 'username' => 'ewinslow', 'description' => "Description of Evan's role in the project"), array('name' => 'Cash Costello', 'email' => 'cash@elgg.org', 'description' => "Description of Cash's role in the project"), @@ -166,17 +166,17 @@ public function testElggPluginManifestGetWebsite() { $this->assertEqual($this->manifest18->getWebsite(), 'http://www.elgg.org/'); $this->assertEqual($this->manifest17->getWebsite(), 'http://www.elgg.org/'); } - + public function testElggPluginManifestGetRepository() { $this->assertEqual($this->manifest18->getRepositoryURL(), 'https://github.com/Elgg/Elgg'); $this->assertEqual($this->manifest17->getRepositoryURL(), ''); } - + public function testElggPluginManifestGetBugtracker() { $this->assertEqual($this->manifest18->getBugTrackerURL(), 'https://github.com/elgg/elgg/issues'); $this->assertEqual($this->manifest17->getBugTrackerURL(), ''); } - + public function testElggPluginManifestGetDonationsPage() { $this->assertEqual($this->manifest18->getDonationsPageURL(), 'http://elgg.org/supporter.php'); $this->assertEqual($this->manifest17->getDonationsPageURL(), ''); @@ -251,7 +251,7 @@ public function testElggPluginManifestGetScreenshots() { $this->assertIdentical($this->package18->getManifest()->getScreenshots(), $screenshots); $this->assertIdentical($this->package17->getManifest()->getScreenshots(), array()); } - + public function testElggPluginManifestGetContributors() { $contributors = array( array('name' => 'Evan Winslow', 'email' => 'evan@elgg.org', 'website' => 'http://evanwinslow.com/', 'username' => 'ewinslow', 'description' => "Description of Evan's role in the project"), @@ -306,19 +306,19 @@ public function testElggPluginPackageDetectIDFromPluginID() { $package = new \ElggPluginPackage('profile'); $this->assertEqual($package->getID(), 'profile'); } - + // \ElggPlugin public function testElggPluginIsValid() { - + $test_plugin = new \ElggPlugin('profile'); - + $this->assertIdentical(true, $test_plugin->isValid()); } - + public function testElggPluginGetID() { - + $test_plugin = new \ElggPlugin('profile'); - + $this->assertIdentical('profile', $test_plugin->getID()); } } diff --git a/engine/tests/ElggCoreRiverAPITest.php b/engine/tests/ElggCoreRiverAPITest.php index ff382ae7cae..e1b0c192e06 100644 --- a/engine/tests/ElggCoreRiverAPITest.php +++ b/engine/tests/ElggCoreRiverAPITest.php @@ -98,14 +98,14 @@ public function testElggTypeSubtypeWhereSQL() { $result = _elgg_get_river_type_subtype_where_sql('rv', $types, $subtypes, null); $this->assertIdentical($result, "((rv.type = 'object') AND ((rv.subtype = 'blog') OR (rv.subtype = 'file')))"); } - + public function testElggRiverDisableEnable() { $user = new \ElggUser(); $user->save(); - + $entity = new \ElggObject(); $entity->save(); - + $params = array( 'view' => 'river/relationship/friend/create', 'action_type' => 'create', @@ -118,23 +118,23 @@ public function testElggRiverDisableEnable() { $river = elgg_get_river(array('ids' => array($id))); $this->assertIdentical($river[0]->enabled, 'yes'); - + $user->disable(); - + // should no longer be able to get the river $river = elgg_get_river(array('ids' => array($id))); - + $this->assertIdentical($river, array()); - + // renabling the user should re-enable the river access_show_hidden_entities(true); $user->enable(); access_show_hidden_entities(false); - + $river = elgg_get_river(array('ids' => array($id))); - + $this->assertIdentical($river[0]->enabled, 'yes'); - + $user->delete(); $entity->delete(); } diff --git a/engine/tests/ElggCoreSkeletonTest.php b/engine/tests/ElggCoreSkeletonTest.php index ae3267fffb6..e2c2f5fb471 100644 --- a/engine/tests/ElggCoreSkeletonTest.php +++ b/engine/tests/ElggCoreSkeletonTest.php @@ -22,7 +22,7 @@ class ElggCoreSkeletonTest extends \ElggCoreUnitTest { */ public function __construct() { parent::__construct(); - + // all __construct() code should come after here } diff --git a/engine/tests/ElggObjectTest.php b/engine/tests/ElggObjectTest.php index cec0704de8f..bfe7e777d98 100644 --- a/engine/tests/ElggObjectTest.php +++ b/engine/tests/ElggObjectTest.php @@ -236,7 +236,7 @@ public function testElggRecursiveDelete() { foreach ($types as $type) { $parent = new $type(); $this->assertTrue($parent->save()); - + $child = new \ElggObject(); $child->container_guid = $parent->guid; $this->assertTrue($child->save()); diff --git a/engine/tests/README.md b/engine/tests/README.md index 4c71937f8e9..790f2a2d0a2 100644 --- a/engine/tests/README.md +++ b/engine/tests/README.md @@ -41,7 +41,7 @@ Briefly, the wins we expect from testing are: * More freedom to refactor. * Built-in, up-to-date documentation. -We love community contributions, but in order to maintain stability we cannot accept outside contributions without first verifying their correctness. By promoting automated testing, the core developers can avoid the hassle of manual verification before accepting patches. It also means that external developers don't have to spend time earning trust with the core team. If a patch comes in and has tests to verify it, then we can be confident it works without worrying about the reputation of the contributor. +We love community contributions, but in order to maintain stability we cannot accept outside contributions without first verifying their correctness. By promoting automated testing, the core developers can avoid the hassle of manual verification before accepting patches. It also means that external developers don't have to spend time earning trust with the core team. If a patch comes in and has tests to verify it, then we can be confident it works without worrying about the reputation of the contributor. Note that these benefits can also extend to the plugins repository. Site owners are encouraged to "test plugins thoroughly" before deploying them on a production site. As of March 2013, this translates to manually verifying all the features that the plugin promises to offer. But Elgg provides a huge number of features, and it's not reasonable to test for *all* of them on *every browser* you want to support on *every device* you want to support. But what if plugin developers could write tests for their plugins and site owners could just run the tests for all installed plugins to verify the functionality is maintained? Then they wouldn't be limited to just picking plugins from "trusted" developers or "stable" releases. They could see that, indeed, nothing broke when they upgraded that critical plugin from 1.3 to 2.5, and push the upgrade to production with confidence. diff --git a/engine/tests/phpunit/Elgg/ActionsServiceTest.php b/engine/tests/phpunit/Elgg/ActionsServiceTest.php index 1a37e02b085..ab5010fda7a 100644 --- a/engine/tests/phpunit/Elgg/ActionsServiceTest.php +++ b/engine/tests/phpunit/Elgg/ActionsServiceTest.php @@ -12,20 +12,20 @@ public function setUp() { */ public function testCanRegisterFilesAsActions() { $actions = new \Elgg\ActionsService(); - + $this->assertFalse($actions->exists('test/output')); $this->assertFalse($actions->exists('test/not_registered')); $this->assertTrue($actions->register('test/output', "$this->actionsDir/output.php", 'public')); $this->assertTrue($actions->register('test/non_ex_file', "$this->actionsDir/non_existing_file.php", 'public')); - + $this->assertTrue($actions->exists('test/output')); $this->assertFalse($actions->exists('test/non_ex_file')); $this->assertFalse($actions->exists('test/not_registered')); - + return $actions; } - + /** * @depends testCanRegisterFilesAsActions */ @@ -34,53 +34,53 @@ public function testCanUnregisterActions($actions) { $this->assertTrue($actions->unregister('test/output')); $this->assertTrue($actions->unregister('test/non_ex_file')); $this->assertFalse($actions->unregister('test/not_registered')); - + $this->assertFalse($actions->exists('test/output')); $this->assertFalse($actions->exists('test/non_ex_file')); $this->assertFalse($actions->exists('test/not_registered')); } - + /** * Tests overwriting existing action */ public function testCanOverrideRegisteredActions() { $actions = new \Elgg\ActionsService(); - + $this->assertFalse($actions->exists('test/output')); - + $this->assertTrue($actions->register('test/output', "$this->actionsDir/output.php", 'public')); - + $this->assertTrue($actions->exists('test/output')); - + $this->assertTrue($actions->register('test/output', "$this->actionsDir/output2.php", 'public')); - + $this->assertTrue($actions->exists('test/output')); } - + public function testActionsAccessLevels() { $actions = new \Elgg\ActionsService(); - + $this->assertFalse($actions->exists('test/output')); $this->assertFalse($actions->exists('test/not_registered')); $this->assertTrue($actions->register('test/output', "$this->actionsDir/output.php", 'public')); $this->assertTrue($actions->register('test/output_logged_in', "$this->actionsDir/output.php", 'logged_in')); $this->assertTrue($actions->register('test/output_admin', "$this->actionsDir/output.php", 'admin')); - + //TODO finish this test $this->markTestIncomplete("Can't test execution due to missing configuration.php dependencies"); // $actions->execute('test/not_registered'); } - + //TODO call non existing - + //TODO token generation/validation // public function testGenerateValidateTokens() { // $actions = new \Elgg\ActionsService(); - + // $i = 40; - + // while ($i-->0) { // $timestamp = rand(100000000, 2000000000); // $token = $actions->generateActionToken($timestamp); @@ -88,9 +88,9 @@ public function testActionsAccessLevels() { // $this->assertFalse($actions->validateActionToken(false, $token, $timestamp+1)); // $this->assertFalse($actions->validateActionToken(false, $token, $timestamp-1)); // } - + // } - + //TODO gatekeeper? } diff --git a/engine/tests/phpunit/Elgg/Amd/ConfigTest.php b/engine/tests/phpunit/Elgg/Amd/ConfigTest.php index 42700e6a162..59dbddc63fd 100644 --- a/engine/tests/phpunit/Elgg/Amd/ConfigTest.php +++ b/engine/tests/phpunit/Elgg/Amd/ConfigTest.php @@ -3,16 +3,16 @@ class ConfigTest extends \PHPUnit_Framework_TestCase { - + public function testCanConfigureModulePaths() { $amdConfig = new \Elgg\Amd\Config(); $amdConfig->addPath('jquery', '/some/path.js'); - + $configArray = $amdConfig->getConfig(); - + $this->assertEquals(array('/some/path'), $configArray['paths']['jquery']); } - + public function testCanConfigureModuleShims() { $amdConfig = new \Elgg\Amd\Config(); $amdConfig->addShim('jquery', array( @@ -20,20 +20,20 @@ public function testCanConfigureModuleShims() { 'exports' => 'jQuery', 'random' => 'stuff', )); - + $configArray = $amdConfig->getConfig(); $this->assertEquals(array('dep'), $configArray['shim']['jquery']['deps']); $this->assertEquals('jQuery', $configArray['shim']['jquery']['exports']); $this->assertFalse(isset($configArray['shim']['jquery']['random'])); } - + public function testCanRequireUnregisteredAmdModules() { $amdConfig = new \Elgg\Amd\Config(); $amdConfig->addDependency('jquery'); - + $configArray = $amdConfig->getConfig(); - + $this->assertEquals(array('jquery'), $configArray['deps']); } diff --git a/engine/tests/phpunit/Elgg/Amd/ViewFilterTest.php b/engine/tests/phpunit/Elgg/Amd/ViewFilterTest.php index aa30b81582c..84917623390 100644 --- a/engine/tests/phpunit/Elgg/Amd/ViewFilterTest.php +++ b/engine/tests/phpunit/Elgg/Amd/ViewFilterTest.php @@ -3,19 +3,19 @@ class ViewFilterTest extends \PHPUnit_Framework_TestCase { - + public function testInsertsNamesForAnonymousModules() { $viewFilter = new \Elgg\Amd\ViewFilter(); - + $originalContent = "// Comment\ndefine({})"; $filteredContent = $viewFilter->filter('js/my/mod.js', $originalContent); - + $this->assertEquals("// Comment\ndefine(\"my/mod\", {})", $filteredContent); } - + public function testLeavesNamedModulesAlone() { $viewFilter = new \Elgg\Amd\ViewFilter(); - + $originalContent = "// Comment\ndefine('any/mod', {})"; $filteredContent = $viewFilter->filter('js/my/mod.js', $originalContent); $this->assertEquals($originalContent, $filteredContent); diff --git a/engine/tests/phpunit/Elgg/Cache/MemoryPoolTest.php b/engine/tests/phpunit/Elgg/Cache/MemoryPoolTest.php index 6a7490ea01f..18fee8c5fcb 100644 --- a/engine/tests/phpunit/Elgg/Cache/MemoryPoolTest.php +++ b/engine/tests/phpunit/Elgg/Cache/MemoryPoolTest.php @@ -11,14 +11,14 @@ public function testGetDoesNotRegenerateValueFromCallbackOnHit() { $result = $pool->get('foo', function() { return 2; }); $this->assertEquals(1, $result); } - + public function testGetRegeneratesValueFromCallbackOnMiss() { $pool = new MemoryPool(); - + $result = $pool->get('foo', function() { return 1; }); $this->assertEquals(1, $result); } - + public function testInvalidateForcesTheSpecifiedValueToBeRegenerated() { $pool = new MemoryPool(); diff --git a/engine/tests/phpunit/Elgg/Cache/NullPoolTest.php b/engine/tests/phpunit/Elgg/Cache/NullPoolTest.php index 8737df2a31a..01414bc0366 100644 --- a/engine/tests/phpunit/Elgg/Cache/NullPoolTest.php +++ b/engine/tests/phpunit/Elgg/Cache/NullPoolTest.php @@ -8,17 +8,17 @@ public function testGetDoesNotRegenerateValueFromCallbackOnHit() { // NullPool never hits, so nothing to test here $this->assertTrue(true); } - + public function testGetRegeneratesValueFromCallbackOnMiss() { $pool = new NullPool(); - + $result = $pool->get('foo', function() { return 1; }); $this->assertEquals(1, $result); - + $result = $pool->get('foo', function() { return 2; }); $this->assertEquals(2, $result); } - + public function testInvalidateForcesTheSpecifiedValueToBeRegenerated() { // All values are always regenerated. Nothing to test here... $this->assertTrue(true); @@ -28,14 +28,14 @@ public function testNeverCachesResults() { $pool = new NullPool(); $increment = function() { static $counter; - + if (!isset($counter)) { $counter = 0; } - + return $counter++; }; - + $this->assertEquals(0, $pool->get('foo', $increment)); $this->assertEquals(1, $pool->get('foo', $increment)); $this->assertEquals(2, $pool->get('foo', $increment)); diff --git a/engine/tests/phpunit/Elgg/Cache/PoolTestCase.php b/engine/tests/phpunit/Elgg/Cache/PoolTestCase.php index a4151f65430..ddb52397f90 100644 --- a/engine/tests/phpunit/Elgg/Cache/PoolTestCase.php +++ b/engine/tests/phpunit/Elgg/Cache/PoolTestCase.php @@ -5,6 +5,6 @@ interface PoolTestCase { public function testGetDoesNotRegenerateValueFromCallbackOnHit(); public function testGetRegeneratesValueFromCallbackOnMiss(); - + public function testInvalidateForcesTheSpecifiedValueToBeRegenerated(); } \ No newline at end of file diff --git a/engine/tests/phpunit/Elgg/Cache/StashPoolTest.php b/engine/tests/phpunit/Elgg/Cache/StashPoolTest.php index a0a529cdab1..f8ddd81acda 100644 --- a/engine/tests/phpunit/Elgg/Cache/StashPoolTest.php +++ b/engine/tests/phpunit/Elgg/Cache/StashPoolTest.php @@ -13,14 +13,14 @@ public function testGetDoesNotRegenerateValueFromCallbackOnHit() { $result = $pool->get('foo', function() { return 2; }); $this->assertEquals(1, $result); } - + public function testGetRegeneratesValueFromCallbackOnMiss() { $pool = StashPool::createEphemeral(); - + $result = $pool->get('foo', function() { return 1; }); $this->assertEquals(1, $result); } - + public function testInvalidateForcesTheSpecifiedValueToBeRegenerated() { $pool = StashPool::createEphemeral(); @@ -82,9 +82,9 @@ public function invalidKeyProvider() { * Stash recommends always calling $item->lock() on miss to make sure that * the caching is as performant as possible by avoiding multiple * simultaneous regenerations of the same value. - * + * * http://www.stashphp.com/Invalidation.html#stampede-protection - * + * * 1. Create a new cache * 2. Get any entry * 3. Check that Stash\Item::lock() was called diff --git a/engine/tests/phpunit/Elgg/CommitMessageGitHookTest.php b/engine/tests/phpunit/Elgg/CommitMessageGitHookTest.php index b58d871d6c3..24d3af90ddb 100644 --- a/engine/tests/phpunit/Elgg/CommitMessageGitHookTest.php +++ b/engine/tests/phpunit/Elgg/CommitMessageGitHookTest.php @@ -20,7 +20,7 @@ public function setUp() { parent::setUp(); } - + /** * Test failures for missing input */ @@ -30,13 +30,13 @@ public function testRejectsEmptyStringInput() { $result = $this->runCmd($cmd, $output); $this->assertFalse($result, $output); } - + public function testRejectsEmptyFileInput() { $cmd = "$this->validateScript /dev/null"; $result = $this->runCmd($cmd, $output); $this->assertFalse($result, $output); } - + public function testRejectsEmptyPipeInput() { $cmd = "echo '' | $this->validateScript"; $result = $this->runCmd($cmd, $output); @@ -54,7 +54,7 @@ public function testAcceptsValidFileInput() { $result = $this->runCmd($cmd, $output); $this->assertTrue($result, $output); } - + public function testAcceptsValidPipeInput() { $msg = escapeshellarg(file_get_contents("{$this->filesDir}valid.txt")); $cmd = "echo $msg | $this->validateScript"; diff --git a/engine/tests/phpunit/Elgg/CommitMessageTest.php b/engine/tests/phpunit/Elgg/CommitMessageTest.php index 8030f6f069b..357a8ac4d0f 100644 --- a/engine/tests/phpunit/Elgg/CommitMessageTest.php +++ b/engine/tests/phpunit/Elgg/CommitMessageTest.php @@ -11,9 +11,9 @@ public function assertInvalidCommitMessages(array $msgs) { foreach ($msgs as $text) { $msg->setMsg($text); $this->assertFalse($msg->isValidFormat(), $text); - } + } } - + public function testRejectsMessagesWithoutSummary() { $this->assertInvalidCommitMessages(array( 'chore(test):', @@ -21,13 +21,13 @@ public function testRejectsMessagesWithoutSummary() { "chore(test):\n", )); } - + public function testRejectsMessagesWithoutType() { $this->assertInvalidCommitMessages(array( 'A bad commit message', )); } - + public function testRejectsMessagesWithoutComponent() { $this->assertInvalidCommitMessages(array( 'chore: Summary', @@ -35,14 +35,14 @@ public function testRejectsMessagesWithoutComponent() { 'chore(test):Summary', )); } - + public function assertIgnoreCommitMessages(array $ignored) { foreach ($ignored as $msg) { $msg = new CommitMessage($msg); $this->assertTrue($msg->shouldIgnore(), $msg); } } - + public function testShouldIgnoreMerges() { $this->assertIgnoreCommitMessages(array( 'Merge pull request', @@ -51,7 +51,7 @@ public function testShouldIgnoreMerges() { 'Merge release 1.8.18 into master.', )); } - + public function testShouldIgnoreReverts() { $this->assertIgnoreCommitMessages(array( 'Revert "fix(amd): removed elgg_require_js for backwards compatibility" @@ -59,13 +59,13 @@ public function testShouldIgnoreReverts() { This reverts commit 76584089bee2b3246c736edb6b250e149acf906f. Conflicts: - engine/lib/views.php' + engine/lib/views.php' )); } public function testCanParseMessagesWithoutBody() { $text = "chore(test): Summary"; - + $msg = new CommitMessage($text); $this->assertTrue($msg->isValidFormat()); diff --git a/engine/tests/phpunit/Elgg/ContextTest.php b/engine/tests/phpunit/Elgg/ContextTest.php index 0c26b6c5af6..81bd18cf3a3 100644 --- a/engine/tests/phpunit/Elgg/ContextTest.php +++ b/engine/tests/phpunit/Elgg/ContextTest.php @@ -4,60 +4,60 @@ class ContextTest extends \PHPUnit_Framework_TestCase { public function testPeekAndPopReturnNullByDefault() { $context = new Context(); - + $this->assertNull($context->peek()); $this->assertNull($context->pop()); - + // TODO: remove once global state is fully deprecated (2.0) _elgg_services()->setValue('context', new Context()); - + $this->assertNull(elgg_get_context()); $this->assertNull(elgg_pop_context()); } - + public function testPopReturnsAndRemovesTheMostRecentlyPushedContext() { $context = new Context(); $context->push('foo'); $context->push('bar'); - + $this->assertEquals('bar', $context->pop()); $this->assertEquals('foo', $context->pop()); - + // TODO: remove once global state is fully deprecated (2.0) _elgg_services()->setValue('context', new Context()); elgg_push_context('foo'); elgg_push_context('bar'); - + $this->assertEquals('bar', elgg_pop_context()); $this->assertEquals('foo', elgg_pop_context()); } - + public function testSetReplacesTheMostRecentlyPushedContext() { $context = new Context(); - + $context->push('foo'); $context->set('bar'); - + $this->assertNotTrue($context->contains('foo')); $this->assertEquals('bar', $context->pop()); $this->assertNotEquals('foo', $context->pop()); - + // TODO: remove once global state is fully deprecated (2.0) _elgg_services()->setValue('context', new Context()); elgg_push_context('foo'); elgg_set_context('bar'); - + $this->assertNotTrue(elgg_in_context('foo')); $this->assertEquals('bar', elgg_pop_context()); $this->assertNotEquals('foo', elgg_pop_context()); } - + public function testPeekReturnsTheMostRecentlyPushedContext() { $context = new Context(); - + $context->push('foo'); $this->assertEquals('foo', $context->peek()); $context->push('bar'); @@ -67,7 +67,7 @@ public function testPeekReturnsTheMostRecentlyPushedContext() { // TODO: remove once global state is fully deprecated (2.0) _elgg_services()->setValue('context', new Context()); - + elgg_push_context('foo'); $this->assertEquals('foo', elgg_get_context()); elgg_push_context('bar'); @@ -75,35 +75,35 @@ public function testPeekReturnsTheMostRecentlyPushedContext() { elgg_pop_context(); $this->assertEquals('foo', elgg_get_context()); } - + public function testContainsTellsYouIfAGivenContextIsInTheCurrentStack() { $context = new Context(); - + $context->push('foo'); $context->push('bar'); $context->push('baz'); - + $this->assertTrue($context->contains('foo')); $this->assertTrue($context->contains('bar')); $this->assertTrue($context->contains('baz')); - + $popped = $context->pop(); - + $this->assertFalse($context->contains($popped)); // TODO: remove once global state is fully deprecated (2.0) _elgg_services()->setValue('context', new Context()); - + elgg_push_context('foo'); elgg_push_context('bar'); elgg_push_context('baz'); - + $this->assertTrue(elgg_in_context('foo')); $this->assertTrue(elgg_in_context('bar')); $this->assertTrue(elgg_in_context('baz')); - + $popped = elgg_pop_context(); - + $this->assertFalse(elgg_in_context($popped)); } } \ No newline at end of file diff --git a/engine/tests/phpunit/Elgg/DatabaseTest.php b/engine/tests/phpunit/Elgg/DatabaseTest.php index 0b5431d2591..1b55175eab9 100644 --- a/engine/tests/phpunit/Elgg/DatabaseTest.php +++ b/engine/tests/phpunit/Elgg/DatabaseTest.php @@ -1,7 +1,7 @@ db; $this->dbClass = get_class($db); - + // Config class $reflectionClass = new ReflectionClass($db); $reflectionProperty = $reflectionClass->getProperty('config'); @@ -26,7 +26,7 @@ public function setUp() { $this->configClass = 'Elgg_Database_Config'; } } - + /** * @dataProvider scriptsWithOneStatement */ @@ -45,7 +45,7 @@ public function scriptsWithOneStatement() { array('one_statement_with_comments.sql'), ); } - + /** * @dataProvider scriptsWithMultipleStatements * @todo Use @see withConsecutive() to test consecutive method calls after upgrading to PHPUnit 4. @@ -63,7 +63,7 @@ public function test_runSqlScript_withMultipleStatements($script) { $this->expectExecutedStatement($db2, 2, $this->matches("INSERT INTO test_sometable (`key`) VALUES ('Value 3')")); $db2->runSqlScript($this->getFixture($script)); } - + public function scriptsWithMultipleStatements() { return array( array('multiple_statements.sql'), @@ -102,7 +102,7 @@ private function getFixture($filename) { DIRECTORY_SEPARATOR . 'sql' . DIRECTORY_SEPARATOR . $filename; } - + /** * @return PHPUnit_Framework_MockObject_MockObject */ @@ -117,7 +117,7 @@ private function getDbMock() ) ); } - + /** * @param PHPUnit_Framework_MockObject_MockObject $db * @param int $index diff --git a/engine/tests/phpunit/Elgg/Di/DiContainerTest.php b/engine/tests/phpunit/Elgg/Di/DiContainerTest.php index dade705d13f..4ff0e1040b8 100644 --- a/engine/tests/phpunit/Elgg/Di/DiContainerTest.php +++ b/engine/tests/phpunit/Elgg/Di/DiContainerTest.php @@ -85,26 +85,26 @@ public function testRemove() { $this->assertSame($di, $di->remove('foo')); $this->assertFalse($di->has('foo')); } - + public function testSetClassNames() { $di = new \Elgg\Di\DiContainer(); $di->setClassName('foo', self::TEST_CLASS); $this->assertInstanceOf(self::TEST_CLASS, $di->foo); - + $this->setExpectedException('InvalidArgumentException', 'Class names must be valid PHP class names'); $di->setClassName('foo', array()); } - + public function testSettingInvalidClassNameThrows() { $di = new \Elgg\Di\DiContainer(); - + $euro = "\xE2\x82\xAC"; - + $di->setClassName('foo1', "Foo2{$euro}3"); $di->setClassName('foo2', "\\Foo2{$euro}3"); $di->setClassName('foo3', "Foo2{$euro}3\\Foo2{$euro}3"); - + $this->setExpectedException('InvalidArgumentException', 'Class names must be valid PHP class names'); $di->setClassName('foo', 'Not Valid'); } diff --git a/engine/tests/phpunit/Elgg/Di/ServiceProviderTest.php b/engine/tests/phpunit/Elgg/Di/ServiceProviderTest.php index 6ed3c57cfd8..cc73ddc7375 100644 --- a/engine/tests/phpunit/Elgg/Di/ServiceProviderTest.php +++ b/engine/tests/phpunit/Elgg/Di/ServiceProviderTest.php @@ -16,7 +16,7 @@ public function testPropertiesReturnCorrectClassNames() { // requires _elgg_get_simplecache_root() to be defined //'amdConfig' => '\Elgg\Amd\Config', - + 'annotations' => '\Elgg\Database\Annotations', 'autoP' => '\ElggAutoP', 'autoloadManager' => '\Elgg\AutoloadManager', diff --git a/engine/tests/phpunit/Elgg/Filesystem/FileTest.php b/engine/tests/phpunit/Elgg/Filesystem/FileTest.php index 43d70f749f4..74001552305 100644 --- a/engine/tests/phpunit/Elgg/Filesystem/FileTest.php +++ b/engine/tests/phpunit/Elgg/Filesystem/FileTest.php @@ -5,12 +5,12 @@ use Gaufrette\Filesystem as GaufretteFilesystem; class FileTest extends \PHPUnit_Framework_TestCase { - + public function testCanCheckForItsOwnExistence() { $filesystem = Filesystem::createInMemory(); - + $filesystem->put('/foo/bar/bar.php', 'bar'); - + $realfile = new File($filesystem, '/foo/bar/bar.php'); $nonfile = new File($filesystem, '/foo/baz.php'); diff --git a/engine/tests/phpunit/Elgg/Filesystem/FilesystemTest.php b/engine/tests/phpunit/Elgg/Filesystem/FilesystemTest.php index 10278f06ee1..735c4475942 100644 --- a/engine/tests/phpunit/Elgg/Filesystem/FilesystemTest.php +++ b/engine/tests/phpunit/Elgg/Filesystem/FilesystemTest.php @@ -4,23 +4,23 @@ class FilesystemTest extends \PHPUnit_Framework_TestCase { public function testCanRecursivelyListAllFilesInThefilesystem() { $filesystem = Filesystem::createInMemory(); - + $filesystem->put('/foo/bar/bar.php', 'bar'); $filesystem->put('/foo/baz/baz.php', 'baz'); $filesystem->put('/foo/foo.php', 'foo'); $filesystem->put('/qux.php', 'qux'); - + $this->assertEquals(4, count($filesystem->getFiles())); } - + public function testCanRecursivelyListAllFilesAtAGivenSubdir() { $filesystem = Filesystem::createInMemory(); - + $filesystem->put('/foo/bar/bar.php', 'bar'); $filesystem->put('/foo/baz/baz.php', 'baz'); $filesystem->put('/foo/foo.php', 'foo'); $filesystem->put('/qux.php', 'qux'); - + $this->assertEquals(3, count($filesystem->getFiles('/foo/'))); $this->assertEquals(3, count($filesystem->getFiles('/foo'))); $this->assertEquals(3, count($filesystem->getFiles('foo/'))); @@ -31,10 +31,10 @@ public function testCanRecursivelyListAllFilesAtAGivenSubdir() { $this->assertEquals(1, count($filesystem->getFiles('foo/bar/'))); $this->assertEquals(1, count($filesystem->getFiles('foo/bar'))); } - + public function testChrootReturnsANewFilesystemThatOnlyHasAccessToTheGivenSubdir() { $filesystem = Filesystem::createInMemory(); - + $filesystem->put('/foo/bar/bar.php', 'bar'); $filesystem->put('/foo/baz/baz.php', 'baz'); $filesystem->put('/foo/foo.php', 'foo'); @@ -50,34 +50,34 @@ public function testChrootReturnsANewFilesystemThatOnlyHasAccessToTheGivenSubdir $this->assertEquals(1, count($filesystem->chroot('/foo/bar')->getFiles())); $this->assertEquals(1, count($filesystem->chroot('foo/bar')->getFiles())); } - + public function testCanGetAnyFileInThisFileSystemEvenIfTheFileDoesNotExistYet() { $filesystem = Filesystem::createInMemory(); - + $this->assertFalse($filesystem->getFile('foo.php')->exists()); } - + public function testCannotChrootOutsideItself() { $filesystem = Filesystem::createInMemory(); - + $filesystem->put('/foo/bar.php', 'bar'); $filesystem->put('/baz.php', 'baz'); - + $filesystem->chroot('foo')->chroot('..'); - + // TODO: Expect to throw exception? Silently cap at existing root? $this->markTestIncomplete(); } - + public function testCannotGetFileOutsideItself() { $filesystem = Filesystem::createInMemory(); - + $filesystem->put('/foo/bar.php', 'bar'); $filesystem->put('/baz.php', 'baz'); - + // TODO: Throw exception? $file = $filesystem->chroot('foo')->getFile('../baz.php'); - + $this->assertNotEquals('baz', $file->getContents()); } } \ No newline at end of file diff --git a/engine/tests/phpunit/Elgg/Forms/StickyForms.php b/engine/tests/phpunit/Elgg/Forms/StickyForms.php index b094def3cf9..9387235381b 100644 --- a/engine/tests/phpunit/Elgg/Forms/StickyForms.php +++ b/engine/tests/phpunit/Elgg/Forms/StickyForms.php @@ -7,11 +7,11 @@ class StickyFormsTest extends TestCase { public function testIsStickyReturnsTrueForFormsMarkedAsSticky() { $this->markTestIncomplete(); } - + public function testIsStickyReturnsFalseForClearedStickyForms() { $this->markTestIncomplete(); } - + /** * It's important to test that this information is actually stored in the * session because that is a meaningful implementation detail that guarantees diff --git a/engine/tests/phpunit/Elgg/HooksRegistrationService.php b/engine/tests/phpunit/Elgg/HooksRegistrationService.php index d6375a78477..e0b003db6c2 100644 --- a/engine/tests/phpunit/Elgg/HooksRegistrationService.php +++ b/engine/tests/phpunit/Elgg/HooksRegistrationService.php @@ -9,7 +9,7 @@ public function setUp() { $this->mock = $this->getMockForAbstractClass('\Elgg\HooksRegistrationService'); } - + public function testCanRegisterHandlers() { $this->assertTrue($this->mock->registerHandler('foo', 'bar', 'callback1')); $this->assertTrue($this->mock->registerHandler('foo', 'bar', 'callback2')); @@ -32,7 +32,7 @@ public function testCanRegisterHandlers() { // check possibly invalid callbacks $this->assertFalse($this->mock->registerHandler('foo', 'bar', 1234)); } - + public function testCanUnregisterHandlers() { $this->mock->registerHandler('foo', 'bar', 'callback1'); $this->mock->registerHandler('foo', 'bar', 'callback2', 100); @@ -46,7 +46,7 @@ public function testCanUnregisterHandlers() { ) ) ); - + $this->assertSame($expected, $this->mock->getAllHandlers()); // check unregistering things that aren't registered diff --git a/engine/tests/phpunit/Elgg/Http/InputTest.php b/engine/tests/phpunit/Elgg/Http/InputTest.php index 8697924df72..b73ee595008 100644 --- a/engine/tests/phpunit/Elgg/Http/InputTest.php +++ b/engine/tests/phpunit/Elgg/Http/InputTest.php @@ -4,27 +4,27 @@ use PHPUnit_Framework_TestCase as TestCase; class InputTest extends TestCase { - + public function testGetInputDefaultsToProvidedDefaultValue() { $this->markTestIncomplete(); } - + public function testGetInputTriggersValidateInputHookIfAndOnlyIfFilteringIsEnabled() { $this->markTestIncomplete(); } - + public function testGetInputCanBeOverriddenBySetInput() { $this->markTestIncomplete(); } - + public function testGetInputChecksBothPostAndGetParams() { $this->markTestIncomplete(); } - + public function testGetInputPushesInputContextDuringFiltering() { $this->markTestIncomplete(); } - + public function testFilterTagsGlobal() { $this->markTestIncomplete(); } diff --git a/engine/tests/phpunit/Elgg/Http/NativeSessionStorageTest.php b/engine/tests/phpunit/Elgg/Http/NativeSessionStorageTest.php index f76f1faa7c5..84536fe55bd 100644 --- a/engine/tests/phpunit/Elgg/Http/NativeSessionStorageTest.php +++ b/engine/tests/phpunit/Elgg/Http/NativeSessionStorageTest.php @@ -2,7 +2,7 @@ namespace Elgg\Http; /** * If you make a change in the tests for native storage, update the tests for mock storage - * + * * Travis-CI cannot handle these tests because PHPUnit output is echoed preventing * the session from starting. */ diff --git a/engine/tests/phpunit/Elgg/PluginHooksServiceTest.php b/engine/tests/phpunit/Elgg/PluginHooksServiceTest.php index 3c122211ee7..44f663b7b81 100644 --- a/engine/tests/phpunit/Elgg/PluginHooksServiceTest.php +++ b/engine/tests/phpunit/Elgg/PluginHooksServiceTest.php @@ -3,25 +3,25 @@ class PluginHooksServiceTest extends \PHPUnit_Framework_TestCase { - + public function testTriggerCallsRegisteredHandlers() { $hooks = new \Elgg\PluginHooksService(); - + $this->setExpectedException('InvalidArgumentException'); - + $hooks->registerHandler('foo', 'bar', array('\Elgg\PluginHooksServiceTest', 'throwInvalidArg')); $hooks->trigger('foo', 'bar'); } - + public function testCanPassParamsAndChangeReturnValue() { $hooks = new \Elgg\PluginHooksService(); $hooks->registerHandler('foo', 'bar', array('\Elgg\PluginHooksServiceTest', 'changeReturn')); - + $returnval = $hooks->trigger('foo', 'bar', array( 'testCase' => $this, ), 1); - + $this->assertEquals(2, $returnval); } @@ -37,7 +37,7 @@ public function testUncallableHandlersAreLogged() { $hooks->trigger('foo', 'bar'); } - + public static function returnTwo() { return 2; } diff --git a/engine/tests/phpunit/Elgg/RouterTest.php b/engine/tests/phpunit/Elgg/RouterTest.php index ff7f52df77c..487f2770dd6 100644 --- a/engine/tests/phpunit/Elgg/RouterTest.php +++ b/engine/tests/phpunit/Elgg/RouterTest.php @@ -33,33 +33,33 @@ function setUp() { function hello_page_handler($segments, $identifier) { include "{$this->pages}/hello.php"; - + return true; } function testCanRegisterFunctionsAsPageHandlers() { $registered = $this->router->registerPageHandler('hello', array($this, 'hello_page_handler')); - + $this->assertTrue($registered); $path = "hello/1/\xE2\x82\xAC"; // euro sign $qs = http_build_query(array('__elgg_uri' => $path)); $request = \Elgg\Http\Request::create("http://localhost/?$qs"); - + ob_start(); $handled = $this->router->route($request); $output = ob_get_clean(); - + $this->assertTrue($handled); $this->assertEquals($path, $output); } - + function testCanUnregisterPageHandlers() { $this->router->registerPageHandler('hello', array($this, 'hello_page_handler')); $this->router->unregisterPageHandler('hello'); - + $request = \Elgg\Http\Request::create('http://localhost/hello/'); - + ob_start(); $handled = $this->router->route($request); $output = ob_get_clean(); @@ -82,21 +82,21 @@ function testCanUnregisterPageHandlers() { function testRouteSupportsSettingHandlerInHookResultForBackwardsCompatibility() { $this->router->registerPageHandler('foo', array($this, 'foo_page_handler')); $this->hooks->registerHandler('route', 'bar', array($this, 'bar_route_handler')); - + $query = http_build_query(array('__elgg_uri' => 'bar/baz')); ob_start(); $this->router->route(\Elgg\Http\Request::create("http://localhost/?$query")); ob_end_clean(); - + $this->assertEquals(1, $this->fooHandlerCalls); } - + function foo_page_handler() { $this->fooHandlerCalls++; return true; } - + function bar_route_handler($hook, $type, $value, $params) { $value['handler'] = 'foo'; return $value; diff --git a/engine/tests/phpunit/Elgg/Structs/ArrayCollectionTest.php b/engine/tests/phpunit/Elgg/Structs/ArrayCollectionTest.php index 22bea8dc386..52eb720ad6c 100644 --- a/engine/tests/phpunit/Elgg/Structs/ArrayCollectionTest.php +++ b/engine/tests/phpunit/Elgg/Structs/ArrayCollectionTest.php @@ -7,17 +7,17 @@ class ArrayCollectionTest extends TestCase { public function testCountIsAccurate() { $zeroItems = new ArrayCollection(); $this->assertEquals(0, count($zeroItems)); - + $oneItem = new ArrayCollection(array('one')); $this->assertEquals(1, count($oneItem)); - + $twoItems = new ArrayCollection(array('one', 'two')); $this->assertEquals(2, count($twoItems)); } - + public function testContainsDoesNotImplicitlyCastSimilarValues() { $collection = new ArrayCollection(array('1', false)); - + $this->assertTrue($collection->contains('1')); $this->assertTrue($collection->contains(false)); @@ -25,25 +25,25 @@ public function testContainsDoesNotImplicitlyCastSimilarValues() { $this->assertFalse($collection->contains(0)); $this->assertFalse($collection->contains('')); } - + public function testIsTraversable() { $collection = new ArrayCollection(array('one', 'two', 'three')); - + $items = array(); foreach ($collection as $item) { $items[] = $item; } - + $this->assertEquals(array('one', 'two', 'three'), $items); } - + public function testIsFilterable() { $collection = new ArrayCollection(array(0, 1, 2, 3, 4)); - + $filtered = $collection->filter(function($number) { return $number > 2; }); - + $this->assertFalse($filtered->contains(0)); $this->assertFalse($filtered->contains(1)); $this->assertFalse($filtered->contains(2)); @@ -52,14 +52,14 @@ public function testIsFilterable() { $this->assertEquals(2, count($filtered)); $this->assertNotSame($filtered, $collection); } - + public function testIsMappable() { $collection = new ArrayCollection(array(0, 1, 2, 3, 4)); - + $mapped = $collection->map(function($number) { return $number * 2; }); - + $this->assertTrue($mapped->contains(0)); $this->assertTrue($mapped->contains(2)); $this->assertTrue($mapped->contains(4)); diff --git a/engine/tests/phpunit/Elgg/TravisValidateCommitMsgTest.php b/engine/tests/phpunit/Elgg/TravisValidateCommitMsgTest.php index 3a958dfd9fc..adfa6e02f28 100644 --- a/engine/tests/phpunit/Elgg/TravisValidateCommitMsgTest.php +++ b/engine/tests/phpunit/Elgg/TravisValidateCommitMsgTest.php @@ -11,7 +11,7 @@ public function setUp() { parent::setUp(); $this->travisScript = $this->scriptsDir . 'travis/check_commit_msgs.sh'; - + $this->markTestSkipped('Testing against particular SHAs is too flaky.'); } diff --git a/engine/tests/phpunit/Elgg/ViewsServiceTest.php b/engine/tests/phpunit/Elgg/ViewsServiceTest.php index c19ae8e9350..865eb233c88 100644 --- a/engine/tests/phpunit/Elgg/ViewsServiceTest.php +++ b/engine/tests/phpunit/Elgg/ViewsServiceTest.php @@ -3,70 +3,70 @@ class ViewsServiceTest extends \PHPUnit_Framework_TestCase { - + public function setUp() { $this->viewsDir = dirname(dirname(__FILE__)) . "/test_files/views"; - + $this->hooks = new \Elgg\PluginHooksService(); $this->logger = $this->getMock('\Elgg\Logger', array(), array(), '', false); - + $this->views = new \Elgg\ViewsService($this->hooks, $this->logger); $this->views->autoregisterViews('', "$this->viewsDir/default", "$this->viewsDir/", 'default'); - // supports deprecation wrapper for $vars['user'] + // supports deprecation wrapper for $vars['user'] _elgg_services()->setValue('session', new \ElggSession(new \Elgg\Http\MockSessionStorage())); } - + public function testCanExtendViews() { $this->views->extendView('foo', 'bar'); - + // Unextending valid extension succeeds. $this->assertTrue($this->views->unextendView('foo', 'bar')); // Unextending non-existent extension "fails." $this->assertFalse($this->views->unextendView('foo', 'bar')); } - + public function testRegistersPhpFilesAsViews() { $this->assertTrue($this->views->viewExists('js/interpreted.js')); } - + public function testRegistersStaticFilesAsViews() { $this->assertTrue($this->views->viewExists('js/static.js')); } - + public function testUsesPhpToRenderNonStaticViews() { $this->assertEquals("// PHP", $this->views->renderView('js/interpreted.js')); } - + public function testDoesNotUsePhpToRenderStaticViews() { $expected = file_get_contents("$this->viewsDir/default/js/static.js"); $this->assertEquals($expected, $this->views->renderView('js/static.js')); } - + public function testStoresDirectoryForViewLocation() { $this->assertEquals("$this->viewsDir/", $this->views->getViewLocation('js/interpreted.js', 'default')); } - + public function testViewtypesCanFallBack() { $this->views->registerViewtypeFallback('mobile'); $this->assertTrue($this->views->doesViewtypeFallBack('mobile')); } - + public function testViewsCanExistBasedOnViewtypeFallback() { $this->views->registerViewtypeFallback('mobile'); $this->assertTrue($this->views->viewExists('js/interpreted.js', 'mobile')); $this->assertEquals('// PHP', $this->views->renderView('js/interpreted.js', array(), false, 'mobile')); } - + public function testCanRegisterViewsAsCacheable() { $this->assertFalse($this->views->isCacheableView('js/interpreted.js')); - + $this->views->registerCacheableView('js/interpreted.js'); - + $this->assertTrue($this->views->isCacheableView('js/interpreted.js')); } - + public function testStaticViewsAreAlwaysCacheable() { $this->assertTrue($this->views->isCacheableView('js/static.js')); } diff --git a/engine/tests/phpunit/Elgg/WidgetsServiceTest.php b/engine/tests/phpunit/Elgg/WidgetsServiceTest.php index 36cbe36cac6..f71906e4518 100644 --- a/engine/tests/phpunit/Elgg/WidgetsServiceTest.php +++ b/engine/tests/phpunit/Elgg/WidgetsServiceTest.php @@ -7,7 +7,7 @@ class WidgetsServiceTest extends \PHPUnit_Framework_TestCase { public function elgg_set_config($key, $val) { //do nothing, that's only for BC } - + public function testRegisterTypeParametersControl() { $service = new \Elgg\WidgetsService(array($this, 'elgg_set_config')); @@ -20,13 +20,13 @@ public function testRegisterTypeParametersControl() { $this->assertFalse($service->registerType('widget_type', null, 'Widget description')); $this->assertFalse($service->registerType('widget_type', false, 'Widget description')); } - + /** * Tests register, exists and unregisrer */ public function testCanRegisterType() { $service = new \Elgg\WidgetsService(array($this, 'elgg_set_config')); - + $this->assertFalse($service->validateType('widget_type')); $this->assertFalse($service->validateType('not_registered_widget')); @@ -36,7 +36,7 @@ public function testCanRegisterType() { $this->assertTrue($service->registerType('widget_type_con_mul', 'Widget name4', 'Widget description4', array('dashboard', 'settings'), true)); //overwrite $this->assertTrue($service->registerType('widget_type_con_mul', 'Widget name5', 'Widget description5', array('dashboard', 'settings'), true)); - + $this->assertTrue($service->validateType('widget_type')); $this->assertTrue($service->validateType('widget_type_con')); $this->assertTrue($service->validateType('widget_type_mul')); @@ -51,7 +51,7 @@ public function testCanRegisterType() { * @param \Elgg\WidgetsService $service */ public function testRegistrationParametersPreserveContext($service) { - + $params = array( //exact, context, expected array(false, 'all', array('widget_type', 'widget_type_mul')), @@ -63,7 +63,7 @@ public function testRegistrationParametersPreserveContext($service) { array(true, 'profile', array('widget_type_con')), array(true, 'settings', array('widget_type_con_mul')), ); - + //is returned set of handlers the same as expected foreach ($params as $case) { list($exact, $context, $expected) = $case; @@ -72,25 +72,25 @@ public function testRegistrationParametersPreserveContext($service) { sort($actual); $this->assertEquals($expected, $actual); } - + return $service; } - + /** * @depends testRegistrationParametersPreserveContext * @param \Elgg\WidgetsService $service */ public function testRegistrationParametersPreserveMultiple($service) { - + $resps = array( 'widget_type' => false, 'widget_type_con' => false, 'widget_type_mul' => true, 'widget_type_con_mul' => true, ); - + $contexts = array('all', 'dashboard', 'profile', 'settings'); - + foreach (array(false, true) as $exact) { foreach ($contexts as $context) { $items = $service->getTypes($context, $exact); @@ -103,25 +103,25 @@ public function testRegistrationParametersPreserveMultiple($service) { } } } - + return $service; } - + /** * @depends testRegistrationParametersPreserveMultiple * @param \Elgg\WidgetsService $service */ public function testRegistrationParametersPreserveNameDescription($service) { - + $resps = array( 'widget_type' => array('Widget name1', 'Widget description1'), 'widget_type_con' => array('Widget name2', 'Widget description2'), 'widget_type_mul' => array('Widget name3', 'Widget description3'), 'widget_type_con_mul' => array('Widget name5', 'Widget description5'), ); - + $contexts = array('all', 'dashboard', 'profile', 'settings'); - + foreach (array(false, true) as $exact) { foreach ($contexts as $context) { $items = $service->getTypes($context, $exact); @@ -136,10 +136,10 @@ public function testRegistrationParametersPreserveNameDescription($service) { } } } - + return $service; } - + /** * @depends testRegistrationParametersPreserveNameDescription * @param \Elgg\WidgetsService $service @@ -151,13 +151,13 @@ public function testCanUnregisterType($service) { $this->assertTrue($service->unregisterType('widget_type_mul')); $this->assertTrue($service->unregisterType('widget_type_con_mul')); $this->assertFalse($service->unregisterType('widget_not_registered')); - + $this->assertFalse($service->validateType('widget_type')); $this->assertFalse($service->validateType('widget_type_con')); $this->assertFalse($service->validateType('widget_type_mul')); $this->assertFalse($service->validateType('not_registered_widget')); } - + //TODO get, view, create, canEditLayout, defaultWidgetsInit, createDefault, defaultWidgetsPermissionsOverride } diff --git a/engine/tests/phpunit/ElggEntityTest.php b/engine/tests/phpunit/ElggEntityTest.php index cea46a483b9..dc6f7460ee8 100644 --- a/engine/tests/phpunit/ElggEntityTest.php +++ b/engine/tests/phpunit/ElggEntityTest.php @@ -1,7 +1,7 @@ obj->$name = '77'; - $this->assertSame(77, $this->obj->$name); + $this->assertSame(77, $this->obj->$name); } } public function testSettingUnsettableAttributes() { foreach (array('guid', 'time_updated', 'last_action') as $name) { $this->obj->$name = 'foo'; - $this->assertNotEquals('foo', $this->obj->$name); - } + $this->assertNotEquals('foo', $this->obj->$name); + } } public function testSettingMetadataNoDatabase() { diff --git a/engine/tests/phpunit/ElggExtenderTest.php b/engine/tests/phpunit/ElggExtenderTest.php index 71481d3ffaa..15d7e9aab0e 100644 --- a/engine/tests/phpunit/ElggExtenderTest.php +++ b/engine/tests/phpunit/ElggExtenderTest.php @@ -27,6 +27,6 @@ public function testSettingValueExplicitly() { $obj = $this->getMockForAbstractClass('\ElggExtender'); $obj->setValue('36', 'integer'); $this->assertSame(36, $obj->value); - $this->assertEquals('integer', $obj->value_type); + $this->assertEquals('integer', $obj->value_type); } } diff --git a/engine/tests/phpunit/ElggPriorityListTest.php b/engine/tests/phpunit/ElggPriorityListTest.php index 2cf3997497b..55d50c9870d 100644 --- a/engine/tests/phpunit/ElggPriorityListTest.php +++ b/engine/tests/phpunit/ElggPriorityListTest.php @@ -194,7 +194,7 @@ public function testGetElement() { public function testPriorityCollision() { $pl = new \ElggPriorityList(); - + $elements = array( 5 => 'Test element 5', 6 => 'Test element 6', @@ -218,7 +218,7 @@ public function testIterator() { 0 => 'Test element 0', 5 => 'Test element 5', ); - + $pl = new \ElggPriorityList($elements); foreach ($pl as $priority => $element) { @@ -270,5 +270,5 @@ function test_sort($elements) { $this->assertSame($elements_sorted_string, $test_elements); } - + } \ No newline at end of file diff --git a/engine/tests/phpunit/ElggUpgradeTest.php b/engine/tests/phpunit/ElggUpgradeTest.php index 3df8ad8e40d..d88eec0ddf9 100644 --- a/engine/tests/phpunit/ElggUpgradeTest.php +++ b/engine/tests/phpunit/ElggUpgradeTest.php @@ -16,7 +16,7 @@ public function setUp() { $this->obj->_callable_egefps = array($this, 'mock_egefps'); } - + public function mock_egefps($options) { return array(); } diff --git a/engine/tests/phpunit/ElggUserTest.php b/engine/tests/phpunit/ElggUserTest.php index 05efb2c91fe..f30d1e5829f 100644 --- a/engine/tests/phpunit/ElggUserTest.php +++ b/engine/tests/phpunit/ElggUserTest.php @@ -6,7 +6,7 @@ protected function setUp() { // required by \ElggEntity when setting the owner/container _elgg_services()->setValue('session', new \ElggSession(new \Elgg\Http\MockSessionStorage())); } - + public function testCanConstructWithoutArguments() { $this->assertNotNull(new \ElggUser()); } @@ -15,8 +15,8 @@ public function testSettingUnsettableAttributes() { $obj = new \ElggUser(); foreach (array('prev_last_action', 'last_login', 'prev_last_login') as $name) { $obj->$name = 'foo'; - $this->assertNotEquals('foo', $obj->$name); - } + $this->assertNotEquals('foo', $obj->$name); + } } } \ No newline at end of file diff --git a/engine/tests/phpunit/test_files/commit_messages/valid.txt b/engine/tests/phpunit/test_files/commit_messages/valid.txt index a6c0d714080..b2aa7e9e48e 100644 --- a/engine/tests/phpunit/test_files/commit_messages/valid.txt +++ b/engine/tests/phpunit/test_files/commit_messages/valid.txt @@ -5,4 +5,4 @@ It has a correctly formatted type, component, and summary, and includes a body with references to issues in the last lines. Refs #123, #456 -Fixes #789 +Fixes #789 diff --git a/engine/tests/phpunit/test_files/views/default/js/interpreted.js.php b/engine/tests/phpunit/test_files/views/default/js/interpreted.js.php index 5e4a60b5464..812acea6f5a 100644 --- a/engine/tests/phpunit/test_files/views/default/js/interpreted.js.php +++ b/engine/tests/phpunit/test_files/views/default/js/interpreted.js.php @@ -1 +1 @@ -// \ No newline at end of file +// short_open_tag off
- + php_version 5.6 diff --git a/install/css/install.css b/install/css/install.css index 4035d8730d5..27f7fe9ca04 100644 --- a/install/css/install.css +++ b/install/css/install.css @@ -205,11 +205,11 @@ input[type="submit"] { color: #fff; background: #4690d6; border: 4px solid #4690d6; - + -webkit-border-radius: 4px; -moz-border-radius: 4px; border-radius: 4px; - + width: auto; height: 35px; padding: 2px 6px; @@ -238,14 +238,14 @@ select { color: #ffffff; background: #4690d6; border: 4px solid #4690d6; - + border-radius: 4px; - + padding: .25em .5em; margin: .5em; cursor: pointer; float: right; - + text-decoration: none; } diff --git a/install/languages/en.php b/install/languages/en.php index 810f1d98c9f..de447416d9f 100644 --- a/install/languages/en.php +++ b/install/languages/en.php @@ -151,7 +151,7 @@ 'install:error:rewrite:altserver' => 'The rewrite rules test failed. You need to configure your web server with Elgg\'s rewrite rules and try again.', 'install:error:rewrite:unknown' => 'Oof. We couldn\'t figure out what kind of web server is running on your server and it failed the rewrite rules. We cannot offer any specific advice. Please check the troubleshooting link.', 'install:warning:rewrite:unknown' => 'Your server does not support automatic testing of the rewrite rules and your browser does not support checking via JavaScript. You can continue the installation, but you may experience problems with your site. You can manually test the rewrite rules by clicking this link: test. You will see the word success if the rules are working.', - + // Bring over some error messages you might see in setup 'exception:contact_admin' => 'An unrecoverable error has occurred and has been logged. If you are the site administrator check your settings file, otherwise contact the site administrator with the following information:', 'DatabaseException:WrongCredentials' => "Elgg couldn't connect to the database using the given credentials. Check the settings file.", diff --git a/js/classes/ElggEntity.js b/js/classes/ElggEntity.js index 5636d2a46a6..524dfd2646c 100644 --- a/js/classes/ElggEntity.js +++ b/js/classes/ElggEntity.js @@ -1,6 +1,6 @@ /** * Create a new ElggEntity - * + * * @class Represents an ElggEntity * @property {number} guid * @property {string} type @@ -11,7 +11,7 @@ * @property {number} time_created * @property {number} time_updated * @property {string} url - * + * */ elgg.ElggEntity = function(o) { $.extend(this, o); diff --git a/js/classes/ElggPriorityList.js b/js/classes/ElggPriorityList.js index 900d8d0ca5f..95d8527ab63 100644 --- a/js/classes/ElggPriorityList.js +++ b/js/classes/ElggPriorityList.js @@ -12,7 +12,7 @@ elgg.ElggPriorityList = function() { * * @param {Object} obj The object to insert * @param {Number} opt_priority An optional priority to insert at. - * + * * @return {Void} */ elgg.ElggPriorityList.prototype.insert = function(obj, opt_priority) { diff --git a/js/lib/comments.js b/js/lib/comments.js index acbc41ea32a..b08fcbfad43 100644 --- a/js/lib/comments.js +++ b/js/lib/comments.js @@ -97,7 +97,7 @@ elgg.comments.Comment.prototype = { /** * Initialize comment inline editing - * + * * @return void */ elgg.comments.init = function() { diff --git a/js/lib/configuration.js b/js/lib/configuration.js index 85eab9276de..d2edb977860 100644 --- a/js/lib/configuration.js +++ b/js/lib/configuration.js @@ -11,7 +11,7 @@ elgg.get_site_url = function() { /** * Get the URL for the cached file - * + * * @param {String} type * @param {String} view * @return {String} The site URL. diff --git a/js/lib/elgglib.js b/js/lib/elgglib.js index 5cab265057c..894548860ca 100644 --- a/js/lib/elgglib.js +++ b/js/lib/elgglib.js @@ -435,7 +435,7 @@ elgg.parse_url = function(url, component, expand) { // It was modified to fix mailto: and javascript: support. expand = expand || false; component = component || false; - + var re_str = // scheme (and user@ testing) '^(?:(?![^:@]+:[^:@/]*@)([^:/?#.]+):)?(?://)?' @@ -525,7 +525,7 @@ elgg.parse_str = function(string) { params[key] = value; } } - + return params; }; diff --git a/js/lib/hooks.js b/js/lib/hooks.js index 56423e166a7..ecd7a71e68b 100644 --- a/js/lib/hooks.js +++ b/js/lib/hooks.js @@ -96,7 +96,7 @@ elgg.trigger_hook = function(name, type, params, value) { elgg.provide('all.all', hooks); var hooksList = []; - + if (name != 'all' && type != 'all') { hooksList.push(hooks[name][type]); } diff --git a/js/lib/security.js b/js/lib/security.js index abd3b50494a..9641406ce5a 100644 --- a/js/lib/security.js +++ b/js/lib/security.js @@ -13,7 +13,7 @@ elgg.security.tokenRefreshTimer = null; * @param {Object} json The json representation of a token containing __elgg_ts and __elgg_token * @return {Void} */ -elgg.security.setToken = function(json) { +elgg.security.setToken = function(json) { //update the convenience object elgg.security.token = json; @@ -31,7 +31,7 @@ elgg.security.setToken = function(json) { /** * Security tokens time out so we refresh those every so often. - * + * * @private */ elgg.security.refreshToken = function() { @@ -62,7 +62,7 @@ elgg.security.addToken = function(data) { var parts = elgg.parse_url(data), args = {}, base = ''; - + if (parts['host'] === undefined) { if (data.indexOf('?') === 0) { // query string diff --git a/js/lib/session.js b/js/lib/session.js index e1e3a9cee95..9b3f17fbfab 100644 --- a/js/lib/session.js +++ b/js/lib/session.js @@ -8,22 +8,22 @@ elgg.provide('elgg.session'); * @param {string} name * @param {string} value * @param {Object} options - * + * * {number|Date} options[expires] * {string} options[path] * {string} options[domain] * {boolean} options[secure] - * + * * @return {string|undefined} The value of the cookie, if only name is specified. Undefined if no value set */ elgg.session.cookie = function(name, value, options) { var cookies = [], cookie = [], i = 0, date, valid = true; - + //elgg.session.cookie() if (elgg.isUndefined(name)) { return document.cookie; } - + //elgg.session.cookie(name) if (elgg.isUndefined(value)) { if (document.cookie && document.cookie !== '') { @@ -37,15 +37,15 @@ elgg.session.cookie = function(name, value, options) { } return undefined; } - + // elgg.session.cookie(name, value[, opts]) options = options || {}; - + if (elgg.isNull(value)) { value = ''; options.expires = -1; } - + cookies.push(name + '=' + value); if (options.expires) { @@ -60,7 +60,7 @@ elgg.session.cookie = function(name, value, options) { cookies.push('expires=' + date.toUTCString()); } } - + // CAUTION: Needed to parenthesize options.path and options.domain // in the following expressions, otherwise they evaluate to undefined // in the packed version for some reason. @@ -71,11 +71,11 @@ elgg.session.cookie = function(name, value, options) { if (options.domain) { cookies.push('domain=' + (options.domain)); } - + if (options.secure) { cookies.push('secure'); } - + document.cookie = cookies.join('; '); }; diff --git a/js/lib/ui.autocomplete.js b/js/lib/ui.autocomplete.js index 1308013caf8..28b37ffd9f4 100644 --- a/js/lib/ui.autocomplete.js +++ b/js/lib/ui.autocomplete.js @@ -1,5 +1,5 @@ /** - * + * */ elgg.provide('elgg.autocomplete'); diff --git a/js/lib/ui.friends_picker.js b/js/lib/ui.friends_picker.js index 98e06379a6e..4509140466a 100644 --- a/js/lib/ui.friends_picker.js +++ b/js/lib/ui.friends_picker.js @@ -6,14 +6,14 @@ jQuery.fn.friendsPicker = function(iterator) { - var settings; + var settings; settings = $.extend({ easeFunc: "easeOutExpo", easeTime: 1000, toolTip: false }, settings); return this.each(function() { var container = $(this); container.addClass("friends-picker"); - // set panelwidth manually as it's hidden initially - adjust this value for different themes/pagewidths + // set panelwidth manually as it's hidden initially - adjust this value for different themes/pagewidths var panelWidth = 730; // count the panels in the container @@ -37,7 +37,7 @@ jQuery.fn.friendsPicker = function(iterator) { // generate a-z tabs $(this).before("