From 82593cd2bc056da73caa1b1e981c5a9ead0f1bf2 Mon Sep 17 00:00:00 2001 From: brettp Date: Wed, 27 Apr 2011 02:37:16 +0000 Subject: Refs #3362. Plugins don't check deps upon boot. Made package and manifest private properties of ElggPlugin and added ->getPackage() and ->getManifest(). git-svn-id: http://code.elgg.org/elgg/trunk@9030 36083f99-b078-4883-b0ff-0f9b5a30f544 --- engine/lib/admin.php | 4 ++-- engine/lib/deprecated-1.8.php | 2 +- engine/lib/plugins.php | 39 +++++++-------------------------------- 3 files changed, 10 insertions(+), 35 deletions(-) (limited to 'engine/lib') diff --git a/engine/lib/admin.php b/engine/lib/admin.php index 06418c44f..61f64c8b3 100644 --- a/engine/lib/admin.php +++ b/engine/lib/admin.php @@ -329,7 +329,7 @@ function elgg_admin_add_plugin_settings_menu() { elgg_register_menu_item('page', array( 'name' => $plugin_id, 'href' => "admin/plugin_settings/$plugin_id", - 'text' => $plugin->manifest->getName(), + 'text' => $plugin->getManifest()->getName(), 'parent_name' => 'settings', 'context' => 'admin', 'section' => 'configure', @@ -541,7 +541,7 @@ function admin_markdown_page_handler($pages) { return true; } - $title = $plugin->manifest->getName() . ": $filename"; + $title = $plugin->getManifest()->getName() . ": $filename"; $text = Markdown($file_contents); $body = elgg_view_layout('admin', array( diff --git a/engine/lib/deprecated-1.8.php b/engine/lib/deprecated-1.8.php index bb52881cd..595b12aea 100644 --- a/engine/lib/deprecated-1.8.php +++ b/engine/lib/deprecated-1.8.php @@ -1667,7 +1667,7 @@ function get_installed_plugins($status = 'all') { if ($include) { $installed_plugins[$plugin->getID()] = array( 'active' => $plugin->isActive(), - 'manifest' => $plugin->manifest->getManifest() + 'manifest' => $plugin->getManifest()->getManifest() ); } } diff --git a/engine/lib/plugins.php b/engine/lib/plugins.php index 0947b7a8e..5aed3065a 100644 --- a/engine/lib/plugins.php +++ b/engine/lib/plugins.php @@ -266,9 +266,9 @@ function elgg_is_active_plugin($plugin_id, $site_guid = null) { /** * Loads all active plugins in the order specified in the tool admin panel. * - * @note This is called on every page load and includes additional checking that plugins - * are fit to be loaded. If a plugin is active and problematic, it will be disabled - * and a visible error emitted. + * @note This is called on every page load. If a plugin is active and problematic, it + * will be disabled and a visible error emitted. This does not check the deps system because + * that was too slow. * * @return bool */ @@ -307,17 +307,6 @@ function elgg_load_plugins() { $plugins = elgg_get_plugins('active'); if ($plugins) { foreach ($plugins as $plugin) { - // check if plugin can be started and try to start it. - // if anything is bad, disable it and emit a message. - if (!$plugin->isValid()) { - $plugin->deactivate(); - $msg = elgg_echo('PluginException:MisconfiguredPlugin', array($plugin->getID(), $plugin->guid)); - register_error($msg); - $return = false; - - continue; - } - try { $plugin->start($start_flags); } catch (Exception $e) { @@ -345,11 +334,10 @@ function elgg_load_plugins() { * Returns an ordered list of plugins * * @param string $status The status of the plugins. active, inactive, or all. - * @param bool $include_bad Include physically deleted and invalid plugins? * @param mixed $site_guid Optional site guid * @return array */ -function elgg_get_plugins($status = 'active', $include_bad = false, $site_guid = NULL) { +function elgg_get_plugins($status = 'active', $site_guid = null) { $db_prefix = get_config('dbprefix'); $priority = elgg_namespace_plugin_private_setting('internal', 'priority'); @@ -388,22 +376,9 @@ function elgg_get_plugins($status = 'active', $include_bad = false, $site_guid = break; } - if ($include_bad) { - $old_ia = elgg_set_ignore_access(true); - } - + $old_ia = elgg_set_ignore_access(true); $plugins = elgg_get_entities_from_relationship($options); - - if ($include_bad) { - elgg_set_ignore_access($old_ia); - } else { - // remove bad plugins - foreach ($plugins as $i => $plugin) { - if (!$plugin->isValid()) { - unset ($plugins[$i]); - } - } - } + elgg_set_ignore_access($old_ia); return $plugins; } @@ -573,7 +548,7 @@ function elgg_get_plugins_provides($type = null, $name = null) { $provides = array(); foreach ($active_plugins as $plugin) { - if ($plugin_provides = $plugin->manifest->getProvides()) { + if ($plugin_provides = $plugin->getManifest()->getProvides()) { foreach ($plugin_provides as $provided) { $provides[$provided['type']][$provided['name']] = array( 'version' => $provided['version'], -- cgit v1.2.3 From 9672142684f84dd26f2520f8f33979e1c638041e Mon Sep 17 00:00:00 2001 From: brettp Date: Wed, 27 Apr 2011 03:02:43 +0000 Subject: Refs #3362. Removed use of $show_bad in elgg_get_plugins(). git-svn-id: http://code.elgg.org/elgg/trunk@9031 36083f99-b078-4883-b0ff-0f9b5a30f544 --- engine/lib/plugins.php | 3 ++- views/default/admin/plugins/advanced.php | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) (limited to 'engine/lib') diff --git a/engine/lib/plugins.php b/engine/lib/plugins.php index 5aed3065a..31b69ce3d 100644 --- a/engine/lib/plugins.php +++ b/engine/lib/plugins.php @@ -380,6 +380,7 @@ function elgg_get_plugins($status = 'active', $site_guid = null) { $plugins = elgg_get_entities_from_relationship($options); elgg_set_ignore_access($old_ia); + $cache[$cache_hash] = $plugins; return $plugins; } @@ -397,7 +398,7 @@ function elgg_get_plugins($status = 'active', $site_guid = null) { function elgg_set_plugin_priorities(array $order) { $name = elgg_namespace_plugin_private_setting('internal', 'priority'); - $plugins = elgg_get_plugins('any', true); + $plugins = elgg_get_plugins('any'); if (!$plugins) { return false; } diff --git a/views/default/admin/plugins/advanced.php b/views/default/admin/plugins/advanced.php index 550154fcd..ea72bab5a 100644 --- a/views/default/admin/plugins/advanced.php +++ b/views/default/admin/plugins/advanced.php @@ -9,7 +9,7 @@ */ elgg_generate_plugin_entities(); -$installed_plugins = elgg_get_plugins('any', true); +$installed_plugins = elgg_get_plugins('any'); $show_category = get_input('category', null); // Get a list of the all categories -- cgit v1.2.3 From 312cab981f0b8dc8bb7e03d19460884b8d673aff Mon Sep 17 00:00:00 2001 From: brettp Date: Wed, 27 Apr 2011 19:39:54 +0000 Subject: Removed stray test code. git-svn-id: http://code.elgg.org/elgg/trunk@9032 36083f99-b078-4883-b0ff-0f9b5a30f544 --- engine/lib/plugins.php | 1 - 1 file changed, 1 deletion(-) (limited to 'engine/lib') diff --git a/engine/lib/plugins.php b/engine/lib/plugins.php index 31b69ce3d..88217b782 100644 --- a/engine/lib/plugins.php +++ b/engine/lib/plugins.php @@ -380,7 +380,6 @@ function elgg_get_plugins($status = 'active', $site_guid = null) { $plugins = elgg_get_entities_from_relationship($options); elgg_set_ignore_access($old_ia); - $cache[$cache_hash] = $plugins; return $plugins; } -- cgit v1.2.3 From 51ac43e54bd9430602e9e754a9d615a8947f4df5 Mon Sep 17 00:00:00 2001 From: brettp Date: Wed, 27 Apr 2011 21:21:36 +0000 Subject: Fixed possible WSOD for plugin text file page handler. git-svn-id: http://code.elgg.org/elgg/trunk@9037 36083f99-b078-4883-b0ff-0f9b5a30f544 --- engine/lib/admin.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'engine/lib') diff --git a/engine/lib/admin.php b/engine/lib/admin.php index 61f64c8b3..5528a29cc 100644 --- a/engine/lib/admin.php +++ b/engine/lib/admin.php @@ -516,9 +516,11 @@ function admin_markdown_page_handler($pages) { $filename = elgg_extract(1, $pages); $error = false; - if (!$plugin) { $error = elgg_echo('admin:plugins:markdown:unknown_plugin'); + $body = elgg_view_layout('admin', array('content' => $error, 'title' => $error)); + echo elgg_view_page($title, $body, 'admin'); + return true; } $text_files = $plugin->getAvailableTextFiles(); @@ -545,7 +547,9 @@ function admin_markdown_page_handler($pages) { $text = Markdown($file_contents); $body = elgg_view_layout('admin', array( - 'content' => $text, + // setting classes here because there's no way to pass classes + // to the layout + 'content' => '
' . $text . '
', 'title' => $title )); -- cgit v1.2.3 From 99b44ae2a37208819dbca47db4356601240fbfd0 Mon Sep 17 00:00:00 2001 From: brettp Date: Thu, 28 Apr 2011 02:02:26 +0000 Subject: Fixes #3127. Normalizing the json returned by the ajax action handler. Doing this in PHP. git-svn-id: http://code.elgg.org/elgg/trunk@9039 36083f99-b078-4883-b0ff-0f9b5a30f544 --- engine/lib/actions.php | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) (limited to 'engine/lib') diff --git a/engine/lib/actions.php b/engine/lib/actions.php index 47e4dd4a4..df7c92de4 100644 --- a/engine/lib/actions.php +++ b/engine/lib/actions.php @@ -411,6 +411,16 @@ function elgg_is_xhr() { */ function ajax_forward_hook($hook, $type, $reason, $params) { if (elgg_is_xhr()) { + // always pass the full structure to avoid boilerplate JS code. + $params = array( + 'output' => '', + 'status' => 0, + 'system_messages' => array( + 'error' => array(), + 'success' => array() + ) + ); + //grab any data echo'd in the action $output = ob_get_clean(); @@ -423,9 +433,14 @@ function ajax_forward_hook($hook, $type, $reason, $params) { } //Grab any system messages so we can inject them via ajax too - $params['system_messages'] = system_messages(NULL, ""); + $system_messages = system_messages(NULL, ""); + + if (isset($system_messages['success'])) { + $params['system_messages']['success'] = $system_messages['success']; + } - if (isset($params['system_messages']['error'])) { + if (isset($system_messages['error'])) { + $params['system_messages']['error'] = $system_messages['error']; $params['status'] = -1; } else { $params['status'] = 0; -- cgit v1.2.3 From 4cfe2dea1cd8e15db2500163bd62476d8cd9bc42 Mon Sep 17 00:00:00 2001 From: brettp Date: Thu, 28 Apr 2011 02:03:46 +0000 Subject: Removed unneeded else. git-svn-id: http://code.elgg.org/elgg/trunk@9040 36083f99-b078-4883-b0ff-0f9b5a30f544 --- engine/lib/actions.php | 2 -- 1 file changed, 2 deletions(-) (limited to 'engine/lib') diff --git a/engine/lib/actions.php b/engine/lib/actions.php index df7c92de4..75f2572cf 100644 --- a/engine/lib/actions.php +++ b/engine/lib/actions.php @@ -442,8 +442,6 @@ function ajax_forward_hook($hook, $type, $reason, $params) { if (isset($system_messages['error'])) { $params['system_messages']['error'] = $system_messages['error']; $params['status'] = -1; - } else { - $params['status'] = 0; } header("Content-type: application/json"); -- cgit v1.2.3 From db3176d97ac0d9cb725c2c42e08f1b0399047be9 Mon Sep 17 00:00:00 2001 From: brettp Date: Fri, 6 May 2011 18:22:52 +0000 Subject: Fixed wrapper for annotation calculations. git-svn-id: http://code.elgg.org/elgg/trunk@9056 36083f99-b078-4883-b0ff-0f9b5a30f544 --- engine/lib/deprecated-1.8.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'engine/lib') diff --git a/engine/lib/deprecated-1.8.php b/engine/lib/deprecated-1.8.php index 595b12aea..44cbb1aaa 100644 --- a/engine/lib/deprecated-1.8.php +++ b/engine/lib/deprecated-1.8.php @@ -115,7 +115,7 @@ function get_entities_from_annotations_calculate_x($sum = "sum", $entity_type = $options['limit'] = $limit; $options['offset'] = $offset; - $options['order_by'] = "calculation $orderdir"; + $options['order_by'] = "annotation_calculation $orderdir"; $options['count'] = $count; @@ -179,7 +179,7 @@ function get_entities_from_annotation_count($entity_type = "", $entity_subtype = $options['limit'] = $limit; $options['offset'] = $offset; - $options['order_by'] = "calculation $orderdir"; + $options['order_by'] = "annotation_calculation $orderdir"; $options['count'] = $count; @@ -241,7 +241,7 @@ function list_entities_from_annotation_count($entity_type = "", $entity_subtype $options['limit'] = $limit; - $options['order_by'] = "calculation $orderdir"; + $options['order_by'] = "annotation_calculation $orderdir"; return elgg_get_entities_from_annotation_calculation($options); } @@ -3504,7 +3504,7 @@ $asc = false, $fullview = true, $listtypetoggle = false, $pagination = true, $or $options['limit'] = $limit; - $options['order_by'] = "calculation $orderdir"; + $options['order_by'] = "annotation_calculation $orderdir"; return elgg_get_entities_from_annotation_calculation($options); } @@ -4470,4 +4470,4 @@ function elgg_count_comments($entity) { } return 0; -} \ No newline at end of file +} -- cgit v1.2.3 From 9f9ba5906cad16f0ab5e3be362253b8fc6ba7128 Mon Sep 17 00:00:00 2001 From: cash Date: Sat, 14 May 2011 14:09:23 +0000 Subject: made database query logging explicitly set to NOTICE level git-svn-id: http://code.elgg.org/elgg/trunk@9066 36083f99-b078-4883-b0ff-0f9b5a30f544 --- engine/lib/database.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'engine/lib') diff --git a/engine/lib/database.php b/engine/lib/database.php index 6b1b494b9..a20fd1ea4 100644 --- a/engine/lib/database.php +++ b/engine/lib/database.php @@ -386,7 +386,7 @@ function elgg_query_runner($query, $callback = null, $single = false) { $cached_query = $DB_QUERY_CACHE[$hash]; if ($cached_query !== FALSE) { - elgg_log("$query results returned from cache (hash: $hash)"); + elgg_log("$query results returned from cache (hash: $hash)", 'NOTICE'); return $cached_query; } } @@ -415,13 +415,13 @@ function elgg_query_runner($query, $callback = null, $single = false) { } if (empty($return)) { - elgg_log("DB query \"$query\" returned no results."); + elgg_log("DB query \"$query\" returned no results.", 'NOTICE'); } // Cache result if ($DB_QUERY_CACHE) { $DB_QUERY_CACHE[$hash] = $return; - elgg_log("$query results cached (hash: $hash)"); + elgg_log("$query results cached (hash: $hash)", 'NOTICE'); } return $return; @@ -447,7 +447,7 @@ function insert_data($query) { $DB_QUERY_CACHE->clear(); } - elgg_log("Query cache invalidated"); + elgg_log("Query cache invalidated", 'NOTICE'); if (execute_query("$query", $dblink)) { return mysql_insert_id($dblink); @@ -473,7 +473,7 @@ function update_data($query) { // Invalidate query cache if ($DB_QUERY_CACHE) { $DB_QUERY_CACHE->clear(); - elgg_log("Query cache invalidated"); + elgg_log("Query cache invalidated", 'NOTICE'); } if (execute_query("$query", $dblink)) { @@ -500,7 +500,7 @@ function delete_data($query) { // Invalidate query cache if ($DB_QUERY_CACHE) { $DB_QUERY_CACHE->clear(); - elgg_log("Query cache invalidated"); + elgg_log("Query cache invalidated", 'NOTICE'); } if (execute_query("$query", $dblink)) { -- cgit v1.2.3 From 9081d693e7791b300f85d383fc66283e4b0348f1 Mon Sep 17 00:00:00 2001 From: cash Date: Sat, 14 May 2011 14:46:49 +0000 Subject: Refs #2591 we were not logging inserts, updates, and deletes. Also logging was happening before formatting of the queries. All fixed in this commit. git-svn-id: http://code.elgg.org/elgg/trunk@9067 36083f99-b078-4883-b0ff-0f9b5a30f544 --- engine/lib/database.php | 32 ++++++++++++++++++++++++++------ 1 file changed, 26 insertions(+), 6 deletions(-) (limited to 'engine/lib') diff --git a/engine/lib/database.php b/engine/lib/database.php index a20fd1ea4..7747eb0d5 100644 --- a/engine/lib/database.php +++ b/engine/lib/database.php @@ -250,8 +250,6 @@ function explain_query($query, $link) { function execute_query($query, $dblink) { global $CONFIG, $dbcalls; - // remove newlines so logs are easier to read - $query = preg_replace("/[\r\n]/", "", $query); if ($query == NULL) { throw new DatabaseException(elgg_echo('DatabaseException:InvalidQuery')); } @@ -362,7 +360,7 @@ function get_data_row($query, $callback = "") { /** * Handles returning data from a query, running it through a callback function, - * and caching the results. + * and caching the results. This is for R queries (from CRUD). * * @access private * @@ -377,6 +375,8 @@ function get_data_row($query, $callback = "") { function elgg_query_runner($query, $callback = null, $single = false) { global $CONFIG, $DB_QUERY_CACHE; + $query = elgg_format_query($query); + // since we want to cache results of running the callback, we need to // need to namespace the query with the callback, and single result request. $hash = (string)$callback . (string)$single . $query; @@ -386,7 +386,7 @@ function elgg_query_runner($query, $callback = null, $single = false) { $cached_query = $DB_QUERY_CACHE[$hash]; if ($cached_query !== FALSE) { - elgg_log("$query results returned from cache (hash: $hash)", 'NOTICE'); + elgg_log("DB query $query results returned from cache (hash: $hash)", 'NOTICE'); return $cached_query; } } @@ -415,13 +415,13 @@ function elgg_query_runner($query, $callback = null, $single = false) { } if (empty($return)) { - elgg_log("DB query \"$query\" returned no results.", 'NOTICE'); + elgg_log("DB query $query returned no results.", 'NOTICE'); } // Cache result if ($DB_QUERY_CACHE) { $DB_QUERY_CACHE[$hash] = $return; - elgg_log("$query results cached (hash: $hash)", 'NOTICE'); + elgg_log("DB query $query results cached (hash: $hash)", 'NOTICE'); } return $return; @@ -440,6 +440,9 @@ function elgg_query_runner($query, $callback = null, $single = false) { function insert_data($query) { global $CONFIG, $DB_QUERY_CACHE; + $query = elgg_format_query($query); + elgg_log("DB query $query", 'NOTICE'); + $dblink = get_db_link('write'); // Invalidate query cache @@ -468,6 +471,9 @@ function insert_data($query) { function update_data($query) { global $CONFIG, $DB_QUERY_CACHE; + $query = elgg_format_query($query); + elgg_log("DB query $query", 'NOTICE'); + $dblink = get_db_link('write'); // Invalidate query cache @@ -495,6 +501,9 @@ function update_data($query) { function delete_data($query) { global $CONFIG, $DB_QUERY_CACHE; + $query = elgg_format_query($query); + elgg_log("DB query $query", 'NOTICE'); + $dblink = get_db_link('write'); // Invalidate query cache @@ -634,6 +643,17 @@ function run_sql_script($scriptlocation) { } } +/** + * Format a query string for logging + * + * @param string $query Query string + * @return string + */ +function elgg_format_query($query) { + // remove newlines and extra spaces so logs are easier to read + return preg_replace('/\s\s+/', ' ', $query); +} + /** * Sanitise a string for database use, but with the option of escaping extra characters. * -- cgit v1.2.3 From f69f31efe44272df0c43985860c502ff3eedbd38 Mon Sep 17 00:00:00 2001 From: cash Date: Sat, 14 May 2011 18:25:22 +0000 Subject: improved documentation of elgg_register_extender_url_handler() git-svn-id: http://code.elgg.org/elgg/trunk@9072 36083f99-b078-4883-b0ff-0f9b5a30f544 --- engine/lib/extender.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'engine/lib') diff --git a/engine/lib/extender.php b/engine/lib/extender.php index a017c9eec..ab04ea674 100644 --- a/engine/lib/extender.php +++ b/engine/lib/extender.php @@ -161,13 +161,13 @@ function can_edit_extender($extender_id, $type, $user_guid = 0) { /** * Sets the URL handler for a particular extender type and name. * It is recommended that you do not call this directly, instead use - * one of the wrapper functions in the subtype files. + * one of the wrapper functions such as elgg_register_annotation_url_handler(). * * @param string $function_name The function to register - * @param string $extender_type Extender type + * @param string $extender_type Extender type ('annotation', 'metadata') * @param string $extender_name The name of the extender * - * @return true|false Depending on success + * @return bool */ function elgg_register_extender_url_handler($extender_type, $extender_name, $function_name) { -- cgit v1.2.3 From 7b4a496f05fe94ab2ff8a420158e1c79cb4d61d4 Mon Sep 17 00:00:00 2001 From: cash Date: Sat, 14 May 2011 18:46:50 +0000 Subject: improved documentation of elgg_register_action() git-svn-id: http://code.elgg.org/elgg/trunk@9074 36083f99-b078-4883-b0ff-0f9b5a30f544 --- engine/lib/actions.php | 1 + 1 file changed, 1 insertion(+) (limited to 'engine/lib') diff --git a/engine/lib/actions.php b/engine/lib/actions.php index 75f2572cf..ff598916f 100644 --- a/engine/lib/actions.php +++ b/engine/lib/actions.php @@ -152,6 +152,7 @@ function action($action, $forwarder = "") { * @param string $filename Optionally, the filename where this action is located. If not specified, * will assume the action is in elgg/actions/.php * @param string $access Who is allowed to execute this action: admin, public, or logged_in. + * (default: logged_in) * * @see action() * @see http://docs.elgg.org/Actions -- cgit v1.2.3 From e583b52a4d5b6d4c217c2d06f8e38fa3f8fbf5c8 Mon Sep 17 00:00:00 2001 From: cash Date: Sat, 14 May 2011 19:16:52 +0000 Subject: removed a deprecated function use in users lib git-svn-id: http://code.elgg.org/elgg/trunk@9077 36083f99-b078-4883-b0ff-0f9b5a30f544 --- engine/lib/users.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engine/lib') diff --git a/engine/lib/users.php b/engine/lib/users.php index dcec36ba5..c16ae1176 100644 --- a/engine/lib/users.php +++ b/engine/lib/users.php @@ -1074,7 +1074,7 @@ function collections_submenu_items() { */ function friends_page_handler($page_elements) { if (isset($page_elements[0]) && $user = get_user_by_username($page_elements[0])) { - set_page_owner($user->getGUID()); + elgg_set_page_owner_guid($user->getGUID()); } if (elgg_get_logged_in_user_guid() == elgg_get_page_owner_guid()) { collections_submenu_items(); -- cgit v1.2.3 From 4e7fd503716d878ce2012d06c2b82aa35a988169 Mon Sep 17 00:00:00 2001 From: cash Date: Sat, 14 May 2011 20:00:43 +0000 Subject: not using deprecated get_annotation/get_metadata functions in can_edit_extender() git-svn-id: http://code.elgg.org/elgg/trunk@9081 36083f99-b078-4883-b0ff-0f9b5a30f544 --- engine/lib/extender.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engine/lib') diff --git a/engine/lib/extender.php b/engine/lib/extender.php index ab04ea674..50b05579b 100644 --- a/engine/lib/extender.php +++ b/engine/lib/extender.php @@ -132,7 +132,7 @@ function can_edit_extender($extender_id, $type, $user_guid = 0) { $user = elgg_get_logged_in_user_entity(); } - $functionname = "get_{$type}"; + $functionname = "elgg_get_{$type}_from_id"; if (is_callable($functionname)) { $extender = $functionname($extender_id); } else { -- cgit v1.2.3 From ff1edc8a348780dcde12e656304309a2bd89755c Mon Sep 17 00:00:00 2001 From: cash Date: Sat, 14 May 2011 20:31:29 +0000 Subject: Fixes #3456 user/default now works much like the object/ views regarding the menu git-svn-id: http://code.elgg.org/elgg/trunk@9082 36083f99-b078-4883-b0ff-0f9b5a30f544 --- engine/lib/users.php | 37 +++++++++++++++++++++++++++++++++++++ views/default/user/default.php | 31 ++++++++++++++++--------------- 2 files changed, 53 insertions(+), 15 deletions(-) (limited to 'engine/lib') diff --git a/engine/lib/users.php b/engine/lib/users.php index c16ae1176..43b6980b2 100644 --- a/engine/lib/users.php +++ b/engine/lib/users.php @@ -1309,6 +1309,41 @@ function elgg_user_hover_menu($hook, $type, $return, $params) { return $return; } +function elgg_users_setup_entity_menu($hook, $type, $return, $params) { + if (elgg_in_context('widgets')) { + return $return; + } + + $entity = $params['entity']; + if (!elgg_instanceof($entity, 'user')) { + return $return; + } + + if ($entity->isBanned()) { + $banned = elgg_echo('banned'); + $options = array( + 'name' => 'banned', + 'text' => "$banned", + 'href' => false, + 'priority' => 0, + ); + $return = array(ElggMenuItem::factory($options)); + } else { + $return = array(); + if (isset($entity->location)) { + $options = array( + 'name' => 'location', + 'text' => "$entity->location", + 'href' => false, + 'priority' => 150, + ); + $return[] = ElggMenuItem::factory($options); + } + } + + return $return; +} + /** * This function loads a set of default fields into the profile, then triggers a hook letting other plugins to edit * add and delete fields. @@ -1529,6 +1564,8 @@ function users_init() { // Register the user type elgg_register_entity_type('user', ''); + elgg_register_plugin_hook_handler('register', 'menu:entity', 'elgg_users_setup_entity_menu', 501); + elgg_register_event_handler('create', 'user', 'user_create_hook_add_site_relationship'); } diff --git a/views/default/user/default.php b/views/default/user/default.php index 71eb273f0..501949306 100644 --- a/views/default/user/default.php +++ b/views/default/user/default.php @@ -6,25 +6,26 @@ * @uses $vars['size'] Size of the icon */ -$user = $vars['entity']; +$entity = $vars['entity']; $size = elgg_extract('size', $vars, 'tiny'); -$icon = elgg_view_entity_icon($user, $size); +$icon = elgg_view_entity_icon($entity, $size); // Simple XFN $rel = ''; -if (elgg_get_logged_in_user_guid() == $user->guid) { +if (elgg_get_logged_in_user_guid() == $entity->guid) { $rel = 'rel="me"'; -} elseif (check_entity_relationship(elgg_get_logged_in_user_guid(), 'friend', $user->guid)) { +} elseif (check_entity_relationship(elgg_get_logged_in_user_guid(), 'friend', $entity->guid)) { $rel = 'rel="friend"'; } -$title = "getUrl() . "\" $rel>" . $user->name . ""; +$title = "getUrl() . "\" $rel>" . $entity->name . ""; - -$metadata = "
  • $user->location
  • "; -$metadata .= elgg_view("entity/metadata", array('entity' => $user)); -$metadata .= "
"; +$metadata = elgg_view_menu('entity', array( + 'entity' => $entity, + 'sort_by' => 'priority', + 'class' => 'elgg-menu-hz', +)); if (elgg_in_context('owner_block') || elgg_in_context('widgets')) { $metadata = ''; @@ -33,20 +34,20 @@ if (elgg_in_context('owner_block') || elgg_in_context('widgets')) { if (elgg_get_context() == 'gallery') { echo $icon; } else { - if ($user->isBanned()) { + if ($entity->isBanned()) { $banned = elgg_echo('banned'); $params = array( - 'entity' => $user, + 'entity' => $entity, 'title' => $title, - 'metadata' => '', + 'metadata' => $metadata, ); } else { $params = array( - 'entity' => $user, + 'entity' => $entity, 'title' => $title, 'metadata' => $metadata, - 'subtitle' => $user->briefdescription, - 'content' => elgg_view('user/status', array('entity' => $user)), + 'subtitle' => $entity->briefdescription, + 'content' => elgg_view('user/status', array('entity' => $entity)), ); } -- cgit v1.2.3 From 3468b554c90457e0033564ccd209359a4a37abd3 Mon Sep 17 00:00:00 2001 From: cash Date: Wed, 18 May 2011 01:35:52 +0000 Subject: Fixes #3132 added 'route', $handler plugin hook git-svn-id: http://code.elgg.org/elgg/trunk@9098 36083f99-b078-4883-b0ff-0f9b5a30f544 --- engine/lib/pagehandler.php | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'engine/lib') diff --git a/engine/lib/pagehandler.php b/engine/lib/pagehandler.php index e598d6821..31d73b18c 100644 --- a/engine/lib/pagehandler.php +++ b/engine/lib/pagehandler.php @@ -27,6 +27,20 @@ function page_handler($handler, $page) { array_pop($page); } + // return false to stop processing the request (because you handled it) + // return a new $params array if you want to route the request differently + $params = array( + 'handler' => $handler, + 'segments' => $page, + ); + $params = elgg_trigger_plugin_hook('route', $handler, NULL, $params); + if ($params === false) { + return true; + } + + $handler = $params['handler']; + $page = $params['segments']; + if (!isset($CONFIG->pagehandler) || empty($handler)) { $result = false; } else if (isset($CONFIG->pagehandler[$handler]) && is_callable($CONFIG->pagehandler[$handler])) { -- cgit v1.2.3 From 81d6884ecad771f4b4f2d8be7572d1a89deaab10 Mon Sep 17 00:00:00 2001 From: cash Date: Thu, 19 May 2011 11:21:53 +0000 Subject: Fixes #3462 empty classes directory is no longer treated as an error git-svn-id: http://code.elgg.org/elgg/trunk@9100 36083f99-b078-4883-b0ff-0f9b5a30f544 --- engine/classes/ElggPlugin.php | 7 +------ engine/lib/elgglib.php | 8 +------- languages/en.php | 1 - 3 files changed, 2 insertions(+), 14 deletions(-) (limited to 'engine/lib') diff --git a/engine/classes/ElggPlugin.php b/engine/classes/ElggPlugin.php index eb911455a..95a7362e2 100644 --- a/engine/classes/ElggPlugin.php +++ b/engine/classes/ElggPlugin.php @@ -839,12 +839,7 @@ class ElggPlugin extends ElggObject { return true; } - // but need to have working ones. - if (!elgg_register_classes($classes_path)) { - $msg = elgg_echo('ElggPlugin:Exception:CannotRegisterClasses', - array($this->getID(), $this->guid, $classes_path)); - throw new PluginException($msg); - } + elgg_register_classes($classes_path); return true; } diff --git a/engine/lib/elgglib.php b/engine/lib/elgglib.php index e67f8b627..170750849 100644 --- a/engine/lib/elgglib.php +++ b/engine/lib/elgglib.php @@ -33,21 +33,15 @@ function _elgg_autoload($class) { * * @param string $dir The dir to look in * - * @return true + * @return void * @since 1.8.0 */ function elgg_register_classes($dir) { $classes = elgg_get_file_list($dir, array(), array(), array('.php')); - if (!$classes) { - return false; - } - foreach ($classes as $class) { elgg_register_class(basename($class, '.php'), $class); } - - return true; } /** diff --git a/languages/en.php b/languages/en.php index ec39f64a9..768658c99 100644 --- a/languages/en.php +++ b/languages/en.php @@ -81,7 +81,6 @@ $english = array( 'ElggPlugin:Exception:CannotIncludeFile' => 'Cannot include %s for plugin %s (guid: %s) at %s. Check permissions!', 'ElggPlugin:Exception:CannotRegisterViews' => 'Cannot open views dir for plugin %s (guid: %s) at %s. Check permissions!', 'ElggPlugin:Exception:CannotRegisterLanguages' => 'Cannot register languages for plugin %s (guid: %s) at %s. Check permissions!', - 'ElggPlugin:Exception:CannotRegisterClasses' => 'Cannot register classes for plugin %s (guid: %s) at %s. Check permissions!', 'ElggPlugin:Exception:NoID' => 'No ID for plugin guid %s!', 'PluginException:ParserError' => 'Error parsing manifest with API version %s in plugin %s.', -- cgit v1.2.3 From 7ee9c7cacbe5da9ecc8c5bb8d3ba51be3ce1d30a Mon Sep 17 00:00:00 2001 From: cash Date: Thu, 19 May 2011 23:42:41 +0000 Subject: Fixes #3163 plugin//settings.php is now the preferred way to add settings plugins git-svn-id: http://code.elgg.org/elgg/trunk@9101 36083f99-b078-4883-b0ff-0f9b5a30f544 --- engine/lib/admin.php | 8 +++++--- views/default/object/plugin/advanced.php | 5 +++-- 2 files changed, 8 insertions(+), 5 deletions(-) (limited to 'engine/lib') diff --git a/engine/lib/admin.php b/engine/lib/admin.php index 5528a29cc..8016a2fd6 100644 --- a/engine/lib/admin.php +++ b/engine/lib/admin.php @@ -325,7 +325,9 @@ function elgg_admin_add_plugin_settings_menu() { foreach ($active_plugins as $plugin) { $plugin_id = $plugin->getID(); - if (elgg_view_exists("settings/$plugin_id/edit")) { + $settings_view_old = 'settings/' . $plugin_id . '/edit'; + $settings_view_new = 'plugins/' . $plugin_id . '/settings'; + if (elgg_view_exists($settings_view_new) || elgg_view_exists($settings_view_old)) { elgg_register_menu_item('page', array( 'name' => $plugin_id, 'href' => "admin/plugin_settings/$plugin_id", @@ -413,8 +415,8 @@ function admin_settings_page_handler($page) { $vars = array('page' => $page); // special page for plugin settings since we create the form for them - if ($page[0] == 'plugin_settings' && isset($page[1]) - && elgg_view_exists("settings/{$page[1]}/edit")) { + if ($page[0] == 'plugin_settings' && isset($page[1]) && + (elgg_view_exists("settings/{$page[1]}/edit") || elgg_view_exists("plugins/{$page[1]}/settings"))) { $view = 'admin/plugin_settings'; $plugin = elgg_get_plugin_from_id($page[1]); diff --git a/views/default/object/plugin/advanced.php b/views/default/object/plugin/advanced.php index 4c8bc8c17..9aed4163c 100644 --- a/views/default/object/plugin/advanced.php +++ b/views/default/object/plugin/advanced.php @@ -182,8 +182,9 @@ if ($files) {
getID() . '/edit'; -if (elgg_view_exists($settings_view)) { +$settings_view_old = 'settings/' . $plugin->getID() . '/edit'; +$settings_view_new = 'plugins/' . $plugin->getID() . '/settings'; +if (elgg_view_exists($settings_view_old) || elgg_view_exists($settings_view_new)) { $link = elgg_get_site_url() . "admin/plugin_settings/" . $plugin->getID(); $settings_link = "[" . elgg_echo('settings') . "]"; } -- cgit v1.2.3 From f158c3117196a61641e1c2dc9539a5ba573515c1 Mon Sep 17 00:00:00 2001 From: cash Date: Thu, 19 May 2011 23:47:32 +0000 Subject: Fixes #3454 not stripping empty attributes git-svn-id: http://code.elgg.org/elgg/trunk@9102 36083f99-b078-4883-b0ff-0f9b5a30f544 --- engine/lib/output.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engine/lib') diff --git a/engine/lib/output.php b/engine/lib/output.php index 3f35a1576..04c737062 100644 --- a/engine/lib/output.php +++ b/engine/lib/output.php @@ -170,7 +170,7 @@ function elgg_format_attributes(array $attrs) { } // ignore $vars['entity'] => ElggEntity stuff - if (is_not_null($val) && (is_array($val) || !is_object($val))) { + if ($val !== NULL && $val !== false && (is_array($val) || !is_object($val))) { // allow $vars['class'] => array('one', 'two'); // @todo what about $vars['style']? Needs to be semi-colon separated... -- cgit v1.2.3 From 8342ead0d181b784f9eb2550d21dc374d8fbd5eb Mon Sep 17 00:00:00 2001 From: cash Date: Thu, 19 May 2011 23:52:50 +0000 Subject: 'creating', 'river' is the plugin hook for preventing or catching a river addition before it happens git-svn-id: http://code.elgg.org/elgg/trunk@9103 36083f99-b078-4883-b0ff-0f9b5a30f544 --- engine/lib/river.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'engine/lib') diff --git a/engine/lib/river.php b/engine/lib/river.php index 80f285e50..49b070082 100644 --- a/engine/lib/river.php +++ b/engine/lib/river.php @@ -23,7 +23,9 @@ function add_to_river($view, $action_type, $subject_guid, $object_guid, $access_id = "", $posted = 0, $annotation_id = 0) { - // use default viewtype for when called from REST api + global $CONFIG; + + // use default viewtype for when called from web services api if (!elgg_view_exists($view, 'default')) { return false; } @@ -60,7 +62,7 @@ $posted = 0, $annotation_id = 0) { ); // return false to stop insert - $params = elgg_trigger_plugin_hook('add', 'river', null, $params); + $params = elgg_trigger_plugin_hook('creating', 'river', null, $params); if ($params == false) { // inserting did not fail - it was just prevented return true; @@ -68,9 +70,6 @@ $posted = 0, $annotation_id = 0) { extract($params); - // Load config - global $CONFIG; - // Attempt to save river item; return success status $insert_data = insert_data("insert into {$CONFIG->dbprefix}river " . " set type = '$type', " . @@ -83,7 +82,8 @@ $posted = 0, $annotation_id = 0) { " annotation_id = $annotation_id, " . " posted = $posted"); - //update the entities which had the action carried out on it + // update the entities which had the action carried out on it + // @todo shouldn't this be down elsewhere? Like when an annotation is saved? if ($insert_data) { update_entity_last_action($object_guid, $posted); return $insert_data; -- cgit v1.2.3 From 2ada5cbb1cb5311ec52446f1b4e9b19d1f47f2d9 Mon Sep 17 00:00:00 2001 From: cash Date: Fri, 20 May 2011 00:08:50 +0000 Subject: Fixes #3300 adds a created,river event git-svn-id: http://code.elgg.org/elgg/trunk@9104 36083f99-b078-4883-b0ff-0f9b5a30f544 --- engine/lib/river.php | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) (limited to 'engine/lib') diff --git a/engine/lib/river.php b/engine/lib/river.php index 49b070082..c467a351c 100644 --- a/engine/lib/river.php +++ b/engine/lib/river.php @@ -18,7 +18,7 @@ * @param int $posted The UNIX epoch timestamp of the river item (default: now) * @param int $annotation_id The annotation ID associated with this river entry * - * @return bool Depending on success + * @return int/bool River ID or false on failure */ function add_to_river($view, $action_type, $subject_guid, $object_guid, $access_id = "", $posted = 0, $annotation_id = 0) { @@ -71,7 +71,7 @@ $posted = 0, $annotation_id = 0) { extract($params); // Attempt to save river item; return success status - $insert_data = insert_data("insert into {$CONFIG->dbprefix}river " . + $id = insert_data("insert into {$CONFIG->dbprefix}river " . " set type = '$type', " . " subtype = '$subtype', " . " action_type = '$action_type', " . @@ -84,9 +84,16 @@ $posted = 0, $annotation_id = 0) { // update the entities which had the action carried out on it // @todo shouldn't this be down elsewhere? Like when an annotation is saved? - if ($insert_data) { + if ($id) { update_entity_last_action($object_guid, $posted); - return $insert_data; + + $river_items = elgg_get_river(array('id' => $id)); + if ($river_items) { + elgg_trigger_event('created', 'river', $river_items[0]); + } + return $id; + } else { + return false; } } @@ -166,6 +173,7 @@ function remove_from_river_by_id($id) { * Get river items * * @param array $options + * ids => INT|ARR River item id(s) * subject_guids => INT|ARR Subject guid(s) * object_guids => INT|ARR Object guid(s) * annotation_ids => INT|ARR The identifier of the annotation(s) @@ -195,6 +203,8 @@ function elgg_get_river(array $options = array()) { global $CONFIG; $defaults = array( + 'ids' => ELGG_ENTITIES_ANY_VALUE, + 'subject_guids' => ELGG_ENTITIES_ANY_VALUE, 'object_guids' => ELGG_ENTITIES_ANY_VALUE, 'annotation_ids' => ELGG_ENTITIES_ANY_VALUE, @@ -224,11 +234,12 @@ function elgg_get_river(array $options = array()) { $options = array_merge($defaults, $options); - $singulars = array('subject_guid', 'object_guid', 'annotation_id', 'action_type', 'type', 'subtype'); + $singulars = array('id', 'subject_guid', 'object_guid', 'annotation_id', 'action_type', 'type', 'subtype'); $options = elgg_normalise_plural_options_array($options, $singulars); $wheres = $options['wheres']; + $wheres[] = elgg_get_guid_based_where_sql('rv.id', $options['ids']); $wheres[] = elgg_get_guid_based_where_sql('rv.subject_guid', $options['subject_guids']); $wheres[] = elgg_get_guid_based_where_sql('rv.object_guid', $options['object_guids']); $wheres[] = elgg_get_guid_based_where_sql('rv.annotation_id', $options['annotation_ids']); -- cgit v1.2.3 From 3f293fe7b5deae93bc90e8f9f30a6b5ae221ea2e Mon Sep 17 00:00:00 2001 From: cash Date: Fri, 20 May 2011 02:51:33 +0000 Subject: Refs #3340 pulls dashboard out as plugin git-svn-id: http://code.elgg.org/elgg/trunk@9108 36083f99-b078-4883-b0ff-0f9b5a30f544 --- engine/lib/users.php | 13 -------- mod/dashboard/manifest.xml | 16 ++++++++++ mod/dashboard/start.php | 42 +++++++++++++++++++++++++ mod/dashboard/views/default/dashboard/blurb.php | 17 ++++++++++ pages/dashboard.php | 29 ----------------- views/default/core/dashboard/blurb.php | 17 ---------- views/default/css/elements/misc.php | 4 --- 7 files changed, 75 insertions(+), 63 deletions(-) create mode 100644 mod/dashboard/manifest.xml create mode 100644 mod/dashboard/start.php create mode 100644 mod/dashboard/views/default/dashboard/blurb.php delete mode 100644 pages/dashboard.php delete mode 100644 views/default/core/dashboard/blurb.php (limited to 'engine/lib') diff --git a/engine/lib/users.php b/engine/lib/users.php index 43b6980b2..a7765a5e5 100644 --- a/engine/lib/users.php +++ b/engine/lib/users.php @@ -1128,18 +1128,6 @@ function collections_page_handler($page_elements) { } } -/** - * Page handler for dashboard - * - * @param array $page_elements Page elements - * - * @return void - */ -function dashboard_page_handler($page_elements) { - require_once(dirname(dirname(dirname(__FILE__))) . "/pages/dashboard.php"); -} - - /** * Page handler for registration * @@ -1525,7 +1513,6 @@ function users_init() { elgg_register_page_handler('friends', 'friends_page_handler'); elgg_register_page_handler('friendsof', 'friends_of_page_handler'); - elgg_register_page_handler('dashboard', 'dashboard_page_handler'); elgg_register_page_handler('register', 'registration_page_handler'); elgg_register_page_handler('resetpassword', 'elgg_user_resetpassword_page_handler'); elgg_register_page_handler('login', 'elgg_user_login_page_handler'); diff --git a/mod/dashboard/manifest.xml b/mod/dashboard/manifest.xml new file mode 100644 index 000000000..b5e9cff2e --- /dev/null +++ b/mod/dashboard/manifest.xml @@ -0,0 +1,16 @@ + + + User Dashboard + Core developers + 1.8 + bundled + A widget-based dashboard for your users + http://www.elgg.org/ + See COPYRIGHT.txt + GNU Public License version 2 + + elgg_version + 2010030101 + + advanced + \ No newline at end of file diff --git a/mod/dashboard/start.php b/mod/dashboard/start.php new file mode 100644 index 000000000..4fa048b3d --- /dev/null +++ b/mod/dashboard/start.php @@ -0,0 +1,42 @@ + 'dashboard', + 'href' => 'dashboard', + 'text' => elgg_view_icon('home') . elgg_echo('dashboard'), + 'priority' => 450, + 'section' => 'alt', + )); +} + +function dashboard_page_handler() { + // Ensure that only logged-in users can see this page + gatekeeper(); + + // Set context and title + elgg_set_context('dashboard'); + elgg_set_page_owner_guid(elgg_get_logged_in_user_guid()); + $title = elgg_echo('dashboard'); + + // wrap intro message in a div + $intro_message = elgg_view('dashboard/blurb'); + + $params = array( + 'content' => $intro_message, + 'num_columns' => 3, + 'show_access' => false, + ); + $widgets = elgg_view_layout('widgets', $params); + + $body = elgg_view_layout('one_column', array('content' => $widgets)); + + echo elgg_view_page($title, $body); +} diff --git a/mod/dashboard/views/default/dashboard/blurb.php b/mod/dashboard/views/default/dashboard/blurb.php new file mode 100644 index 000000000..202be1dc5 --- /dev/null +++ b/mod/dashboard/views/default/dashboard/blurb.php @@ -0,0 +1,17 @@ + + +
+ 'dashboard-info', + 'class' => 'elgg-inner elgg-border-plain pam mhs mbl mtn', + 'value' => elgg_echo("dashboard:nowidgets"), + )); + +?> +
\ No newline at end of file diff --git a/pages/dashboard.php b/pages/dashboard.php deleted file mode 100644 index 31cc9087d..000000000 --- a/pages/dashboard.php +++ /dev/null @@ -1,29 +0,0 @@ - $intro_message, - 'num_columns' => 3, - 'show_access' => false, -); -$widgets = elgg_view_layout('widgets', $params); - -$body = elgg_view_layout('one_column', array('content' => $widgets)); - -echo elgg_view_page($title, $body); \ No newline at end of file diff --git a/views/default/core/dashboard/blurb.php b/views/default/core/dashboard/blurb.php deleted file mode 100644 index 0c4e3947a..000000000 --- a/views/default/core/dashboard/blurb.php +++ /dev/null @@ -1,17 +0,0 @@ - - -
- 'dashboard-info', - 'class' => 'elgg-inner pas mhs mbl', - 'value' => elgg_echo("dashboard:nowidgets"), - )); - -?> -
\ No newline at end of file diff --git a/views/default/css/elements/misc.php b/views/default/css/elements/misc.php index c8ba4f735..ebac2b91f 100644 --- a/views/default/css/elements/misc.php +++ b/views/default/css/elements/misc.php @@ -8,10 +8,6 @@ z-index: 100; } -#dashboard-info .elgg-inner { - border: 2px solid #dedede; -} - /* *************************************** AVATAR UPLOADING & CROPPING *************************************** */ -- cgit v1.2.3 From a5b06dfbcb6cdecf3b4e1f9d168711fc7faa2aad Mon Sep 17 00:00:00 2001 From: cash Date: Wed, 1 Jun 2011 12:01:44 +0000 Subject: Fixes #3455 added documentation back to deprecated functions git-svn-id: http://code.elgg.org/elgg/trunk@9125 36083f99-b078-4883-b0ff-0f9b5a30f544 --- engine/lib/deprecated-1.8.php | 366 ++++++++++++++++++++++++++++++++---------- 1 file changed, 281 insertions(+), 85 deletions(-) (limited to 'engine/lib') diff --git a/engine/lib/deprecated-1.8.php b/engine/lib/deprecated-1.8.php index 44cbb1aaa..12398c8d5 100644 --- a/engine/lib/deprecated-1.8.php +++ b/engine/lib/deprecated-1.8.php @@ -1,7 +1,83 @@ path . 'engine/schema/upgrades/'; + } + + if ($handle = opendir($fromdir)) { + $sqlupgrades = array(); + + while ($sqlfile = readdir($handle)) { + if (!is_dir($fromdir . $sqlfile)) { + if (preg_match('/^([0-9]{10})\.(sql)$/', $sqlfile, $matches)) { + $sql_version = (int) $matches[1]; + if ($sql_version > $version) { + $sqlupgrades[] = $sqlfile; + } + } + } + } + + asort($sqlupgrades); + + if (sizeof($sqlupgrades) > 0) { + foreach ($sqlupgrades as $sqlfile) { + + // hide all errors. + if ($quiet) { + try { + run_sql_script($fromdir . $sqlfile); + } catch (DatabaseException $e) { + error_log($e->getmessage()); + } + } else { + run_sql_script($fromdir . $sqlfile); + } + } + } + } + + return TRUE; +} + +/** + * Lists entities from an access collection + * * @deprecated 1.8 Use elgg_list_entities_from_access_id() + * + * @return str */ function list_entities_from_access_id($access_id, $entity_type = "", $entity_subtype = "", $owner_guid = 0, $limit = 10, $fullview = true, $listtypetoggle = true, $pagination = true) { @@ -14,7 +90,14 @@ function list_entities_from_access_id($access_id, $entity_type = "", $entity_sub } /** + * Registers a particular action in memory + * * @deprecated 1.8 Use {@link elgg_register_action()} instead + * + * @param string $action The name of the action (eg "register", "account/settings/save") + * @param boolean $public Can this action be accessed by people not logged into the system? + * @param string $filename Optionally, the filename where this action is located + * @param boolean $admin_only Whether this action is only available to admin users. */ function register_action($action, $public = false, $filename = "", $admin_only = false) { elgg_deprecated_notice("register_action() was deprecated by elgg_register_action()", 1.8); @@ -35,6 +118,8 @@ function register_action($action, $public = false, $filename = "", $admin_only = * This function extends the view "admin/main" with the provided view. * This view should provide a description and either a control or a link to. * + * @deprecated 1.8 Extend admin views manually + * * Usage: * - To add a control to the main admin panel then extend admin/main * - To add a control to a new page create a page which renders a view admin/subpage @@ -48,8 +133,6 @@ function register_action($action, $public = false, $filename = "", $admin_only = * @param string $view The view to extend, by default this is 'admin/main'. * @param int $priority Optional priority to govern the appearance in the list. * - * @deprecated 1.8 Extend admin views manually - * * @return void */ function extend_elgg_admin_page($new_admin_view, $view = 'admin/main', $priority = 500) { @@ -249,6 +332,8 @@ function list_entities_from_annotation_count($entity_type = "", $entity_subtype /** * Adds an entry in $CONFIG[$register_name][$subregister_name]. * + * @deprecated 1.8 Use the new menu system. + * * This is only used for the site-wide menu. See {@link add_menu()}. * * @param string $register_name The name of the top-level register @@ -257,7 +342,6 @@ function list_entities_from_annotation_count($entity_type = "", $entity_subtype * @param array $children_array Optionally, an array of children * * @return true|false Depending on success - * @deprecated 1.8 */ function add_to_register($register_name, $subregister_name, $subregister_value, $children_array = array()) { elgg_deprecated_notice("add_to_register() has been deprecated", 1.8); @@ -290,6 +374,8 @@ function add_to_register($register_name, $subregister_name, $subregister_value, /** * Removes a register entry from $CONFIG[register_name][subregister_name] * + * @deprecated 1.8 Use the new menu system. + * * This is used to by {@link remove_menu()} to remove site-wide menu items. * * @param string $register_name The name of the top-level register @@ -297,7 +383,6 @@ function add_to_register($register_name, $subregister_name, $subregister_value, * * @return true|false Depending on success * @since 1.7.0 - * @deprecated 1.8 */ function remove_from_register($register_name, $subregister_name) { elgg_deprecated_notice("remove_from_register() has been deprecated", 1.8); @@ -326,10 +411,11 @@ function remove_from_register($register_name, $subregister_name) { /** * If it exists, returns a particular register as an array * + * @deprecated 1.8 Use the new menu system + * * @param string $register_name The name of the register * * @return array|false Depending on success - * @deprecated 1.8 */ function get_register($register_name) { elgg_deprecated_notice("get_register() has been deprecated", 1.8); @@ -363,6 +449,8 @@ function get_register($register_name) { * Deprecated events core function. Code divided between elgg_register_event_handler() * and trigger_elgg_event(). * + * @deprecated 1.8 Use explicit register/trigger event functions + * * @param string $event The type of event (eg 'init', 'update', 'delete') * @param string $object_type The type of object (eg 'system', 'blog', 'user') * @param string $function The name of the function that will handle the event @@ -371,7 +459,6 @@ function get_register($register_name) { * @param mixed $object Optionally, the object the event is being performed on (eg a user) * * @return true|false Depending on success - * @deprecated 1.8 Use explicit register/trigger event functions */ function events($event = "", $object_type = "", $function = "", $priority = 500, $call = false, $object = null) { @@ -386,7 +473,14 @@ function events($event = "", $object_type = "", $function = "", $priority = 500, } /** + * Alias function for events, that registers a function to a particular kind of event + * * @deprecated 1.8 Use elgg_register_event_handler() instead + * + * @param string $event The event type + * @param string $object_type The object type + * @param string $function The function name + * @return true|false Depending on success */ function register_elgg_event_handler($event, $object_type, $callback, $priority = 500) { elgg_deprecated_notice("register_elgg_event_handler() was deprecated by elgg_register_event_handler()", 1.8); @@ -394,7 +488,14 @@ function register_elgg_event_handler($event, $object_type, $callback, $priority } /** + * Unregisters a function to a particular kind of event + * * @deprecated 1.8 Use elgg_unregister_event_handler instead + * + * @param string $event The event type + * @param string $object_type The object type + * @param string $function The function name + * @since 1.7.0 */ function unregister_elgg_event_handler($event, $object_type, $callback) { elgg_deprecated_notice('unregister_elgg_event_handler => elgg_unregister_event_handler', 1.8); @@ -402,7 +503,14 @@ function unregister_elgg_event_handler($event, $object_type, $callback) { } /** + * Alias function for events, that triggers a particular kind of event + * * @deprecated 1.8 Use elgg_trigger_event() instead + * + * @param string $event The event type + * @param string $object_type The object type + * @param string $function The function name + * @return true|false Depending on success */ function trigger_elgg_event($event, $object_type, $object = null) { elgg_deprecated_notice('trigger_elgg_event() was deprecated by elgg_trigger_event()', 1.8); @@ -410,7 +518,29 @@ function trigger_elgg_event($event, $object_type, $object = null) { } /** + * Register a function to a plugin hook for a particular entity type, with a given priority. + * * @deprecated 1.8 Use elgg_register_plugin_hook_handler() instead + * + * eg if you want the function "export_user" to be called when the hook "export" for "user" entities + * is run, use: + * + * register_plugin_hook("export", "user", "export_user"); + * + * "all" is a valid value for both $hook and $entity_type. "none" is a valid value for $entity_type. + * + * The export_user function would then be defined as: + * + * function export_user($hook, $entity_type, $returnvalue, $params); + * + * Where $returnvalue is the return value returned by the last function returned by the hook, and + * $params is an array containing a set of parameters (or nothing). + * + * @param string $hook The name of the hook + * @param string $entity_type The name of the type of entity (eg "user", "object" etc) + * @param string $function The name of a valid function to be run + * @param string $priority The priority - 0 is first, 1000 last, default is 500 + * @return true|false Depending on success */ function register_plugin_hook($hook, $type, $callback, $priority = 500) { elgg_deprecated_notice("register_plugin_hook() was deprecated by elgg_register_plugin_hook_handler()", 1.8); @@ -418,7 +548,14 @@ function register_plugin_hook($hook, $type, $callback, $priority = 500) { } /** + * Unregister a function to a plugin hook for a particular entity type + * * @deprecated 1.8 Use elgg_unregister_plugin_hook_handler() instead + * + * @param string $hook The name of the hook + * @param string $entity_type The name of the type of entity (eg "user", "object" etc) + * @param string $function The name of a valid function to be run + * @since 1.7.0 */ function unregister_plugin_hook($hook, $entity_type, $callback) { elgg_deprecated_notice("unregister_plugin_hook() was deprecated by elgg_unregister_plugin_hook_handler()", 1.8); @@ -426,7 +563,20 @@ function unregister_plugin_hook($hook, $entity_type, $callback) { } /** + * Triggers a plugin hook, with various parameters as an array. For example, to provide + * a 'foo' hook that concerns an entity of type 'bar', with a parameter called 'param1' + * with value 'value1', that by default returns true, you'd call: + * * @deprecated 1.8 Use elgg_trigger_plugin_hook() instead + * + * trigger_plugin_hook('foo', 'bar', array('param1' => 'value1'), true); + * + * @see register_plugin_hook + * @param string $hook The name of the hook to trigger + * @param string $entity_type The name of the entity type to trigger it for (or "all", or "none") + * @param array $params Any parameters. It's good practice to name the keys, i.e. by using array('name' => 'value', 'name2' => 'value2') + * @param mixed $returnvalue An initial return value + * @return mixed|null The cumulative return value for the plugin hook functions */ function trigger_plugin_hook($hook, $type, $params = null, $returnvalue = null) { elgg_deprecated_notice("trigger_plugin_hook() was deprecated by elgg_trigger_plugin_hook()", 1.8); @@ -2844,6 +2994,13 @@ $priority = 500) { } /** + * Returns a representation of a full 'page' (which might be an HTML page, + * RSS file, etc, depending on the current viewtype) + * + * @param string $title + * @param string $body + * @return string + * * @deprecated 1.8 Use elgg_view_page() */ function page_draw($title, $body, $sidebar = "") { @@ -3510,8 +3667,12 @@ $asc = false, $fullview = true, $listtypetoggle = false, $pagination = true, $or } /** - * @deprecated 1.8 - * @see elgg_set_view_location() + * Set an alternative base location for a view (as opposed to the default of $CONFIG->viewpath) + * + * @param string $view The name of the view + * @param string $location The base location path + * + * @deprecated 1.8 Use elgg_set_view_location() */ function set_view_location($view, $location, $viewtype = '') { elgg_deprecated_notice("set_view_location() was deprecated by elgg_set_view_location()", 1.8); @@ -3519,8 +3680,14 @@ function set_view_location($view, $location, $viewtype = '') { } /** - * @deprecated 1.8 - * @see elgg_register_entity_url_handler() + * Sets the URL handler for a particular entity type and subtype + * + * @param string $function_name The function to register + * @param string $entity_type The entity type + * @param string $entity_subtype The entity subtype + * @return true|false Depending on success + * + * @deprecated 1.8 Use elgg_register_entity_url_handler() */ function register_entity_url_handler($function_name, $entity_type = "all", $entity_subtype = "all") { elgg_deprecated_notice("register_entity_url_handler() was deprecated by elgg_register_entity_url_handler()", 1.8); @@ -3807,6 +3974,27 @@ function clear_annotations_by_owner($owner_guid) { } /** + * Registers a page handler for a particular identifier + * + * For example, you can register a function called 'blog_page_handler' for handler type 'blog' + * Now for all URLs of type http://yoururl/pg/blog/*, the blog_page_handler() function will be called. + * The part of the URL marked with * above will be exploded on '/' characters and passed as an + * array to that function. + * For example, the URL http://yoururl/blog/username/friends/ would result in the call: + * blog_page_handler(array('username','friends'), blog); + * + * Page handler functions should return true or the default page handler will be called. + * + * A request to register a page handler with the same identifier as previously registered + * handler will replace the previous one. + * + * The context is set to the page handler identifier before the registered + * page handler function is called. For the above example, the context is set to 'blog'. + * + * @param string $handler The page type to handle + * @param string $function Your function name + * @return true|false Depending on success + * * @deprecated 1.8 Use {@link elgg_register_page_handler()} */ function register_page_handler($handler, $function){ @@ -3815,6 +4003,13 @@ function register_page_handler($handler, $function){ } /** + * Unregister a page handler for an identifier + * + * Note: to replace a page handler, call register_page_handler() + * + * @param string $handler The page type identifier + * @since 1.7.2 + * * @deprecated 1.8 Use {@link elgg_unregister_page_handler()} */ function unregister_page_handler($handler) { @@ -3823,6 +4018,11 @@ function unregister_page_handler($handler) { } /** + * Register an annotation url handler. + * + * @param string $function_name The function. + * @param string $extender_name The name, default 'all'. + * * @deprecated 1.8 Use {@link elgg_register_annotation_url_handler()} */ function register_annotation_url_handler($function, $extender_name) { @@ -3831,6 +4031,15 @@ function register_annotation_url_handler($function, $extender_name) { } /** + * Sets the URL handler for a particular extender type and name. + * It is recommended that you do not call this directly, instead use one of the wrapper functions in the + * subtype files. + * + * @param string $function_name The function to register + * @param string $extender_type Extender type + * @param string $extender_name The name of the extender + * @return true|false Depending on success + * * @deprecated 1.8 Use {@link elgg_register_extender_url_handler()} */ function register_extender_url_handler($function, $type = "all", $name = "all") { @@ -3839,6 +4048,14 @@ function register_extender_url_handler($function, $type = "all", $name = "all") } /** + * Registers and entity type and subtype to return in search and other places. + * A description in the elgg_echo languages file of the form item:type:subtype + * is also expected. + * + * @param string $type The type of entity (object, site, user, group) + * @param string $subtype The subtype to register (may be blank) + * @return true|false Depending on success + * * @deprecated 1.8 Use {@link elgg_register_entity_type()} */ function register_entity_type($type, $subtype = null) { @@ -3847,6 +4064,11 @@ function register_entity_type($type, $subtype = null) { } /** + * Register a metadata url handler. + * + * @param string $function_name The function. + * @param string $extender_name The name, default 'all'. + * * @deprecated 1.8 Use {@link elgg_register_metadata_url_handler()} */ function register_metadata_url_handler($function, $extender_name = "all") { @@ -3854,7 +4076,12 @@ function register_metadata_url_handler($function, $extender_name = "all") { } /** + * Sets the URL handler for a particular relationship type * + * @param string $function_name The function to register + * @param string $relationship_type The relationship type. + * @return true|false Depending on success + * * @deprecated 1.8 Use {@link elgg_register_relationship_url_handler()} */ function register_relationship_url_handler($function_name, $relationship_type = "all") { @@ -3863,6 +4090,15 @@ function register_relationship_url_handler($function_name, $relationship_type = } /** + * Registers a view to be simply cached + * + * Views cached in this manner must take no parameters and be login agnostic - + * that is to say, they look the same no matter who is logged in (or logged out). + * + * CSS and the basic jS views are automatically cached like this. + * + * @param string $viewname View name + * * @deprecated 1.8 Use {@link elgg_register_simplecache_view()} */ function elgg_view_register_simplecache($viewname) { @@ -3871,6 +4107,11 @@ function elgg_view_register_simplecache($viewname) { } /** + * Regenerates the simple cache. + * + * @param string $viewtype Optional viewtype to regenerate + * @see elgg_view_register_simplecache() + * * @deprecated 1.8 Use {@link elgg_regenerate_simplecache()} */ function elgg_view_regenerate_simplecache($viewtype = NULL) { @@ -3879,6 +4120,10 @@ function elgg_view_regenerate_simplecache($viewtype = NULL) { } /** + * Enables the simple cache. + * + * @see elgg_view_register_simplecache() + * * @deprecated 1.8 Use {@link elgg_enable_simplecache()} */ function elgg_view_enable_simplecache() { @@ -3887,6 +4132,10 @@ function elgg_view_enable_simplecache() { } /** + * Disables the simple cache. + * + * @see elgg_view_register_simplecache() + * * @deprecated 1.8 Use {@link elgg_disable_simplecache()} */ function elgg_view_disable_simplecache() { @@ -3912,6 +4161,22 @@ function is_installed() { } /** + * Attempt to authenticate. + * This function will process all registered PAM handlers or stop when the first + * handler fails. A handler fails by either returning false or throwing an + * exception. The advantage of throwing an exception is that it returns a message + * through the global $_PAM_HANDLERS_MSG which can be used in communication with + * a user. The order that handlers are processed is determined by the order that + * they were registered. + * + * If $credentials are provided the PAM handler should authenticate using the + * provided credentials, if not then credentials should be prompted for or + * otherwise retrieved (eg from the HTTP header or $_SESSION). + * + * @param mixed $credentials Mixed PAM handler specific credentials (e.g. username, password) + * @param string $policy - the policy type, default is "user" + * @return bool true if authenticated, false if not. + * * @deprecated 1.8 See {@link ElggPAM} */ function pam_authenticate($credentials = NULL, $policy = "user") { @@ -4375,6 +4640,11 @@ function using_widgets() { } /** + * Displays a particular widget + * + * @param ElggObject $widget The widget to display + * @return string The HTML for the widget, including JavaScript wrapper + * * @deprecated 1.8 */ function display_widget(ElggObject $widget) { @@ -4382,80 +4652,6 @@ function display_widget(ElggObject $widget) { return elgg_view_entity($widget); } - -/** - * *************************************************************************** - * NOTE: If this is ever removed from Elgg, sites lose the ability to upgrade - * from 1.7.x and earlier to the latest version of Elgg without upgrading to - * 1.8 first. - * *************************************************************************** - * - * Upgrade the database schema in an ordered sequence. - * - * Executes all upgrade files in elgg/engine/schema/upgrades/ in sequential order. - * Upgrade files must be in the standard Elgg release format of YYYYMMDDII.sql - * where II is an incrementor starting from 01. - * - * Files that are < $version will be ignored. - * - * @warning Plugin authors should not call this function directly. - * - * @param int $version The version you are upgrading from in the format YYYYMMDDII. - * @param string $fromdir Optional directory to load upgrades from. default: engine/schema/upgrades/ - * @param bool $quiet If true, suppress all error messages. Only use for the upgrade from <=1.6. - * - * @return bool - * @see upgrade.php - * @see version.php - * @deprecated 1.8 Use PHP upgrades for sql changes. - */ -function db_upgrade($version, $fromdir = "", $quiet = FALSE) { - global $CONFIG; - - elgg_deprecated_notice('db_upgrade() is deprecated by using PHP upgrades.', 1.8); - - $version = (int) $version; - - if (!$fromdir) { - $fromdir = $CONFIG->path . 'engine/schema/upgrades/'; - } - - if ($handle = opendir($fromdir)) { - $sqlupgrades = array(); - - while ($sqlfile = readdir($handle)) { - if (!is_dir($fromdir . $sqlfile)) { - if (preg_match('/^([0-9]{10})\.(sql)$/', $sqlfile, $matches)) { - $sql_version = (int) $matches[1]; - if ($sql_version > $version) { - $sqlupgrades[] = $sqlfile; - } - } - } - } - - asort($sqlupgrades); - - if (sizeof($sqlupgrades) > 0) { - foreach ($sqlupgrades as $sqlfile) { - - // hide all errors. - if ($quiet) { - try { - run_sql_script($fromdir . $sqlfile); - } catch (DatabaseException $e) { - error_log($e->getmessage()); - } - } else { - run_sql_script($fromdir . $sqlfile); - } - } - } - } - - return TRUE; -} - /** * Count the number of comments attached to an entity * -- cgit v1.2.3 From 22f8de74875e5351fd7711f3b7b2b430c98f1c05 Mon Sep 17 00:00:00 2001 From: brettp Date: Tue, 7 Jun 2011 22:58:46 +0000 Subject: Refs #3510, #3418. Merged fix for forwarding after output to trunk. git-svn-id: http://code.elgg.org/elgg/trunk@9141 36083f99-b078-4883-b0ff-0f9b5a30f544 --- engine/lib/group.php | 5 +++-- engine/lib/sessions.php | 9 +++++++-- languages/en.php | 1 + 3 files changed, 11 insertions(+), 4 deletions(-) (limited to 'engine/lib') diff --git a/engine/lib/group.php b/engine/lib/group.php index d78274961..755482b00 100644 --- a/engine/lib/group.php +++ b/engine/lib/group.php @@ -276,8 +276,9 @@ function group_gatekeeper($forward = true) { if ($forward && $allowed == false) { register_error(elgg_echo('membershiprequired')); - forward($url, 'member'); - exit; + if (!forward($url, 'member')) { + throw new SecurityException(elgg_echo('SecurityException:UnexpectedOutputInGatekeeper')); + } } return $allowed; diff --git a/engine/lib/sessions.php b/engine/lib/sessions.php index ae42956a9..407bb69c5 100644 --- a/engine/lib/sessions.php +++ b/engine/lib/sessions.php @@ -472,7 +472,10 @@ function gatekeeper() { if (!elgg_is_logged_in()) { $_SESSION['last_forward_from'] = current_page_url(); register_error(elgg_echo('loggedinrequired')); - forward('', 'login'); + + if (!forward('', 'login')) { + throw new SecurityException(elgg_echo('SecurityException:UnexpectedOutputInGatekeeper')); + } } } @@ -487,7 +490,9 @@ function admin_gatekeeper() { if (!elgg_is_admin_logged_in()) { $_SESSION['last_forward_from'] = current_page_url(); register_error(elgg_echo('adminrequired')); - forward('', 'admin'); + if (!forward('', 'admin')) { + throw new SecurityException(elgg_echo('SecurityException:UnexpectedOutputInGatekeeper')); + } } } diff --git a/languages/en.php b/languages/en.php index 83fb66dad..46ac19a34 100644 --- a/languages/en.php +++ b/languages/en.php @@ -170,6 +170,7 @@ $english = array( 'ConfigurationException:NoSiteID' => "No site ID has been specified.", 'SecurityException:APIAccessDenied' => "Sorry, API access has been disabled by the administrator.", 'SecurityException:NoAuthMethods' => "No authentication methods were found that could authenticate this API request.", + 'SecurityException:UnexpectedOutputInGatekeeper' => 'Unexpected output in gatekeeper call. Halting execution for security. Search http://docs.elgg.org/ for more information.', 'InvalidParameterException:APIMethodOrFunctionNotSet' => "Method or function not set in call in expose_method()", 'InvalidParameterException:APIParametersArrayStructure' => "Parameters array structure is incorrect for call to expose method '%s'", 'InvalidParameterException:UnrecognisedHttpMethod' => "Unrecognised http method %s for api method '%s'", -- cgit v1.2.3 From 740d6a543605e6179b77c996aae3030b96069c5e Mon Sep 17 00:00:00 2001 From: brettp Date: Wed, 8 Jun 2011 22:41:21 +0000 Subject: Refs #3510, #3416. Merged update for making sure users have relationship member_of on site object. git-svn-id: http://code.elgg.org/elgg/trunk@9144 36083f99-b078-4883-b0ff-0f9b5a30f544 --- engine/lib/upgrades/2011052801.php | 45 ++++++++++++++++++++++++++++++++++++++ version.php | 2 +- 2 files changed, 46 insertions(+), 1 deletion(-) create mode 100644 engine/lib/upgrades/2011052801.php (limited to 'engine/lib') diff --git a/engine/lib/upgrades/2011052801.php b/engine/lib/upgrades/2011052801.php new file mode 100644 index 000000000..8084bc06c --- /dev/null +++ b/engine/lib/upgrades/2011052801.php @@ -0,0 +1,45 @@ +guid', + 'member_of_site', + '$user->site_guid', + '$user->time_created' + )"; + + insert_data($rel_q); + } + + // every time we run this query we've just reduced the rows it returns by $limit + // so don't pass an offset. + $q = "SELECT e.* FROM {$db_prefix}entities e + WHERE e.type = 'user' AND e.guid NOT IN ( + SELECT guid_one FROM {$db_prefix}entity_relationships + WHERE guid_two = 1 AND relationship = 'member_of_site' + ) + LIMIT $limit"; + + $users = get_data($q); +} \ No newline at end of file diff --git a/version.php b/version.php index f3e7010b0..d1cc63aef 100644 --- a/version.php +++ b/version.php @@ -11,7 +11,7 @@ // YYYYMMDD = Elgg Date // XX = Interim incrementer -$version = 2011032200; +$version = 2011052801; // Human-friendly version name $release = '1.8b1'; -- cgit v1.2.3 From 3374741869ae97a5c258aceb3289092340b17f67 Mon Sep 17 00:00:00 2001 From: brettp Date: Thu, 9 Jun 2011 01:58:26 +0000 Subject: Refs #3510, #3366. Added warning about count vs sum in egef_annotation_count() to trunk. git-svn-id: http://code.elgg.org/elgg/trunk@9147 36083f99-b078-4883-b0ff-0f9b5a30f544 --- engine/lib/deprecated-1.8.php | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'engine/lib') diff --git a/engine/lib/deprecated-1.8.php b/engine/lib/deprecated-1.8.php index 12398c8d5..a04907a6d 100644 --- a/engine/lib/deprecated-1.8.php +++ b/engine/lib/deprecated-1.8.php @@ -208,6 +208,12 @@ function get_entities_from_annotations_calculate_x($sum = "sum", $entity_type = /** * Returns entities ordered by the sum of an annotation * + * @warning This is function uses sum instead of count. THIS IS SLOW. See #3366. + * This should be used when you have annotations with different values and you + * want a list of entities ordered by the sum of all of those values. + * If you want a list of entities ordered by the number of annotations on each entity, + * use __get_entities_from_annotations_calculate_x() and pass 'count' as the first param. + * * @deprecated 1.8 Use elgg_get_entities_from_annotation_calculation() * * @param string $entity_type Type of Entity -- cgit v1.2.3 From 977ab26af244f793440301a3bd4f35d45b1dd0b1 Mon Sep 17 00:00:00 2001 From: cash Date: Thu, 9 Jun 2011 19:35:05 +0000 Subject: Refs #2871 promoted advanced plugins up to be a primary menu git-svn-id: http://code.elgg.org/elgg/trunk@9156 36083f99-b078-4883-b0ff-0f9b5a30f544 --- engine/lib/admin.php | 13 ++- views/default/admin/plugins.php | 171 +++++++++++++++++++++++++++++++ views/default/admin/plugins/advanced.php | 171 ------------------------------- 3 files changed, 181 insertions(+), 174 deletions(-) create mode 100644 views/default/admin/plugins.php delete mode 100644 views/default/admin/plugins/advanced.php (limited to 'engine/lib') diff --git a/engine/lib/admin.php b/engine/lib/admin.php index 8016a2fd6..7c41fc24e 100644 --- a/engine/lib/admin.php +++ b/engine/lib/admin.php @@ -262,11 +262,18 @@ function admin_init() { // configure // plugins - elgg_register_admin_menu_item('configure', 'plugins', null, 10); - elgg_register_admin_menu_item('configure', 'simple', 'plugins', 10); - elgg_register_admin_menu_item('configure', 'advanced', 'plugins', 20); + elgg_register_menu_item('page', array( + 'name' => 'plugins', + 'href' => 'admin/plugins', + 'text' => elgg_echo('admin:plugins'), + 'context' => 'admin', + 'priority' => 75, + 'section' => 'configure' + )); // settings + elgg_register_admin_menu_item('configure', 'appearance', null, 50); + elgg_register_admin_menu_item('configure', 'settings', null, 100); elgg_register_admin_menu_item('configure', 'basic', 'settings', 10); elgg_register_admin_menu_item('configure', 'advanced', 'settings', 20); elgg_register_admin_menu_item('configure', 'menu_items', 'appearance', 30); diff --git a/views/default/admin/plugins.php b/views/default/admin/plugins.php new file mode 100644 index 000000000..9f426fae2 --- /dev/null +++ b/views/default/admin/plugins.php @@ -0,0 +1,171 @@ + $plugin) { + if (!$plugin->isValid()) { + continue; + } + + $plugin_categories = $plugin->getManifest()->getCategories(); + + // handle plugins that don't declare categories + // unset them here because this is the list we foreach + switch ($show_category) { + case 'all': + break; + case 'active': + if (!$plugin->isActive()) { + unset($installed_plugins[$id]); + } + break; + case 'inactive': + if ($plugin->isActive()) { + unset($installed_plugins[$id]); + } + break; + default: + if (!in_array($show_category, $plugin_categories)) { + unset($installed_plugins[$id]); + } + break; + } + + if (isset($plugin_categories)) { + foreach ($plugin_categories as $category) { + if (!array_key_exists($category, $categories)) { + $categories[$category] = elgg_echo("admin:plugins:category:$category"); + } + } + } +} + +// sort plugins +switch ($sort) { + case 'date': + $plugin_list = array(); + foreach ($installed_plugins as $plugin) { + $create_date = $plugin->getTimeCreated(); + while (isset($plugin_list[$create_date])) { + $create_date++; + } + $plugin_list[$create_date] = $plugin; + } + krsort($plugin_list); + break; + case 'alpha': + $plugin_list = array(); + foreach ($installed_plugins as $plugin) { + $plugin_list[$plugin->getManifest()->getName()] = $plugin; + } + ksort($plugin_list); + break; + case 'priority': + default: + $plugin_list = $installed_plugins; + break; +} + + + +asort($categories); + +$common_categories = array( + 'all' => elgg_echo('admin:plugins:category:all'), + 'active' => elgg_echo('admin:plugins:category:active'), + 'inactive' => elgg_echo('admin:plugins:category:inactive'), +); + +$categories = array_merge($common_categories, $categories); +// security - only want a defined option +if (!array_key_exists($show_category, $categories)) { + $show_category = reset($categories); +} + +$category_form = elgg_view_form('admin/plugins/filter', array( + 'action' => 'admin/plugins/advanced', + 'method' => 'get', + 'disable_security' => true, +), array( + 'category' => $show_category, + 'category_options' => $categories, + 'sort' => $sort, +)); + + +$sort_options = array( + 'priority' => elgg_echo('admin:plugins:sort:priority'), + 'alpha' => elgg_echo('admin:plugins:sort:alpha'), + 'date' => elgg_echo('admin:plugins:sort:date'), +); +// security - only want a defined option +if (!array_key_exists($sort, $sort_options)) { + $sort = reset($sort_options); +} + +$sort_form = elgg_view_form('admin/plugins/sort', array( + 'action' => 'admin/plugins/advanced', + 'method' => 'get', + 'disable_security' => true, +), array( + 'sort' => $sort, + 'sort_options' => $sort_options, + 'category' => $show_category, +)); + + +// @todo Until "en/deactivate all" means "All plugins on this page" hide when not looking at all. +if ($show_category == 'all') { + $activate_url = "action/admin/plugins/activate_all"; + $activate_url = elgg_add_action_tokens_to_url($activate_url); + $deactivate_url = "action/admin/plugins/deactivate_all"; + $deactivate_url = elgg_add_action_tokens_to_url($deactivate_url); + + $buttons = ""; +} else { + $buttons = ''; +} + +$buttons .= $category_form . $sort_form; + +// construct page header +?> +
+
+
+ +
+ 0, + 'full_view' => true, + 'list_type_toggle' => false, + 'pagination' => false, +); +if ($show_category == 'all' && $sort == 'priority') { + $options['display_reordering'] = true; +} +echo elgg_view_entity_list($plugin_list, $options); + +?> +
\ No newline at end of file diff --git a/views/default/admin/plugins/advanced.php b/views/default/admin/plugins/advanced.php deleted file mode 100644 index 9f426fae2..000000000 --- a/views/default/admin/plugins/advanced.php +++ /dev/null @@ -1,171 +0,0 @@ - $plugin) { - if (!$plugin->isValid()) { - continue; - } - - $plugin_categories = $plugin->getManifest()->getCategories(); - - // handle plugins that don't declare categories - // unset them here because this is the list we foreach - switch ($show_category) { - case 'all': - break; - case 'active': - if (!$plugin->isActive()) { - unset($installed_plugins[$id]); - } - break; - case 'inactive': - if ($plugin->isActive()) { - unset($installed_plugins[$id]); - } - break; - default: - if (!in_array($show_category, $plugin_categories)) { - unset($installed_plugins[$id]); - } - break; - } - - if (isset($plugin_categories)) { - foreach ($plugin_categories as $category) { - if (!array_key_exists($category, $categories)) { - $categories[$category] = elgg_echo("admin:plugins:category:$category"); - } - } - } -} - -// sort plugins -switch ($sort) { - case 'date': - $plugin_list = array(); - foreach ($installed_plugins as $plugin) { - $create_date = $plugin->getTimeCreated(); - while (isset($plugin_list[$create_date])) { - $create_date++; - } - $plugin_list[$create_date] = $plugin; - } - krsort($plugin_list); - break; - case 'alpha': - $plugin_list = array(); - foreach ($installed_plugins as $plugin) { - $plugin_list[$plugin->getManifest()->getName()] = $plugin; - } - ksort($plugin_list); - break; - case 'priority': - default: - $plugin_list = $installed_plugins; - break; -} - - - -asort($categories); - -$common_categories = array( - 'all' => elgg_echo('admin:plugins:category:all'), - 'active' => elgg_echo('admin:plugins:category:active'), - 'inactive' => elgg_echo('admin:plugins:category:inactive'), -); - -$categories = array_merge($common_categories, $categories); -// security - only want a defined option -if (!array_key_exists($show_category, $categories)) { - $show_category = reset($categories); -} - -$category_form = elgg_view_form('admin/plugins/filter', array( - 'action' => 'admin/plugins/advanced', - 'method' => 'get', - 'disable_security' => true, -), array( - 'category' => $show_category, - 'category_options' => $categories, - 'sort' => $sort, -)); - - -$sort_options = array( - 'priority' => elgg_echo('admin:plugins:sort:priority'), - 'alpha' => elgg_echo('admin:plugins:sort:alpha'), - 'date' => elgg_echo('admin:plugins:sort:date'), -); -// security - only want a defined option -if (!array_key_exists($sort, $sort_options)) { - $sort = reset($sort_options); -} - -$sort_form = elgg_view_form('admin/plugins/sort', array( - 'action' => 'admin/plugins/advanced', - 'method' => 'get', - 'disable_security' => true, -), array( - 'sort' => $sort, - 'sort_options' => $sort_options, - 'category' => $show_category, -)); - - -// @todo Until "en/deactivate all" means "All plugins on this page" hide when not looking at all. -if ($show_category == 'all') { - $activate_url = "action/admin/plugins/activate_all"; - $activate_url = elgg_add_action_tokens_to_url($activate_url); - $deactivate_url = "action/admin/plugins/deactivate_all"; - $deactivate_url = elgg_add_action_tokens_to_url($deactivate_url); - - $buttons = ""; -} else { - $buttons = ''; -} - -$buttons .= $category_form . $sort_form; - -// construct page header -?> -
-
-
- -
- 0, - 'full_view' => true, - 'list_type_toggle' => false, - 'pagination' => false, -); -if ($show_category == 'all' && $sort == 'priority') { - $options['display_reordering'] = true; -} -echo elgg_view_entity_list($plugin_list, $options); - -?> -
\ No newline at end of file -- cgit v1.2.3 From 8cd4d7f312dbf68636d10a34121d781628c2ead2 Mon Sep 17 00:00:00 2001 From: cash Date: Thu, 9 Jun 2011 20:42:58 +0000 Subject: Fixes #3548 the check for an admin menu's parent wasn't working git-svn-id: http://code.elgg.org/elgg/trunk@9159 36083f99-b078-4883-b0ff-0f9b5a30f544 --- engine/lib/admin.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engine/lib') diff --git a/engine/lib/admin.php b/engine/lib/admin.php index 7c41fc24e..6ef626f81 100644 --- a/engine/lib/admin.php +++ b/engine/lib/admin.php @@ -183,7 +183,7 @@ function elgg_admin_notice_exists($id) { function elgg_register_admin_menu_item($section, $menu_id, $parent_id = NULL, $priority = 100) { // make sure parent is registered - if ($parent_id && !elgg_is_menu_item_registered($menu_id, $parent_id)) { + if ($parent_id && !elgg_is_menu_item_registered('page', $parent_id)) { elgg_register_admin_menu_item($section, $parent_id); } -- cgit v1.2.3 From 6fbacea7340b0739c23be0a7d073782c64eee78d Mon Sep 17 00:00:00 2001 From: cash Date: Thu, 9 Jun 2011 22:15:56 +0000 Subject: Fixes #3489 added input/output views for tag and location git-svn-id: http://code.elgg.org/elgg/trunk@9163 36083f99-b078-4883-b0ff-0f9b5a30f544 --- engine/lib/users.php | 4 ++-- views/default/input/location.php | 21 +++++++++++++++++++++ views/default/input/tag.php | 17 +++++++++++++++++ views/default/output/location.php | 14 ++++++++++++++ views/default/output/tag.php | 30 ++++++++++++++++++++++++++++++ views/default/output/tags.php | 2 +- 6 files changed, 85 insertions(+), 3 deletions(-) create mode 100644 views/default/input/location.php create mode 100644 views/default/input/tag.php create mode 100644 views/default/output/location.php create mode 100644 views/default/output/tag.php (limited to 'engine/lib') diff --git a/engine/lib/users.php b/engine/lib/users.php index a7765a5e5..832bcd529 100644 --- a/engine/lib/users.php +++ b/engine/lib/users.php @@ -1345,7 +1345,7 @@ function elgg_profile_fields_setup() { $profile_defaults = array ( 'description' => 'longtext', 'briefdescription' => 'text', - 'location' => 'tags', + 'location' => 'location', 'interests' => 'tags', 'skills' => 'tags', 'contactemail' => 'email', @@ -1379,7 +1379,7 @@ function elgg_profile_fields_setup() { // register any tag metadata names foreach ($CONFIG->profile_fields as $name => $type) { - if ($type == 'tags') { + if ($type == 'tags' || $type == 'location' || $type == 'tag') { elgg_register_tag_metadata_name($name); // register a tag name translation add_translation(get_current_language(), array("tag_names:$name" => elgg_echo("profile:$name"))); diff --git a/views/default/input/location.php b/views/default/input/location.php new file mode 100644 index 000000000..d7ae2bbbd --- /dev/null +++ b/views/default/input/location.php @@ -0,0 +1,21 @@ + 'elgg-input-location', + 'disabled' => FALSE, +); + +if (isset($vars['entity'])) { + $defaults['value'] = $vars['entity']->location; + unset($vars['entity']); +} + +$vars = array_merge($defaults, $vars); + +echo elgg_view('input/tag', $vars); diff --git a/views/default/input/tag.php b/views/default/input/tag.php new file mode 100644 index 000000000..a78ec3163 --- /dev/null +++ b/views/default/input/tag.php @@ -0,0 +1,17 @@ + 'elgg-input-tag', + 'disabled' => FALSE, +); + +$vars = array_merge($defaults, $vars); + +echo elgg_view('input/text', $vars); \ No newline at end of file diff --git a/views/default/output/location.php b/views/default/output/location.php new file mode 100644 index 000000000..e3619d2e1 --- /dev/null +++ b/views/default/output/location.php @@ -0,0 +1,14 @@ +location; + unset($vars['entity']); +} + +echo elgg_view('output/tag', $vars); diff --git a/views/default/output/tag.php b/views/default/output/tag.php new file mode 100644 index 000000000..abae9c4b2 --- /dev/null +++ b/views/default/output/tag.php @@ -0,0 +1,30 @@ + $url, 'text' => $vars['value'], 'rel' => 'tag')); +} diff --git a/views/default/output/tags.php b/views/default/output/tags.php index 57cb21ea7..6dedfacc7 100644 --- a/views/default/output/tags.php +++ b/views/default/output/tags.php @@ -10,7 +10,7 @@ */ if (isset($vars['entity'])) { - $defaults['value'] = $vars['entity']->tags; + $vars['tags'] = $vars['entity']->tags; unset($vars['entity']); } -- cgit v1.2.3 From a3a84cec2f5424a9195c38f299161278a623913a Mon Sep 17 00:00:00 2001 From: cash Date: Sat, 11 Jun 2011 14:01:13 +0000 Subject: sorting plugin settings menu items by text git-svn-id: http://code.elgg.org/elgg/trunk@9169 36083f99-b078-4883-b0ff-0f9b5a30f544 --- engine/classes/ElggMenuItem.php | 11 +++++++++++ engine/lib/admin.php | 35 ++++++++++++++++++++++++++++++++++- 2 files changed, 45 insertions(+), 1 deletion(-) (limited to 'engine/lib') diff --git a/engine/classes/ElggMenuItem.php b/engine/classes/ElggMenuItem.php index 61dbf539e..caaba49a1 100644 --- a/engine/classes/ElggMenuItem.php +++ b/engine/classes/ElggMenuItem.php @@ -419,6 +419,17 @@ class ElggMenuItem { $this->children[] = $item; } + /** + * Set the menu item's children + * + * @param array $children Array of ElggMenuItems + * + * @return void + */ + public function setChildren($children) { + $this->children = $children; + } + /** * Get the children menu items * diff --git a/engine/lib/admin.php b/engine/lib/admin.php index 6ef626f81..3bfb69102 100644 --- a/engine/lib/admin.php +++ b/engine/lib/admin.php @@ -211,7 +211,7 @@ function elgg_register_admin_menu_item($section, $menu_id, $parent_id = NULL, $p } /** - * Initialise the admin backend. + * Initialize the admin backend. * * @return void */ @@ -284,6 +284,11 @@ function admin_init() { // plugin settings are added in elgg_admin_add_plugin_settings_menu() via the admin page handler // for performance reasons. + // we want plugin settings menu items to be sorted alphabetical + if (elgg_in_context('admin')) { + elgg_register_plugin_hook_handler('prepare', 'menu:page', 'elgg_admin_sort_page_menu'); + } + if (elgg_is_admin_logged_in()) { elgg_register_menu_item('topbar', array( 'name' => 'administration', @@ -321,6 +326,7 @@ function admin_init() { * * @return void * @access private + * @since 1.8.0 */ function elgg_admin_add_plugin_settings_menu() { @@ -347,6 +353,33 @@ function elgg_admin_add_plugin_settings_menu() { } } +/** + * Sort the plugin settings menu items + * + * @param string $hook + * @param string $type + * @param array $return + * @param array $params + * + * @return void + * @since 1.8.0 + */ +function elgg_admin_sort_page_menu($hook, $type, $return, $params) { + $configure_items = $return['configure']; + foreach ($configure_items as $menu_item) { + if ($menu_item->getName() == 'settings') { + $settings = $menu_item; + } + } + + // keep the basic and advanced settings at the top + $children = $settings->getChildren(); + $site_settings = array_splice($children, 0, 2); + usort($children, array('ElggMenuBuilder', 'compareByText')); + array_splice($children, 0, 0, $site_settings); + $settings->setChildren($children); +} + /** * Handles any set up required for administration pages * -- cgit v1.2.3 From 0e39eac3459d2ff698b51e87a469a2790e510a19 Mon Sep 17 00:00:00 2001 From: cash Date: Sat, 11 Jun 2011 15:56:11 +0000 Subject: Fixes #3515 created a unified page handler for account pages git-svn-id: http://code.elgg.org/elgg/trunk@9175 36083f99-b078-4883-b0ff-0f9b5a30f544 --- engine/classes/ElggSite.php | 2 +- engine/lib/users.php | 60 ++++++++-------------- pages/account/forgotten_password.php | 2 - pages/account/reset_password.php | 35 +++++++++++++ views/default/core/account/login_walled_garden.php | 2 +- views/default/forms/login.php | 2 +- 6 files changed, 58 insertions(+), 45 deletions(-) create mode 100644 pages/account/reset_password.php (limited to 'engine/lib') diff --git a/engine/classes/ElggSite.php b/engine/classes/ElggSite.php index d3cb0d488..30b222c24 100644 --- a/engine/classes/ElggSite.php +++ b/engine/classes/ElggSite.php @@ -400,7 +400,7 @@ class ElggSite extends ElggEntity { 'action/login', 'register', 'action/register', - 'pages/account/forgotten_password\.php', + 'forgotpassword', 'action/user/requestnewpassword', 'resetpassword', 'upgrade\.php', diff --git a/engine/lib/users.php b/engine/lib/users.php index 832bcd529..8333888a2 100644 --- a/engine/lib/users.php +++ b/engine/lib/users.php @@ -747,40 +747,6 @@ function execute_new_password_request($user_guid, $conf_code) { return FALSE; } -/** - * Handles pages for password reset requests. - * - * @param array $page Pages array - * - * @return void - */ -function elgg_user_resetpassword_page_handler($page) { - - $user_guid = get_input('u'); - $code = get_input('c'); - - $user = get_entity($user_guid); - - // don't check code here to avoid automated attacks - if (!$user instanceof ElggUser) { - register_error(elgg_echo('user:passwordreset:unknown_user')); - forward(); - } - - $params = array( - 'guid' => $user_guid, - 'code' => $code, - ); - $form = elgg_view_form('user/passwordreset', array(), $params); - - $title = elgg_echo('resetpassword'); - $content = elgg_view_title(elgg_echo('resetpassword')) . $form; - - $body = elgg_view_layout('one_column', array('content' => $content)); - - echo elgg_view_page($title, $body); -} - /** * Simple function that will generate a random clear text password * suitable for feeding into generate_user_password(). @@ -1129,14 +1095,27 @@ function collections_page_handler($page_elements) { } /** - * Page handler for registration + * Page handler for account related pages * - * @param array $page_elements Page elements + * @param array $page_elements Page elements + * @param string $handler The handler string * * @return void */ -function registration_page_handler($page_elements) { - require_once(dirname(dirname(dirname(__FILE__))) . "/pages/account/register.php"); +function elgg_user_account_page_handler($page_elements, $handler) { + + $base_dir = elgg_get_root_path() . 'pages/account'; + switch ($handler) { + case 'forgotpassword': + require_once("$base_dir/forgotten_password.php"); + break; + case 'resetpassword': + require_once("$base_dir/reset_password.php"); + break; + case 'register': + require_once("$base_dir/register.php"); + break; + } } /** @@ -1513,8 +1492,9 @@ function users_init() { elgg_register_page_handler('friends', 'friends_page_handler'); elgg_register_page_handler('friendsof', 'friends_of_page_handler'); - elgg_register_page_handler('register', 'registration_page_handler'); - elgg_register_page_handler('resetpassword', 'elgg_user_resetpassword_page_handler'); + elgg_register_page_handler('register', 'elgg_user_account_page_handler'); + elgg_register_page_handler('forgotpassword', 'elgg_user_account_page_handler'); + elgg_register_page_handler('resetpassword', 'elgg_user_account_page_handler'); elgg_register_page_handler('login', 'elgg_user_login_page_handler'); elgg_register_page_handler('avatar', 'elgg_avatar_page_handler'); elgg_register_page_handler('profile', 'elgg_profile_page_handler'); diff --git a/pages/account/forgotten_password.php b/pages/account/forgotten_password.php index 93d786e22..7679eaa55 100644 --- a/pages/account/forgotten_password.php +++ b/pages/account/forgotten_password.php @@ -6,8 +6,6 @@ * @subpackage Registration */ -require_once(dirname(dirname(dirname(__FILE__))) . "/engine/start.php"); - if (elgg_is_logged_in()) { forward(); } diff --git a/pages/account/reset_password.php b/pages/account/reset_password.php new file mode 100644 index 000000000..019ec3add --- /dev/null +++ b/pages/account/reset_password.php @@ -0,0 +1,35 @@ + $user_guid, + 'code' => $code, +); +$form = elgg_view_form('user/passwordreset', array(), $params); + +$title = elgg_echo('resetpassword'); +$content = elgg_view_title(elgg_echo('resetpassword')) . $form; + +$body = elgg_view_layout('one_column', array('content' => $content)); + +echo elgg_view_page($title, $body); diff --git a/views/default/core/account/login_walled_garden.php b/views/default/core/account/login_walled_garden.php index 9b5019096..1606b9592 100644 --- a/views/default/core/account/login_walled_garden.php +++ b/views/default/core/account/login_walled_garden.php @@ -6,7 +6,7 @@ */ $reg_url = elgg_normalize_url('register'); -$forgot_url = elgg_normalize_url('pages/account/forgotten_password.php'); +$forgot_url = elgg_normalize_url('forgotpassword'); $cancel_button = elgg_view('input/button', array( 'value' => elgg_echo('cancel'), 'class' => 'elgg-button-cancel mlm', diff --git a/views/default/forms/login.php b/views/default/forms/login.php index 452c4c425..5cfdcd4c6 100644 --- a/views/default/forms/login.php +++ b/views/default/forms/login.php @@ -39,7 +39,7 @@ echo '
  • ' . elgg_echo('register') . '
  • '; } ?> -
  • +
  • \ No newline at end of file -- cgit v1.2.3 From bebc9a864caf99983e28e6d6885a15a9d3b14cd4 Mon Sep 17 00:00:00 2001 From: cash Date: Sat, 11 Jun 2011 19:10:57 +0000 Subject: Fixes #3039 added elgg_delete_river() git-svn-id: http://code.elgg.org/elgg/trunk@9180 36083f99-b078-4883-b0ff-0f9b5a30f544 --- engine/lib/deprecated-1.8.php | 58 ++++++++++++++ engine/lib/river.php | 173 ++++++++++++++++++++++++++++-------------- 2 files changed, 175 insertions(+), 56 deletions(-) (limited to 'engine/lib') diff --git a/engine/lib/deprecated-1.8.php b/engine/lib/deprecated-1.8.php index a04907a6d..d92257a09 100644 --- a/engine/lib/deprecated-1.8.php +++ b/engine/lib/deprecated-1.8.php @@ -4673,3 +4673,61 @@ function elgg_count_comments($entity) { return 0; } + +/** + * Removes all items relating to a particular acting entity from the river + * + * @param int $subject_guid The GUID of the entity + * + * @return bool Depending on success + * @deprecated 1.8 Use elgg_delete_river() + */ +function remove_from_river_by_subject($subject_guid) { + elgg_deprecated_notice("remove_from_river_by_subject() deprecated by elgg_delete_river()", 1.8); + + return elgg_delete_river(array('subject_guid' => $subject_guid)); +} + +/** + * Removes all items relating to a particular entity being acted upon from the river + * + * @param int $object_guid The GUID of the entity + * + * @return bool Depending on success + * @deprecated 1.8 Use elgg_delete_river() + */ +function remove_from_river_by_object($object_guid) { + elgg_deprecated_notice("remove_from_river_by_object() deprecated by elgg_delete_river()", 1.8); + + return elgg_delete_river(array('object_guid' => $object_guid)); +} + +/** + * Removes all items relating to a particular annotation being acted upon from the river + * + * @param int $annotation_id The ID of the annotation + * + * @return bool Depending on success + * @since 1.7.0 + * @deprecated 1.8 Use elgg_delete_river() + */ +function remove_from_river_by_annotation($annotation_id) { + elgg_deprecated_notice("remove_from_river_by_annotation() deprecated by elgg_delete_river()", 1.8); + + return elgg_delete_river(array('annotation_id' => $annotation_id)); +} + +/** + * Removes a single river entry + * + * @param int $id The ID of the river entry + * + * @return bool Depending on success + * @since 1.7.2 + * @deprecated 1.8 Use elgg_delete_river() + */ +function remove_from_river_by_id($id) { + elgg_deprecated_notice("remove_from_river_by_id() deprecated by elgg_delete_river()", 1.8); + + return elgg_delete_river(array('id' => $id)); +} diff --git a/engine/lib/river.php b/engine/lib/river.php index c467a351c..36dde7f05 100644 --- a/engine/lib/river.php +++ b/engine/lib/river.php @@ -98,75 +98,107 @@ $posted = 0, $annotation_id = 0) { } /** - * Removes all items relating to a particular acting entity from the river + * Delete river items * - * @param int $subject_guid The GUID of the entity + * @warning not checking access (should we?) * - * @return bool Depending on success + * @param array $options + * ids => INT|ARR River item id(s) + * subject_guids => INT|ARR Subject guid(s) + * object_guids => INT|ARR Object guid(s) + * annotation_ids => INT|ARR The identifier of the annotation(s) + * action_types => STR|ARR The river action type(s) identifier + * views => STR|ARR River view(s) + * + * types => STR|ARR Entity type string(s) + * subtypes => STR|ARR Entity subtype string(s) + * type_subtype_pairs => ARR Array of type => subtype pairs where subtype + * can be an array of subtype strings + * + * posted_time_lower => INT The lower bound on the time posted + * posted_time_upper => INT The upper bound on the time posted + * + * @return bool + * @since 1.8.0 */ -function remove_from_river_by_subject($subject_guid) { - // Sanitise - $subject_guid = (int) $subject_guid; - - // Load config +function elgg_delete_river(array $options = array()) { global $CONFIG; - // Remove - return delete_data("delete from {$CONFIG->dbprefix}river where subject_guid = {$subject_guid}"); -} + $defaults = array( + 'ids' => ELGG_ENTITIES_ANY_VALUE, -/** - * Removes all items relating to a particular entity being acted upon from the river - * - * @param int $object_guid The GUID of the entity - * - * @return bool Depending on success - */ -function remove_from_river_by_object($object_guid) { - // Sanitise - $object_guid = (int) $object_guid; + 'subject_guids' => ELGG_ENTITIES_ANY_VALUE, + 'object_guids' => ELGG_ENTITIES_ANY_VALUE, + 'annotation_ids' => ELGG_ENTITIES_ANY_VALUE, - // Load config - global $CONFIG; + 'views' => ELGG_ENTITIES_ANY_VALUE, + 'action_types' => ELGG_ENTITIES_ANY_VALUE, - // Remove - return delete_data("delete from {$CONFIG->dbprefix}river where object_guid = {$object_guid}"); -} + 'types' => ELGG_ENTITIES_ANY_VALUE, + 'subtypes' => ELGG_ENTITIES_ANY_VALUE, + 'type_subtype_pairs' => ELGG_ENTITIES_ANY_VALUE, -/** - * Removes all items relating to a particular annotation being acted upon from the river - * - * @param int $annotation_id The ID of the annotation - * - * @return bool Depending on success - * @since 1.7.0 - */ -function remove_from_river_by_annotation($annotation_id) { - // Sanitise - $annotation_id = (int) $annotation_id; + 'posted_time_lower' => ELGG_ENTITIES_ANY_VALUE, + 'posted_time_upper' => ELGG_ENTITIES_ANY_VALUE, - // Load config - global $CONFIG; + 'wheres' => array(), + 'joins' => array(), - // Remove - return delete_data("delete from {$CONFIG->dbprefix}river where annotation_id = {$annotation_id}"); -} + ); -/** - * Removes a single river entry - * - * @param int $id The ID of the river entry - * - * @return bool Depending on success - * @since 1.7.2 - */ -function remove_from_river_by_id($id) { - global $CONFIG; + $options = array_merge($defaults, $options); - // Sanitise - $id = (int) $id; + $singulars = array('id', 'subject_guid', 'object_guid', 'annotation_id', 'action_type', 'view', 'type', 'subtype'); + $options = elgg_normalise_plural_options_array($options, $singulars); + + $wheres = $options['wheres']; + + $wheres[] = elgg_get_guid_based_where_sql('rv.id', $options['ids']); + $wheres[] = elgg_get_guid_based_where_sql('rv.subject_guid', $options['subject_guids']); + $wheres[] = elgg_get_guid_based_where_sql('rv.object_guid', $options['object_guids']); + $wheres[] = elgg_get_guid_based_where_sql('rv.annotation_id', $options['annotation_ids']); + $wheres[] = elgg_river_get_action_where_sql($options['action_types']); + $wheres[] = elgg_river_get_view_where_sql($options['views']); + $wheres[] = elgg_get_river_type_subtype_where_sql('rv', $options['types'], + $options['subtypes'], $options['type_subtype_pairs']); + + if ($options['posted_time_lower'] && is_int($options['posted_time_lower'])) { + $wheres[] = "rv.posted >= {$options['posted_time_lower']}"; + } + + if ($options['posted_time_upper'] && is_int($options['posted_time_upper'])) { + $wheres[] = "rv.posted <= {$options['posted_time_upper']}"; + } + + // remove identical where clauses + $wheres = array_unique($wheres); - return delete_data("delete from {$CONFIG->dbprefix}river where id = {$id}"); + // see if any functions failed + // remove empty strings on successful functions + foreach ($wheres as $i => $where) { + if ($where === FALSE) { + return FALSE; + } elseif (empty($where)) { + unset($wheres[$i]); + } + } + + $query = "DELETE rv.* FROM {$CONFIG->dbprefix}river rv "; + + // add joins + foreach ($joins as $j) { + $query .= " $j "; + } + + // add wheres + $query .= ' WHERE '; + + foreach ($wheres as $w) { + $query .= " $w AND "; + } + $query .= "1=1"; + + return delete_data($query); } /** @@ -482,7 +514,7 @@ function elgg_river_get_action_where_sql($types) { if (!is_array($types)) { $types = sanitise_string($types); - return "'(rv.action_type = '$types')"; + return "(rv.action_type = '$types')"; } // sanitize types array @@ -495,6 +527,35 @@ function elgg_river_get_action_where_sql($types) { return "(rv.action_type IN ('$type_str'))"; } +/** + * Get the where clause based on river view strings + * + * @param array $types Array of view strings + * + * @return string + * @since 1.8.0 + * @access private + */ +function elgg_river_get_view_where_sql($views) { + if (!$views) { + return ''; + } + + if (!is_array($views)) { + $views = sanitise_string($views); + return "(rv.view = '$views')"; + } + + // sanitize views array + $views_sanitized = array(); + foreach ($views as $view) { + $views_sanitized[] = sanitise_string($view); + } + + $view_str = implode("','", $views_sanitized); + return "(rv.view IN ('$view_str'))"; +} + /** * Sets the access ID on river items for a particular object * -- cgit v1.2.3 From 4d11e2d761919130aa572203e303baa0d8fe00d8 Mon Sep 17 00:00:00 2001 From: cash Date: Sat, 11 Jun 2011 20:06:30 +0000 Subject: topbar icons were pushing the site title. Forced the elgg logo and avatar to behave. Adding overflow hidden to the topbar div would prevent future problems but cause issues for those adding drop down menus git-svn-id: http://code.elgg.org/elgg/trunk@9183 36083f99-b078-4883-b0ff-0f9b5a30f544 --- engine/lib/elgglib.php | 3 ++- engine/lib/users.php | 1 + views/default/css/elements/navigation.php | 13 ++++++++++++- 3 files changed, 15 insertions(+), 2 deletions(-) (limited to 'engine/lib') diff --git a/engine/lib/elgglib.php b/engine/lib/elgglib.php index 170750849..08f3d5e7c 100644 --- a/engine/lib/elgglib.php +++ b/engine/lib/elgglib.php @@ -2002,8 +2002,9 @@ function elgg_init() { elgg_register_menu_item('topbar', array( 'name' => 'elgg_logo', 'href' => 'http://www.elgg.org/', - 'text' => "\"Elgg", + 'text' => "\"Elgg", 'priority' => 1, + 'link_class' => 'elgg-topbar-logo', )); // Sets a blacklist of words in the current language. diff --git a/engine/lib/users.php b/engine/lib/users.php index 8333888a2..59bfa1259 100644 --- a/engine/lib/users.php +++ b/engine/lib/users.php @@ -1453,6 +1453,7 @@ function users_pagesetup() { 'href' => $user->getURL(), 'text' => "\"$user-name\" title=\"$title\" class=\"$class\" />", 'priority' => 100, + 'link_class' => 'elgg-topbar-avatar', )); elgg_register_menu_item('topbar', array( diff --git a/views/default/css/elements/navigation.php b/views/default/css/elements/navigation.php index e4709cb27..ff27acd4b 100644 --- a/views/default/css/elements/navigation.php +++ b/views/default/css/elements/navigation.php @@ -130,7 +130,7 @@ } .elgg-menu-topbar > li > a { - padding: 2px 15px; + padding: 2px 15px 0; color: #eee; margin-top: 1px; } @@ -144,6 +144,17 @@ float: right; } +.elgg-menu-topbar > li > a.elgg-topbar-logo { + margin-top: 0; + width: 38px; + height: 20px; +} + +.elgg-menu-topbar > li > a.elgg-topbar-avatar { + width: 18px; + height: 18px; +} + /* *************************************** SITE MENU *************************************** */ -- cgit v1.2.3 From cf30721c8fa78bd9b2d10a387735c0080021b3c5 Mon Sep 17 00:00:00 2001 From: cash Date: Sun, 12 Jun 2011 20:13:30 +0000 Subject: Fixes #3480 not requiring a timestamp when using the js/css page handler git-svn-id: http://code.elgg.org/elgg/trunk@9191 36083f99-b078-4883-b0ff-0f9b5a30f544 --- engine/lib/elgglib.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'engine/lib') diff --git a/engine/lib/elgglib.php b/engine/lib/elgglib.php index 08f3d5e7c..df78515f2 100644 --- a/engine/lib/elgglib.php +++ b/engine/lib/elgglib.php @@ -1789,8 +1789,9 @@ function elgg_cacheable_view_page_handler($page, $type) { // translates to the url /js/calendars/jquery.fullcalendar.min..js // and the view js/calendars/jquery.fullcalendar.min // we ignore the last two dots for the ts and the ext. + // Additionally, the timestamp is optional. $page = implode('/', $page); - $regex = '|(.+)\.([^\.]+)\.([^.]+)$|'; + $regex = '|(.+?)\.([\d]+\.)?\w+$|'; preg_match($regex, $page, $matches); $view = $matches[1]; $return = elgg_view("$type/$view"); -- cgit v1.2.3 From ba88a1c96ab89b4afcc574e3fc8a71df640a9fd8 Mon Sep 17 00:00:00 2001 From: cash Date: Sun, 12 Jun 2011 21:07:49 +0000 Subject: Fixes #2910 set the site_guid of site entities git-svn-id: http://code.elgg.org/elgg/trunk@9192 36083f99-b078-4883-b0ff-0f9b5a30f544 --- engine/classes/ElggSite.php | 9 +++++++ ...8b1-sites_need_a_site_guid-6d9dcbf46c0826cc.php | 30 ++++++++++++++++++++++ version.php | 2 +- 3 files changed, 40 insertions(+), 1 deletion(-) create mode 100644 engine/lib/upgrades/2011061200-1.8b1-sites_need_a_site_guid-6d9dcbf46c0826cc.php (limited to 'engine/lib') diff --git a/engine/classes/ElggSite.php b/engine/classes/ElggSite.php index 30b222c24..e3b8b8f1a 100644 --- a/engine/classes/ElggSite.php +++ b/engine/classes/ElggSite.php @@ -148,11 +148,20 @@ class ElggSite extends ElggEntity { * @return bool */ public function save() { + global $CONFIG; + // Save generic stuff if (!parent::save()) { return false; } + // make sure the site guid is set (if not, set to self) + if (!$this->get('site_guid')) { + $guid = $this->get('guid'); + update_data("UPDATE {$CONFIG->dbprefix}entities SET site_guid=$guid + WHERE guid=$guid"); + } + // Now save specific stuff return create_site_entity($this->get('guid'), $this->get('name'), $this->get('description'), $this->get('url')); diff --git a/engine/lib/upgrades/2011061200-1.8b1-sites_need_a_site_guid-6d9dcbf46c0826cc.php b/engine/lib/upgrades/2011061200-1.8b1-sites_need_a_site_guid-6d9dcbf46c0826cc.php new file mode 100644 index 000000000..4fc59ac41 --- /dev/null +++ b/engine/lib/upgrades/2011061200-1.8b1-sites_need_a_site_guid-6d9dcbf46c0826cc.php @@ -0,0 +1,30 @@ + 'site', + 'site_guid' => 0, +); +$batch = new ElggBatch('elgg_get_entities', $options); + +foreach ($batch as $entity) { + if (!$entity->site_guid) { + update_data("UPDATE {$CONFIG->dbprefix}entities SET site_guid=$entity->guid + WHERE guid=$entity->guid"); + } +} + +access_show_hidden_entities($access_status); +elgg_set_ignore_access($ia); diff --git a/version.php b/version.php index d1cc63aef..9d3bf43e3 100644 --- a/version.php +++ b/version.php @@ -11,7 +11,7 @@ // YYYYMMDD = Elgg Date // XX = Interim incrementer -$version = 2011052801; +$version = 2011061200; // Human-friendly version name $release = '1.8b1'; -- cgit v1.2.3