diff options
136 files changed, 948 insertions, 1573 deletions
diff --git a/CHANGES.txt b/CHANGES.txt index fb5870700..5232deadc 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -1,3 +1,60 @@ +Version 1.8.2 +(December 21, 2011 from https://github.com/Elgg/Elgg/tree/1.8) + + Enhancements: + * Added a 404 page + * Widgets controls now using the menu system + * Admins can edit users' account information + * Embed uploader supports uploading into groups + * Add a control panel widget for easy access to cache flushing and upgrading + * Comments now have a unqiue URL with fragment identifier + * JavaScript language files are cacheable + * jQuery form script only loaded when required + + Bugfixes: + * Fixed default widgets + * Fixed activity filtering + * Embedding an image now inserts a medium sized image + * Search plugin only uses mbstring extension if enabled + * Site pages links returned to footer + * Fixed URL creation for users with non-ASCII characters in username + * The wire username parsing supports periods in usernames + * Returned the posting area to the main wire page + * Fixed layout issue on pages with a fragment identifier in URL + * Added support for call elgg_load_js() in header and footer + * Fixed user picker + * Fixed uservalidationbyemail plugin ignoring the actions of other plugins + * Fixed bug preventing the creation of admin users + * Fixed deleting a widget with JavaScript disabled + * Fixed many bugs in the unit/integration tests + + +Version 1.8.1 +(November 16, 2011 from https://github.com/Elgg/Elgg/tree/1.8) + + Enhancements: + * Completed styling of user validation admin page + * Adding rel=nofollow for non-trusted links + * Added direct icon loading for profile avatars in profile plugin + * Improved the structure of content views to make styling easier + * Updated version of jQuery to 1.6.4 + * Added basic support for icon size customization + * Added a toggle for gallery/list view in file plugin + * Added support for passing CSS classes to icon views + * Added support for non http URLs to Elgg's normalize functions + * Added better support for the 404 forward if a page handler does handle a request + + Bugfixes: + * Fixed autocomplete and userpicker + * Fixed RSS and web service-related view types + * Fixed walled garden display issues + * Added work around for IE/TinyMCE/embed insert problem + * Implemented ElggUser.isAdmin() JavaScript method + * Fixed the date views and JavaScript datepicker + * Fixed horizontal radio buttons styling + * Modules only display header if there is content for it + + Version 1.8.1b (October 11, 2011 from git://github.com/Elgg/Elgg.git) @@ -152,343 +209,3 @@ Version 1.8.0 (Jackie) Elgg 1.8.0.1 was released immediately after 1.8.0 to correct a problem in installation. - - -Previous and Merged Changes: - -Version 1.7.11 -(August 15, 2011 from http://github.com/Elgg/elgg) - - Security Enhancements: - * Fixed possible XSS vector in the embed plugin. Thanks to Aung Khant from YEHG for the report. - * Fixed possible SQL exposure exploit in the search plugin. Thanks again to Aung Khant. - * Fixed possible SQL injection vector in the search plugin. Thanks to Lostmon Lords for the report. - - Bugfixes: - * Filtering by content works in the dashboard again. - * Dragging widgets works in IE9. - - API Changes: - * Deleting a container will delete all contained objects regardless of access_id. - * setLocation() and setLatLong() no longer double escapes strings. - * Calling elgg_list_entities() with count set no longer breaks the display. - - -Version 1.7.10 -(June 14, 2011 from http://code.elgg.org/branches/1.7) - - Security Enhancements: - * Changes to prevent numerous reflected cross site scripting vectors. Thanks to Aung Khant for - the reports! - - Enhancements: - * Banned users are more apparent in user lists and profiles. - - Bugfixes: - * TinyMCE: Using Elgg's default font to prevent small font sizes. - * Files: Optimizations to allow uploading and downloading larger files. - * Fixed bugs preventing users from adding and removing friends in Friends Collections. - * $CONFIG->lastcache is correctly set for pages that regenerate the cache. - - API Changes: - * Added unit tests for access collections. - * Added can_edit_access_collection(). - * Access collection functions no longer check permissions. Do this in actions instead. - - -Version 1.7.9 -(June 1, 2011 from http://code.elgg.org/branches/1.7) - - Security Enhancements: - * Blocking possible access to restricted pages if headers are output too early. Thanks to Vazco - for reporting! - - Bugfixes: - * Admins can delete Pages again. - * TinyMCE upgraded to 3.4.2 to fix IE support. - * Autocomplete input works correctly. - * Fixed Message Board "all" posts. - * Fixed deleting internal messages on some non-English sites. - * Better feedback if an error occurs when saving widgets. - * Messages from deleted users no longer show the recipient's avatar. - * Https logins on fully https sites work correctly. - - API Changes: - * Added "creating", "river" plugin hook. - * User metadata is registered as independent higher in the boot sequence. - * Group ACLs are updated correctly when joining a non-logged in user to a group. - * Can return 0 for plugin hook 'comments', 'count'. - - -Version 1.7.8 -(April 4, 2011 from http://code.elgg.org/branches/1.7) - - Security Enhancements: - * Properly encoding search queries (Thanks to lord epsylon (of Lorea) for the report!) - - Bugfixes: - * Blogs - Fixed disappearing blog draft issue. - * Groups - Editing a topic from discussion list page works now. - * Search - Group names used in titles. - * InviteFriends - Invitation link no longer shows up when logged out. - * Messages - Denormalized the message calculation for better performance. - * Sorting by time_created in relationship functions supported. - * Metadata and annotation names can now be updated. - * Fixed error with deleting a user with disabled entities. - * Removed unnecessary executable permissions on a number of files. (Thanks to - pauloortiz for the report!) - - API Changes: - * Added delete_submenu_item() for removing sidebar menu items. - - -Version 1.7.7 -(January 31, 2011 from http://code.elgg.org/branches/1.7) - - Security Enhancements: - * Only admins can view the unvalidated users page (Thanks to Manacim - Medriano for the report!) - - Bugfixes: - * Fixed deprecation notices for locales that use comma as radix point. - * Groups - Files can be completely disabled per group. - * Pages - Deleting and creating subpages is restricted to owner or group member. - * Groups - group icons deleted when group is deleted. - * Pagination will not display when all content id displayed. - * Fixed issue with get_context() when trailing slash is missing. - - API Changes: - * Added $CONFIG->action_token_timeout. - * Added callback option to elgg_get_entities(). - - -Version 1.7.6 -(December 23, 2010 from http://code.elgg.org/branches/1.7) - - Security Enhancements: - * Fixed a possible SQL injection attack when using a crafted - URL. Thanks to Gerrit Venema from Gol Gol (golgol.nl) for - the report. - - Bugfixes: - * Pages - Fixed "All Pages" link on "All Site Pages" page. - * Messages - Fixed invalid URLs when using old-style - pg/messages/<username> links. - * Messages - Fixed redirect after deleting a message. - - API Changes: - * Added get_entities_from_access_collection() and deprecated it. - * is_registered_entity_type() returns correctly when requesting - just a type and not a subtype. - - -Version 1.7.5 -(November 26, 2010 from http://code.elgg.org/branches/1.7) - - Security Enhancements: - * Fixed a security flaw in the Bookmarks plugin that could - allow an XSS attack using crafted URLs. Thanks to Akhilesh - Gupta for the bug report. - * Fixed a security flaw in the widgets system that could allow - an XSS attack using crafted URLs. - - Bugfixes: - * Checking for mismatched passwords before creating user when - manually adding users. - * 'large' size profile icons created when cropped. - * Fixed menu entry for user's files link. - * Fixed caching issues with plugin-added view types. - * Fixed XFN links on profile page and user lists. - * Fixed PHP warnings about invalid foreaches in plugins.php - * Fixed problems in elgg_get_entities_*() when using an array - for owner_guid. - * Group profile edit action correctly encodes and saves array input. - * Language string corrections. - - UI/UX Changes: - * Users must verify their current password before they can changing - passwords. - * Using pagehandlers instead of mod/mod_name/ calls in Blogs, - Bookmarks, Members, Pages, The Wire, Groups, Invite Friends, - and Messages. - * Added a page to view Wire posts by user. - - API Changes: - * Added remove_group_tool_option(). - * Wrapped Twitter Service's vendor's oAuth lib in class_exists(). - * Added elgg_list_entities_from_relationship(). - * Exposed order_by param in list_entities_from_relationship(). - * Added a default annotation view. - - -Version 1.7.4 -(October 14, 2010 from http://code.elgg.org/branches/1.7) - - Bugfixes: - * Upgrade Twitter Services to use oAuth so The Wire can post - to Twitter. See http://el.gg/twitteroauth for instructions. - * WSOD fixed when viewing an invalid profile page. - * Checking for mismatched passwords earlier in registration to avoid - creating a user who can never log in and wasting a username/email. - * POST data in the web services API is correctly quoted on servers - with magic quotes enabled. - * WSOD fixed when trying to update an invalid entity. - * Group file widget only shows when Files are enabled for the group. - * Fixed misformatting of some group forum posts in the River. - * Fixed resizing tall non-square images. - * Non-English languages work when using memcache. - * User avatar menus work when switching filters on River Dashboard page. - * CSS is correctly cached for newly enabled plugins. - * Can no longer add bookmarks without a title. Previous bookmarks with - out titles can now be deleted. - - UI/UX Changes: - * Pages: Admin users can edit user-defined "Welcome page." - * Pages: Group "Welcome page" can be edited. - * User Validation: Added an admin section for unvalidated users. An - admin user can resend validation request, validate, or delete - unvalidated users. - - API Changes: - * test_ip() removed. - * is_ip_in_range() removed. - * Read/write DB connections can use different credentials. - * Twitter services plugin allows other plugins to tweet - if the user authorizes them. See twitterservice/README.txt - - -Version 1.7.3 -(September 2, 2010 from http://code.elgg.org/branches/1.7) - - Security enhancements: - * Fixed a security flaw that allowed an SQL injection attack - using crafted POSTs. Thanks to Georg-Christian Pranschke of - www.sensepost.com for the bug report. - - UI/UX Changes: - * Entering an invalid captcha now forwards to referring page. - - Bugfixes: - * Multiple owners support fixed for legacy get_entity*() functions. - * "Edit details" and "Edit profile icon" only show up for user's own - profile. - * get_objects_in_group() works correctly. - - -Version 1.7.2 -(August 18, 2010 from http://code.elgg.org/elgg/branches/1.7) - - UI Changes: - * Group "widgets" have been standardized with new blog and bookmark widgets. - * New group member listing page. - * Group forum topics can be edited including title and status. - * Added a group creation river entry. - - Bugfixes: - * Fixed preview and draft saving for blog plugin. - * Page titles are now editable. - * Fixed several bugs with the new elgg_get* and elgg_list* functions. - * Groups do not show up as personal friend collections anymore. - * Fixed an upgrade issue with utf8 usernames. - * Encoding of & in group forums is fixed. - - API changes: - * Added elgg_list_entities_from_metadata(). - * Added elgg_send_email(). - * Added remove_from_river_by_id(). - * Added remove_from_register() for removing menu items. - * Added elgg_get_excerpt(). - * Added elgg_get_friendly_title() and elgg_get_friendly_time(). - - -Version 1.7.1 -(April 21, 2010 from http://code.elgg.org/elgg/branches/1.7) - - UI changes: - * (Unused) tags field removed from external pages. - * Languages fixes in groups. - * Installation checks database settings before writing settings.php. - * Made the widgets more consistent in their UI. - - Bugfixes: - * Pagination fixed. - * Profile icons fixed for PHP-CGI users who were seeing incorrect avatars. - * Tag search works in groups and members. - * Tag clouds correctly link to tag search. - * RSS views added to search. - * Wrapper function for get_entities() correctly rewrites container_guid to - owner_guid. - * output/url correctly appends http:// again. - * full_url() urlencode()'s ' and " to avoid a security problem in IE. - - API changes: - * Moved admin flag to users_entity table and added ElggUser->isAdmin(), - ->makeAdmin(), and ->removeAdmin() to replace the metadata. - * Plugin hook for reported content includes the report object. - * UTF8 upgrade checks server defaults before running to avoid - corrupted strings. - * Tags lib updated to elgg_get_*() interface. - * Can get entities based upon annotation/metadata owner_guid. - * Moved friendly time and friendly title into overridable views. - * Added unregister_notification_handler(). - * Added remove_widget_type(). - * Search supports container_guid. - - -Version 1.7.0 -(March 2, 2010 from http://code.elgg.org/elgg/trunk/) - - User-visible changes: - * UTF8 now saved correctly in database. #1151 - * Unit tests added to System diagnostics. - * Debug values output to screen when enabled in admin settings. - * Users can now log in from multiple computers or browsers concurrently. - * Misconfigured plugins no longer break the site. #1454 - * User display names cannot have HTML or be longer than 50 characters. - * New search system. - - Bugfixes: - * Searching by tag with extended characters now works. #1151, #1231 - * Searching for entities works properly with case-insensitive metadata. #1326 - * Invalid views now default to 'default' view. #1161. - * Metadata cache now handles a 0 string. #1227 - * ElggPlugin get() now works with 0. #1286 - * Metadata __isset() now works for falsy values (except NULL). #1414 - * clear_plugin_setting() now only clears a single setting. - * Submenu entries are correctly calculated after a simplecache refresh. - - API changes: - * New plugin hook system:unit_test for adding files to unit tests. - * $is_admin global deprecated; use elgg_set_ignore_access() instead. - * Deprecated get_entities(). Use elgg_get_entities(). - * Deprecated get_entities_from_metadata(). Use elgg_get_entities_from_metadata(). - * Deprecated get_entities_from_relationship() and g_e_f_relationships_and_meta(). Use elgg_get_entities_from_relationship(). - * Deprecated get_entities_from_access_id(). Use elgg_get_entities_from_access_id(). - * Deprecated get_entities_from_annotations(). Use elgg_get_entities_from_annotations(). - * Reorganized directory file path to rely on GUID instead of username. - * annotation_id column added to the river database table. - * remove_from_river_by_annotation() added. - * unregister_elgg_event_handler() and unregister_plugin_hook() added. #1465 - * clear_all_plugin_settings() added. - * get_entity_relationships() supports inverse relationships. #1472. - * can_write_to_container() can be overridden with the container_permissions_check hook. #1164 (part 2). - * Deprecated search_for_*(). - * Deprecated search_list*(). - * Added elgg_deprecated_notice(). - * ElggEntity::countEntitiesFromRelationship() supports inverse relationships. #1325 - * delete_relationship() triggers the hook delete:relationship and passes the relationship object. #1213 - * added ElggEntity::removeRelationship(). #1376. - * get_entity_dates() supports order by. #1406. - * Added elgg_http_add_url_query_elements(). - * Added elgg_register_tag_metadata_name() and elgg_get_registered_tag_metadata_names(); - * Added ElggEntity::getTags(). - * Added elgg_add_action_tokens_to_url(). - - Services API: - * Separated user and api authenticate processing - * hmac signature encoding now compatible with OAuth - * New plugin hook api_key:use for keeping stats on key usage - * New plugin hook rest:init so plugins can configure authentication modules - * Moved auth.gettoken to POST for increased security - * Fixed REST POST bug #1114 - * Fixed #881, #1214, #1215, #1216, #1217, #1218, #1219, #1220, #1298, #1364 diff --git a/actions/admin/site/flush_cache.php b/actions/admin/site/flush_cache.php new file mode 100644 index 000000000..b81f5fc83 --- /dev/null +++ b/actions/admin/site/flush_cache.php @@ -0,0 +1,10 @@ +<?php +/** + * Flush all the caches + */ + +elgg_invalidate_simplecache(); +elgg_filepath_cache_reset(); + +system_message(elgg_echo('admin:cache:flushed')); +forward(REFERER);
\ No newline at end of file diff --git a/actions/admin/site/update_basic.php b/actions/admin/site/update_basic.php index c809dc671..45f00a20d 100644 --- a/actions/admin/site/update_basic.php +++ b/actions/admin/site/update_basic.php @@ -24,4 +24,5 @@ if (datalist_get('default_site')) { set_config('language', get_input('language'), $site->getGUID()); } +system_message(elgg_echo('admin:configuration:success')); forward(REFERER);
\ No newline at end of file diff --git a/actions/login.php b/actions/login.php index 5934d1423..c717faadd 100644 --- a/actions/login.php +++ b/actions/login.php @@ -28,7 +28,6 @@ if (empty($username) || empty($password)) { } // check if logging in with email address -// @todo Are usernames with @ not allowed? if (strpos($username, '@') !== FALSE && ($users = get_user_by_email($username))) { $username = $users[0]->username; } diff --git a/actions/profile/edit.php b/actions/profile/edit.php index e86053b07..8ca60f246 100644 --- a/actions/profile/edit.php +++ b/actions/profile/edit.php @@ -62,12 +62,7 @@ if ($name) { register_error(elgg_echo('user:name:fail')); } elseif ($owner->name != $name) { $owner->name = $name; - // @todo this is weird...giving two notifications? - if ($owner->save()) { - system_message(elgg_echo('user:name:success')); - } else { - register_error(elgg_echo('user:name:fail')); - } + $owner->save(); } } diff --git a/actions/user/requestnewpassword.php b/actions/user/requestnewpassword.php index 5dfa24952..f1d4fa43c 100644 --- a/actions/user/requestnewpassword.php +++ b/actions/user/requestnewpassword.php @@ -8,6 +8,11 @@ $username = get_input('username'); +// allow email addresses +if (strpos($username, '@') !== false && ($users = get_user_by_email($username))) { + $username = $users[0]->username; +} + $user = get_user_by_username($username); if ($user) { if (send_new_password_request($user->guid)) { diff --git a/actions/useradd.php b/actions/useradd.php index 3df41af79..fdcd7e438 100644 --- a/actions/useradd.php +++ b/actions/useradd.php @@ -37,7 +37,7 @@ try { if ($guid) { $new_user = get_entity($guid); - if ($uew_user && $admin && elgg_is_admin_logged_in()) { + if ($new_user && $admin && elgg_is_admin_logged_in()) { $new_user->makeAdmin(); } diff --git a/engine/classes/ElggEntity.php b/engine/classes/ElggEntity.php index fdf2a80ea..df87082fe 100644 --- a/engine/classes/ElggEntity.php +++ b/engine/classes/ElggEntity.php @@ -1335,6 +1335,9 @@ abstract class ElggEntity extends ElggData implements $this->attributes['tables_loaded']++; } + // guid needs to be an int http://trac.elgg.org/ticket/4111 + $this->attributes['guid'] = (int)$this->attributes['guid']; + // Cache object handle if ($this->attributes['guid']) { cache_entity($this); diff --git a/engine/classes/ElggGroup.php b/engine/classes/ElggGroup.php index 49ba27204..0190e5eac 100644 --- a/engine/classes/ElggGroup.php +++ b/engine/classes/ElggGroup.php @@ -309,7 +309,7 @@ class ElggGroup extends ElggEntity * * @param ElggUser $user User * - * @return void + * @return bool */ public function leave(ElggUser $user) { return leave_group($this->getGUID(), $user->getGUID()); @@ -322,7 +322,7 @@ class ElggGroup extends ElggEntity * * @param int $guid GUID of an ElggGroup entity * - * @return true + * @return bool */ protected function load($guid) { // Test to see if we have the generic stuff @@ -340,7 +340,7 @@ class ElggGroup extends ElggEntity $row = get_group_entity_as_row($guid); if (($row) && (!$this->isFullyLoaded())) { // If $row isn't a cached copy then increment the counter - $this->attributes['tables_loaded'] ++; + $this->attributes['tables_loaded']++; } // Now put these into the attributes array as core values @@ -349,6 +349,9 @@ class ElggGroup extends ElggEntity $this->attributes[$key] = $value; } + // guid needs to be an int http://trac.elgg.org/ticket/4111 + $this->attributes['guid'] = (int)$this->attributes['guid']; + return true; } diff --git a/engine/classes/ElggMemcache.php b/engine/classes/ElggMemcache.php index 1fd3be0d1..a54c29723 100644 --- a/engine/classes/ElggMemcache.php +++ b/engine/classes/ElggMemcache.php @@ -161,7 +161,7 @@ class ElggMemcache extends ElggSharedMemoryCache { } $result = $this->memcache->set($key, $data, null, $expires); - if (!$result) { + if ($result === false) { elgg_log("MEMCACHE: FAILED TO SAVE $key", 'ERROR'); } @@ -181,7 +181,7 @@ class ElggMemcache extends ElggSharedMemoryCache { $key = $this->_makeMemcacheKey($key); $result = $this->memcache->get($key); - if (!$result) { + if ($result === false) { elgg_log("MEMCACHE: FAILED TO LOAD $key", 'ERROR'); } diff --git a/engine/classes/ElggObject.php b/engine/classes/ElggObject.php index caccfb038..0b8340697 100644 --- a/engine/classes/ElggObject.php +++ b/engine/classes/ElggObject.php @@ -110,7 +110,7 @@ class ElggObject extends ElggEntity { $row = get_object_entity_as_row($guid); if (($row) && (!$this->isFullyLoaded())) { // If $row isn't a cached copy then increment the counter - $this->attributes['tables_loaded'] ++; + $this->attributes['tables_loaded']++; } // Now put these into the attributes array as core values @@ -119,6 +119,9 @@ class ElggObject extends ElggEntity { $this->attributes[$key] = $value; } + // guid needs to be an int http://trac.elgg.org/ticket/4111 + $this->attributes['guid'] = (int)$this->attributes['guid']; + return true; } diff --git a/engine/classes/ElggPluginManifest.php b/engine/classes/ElggPluginManifest.php index eacc16455..7592eb667 100644 --- a/engine/classes/ElggPluginManifest.php +++ b/engine/classes/ElggPluginManifest.php @@ -553,7 +553,7 @@ class ElggPluginManifest { } /** - * Returns the admin interface to use. + * Should this plugin be activated when Elgg is installed * * @return bool */ diff --git a/engine/classes/ElggSite.php b/engine/classes/ElggSite.php index 16b80b9d3..2d6238a19 100644 --- a/engine/classes/ElggSite.php +++ b/engine/classes/ElggSite.php @@ -128,7 +128,7 @@ class ElggSite extends ElggEntity { $row = get_site_entity_as_row($guid); if (($row) && (!$this->isFullyLoaded())) { // If $row isn't a cached copy then increment the counter - $this->attributes['tables_loaded'] ++; + $this->attributes['tables_loaded']++; } // Now put these into the attributes array as core values @@ -137,6 +137,9 @@ class ElggSite extends ElggEntity { $this->attributes[$key] = $value; } + // guid needs to be an int http://trac.elgg.org/ticket/4111 + $this->attributes['guid'] = (int)$this->attributes['guid']; + return true; } @@ -418,10 +421,10 @@ class ElggSite extends ElggEntity { 'action/security/refreshtoken', 'ajax/view/js/languages', 'upgrade\.php', - 'xml-rpc\.php', - 'mt/mt-xmlrpc\.cgi', 'css/.*', - 'js/.*' + 'js/.*', + 'cache/css/.*', + 'cache/js/.*', ); // include a hook for plugin authors to include public pages diff --git a/engine/classes/ElggUser.php b/engine/classes/ElggUser.php index 75ac008f6..a1c7147a5 100644 --- a/engine/classes/ElggUser.php +++ b/engine/classes/ElggUser.php @@ -114,7 +114,7 @@ class ElggUser extends ElggEntity $row = get_user_entity_as_row($guid); if (($row) && (!$this->isFullyLoaded())) { // If $row isn't a cached copy then increment the counter - $this->attributes['tables_loaded'] ++; + $this->attributes['tables_loaded']++; } // Now put these into the attributes array as core values @@ -123,6 +123,9 @@ class ElggUser extends ElggEntity $this->attributes[$key] = $value; } + // guid needs to be an int http://trac.elgg.org/ticket/4111 + $this->attributes['guid'] = (int)$this->attributes['guid']; + return true; } diff --git a/engine/classes/XMLRPCArrayParameter.php b/engine/classes/XMLRPCArrayParameter.php deleted file mode 100644 index a8edccba7..000000000 --- a/engine/classes/XMLRPCArrayParameter.php +++ /dev/null @@ -1,56 +0,0 @@ -<?php - -/** - * An array containing other XMLRPCParameter objects. - * - * @package Elgg.Core - * @subpackage XMLRPC - * - */ -class XMLRPCArrayParameter extends XMLRPCParameter -{ - /** - * Construct an array. - * - * @param array $parameters Optional array of parameters, if not provided - * then addField must be used. - */ - function __construct($parameters = NULL) { - parent::__construct(); - - if (is_array($parameters)) { - foreach ($parameters as $v) { - $this->addField($v); - } - } - } - - /** - * Add a field to the container. - * - * @param XMLRPCParameter $value The value. - * - * @return void - */ - public function addField(XMLRPCParameter $value) { - if (!is_array($this->value)) { - $this->value = array(); - } - - $this->value[] = $value; - } - - /** - * Converts XML array to string - * - * @return string - */ - function __toString() { - $params = ""; - foreach ($this->value as $value) { - $params .= "$value"; - } - - return "<array><data>$params</data></array>"; - } -} diff --git a/engine/classes/XMLRPCBase64Parameter.php b/engine/classes/XMLRPCBase64Parameter.php deleted file mode 100644 index 7db0a761c..000000000 --- a/engine/classes/XMLRPCBase64Parameter.php +++ /dev/null @@ -1,28 +0,0 @@ -<?php -/** - * A base 64 encoded blob of binary. - * - * @package Elgg.Core - * @subpackage XMLRPC - */ -class XMLRPCBase64Parameter extends XMLRPCParameter { - /** - * Construct a base64 encoded block - * - * @param string $blob Unencoded binary blob - */ - function __construct($blob) { - parent::__construct(); - - $this->value = base64_encode($blob); - } - - /** - * Convert to string - * - * @return string - */ - function __toString() { - return "<value><base64>{$value}</base64></value>"; - } -} diff --git a/engine/classes/XMLRPCBoolParameter.php b/engine/classes/XMLRPCBoolParameter.php deleted file mode 100644 index 607841cb8..000000000 --- a/engine/classes/XMLRPCBoolParameter.php +++ /dev/null @@ -1,30 +0,0 @@ -<?php -/** - * A boolean. - * - * @package Elgg.Core - * @subpackage XMLRPC - */ -class XMLRPCBoolParameter extends XMLRPCParameter { - - /** - * New bool parameter - * - * @param bool $value Value - */ - function __construct($value) { - parent::__construct(); - - $this->value = (bool)$value; - } - - /** - * Convert to string - * - * @return string - */ - function __toString() { - $code = ($this->value) ? "1" : "0"; - return "<value><boolean>{$code}</boolean></value>"; - } -} diff --git a/engine/classes/XMLRPCCall.php b/engine/classes/XMLRPCCall.php deleted file mode 100644 index 8eeba0c29..000000000 --- a/engine/classes/XMLRPCCall.php +++ /dev/null @@ -1,62 +0,0 @@ -<?php -/** - * An XMLRPC call - * - * @package Elgg.Core - * @subpackage XMLRPC - */ -class XMLRPCCall { - /** Method name */ - private $methodname; - - /** Parameters */ - private $params; - - /** - * Construct a new XML RPC Call - * - * @param string $xml XML - */ - function __construct($xml) { - $this->_parse($xml); - } - - /** - * Return the method name associated with the call. - * - * @return string - */ - public function getMethodName() { return $this->methodname; } - - /** - * Return the parameters. - * Returns a nested array of XmlElement. - * - * @see XmlElement - * @return array - */ - public function getParameters() { return $this->params; } - - /** - * Parse the xml into its components according to spec. - * This first version is a little primitive. - * - * @param string $xml XML - * - * @return void - */ - private function _parse($xml) { - $xml = xml_to_object($xml); - - // sanity check - if ((isset($xml->name)) && (strcasecmp($xml->name, "methodCall") != 0)) { - throw new CallException(elgg_echo('CallException:NotRPCCall')); - } - - // method name - $this->methodname = $xml->children[0]->content; - - // parameters - $this->params = $xml->children[1]->children; - } -} diff --git a/engine/classes/XMLRPCDateParameter.php b/engine/classes/XMLRPCDateParameter.php deleted file mode 100644 index 93bbbd8f5..000000000 --- a/engine/classes/XMLRPCDateParameter.php +++ /dev/null @@ -1,33 +0,0 @@ -<?php -/** - * An ISO8601 data and time. - * - * @package Elgg.Core - * @subpackage XMLRPC - */ -class XMLRPCDateParameter extends XMLRPCParameter { - /** - * Construct a date - * - * @param int $timestamp The unix timestamp, or blank for "now". - */ - function __construct($timestamp = 0) { - parent::__construct(); - - $this->value = $timestamp; - - if (!$timestamp) { - $this->value = time(); - } - } - - /** - * Convert to string - * - * @return string - */ - function __toString() { - $value = date('c', $this->value); - return "<value><dateTime.iso8601>{$value}</dateTime.iso8601></value>"; - } -} diff --git a/engine/classes/XMLRPCDoubleParameter.php b/engine/classes/XMLRPCDoubleParameter.php deleted file mode 100644 index b7834650e..000000000 --- a/engine/classes/XMLRPCDoubleParameter.php +++ /dev/null @@ -1,29 +0,0 @@ -<?php -/** - * A double precision signed floating point number. - * - * @package Elgg.Core - * @subpackage XMLRPC - */ -class XMLRPCDoubleParameter extends XMLRPCParameter { - - /** - * New XML Double - * - * @param int $value Value - */ - function __construct($value) { - parent::__construct(); - - $this->value = (float)$value; - } - - /** - * Convert to string - * - * @return string - */ - function __toString() { - return "<value><double>{$this->value}</double></value>"; - } -} diff --git a/engine/classes/XMLRPCErrorResponse.php b/engine/classes/XMLRPCErrorResponse.php deleted file mode 100644 index 425c075cc..000000000 --- a/engine/classes/XMLRPCErrorResponse.php +++ /dev/null @@ -1,36 +0,0 @@ -<?php - -/** - * XMLRPC Error Response - * - * @package Elgg.Core - * @subpackage XMLRPC - */ -class XMLRPCErrorResponse extends XMLRPCResponse { - /** - * Set the error response and error code. - * - * @param string $message The message - * @param int $code Error code (default = system error as defined by - * http://xmlrpc-epi.sourceforge.net/specs/rfc.fault_codes.php) - */ - function __construct($message, $code = -32400) { - $this->addParameter( - new XMLRPCStructParameter( - array ( - 'faultCode' => new XMLRPCIntParameter($code), - 'faultString' => new XMLRPCStringParameter($message) - ) - ) - ); - } - - /** - * Output to XML. - * - * @return string - */ - public function __toString() { - return "<methodResponse><fault><value>{$this->parameters[0]}</value></fault></methodResponse>"; - } -} diff --git a/engine/classes/XMLRPCIntParameter.php b/engine/classes/XMLRPCIntParameter.php deleted file mode 100644 index 0fc146165..000000000 --- a/engine/classes/XMLRPCIntParameter.php +++ /dev/null @@ -1,29 +0,0 @@ -<?php -/** - * An Integer. - * - * @package Elgg.Core - * @subpackage XMLRPC - */ -class XMLRPCIntParameter extends XMLRPCParameter { - - /** - * A new XML int - * - * @param int $value Value - */ - function __construct($value) { - parent::__construct(); - - $this->value = (int)$value; - } - - /** - * Convert to string - * - * @return string - */ - function __toString() { - return "<value><i4>{$this->value}</i4></value>"; - } -} diff --git a/engine/classes/XMLRPCParameter.php b/engine/classes/XMLRPCParameter.php deleted file mode 100644 index ffbad8082..000000000 --- a/engine/classes/XMLRPCParameter.php +++ /dev/null @@ -1,16 +0,0 @@ -<?php -/** - * Superclass for all RPC parameters. - * - * @package Elgg.Core - * @subpackage XMLRPC - */ -abstract class XMLRPCParameter { - protected $value; - - /** - * Set initial values - */ - function __construct() { } - -} diff --git a/engine/classes/XMLRPCResponse.php b/engine/classes/XMLRPCResponse.php deleted file mode 100644 index a6256d385..000000000 --- a/engine/classes/XMLRPCResponse.php +++ /dev/null @@ -1,71 +0,0 @@ -<?php - -/** - * XML-RPC Response. - * - * @package Elgg.Core - * @subpackage XMLRPC - */ -abstract class XMLRPCResponse { - /** An array of parameters */ - protected $parameters = array(); - - /** - * Add a parameter here. - * - * @param XMLRPCParameter $param The parameter. - * - * @return void - */ - public function addParameter(XMLRPCParameter $param) { - if (!is_array($this->parameters)) { - $this->parameters = array(); - } - - $this->parameters[] = $param; - } - - /** - * Add an integer - * - * @param int $value Value - * - * @return void - */ - public function addInt($value) { - $this->addParameter(new XMLRPCIntParameter($value)); - } - - /** - * Add a string - * - * @param string $value Value - * - * @return void - */ - public function addString($value) { - $this->addParameter(new XMLRPCStringParameter($value)); - } - - /** - * Add a double - * - * @param int $value Value - * - * @return void - */ - public function addDouble($value) { - $this->addParameter(new XMLRPCDoubleParameter($value)); - } - - /** - * Add a boolean - * - * @param bool $value Value - * - * @return void - */ - public function addBoolean($value) { - $this->addParameter(new XMLRPCBoolParameter($value)); - } -} diff --git a/engine/classes/XMLRPCStringParameter.php b/engine/classes/XMLRPCStringParameter.php deleted file mode 100644 index 35b28214b..000000000 --- a/engine/classes/XMLRPCStringParameter.php +++ /dev/null @@ -1,30 +0,0 @@ -<?php -/** - * A string. - * - * @package Elgg.Core - * @subpackage XMLRPC - */ -class XMLRPCStringParameter extends XMLRPCParameter { - - /** - * A new XML string - * - * @param string $value Value - */ - function __construct($value) { - parent::__construct(); - - $this->value = $value; - } - - /** - * Convert to XML string - * - * @return string - */ - function __toString() { - $value = htmlentities($this->value); - return "<value><string>{$value}</string></value>"; - } -} diff --git a/engine/classes/XMLRPCStructParameter.php b/engine/classes/XMLRPCStructParameter.php deleted file mode 100644 index 694ddf5df..000000000 --- a/engine/classes/XMLRPCStructParameter.php +++ /dev/null @@ -1,55 +0,0 @@ -<?php - -/** - * A structure containing other XMLRPCParameter objects. - * - * @package Elgg.Core - * @subpackage XMLRPC - */ -class XMLRPCStructParameter extends XMLRPCParameter { - /** - * Construct a struct. - * - * @param array $parameters Optional associated array of parameters, if - * not provided then addField must be used. - */ - function __construct($parameters = NULL) { - parent::__construct(); - - if (is_array($parameters)) { - foreach ($parameters as $k => $v) { - $this->addField($k, $v); - } - } - } - - /** - * Add a field to the container. - * - * @param string $name The name of the field. - * @param XMLRPCParameter $value The value. - * - * @return void - */ - public function addField($name, XMLRPCParameter $value) { - if (!is_array($this->value)) { - $this->value = array(); - } - - $this->value[$name] = $value; - } - - /** - * Convert to string - * - * @return string - */ - function __toString() { - $params = ""; - foreach ($this->value as $k => $v) { - $params .= "<member><name>$k</name>$v</member>"; - } - - return "<value><struct>$params</struct></value>"; - } -} diff --git a/engine/classes/XMLRPCSuccessResponse.php b/engine/classes/XMLRPCSuccessResponse.php deleted file mode 100644 index e02e82c5c..000000000 --- a/engine/classes/XMLRPCSuccessResponse.php +++ /dev/null @@ -1,22 +0,0 @@ -<?php -/** - * Success Response - * - * @package Elgg.Core - * @subpackage XMLRPC - */ -class XMLRPCSuccessResponse extends XMLRPCResponse { - /** - * Output to XML. - * - * @return string - */ - public function __toString() { - $params = ""; - foreach ($this->parameters as $param) { - $params .= "<param>$param</param>\n"; - } - - return "<methodResponse><params>$params</params></methodResponse>"; - } -} diff --git a/engine/handlers/page_handler.php b/engine/handlers/page_handler.php index 1ed295b7d..7eca37bb1 100644 --- a/engine/handlers/page_handler.php +++ b/engine/handlers/page_handler.php @@ -13,12 +13,16 @@ * * cache * * services * * export - * * mt - * * xml-rpc.php + * * js + * * css * * rewrite.php * * tag (deprecated, reserved for backwards compatibility) * * pg (deprecated, reserved for backwards compatibility) * + * These additionally are reserved for the xml-rpc plugin + * * mt + * * xml-rpc.php + * * {@link page_handler()} explodes the pages string by / and sends it to * the page handler function as registered by {@link elgg_register_page_handler()}. * If a valid page handler isn't found, plugins have a chance to provide a 404. diff --git a/engine/handlers/xml-rpc_handler.php b/engine/handlers/xml-rpc_handler.php deleted file mode 100644 index 2ee29e5b7..000000000 --- a/engine/handlers/xml-rpc_handler.php +++ /dev/null @@ -1,44 +0,0 @@ -<?php -/** - * XML-RPC handler. - * - * @warning This is very old code. Does it work at all? - * - * @package Elgg.Core - * @subpackage XMLRPC - * @link http://docs.elgg.org/Tutorials/XMLRPC - * @todo Does this work? - */ - -require_once(dirname(dirname(__FILE__)) . "/start.php"); - -// Register the error handler -error_reporting(E_ALL); -set_error_handler('_php_xmlrpc_error_handler'); - -// Register a default exception handler -set_exception_handler('_php_xmlrpc_exception_handler'); - -// Set some defaults -$result = null; -set_input('view', 'xml'); // Set default view regardless - -// Get the post data -$input = get_post_data(); - -if ($input) { - // Parse structures from xml - $call = new XMLRPCCall($input); - - // Process call - $result = trigger_xmlrpc_handler($call); -} else { - throw new CallException(elgg_echo('xmlrpc:noinputdata')); -} - -if (!($result instanceof XMLRPCResponse)) { - throw new APIException(elgg_echo('APIException:ApiResultUnknown')); -} - -// Output result -echo elgg_view_page("XML-RPC", elgg_view("xml-rpc/output", array('result' => $result))); diff --git a/engine/lib/access.php b/engine/lib/access.php index 97f744fb9..08b9283cd 100644 --- a/engine/lib/access.php +++ b/engine/lib/access.php @@ -610,8 +610,7 @@ function delete_access_collection($collection_id) { WHERE id = {$collection_id}"; $result = delete_data($q); - - return $result; + return (bool)$result; } /** @@ -718,7 +717,7 @@ function remove_user_from_access_collection($user_guid, $collection_id) { WHERE access_collection_id = {$collection_id} AND user_guid = {$user_guid}"; - return delete_data($q); + return (bool)delete_data($q); } /** diff --git a/engine/lib/admin.php b/engine/lib/admin.php index 3baf2ff61..a191d740b 100644 --- a/engine/lib/admin.php +++ b/engine/lib/admin.php @@ -225,6 +225,7 @@ function admin_init() { elgg_register_action('admin/site/update_basic', '', 'admin'); elgg_register_action('admin/site/update_advanced', '', 'admin'); + elgg_register_action('admin/site/flush_cache', '', 'admin'); elgg_register_action('admin/menu/save', '', 'admin'); @@ -301,7 +302,7 @@ function admin_init() { } // widgets - $widgets = array('online_users', 'new_users', 'content_stats', 'admin_welcome'); + $widgets = array('online_users', 'new_users', 'content_stats', 'admin_welcome', 'control_panel'); foreach ($widgets as $widget) { elgg_register_widget_type( $widget, @@ -616,7 +617,7 @@ function elgg_add_admin_widgets($event, $type, $user) { // In the form column => array of handlers in order, top to bottom $adminWidgets = array( - 1 => array('admin_welcome'), + 1 => array('control_panel', 'admin_welcome'), 2 => array('online_users', 'new_users', 'content_stats'), ); diff --git a/engine/lib/annotations.php b/engine/lib/annotations.php index e40ab2e39..bfd40d1e8 100644 --- a/engine/lib/annotations.php +++ b/engine/lib/annotations.php @@ -529,6 +529,20 @@ function elgg_annotation_exists($entity_guid, $annotation_type, $owner_guid = NU } /** + * Return the URL for a comment + * + * @param ElggAnnotation $comment The comment object + * @return string + * @access private + */ +function elgg_comment_url_handler(ElggAnnotation $comment) { + $entity = $comment->getEntity(); + if ($entity) { + return $entity->getURL() . '#item-annotation-' . $comment->id; + } +} + +/** * Register an annotation url handler. * * @param string $function_name The function. @@ -540,11 +554,6 @@ function elgg_register_annotation_url_handler($extender_name = "all", $function_ return elgg_register_extender_url_handler('annotation', $extender_name, $function_name); } -/** Register the hook */ -elgg_register_plugin_hook_handler("export", "all", "export_annotation_plugin_hook", 2); - -elgg_register_plugin_hook_handler('unit_test', 'system', 'annotations_test'); - /** * Register annotation unit tests * @access private @@ -554,3 +563,16 @@ function annotations_test($hook, $type, $value, $params) { $value[] = $CONFIG->path . 'engine/tests/api/annotations.php'; return $value; } + +/** + * Initialize the annotation library + * @access private + */ +function elgg_annotations_init() { + elgg_register_annotation_url_handler('generic_comment', 'elgg_comment_url_handler'); + + elgg_register_plugin_hook_handler("export", "all", "export_annotation_plugin_hook", 2); + elgg_register_plugin_hook_handler('unit_test', 'system', 'annotations_test'); +} + +elgg_register_event_handler('init', 'system', 'elgg_annotations_init'); diff --git a/engine/lib/calendar.php b/engine/lib/deprecated-1.9.php index 9a06c5292..31d03428f 100644 --- a/engine/lib/calendar.php +++ b/engine/lib/deprecated-1.9.php @@ -1,14 +1,5 @@ <?php /** - * Elgg calendar / entity / event functions. - * - * @package Elgg.Core - * @subpackage Calendar - * - * @todo Implement or remove - */ - -/** * Return a timestamp for the start of a given day (defaults today). * * @param int $day Day @@ -17,8 +8,10 @@ * * @return int * @access private + * @deprecated 1.9 */ function get_day_start($day = null, $month = null, $year = null) { + elgg_deprecated_notice('get_day_start() has been deprecated', 1.9); return mktime(0, 0, 0, $month, $day, $year); } @@ -31,8 +24,10 @@ function get_day_start($day = null, $month = null, $year = null) { * * @return int * @access private + * @deprecated 1.9 */ function get_day_end($day = null, $month = null, $year = null) { + elgg_deprecated_notice('get_day_end() has been deprecated', 1.9); return mktime(23, 59, 59, $month, $day, $year); } @@ -53,10 +48,12 @@ function get_day_end($day = null, $month = null, $year = null) { * * @return array|false * @access private + * @deprecated 1.9 */ function get_notable_entities($start_time, $end_time, $type = "", $subtype = "", $owner_guid = 0, $order_by = "asc", $limit = 10, $offset = 0, $count = false, $site_guid = 0, $container_guid = null) { + elgg_deprecated_notice('get_notable_entities() has been deprecated', 1.9); global $CONFIG; if ($subtype === false || $subtype === null || $subtype === 0) { @@ -201,10 +198,12 @@ $container_guid = null) { * * @return int|array A list of entities, or a count if $count is set to true * @access private + * @deprecated 1.9 */ function get_notable_entities_from_metadata($start_time, $end_time, $meta_name, $meta_value = "", $entity_type = "", $entity_subtype = "", $owner_guid = 0, $limit = 10, $offset = 0, $order_by = "", $site_guid = 0, $count = false) { + elgg_deprecated_notice('get_notable_entities_from_metadata() has been deprecated', 1.9); global $CONFIG; @@ -331,10 +330,12 @@ $site_guid = 0, $count = false) { * * @return array|int|false An array of entities, or the number of entities, or false on failure * @access private + * @deprecated 1.9 */ function get_noteable_entities_from_relationship($start_time, $end_time, $relationship, $relationship_guid, $inverse_relationship = false, $type = "", $subtype = "", $owner_guid = 0, $order_by = "", $limit = 10, $offset = 0, $count = false, $site_guid = 0) { + elgg_deprecated_notice('get_noteable_entities_from_relationship() has been deprecated', 1.9); global $CONFIG; @@ -441,9 +442,11 @@ $order_by = "", $limit = 10, $offset = 0, $count = false, $site_guid = 0) { * * @return array|false * @access private + * @deprecated 1.9 */ function get_todays_entities($type = "", $subtype = "", $owner_guid = 0, $order_by = "", $limit = 10, $offset = 0, $count = false, $site_guid = 0, $container_guid = null) { + elgg_deprecated_notice('get_todays_entities() has been deprecated', 1.9); $day_start = get_day_start(); $day_end = get_day_end(); @@ -468,10 +471,12 @@ $limit = 10, $offset = 0, $count = false, $site_guid = 0, $container_guid = null * * @return int|array A list of entities, or a count if $count is set to true * @access private + * @deprecated 1.9 */ function get_todays_entities_from_metadata($meta_name, $meta_value = "", $entity_type = "", $entity_subtype = "", $owner_guid = 0, $limit = 10, $offset = 0, $order_by = "", $site_guid = 0, $count = false) { + elgg_deprecated_notice('get_todays_entities_from_metadata() has been deprecated', 1.9); $day_start = get_day_start(); $day_end = get_day_end(); @@ -499,10 +504,12 @@ $count = false) { * * @return array|int|false An array of entities, or the number of entities, or false on failure * @access private + * @deprecated 1.9 */ function get_todays_entities_from_relationship($relationship, $relationship_guid, $inverse_relationship = false, $type = "", $subtype = "", $owner_guid = 0, $order_by = "", $limit = 10, $offset = 0, $count = false, $site_guid = 0) { + elgg_deprecated_notice('get_todays_entities_from_relationship() has been deprecated', 1.9); $day_start = get_day_start(); $day_end = get_day_end(); @@ -529,9 +536,11 @@ $order_by = "", $limit = 10, $offset = 0, $count = false, $site_guid = 0) { * * @return string A viewable list of entities * @access private + * @deprecated 1.9 */ function list_notable_entities($start_time, $end_time, $type= "", $subtype = "", $owner_guid = 0, $limit = 10, $fullview = true, $listtypetoggle = false, $navigation = true) { + elgg_deprecated_notice('list_notable_entities() has been deprecated', 1.9); $offset = (int) get_input('offset'); $count = get_notable_entities($start_time, $end_time, $type, $subtype, @@ -559,9 +568,11 @@ $limit = 10, $fullview = true, $listtypetoggle = false, $navigation = true) { * * @return string A viewable list of entities * @access private + * @deprecated 1.9 */ function list_todays_entities($type= "", $subtype = "", $owner_guid = 0, $limit = 10, $fullview = true, $listtypetoggle = false, $navigation = true) { + elgg_deprecated_notice('list_todays_entities() has been deprecated', 1.9); $day_start = get_day_start(); $day_end = get_day_end(); diff --git a/engine/lib/elgglib.php b/engine/lib/elgglib.php index 08b346960..57d602450 100644 --- a/engine/lib/elgglib.php +++ b/engine/lib/elgglib.php @@ -107,7 +107,10 @@ function elgg_load_library($name) { } if (!include_once($CONFIG->libraries[$name])) { - $error = elgg_echo('InvalidParameterException:LibraryNotRegistered', array($name)); + $error = elgg_echo('InvalidParameterException:LibraryNotFound', array( + $name, + $CONFIG->libraries[$name]) + ); throw new InvalidParameterException($error); } } diff --git a/engine/lib/entities.php b/engine/lib/entities.php index fd2b0e9f9..daced6740 100644 --- a/engine/lib/entities.php +++ b/engine/lib/entities.php @@ -124,8 +124,6 @@ function retrieve_cached_entity_row($guid) { * @internal Subtypes are stored in the entity_subtypes table. There is a foreign * key in the entities table. * - * @todo Move to a nicer place? - * * @param string $type Type * @param string $subtype Subtype * @@ -144,7 +142,7 @@ function get_subtype_id($type, $subtype) { return FALSE; } - // Todo: cache here? Or is looping less efficient that going to the db each time? + // @todo use the cache before hitting database $result = get_data_row("SELECT * from {$CONFIG->dbprefix}entity_subtypes where type='$type' and subtype='$subtype'"); @@ -163,8 +161,6 @@ function get_subtype_id($type, $subtype) { /** * Return string name for a given subtype ID. * - * @todo Move to a nicer place? - * * @param int $subtype_id Subtype ID * * @return string Subtype name @@ -199,11 +195,11 @@ function get_subtype_from_id($subtype_id) { } /** - * Return a classname for a registered type and subtype. + * Return the class name for a registered type and subtype. * * Entities can be registered to always be loaded as a certain class - * with {@link register_entity_subtype()}. This function returns - * the class name if found, and NULL if not. + * with add_subtype() or update_subtype(). This function returns the class + * name if found and NULL if not. * * @param string $type The type * @param string $subtype The subtype @@ -219,7 +215,7 @@ function get_subtype_class($type, $subtype) { $type = sanitise_string($type); $subtype = sanitise_string($subtype); - // Todo: cache here? Or is looping less efficient that going to the db each time? + // @todo use the cache before going to the database $result = get_data_row("SELECT * from {$CONFIG->dbprefix}entity_subtypes where type='$type' and subtype='$subtype'"); @@ -236,7 +232,7 @@ function get_subtype_class($type, $subtype) { } /** - * Returns the classname for a subtype id. + * Returns the class name for a subtype id. * * @param int $subtype_id The subtype id * @@ -279,6 +275,9 @@ function get_subtype_class_from_id($subtype_id) { * it will be loaded as that class automatically when retrieved from the database with * {@link get_entity()}. * + * @warning This function cannot be used to change the class for a type-subtype pair. + * Use update_subtype() for that. + * * @param string $type The type you're subtyping (site, user, object, or group) * @param string $subtype The subtype * @param string $class Optional class name for the object @@ -670,7 +669,10 @@ function get_entity($guid) { static $newentity_cache; $new_entity = false; - if (!is_numeric($guid)) { + // 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; } @@ -1563,7 +1565,7 @@ function delete_entity($guid, $recursive = true) { } } - return $res; + return (bool)$res; } } } @@ -2148,8 +2150,13 @@ function elgg_list_registered_entities(array $options = array()) { } } - $count = elgg_get_entities(array_merge(array('count' => TRUE), $options)); - $entities = elgg_get_entities($options); + if (!empty($options['type_subtype_pairs'])) { + $count = elgg_get_entities(array_merge(array('count' => TRUE), $options)); + $entities = elgg_get_entities($options); + } else { + $count = 0; + $entities = array(); + } return elgg_view_entity_list($entities, $count, $options['offset'], $options['limit'], $options['full_view'], $options['list_type_toggle'], $options['pagination']); diff --git a/engine/lib/languages.php b/engine/lib/languages.php index 7607ea3bf..0400843af 100644 --- a/engine/lib/languages.php +++ b/engine/lib/languages.php @@ -301,4 +301,15 @@ function get_missing_language_keys($language) { return false; } +/** + * Initialize the language library + * @access private + */ +function elgg_languages_init() { + $lang = get_current_language(); + elgg_register_simplecache_view("cache/js/languages/$lang"); +} + +elgg_register_event_handler('init', 'system', 'elgg_languages_init'); + register_translations(dirname(dirname(dirname(__FILE__))) . "/languages/"); diff --git a/engine/lib/metastrings.php b/engine/lib/metastrings.php index 9dccec700..9fe9b4bff 100644 --- a/engine/lib/metastrings.php +++ b/engine/lib/metastrings.php @@ -810,7 +810,7 @@ function elgg_delete_metastring_based_object_by_id($id, $type) { } if (($obj->canEdit()) && (elgg_trigger_event('delete', $type, $obj))) { - return delete_data("DELETE from $table where id=$id"); + return (bool)delete_data("DELETE from $table where id=$id"); } } diff --git a/engine/lib/navigation.php b/engine/lib/navigation.php index 176790188..956ca220a 100644 --- a/engine/lib/navigation.php +++ b/engine/lib/navigation.php @@ -385,6 +385,55 @@ function elgg_entity_menu_setup($hook, $type, $return, $params) { } /** + * Widget menu is a set of widget controls + * @access private + */ +function elgg_widget_menu_setup($hook, $type, $return, $params) { + + $widget = $params['entity']; + $show_edit = elgg_extract('show_edit', $params, true); + + $collapse = array( + 'name' => 'collapse', + 'text' => ' ', + 'href' => "#elgg-widget-content-$widget->guid", + 'class' => 'elgg-widget-collapse-button', + 'rel' => 'toggle', + 'priority' => 1 + ); + $return[] = ElggMenuItem::factory($collapse); + + if ($widget->canEdit()) { + $delete = array( + 'name' => 'delete', + 'text' => elgg_view_icon('delete-alt'), + 'title' => elgg_echo('widget:delete', array($widget->getTitle())), + 'href' => "action/widgets/delete?widget_guid=$widget->guid", + 'is_action' => true, + 'class' => 'elgg-widget-delete-button', + 'id' => "elgg-widget-delete-button-$widget->guid", + 'priority' => 900 + ); + $return[] = ElggMenuItem::factory($delete); + + if ($show_edit) { + $edit = array( + 'name' => 'settings', + 'text' => elgg_view_icon('settings-alt'), + 'title' => elgg_echo('widget:edit'), + 'href' => "#widget-edit-$widget->guid", + 'class' => "elgg-widget-edit-button", + 'rel' => 'toggle', + 'priority' => 800, + ); + $return[] = ElggMenuItem::factory($edit); + } + } + + return $return; +} + +/** * Adds a delete link to "generic_comment" annotations * @access private */ @@ -418,6 +467,7 @@ function elgg_nav_init() { elgg_register_plugin_hook_handler('prepare', 'menu:site', 'elgg_site_menu_setup'); elgg_register_plugin_hook_handler('register', 'menu:river', 'elgg_river_menu_setup'); elgg_register_plugin_hook_handler('register', 'menu:entity', 'elgg_entity_menu_setup'); + elgg_register_plugin_hook_handler('register', 'menu:widget', 'elgg_widget_menu_setup'); elgg_register_plugin_hook_handler('register', 'menu:annotation', 'elgg_annotation_menu_setup'); } diff --git a/engine/lib/output.php b/engine/lib/output.php index 60bcc72cd..6554481f5 100644 --- a/engine/lib/output.php +++ b/engine/lib/output.php @@ -234,7 +234,7 @@ function elgg_clean_vars(array $vars = array()) { * * @example * elgg_normalize_url(''); // 'http://my.site.com/' - * elgg_normalize_url('dashboard'); // 'http://my.site.com/dashboard' + * elgg_normalize_url('dashboard'); // 'http://my.site.com/dashboard' * elgg_normalize_url('http://google.com/'); // no change * elgg_normalize_url('//google.com/'); // no change * @@ -257,6 +257,11 @@ function elgg_normalize_url($url) { $validated = filter_var($url, FILTER_VALIDATE_URL); } + // work around for handling absoluate IRIs (RFC 3987) - see #4190 + if (!$validated && (strpos($url, 'http:') === 0) || (strpos($url, 'https:') === 0)) { + $validated = true; + } + if ($validated) { // all normal URLs including mailto: return $url; @@ -306,6 +311,9 @@ function elgg_get_friendly_title($title) { } //$title = iconv('UTF-8', 'ASCII//TRANSLIT', $title); + + // use A-Za-z0-9_ instead of \w because \w is locale sensitive + $title = preg_replace("/[^A-Za-z0-9_ ]/", "", $title); $title = preg_replace("/[^\w ]/", "", $title); $title = str_replace(" ", "-", $title); $title = str_replace("--", "-", $title); diff --git a/engine/lib/pagehandler.php b/engine/lib/pagehandler.php index aba921416..ffcfc5b6a 100644 --- a/engine/lib/pagehandler.php +++ b/engine/lib/pagehandler.php @@ -110,3 +110,36 @@ function elgg_unregister_page_handler($handler) { unset($CONFIG->pagehandler[$handler]); } + +/** + * Serve an error page + * + * @todo not sending status codes yet + * + * @param string $hook The name of the hook + * @param string $type The type of the hook + * @param bool $result The current value of the hook + * @param array $params Parameters related to the hook + */ +function elgg_error_page_handler($hook, $type, $result, $params) { + if (elgg_view_exists("errors/$type")) { + $content = elgg_view("errors/$type", $params); + } else { + $content = elgg_view("errors/default", $params); + } + $body = elgg_view_layout('error', array('content' => $content)); + echo elgg_view_page($title, $body, 'error'); + exit; +} + +/** + * Initializes the page handler/routing system + * + * @return void + * @access private + */ +function page_handler_init() { + elgg_register_plugin_hook_handler('forward', '404', 'elgg_error_page_handler'); +} + +elgg_register_event_handler('init', 'system', 'page_handler_init'); diff --git a/engine/lib/relationships.php b/engine/lib/relationships.php index 3578f0cb8..5b7080b56 100644 --- a/engine/lib/relationships.php +++ b/engine/lib/relationships.php @@ -158,7 +158,7 @@ function remove_entity_relationship($guid_one, $relationship, $guid_two) { and relationship='$relationship' and guid_two=$guid_two"; - return delete_data($query); + return (bool)delete_data($query); } else { return false; } diff --git a/engine/lib/river.php b/engine/lib/river.php index 466eca253..421813441 100644 --- a/engine/lib/river.php +++ b/engine/lib/river.php @@ -207,6 +207,8 @@ function elgg_delete_river(array $options = array()) { /** * Get river items * + * @note If using types and subtypes in a query, they are joined with an AND. + * * @param array $options * ids => INT|ARR River item id(s) * subject_guids => INT|ARR Subject guid(s) @@ -430,7 +432,6 @@ function elgg_river_get_access_sql() { * * @internal This is a simplified version of elgg_get_entity_type_subtype_where_sql() * which could be used for all queries once the subtypes have been denormalized. - * FYI: It allows types and subtypes to not be paired. * * @param string $table 'rv' * @param NULL|array $types Array of types or NULL if none. @@ -447,7 +448,8 @@ function elgg_get_river_type_subtype_where_sql($table, $types, $subtypes, $pairs return ''; } - $wheres = array(); + $types_wheres = array(); + $subtypes_wheres = array(); // if no pairs, use types and subtypes if (!is_array($pairs)) { @@ -457,7 +459,7 @@ function elgg_get_river_type_subtype_where_sql($table, $types, $subtypes, $pairs } foreach ($types as $type) { $type = sanitise_string($type); - $wheres[] = "({$table}.type = '$type')"; + $types_wheres[] = "({$table}.type = '$type')"; } } @@ -467,13 +469,20 @@ function elgg_get_river_type_subtype_where_sql($table, $types, $subtypes, $pairs } foreach ($subtypes as $subtype) { $subtype = sanitise_string($subtype); - $wheres[] = "({$table}.subtype = '$subtype')"; + $subtypes_wheres[] = "({$table}.subtype = '$subtype')"; } } - if (is_array($wheres) && count($wheres)) { - $wheres = array(implode(' OR ', $wheres)); + if (is_array($types_wheres) && count($types_wheres)) { + $types_wheres = array(implode(' OR ', $types_wheres)); + } + + if (is_array($subtypes_wheres) && count($subtypes_wheres)) { + $subtypes_wheres = array('(' . implode(' OR ', $subtypes_wheres) . ')'); } + + $wheres = array(implode(' AND ', array_merge($types_wheres, $subtypes_wheres))); + } else { // using type/subtype pairs foreach ($pairs as $paired_type => $paired_subtypes) { @@ -611,6 +620,16 @@ function elgg_river_page_handler($page) { } /** + * Register river unit tests + * @access private + */ +function elgg_river_test($hook, $type, $value) { + global $CONFIG; + $value[] = $CONFIG->path . 'engine/tests/api/river.php'; + return $value; +} + +/** * Initialize river library * @access private */ @@ -620,6 +639,8 @@ function elgg_river_init() { elgg_register_menu_item('site', $item); elgg_register_widget_type('river_widget', elgg_echo('river:widget:title'), elgg_echo('river:widget:description')); + + elgg_register_plugin_hook_handler('unit_test', 'system', 'elgg_river_test'); } elgg_register_event_handler('init', 'system', 'elgg_river_init'); diff --git a/engine/lib/user_settings.php b/engine/lib/user_settings.php index 1e2d6db10..af30d8f0d 100644 --- a/engine/lib/user_settings.php +++ b/engine/lib/user_settings.php @@ -265,8 +265,8 @@ function elgg_set_user_default_access() { * @access private */ function usersettings_pagesetup() { - if (elgg_get_context() == "settings" && elgg_get_logged_in_user_guid()) { - $user = elgg_get_logged_in_user_entity(); + if (elgg_get_context() == "settings") { + $user = elgg_get_page_owner_entity(); $params = array( 'name' => '1_account', @@ -346,6 +346,13 @@ function usersettings_init() { elgg_register_plugin_hook_handler('usersettings:save', 'user', 'users_settings_save'); elgg_register_action("usersettings/save"); + + // extend the account settings form + elgg_extend_view('forms/account/settings', 'core/settings/account/name', 100); + elgg_extend_view('forms/account/settings', 'core/settings/account/password', 100); + elgg_extend_view('forms/account/settings', 'core/settings/account/email', 100); + elgg_extend_view('forms/account/settings', 'core/settings/account/language', 100); + elgg_extend_view('forms/account/settings', 'core/settings/account/default_access', 100); } elgg_register_event_handler('init', 'system', 'usersettings_init'); diff --git a/engine/lib/users.php b/engine/lib/users.php index 9cb8ddfa7..1b3cca799 100644 --- a/engine/lib/users.php +++ b/engine/lib/users.php @@ -565,6 +565,8 @@ function get_user_by_username($username) { $entity = get_data_row($query, 'entity_row_to_elggstar'); if ($entity) { $USERNAME_TO_GUID_MAP_CACHE[$username] = $entity->guid; + } else { + $entity = false; } return $entity; @@ -1019,7 +1021,7 @@ function elgg_get_user_validation_status($user_guid) { return; } - if ($md->value) { + if ($md[0]->value) { return true; } @@ -1281,6 +1283,11 @@ 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 = "settings/user/$user->username"; + $item = new ElggMenuItem('settings:edit', elgg_echo('settings:edit'), $url); + $item->setSection('admin'); + $return[] = $item; } return $return; @@ -1555,13 +1562,6 @@ function users_init() { elgg_register_widget_type('friends', elgg_echo('friends'), elgg_echo('friends:widget:description')); - // extend the account settings form - elgg_extend_view('forms/account/settings', 'core/settings/account/name', 100); - elgg_extend_view('forms/account/settings', 'core/settings/account/password', 100); - elgg_extend_view('forms/account/settings', 'core/settings/account/email', 100); - elgg_extend_view('forms/account/settings', 'core/settings/account/language', 100); - elgg_extend_view('forms/account/settings', 'core/settings/account/default_access', 100); - // Register the user type elgg_register_entity_type('user', ''); diff --git a/engine/lib/views.php b/engine/lib/views.php index 0f806b8be..b938dd60e 100644 --- a/engine/lib/views.php +++ b/engine/lib/views.php @@ -1598,10 +1598,10 @@ function elgg_views_boot() { elgg_load_js('jquery'); elgg_load_js('jquery-ui'); - elgg_load_js('jquery.form'); elgg_load_js('elgg'); elgg_register_simplecache_view('js/lightbox'); + elgg_register_simplecache_view('css/lightbox'); $lightbox_js_url = elgg_get_simplecache_url('js', 'lightbox'); elgg_register_js('lightbox', $lightbox_js_url); $lightbox_css_url = elgg_get_simplecache_url('css', 'lightbox'); diff --git a/engine/lib/widgets.php b/engine/lib/widgets.php index 5d18a16b0..46f34391a 100644 --- a/engine/lib/widgets.php +++ b/engine/lib/widgets.php @@ -332,14 +332,14 @@ function elgg_default_widgets_init() { * @param string $event The event * @param string $type The type of object * @param object $entity The entity being created - * @return null + * @return void * @access private */ function elgg_create_default_widgets($event, $type, $entity) { $default_widget_info = elgg_get_config('default_widget_info'); if (!$default_widget_info || !$entity) { - return null; + return; } $type = $entity->getType(); @@ -347,53 +347,48 @@ function elgg_create_default_widgets($event, $type, $entity) { // event is already guaranteed by the hook registration. // need to check subtype and type. - foreach ($default_widget_info as $temp) { - if ($temp['entity_type'] == $type) { - if ($temp['entity_subtype'] == ELGG_ENTITIES_ANY_VALUE || $temp['entity_subtype'] == $subtype) { - $info = $temp; - break; + foreach ($default_widget_info as $info) { + if ($info['entity_type'] == $type) { + if ($info['entity_subtype'] == ELGG_ENTITIES_ANY_VALUE || $info['entity_subtype'] == $subtype) { + + // need to be able to access everything + $old_ia = elgg_set_ignore_access(true); + elgg_push_context('create_default_widgets'); + + // pull in by widget context with widget owners as the site + // not using elgg_get_widgets() because it sorts by columns and we don't care right now. + $options = array( + 'type' => 'object', + 'subtype' => 'widget', + 'owner_guid' => elgg_get_site_entity()->guid, + 'private_setting_name' => 'context', + 'private_setting_value' => $info['widget_context'], + 'limit' => 0 + ); + + $widgets = elgg_get_entities_from_private_settings($options); + + foreach ($widgets as $widget) { + // change the container and owner + $new_widget = clone $widget; + $new_widget->container_guid = $entity->guid; + $new_widget->owner_guid = $entity->guid; + + // pull in settings + $settings = get_all_private_settings($widget->guid); + + foreach ($settings as $name => $value) { + $new_widget->$name = $value; + } + + $new_widget->save(); + } + + elgg_set_ignore_access($old_ia); + elgg_pop_context(); } } } - - // need to be able to access everything - $old_ia = elgg_get_ignore_access(true); - elgg_push_context('create_default_widgets'); - - // pull in by widget context with widget owners as the site - // not using elgg_get_widgets() because it sorts by columns and we don't care right now. - $options = array( - 'type' => 'object', - 'subtype' => 'widget', - 'owner_guid' => elgg_get_site_entity()->guid, - 'private_setting_name' => 'context', - 'private_setting_value' => $info['widget_context'], - 'limit' => 0 - ); - - $widgets = elgg_get_entities_from_private_settings($options); - - foreach ($widgets as $widget) { - // change the container and owner - $new_widget = clone $widget; - $new_widget->container_guid = $entity->guid; - $new_widget->owner_guid = $entity->guid; - - // pull in settings - $settings = get_all_private_settings($widget->guid); - - foreach ($settings as $name => $value) { - $new_widget->$name = $value; - } - - $new_widget->save(); - } - - elgg_get_ignore_access($old_ia); - elgg_pop_context(); - - // failure here shouldn't stop the event. - return null; } /** diff --git a/engine/lib/xml-rpc.php b/engine/lib/xml-rpc.php deleted file mode 100644 index bfe1a8645..000000000 --- a/engine/lib/xml-rpc.php +++ /dev/null @@ -1,203 +0,0 @@ -<?php -/** - * Elgg XML-RPC library. - * Contains functions and classes to handle XML-RPC services, currently only server only. - * - * @package Elgg.Core - * @subpackage XMLRPC - */ - -/** - * parse XMLRPCCall parameters - * - * Convert an XMLRPCCall result array into native data types - * - * @param array $parameters An array of params - * - * @return array - * @access private - */ -function xmlrpc_parse_params($parameters) { - $result = array(); - - foreach ($parameters as $parameter) { - $result[] = xmlrpc_scalar_value($parameter); - } - - return $result; -} - -/** - * Extract the scalar value of an XMLObject type result array - * - * @param XMLObject $object And object - * - * @return mixed - * @access private - */ -function xmlrpc_scalar_value($object) { - if ($object->name == 'param') { - $object = $object->children[0]->children[0]; - } - - switch ($object->name) { - case 'string': - return $object->content; - - case 'array': - foreach ($object->children[0]->children as $child) { - $value[] = xmlrpc_scalar_value($child); - } - return $value; - - case 'struct': - foreach ($object->children as $child) { - if (isset($child->children[1]->children[0])) { - $value[$child->children[0]->content] = xmlrpc_scalar_value($child->children[1]->children[0]); - } else { - $value[$child->children[0]->content] = $child->children[1]->content; - } - } - return $value; - - case 'boolean': - return (boolean) $object->content; - - case 'i4': - case 'int': - return (int) $object->content; - - case 'double': - return (double) $object->content; - - case 'dateTime.iso8601': - return (int) strtotime($object->content); - - case 'base64': - return base64_decode($object->content); - - case 'value': - return xmlrpc_scalar_value($object->children[0]); - - default: - // @todo unsupported, throw an error - return false; - } -} - -// Functions for adding handlers ////////////////////////////////////////////////////////// - -/** XML-RPC Handlers */ -global $XML_RPC_HANDLERS; -$XML_RPC_HANDLERS = array(); - -/** - * Register a method handler for a given XML-RPC method. - * - * @param string $method Method parameter. - * @param string $handler The handler function. This function accepts - * one XMLRPCCall object and must return a XMLRPCResponse object. - * - * @return bool - */ -function register_xmlrpc_handler($method, $handler) { - global $XML_RPC_HANDLERS; - - $XML_RPC_HANDLERS[$method] = $handler; -} - -/** - * Trigger a method call and pass the relevant parameters to the funciton. - * - * @param XMLRPCCall $parameters The call and parameters. - * - * @return XMLRPCCall - * @access private - */ -function trigger_xmlrpc_handler(XMLRPCCall $parameters) { - global $XML_RPC_HANDLERS; - - // Go through and see if we have a handler - if (isset($XML_RPC_HANDLERS[$parameters->getMethodName()])) { - $handler = $XML_RPC_HANDLERS[$parameters->getMethodName()]; - $result = $handler($parameters); - - if (!($result instanceof XMLRPCResponse)) { - $msg = elgg_echo('InvalidParameterException:UnexpectedReturnFormat', - array($parameters->getMethodName())); - throw new InvalidParameterException($msg); - } - - // Result in right format, return it. - return $result; - } - - // if no handler then throw exception - $msg = elgg_echo('NotImplementedException:XMLRPCMethodNotImplemented', - array($parameters->getMethodName())); - throw new NotImplementedException($msg); -} - -/** - * PHP Error handler function. - * This function acts as a wrapper to catch and report PHP error messages. - * - * @see http://uk3.php.net/set-error-handler - * - * @param int $errno Error number - * @param string $errmsg Human readable message - * @param string $filename Filename - * @param int $linenum Line number - * @param array $vars Vars - * - * @return void - * @access private - */ -function _php_xmlrpc_error_handler($errno, $errmsg, $filename, $linenum, $vars) { - $error = date("Y-m-d H:i:s (T)") . ": \"" . $errmsg . "\" in file " - . $filename . " (line " . $linenum . ")"; - - switch ($errno) { - case E_USER_ERROR: - error_log("ERROR: " . $error); - - // Since this is a fatal error, we want to stop any further execution but do so gracefully. - throw new Exception("ERROR: " . $error); - break; - - case E_WARNING : - case E_USER_WARNING : - error_log("WARNING: " . $error); - break; - - default: - error_log("DEBUG: " . $error); - } -} - -/** - * PHP Exception handler for XMLRPC. - * - * @param Exception $exception The exception - * - * @return void - * @access private - */ -function _php_xmlrpc_exception_handler($exception) { - - error_log("*** FATAL EXCEPTION (XML-RPC) *** : " . $exception); - - $code = $exception->getCode(); - - if ($code == 0) { - $code = -32400; - } - - $result = new XMLRPCErrorResponse($exception->getMessage(), $code); - - $vars = array('result' => $result); - - $content = elgg_view("xml-rpc/output", $vars); - - echo elgg_view_page($exception->getMessage(), $content); -} diff --git a/engine/start.php b/engine/start.php index 00bdc3197..1decc5d80 100644 --- a/engine/start.php +++ b/engine/start.php @@ -92,7 +92,7 @@ $lib_files = array( // these need to be loaded first. 'database.php', 'actions.php', - 'admin.php', 'annotations.php', 'calendar.php', + 'admin.php', 'annotations.php', 'configuration.php', 'cron.php', 'entities.php', 'export.php', 'extender.php', 'filestore.php', 'group.php', 'location.php', 'mb_wrapper.php', 'memcache.php', 'metadata.php', @@ -100,10 +100,10 @@ $lib_files = array( 'opendd.php', 'pagehandler.php', 'pam.php', 'plugins.php', 'private_settings.php', 'relationships.php', 'river.php', 'sites.php', 'statistics.php', 'tags.php', 'user_settings.php', 'users.php', - 'upgrade.php', 'web_services.php', 'widgets.php', 'xml.php', 'xml-rpc.php', + 'upgrade.php', 'web_services.php', 'widgets.php', 'xml.php', - //backwards compatibility - 'deprecated-1.7.php', 'deprecated-1.8.php', + // backward compatibility + 'deprecated-1.7.php', 'deprecated-1.8.php', 'deprecated-1.9.php' ); foreach ($lib_files as $file) { diff --git a/engine/tests/api/access_collections.php b/engine/tests/api/access_collections.php index 0c37fa779..bea995a6e 100644 --- a/engine/tests/api/access_collections.php +++ b/engine/tests/api/access_collections.php @@ -76,7 +76,7 @@ class ElggCoreAccessCollectionsTest extends ElggCoreUnitTest { $q = "SELECT * FROM {$this->dbPrefix}access_collections WHERE id = $acl_id"; $data = get_data($q); - $this->assertFalse($data); + $this->assertIdentical(array(), $data); } } @@ -88,7 +88,7 @@ class ElggCoreAccessCollectionsTest extends ElggCoreUnitTest { if ($result) { $result = remove_user_from_access_collection($this->user->guid, $acl_id); - $this->assertTrue($result); + $this->assertIdentical(true, $result); } delete_access_collection($acl_id); diff --git a/engine/tests/api/entity_getter_functions.php b/engine/tests/api/entity_getter_functions.php index e7906d3c8..9db248de9 100644 --- a/engine/tests/api/entity_getter_functions.php +++ b/engine/tests/api/entity_getter_functions.php @@ -175,9 +175,10 @@ class ElggCoreEntityGetterFunctionsTest extends ElggCoreUnitTest { } /** + * Get a mix of valid and invalid types * - * @param unknown_type $num - * @return unknown_type + * @param int $num + * @return array */ public function getRandomMixedTypes($num = 2) { $have_valid = $have_invalid = false; @@ -196,8 +197,8 @@ class ElggCoreEntityGetterFunctionsTest extends ElggCoreUnitTest { * Get random mix of valid and invalid subtypes for types given. * * @param array $types - * @param unknown_type $num - * @return unknown_type + * @param int $num + * @return array */ public function getRandomMixedSubtypes(array $types, $num = 2) { $types_c = count($types); @@ -230,8 +231,8 @@ class ElggCoreEntityGetterFunctionsTest extends ElggCoreUnitTest { /** * Creates random annotations on $entity * - * @param unknown_type $entity - * @param unknown_type $max + * @param ElggEntity $entity + * @param int $max */ public function createRandomAnnotations($entity, $max = 1) { $annotations = array(); @@ -563,7 +564,9 @@ class ElggCoreEntityGetterFunctionsTest extends ElggCoreUnitTest { * TYPE_SUBTYPE_PAIRS ***************************/ - + /** + * Valid type, valid subtype pairs + */ public function testElggAPIGettersTSPValidTypeValidSubtype() { $type_num = 1; $subtype_num = 1; @@ -586,6 +589,9 @@ class ElggCoreEntityGetterFunctionsTest extends ElggCoreUnitTest { } } + /** + * Valid type, multiple valid subtypes + */ public function testElggAPIGettersTSPValidTypeValidPluralSubtype() { $type_num = 1; $subtype_num = 3; @@ -608,6 +614,9 @@ class ElggCoreEntityGetterFunctionsTest extends ElggCoreUnitTest { } } + /** + * Valid type, both valid and invalid subtypes + */ public function testElggAPIGettersTSPValidTypeMixedPluralSubtype() { $type_num = 1; $valid_subtype_num = 2; @@ -635,9 +644,6 @@ class ElggCoreEntityGetterFunctionsTest extends ElggCoreUnitTest { } - - - /**************************** * FALSE-RETURNING TESTS **************************** @@ -652,8 +658,8 @@ class ElggCoreEntityGetterFunctionsTest extends ElggCoreUnitTest { */ - /* - * Test invalid types. + /** + * Test invalid types with singular 'type'. */ public function testElggApiGettersInvalidTypeUsingType() { $type_arr = $this->getRandomInvalids(); @@ -667,7 +673,9 @@ class ElggCoreEntityGetterFunctionsTest extends ElggCoreUnitTest { $this->assertFalse($es); } - + /** + * Test invalid types with plural 'types'. + */ public function testElggApiGettersInvalidTypeUsingTypesAsString() { $type_arr = $this->getRandomInvalids(); $type = $type_arr[0]; @@ -680,8 +688,11 @@ class ElggCoreEntityGetterFunctionsTest extends ElggCoreUnitTest { $this->assertFalse($es); } + /** + * Test invalid types with plural 'types' and an array of a single type + */ public function testElggApiGettersInvalidTypeUsingTypesAsArray() { - $type_arr = $this->getRandomInvalids(); + $type_arr = $this->getRandomInvalids(1); $options = array( 'types' => $type_arr @@ -691,6 +702,9 @@ class ElggCoreEntityGetterFunctionsTest extends ElggCoreUnitTest { $this->assertFalse($es); } + /** + * Test invalid types with plural 'types' and an array of a two types + */ public function testElggApiGettersInvalidTypes() { $type_arr = $this->getRandomInvalids(2); @@ -1053,7 +1067,7 @@ class ElggCoreEntityGetterFunctionsTest extends ElggCoreUnitTest { $entities = elgg_get_entities_from_metadata($options); - $this->assertFalse($entities); + $this->assertIdentical(array(), $entities); $e->delete(); } @@ -1081,7 +1095,7 @@ class ElggCoreEntityGetterFunctionsTest extends ElggCoreUnitTest { $entities = elgg_get_entities_from_metadata($options); - $this->assertFalse($entities); + $this->assertIdentical(array(), $entities); $e->delete(); } @@ -1214,7 +1228,7 @@ class ElggCoreEntityGetterFunctionsTest extends ElggCoreUnitTest { } } - function testElggApiGettersEntityMetadatavalueInvalidSingle() { + function testElggApiGettersEntityMetadataValueInvalidSingle() { $subtypes = $this->getRandomValidSubtypes(array('object'), 1); $subtype = $subtypes[0]; $md_name = 'test_metadata_name_' . rand(); @@ -1235,7 +1249,7 @@ class ElggCoreEntityGetterFunctionsTest extends ElggCoreUnitTest { $entities = elgg_get_entities_from_metadata($options); - $this->assertFalse($entities); + $this->assertIdentical(array(), $entities); $e->delete(); } @@ -1263,7 +1277,7 @@ class ElggCoreEntityGetterFunctionsTest extends ElggCoreUnitTest { $entities = elgg_get_entities_from_metadata($options); - $this->assertFalse($entities); + $this->assertIdentical(array(), $entities); $e->delete(); } @@ -1641,6 +1655,9 @@ class ElggCoreEntityGetterFunctionsTest extends ElggCoreUnitTest { } } + /** + * Name value pair with valid name and invalid value + */ function testElggApiGettersEntityMetadataNVPValidNInvalidV() { $subtypes = $this->getRandomValidSubtypes(array('object'), 1); $subtype = $subtypes[0]; @@ -1676,7 +1693,7 @@ class ElggCoreEntityGetterFunctionsTest extends ElggCoreUnitTest { $entities = elgg_get_entities_from_metadata($options); - $this->assertFalse($entities); + $this->assertIdentical(array(), $entities); foreach ($guids as $guid) { if ($e = get_entity($guid)) { @@ -1685,7 +1702,9 @@ class ElggCoreEntityGetterFunctionsTest extends ElggCoreUnitTest { } } - + /** + * Name value pair with invalid name and valid value + */ function testElggApiGettersEntityMetadataNVPInvalidNValidV() { $subtypes = $this->getRandomValidSubtypes(array('object'), 1); $subtype = $subtypes[0]; @@ -1721,7 +1740,7 @@ class ElggCoreEntityGetterFunctionsTest extends ElggCoreUnitTest { $entities = elgg_get_entities_from_metadata($options); - $this->assertFalse($entities); + $this->assertIdentical(array(), $entities); foreach ($guids as $guid) { if ($e = get_entity($guid)) { @@ -2083,7 +2102,7 @@ class ElggCoreEntityGetterFunctionsTest extends ElggCoreUnitTest { $es = elgg_get_entities_from_relationship($options); $this->assertTrue(is_array($es)); - $this->assertTrue(count($es), 1); + $this->assertIdentical(count($es), 1); foreach ($es as $e) { $this->assertEqual($guids[1], $e->guid); @@ -2115,7 +2134,7 @@ class ElggCoreEntityGetterFunctionsTest extends ElggCoreUnitTest { $es = elgg_get_entities_from_relationship($options); $this->assertTrue(is_array($es)); - $this->assertTrue(count($es), 1); + $this->assertIdentical(count($es), 1); foreach ($es as $e) { $this->assertEqual($guids[1], $e->guid); @@ -2151,7 +2170,7 @@ class ElggCoreEntityGetterFunctionsTest extends ElggCoreUnitTest { $es = elgg_get_entities_from_relationship($options); $this->assertTrue(is_array($es)); - $this->assertTrue(count($es), 1); + $this->assertIdentical(count($es), 1); foreach ($es as $e) { $this->assertEqual($guids[1], $e->guid); @@ -2578,7 +2597,7 @@ class ElggCoreEntityGetterFunctionsTest extends ElggCoreUnitTest { foreach ($fan_entities as $fan_entity) { $this->assertTrue(in_array($fan_entity->guid, $relationships[$e->guid])); - $this->assertTrue(check_entity_relationship($fan_entity->guid, $relationship_name, $e->guid)); + $this->assertNotIdentical(false, check_entity_relationship($fan_entity->guid, $relationship_name, $e->guid)); } } } diff --git a/engine/tests/api/helpers.php b/engine/tests/api/helpers.php index f48f91faf..77205138d 100644 --- a/engine/tests/api/helpers.php +++ b/engine/tests/api/helpers.php @@ -127,7 +127,7 @@ class ElggCoreHelpersTest extends ElggCoreUnitTest { $this->assertIdentical('http://test1.com', $item->url); // send a bad url - $result = @elgg_register_js('bad'); + $result = elgg_register_js('bad', null); $this->assertFalse($result); } @@ -351,7 +351,7 @@ class ElggCoreHelpersTest extends ElggCoreUnitTest { $test_elements = $pl->getElements(); // make sure it's gone. - $this->assertTrue(2, count($test_elements)); + $this->assertEqual(2, count($test_elements)); $this->assertIdentical($elements[0], $test_elements[0]); $this->assertIdentical($elements[2], $test_elements[2]); } @@ -369,7 +369,7 @@ class ElggCoreHelpersTest extends ElggCoreUnitTest { $pl->add($element, $priority); } - $this->assertTrue($pl->move($elements[-5], 10)); + $this->assertEqual($pl->move($elements[-5], 10), 10); // check it's at the new place $this->assertIdentical($elements[-5], $pl->getElement(10)); diff --git a/engine/tests/api/metadata.php b/engine/tests/api/metadata.php index 7897b8d47..f5b615ca8 100644 --- a/engine/tests/api/metadata.php +++ b/engine/tests/api/metadata.php @@ -58,11 +58,11 @@ class ElggCoreMetadataAPITest extends ElggCoreUnitTest { $this->create_metastring('tested'); // create_metadata returns id of metadata on success - $this->assertTrue(create_metadata($this->object->guid, 'metaUnitTest', 'tested')); + $this->assertNotEqual(false, create_metadata($this->object->guid, 'metaUnitTest', 'tested')); // check value with improper case $options = array('metadata_names' => 'metaUnitTest', 'metadata_values' => 'Tested', 'limit' => 10, 'metadata_case_sensitive' => TRUE); - $this->assertFalse(elgg_get_entities_from_metadata($options)); + $this->assertIdentical(array(), elgg_get_entities_from_metadata($options)); // compare forced case with ignored case $options = array('metadata_names' => 'metaUnitTest', 'metadata_values' => 'tested', 'limit' => 10, 'metadata_case_sensitive' => TRUE); diff --git a/engine/tests/api/metastrings.php b/engine/tests/api/metastrings.php index 9b5d7ee4e..a96388217 100644 --- a/engine/tests/api/metastrings.php +++ b/engine/tests/api/metastrings.php @@ -68,9 +68,6 @@ class ElggCoreMetastringsTest extends ElggCoreUnitTest { parent::__destruct(); } - /** - * A basic test that will be called and fail. - */ public function testDeleteByID() { $db_prefix = elgg_get_config('dbprefix'); $annotations = $this->createAnnotations(1); @@ -83,8 +80,8 @@ class ElggCoreMetastringsTest extends ElggCoreUnitTest { $test = get_data($q); $this->assertEqual($test[0]->id, $id); - $this->assertTrue(elgg_delete_metastring_based_object_by_id($id, $type)); - $this->assertFalse(get_data($q)); + $this->assertIdentical(true, elgg_delete_metastring_based_object_by_id($id, $type)); + $this->assertIdentical(array(), get_data($q)); } } @@ -101,9 +98,6 @@ class ElggCoreMetastringsTest extends ElggCoreUnitTest { } } - /** - * A basic test that will be called and fail. - */ public function testEnableDisableByID() { $db_prefix = elgg_get_config('dbprefix'); $annotations = $this->createAnnotations(1); diff --git a/engine/tests/api/plugins.php b/engine/tests/api/plugins.php index a0faaff0e..8ecb0a46c 100644 --- a/engine/tests/api/plugins.php +++ b/engine/tests/api/plugins.php @@ -93,22 +93,23 @@ class ElggCorePluginsAPITest extends ElggCoreUnitTest { ), 'conflicts' => array( - array('type' => 'plugin', 'name' => 'profile_api', 'version' => 1.0) + array('type' => 'plugin', 'name' => 'profile_api', 'version' => '1.0') ), 'provides' => array( - array('type' => 'plugin', 'name' => 'profile_api', 'version' => 1.3), - array('type' => 'php_extension', 'name' => 'big_math', 'version' => 1.0) + array('type' => 'plugin', 'name' => 'profile_api', 'version' => '1.3'), + array('type' => 'php_extension', 'name' => 'big_math', 'version' => '1.0') ), 'suggests' => array( - array('type' => 'plugin', 'name' => 'facebook_connect', 'version' => 1.0), + array('type' => 'plugin', 'name' => 'facebook_connect', 'version' => '1.0'), ), - 'activate_on_install' => true + // string because we are reading from a file + 'activate_on_install' => 'true', ); - $this->assertEqual($this->manifest18->getManifest(), $manifest_array); + $this->assertIdentical($this->manifest18->getManifest(), $manifest_array); } public function testElggPluginManifest17() { @@ -123,7 +124,7 @@ class ElggCorePluginsAPITest extends ElggCoreUnitTest { 'name' => 'Plugin Test 17', ); - $this->assertEqual($this->manifest17->getManifest(), $manifest_array); + $this->assertIdentical($this->manifest17->getManifest(), $manifest_array); } @@ -180,7 +181,7 @@ class ElggCorePluginsAPITest extends ElggCoreUnitTest { array('type' => 'elgg_version', 'version' => '3009030802', 'comparison' => 'lt'), array('type' => 'elgg_release', 'version' => '1.8-svn', 'comparison' => 'ge'), array('type' => 'php_extension', 'name' => 'gd', 'version' => '', 'comparison' => '='), - array('type' => 'php_ini', 'name' => 'short_open_tag', 'value' => 'off', 'comparison' => '='), + array('type' => 'php_ini', 'name' => 'short_open_tag', 'value' => 0, 'comparison' => '='), array('type' => 'php_extension', 'name' => 'made_up', 'version' => '1.0', 'comparison' => '='), array('type' => 'plugin', 'name' => 'fake_plugin', 'version' => '1.0', 'comparison' => 'ge'), array('type' => 'plugin', 'name' => 'profile', 'version' => '1.0', 'comparison' => 'ge'), @@ -188,13 +189,13 @@ class ElggCorePluginsAPITest extends ElggCoreUnitTest { array('type' => 'priority', 'priority' => 'after', 'plugin' => 'profile'), ); - $this->assertEqual($this->package18->getManifest()->getRequires(), $requires); + $this->assertIdentical($this->package18->getManifest()->getRequires(), $requires); $requires = array( array('type' => 'elgg_version', 'version' => '2009030702', 'comparison' => 'ge') ); - $this->assertEqual($this->package17->getManifest()->getRequires(), $requires); + $this->assertIdentical($this->package17->getManifest()->getRequires(), $requires); } public function testElggPluginManifestGetSuggests() { @@ -202,11 +203,11 @@ class ElggCorePluginsAPITest extends ElggCoreUnitTest { array('type' => 'plugin', 'name' => 'facebook_connect', 'version' => '1.0', 'comparison' => 'ge'), ); - $this->assertEqual($this->package18->getManifest()->getSuggests(), $suggests); + $this->assertIdentical($this->package18->getManifest()->getSuggests(), $suggests); $suggests = array(); - $this->assertEqual($this->package17->getManifest()->getSuggests(), $suggests); + $this->assertIdentical($this->package17->getManifest()->getSuggests(), $suggests); } public function testElggPluginManifestGetDescription() { @@ -219,8 +220,8 @@ class ElggCorePluginsAPITest extends ElggCoreUnitTest { 'Admin', 'ServiceAPI' ); - $this->assertEqual($this->package18->getManifest()->getCategories(), $categories); - $this->assertEqual($this->package17->getManifest()->getCategories(), array()); + $this->assertIdentical($this->package18->getManifest()->getCategories(), $categories); + $this->assertIdentical($this->package17->getManifest()->getCategories(), array()); } public function testElggPluginManifestGetScreenshots() { @@ -229,25 +230,25 @@ class ElggCorePluginsAPITest extends ElggCoreUnitTest { array('description' => 'Fun things to do 2', 'path' => 'graphics/plugin_ss2.png'), ); - $this->assertEqual($this->package18->getManifest()->getScreenshots(), $screenshots); - $this->assertEqual($this->package17->getManifest()->getScreenshots(), array()); + $this->assertIdentical($this->package18->getManifest()->getScreenshots(), $screenshots); + $this->assertIdentical($this->package17->getManifest()->getScreenshots(), array()); } public function testElggPluginManifestGetProvides() { $provides = array( - array('type' => 'plugin', 'name' => 'profile_api', 'version' => 1.3), - array('type' => 'php_extension', 'name' => 'big_math', 'version' => 1.0), - array('type' => 'plugin', 'name' => 'plugin_18', 'version' => 1.0) + array('type' => 'plugin', 'name' => 'profile_api', 'version' => '1.3'), + array('type' => 'php_extension', 'name' => 'big_math', 'version' => '1.0'), + array('type' => 'plugin', 'name' => 'plugin_18', 'version' => '1.0') ); - $this->assertEqual($this->package18->getManifest()->getProvides(), $provides); + $this->assertIdentical($this->package18->getManifest()->getProvides(), $provides); $provides = array( array('type' => 'plugin', 'name' => 'plugin_17', 'version' => '1.0') ); - $this->assertEqual($this->package17->getManifest()->getProvides(), $provides); + $this->assertIdentical($this->package17->getManifest()->getProvides(), $provides); } public function testElggPluginManifestGetConflicts() { @@ -260,12 +261,12 @@ class ElggCorePluginsAPITest extends ElggCoreUnitTest { ) ); - $this->assertEqual($this->manifest18->getConflicts(), $conflicts); - $this->assertEqual($this->manifest17->getConflicts(), array()); + $this->assertIdentical($this->manifest18->getConflicts(), $conflicts); + $this->assertIdentical($this->manifest17->getConflicts(), array()); } public function testElggPluginManifestGetActivateOnInstall() { - $this->assertEqual($this->manifest18->getActivateOnInstall(), true); + $this->assertIdentical($this->manifest18->getActivateOnInstall(), true); } // ElggPluginPackage diff --git a/engine/tests/api/river.php b/engine/tests/api/river.php new file mode 100644 index 000000000..6931b9f41 --- /dev/null +++ b/engine/tests/api/river.php @@ -0,0 +1,21 @@ +<?php +/** + * Elgg Test river api + * + * @package Elgg + * @subpackage Test + */ +class ElggCoreRiverAPITest extends ElggCoreUnitTest { + + public function testElggTypeSubtypeWhereSQL() { + $types = array('object'); + $subtypes = array('blog'); + $result = elgg_get_river_type_subtype_where_sql('rv', $types, $subtypes, null); + $this->assertIdentical($result, "((rv.type = 'object') AND ((rv.subtype = 'blog')))"); + + $types = array('object'); + $subtypes = array('blog', 'file'); + $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')))"); + } +} diff --git a/engine/tests/objects/entities.php b/engine/tests/objects/entities.php index c13b4c731..1772f7c1a 100644 --- a/engine/tests/objects/entities.php +++ b/engine/tests/objects/entities.php @@ -89,21 +89,21 @@ class ElggCoreEntityTest extends ElggCoreUnitTest { $this->assertFalse(isset($this->entity->non_existent)); // create metadata - $this->assertTrue($this->entity->non_existent = 'testing'); + $this->entity->existent = 'testing'; + $this->assertIdentical($this->entity->existent, 'testing'); // check metadata set - $this->assertTrue(isset($this->entity->non_existent)); - $this->assertIdentical($this->entity->non_existent, 'testing'); - $this->assertIdentical($this->entity->getMetaData('non_existent'), 'testing'); + $this->assertTrue(isset($this->entity->existent)); + $this->assertIdentical($this->entity->getMetaData('existent'), 'testing'); // check internal metadata array $metadata = $this->entity->expose_metadata(); - $this->assertIdentical($metadata['non_existent'], 'testing'); + $this->assertIdentical($metadata['existent'], 'testing'); } public function testElggEnityGetAndSetAnnotations() { $this->assertFalse(array_key_exists('non_existent', $this->entity->expose_annotations())); - $this->assertFalse($this->entity->getAnnotations('non_existent')); + $this->assertIdentical($this->entity->getAnnotations('non_existent'), array()); // set and check temp annotation $this->assertTrue($this->entity->annotate('non_existent', 'testing')); @@ -178,7 +178,7 @@ class ElggCoreEntityTest extends ElggCoreUnitTest { $this->AssertEqual($this->entity->get('non_existent'), 'testing'); // clean up with delete - $this->assertTrue($this->entity->delete()); + $this->assertIdentical(true, $this->entity->delete()); } public function testElggEntityDisableAndEnable() { @@ -230,24 +230,26 @@ class ElggCoreEntityTest extends ElggCoreUnitTest { // let's delete a non-existent metadata $this->assertFalse($this->entity->deleteMetadata('important')); - // let's add the meatadata - $this->assertTrue($this->entity->important = 'indeed!'); - $this->assertTrue($this->entity->less_important = 'true, too!'); + // let's add the metadata + $this->entity->important = 'indeed!'; + $this->assertIdentical('indeed!', $this->entity->important); + $this->entity->less_important = 'true, too!'; + $this->assertIdentical('true, too!', $this->entity->less_important); $this->save_entity(); // test deleting incorrectly // @link http://trac.elgg.org/ticket/2273 - $this->assertFalse($this->entity->deleteMetadata('impotent')); + $this->assertNull($this->entity->deleteMetadata('impotent')); $this->assertEqual($this->entity->important, 'indeed!'); // get rid of one metadata $this->assertEqual($this->entity->important, 'indeed!'); $this->assertTrue($this->entity->deleteMetadata('important')); - $this->assertEqual($this->entity->important, ''); + $this->assertNull($this->entity->important); // get rid of all metadata $this->assertTrue($this->entity->deleteMetadata()); - $this->assertEqual($this->entity->less_important, ''); + $this->assertNull($this->entity->less_important); // clean up database $this->assertTrue($this->entity->delete()); diff --git a/engine/tests/objects/sites.php b/engine/tests/objects/sites.php index e5acbb3f9..a01a661e3 100644 --- a/engine/tests/objects/sites.php +++ b/engine/tests/objects/sites.php @@ -36,9 +36,6 @@ class ElggCoreSiteTest extends ElggCoreUnitTest { parent::__destruct(); } - /** - * A basic test that will be called and fail. - */ public function testElggSiteConstructor() { $attributes = array(); $attributes['guid'] = NULL; @@ -66,8 +63,10 @@ class ElggCoreSiteTest extends ElggCoreUnitTest { } public function testElggSiteSaveAndDelete() { - $this->assertTrue($this->site->save()); - $this->assertTrue($this->site->delete()); + $guid = $this->site->save(); + $this->assertIsA($guid, 'int'); + $this->assertTrue($guid > 0); + $this->assertIdentical(true, $this->site->delete()); } } diff --git a/engine/tests/objects/users.php b/engine/tests/objects/users.php index d1533c3d2..a3573acb6 100644 --- a/engine/tests/objects/users.php +++ b/engine/tests/objects/users.php @@ -41,9 +41,6 @@ class ElggCoreUserTest extends ElggCoreUnitTest { parent::__destruct(); } - /** - * A basic test that will be called and fail. - */ public function testElggUserConstructor() { $attributes = array(); $attributes['guid'] = NULL; @@ -138,7 +135,7 @@ class ElggCoreUserTest extends ElggCoreUnitTest { $guid = $this->user->save(); // delete object - $this->assertTrue($this->user->delete()); + $this->assertIdentical(true, $this->user->delete()); // check GUID not in database $this->assertFalse($this->fetchUser($guid)); diff --git a/engine/tests/regression/trac_bugs.php b/engine/tests/regression/trac_bugs.php index 2bfc37558..99cf81774 100644 --- a/engine/tests/regression/trac_bugs.php +++ b/engine/tests/regression/trac_bugs.php @@ -45,7 +45,7 @@ class ElggCoreRegressionBugsTest extends ElggCoreUnitTest { /** * #1558 */ - public function testElggObjectClearAnnotations() { + public function testElggObjectDeleteAnnotations() { $this->entity = new ElggObject(); $guid = $this->entity->save(); diff --git a/engine/tests/test_files/plugin_18/manifest.xml b/engine/tests/test_files/plugin_18/manifest.xml index e0776ffc1..9654b6422 100644 --- a/engine/tests/test_files/plugin_18/manifest.xml +++ b/engine/tests/test_files/plugin_18/manifest.xml @@ -34,8 +34,6 @@ <category>ServiceAPI</category> - <activate_on_install>true</activate_on_install> - <requires> <type>php_extension</type> <name>gd</name> @@ -102,4 +100,6 @@ <version>1.0</version> </suggests> + <activate_on_install>true</activate_on_install> + </plugin_manifest> diff --git a/engine/tests/test_skeleton.php b/engine/tests/test_skeleton.php index e5ff557e5..5a5de89bb 100644 --- a/engine/tests/test_skeleton.php +++ b/engine/tests/test_skeleton.php @@ -49,9 +49,6 @@ class ElggCoreSkeletonTest extends ElggCoreUnitTest { parent::__destruct(); } - /** - * A basic test that will be called and fail. - */ public function testFailure() { $this->assertTrue(FALSE); } diff --git a/htaccess_dist b/htaccess_dist index bf163c69e..88285f81b 100644 --- a/htaccess_dist +++ b/htaccess_dist @@ -115,9 +115,6 @@ RewriteRule ^services\/api\/([A-Za-z0-9\_\-]+)\/(.*)$ engine/handlers/service_ha RewriteRule ^export\/([A-Za-z]+)\/([0-9]+)\/?$ engine/handlers/export_handler.php?view=$1&guid=$2 RewriteRule ^export\/([A-Za-z]+)\/([0-9]+)\/([A-Za-z]+)\/([A-Za-z0-9\_]+)\/$ engine/handlers/export_handler.php?view=$1&guid=$2&type=$3&idname=$4 -RewriteRule xml-rpc.php engine/handlers/xml-rpc_handler.php -RewriteRule mt/mt-xmlrpc.cgi engine/handlers/xml-rpc_handler.php - # rule for rewrite module test during install - can be removed after installation RewriteRule ^rewrite.php$ install.php @@ -125,7 +122,7 @@ RewriteRule ^rewrite.php$ install.php # Everything else that isn't a file gets routed through the page handler RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f -RewriteRule ^([A-Za-z0-9\_\-]+)$ engine/handlers/page_handler.php?handler=$1 [QSA] +RewriteRule ^([A-Za-z0-9\_\-.]+)$ engine/handlers/page_handler.php?handler=$1 [QSA] RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f diff --git a/install/ElggInstaller.php b/install/ElggInstaller.php index d556ba744..2070f15e9 100644 --- a/install/ElggInstaller.php +++ b/install/ElggInstaller.php @@ -780,7 +780,7 @@ class ElggInstaller { 'database.php', 'actions.php', 'admin.php', 'annotations.php', - 'calendar.php', 'cron.php', 'entities.php', + 'cron.php', 'entities.php', 'extender.php', 'filestore.php', 'group.php', 'location.php', 'mb_wrapper.php', 'memcache.php', 'metadata.php', 'metastrings.php', @@ -790,8 +790,8 @@ class ElggInstaller { 'private_settings.php', 'relationships.php', 'river.php', 'sites.php', 'statistics.php', 'tags.php', 'user_settings.php', 'users.php', 'upgrade.php', 'web_services.php', - 'widgets.php', 'xml.php', 'xml-rpc.php', 'deprecated-1.7.php', - 'deprecated-1.8.php', + 'widgets.php', 'xml.php', 'deprecated-1.7.php', + 'deprecated-1.8.php', 'deprecated-1.9.php' ); foreach ($lib_files as $file) { diff --git a/install/languages/en.php b/install/languages/en.php index 3e2569669..bbcd72d20 100644 --- a/install/languages/en.php +++ b/install/languages/en.php @@ -64,7 +64,7 @@ If you are ready to proceed, click the Next button.", 'install:database:label:dbhost' => 'Database Host', 'install:database:label:dbprefix' => 'Database Table Prefix', - 'install:database:help:dbuser' => 'User that has full priviledges to the MySQL database that you created for Elgg', + 'install:database:help:dbuser' => 'User that has full privileges to the MySQL database that you created for Elgg', 'install:database:help:dbpassword' => 'Password for the above database user account', 'install:database:help:dbname' => 'Name of the Elgg database', 'install:database:help:dbhost' => 'Hostname of the MySQL server (usually localhost)', diff --git a/js/lib/languages.js b/js/lib/languages.js index ae7ba63e2..bfa858364 100644 --- a/js/lib/languages.js +++ b/js/lib/languages.js @@ -26,16 +26,22 @@ elgg.add_translation = function(lang, translations) { elgg.reload_all_translations = function(language) { var lang = language || elgg.get_language(); - elgg.getJSON('ajax/view/js/languages', { - data: { - language: lang - }, - success: function(json) { - elgg.add_translation(lang, json); - elgg.config.languageReady = true; - elgg.initWhenReady(); - } - }); + var url, options; + if (elgg.config.simplecache_enabled) { + url = 'cache/js/default/languages/' + lang + '.' + elgg.config.lastcache + '.js'; + options = {}; + } else { + url = 'ajax/view/js/languages'; + options = {data: {language: lang}}; + } + + options['success'] = function(json) { + elgg.add_translation(lang, json); + elgg.config.languageReady = true; + elgg.initWhenReady(); + }; + + elgg.getJSON(url, options); }; /** diff --git a/js/lib/pageowner.js b/js/lib/pageowner.js index 825898416..c695c41c3 100644 --- a/js/lib/pageowner.js +++ b/js/lib/pageowner.js @@ -6,9 +6,13 @@ */ /** - * @return {number} The GUID of the logged in user + * @return {number} The GUID of the page owner entity or 0 for no owner */ elgg.get_page_owner_guid = function() { - return elgg.page_owner.guid || 0; + if (elgg.page_owner !== undefined) { + return elgg.page_owner.guid; + } else { + return 0; + } }; diff --git a/js/lib/ui.userpicker.js b/js/lib/ui.userpicker.js index 8287ba91c..7298da114 100644 --- a/js/lib/ui.userpicker.js +++ b/js/lib/ui.userpicker.js @@ -93,7 +93,7 @@ elgg.userpicker.viewUser = function(info) { html += "<div class='elgg-image'>" + info.icon + "</div>"; html += "<div class='elgg-image-alt'>" + deleteLink + "</div>"; html += "<div class='elgg-body'>" + info.name + "</div>"; - html += "</div"; + html += "</div>"; return html; }; diff --git a/js/lib/ui.widgets.js b/js/lib/ui.widgets.js index 6435d2147..47e43c876 100644 --- a/js/lib/ui.widgets.js +++ b/js/lib/ui.widgets.js @@ -107,7 +107,7 @@ elgg.ui.widgets.move = function(event, ui) { * @return void */ elgg.ui.widgets.remove = function(event) { - var $widget = $(this).parent().parent(); + var $widget = $(this).closest('.elgg-module-widget'); // if widget type is single instance type, enable the add buton var type = $widget.attr('class'); @@ -124,15 +124,9 @@ elgg.ui.widgets.remove = function(event) { $widget.remove(); - // elgg-widget-delete-button-<guid> - var id = $(this).attr('id'); - id = id.substr(id.indexOf('elgg-widget-delete-button-') + "elgg-widget-delete-button-".length); + // delete the widget through ajax + elgg.action($(this).attr('href')); - elgg.action('widgets/delete', { - data: { - widget_guid: id - } - }); event.preventDefault(); }; @@ -196,7 +190,7 @@ elgg.ui.widgets.equalHeight = function(selector) { maxHeight = $(this).height(); } }) - $(selector).css('min-height', maxHeight); + $(selector).css('min-height', maxHeight + 'px'); }; elgg.register_hook_handler('init', 'system', elgg.ui.widgets.init); diff --git a/languages/en.php b/languages/en.php index 62effb334..7d985b82f 100644 --- a/languages/en.php +++ b/languages/en.php @@ -20,7 +20,7 @@ $english = array( 'login' => "Log in", 'loginok' => "You have been logged in.", 'loginerror' => "We couldn't log you in. Please check your credentials and try again.", - 'login:empty' => "Username and password are required.", + 'login:empty' => "Username/email and password are required.", 'login:baduser' => "Unable to load your user account.", 'auth:nopams' => "Internal error. No user authentication method installed.", @@ -167,6 +167,7 @@ $english = array( 'InvalidParameterException:DoesNotBelongOrRefer' => "Does not belong to entity or refer to entity.", 'InvalidParameterException:MissingParameter' => "Missing parameter, you need to provide a GUID.", 'InvalidParameterException:LibraryNotRegistered' => '%s is not a registered library', + 'InvalidParameterException:LibraryNotFound' => 'Could not load the %s library from %s', 'APIException:ApiResultUnknown' => "API Result is of an unknown type, this should never happen.", 'ConfigurationException:NoSiteID' => "No site ID has been specified.", @@ -207,10 +208,6 @@ $english = array( 'SecurityException:InvalidAPIKey' => "Invalid or missing API Key.", 'NotImplementedException:CallMethodNotImplemented' => "Call method '%s' is currently not supported.", - 'NotImplementedException:XMLRPCMethodNotImplemented' => "XML-RPC method call '%s' not implemented.", - 'InvalidParameterException:UnexpectedReturnFormat' => "Call to method '%s' returned an unexpected result.", - 'CallException:NotRPCCall' => "Call does not appear to be a valid XML-RPC call", - 'PluginException:NoPluginName' => "The plugin name could not be found", 'SecurityException:authenticationfailed' => "User could not be authenticated", @@ -222,8 +219,8 @@ $english = array( 'RegistrationException:EmptyPassword' => 'The password fields cannot be empty', 'RegistrationException:PasswordMismatch' => 'Passwords must match', 'LoginException:BannedUser' => 'You have been banned from this site and cannot log in', - 'LoginException:UsernameFailure' => 'We could not log you in. Please check your username and password.', - 'LoginException:PasswordFailure' => 'We could not log you in. Please check your username and password.', + 'LoginException:UsernameFailure' => 'We could not log you in. Please check your username/email and password.', + 'LoginException:PasswordFailure' => 'We could not log you in. Please check your username/email and password.', 'LoginException:AccountLocked' => 'Your account has been locked for too many log in failures.', 'LoginException:ChangePasswordFailure' => 'Failed current password check.', @@ -239,6 +236,9 @@ $english = array( 'changebookmark' => 'Please change your bookmark for this page', 'noaccess' => 'This content has been removed, is invalid, or you do not have permission to view it.', + 'error:default' => 'Oops...something went wrong.', + 'error:404' => 'Sorry. We could not find the page that you requested.', + /** * API */ @@ -481,6 +481,7 @@ $english = array( 'account' => "Account", 'settings' => "Settings", 'tools' => "Tools", + 'settings:edit' => 'Edit settings', 'register' => "Register", 'registerok' => "You have successfully registered for %s.", @@ -530,7 +531,7 @@ $english = array( 'user:password:resetreq:success' => 'Successfully requested a new password, email sent', 'user:password:resetreq:fail' => 'Could not request a new password.', - 'user:password:text' => 'To request a new password, enter your username below and click the Request button.', + 'user:password:text' => 'To request a new password, enter your username or email address below and click the Request button.', 'user:persistent' => 'Remember me', @@ -608,6 +609,12 @@ $english = array( // argh, this is ugly 'admin:widget:admin_welcome:outro' => '<br />Be sure to check out the resources available through the footer links and thank you for using Elgg!', + 'admin:widget:control_panel' => 'Control panel', + 'admin:widget:control_panel:help' => "Provides easy access to common controls", + + 'admin:cache:flush' => 'Flush the caches', + 'admin:cache:flushed' => "The site's caches have been flushed", + 'admin:footer:faq' => 'Administration FAQ', 'admin:footer:manual' => 'Administration Manual', 'admin:footer:community_forums' => 'Elgg Community Forums', @@ -1038,7 +1045,7 @@ Once you have logged in, we highly recommend that you change your password. 'email:settings' => "Email settings", 'email:address:label' => "Your email address", - 'email:save:success' => "New email address saved, verification requested.", + 'email:save:success' => "New email address saved. Verification is requested.", 'email:save:fail' => "Your new email address could not be saved.", 'friend:newfriend:subject' => "%s has made you a friend!", @@ -1063,7 +1070,7 @@ Your password has been reset to: %s", Somebody (from the IP address %s) has requested a new password for their account. -If you requested this click on the link below, otherwise ignore this email. +If you requested this, click on the link below. Otherwise ignore this email. %s ", @@ -1078,11 +1085,6 @@ If you requested this click on the link below, otherwise ignore this email. 'user:default_access:failure' => "Your new default access level could not be saved.", /** - * XML-RPC - */ - 'xmlrpc:noinputdata' => "Input data missing", - -/** * Comments */ diff --git a/mod/blog/actions/blog/auto_save_revision.php b/mod/blog/actions/blog/auto_save_revision.php index 1acf3b31b..66b65c5fd 100644 --- a/mod/blog/actions/blog/auto_save_revision.php +++ b/mod/blog/actions/blog/auto_save_revision.php @@ -63,7 +63,7 @@ if ($title && $description) { if (!$auto_save) { $annotation_id = $blog->annotate('blog_auto_save', $description); } elseif ($auto_save instanceof ElggAnnotation && $auto_save->value != $description) { - $blog->clearAnnotations('blog_auto_save'); + $blog->deleteAnnotations('blog_auto_save'); $annotation_id = $blog->annotate('blog_auto_save', $description); } elseif ($auto_save instanceof ElggAnnotation && $auto_save->value == $description) { // this isn't an error because we have an up to date annotation. diff --git a/mod/blog/actions/blog/save.php b/mod/blog/actions/blog/save.php index 8be67ec6c..8ca8ce846 100644 --- a/mod/blog/actions/blog/save.php +++ b/mod/blog/actions/blog/save.php @@ -131,10 +131,10 @@ if (!$error) { elgg_clear_sticky_form('blog'); // remove autosave draft if exists - $blog->clearAnnotations('blog_auto_save'); + $blog->deleteAnnotations('blog_auto_save'); // no longer a brand new post. - $blog->clearMetadata('new_post'); + $blog->deleteMetadata('new_post'); // if this was an edit, create a revision annotation if (!$new_post && $revision_text) { diff --git a/mod/developers/start.php b/mod/developers/start.php index 2e3df7663..79ec0655a 100644 --- a/mod/developers/start.php +++ b/mod/developers/start.php @@ -23,6 +23,8 @@ function developers_init() { elgg_register_js('jquery.jstree', 'mod/developers/vendors/jsTree/jquery.jstree.js', 'footer'); elgg_register_css('jquery.jstree', 'mod/developers/vendors/jsTree/themes/default/style.css'); + elgg_load_js('jquery.form'); + elgg_register_js('elgg.dev', 'js/developers/developers.js', 'footer'); elgg_load_js('elgg.dev'); } @@ -166,13 +168,13 @@ function developers_theme_preview_controller($page) { $pages = array( 'buttons', - 'components', - 'forms', - 'grid', + 'components', + 'forms', + 'grid', 'icons', - 'modules', - 'navigation', - 'typography', + 'modules', + 'navigation', + 'typography', ); foreach ($pages as $page_name) { diff --git a/mod/embed/manifest.xml b/mod/embed/manifest.xml index 7ffbc23a4..46ab2df9e 100644 --- a/mod/embed/manifest.xml +++ b/mod/embed/manifest.xml @@ -13,9 +13,10 @@ <type>elgg_release</type> <version>1.8</version> </requires> - <requires> + <suggests> <type>plugin</type> <name>file</name> - </requires> + <version>1.8.1</version> + </suggests> <activate_on_install>true</activate_on_install> </plugin_manifest> diff --git a/mod/embed/start.php b/mod/embed/start.php index 015c0c0e4..a3ccab66b 100644 --- a/mod/embed/start.php +++ b/mod/embed/start.php @@ -37,10 +37,15 @@ function embed_longtext_menu($hook, $type, $items, $vars) { if (elgg_get_context() == 'embed') { return $items; } + + $url = 'embed'; + if (elgg_get_page_owner_guid()) { + $url = 'embed?container_guid=' . elgg_get_page_owner_guid(); + } $items[] = ElggMenuItem::factory(array( 'name' => 'embed', - 'href' => "embed", + 'href' => $url, 'text' => elgg_echo('embed:media'), 'rel' => 'lightbox', 'link_class' => "elgg-longtext-control elgg-lightbox embed-control embed-control-{$vars['id']}", @@ -49,6 +54,7 @@ function embed_longtext_menu($hook, $type, $items, $vars) { elgg_load_js('lightbox'); elgg_load_css('lightbox'); + elgg_load_js('jquery.form'); elgg_load_js('elgg.embed'); return $items; @@ -64,7 +70,9 @@ function embed_longtext_menu($hook, $type, $items, $vars) { */ function embed_select_tab($hook, $type, $items, $vars) { - $tab_name = array_pop(explode('/', full_url())); + // can this ba called from page handler instead? + $page = get_input('page'); + $tab_name = array_pop(explode('/', $page)); foreach ($items as $item) { if ($item->getName() == $tab_name) { $item->setSelected(); @@ -85,6 +93,11 @@ function embed_select_tab($hook, $type, $items, $vars) { */ function embed_page_handler($page) { + $container_guid = (int)get_input('container_guid'); + if ($container_guid) { + elgg_set_page_owner_guid($container_guid); + } + echo elgg_view('embed/layout'); // exit because this is in a modal display. @@ -120,15 +133,17 @@ function embed_list_items($entities, $vars = array()) { */ function embed_get_list_options($options = array()) { + $container_guids = array(elgg_get_logged_in_user_guid()); if (elgg_get_page_owner_guid()) { - $container_guid = elgg_get_page_owner_guid(); - } else { - $container_guid = elgg_get_logged_in_user_guid(); + $page_owner_guid = elgg_get_page_owner_guid(); + if ($page_owner_guid != elgg_get_logged_in_user_guid()) { + $container_guids[] = $page_owner_guid; + } } $defaults = array( 'limit' => 6, - 'container_guid' => $container_guid, + 'container_guids' => $container_guids, 'item_class' => 'embed-item', ); diff --git a/mod/embed/views/default/embed/layout.php b/mod/embed/views/default/embed/layout.php index c1e43f13c..e906160b1 100644 --- a/mod/embed/views/default/embed/layout.php +++ b/mod/embed/views/default/embed/layout.php @@ -21,10 +21,17 @@ if ($selected->getData('view')) { } } + +$container_info = elgg_view('input/hidden', array( + 'name' => 'embed_container_guid', + 'value' => elgg_get_page_owner_guid(), +)); + echo <<<HTML <div class="embed-wrapper"> $title $menu $tab + $container_info </div> HTML; diff --git a/mod/embed/views/default/js/embed/embed.php b/mod/embed/views/default/js/embed/embed.php index 8a8f0290c..5fd534a09 100644 --- a/mod/embed/views/default/js/embed/embed.php +++ b/mod/embed/views/default/js/embed/embed.php @@ -35,7 +35,12 @@ elgg.embed.insert = function(event) { // generalize this based on a css class attached to what should be inserted var content = ' ' + $(this).find(".embed-insert").parent().html() + ' '; - + + // this is a temporary work-around for #3971 + if (content.indexOf('thumbnail.php') != -1) { + content = content.replace('size=small', 'size=medium'); + } + textArea.val(textArea.val() + content); textArea.focus(); @@ -75,9 +80,13 @@ elgg.embed.submit = function(event) { if (response.status >= 0) { var forward = $('input[name=embed_forward]').val(); var url = elgg.normalize_url('embed/tab/' + forward); + url = elgg.embed.addContainerGUID(url); $('.embed-wrapper').parent().load(url); } } + }, + error: function(xhr, status) { + // nothing for now } }); @@ -93,8 +102,27 @@ elgg.embed.submit = function(event) { * @return void */ elgg.embed.forward = function(event) { - $('.embed-wrapper').parent().load($(this).attr('href')); + // make sure container guid is passed + var url = $(this).attr('href'); + url = elgg.embed.addContainerGUID(url); + + $('.embed-wrapper').parent().load(url); event.preventDefault(); }; +/** + * Adds the container guid to a URL + * + * @param {string} url + * @return string + */ +elgg.embed.addContainerGUID = function(url) { + if (url.indexOf('container_guid=') == -1) { + var guid = $('input[name=embed_container_guid]').val(); + return url + '?container_guid=' + guid; + } else { + return url; + } +}; + elgg.register_hook_handler('init', 'system', elgg.embed.init); diff --git a/mod/externalpages/start.php b/mod/externalpages/start.php index 13235af53..152a8b4d9 100644 --- a/mod/externalpages/start.php +++ b/mod/externalpages/start.php @@ -43,8 +43,11 @@ function expages_setup_footer_menu() { $pages = array('about', 'terms', 'privacy'); foreach ($pages as $page) { $url = "$page"; - $item = new ElggMenuItem($page, elgg_echo("expages:$page"), $url); - elgg_register_menu_item('walled_garden', $item); + $wg_item = new ElggMenuItem($page, elgg_echo("expages:$page"), $url); + elgg_register_menu_item('walled_garden', $wg_item); + + $footer_item = clone $wg_item; + elgg_register_menu_item('footer', $footer_item); } } diff --git a/mod/file/views/default/embed/file_upload/content.php b/mod/file/views/default/embed/file_upload/content.php index 4d3db0d97..8b630c828 100644 --- a/mod/file/views/default/embed/file_upload/content.php +++ b/mod/file/views/default/embed/file_upload/content.php @@ -7,7 +7,8 @@ $form_vars = array( 'enctype' => 'multipart/form-data', 'class' => 'elgg-form-embed', ); -echo elgg_view_form('file/upload', $form_vars); +$body_vars = array('container_guid' => elgg_get_page_owner_guid()); +echo elgg_view_form('file/upload', $form_vars, $body_vars); // the tab we want to be forwarded to after upload is complete echo elgg_view('input/hidden', array( diff --git a/mod/groups/start.php b/mod/groups/start.php index 7dcf6b7c4..09362cbbc 100644 --- a/mod/groups/start.php +++ b/mod/groups/start.php @@ -830,7 +830,7 @@ function discussion_add_to_river_menu($hook, $type, $return, $params) { if (elgg_instanceof($object, 'object', 'groupforumtopic')) { if ($item->annotation_id == 0) { $group = $object->getContainerEntity(); - if ($group->canWriteToContainer() || elgg_is_admin_logged_in()) { + if ($group && ($group->canWriteToContainer() || elgg_is_admin_logged_in())) { $options = array( 'name' => 'reply', 'href' => "#groups-reply-$object->guid", diff --git a/mod/groups/views/default/groups/membershiprequests.php b/mod/groups/views/default/groups/membershiprequests.php index 9cd28262f..2bac0e32b 100644 --- a/mod/groups/views/default/groups/membershiprequests.php +++ b/mod/groups/views/default/groups/membershiprequests.php @@ -7,7 +7,6 @@ */ if (!empty($vars['requests']) && is_array($vars['requests'])) { - $user = elgg_get_logged_in_user_entity(); echo '<ul class="elgg-list">'; foreach ($vars['requests'] as $user) { $icon = elgg_view_entity_icon($user, 'tiny', array('use_hover' => 'true')); @@ -44,5 +43,5 @@ if (!empty($vars['requests']) && is_array($vars['requests'])) { } echo '</ul>'; } else { - echo '<p class="mtm">' . elgg_echo('groups:requests:none') . "</p>"; + echo '<p class="mtm">' . elgg_echo('groups:requests:none') . '</p>'; } diff --git a/mod/likes/start.php b/mod/likes/start.php index 690d7c052..0f8e12159 100644 --- a/mod/likes/start.php +++ b/mod/likes/start.php @@ -65,6 +65,11 @@ function likes_river_menu_setup($hook, $type, $return, $params) { if ($item->type == "group" && $item->view != "river/group/create") { return $return; } + + // don't like users #4116 + if ($item->type == "user") { + return $return; + } $object = $item->getObjectEntity(); if (!elgg_in_context('widgets') && $item->annotation_id == 0) { diff --git a/mod/logbrowser/start.php b/mod/logbrowser/start.php index 3bffe800a..22659877b 100644 --- a/mod/logbrowser/start.php +++ b/mod/logbrowser/start.php @@ -23,7 +23,7 @@ function logbrowser_init() { function logbrowser_user_hover_menu($hook, $type, $return, $params) { $user = $params['entity']; - $url = "admin/utilities/logbrowser?user_guid={$user->guid}"; + $url = "admin/administer_utilities/logbrowser?user_guid={$user->guid}"; $item = new ElggMenuItem('logbrowser', elgg_echo('logbrowser:explore'), $url); $item->setSection('admin'); $return[] = $item; diff --git a/mod/logbrowser/views/default/admin/administer_utilities/logbrowser.php b/mod/logbrowser/views/default/admin/administer_utilities/logbrowser.php index 2be1f33dc..a04ef686a 100644 --- a/mod/logbrowser/views/default/admin/administer_utilities/logbrowser.php +++ b/mod/logbrowser/views/default/admin/administer_utilities/logbrowser.php @@ -13,14 +13,14 @@ $offset = get_input('offset'); $search_username = get_input('search_username'); if ($search_username) { if ($user = get_user_by_username($search_username)) { - $user = $user->guid; + $user_guid = $user->guid; } } else { $user_guid = get_input('user_guid',0); if ($user_guid) { - $user = (int) $user_guid; + $user_guid = (int) $user_guid; } else { - $user = ""; + $user_guid = null; } } @@ -35,14 +35,14 @@ if ($timeupper) { } $refine = elgg_view('logbrowser/refine', array( - 'user_guid' => $user, + 'user_guid' => $user_guid, 'timeupper' => $timeupper, 'timelower' => $timelower, )); // Get log entries -$log = get_system_log($user, "", "", "","", $limit, $offset, false, $timeupper, $timelower); -$count = get_system_log($user, "", "", "","", $limit, $offset, true, $timeupper, $timelower); +$log = get_system_log($user_guid, "", "", "","", $limit, $offset, false, $timeupper, $timelower); +$count = get_system_log($user_guid, "", "", "","", $limit, $offset, true, $timeupper, $timelower); $table = elgg_view('logbrowser/table', array('log_entries' => $log)); diff --git a/mod/logbrowser/views/default/logbrowser/refine.php b/mod/logbrowser/views/default/logbrowser/refine.php index 27cb6042f..86460c79e 100644 --- a/mod/logbrowser/views/default/logbrowser/refine.php +++ b/mod/logbrowser/views/default/logbrowser/refine.php @@ -18,13 +18,18 @@ $toggle_link = elgg_view('output/url', array( 'rel' => 'toggle', )); +$form_class = 'elgg-module elgg-module-inline'; +if (!isset($vars['user_guid'])) { + $form_class .= ' hidden'; +} + ?> <div id="logbrowser-search-area" class="mbm"> <div> <?php echo $toggle_link; ?> </div> - <div id="log-browser-search-form" class="elgg-module elgg-module-inline hidden"> + <div id="log-browser-search-form" class="<?php echo $form_class; ?>"> <div class="elgg-head"> <h3><?php echo elgg_echo('logbrowser:search'); ?></h3> </div> diff --git a/mod/messages/languages/en.php b/mod/messages/languages/en.php index 308c3d519..7732a9dce 100644 --- a/mod/messages/languages/en.php +++ b/mod/messages/languages/en.php @@ -11,6 +11,7 @@ $english = array( */ 'messages' => "Messages", + 'messages:unreadcount' => "%s unread", 'messages:back' => "back to messages", 'messages:user' => "%s's inbox", 'messages:posttitle' => "%s's messages: %s", diff --git a/mod/messages/start.php b/mod/messages/start.php index e4ef4d43a..1a2709324 100644 --- a/mod/messages/start.php +++ b/mod/messages/start.php @@ -125,11 +125,13 @@ function messages_notifier() { if (elgg_is_logged_in()) { $class = "elgg-icon elgg-icon-mail"; $text = "<span class='$class'></span>"; - + $tooltip = elgg_echo("messages"); + // get unread messages $num_messages = (int)messages_count_unread(); if ($num_messages != 0) { $text .= "<span class=\"messages-new\">$num_messages</span>"; + $tooltip .= " (" . elgg_echo("messages:unreadcount", array($num_messages)) . ")"; } elgg_register_menu_item('topbar', array( @@ -137,6 +139,7 @@ function messages_notifier() { 'href' => 'messages/inbox/' . elgg_get_logged_in_user_entity()->username, 'text' => $text, 'priority' => 600, + 'title' => $tooltip, )); } } diff --git a/mod/messages/views/default/forms/messages/process.php b/mod/messages/views/default/forms/messages/process.php index 7e182b8f0..f86c3217a 100644 --- a/mod/messages/views/default/forms/messages/process.php +++ b/mod/messages/views/default/forms/messages/process.php @@ -10,7 +10,8 @@ $messages = $vars['list']; if (!$messages) { - $messages = elgg_echo('messages:nomessages'); + echo elgg_echo('messages:nomessages'); + return true; } echo '<div class="messages-container">'; diff --git a/mod/oauth_api/manifest.xml b/mod/oauth_api/manifest.xml index efd3d944f..991be6a22 100644 --- a/mod/oauth_api/manifest.xml +++ b/mod/oauth_api/manifest.xml @@ -18,4 +18,8 @@ <type>plugin</type> <name>oauth_lib</name> </conflicts> + <conflicts> + <type>php_extension</type> + <name>oauth</name> + </conflicts> </plugin_manifest> diff --git a/mod/profile/start.php b/mod/profile/start.php index adee838fc..abe044632 100644 --- a/mod/profile/start.php +++ b/mod/profile/start.php @@ -73,7 +73,7 @@ function profile_page_handler($page) { // use the core profile edit page $base_dir = elgg_get_root_path(); require "{$base_dir}pages/profile/edit.php"; - return; + return true; } // main profile page diff --git a/mod/profile/views/default/profile/owner_block.php b/mod/profile/views/default/profile/owner_block.php index 35199726a..63cb5391a 100644 --- a/mod/profile/views/default/profile/owner_block.php +++ b/mod/profile/views/default/profile/owner_block.php @@ -11,7 +11,10 @@ if (!$user) { return TRUE; } -$icon = elgg_view_entity_icon($user, 'large', array('use_hover' => 'true')); +$icon = elgg_view_entity_icon($user, 'large', array( + 'use_hover' => false, + 'use_link' => false, +)); // grab the actions and admin menu items from user hover $menu = elgg_trigger_plugin_hook('register', "menu:user_hover", array('entity' => $user), array()); diff --git a/mod/search/pages/search/index.php b/mod/search/pages/search/index.php index c4e8d2219..efa3ec037 100644 --- a/mod/search/pages/search/index.php +++ b/mod/search/pages/search/index.php @@ -19,7 +19,12 @@ $query = stripslashes(get_input('q', get_input('tag', ''))); // @todo - create function for sanitization of strings for display in 1.8 // encode <,>,&, quotes and characters above 127 -$display_query = mb_convert_encoding($query, 'HTML-ENTITIES', 'UTF-8'); +if (function_exists('mb_convert_encoding')) { + $display_query = mb_convert_encoding($query, 'HTML-ENTITIES', 'UTF-8'); +} else { + // if no mbstring extension, we just strip characters + $display_query = preg_replace("/[^\x01-\x7F]/", "", $query); +} $display_query = htmlspecialchars($display_query, ENT_QUOTES, 'UTF-8', false); // check that we have an actual query diff --git a/mod/search/start.php b/mod/search/start.php index 73a96dc0a..bb8531e9c 100644 --- a/mod/search/start.php +++ b/mod/search/start.php @@ -107,6 +107,7 @@ function search_get_highlighted_relevant_substrings($haystack, $query, $min_matc $word = elgg_strtolower($word); $count = elgg_substr_count($haystack_lc, $word); $word_len = elgg_strlen($word); + $haystack_len = elgg_strlen($haystack_lc); // find the start positions for the words if ($count > 1) { @@ -117,6 +118,10 @@ function search_get_highlighted_relevant_substrings($haystack, $query, $min_matc $stop = $pos + $word_len + $min_match_context; $lengths[] = $stop - $start; $offset += $pos + $word_len; + + if ($offset >= $haystack_len) { + break; + } } } else { $pos = elgg_strpos($haystack_lc, $word); diff --git a/mod/search/views/default/search/search_box.php b/mod/search/views/default/search/search_box.php index 9440dd1de..87d59519c 100644 --- a/mod/search/views/default/search/search_box.php +++ b/mod/search/views/default/search/search_box.php @@ -24,7 +24,12 @@ $value = stripslashes($value); // @todo - create function for sanitization of strings for display in 1.8 // encode <,>,&, quotes and characters above 127 -$display_query = mb_convert_encoding($value, 'HTML-ENTITIES', 'UTF-8'); +if (function_exists('mb_convert_encoding')) { + $display_query = mb_convert_encoding($value, 'HTML-ENTITIES', 'UTF-8'); +} else { + // if no mbstring extension, we just strip characters + $display_query = preg_replace("/[^\x01-\x7F]/", "", $value); +} $display_query = htmlspecialchars($display_query, ENT_QUOTES, 'UTF-8', false); diff --git a/mod/thewire/pages/thewire/everyone.php b/mod/thewire/pages/thewire/everyone.php index 4e88d17af..909f0caf2 100644 --- a/mod/thewire/pages/thewire/everyone.php +++ b/mod/thewire/pages/thewire/everyone.php @@ -8,13 +8,14 @@ elgg_push_breadcrumb(elgg_echo('thewire')); $title = elgg_echo('thewire:everyone'); +$content = ''; if (elgg_is_logged_in()) { $form_vars = array('class' => 'thewire-form'); $content .= elgg_view_form('thewire/add', $form_vars); $content .= elgg_view('input/urlshortener'); } -$content = elgg_list_entities(array( +$content .= elgg_list_entities(array( 'type' => 'object', 'subtype' => 'thewire', 'limit' => 15, diff --git a/mod/thewire/pages/thewire/friends.php b/mod/thewire/pages/thewire/friends.php index 26ad03da6..e7f5eed59 100644 --- a/mod/thewire/pages/thewire/friends.php +++ b/mod/thewire/pages/thewire/friends.php @@ -14,7 +14,7 @@ elgg_push_breadcrumb(elgg_echo('thewire'), "thewire/all"); elgg_push_breadcrumb($owner->name, "thewire/owner/$owner->username"); elgg_push_breadcrumb(elgg_echo('friends')); -if (get_loggedin_userid() == $owner->guid) { +if (elgg_get_logged_in_user_guid() == $owner->guid) { $form_vars = array('class' => 'thewire-form'); $content = elgg_view_form('thewire/add', $form_vars); $content .= elgg_view('input/urlshortener'); diff --git a/mod/thewire/pages/thewire/owner.php b/mod/thewire/pages/thewire/owner.php index a95786b0a..f544aa655 100644 --- a/mod/thewire/pages/thewire/owner.php +++ b/mod/thewire/pages/thewire/owner.php @@ -14,7 +14,7 @@ $title = elgg_echo('thewire:user', array($owner->name)); elgg_push_breadcrumb(elgg_echo('thewire'), "thewire/all"); elgg_push_breadcrumb($owner->name); -if (get_loggedin_userid() == $owner->guid) { +if (elgg_get_logged_in_user_guid() == $owner->guid) { $form_vars = array('class' => 'thewire-form'); $content = elgg_view_form('thewire/add', $form_vars); $content .= elgg_view('input/urlshortener'); diff --git a/mod/thewire/start.php b/mod/thewire/start.php index c0890344f..328e5d46c 100644 --- a/mod/thewire/start.php +++ b/mod/thewire/start.php @@ -217,7 +217,7 @@ function thewire_filter($text) { // usernames $text = preg_replace( - '/(^|[^\w])@([\w]+)/', + '/(^|[^\w])@([\w.]+)/', '$1<a href="' . $CONFIG->wwwroot . 'thewire/owner/$2">@$2</a>', $text); diff --git a/mod/uservalidationbyemail/lib/functions.php b/mod/uservalidationbyemail/lib/functions.php index eaca374f4..f3091f94d 100644 --- a/mod/uservalidationbyemail/lib/functions.php +++ b/mod/uservalidationbyemail/lib/functions.php @@ -87,7 +87,13 @@ function uservalidationbyemail_get_unvalidated_users_sql_where() { global $CONFIG; $validated_id = get_metastring_id('validated'); - $one_id = get_metastring_id(1); + if ($validated_id === false) { + $validated_id = add_metastring('validated'); + } + $one_id = get_metastring_id('1'); + if ($one_id === false) { + $one_id = add_metastring('1'); + } // thanks to daveb@freenode for the SQL tips! $wheres = array(); diff --git a/mod/uservalidationbyemail/start.php b/mod/uservalidationbyemail/start.php index 8de5d0522..ea59a2e7b 100644 --- a/mod/uservalidationbyemail/start.php +++ b/mod/uservalidationbyemail/start.php @@ -69,6 +69,17 @@ function uservalidationbyemail_disable_new_user($hook, $type, $value, $params) { return; } + // another plugin is requesting that registration be terminated + // no need for uservalidationbyemail + if (!$value) { + return $value; + } + + // has the user already been validated? + if (elgg_get_user_validation_status($user->guid) == true) { + return $value; + } + // disable user to prevent showing up on the site // set context so our canEdit() override works elgg_push_context('uservalidationbyemail_new_user'); diff --git a/pages/river.php b/pages/river.php index 5770084ab..601faf16f 100644 --- a/pages/river.php +++ b/pages/river.php @@ -7,7 +7,6 @@ $options = array(); $page_type = preg_replace('[\W]', '', get_input('page_type', 'all')); $type = preg_replace('[\W]', '', get_input('type', 'all')); -$active_section = $subtype = preg_replace('[\W]', '', get_input('subtype', '')); if ($subtype) { $selector = "type=$type&subtype=$subtype"; diff --git a/version.php b/version.php index 8b9804de6..07e854f8e 100644 --- a/version.php +++ b/version.php @@ -14,4 +14,4 @@ $version = 2011110700; // Human-friendly version name -$release = '1.9-dev'; +$release = '1.9.0-dev'; diff --git a/views/default/admin/plugins.php b/views/default/admin/plugins.php index c3e7e3ab0..b793175e0 100644 --- a/views/default/admin/plugins.php +++ b/views/default/admin/plugins.php @@ -8,6 +8,9 @@ * @subpackage Admin.Plugins */ +elgg_load_js('lightbox'); +elgg_load_css('lightbox'); + elgg_generate_plugin_entities(); $installed_plugins = elgg_get_plugins('any'); $show_category = get_input('category', 'all'); diff --git a/views/default/core/settings/account/name.php b/views/default/core/settings/account/name.php index 69ffcecaf..f719a84de 100644 --- a/views/default/core/settings/account/name.php +++ b/views/default/core/settings/account/name.php @@ -4,12 +4,23 @@ * * @package Elgg * @subpackage Core - - */ $user = elgg_get_page_owner_entity(); - -// all hidden, but necessary for properly updating user details -echo elgg_view('input/hidden', array('name' => 'name', 'value' => $user->name)); +?> +<div class="elgg-module elgg-module-info"> + <div class="elgg-head"> + <h3><?php echo elgg_echo('user:name:label'); ?></h3> + </div> + <div class="elgg-body"> + <p> + <?php echo elgg_echo('name'); ?>: + <?php + echo elgg_view('input/text', array('name' => 'name', 'value' => $user->name)); + ?> + </p> + </div> +</div> +<?php +// need the user's guid to make sure the correct user gets updated echo elgg_view('input/hidden', array('name' => 'guid', 'value' => $user->guid)); diff --git a/views/default/css/admin.php b/views/default/css/admin.php index c02d43512..dc1b503cb 100644 --- a/views/default/css/admin.php +++ b/views/default/css/admin.php @@ -138,6 +138,7 @@ p { visibility: hidden; height: 0 !important; line-height: 0; + overflow: hidden; font-size: xx-large; content: " x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x "; } diff --git a/views/default/css/elements/components.php b/views/default/css/elements/components.php index f675ab7cb..77313fa1a 100644 --- a/views/default/css/elements/components.php +++ b/views/default/css/elements/components.php @@ -7,17 +7,6 @@ * @package Elgg.Core * @subpackage UI */ -/** - * elgg-body fills the space available to it. - * It uses hidden text to expand itself. The combination of auto width, overflow - * hidden, and the hidden text creates this effect. - * - * This allows us to float fixed width divs to either side of an .elgg-body div - * without having to specify the body div's width. - * - * @todo check what happens with long <pre> tags or large images - * @todo Move this to its own file -- it is very complicated and should not have to be overridden. - */ ?> /* *************************************** diff --git a/views/default/css/elements/core.php b/views/default/css/elements/core.php index ace6048bb..74f21ee59 100644 --- a/views/default/css/elements/core.php +++ b/views/default/css/elements/core.php @@ -46,13 +46,28 @@ *overflow:visible; } -<?php //@todo isn't this only needed if we use display:table-cell? ?> +<?php +/** + * elgg-body fills the space available to it. + * It uses hidden text to expand itself. The combination of auto width, overflow + * hidden, and the hidden text creates this effect. + * + * This allows us to float fixed width divs to either side of an .elgg-body div + * without having to specify the body div's width. + * + * @todo check what happens with long <pre> tags or large images + * @todo Move this to its own file -- it is very complicated and should not have to be overridden. + */ + +//@todo isn't this only needed if we use display:table-cell? +?> .elgg-body:after, .elgg-col-last:after { display: block; visibility: hidden; height: 0 !important; line-height: 0; + overflow: hidden; /* Stretch to fill up available space */ font-size: xx-large; diff --git a/views/default/css/elements/forms.php b/views/default/css/elements/forms.php index e358c86e7..81db81747 100644 --- a/views/default/css/elements/forms.php +++ b/views/default/css/elements/forms.php @@ -41,7 +41,7 @@ input, textarea { box-sizing: border-box; } -input:focus, textarea:focus { +input[type=text]:focus, textarea:focus { border: solid 1px #4690d6; background: #e4ecf5; color:#333; diff --git a/views/default/css/elements/layout.php b/views/default/css/elements/layout.php index 42d898439..25a2bffb7 100644 --- a/views/default/css/elements/layout.php +++ b/views/default/css/elements/layout.php @@ -81,6 +81,9 @@ .elgg-layout-two-sidebar { background: transparent url(<?php echo elgg_get_site_url(); ?>_graphics/two_sidebar_background.gif) repeat-y right top; } +.elgg-layout-error { + margin-top: 20px; +} .elgg-sidebar { position: relative; padding: 20px 10px; diff --git a/views/default/css/elements/modules.php b/views/default/css/elements/modules.php index ef85d4dd5..7750c208f 100644 --- a/views/default/css/elements/modules.php +++ b/views/default/css/elements/modules.php @@ -158,16 +158,7 @@ .elgg-module-widget.elgg-state-draggable > .elgg-head { cursor: move; } -.elgg-module-widget > .elgg-head a { - position: absolute; - top: 4px; - display: inline-block; - width: 18px; - height: 18px; - padding: 2px 2px 0 0; -} a.elgg-widget-collapse-button { - left: 5px; color: #c5c5c5; } a.elgg-widget-collapse-button:hover, @@ -181,12 +172,6 @@ a.elgg-widget-collapse-button:before { a.elgg-widget-collapsed:before { content: "\25BA"; } -a.elgg-widget-delete-button { - right: 5px; -} -a.elgg-widget-edit-button { - right: 25px; -} .elgg-module-widget > .elgg-body { background-color: white; width: 100%; diff --git a/views/default/css/elements/navigation.php b/views/default/css/elements/navigation.php index bf1046dda..62f370069 100644 --- a/views/default/css/elements/navigation.php +++ b/views/default/css/elements/navigation.php @@ -130,9 +130,9 @@ } .elgg-menu-topbar > li > a { - padding: 2px 15px 0; + padding-top: 2px; color: #eee; - margin-top: 1px; + margin: 1px 15px 0; } .elgg-menu-topbar > li > a:hover { @@ -372,7 +372,10 @@ position: absolute; z-index: 10000; - width: 165px; + overflow: hidden; + + min-width: 165px; + max-width: 250px; border: solid 1px; border-color: #E5E5E5 #999 #999 #E5E5E5; background-color: #FFF; @@ -531,4 +534,26 @@ *************************************** */ .elgg-menu-extras { margin-bottom: 15px; -}
\ No newline at end of file +} + +/* *************************************** + WIDGET MENU +*************************************** */ +.elgg-menu-widget > li { + position: absolute; + top: 4px; + display: inline-block; + width: 18px; + height: 18px; + padding: 2px 2px 0 0; +} + +.elgg-menu-widget > .elgg-menu-item-collapse { + left: 5px; +} +.elgg-menu-widget > .elgg-menu-item-delete { + right: 5px; +} +.elgg-menu-widget > .elgg-menu-item-settings { + right: 25px; +} diff --git a/views/default/css/elements/typography.php b/views/default/css/elements/typography.php index f080a29b2..d93b28d2c 100644 --- a/views/default/css/elements/typography.php +++ b/views/default/css/elements/typography.php @@ -139,7 +139,7 @@ h6 { font-size: 0.8em; } .elgg-output dt { font-weight: bold } .elgg-output dd { margin: 0 0 1em 1em } -.elgg-output ul, ol { +.elgg-output ul, .elgg-output ol { margin: 0 1.5em 1.5em 0; padding-left: 1.5em; } diff --git a/views/default/errors/404.php b/views/default/errors/404.php new file mode 100644 index 000000000..8bc35acdd --- /dev/null +++ b/views/default/errors/404.php @@ -0,0 +1,8 @@ +<?php +/** + * Page not found error + */ + +$message = elgg_echo('error:404'); + +echo "<h2>$message</h2>"; diff --git a/views/default/errors/default.php b/views/default/errors/default.php new file mode 100644 index 000000000..a0582eba2 --- /dev/null +++ b/views/default/errors/default.php @@ -0,0 +1,8 @@ +<?php +/** + * General error + */ + +$message = elgg_echo('error:default'); + +echo "<h2>$message</h2>"; diff --git a/views/default/forms/admin/site/update_advanced.php b/views/default/forms/admin/site/update_advanced.php index e12764092..5155fc415 100644 --- a/views/default/forms/admin/site/update_advanced.php +++ b/views/default/forms/admin/site/update_advanced.php @@ -91,7 +91,7 @@ $form_body .= "</div>"; $form_body .= elgg_view('input/hidden', array('name' => 'settings', 'value' => 'go')); -$form_body .= '<div class="elgg-divide-top">'; +$form_body .= '<div class="elgg-foot">'; $form_body .= elgg_view('input/submit', array('value' => elgg_echo("save"))); $form_body .= '</div>'; diff --git a/views/default/forms/admin/site/update_basic.php b/views/default/forms/admin/site/update_basic.php index 66722aef2..88870bc60 100644 --- a/views/default/forms/admin/site/update_basic.php +++ b/views/default/forms/admin/site/update_basic.php @@ -24,7 +24,7 @@ $form_body .= elgg_view("input/dropdown", array( 'options_values' => $languages, )) . "</div>"; -$form_body .= '<div class="elgg-divide-top">'; +$form_body .= '<div class="elgg-foot">'; $form_body .= elgg_view('input/submit', array('value' => elgg_echo("save"))); $form_body .= '</div>'; diff --git a/views/default/forms/user/requestnewpassword.php b/views/default/forms/user/requestnewpassword.php index 8a5a18734..c90971eaf 100644 --- a/views/default/forms/user/requestnewpassword.php +++ b/views/default/forms/user/requestnewpassword.php @@ -11,7 +11,7 @@ <?php echo elgg_echo('user:password:text'); ?> </div> <div> - <label><?php echo elgg_echo('username'); ?></label><br /> + <label><?php echo elgg_echo('loginusername'); ?></label><br /> <?php echo elgg_view('input/text', array( 'name' => 'username', 'class' => 'elgg-autofocus', diff --git a/views/default/graphics/ajax_loader.php b/views/default/graphics/ajax_loader.php index 1a9046178..d5ce87ea9 100644 --- a/views/default/graphics/ajax_loader.php +++ b/views/default/graphics/ajax_loader.php @@ -6,6 +6,7 @@ * @subpackage Core * * @uses $vars['id'] CSS id + * @uses $vars['class'] Optional additional CSS class * @uses $vars['hidden'] Begin hidden? (true) */ @@ -13,15 +14,18 @@ if (isset($vars['id'])) { $id = "id=\"{$vars['id']}\""; } +$class = 'elgg-ajax-loader'; +if (isset($vars['class'])) { + $class = "$class {$vars['class']}"; +} + if (elgg_extract('hidden', $vars, true)) { - $hidden = 'hidden'; -} else { - $hidden = ''; + $class = "$class hidden"; } $loader = <<< END -<div class="elgg-ajax-loader $hidden" $id></div> +<div class="$class" $id></div> END; diff --git a/views/default/input/userpicker.php b/views/default/input/userpicker.php index 246c462da..91a397e37 100644 --- a/views/default/input/userpicker.php +++ b/views/default/input/userpicker.php @@ -20,6 +20,7 @@ */ elgg_load_js('elgg.userpicker'); +elgg_load_js('jquery.ui.autocomplete.html'); function user_picker_add_user($user_id) { $user = get_entity($user_id); diff --git a/views/default/js/admin.php b/views/default/js/admin.php index d4dd06822..5cefba512 100644 --- a/views/default/js/admin.php +++ b/views/default/js/admin.php @@ -17,9 +17,6 @@ elgg.admin.init = function () { $(this).stop().slideUp('medium'); }); - // plugin screenshot modal - $('.elgg-plugin-screenshot a').click(elgg.admin.displayPluginScreenshot); - // draggable plugin reordering $('#elgg-plugin-list > ul').sortable({ items: 'li:has(> .elgg-state-draggable)', @@ -74,48 +71,6 @@ elgg.admin.movePlugin = function(e, ui) { }; /** - * Display a plugin screenshot. - * - * @param {Object} e The event object. - * @return void - */ -elgg.admin.displayPluginScreenshot = function(e) { - e.preventDefault(); - var lb = $('.elgg-plugin-screenshot-lightbox'); - - if (lb.length < 1) { - $('body').append('<div class="elgg-plugin-screenshot-lightbox"></div>'); - lb = $('.elgg-plugin-screenshot-lightbox'); - - lb.click(function() { - lb.hide(); - }); - - $(document).click(function(e) { - var target = $(e.target); - if (target.is('a') && target.hasClass('elgg-plugin-screenshot-lightbox')) { - lb.hide(); - e.preventDefault(); - } - }); - } - - var html = '<img class="pas" src="' + $(this).attr('href') + '">'; - var desc = $(this).find('img').attr('alt'); - - if (desc) { - html = '<h2 class="pam">' + desc + '</h2>' + html; - } - - lb.html(html); - - top_pos = $(window).scrollTop() + 10 + 'px'; - left_pos = $(window).scrollLeft() + 5 + 'px'; - - lb.css('top', top_pos).css('left', left_pos).show(); -}; - -/** * In-line editing for custom profile fields * * @param string value The new value diff --git a/views/default/js/lightbox.php b/views/default/js/lightbox.php index 5f3764756..c45d46098 100644 --- a/views/default/js/lightbox.php +++ b/views/default/js/lightbox.php @@ -5,6 +5,10 @@ * Usage * Apply the class elgg-lightbox to links. * + * Advanced Usage + * Elgg is distributed with the Fancybox jQuery library. Please go to + * http://fancybox.net for more information on the options of this lightbox. + * * Overriding * In a plugin, override this view and override the registration for the * lightbox JavaScript and CSS (@see elgg_views_boot()). diff --git a/views/default/navigation/menu/default.php b/views/default/navigation/menu/default.php index 0fa391433..006deb3ea 100644 --- a/views/default/navigation/menu/default.php +++ b/views/default/navigation/menu/default.php @@ -2,15 +2,17 @@ /** * Default menu * - * @uses $vars['name'] - * @uses $vars['menu'] - * @uses $vars['class'] - * @uses $vars['show_section_headers'] + * @uses $vars['name'] Name of the menu + * @uses $vars['menu'] Array of menu items + * @uses $vars['class'] Additional CSS class for the menu + * @uses $vars['item_class'] Additional CSS class for each menu item + * @uses $vars['show_section_headers'] Do we show headers for each section? */ // we want css classes to use dashes $vars['name'] = preg_replace('/[^a-z0-9\-]/i', '-', $vars['name']); $headers = elgg_extract('show_section_headers', $vars, false); +$item_class = elgg_extract('item_class', $vars, ''); $class = "elgg-menu elgg-menu-{$vars['name']}"; if (isset($vars['class'])) { @@ -23,6 +25,7 @@ foreach ($vars['menu'] as $section => $menu_items) { 'class' => "$class elgg-menu-{$vars['name']}-$section", 'section' => $section, 'name' => $vars['name'], - 'show_section_headers' => $headers + 'show_section_headers' => $headers, + 'item_class' => $item_class, )); } diff --git a/views/default/navigation/menu/elements/item.php b/views/default/navigation/menu/elements/item.php index 5d6a7e367..22383ce0b 100644 --- a/views/default/navigation/menu/elements/item.php +++ b/views/default/navigation/menu/elements/item.php @@ -4,6 +4,9 @@ * * @package Elgg.Core * @subpackage Navigation + * + * @uses $vars['item'] ElggMenuItem + * @uses $vars['item_class'] Additional CSS class for the menu item */ $item = $vars['item']; @@ -21,6 +24,9 @@ if ($children) { } $item_class = $item->getItemClass(); +if (isset($vars['item_class']) && $vars['item_class']) { + $item_class .= ' ' . $vars['item_class']; +} echo "<li class=\"$item_class\">"; echo $item->getContent(); diff --git a/views/default/navigation/menu/elements/section.php b/views/default/navigation/menu/elements/section.php index 92a259776..c0e9ba750 100644 --- a/views/default/navigation/menu/elements/section.php +++ b/views/default/navigation/menu/elements/section.php @@ -2,15 +2,17 @@ /** * Menu group * - * @uses $vars['items'] - * @uses $vars['class'] - * @uses $vars['name'] - * @uses $vars['section'] - * @uses $vars['show_section_headers'] + * @uses $vars['items'] Array of menu items + * @uses $vars['class'] Additional CSS class for the section + * @uses $vars['name'] Name of the menu + * @uses $vars['section'] The section name + * @uses $vars['item_class'] Additional CSS class for each menu item + * @uses $vars['show_section_headers'] Do we show headers for each section */ $headers = elgg_extract('show_section_headers', $vars, false); $class = elgg_extract('class', $vars, ''); +$item_class = elgg_extract('item_class', $vars, ''); if ($headers) { $name = elgg_extract('name', $vars); @@ -20,6 +22,9 @@ if ($headers) { echo "<ul class=\"$class\">"; foreach ($vars['items'] as $menu_item) { - echo elgg_view('navigation/menu/elements/item', array('item' => $menu_item)); + echo elgg_view('navigation/menu/elements/item', array( + 'item' => $menu_item, + 'item_class' => $item_class, + )); } echo '</ul>'; diff --git a/views/default/navigation/menu/site.php b/views/default/navigation/menu/site.php index 38b42bda9..24c21dd57 100644 --- a/views/default/navigation/menu/site.php +++ b/views/default/navigation/menu/site.php @@ -6,12 +6,15 @@ * @uses $vars['menu']['more'] */ +$default_items = elgg_extract('default', $vars['menu'], array()); +$more_items = elgg_extract('more', $vars['menu'], array()); + echo '<ul class="elgg-menu elgg-menu-site elgg-menu-site-default clearfix">'; -foreach ($vars['menu']['default'] as $menu_item) { +foreach ($default_items as $menu_item) { echo elgg_view('navigation/menu/elements/item', array('item' => $menu_item)); } -if (isset($vars['menu']['more']) && !empty($vars['menu']['more'])) { +if ($more_items) { echo '<li class="elgg-more">'; $more = elgg_echo('more'); @@ -19,7 +22,7 @@ if (isset($vars['menu']['more']) && !empty($vars['menu']['more'])) { echo elgg_view('navigation/menu/elements/section', array( 'class' => 'elgg-menu elgg-menu-site elgg-menu-site-more', - 'items' => $vars['menu']['more'], + 'items' => $more_items, )); echo '</li>'; diff --git a/views/default/navigation/pagination.php b/views/default/navigation/pagination.php index 4df5cf575..ad4689d83 100644 --- a/views/default/navigation/pagination.php +++ b/views/default/navigation/pagination.php @@ -25,7 +25,12 @@ if (!$limit = (int) elgg_extract('limit', $vars, 10)) { $count = (int) elgg_extract('count', $vars, 0); $offset_key = elgg_extract('offset_key', $vars, 'offset'); -$base_url = elgg_extract('baseurl', $vars, current_page_url()); +// some views pass an empty string for base_url +if (isset($vars['base_url']) && $vars['base_url']) { + $base_url = $vars['base_url']; +} else { + $base_url = current_page_url(); +} $num_pages = elgg_extract('num_pages', $vars, 10); $delta = ceil($num_pages / 2); diff --git a/views/default/object/elements/summary.php b/views/default/object/elements/summary.php index 8d82bc52a..22db03f51 100644 --- a/views/default/object/elements/summary.php +++ b/views/default/object/elements/summary.php @@ -46,7 +46,9 @@ if ($tags !== false) { if ($metadata) { echo $metadata; } -echo "<h3>$title_link</h3>"; +if ($title_link) { + echo "<h3>$title_link</h3>"; +} echo "<div class=\"elgg-subtext\">$subtitle</div>"; echo $tags; diff --git a/views/default/object/plugin/full.php b/views/default/object/plugin/full.php index db4e4dbcc..8955178a6 100644 --- a/views/default/object/plugin/full.php +++ b/views/default/object/plugin/full.php @@ -156,7 +156,7 @@ if ($screenshots) { $screenshot_full = "{$vars['url']}admin_plugin_screenshot/{$plugin->getID()}/full/{$screenshot['path']}"; $screenshot_src = "{$vars['url']}admin_plugin_screenshot/{$plugin->getID()}/thumbnail/{$screenshot['path']}"; - $screenshots_html .= "<li class=\"elgg-plugin-screenshot prm ptm\"><a href=\"$screenshot_full\">" + $screenshots_html .= "<li class=\"elgg-plugin-screenshot prm ptm\"><a class=\"elgg-lightbox\" href=\"$screenshot_full\">" . "<img src=\"$screenshot_src\" alt=\"$alt\"></a></li>"; } } diff --git a/views/default/object/widget/elements/controls.php b/views/default/object/widget/elements/controls.php index 6d06d28bc..d1d630c4f 100644 --- a/views/default/object/widget/elements/controls.php +++ b/views/default/object/widget/elements/controls.php @@ -6,44 +6,11 @@ * @uses $vars['show_edit'] Whether to show the edit button (true) */ -$widget = $vars['widget']; -$show_edit = elgg_extract('show_edit', $vars, true); - -$params = array( - 'text' => ' ', - 'href' => "#elgg-widget-content-$widget->guid", - 'class' => 'elgg-widget-collapse-button', - 'rel' => 'toggle', -); -$collapse_link = elgg_view('output/url', $params); - -$delete_link = $edit_link = ''; -if ($widget->canEdit()) { - $params = array( - 'text' => elgg_view_icon('delete-alt'), - 'title' => elgg_echo('widget:delete', array($widget->getTitle())), - 'href' => "action/widgets/delete?guid=$widget->guid", - 'is_action' => true, - 'is_trusted' => true, - 'class' => 'elgg-widget-delete-button', - 'id' => "elgg-widget-delete-button-$widget->guid" - ); - $delete_link = elgg_view('output/url', $params); - - if ($show_edit) { - $params = array( - 'text' => elgg_view_icon('settings-alt'), - 'title' => elgg_echo('widget:edit'), - 'href' => "#widget-edit-$widget->guid", - 'class' => "elgg-widget-edit-button", - 'rel' => 'toggle', - ); - $edit_link = elgg_view('output/url', $params); - } -} - -echo <<<___END - $collapse_link - $delete_link - $edit_link -___END; +echo elgg_view_menu('widget', array( + 'entity' => elgg_extract('widget', $vars), + 'params' => array( + 'show_edit' => elgg_extract('show_edit', $vars, true) + ), + 'sort_by' => 'priority', + 'class' => 'elgg-menu-hz', +)); diff --git a/views/default/page/admin.php b/views/default/page/admin.php index cd03541d5..7045edd91 100644 --- a/views/default/page/admin.php +++ b/views/default/page/admin.php @@ -5,16 +5,11 @@ * @package Elgg * @subpackage Core * - * @uses $vars['title'] The page title - * @uses $vars['body'] The main content of the page + * @uses $vars['title'] The page title + * @uses $vars['body'] The main content of the page * @uses $vars['sysmessages'] A 2d array of various message registers, passed from system_messages() */ -// Set the content type -header("Content-type: text/html; charset=UTF-8"); - -$messages = $vars['sysmessages']; - $notices_html = ''; $notices = elgg_get_admin_notices(); if ($notices) { @@ -25,6 +20,16 @@ if ($notices) { $notices_html = "<div class=\"elgg-admin-notices\">$notices_html</div>"; } +// render content before head so that JavaScript and CSS can be loaded. See #4032 +$messages = elgg_view('page/elements/messages', array('object' => $vars['sysmessages'])); +$header = elgg_view('admin/header', $vars); +$body = $vars['body']; +$footer = elgg_view('admin/footer', $vars); + + +// Set the content type +header("Content-type: text/html; charset=UTF-8"); + ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> @@ -36,21 +41,21 @@ if ($notices) { <div class="elgg-inner"> <div class="elgg-page-header"> <div class="elgg-inner clearfix"> - <?php echo elgg_view('admin/header'); ?> + <?php echo $header; ?> </div> </div> <div class="elgg-page-messages"> - <?php echo elgg_view('page/elements/messages', array('object' => $messages)); ?> + <?php echo $messages; ?> <?php echo $notices_html; ?> </div> <div class="elgg-page-body"> <div class="elgg-inner"> - <?php echo $vars['body']; ?> + <?php echo $body; ?> </div> </div> <div class="elgg-page-footer"> <div class="elgg-inner"> - <?php echo elgg_view('admin/footer'); ?> + <?php echo $footer; ?> </div> </div> </div> diff --git a/views/default/page/components/gallery.php b/views/default/page/components/gallery.php index 149ceeaf8..e8b3f477e 100644 --- a/views/default/page/components/gallery.php +++ b/views/default/page/components/gallery.php @@ -16,7 +16,7 @@ */ $items = $vars['items']; -if (!is_array($items) && sizeof($items) == 0) { +if (!is_array($items) || sizeof($items) == 0) { return true; } diff --git a/views/default/page/default.php b/views/default/page/default.php index 0e27cda52..892069fad 100644 --- a/views/default/page/default.php +++ b/views/default/page/default.php @@ -6,8 +6,8 @@ * @package Elgg * @subpackage Core * - * @uses $vars['title'] The page title - * @uses $vars['body'] The main content of the page + * @uses $vars['title'] The page title + * @uses $vars['body'] The main content of the page * @uses $vars['sysmessages'] A 2d array of various message registers, passed from system_messages() */ @@ -21,6 +21,13 @@ if (elgg_get_context() == 'admin') { return true; } +// render content before head so that JavaScript and CSS can be loaded. See #4032 +$topbar = elgg_view('page/elements/topbar', $vars); +$messages = elgg_view('page/elements/messages', array('object' => $vars['sysmessages'])); +$header = elgg_view('page/elements/header', $vars); +$body = elgg_view('page/elements/body', $vars); +$footer = elgg_view('page/elements/footer', $vars); + // Set the content type header("Content-type: text/html; charset=UTF-8"); @@ -33,30 +40,30 @@ header("Content-type: text/html; charset=UTF-8"); <body> <div class="elgg-page elgg-page-default"> <div class="elgg-page-messages"> - <?php echo elgg_view('page/elements/messages', array('object' => $vars['sysmessages'])); ?> + <?php echo $messages; ?> </div> <?php if (elgg_is_logged_in()): ?> <div class="elgg-page-topbar"> <div class="elgg-inner"> - <?php echo elgg_view('page/elements/topbar', $vars); ?> + <?php echo $topbar; ?> </div> </div> <?php endif; ?> <div class="elgg-page-header"> <div class="elgg-inner"> - <?php echo elgg_view('page/elements/header', $vars); ?> + <?php echo $header; ?> </div> </div> <div class="elgg-page-body"> <div class="elgg-inner"> - <?php echo elgg_view('page/elements/body', $vars); ?> + <?php echo $body; ?> </div> </div> <div class="elgg-page-footer"> <div class="elgg-inner"> - <?php echo elgg_view('page/elements/footer', $vars); ?> + <?php echo $footer; ?> </div> </div> </div> diff --git a/views/default/page/error.php b/views/default/page/error.php new file mode 100644 index 000000000..b7ba3ae9b --- /dev/null +++ b/views/default/page/error.php @@ -0,0 +1,14 @@ +<?php +/** + * Page shell for errors + * + * This is for errors that are not unhandled exceptions. Those are handled + * through the failsafe viewtype to guarantee that no further exceptions occur. + * An example error would be 404 (page not found). + * + * @uses $vars['title'] The page title + * @uses $vars['body'] The main content of the page + * @uses $vars['sysmessages'] A 2d array of various message registers, passed from system_messages() + */ + +echo elgg_view('page/default', $vars); diff --git a/views/default/page/layouts/error.php b/views/default/page/layouts/error.php new file mode 100644 index 000000000..cdce28a8e --- /dev/null +++ b/views/default/page/layouts/error.php @@ -0,0 +1,12 @@ +<?php +/** + * Error layout + */ + +$class = 'elgg-layout-error'; +if (isset($vars['class'])) { + $class = "$class {$vars['class']}"; +} +$vars['class'] = $class; + +echo elgg_view('page/layouts/one_column', $vars); diff --git a/views/default/widgets/control_panel/content.php b/views/default/widgets/control_panel/content.php new file mode 100644 index 000000000..d2db54bc6 --- /dev/null +++ b/views/default/widgets/control_panel/content.php @@ -0,0 +1,24 @@ +<?php +/** + * Admin control panel widget + */ + +elgg_register_menu_item('admin_control_panel', array( + 'name' => 'flush', + 'text' => elgg_echo('admin:cache:flush'), + 'href' => 'action/admin/site/flush_cache', + 'is_action' => true, + 'link_class' => 'elgg-button elgg-button-action', +)); + +elgg_register_menu_item('admin_control_panel', array( + 'name' => 'upgrade', + 'text' => elgg_echo('upgrade'), + 'href' => 'upgrade.php', + 'link_class' => 'elgg-button elgg-button-action', +)); + +echo elgg_view_menu('admin_control_panel', array( + 'class' => 'elgg-menu-hz', + 'item_class' => 'mrm', +)); diff --git a/views/rss/page/components/gallery.php b/views/rss/page/components/gallery.php new file mode 100644 index 000000000..690416e5b --- /dev/null +++ b/views/rss/page/components/gallery.php @@ -0,0 +1,8 @@ +<?php +/* + * RSS gallery view + * + * @uses $vars['items'] + */ + +echo elgg_view('page/components/list', $vars); diff --git a/views/xml/xml-rpc/output.php b/views/xml/xml-rpc/output.php deleted file mode 100644 index 4276029d1..000000000 --- a/views/xml/xml-rpc/output.php +++ /dev/null @@ -1,11 +0,0 @@ -<?php -/** - * Elgg XML output for XML-RPC - * - * @package Elgg - * @subpackage Core - */ - -$result = $vars['result']; - -echo "$result";
\ No newline at end of file |