From 8cca602e2bc1c65b99a2d0c2a60255ab09ca4f3d Mon Sep 17 00:00:00 2001 From: cash Date: Thu, 10 Nov 2011 21:31:39 -0500 Subject: Fixes #4071 hellekin was right - it was a bad idea to format queries --- engine/lib/database.php | 5 ----- 1 file changed, 5 deletions(-) (limited to 'engine/lib') diff --git a/engine/lib/database.php b/engine/lib/database.php index ddfda8f4c..c44fdf1fd 100644 --- a/engine/lib/database.php +++ b/engine/lib/database.php @@ -400,8 +400,6 @@ 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. // http://trac.elgg.org/ticket/4049 @@ -467,7 +465,6 @@ 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'); @@ -499,7 +496,6 @@ 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'); @@ -530,7 +526,6 @@ 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'); -- cgit v1.2.3 From 19f9a2ade78ee4522d3775bdba190a636cf79da5 Mon Sep 17 00:00:00 2001 From: Cash Costello Date: Sat, 12 Nov 2011 09:50:12 -0500 Subject: removed uses of deprecated function for setting page owner guid --- engine/lib/users.php | 4 ++-- mod/groups/actions/groups/edit.php | 2 +- mod/groups/actions/groups/membership/leave.php | 2 +- mod/invitefriends/start.php | 2 +- pages/entities/index.php | 4 ++-- pages/settings/account.php | 2 +- pages/settings/statistics.php | 2 +- 7 files changed, 9 insertions(+), 9 deletions(-) (limited to 'engine/lib') diff --git a/engine/lib/users.php b/engine/lib/users.php index ac507e060..4072740f9 100644 --- a/engine/lib/users.php +++ b/engine/lib/users.php @@ -1088,14 +1088,14 @@ function collections_page_handler($page_elements) { $base = elgg_get_config('path'); if (isset($page_elements[0])) { if ($page_elements[0] == "add") { - set_page_owner(elgg_get_logged_in_user_guid()); + elgg_set_page_owner_guid(elgg_get_logged_in_user_guid()); collections_submenu_items(); require_once "{$base}pages/friends/collections/add.php"; return true; } else { $user = get_user_by_username($page_elements[0]); if ($user) { - 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(); } diff --git a/mod/groups/actions/groups/edit.php b/mod/groups/actions/groups/edit.php index 27f6e0426..c4cf6667e 100644 --- a/mod/groups/actions/groups/edit.php +++ b/mod/groups/actions/groups/edit.php @@ -91,7 +91,7 @@ $group->save(); // group creator needs to be member of new group and river entry created if ($new_group_flag) { - set_page_owner($group->guid); + elgg_set_page_owner_guid($group->guid); $group->join($user); add_to_river('river/group/create', 'create', $user->guid, $group->guid); } diff --git a/mod/groups/actions/groups/membership/leave.php b/mod/groups/actions/groups/membership/leave.php index 390870df1..4f34c7dde 100644 --- a/mod/groups/actions/groups/membership/leave.php +++ b/mod/groups/actions/groups/membership/leave.php @@ -17,7 +17,7 @@ if (!$user_guid) { $group = get_entity($group_guid); -set_page_owner($group->guid); +elgg_set_page_owner_guid($group->guid); if (($user instanceof ElggUser) && ($group instanceof ElggGroup)) { if ($group->getOwnerGUID() != elgg_get_logged_in_user_guid()) { diff --git a/mod/invitefriends/start.php b/mod/invitefriends/start.php index be853f2ce..368f6348a 100644 --- a/mod/invitefriends/start.php +++ b/mod/invitefriends/start.php @@ -33,7 +33,7 @@ function invitefriends_page_handler($page) { gatekeeper(); elgg_set_context('friends'); - set_page_owner(elgg_get_logged_in_user_guid()); + elgg_set_page_owner_guid(elgg_get_logged_in_user_guid()); $title = elgg_echo('friends:invite'); diff --git a/pages/entities/index.php b/pages/entities/index.php index d3b935dc4..e73d65db4 100644 --- a/pages/entities/index.php +++ b/pages/entities/index.php @@ -25,9 +25,9 @@ if ($context) { // Get the entity, if possible if ($entity = get_entity($guid)) { if ($entity->container_guid) { - set_page_owner($entity->container_guid); + elgg_set_page_owner_guid($entity->container_guid); } else { - set_page_owner($entity->owner_guid); + elgg_set_page_owner_guid($entity->owner_guid); } // Set the body to be the full view of the entity, and the title to be its title diff --git a/pages/settings/account.php b/pages/settings/account.php index 1a57f89d8..1bf71973b 100644 --- a/pages/settings/account.php +++ b/pages/settings/account.php @@ -11,7 +11,7 @@ gatekeeper(); // Make sure we don't open a security hole ... if ((!elgg_get_page_owner_entity()) || (!elgg_get_page_owner_entity()->canEdit())) { - set_page_owner(elgg_get_logged_in_user_guid()); + elgg_set_page_owner_guid(elgg_get_logged_in_user_guid()); } $title = elgg_echo('usersettings:user'); diff --git a/pages/settings/statistics.php b/pages/settings/statistics.php index b7394cbe8..9df71ec5e 100644 --- a/pages/settings/statistics.php +++ b/pages/settings/statistics.php @@ -11,7 +11,7 @@ gatekeeper(); // Make sure we don't open a security hole ... if ((!elgg_get_page_owner_entity()) || (!elgg_get_page_owner_entity()->canEdit())) { - set_page_owner(elgg_get_logged_in_user_guid()); + elgg_set_page_owner_guid(elgg_get_logged_in_user_guid()); } $title = elgg_echo("usersettings:statistics"); -- cgit v1.2.3 From 6483d9d446e7fa50e16823fe20514a45416880e2 Mon Sep 17 00:00:00 2001 From: Cash Costello Date: Sun, 13 Nov 2011 16:22:57 -0500 Subject: Fixes #4082 adds output/img --- engine/lib/users.php | 11 ++++++----- mod/bookmarks/views/default/bookmarks/bookmarklet.php | 9 ++++++--- views/default/core/avatar/upload.php | 7 +++++-- views/default/forms/avatar/crop.php | 17 +++++++++++++---- views/default/icon/default.php | 7 +++++-- views/default/icon/user/default.php | 12 +++++++++--- views/default/output/img.php | 12 ++++++++++++ 7 files changed, 56 insertions(+), 19 deletions(-) create mode 100644 views/default/output/img.php (limited to 'engine/lib') diff --git a/engine/lib/users.php b/engine/lib/users.php index 4072740f9..9cb8ddfa7 100644 --- a/engine/lib/users.php +++ b/engine/lib/users.php @@ -1476,14 +1476,15 @@ function users_pagesetup() { // topbar if ($viewer) { - - $icon_url = $viewer->getIconURL('topbar'); - $class = 'elgg-border-plain elgg-transition'; - $title = elgg_echo('profile'); elgg_register_menu_item('topbar', array( 'name' => 'profile', 'href' => $viewer->getURL(), - 'text' => "\"$viewer-name\" title=\"$title\" class=\"$class\" />", + 'text' => elgg_view('output/img', array( + 'src' => $viewer->getIconURL('topbar'), + 'alt' => $viewer->name, + 'title' => elgg_echo('profile'), + 'class' => 'elgg-border-plain elgg-transition', + )), 'priority' => 100, 'link_class' => 'elgg-topbar-avatar', )); diff --git a/mod/bookmarks/views/default/bookmarks/bookmarklet.php b/mod/bookmarks/views/default/bookmarks/bookmarklet.php index 1d0b25498..b3e9737fe 100644 --- a/mod/bookmarks/views/default/bookmarks/bookmarklet.php +++ b/mod/bookmarks/views/default/bookmarks/bookmarklet.php @@ -20,13 +20,16 @@ if (!$name && ($user = elgg_get_logged_in_user_entity())) { } $url = elgg_get_site_url(); - +$img = elgg_view('output/img', array( + 'src' => 'mod/bookmarks/graphics/bookmarklet.gif', + 'alt' => $title, +)); $bookmarklet = "getIconUrl('medium'); +$user_avatar = elgg_view('output/img', array( + 'src' => $vars['entity']->getIconUrl('medium'), + 'alt' => elgg_echo('avatar'), +)); $current_label = elgg_echo('avatar:current'); @@ -23,7 +26,7 @@ $upload_form = elgg_view_form('avatar/upload', $form_params, $vars); $image = <<
- avatar + $user_avatar HTML; diff --git a/views/default/forms/avatar/crop.php b/views/default/forms/avatar/crop.php index f622fd60f..3e798cb27 100644 --- a/views/default/forms/avatar/crop.php +++ b/views/default/forms/avatar/crop.php @@ -9,14 +9,23 @@ elgg_load_js('jquery.imgareaselect'); elgg_load_js('elgg.avatar_cropper'); elgg_load_css('jquery.imgareaselect'); -$master_image = $vars['entity']->getIconUrl('master'); +$master_img = elgg_view('output/img', array( + 'src' => $vars['entity']->getIconUrl('master'), + 'alt' => elgg_echo('avatar'), + 'class' => 'mrl', + 'id' => 'user-avatar-cropper', +)); + +$preview_img = elgg_view('output/img', array( + 'src' => $vars['entity']->getIconUrl('master'), + 'alt' => elgg_echo('avatar'), +)); ?>
- <?php echo elgg_echo('avatar'); ?> +
-
- +
getIconURL($vars['size']); -$img = "\"$title\""; +$img = elgg_view('output/img', array( + 'src' => $entity->getIconURL($vars['size']), + 'alt' => $title, + 'class' => $class, +)); if ($url) { $params = array( diff --git a/views/default/icon/user/default.php b/views/default/icon/user/default.php index a208ec41a..c0b0e7483 100644 --- a/views/default/icon/user/default.php +++ b/views/default/icon/user/default.php @@ -47,7 +47,7 @@ if ($js) { $img_class = ''; if (isset($vars['img_class'])) { - $img_class = "class=\"{$vars['img_class']}\""; + $img_class = $vars['img_class']; } $use_hover = elgg_extract('use_hover', $vars, true); @@ -62,8 +62,14 @@ if (isset($vars['hover'])) { $spacer_url = elgg_get_site_url() . '_graphics/spacer.gif'; -$icon_url = $user->getIconURL($size); -$icon = "\"$name\""; +$icon_url = elgg_format_url($user->getIconURL($size)); +$icon = elgg_view('output/img', array( + 'src' => $spacer_url, + 'alt' => $name, + 'title' => $name, + 'class' => $img_class, + 'style' => "background: url($icon_url) no-repeat;", +)); $show_menu = $use_hover && (elgg_is_admin_logged_in() || !$user->isBanned()); diff --git a/views/default/output/img.php b/views/default/output/img.php new file mode 100644 index 000000000..d3f596801 --- /dev/null +++ b/views/default/output/img.php @@ -0,0 +1,12 @@ +"; -- cgit v1.2.3 From 6ee02beb269d4eac6d24d163fd8b9fbbd0bdab14 Mon Sep 17 00:00:00 2001 From: Cash Costello Date: Tue, 15 Nov 2011 18:51:45 -0500 Subject: Fixes #4090 removes double assignment - thanks to andres.fortier --- engine/lib/relationships.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engine/lib') diff --git a/engine/lib/relationships.php b/engine/lib/relationships.php index 929d3841d..3578f0cb8 100644 --- a/engine/lib/relationships.php +++ b/engine/lib/relationships.php @@ -123,7 +123,7 @@ function check_entity_relationship($guid_one, $relationship, $guid_two) { AND relationship='$relationship' AND guid_two=$guid_two limit 1"; - $row = $row = get_data_row($query); + $row = get_data_row($query); if ($row) { return $row; } -- cgit v1.2.3 From fbbed3deaa0090173d398587cfea4af144d062a2 Mon Sep 17 00:00:00 2001 From: Cash Costello Date: Tue, 15 Nov 2011 20:03:52 -0500 Subject: atleast renaming the ui js libs --- engine/lib/elgglib.php | 8 +-- js/lib/autocomplete.js | 14 ------ js/lib/avatar_cropper.js | 76 ---------------------------- js/lib/friends_picker.js | 91 ---------------------------------- js/lib/ui.autocomplete.js | 14 ++++++ js/lib/ui.avatar_cropper.js | 76 ++++++++++++++++++++++++++++ js/lib/ui.friends_picker.js | 91 ++++++++++++++++++++++++++++++++++ js/lib/ui.userpicker.js | 117 ++++++++++++++++++++++++++++++++++++++++++++ js/lib/userpicker.js | 117 -------------------------------------------- 9 files changed, 302 insertions(+), 302 deletions(-) delete mode 100644 js/lib/autocomplete.js delete mode 100644 js/lib/avatar_cropper.js delete mode 100644 js/lib/friends_picker.js create mode 100644 js/lib/ui.autocomplete.js create mode 100644 js/lib/ui.avatar_cropper.js create mode 100644 js/lib/ui.friends_picker.js create mode 100644 js/lib/ui.userpicker.js delete mode 100644 js/lib/userpicker.js (limited to 'engine/lib') diff --git a/engine/lib/elgglib.php b/engine/lib/elgglib.php index 47ca157e1..08b346960 100644 --- a/engine/lib/elgglib.php +++ b/engine/lib/elgglib.php @@ -2048,12 +2048,12 @@ function elgg_init() { elgg_register_page_handler('css', 'elgg_css_page_handler'); elgg_register_page_handler('ajax', 'elgg_ajax_page_handler'); - elgg_register_js('elgg.autocomplete', 'js/lib/autocomplete.js'); + elgg_register_js('elgg.autocomplete', 'js/lib/ui.autocomplete.js'); elgg_register_js('jquery.ui.autocomplete.html', 'vendors/jquery/jquery.ui.autocomplete.html.js'); - elgg_register_js('elgg.userpicker', 'js/lib/userpicker.js'); - elgg_register_js('elgg.friendspicker', 'js/lib/friends_picker.js'); + elgg_register_js('elgg.userpicker', 'js/lib/ui.userpicker.js'); + elgg_register_js('elgg.friendspicker', 'js/lib/ui.friends_picker.js'); elgg_register_js('jquery.easing', 'vendors/jquery/jquery.easing.1.3.packed.js'); - elgg_register_js('elgg.avatar_cropper', 'js/lib/avatar_cropper.js'); + elgg_register_js('elgg.avatar_cropper', 'js/lib/ui.avatar_cropper.js'); elgg_register_js('jquery.imgareaselect', 'vendors/jquery/jquery.imgareaselect-0.9.8/scripts/jquery.imgareaselect.min.js'); elgg_register_css('jquery.imgareaselect', 'vendors/jquery/jquery.imgareaselect-0.9.8/css/imgareaselect-deprecated.css'); diff --git a/js/lib/autocomplete.js b/js/lib/autocomplete.js deleted file mode 100644 index 46d72d146..000000000 --- a/js/lib/autocomplete.js +++ /dev/null @@ -1,14 +0,0 @@ -/** - * - */ -elgg.provide('elgg.autocomplete'); - -elgg.autocomplete.init = function() { - $('.elgg-input-autocomplete').autocomplete({ - source: elgg.autocomplete.url, //gets set by input/autocomplete view - minLength: 2, - html: "html" - }) -}; - -elgg.register_hook_handler('init', 'system', elgg.autocomplete.init); \ No newline at end of file diff --git a/js/lib/avatar_cropper.js b/js/lib/avatar_cropper.js deleted file mode 100644 index fc32a0832..000000000 --- a/js/lib/avatar_cropper.js +++ /dev/null @@ -1,76 +0,0 @@ -/** - * Avatar cropping - */ - -elgg.provide('elgg.avatarCropper'); - -/** - * Register the avatar cropper. - * - * If the hidden inputs have the coordinates from a previous cropping, begin - * the selection and preview with that displayed. - */ -elgg.avatarCropper.init = function() { - var params = { - selectionOpacity: 0, - aspectRatio: '1:1', - onSelectEnd: elgg.avatarCropper.selectChange, - onSelectChange: elgg.avatarCropper.preview - }; - - if ($('input[name=x2]').val()) { - params.x1 = $('input[name=x1]').val(); - params.x2 = $('input[name=x2]').val(); - params.y1 = $('input[name=y1]').val(); - params.y2 = $('input[name=y2]').val(); - } - - $('#user-avatar-cropper').imgAreaSelect(params); - - if ($('input[name=x2]').val()) { - var ias = $('#user-avatar-cropper').imgAreaSelect({instance: true}); - var selection = ias.getSelection(); - elgg.avatarCropper.preview($('#user-avatar-cropper'), selection); - } -}; - -/** - * Handler for changing select area. - * - * @param {Object} reference to the image - * @param {Object} imgareaselect selection object - * @return void - */ -elgg.avatarCropper.preview = function(img, selection) { - // catch for the first click on the image - if (selection.width == 0 || selection.height == 0) { - return; - } - - var origWidth = $("#user-avatar-cropper").width(); - var origHeight = $("#user-avatar-cropper").height(); - var scaleX = 100 / selection.width; - var scaleY = 100 / selection.height; - $('#user-avatar-preview > img').css({ - width: Math.round(scaleX * origWidth) + 'px', - height: Math.round(scaleY * origHeight) + 'px', - marginLeft: '-' + Math.round(scaleX * selection.x1) + 'px', - marginTop: '-' + Math.round(scaleY * selection.y1) + 'px' - }); -}; - -/** - * Handler for updating the form inputs after select ends - * - * @param {Object} reference to the image - * @param {Object} imgareaselect selection object - * @return void - */ -elgg.avatarCropper.selectChange = function(img, selection) { - $('input[name=x1]').val(selection.x1); - $('input[name=x2]').val(selection.x2); - $('input[name=y1]').val(selection.y1); - $('input[name=y2]').val(selection.y2); -}; - -elgg.register_hook_handler('init', 'system', elgg.avatarCropper.init); \ No newline at end of file diff --git a/js/lib/friends_picker.js b/js/lib/friends_picker.js deleted file mode 100644 index 9257c40fc..000000000 --- a/js/lib/friends_picker.js +++ /dev/null @@ -1,91 +0,0 @@ -/* - elgg friendsPicker plugin - adapted from Niall Doherty's excellent Coda-Slider - http://www.ndoherty.com/coda-slider - */ - - -jQuery.fn.friendsPicker = function(iterator) { - - var settings; - settings = $.extend({ easeFunc: "easeOutExpo", easeTime: 1000, toolTip: false }, settings); - - return this.each(function() { - - var container = $(this); - container.addClass("friends-picker"); - // set panelwidth manually as it's hidden initially - adjust this value for different themes/pagewidths - var panelWidth = 730; - - // count the panels in the container - var panelCount = container.find("div.panel").size(); - // calculate the width of all the panels lined up end-to-end - var friendsPicker_containerWidth = panelWidth*panelCount; - // specify width for the friendsPicker_container - container.find("div.friends-picker-container").css("width" , friendsPicker_containerWidth); - - // global variables for container.each function below - var friendsPickerNavigationWidth = 0; - var currentPanel = 1; - - // generate appropriate nav for each container - container.each(function(i) { - // generate Left and Right arrows - $(this).before("
Left<\/div>"); - $(this).after("
Right<\/div>"); - - // generate a-z tabs - $(this).before("
    <\/ul><\/div>"); - $(this).find("div.panel").each(function(individualTabItemNumber) { - $("div#friends-picker-navigation" + iterator + " ul").append("
  • " + $(this).attr("title") + "<\/a><\/li>"); - }); - - // tabs navigation - $("div#friends-picker-navigation" + iterator + " a").each(function(individualTabItemNumber) { - // calc friendsPickerNavigationWidth by summing width of each li - friendsPickerNavigationWidth += $(this).parent().width(); - // set-up individual tab clicks - $(this).bind("click", function() { - $(this).addClass("current").parent().parent().find("a").not($(this)).removeClass("current"); - var distanceToMoveFriendsPicker_container = - (panelWidth*individualTabItemNumber); - currentPanel = individualTabItemNumber + 1; - $(this).parent().parent().parent().next().find("div.friends-picker-container").animate({ left: distanceToMoveFriendsPicker_container}, settings.easeTime, settings.easeFunc); - }); - }); - - // Right arow click function - $("div#friends-picker-navigation-r" + iterator + " a").click(function() { - if (currentPanel == panelCount) { - var distanceToMoveFriendsPicker_container = 0; - currentPanel = 1; - $(this).parent().parent().find("div.friends-picker-navigation a.current").removeClass("current").parent().parent().find("a:eq(0)").addClass("current"); - } else { - var distanceToMoveFriendsPicker_container = - (panelWidth*currentPanel); - currentPanel += 1; - $(this).parent().parent().find("div.friends-picker-navigation a.current").removeClass("current").parent().next().find("a").addClass("current"); - }; - $(this).parent().parent().find("div.friends-picker-container").animate({ left: distanceToMoveFriendsPicker_container}, settings.easeTime, settings.easeFunc); - return false; - }); - - // Left arrow click function - $("div#friends-picker-navigation-l" + iterator + " a").click(function() { - if (currentPanel == 1) { - var distanceToMoveFriendsPicker_container = - (panelWidth*(panelCount - 1)); - currentPanel = panelCount; - $(this).parent().parent().find("div.friends-picker-navigation a.current").removeClass("current").parent().parent().find("li:last a").addClass("current"); - } else { - currentPanel -= 1; - var distanceToMoveFriendsPicker_container = - (panelWidth*(currentPanel - 1)); - $(this).parent().parent().find("div.friends-picker-navigation a.current").removeClass("current").parent().prev().find("a").addClass("current"); - }; - $(this).parent().parent().find("div.friends-picker-container").animate({ left: distanceToMoveFriendsPicker_container}, settings.easeTime, settings.easeFunc); - return false; - }); - - // apply 'current' class to currently selected tab link - $("div#friends-picker-navigation" + iterator + " a:eq(0)").addClass("current"); - }); - - $("div#friends-picker-navigation" + iterator).append("
    "); - }); -}; \ No newline at end of file diff --git a/js/lib/ui.autocomplete.js b/js/lib/ui.autocomplete.js new file mode 100644 index 000000000..46d72d146 --- /dev/null +++ b/js/lib/ui.autocomplete.js @@ -0,0 +1,14 @@ +/** + * + */ +elgg.provide('elgg.autocomplete'); + +elgg.autocomplete.init = function() { + $('.elgg-input-autocomplete').autocomplete({ + source: elgg.autocomplete.url, //gets set by input/autocomplete view + minLength: 2, + html: "html" + }) +}; + +elgg.register_hook_handler('init', 'system', elgg.autocomplete.init); \ No newline at end of file diff --git a/js/lib/ui.avatar_cropper.js b/js/lib/ui.avatar_cropper.js new file mode 100644 index 000000000..fc32a0832 --- /dev/null +++ b/js/lib/ui.avatar_cropper.js @@ -0,0 +1,76 @@ +/** + * Avatar cropping + */ + +elgg.provide('elgg.avatarCropper'); + +/** + * Register the avatar cropper. + * + * If the hidden inputs have the coordinates from a previous cropping, begin + * the selection and preview with that displayed. + */ +elgg.avatarCropper.init = function() { + var params = { + selectionOpacity: 0, + aspectRatio: '1:1', + onSelectEnd: elgg.avatarCropper.selectChange, + onSelectChange: elgg.avatarCropper.preview + }; + + if ($('input[name=x2]').val()) { + params.x1 = $('input[name=x1]').val(); + params.x2 = $('input[name=x2]').val(); + params.y1 = $('input[name=y1]').val(); + params.y2 = $('input[name=y2]').val(); + } + + $('#user-avatar-cropper').imgAreaSelect(params); + + if ($('input[name=x2]').val()) { + var ias = $('#user-avatar-cropper').imgAreaSelect({instance: true}); + var selection = ias.getSelection(); + elgg.avatarCropper.preview($('#user-avatar-cropper'), selection); + } +}; + +/** + * Handler for changing select area. + * + * @param {Object} reference to the image + * @param {Object} imgareaselect selection object + * @return void + */ +elgg.avatarCropper.preview = function(img, selection) { + // catch for the first click on the image + if (selection.width == 0 || selection.height == 0) { + return; + } + + var origWidth = $("#user-avatar-cropper").width(); + var origHeight = $("#user-avatar-cropper").height(); + var scaleX = 100 / selection.width; + var scaleY = 100 / selection.height; + $('#user-avatar-preview > img').css({ + width: Math.round(scaleX * origWidth) + 'px', + height: Math.round(scaleY * origHeight) + 'px', + marginLeft: '-' + Math.round(scaleX * selection.x1) + 'px', + marginTop: '-' + Math.round(scaleY * selection.y1) + 'px' + }); +}; + +/** + * Handler for updating the form inputs after select ends + * + * @param {Object} reference to the image + * @param {Object} imgareaselect selection object + * @return void + */ +elgg.avatarCropper.selectChange = function(img, selection) { + $('input[name=x1]').val(selection.x1); + $('input[name=x2]').val(selection.x2); + $('input[name=y1]').val(selection.y1); + $('input[name=y2]').val(selection.y2); +}; + +elgg.register_hook_handler('init', 'system', elgg.avatarCropper.init); \ No newline at end of file diff --git a/js/lib/ui.friends_picker.js b/js/lib/ui.friends_picker.js new file mode 100644 index 000000000..9257c40fc --- /dev/null +++ b/js/lib/ui.friends_picker.js @@ -0,0 +1,91 @@ +/* + elgg friendsPicker plugin + adapted from Niall Doherty's excellent Coda-Slider - http://www.ndoherty.com/coda-slider + */ + + +jQuery.fn.friendsPicker = function(iterator) { + + var settings; + settings = $.extend({ easeFunc: "easeOutExpo", easeTime: 1000, toolTip: false }, settings); + + return this.each(function() { + + var container = $(this); + container.addClass("friends-picker"); + // set panelwidth manually as it's hidden initially - adjust this value for different themes/pagewidths + var panelWidth = 730; + + // count the panels in the container + var panelCount = container.find("div.panel").size(); + // calculate the width of all the panels lined up end-to-end + var friendsPicker_containerWidth = panelWidth*panelCount; + // specify width for the friendsPicker_container + container.find("div.friends-picker-container").css("width" , friendsPicker_containerWidth); + + // global variables for container.each function below + var friendsPickerNavigationWidth = 0; + var currentPanel = 1; + + // generate appropriate nav for each container + container.each(function(i) { + // generate Left and Right arrows + $(this).before("
    Left<\/div>"); + $(this).after("
    Right<\/div>"); + + // generate a-z tabs + $(this).before("
      <\/ul><\/div>"); + $(this).find("div.panel").each(function(individualTabItemNumber) { + $("div#friends-picker-navigation" + iterator + " ul").append("
    • " + $(this).attr("title") + "<\/a><\/li>"); + }); + + // tabs navigation + $("div#friends-picker-navigation" + iterator + " a").each(function(individualTabItemNumber) { + // calc friendsPickerNavigationWidth by summing width of each li + friendsPickerNavigationWidth += $(this).parent().width(); + // set-up individual tab clicks + $(this).bind("click", function() { + $(this).addClass("current").parent().parent().find("a").not($(this)).removeClass("current"); + var distanceToMoveFriendsPicker_container = - (panelWidth*individualTabItemNumber); + currentPanel = individualTabItemNumber + 1; + $(this).parent().parent().parent().next().find("div.friends-picker-container").animate({ left: distanceToMoveFriendsPicker_container}, settings.easeTime, settings.easeFunc); + }); + }); + + // Right arow click function + $("div#friends-picker-navigation-r" + iterator + " a").click(function() { + if (currentPanel == panelCount) { + var distanceToMoveFriendsPicker_container = 0; + currentPanel = 1; + $(this).parent().parent().find("div.friends-picker-navigation a.current").removeClass("current").parent().parent().find("a:eq(0)").addClass("current"); + } else { + var distanceToMoveFriendsPicker_container = - (panelWidth*currentPanel); + currentPanel += 1; + $(this).parent().parent().find("div.friends-picker-navigation a.current").removeClass("current").parent().next().find("a").addClass("current"); + }; + $(this).parent().parent().find("div.friends-picker-container").animate({ left: distanceToMoveFriendsPicker_container}, settings.easeTime, settings.easeFunc); + return false; + }); + + // Left arrow click function + $("div#friends-picker-navigation-l" + iterator + " a").click(function() { + if (currentPanel == 1) { + var distanceToMoveFriendsPicker_container = - (panelWidth*(panelCount - 1)); + currentPanel = panelCount; + $(this).parent().parent().find("div.friends-picker-navigation a.current").removeClass("current").parent().parent().find("li:last a").addClass("current"); + } else { + currentPanel -= 1; + var distanceToMoveFriendsPicker_container = - (panelWidth*(currentPanel - 1)); + $(this).parent().parent().find("div.friends-picker-navigation a.current").removeClass("current").parent().prev().find("a").addClass("current"); + }; + $(this).parent().parent().find("div.friends-picker-container").animate({ left: distanceToMoveFriendsPicker_container}, settings.easeTime, settings.easeFunc); + return false; + }); + + // apply 'current' class to currently selected tab link + $("div#friends-picker-navigation" + iterator + " a:eq(0)").addClass("current"); + }); + + $("div#friends-picker-navigation" + iterator).append("
      "); + }); +}; \ No newline at end of file diff --git a/js/lib/ui.userpicker.js b/js/lib/ui.userpicker.js new file mode 100644 index 000000000..8287ba91c --- /dev/null +++ b/js/lib/ui.userpicker.js @@ -0,0 +1,117 @@ +elgg.provide('elgg.userpicker'); + +/** + * Userpicker initialization + * + * The userpicker is an autocomplete library for selecting multiple users or + * friends. It works in concert with the view input/userpicker. + * + * @return void + */ +elgg.userpicker.init = function() { + + // binding autocomplete. + // doing this as an each so we can pass this to functions. + $('.elgg-input-user-picker').each(function() { + + $(this).autocomplete({ + source: function(request, response) { + + var params = elgg.userpicker.getSearchParams(this); + + elgg.get('livesearch', { + data: params, + dataType: 'json', + success: function(data) { + response(data); + } + }); + }, + minLength: 2, + html: "html", + select: elgg.userpicker.addUser + }) + }); + + $('.elgg-userpicker-remove').live('click', elgg.userpicker.removeUser); +}; + +/** + * Adds a user to the select user list + * + * elgg.userpicker.userList is defined in the input/userpicker view + * + * @param {Object} event + * @param {Object} ui The object returned by the autocomplete endpoint + * @return void + */ +elgg.userpicker.addUser = function(event, ui) { + var info = ui.item; + + // do not allow users to be added multiple times + if (!(info.guid in elgg.userpicker.userList)) { + elgg.userpicker.userList[info.guid] = true; + var users = $(this).siblings('.elgg-user-picker-list'); + var li = ''; + li += elgg.userpicker.viewUser(info); + $('
    • ').html(li).appendTo(users); + } + + $(this).val(''); + event.preventDefault(); +}; + +/** + * Remove a user from the selected user list + * + * @param {Object} event + * @return void + */ +elgg.userpicker.removeUser = function(event) { + var item = $(this).closest('.elgg-user-picker-list > li'); + + var guid = item.find('[name="members[]"]').val(); + delete elgg.userpicker.userList[guid]; + + item.remove(); + event.preventDefault(); +}; + +/** + * Render the list item for insertion into the selected user list + * + * The html in this method has to remain synced with the input/userpicker view + * + * @param {Object} info The object returned by the autocomplete endpoint + * @return string + */ +elgg.userpicker.viewUser = function(info) { + + var deleteLink = "X"; + + var html = "
      "; + html += "
      " + info.icon + "
      "; + html += "
      " + deleteLink + "
      "; + html += "
      " + info.name + "
      "; + html += "'; - li += elgg.userpicker.viewUser(info); - $('
    • ').html(li).appendTo(users); - } - - $(this).val(''); - event.preventDefault(); -}; - -/** - * Remove a user from the selected user list - * - * @param {Object} event - * @return void - */ -elgg.userpicker.removeUser = function(event) { - var item = $(this).closest('.elgg-user-picker-list > li'); - - var guid = item.find('[name="members[]"]').val(); - delete elgg.userpicker.userList[guid]; - - item.remove(); - event.preventDefault(); -}; - -/** - * Render the list item for insertion into the selected user list - * - * The html in this method has to remain synced with the input/userpicker view - * - * @param {Object} info The object returned by the autocomplete endpoint - * @return string - */ -elgg.userpicker.viewUser = function(info) { - - var deleteLink = "X"; - - var html = "
      "; - html += "
      " + info.icon + "
      "; - html += "
      " + deleteLink + "
      "; - html += "
      " + info.name + "
      "; - html += " Date: Fri, 18 Nov 2011 06:42:45 -0500 Subject: Fixes #4108 delete() returns bool now and updated unit tests --- engine/lib/entities.php | 2 +- engine/tests/objects/entities.php | 2 +- engine/tests/objects/sites.php | 6 ++++-- engine/tests/objects/users.php | 2 +- 4 files changed, 7 insertions(+), 5 deletions(-) (limited to 'engine/lib') diff --git a/engine/lib/entities.php b/engine/lib/entities.php index fd2b0e9f9..d8db88462 100644 --- a/engine/lib/entities.php +++ b/engine/lib/entities.php @@ -1563,7 +1563,7 @@ function delete_entity($guid, $recursive = true) { } } - return $res; + return (bool)$res; } } } diff --git a/engine/tests/objects/entities.php b/engine/tests/objects/entities.php index 06bc80a4a..1772f7c1a 100644 --- a/engine/tests/objects/entities.php +++ b/engine/tests/objects/entities.php @@ -178,7 +178,7 @@ class ElggCoreEntityTest extends ElggCoreUnitTest { $this->AssertEqual($this->entity->get('non_existent'), 'testing'); // clean up with delete - $this->assertTrue($this->entity->delete()); + $this->assertIdentical(true, $this->entity->delete()); } public function testElggEntityDisableAndEnable() { diff --git a/engine/tests/objects/sites.php b/engine/tests/objects/sites.php index e5acbb3f9..a05074c59 100644 --- a/engine/tests/objects/sites.php +++ b/engine/tests/objects/sites.php @@ -66,8 +66,10 @@ class ElggCoreSiteTest extends ElggCoreUnitTest { } public function testElggSiteSaveAndDelete() { - $this->assertTrue($this->site->save()); - $this->assertTrue($this->site->delete()); + $guid = $this->site->save(); + $this->assertIsA($guid, 'int'); + $this->assertTrue($guid > 0); + $this->assertIdentical(true, $this->site->delete()); } } diff --git a/engine/tests/objects/users.php b/engine/tests/objects/users.php index d1533c3d2..901d76ac0 100644 --- a/engine/tests/objects/users.php +++ b/engine/tests/objects/users.php @@ -138,7 +138,7 @@ class ElggCoreUserTest extends ElggCoreUnitTest { $guid = $this->user->save(); // delete object - $this->assertTrue($this->user->delete()); + $this->assertIdentical(true, $this->user->delete()); // check GUID not in database $this->assertFalse($this->fetchUser($guid)); -- cgit v1.2.3 From 597641b401a73d6d5cd7f35f052095105bd2fb22 Mon Sep 17 00:00:00 2001 From: cash Date: Fri, 18 Nov 2011 17:15:02 -0500 Subject: Fixes #4112 get_user_by_username() returns false if no user --- engine/lib/users.php | 2 ++ 1 file changed, 2 insertions(+) (limited to 'engine/lib') diff --git a/engine/lib/users.php b/engine/lib/users.php index 9cb8ddfa7..29fa4db2f 100644 --- a/engine/lib/users.php +++ b/engine/lib/users.php @@ -565,6 +565,8 @@ function get_user_by_username($username) { $entity = get_data_row($query, 'entity_row_to_elggstar'); if ($entity) { $USERNAME_TO_GUID_MAP_CACHE[$username] = $entity->guid; + } else { + $entity = false; } return $entity; -- cgit v1.2.3 From 3d975e028c3d5bde2ee8a5c9e09d7650b8f3c505 Mon Sep 17 00:00:00 2001 From: cash Date: Fri, 18 Nov 2011 17:41:58 -0500 Subject: Fixes #4113 returning a bool from delete_access_collection() --- engine/lib/access.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'engine/lib') diff --git a/engine/lib/access.php b/engine/lib/access.php index 97f744fb9..ba3820f46 100644 --- a/engine/lib/access.php +++ b/engine/lib/access.php @@ -610,8 +610,7 @@ function delete_access_collection($collection_id) { WHERE id = {$collection_id}"; $result = delete_data($q); - - return $result; + return (bool)$result; } /** -- cgit v1.2.3 From 15f02eea51f0f0eb92e427b627324d58af166e5e Mon Sep 17 00:00:00 2001 From: cash Date: Fri, 18 Nov 2011 17:44:45 -0500 Subject: Fixes #4115 returning bool from remove_user_from_access_collection() --- engine/lib/access.php | 2 +- engine/tests/api/access_collections.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'engine/lib') diff --git a/engine/lib/access.php b/engine/lib/access.php index ba3820f46..08b9283cd 100644 --- a/engine/lib/access.php +++ b/engine/lib/access.php @@ -717,7 +717,7 @@ function remove_user_from_access_collection($user_guid, $collection_id) { WHERE access_collection_id = {$collection_id} AND user_guid = {$user_guid}"; - return delete_data($q); + return (bool)delete_data($q); } /** diff --git a/engine/tests/api/access_collections.php b/engine/tests/api/access_collections.php index 7875b1409..bea995a6e 100644 --- a/engine/tests/api/access_collections.php +++ b/engine/tests/api/access_collections.php @@ -88,7 +88,7 @@ class ElggCoreAccessCollectionsTest extends ElggCoreUnitTest { if ($result) { $result = remove_user_from_access_collection($this->user->guid, $acl_id); - $this->assertTrue($result); + $this->assertIdentical(true, $result); } delete_access_collection($acl_id); -- cgit v1.2.3 From 30630b3a25e37430d966af6e6af933b7d000ab1a Mon Sep 17 00:00:00 2001 From: cash Date: Fri, 18 Nov 2011 17:50:36 -0500 Subject: Fixes #4118 returning bool from leave group functions --- engine/classes/ElggGroup.php | 6 +++--- engine/lib/relationships.php | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'engine/lib') diff --git a/engine/classes/ElggGroup.php b/engine/classes/ElggGroup.php index 49ba27204..5c16e978f 100644 --- a/engine/classes/ElggGroup.php +++ b/engine/classes/ElggGroup.php @@ -309,7 +309,7 @@ class ElggGroup extends ElggEntity * * @param ElggUser $user User * - * @return void + * @return bool */ public function leave(ElggUser $user) { return leave_group($this->getGUID(), $user->getGUID()); @@ -322,7 +322,7 @@ class ElggGroup extends ElggEntity * * @param int $guid GUID of an ElggGroup entity * - * @return true + * @return bool */ protected function load($guid) { // Test to see if we have the generic stuff @@ -340,7 +340,7 @@ class ElggGroup extends ElggEntity $row = get_group_entity_as_row($guid); if (($row) && (!$this->isFullyLoaded())) { // If $row isn't a cached copy then increment the counter - $this->attributes['tables_loaded'] ++; + $this->attributes['tables_loaded']++; } // Now put these into the attributes array as core values diff --git a/engine/lib/relationships.php b/engine/lib/relationships.php index 3578f0cb8..5b7080b56 100644 --- a/engine/lib/relationships.php +++ b/engine/lib/relationships.php @@ -158,7 +158,7 @@ function remove_entity_relationship($guid_one, $relationship, $guid_two) { and relationship='$relationship' and guid_two=$guid_two"; - return delete_data($query); + return (bool)delete_data($query); } else { return false; } -- cgit v1.2.3 From f3b50d11966eb75c648e317ab11045913e28e56a Mon Sep 17 00:00:00 2001 From: cash Date: Fri, 18 Nov 2011 18:02:39 -0500 Subject: Fixes #4131 elgg_delete_metastring_based_object_by_id() should return a bool --- engine/lib/metastrings.php | 2 +- engine/tests/api/metastrings.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'engine/lib') diff --git a/engine/lib/metastrings.php b/engine/lib/metastrings.php index 9dccec700..9fe9b4bff 100644 --- a/engine/lib/metastrings.php +++ b/engine/lib/metastrings.php @@ -810,7 +810,7 @@ function elgg_delete_metastring_based_object_by_id($id, $type) { } if (($obj->canEdit()) && (elgg_trigger_event('delete', $type, $obj))) { - return delete_data("DELETE from $table where id=$id"); + return (bool)delete_data("DELETE from $table where id=$id"); } } diff --git a/engine/tests/api/metastrings.php b/engine/tests/api/metastrings.php index 0a008c6ce..f6870d34b 100644 --- a/engine/tests/api/metastrings.php +++ b/engine/tests/api/metastrings.php @@ -80,7 +80,7 @@ class ElggCoreMetastringsTest extends ElggCoreUnitTest { $test = get_data($q); $this->assertEqual($test[0]->id, $id); - $this->assertTrue(elgg_delete_metastring_based_object_by_id($id, $type)); + $this->assertIdentical(true, elgg_delete_metastring_based_object_by_id($id, $type)); $this->assertFalse(get_data($q)); } } -- cgit v1.2.3 From 75c00c55dd9cc2de4d97f829d9b47c99eb4ba287 Mon Sep 17 00:00:00 2001 From: cash Date: Fri, 18 Nov 2011 22:40:04 -0500 Subject: Fixes #3792 admin can edit settings again --- engine/lib/user_settings.php | 4 ++-- engine/lib/users.php | 5 +++++ languages/en.php | 1 + 3 files changed, 8 insertions(+), 2 deletions(-) (limited to 'engine/lib') diff --git a/engine/lib/user_settings.php b/engine/lib/user_settings.php index 1e2d6db10..c71670357 100644 --- a/engine/lib/user_settings.php +++ b/engine/lib/user_settings.php @@ -265,8 +265,8 @@ function elgg_set_user_default_access() { * @access private */ function usersettings_pagesetup() { - if (elgg_get_context() == "settings" && elgg_get_logged_in_user_guid()) { - $user = elgg_get_logged_in_user_entity(); + if (elgg_get_context() == "settings") { + $user = elgg_get_page_owner_entity(); $params = array( 'name' => '1_account', diff --git a/engine/lib/users.php b/engine/lib/users.php index 29fa4db2f..3a86c1faa 100644 --- a/engine/lib/users.php +++ b/engine/lib/users.php @@ -1283,6 +1283,11 @@ function elgg_user_hover_menu($hook, $type, $return, $params) { $item = new ElggMenuItem('profile:edit', elgg_echo('profile:edit'), $url); $item->setSection('admin'); $return[] = $item; + + $url = "settings/user/$user->username"; + $item = new ElggMenuItem('settings:edit', elgg_echo('settings:edit'), $url); + $item->setSection('admin'); + $return[] = $item; } return $return; diff --git a/languages/en.php b/languages/en.php index 5964580ad..af97e112d 100644 --- a/languages/en.php +++ b/languages/en.php @@ -481,6 +481,7 @@ $english = array( 'account' => "Account", 'settings' => "Settings", 'tools' => "Tools", + 'settings:edit' => 'Edit settings', 'register' => "Register", 'registerok' => "You have successfully registered for %s.", -- cgit v1.2.3 From ddd7872bdfb68369d0e0e1b0401a8640b08bfc7c Mon Sep 17 00:00:00 2001 From: cash Date: Wed, 23 Nov 2011 11:09:42 -0500 Subject: Refs #4143 adds a unit test for type/subtype where sql generation --- engine/lib/river.php | 12 ++++++++++++ pages/river.php | 1 - 2 files changed, 12 insertions(+), 1 deletion(-) (limited to 'engine/lib') diff --git a/engine/lib/river.php b/engine/lib/river.php index 466eca253..309aeb30f 100644 --- a/engine/lib/river.php +++ b/engine/lib/river.php @@ -610,6 +610,16 @@ function elgg_river_page_handler($page) { return true; } +/** + * Register river unit tests + * @access private + */ +function elgg_river_test($hook, $type, $value) { + global $CONFIG; + $value[] = $CONFIG->path . 'engine/tests/api/river.php'; + return $value; +} + /** * Initialize river library * @access private @@ -620,6 +630,8 @@ function elgg_river_init() { elgg_register_menu_item('site', $item); elgg_register_widget_type('river_widget', elgg_echo('river:widget:title'), elgg_echo('river:widget:description')); + + elgg_register_plugin_hook_handler('unit_test', 'system', 'elgg_river_test'); } elgg_register_event_handler('init', 'system', 'elgg_river_init'); diff --git a/pages/river.php b/pages/river.php index 5770084ab..601faf16f 100644 --- a/pages/river.php +++ b/pages/river.php @@ -7,7 +7,6 @@ $options = array(); $page_type = preg_replace('[\W]', '', get_input('page_type', 'all')); $type = preg_replace('[\W]', '', get_input('type', 'all')); -$active_section = $subtype = preg_replace('[\W]', '', get_input('subtype', '')); if ($subtype) { $selector = "type=$type&subtype=$subtype"; -- cgit v1.2.3 From 583e52700ca5c7ed1d0dd58054dbd08208c0c158 Mon Sep 17 00:00:00 2001 From: Danny Navarro Date: Thu, 17 Nov 2011 14:17:24 +0100 Subject: Refs #3496 improving type/subtype handling for the river --- engine/lib/river.php | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) (limited to 'engine/lib') diff --git a/engine/lib/river.php b/engine/lib/river.php index 309aeb30f..02d52dea1 100644 --- a/engine/lib/river.php +++ b/engine/lib/river.php @@ -447,7 +447,8 @@ function elgg_get_river_type_subtype_where_sql($table, $types, $subtypes, $pairs return ''; } - $wheres = array(); + $types_wheres = array(); + $subtypes_wheres = array(); // if no pairs, use types and subtypes if (!is_array($pairs)) { @@ -457,7 +458,7 @@ function elgg_get_river_type_subtype_where_sql($table, $types, $subtypes, $pairs } foreach ($types as $type) { $type = sanitise_string($type); - $wheres[] = "({$table}.type = '$type')"; + $types_wheres[] = "({$table}.type = '$type')"; } } @@ -467,13 +468,20 @@ function elgg_get_river_type_subtype_where_sql($table, $types, $subtypes, $pairs } foreach ($subtypes as $subtype) { $subtype = sanitise_string($subtype); - $wheres[] = "({$table}.subtype = '$subtype')"; + $subtypes_wheres[] = "({$table}.subtype = '$subtype')"; } } - if (is_array($wheres) && count($wheres)) { - $wheres = array(implode(' OR ', $wheres)); + if (is_array($types_wheres) && count($types_wheres)) { + $types_wheres = array(implode(' OR ', $types_wheres)); } + + if (is_array($subtypes_wheres) && count($subtypes_wheres)) { + $subtypes_wheres = array(implode(' OR ', $subtypes_wheres)); + } + + $wheres = array(implode(' AND ', array_merge($types_wheres, $subtypes_wheres))); + } else { // using type/subtype pairs foreach ($pairs as $paired_type => $paired_subtypes) { -- cgit v1.2.3 From 3d9b7cc539d390043f1c28d1776dc97e591f5d87 Mon Sep 17 00:00:00 2001 From: Cash Costello Date: Fri, 25 Nov 2011 13:49:17 -0500 Subject: added a better message for php libraries that don't exist on disk --- engine/lib/elgglib.php | 5 ++++- languages/en.php | 1 + 2 files changed, 5 insertions(+), 1 deletion(-) (limited to 'engine/lib') diff --git a/engine/lib/elgglib.php b/engine/lib/elgglib.php index 08b346960..57d602450 100644 --- a/engine/lib/elgglib.php +++ b/engine/lib/elgglib.php @@ -107,7 +107,10 @@ function elgg_load_library($name) { } if (!include_once($CONFIG->libraries[$name])) { - $error = elgg_echo('InvalidParameterException:LibraryNotRegistered', array($name)); + $error = elgg_echo('InvalidParameterException:LibraryNotFound', array( + $name, + $CONFIG->libraries[$name]) + ); throw new InvalidParameterException($error); } } diff --git a/languages/en.php b/languages/en.php index 1576ed73d..036ca8883 100644 --- a/languages/en.php +++ b/languages/en.php @@ -167,6 +167,7 @@ $english = array( 'InvalidParameterException:DoesNotBelongOrRefer' => "Does not belong to entity or refer to entity.", 'InvalidParameterException:MissingParameter' => "Missing parameter, you need to provide a GUID.", 'InvalidParameterException:LibraryNotRegistered' => '%s is not a registered library', + 'InvalidParameterException:LibraryNotFound' => 'Could not load the %s library from %s', 'APIException:ApiResultUnknown' => "API Result is of an unknown type, this should never happen.", 'ConfigurationException:NoSiteID' => "No site ID has been specified.", -- cgit v1.2.3 From 3a0043a94076ff8c3f0dc4ac3e195763cb3fc2b5 Mon Sep 17 00:00:00 2001 From: Cash Costello Date: Sun, 27 Nov 2011 18:37:33 -0500 Subject: fixed some documentation related to subtypes --- engine/lib/entities.php | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) (limited to 'engine/lib') diff --git a/engine/lib/entities.php b/engine/lib/entities.php index d8db88462..f7ae108ed 100644 --- a/engine/lib/entities.php +++ b/engine/lib/entities.php @@ -124,8 +124,6 @@ function retrieve_cached_entity_row($guid) { * @internal Subtypes are stored in the entity_subtypes table. There is a foreign * key in the entities table. * - * @todo Move to a nicer place? - * * @param string $type Type * @param string $subtype Subtype * @@ -144,7 +142,7 @@ function get_subtype_id($type, $subtype) { return FALSE; } - // Todo: cache here? Or is looping less efficient that going to the db each time? + // @todo use the cache before hitting database $result = get_data_row("SELECT * from {$CONFIG->dbprefix}entity_subtypes where type='$type' and subtype='$subtype'"); @@ -163,8 +161,6 @@ function get_subtype_id($type, $subtype) { /** * Return string name for a given subtype ID. * - * @todo Move to a nicer place? - * * @param int $subtype_id Subtype ID * * @return string Subtype name @@ -199,11 +195,11 @@ function get_subtype_from_id($subtype_id) { } /** - * Return a classname for a registered type and subtype. + * Return the class name for a registered type and subtype. * * Entities can be registered to always be loaded as a certain class - * with {@link register_entity_subtype()}. This function returns - * the class name if found, and NULL if not. + * with add_subtype() or update_subtype(). This function returns the class + * name if found and NULL if not. * * @param string $type The type * @param string $subtype The subtype @@ -219,7 +215,7 @@ function get_subtype_class($type, $subtype) { $type = sanitise_string($type); $subtype = sanitise_string($subtype); - // Todo: cache here? Or is looping less efficient that going to the db each time? + // @todo use the cache before going to the database $result = get_data_row("SELECT * from {$CONFIG->dbprefix}entity_subtypes where type='$type' and subtype='$subtype'"); @@ -236,7 +232,7 @@ function get_subtype_class($type, $subtype) { } /** - * Returns the classname for a subtype id. + * Returns the class name for a subtype id. * * @param int $subtype_id The subtype id * @@ -279,6 +275,9 @@ function get_subtype_class_from_id($subtype_id) { * it will be loaded as that class automatically when retrieved from the database with * {@link get_entity()}. * + * @warning This function cannot be used to change the class for a type-subtype pair. + * Use update_subtype() for that. + * * @param string $type The type you're subtyping (site, user, object, or group) * @param string $subtype The subtype * @param string $class Optional class name for the object -- cgit v1.2.3 From 6cc08f83225237d0cd57e0a5c0ebec0a8327aa30 Mon Sep 17 00:00:00 2001 From: cash Date: Mon, 28 Nov 2011 21:24:42 -0500 Subject: Fixes #3496 finished up this ticket by updating unit test and using more parantheses to make it clear how the OR/AND gets applied --- engine/lib/river.php | 5 +++-- engine/tests/api/river.php | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) (limited to 'engine/lib') diff --git a/engine/lib/river.php b/engine/lib/river.php index 02d52dea1..421813441 100644 --- a/engine/lib/river.php +++ b/engine/lib/river.php @@ -207,6 +207,8 @@ function elgg_delete_river(array $options = array()) { /** * Get river items * + * @note If using types and subtypes in a query, they are joined with an AND. + * * @param array $options * ids => INT|ARR River item id(s) * subject_guids => INT|ARR Subject guid(s) @@ -430,7 +432,6 @@ function elgg_river_get_access_sql() { * * @internal This is a simplified version of elgg_get_entity_type_subtype_where_sql() * which could be used for all queries once the subtypes have been denormalized. - * FYI: It allows types and subtypes to not be paired. * * @param string $table 'rv' * @param NULL|array $types Array of types or NULL if none. @@ -477,7 +478,7 @@ function elgg_get_river_type_subtype_where_sql($table, $types, $subtypes, $pairs } if (is_array($subtypes_wheres) && count($subtypes_wheres)) { - $subtypes_wheres = array(implode(' OR ', $subtypes_wheres)); + $subtypes_wheres = array('(' . implode(' OR ', $subtypes_wheres) . ')'); } $wheres = array(implode(' AND ', array_merge($types_wheres, $subtypes_wheres))); diff --git a/engine/tests/api/river.php b/engine/tests/api/river.php index 55ddbfeec..6931b9f41 100644 --- a/engine/tests/api/river.php +++ b/engine/tests/api/river.php @@ -11,7 +11,7 @@ class ElggCoreRiverAPITest extends ElggCoreUnitTest { $types = array('object'); $subtypes = array('blog'); $result = elgg_get_river_type_subtype_where_sql('rv', $types, $subtypes, null); - $this->assertIdentical($result, "((rv.type = 'object') AND (rv.subtype = 'blog'))"); + $this->assertIdentical($result, "((rv.type = 'object') AND ((rv.subtype = 'blog')))"); $types = array('object'); $subtypes = array('blog', 'file'); -- cgit v1.2.3 From e57ad78561dd4e80eb3621475aaade030c0fbdd0 Mon Sep 17 00:00:00 2001 From: Jeff Tilson Date: Fri, 25 Nov 2011 18:11:12 -0500 Subject: Need to call elgg_register_simplecache_view('css/lightbox') to register the lightbox CSS with simplecache --- engine/lib/views.php | 1 + 1 file changed, 1 insertion(+) (limited to 'engine/lib') diff --git a/engine/lib/views.php b/engine/lib/views.php index 0f806b8be..d3c9ff551 100644 --- a/engine/lib/views.php +++ b/engine/lib/views.php @@ -1602,6 +1602,7 @@ function elgg_views_boot() { elgg_load_js('elgg'); elgg_register_simplecache_view('js/lightbox'); + elgg_register_simplecache_view('css/lightbox'); $lightbox_js_url = elgg_get_simplecache_url('js', 'lightbox'); elgg_register_js('lightbox', $lightbox_js_url); $lightbox_css_url = elgg_get_simplecache_url('css', 'lightbox'); -- cgit v1.2.3 From 8e7dfcc5146f1cb22e684a9cdb635bbac184d6a1 Mon Sep 17 00:00:00 2001 From: cash Date: Sat, 3 Dec 2011 20:04:01 -0500 Subject: Refs #4176 added elgg_list_registered_entities() fix to 1.8 branch --- engine/lib/entities.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'engine/lib') diff --git a/engine/lib/entities.php b/engine/lib/entities.php index f7ae108ed..dbb5ee695 100644 --- a/engine/lib/entities.php +++ b/engine/lib/entities.php @@ -2147,8 +2147,13 @@ function elgg_list_registered_entities(array $options = array()) { } } - $count = elgg_get_entities(array_merge(array('count' => TRUE), $options)); - $entities = elgg_get_entities($options); + if (!empty($options['type_subtype_pairs'])) { + $count = elgg_get_entities(array_merge(array('count' => TRUE), $options)); + $entities = elgg_get_entities($options); + } else { + $count = 0; + $entities = array(); + } return elgg_view_entity_list($entities, $count, $options['offset'], $options['limit'], $options['full_view'], $options['list_type_toggle'], $options['pagination']); -- cgit v1.2.3 From c2cddede38dbb29d53167e296981a678759e0648 Mon Sep 17 00:00:00 2001 From: cash Date: Mon, 5 Dec 2011 21:54:09 -0500 Subject: first version of a 404 page --- engine/lib/pagehandler.php | 31 +++++++++++++++++++++++++++++++ languages/en.php | 3 +++ views/default/errors/404.php | 8 ++++++++ views/default/errors/default.php | 8 ++++++++ views/default/page/error.php | 14 ++++++++++++++ views/default/page/layouts/error.php | 6 ++++++ 6 files changed, 70 insertions(+) create mode 100644 views/default/errors/404.php create mode 100644 views/default/errors/default.php create mode 100644 views/default/page/error.php create mode 100644 views/default/page/layouts/error.php (limited to 'engine/lib') diff --git a/engine/lib/pagehandler.php b/engine/lib/pagehandler.php index aba921416..16be6e3b2 100644 --- a/engine/lib/pagehandler.php +++ b/engine/lib/pagehandler.php @@ -110,3 +110,34 @@ function elgg_unregister_page_handler($handler) { unset($CONFIG->pagehandler[$handler]); } + +/** + * Serve an error page + * + * @param string $hook The name of the hook + * @param string $type The type of the hook + * @param bool $result The current value of the hook + * @param array $params Parameters related to the hook + */ +function elgg_error_page_handler($hook, $type, $result, $params) { + if (elgg_view_exists("errors/$type")) { + $content = elgg_view("errors/$type", $params); + } else { + $content = elgg_view("errors/default", $params); + } + $body = elgg_view_layout('error', array('content' => $content)); + echo elgg_view_page($title, $body, 'error'); + exit; +} + +/** + * Initializes the page handler/routing system + * + * @return void + * @access private + */ +function page_handler_init() { + elgg_register_plugin_hook_handler('forward', '404', 'elgg_error_page_handler'); +} + +elgg_register_event_handler('init', 'system', 'page_handler_init'); diff --git a/languages/en.php b/languages/en.php index 036ca8883..eecb2f1aa 100644 --- a/languages/en.php +++ b/languages/en.php @@ -240,6 +240,9 @@ $english = array( 'changebookmark' => 'Please change your bookmark for this page', 'noaccess' => 'This content has been removed, is invalid, or you do not have permission to view it.', + 'error:default' => 'Oops...something went wrong.', + 'error:404' => 'Sorry. We could not find the page that you requested.', + /** * API */ diff --git a/views/default/errors/404.php b/views/default/errors/404.php new file mode 100644 index 000000000..8bc35acdd --- /dev/null +++ b/views/default/errors/404.php @@ -0,0 +1,8 @@ +$message"; diff --git a/views/default/errors/default.php b/views/default/errors/default.php new file mode 100644 index 000000000..a0582eba2 --- /dev/null +++ b/views/default/errors/default.php @@ -0,0 +1,8 @@ +$message"; diff --git a/views/default/page/error.php b/views/default/page/error.php new file mode 100644 index 000000000..b7ba3ae9b --- /dev/null +++ b/views/default/page/error.php @@ -0,0 +1,14 @@ + Date: Tue, 6 Dec 2011 22:05:48 -0500 Subject: Fixes #4173 removed use of \w since it is locale sensitive --- engine/lib/output.php | 3 +++ 1 file changed, 3 insertions(+) (limited to 'engine/lib') diff --git a/engine/lib/output.php b/engine/lib/output.php index 60bcc72cd..989eca60e 100644 --- a/engine/lib/output.php +++ b/engine/lib/output.php @@ -306,6 +306,9 @@ function elgg_get_friendly_title($title) { } //$title = iconv('UTF-8', 'ASCII//TRANSLIT', $title); + + // use A-Za-z0-9_ instead of \w because \w is locale sensitive + $title = preg_replace("/[^A-Za-z0-9_ ]/", "", $title); $title = preg_replace("/[^\w ]/", "", $title); $title = str_replace(" ", "-", $title); $title = str_replace("--", "-", $title); -- cgit v1.2.3 From 7591e47ca63159e6324090bde7063ba53af8bfe6 Mon Sep 17 00:00:00 2001 From: Janek Lasocki-Biczysko Date: Tue, 6 Dec 2011 11:15:14 +0000 Subject: #4187 (get_entity optimization) --- engine/lib/entities.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'engine/lib') diff --git a/engine/lib/entities.php b/engine/lib/entities.php index dbb5ee695..daced6740 100644 --- a/engine/lib/entities.php +++ b/engine/lib/entities.php @@ -669,7 +669,10 @@ function get_entity($guid) { static $newentity_cache; $new_entity = false; - if (!is_numeric($guid)) { + // We could also use: if (!(int) $guid) { return FALSE }, + // but that evaluates to a false positive for $guid = TRUE. + // This is a bit slower, but more thorough. + if (!is_numeric($guid) || $guid === 0 || $guid === '0') { return FALSE; } -- cgit v1.2.3 From 1ec7692c1639e8415cd9984d9ad040ec28bd9755 Mon Sep 17 00:00:00 2001 From: cash Date: Thu, 8 Dec 2011 20:09:36 -0500 Subject: Fixes #4185, #2111 adds control panel widget --- actions/admin/site/flush_cache.php | 10 ++++++++++ engine/lib/admin.php | 5 +++-- languages/en.php | 6 ++++++ views/default/widgets/control_panel/content.php | 24 ++++++++++++++++++++++++ 4 files changed, 43 insertions(+), 2 deletions(-) create mode 100644 actions/admin/site/flush_cache.php create mode 100644 views/default/widgets/control_panel/content.php (limited to 'engine/lib') diff --git a/actions/admin/site/flush_cache.php b/actions/admin/site/flush_cache.php new file mode 100644 index 000000000..b81f5fc83 --- /dev/null +++ b/actions/admin/site/flush_cache.php @@ -0,0 +1,10 @@ + array of handlers in order, top to bottom $adminWidgets = array( - 1 => array('admin_welcome'), + 1 => array('control_panel', 'admin_welcome'), 2 => array('online_users', 'new_users', 'content_stats'), ); diff --git a/languages/en.php b/languages/en.php index 036ca8883..a2e6e152e 100644 --- a/languages/en.php +++ b/languages/en.php @@ -610,6 +610,12 @@ $english = array( // argh, this is ugly 'admin:widget:admin_welcome:outro' => '
      Be sure to check out the resources available through the footer links and thank you for using Elgg!', + 'admin:widget:control_panel' => 'Control panel', + 'admin:widget:control_panel:help' => "Provides easy access to common controls", + + 'admin:cache:flush' => 'Flush the caches', + 'admin:cache:flushed' => "The site's caches have been flushed", + 'admin:footer:faq' => 'Administration FAQ', 'admin:footer:manual' => 'Administration Manual', 'admin:footer:community_forums' => 'Elgg Community Forums', diff --git a/views/default/widgets/control_panel/content.php b/views/default/widgets/control_panel/content.php new file mode 100644 index 000000000..d2db54bc6 --- /dev/null +++ b/views/default/widgets/control_panel/content.php @@ -0,0 +1,24 @@ + 'flush', + 'text' => elgg_echo('admin:cache:flush'), + 'href' => 'action/admin/site/flush_cache', + 'is_action' => true, + 'link_class' => 'elgg-button elgg-button-action', +)); + +elgg_register_menu_item('admin_control_panel', array( + 'name' => 'upgrade', + 'text' => elgg_echo('upgrade'), + 'href' => 'upgrade.php', + 'link_class' => 'elgg-button elgg-button-action', +)); + +echo elgg_view_menu('admin_control_panel', array( + 'class' => 'elgg-menu-hz', + 'item_class' => 'mrm', +)); -- cgit v1.2.3 From cafd3b84cead11f6e9bf4222f1e28ee3cc158a7a Mon Sep 17 00:00:00 2001 From: cash Date: Thu, 8 Dec 2011 20:59:08 -0500 Subject: Fixes #4025 added a url handler for comments --- engine/lib/annotations.php | 32 +++++++++++++++++++++++++++----- 1 file changed, 27 insertions(+), 5 deletions(-) (limited to 'engine/lib') diff --git a/engine/lib/annotations.php b/engine/lib/annotations.php index e40ab2e39..bfd40d1e8 100644 --- a/engine/lib/annotations.php +++ b/engine/lib/annotations.php @@ -528,6 +528,20 @@ function elgg_annotation_exists($entity_guid, $annotation_type, $owner_guid = NU return FALSE; } +/** + * Return the URL for a comment + * + * @param ElggAnnotation $comment The comment object + * @return string + * @access private + */ +function elgg_comment_url_handler(ElggAnnotation $comment) { + $entity = $comment->getEntity(); + if ($entity) { + return $entity->getURL() . '#item-annotation-' . $comment->id; + } +} + /** * Register an annotation url handler. * @@ -540,11 +554,6 @@ function elgg_register_annotation_url_handler($extender_name = "all", $function_ return elgg_register_extender_url_handler('annotation', $extender_name, $function_name); } -/** Register the hook */ -elgg_register_plugin_hook_handler("export", "all", "export_annotation_plugin_hook", 2); - -elgg_register_plugin_hook_handler('unit_test', 'system', 'annotations_test'); - /** * Register annotation unit tests * @access private @@ -554,3 +563,16 @@ function annotations_test($hook, $type, $value, $params) { $value[] = $CONFIG->path . 'engine/tests/api/annotations.php'; return $value; } + +/** + * Initialize the annotation library + * @access private + */ +function elgg_annotations_init() { + elgg_register_annotation_url_handler('generic_comment', 'elgg_comment_url_handler'); + + elgg_register_plugin_hook_handler("export", "all", "export_annotation_plugin_hook", 2); + elgg_register_plugin_hook_handler('unit_test', 'system', 'annotations_test'); +} + +elgg_register_event_handler('init', 'system', 'elgg_annotations_init'); -- cgit v1.2.3 From 1ebbff44be8bccb87ec8cacee171d9b951ec50f4 Mon Sep 17 00:00:00 2001 From: cash Date: Thu, 8 Dec 2011 22:12:32 -0500 Subject: Fixes #3181 caching language js on server side with proper headers --- engine/lib/languages.php | 11 +++++++++++ js/lib/languages.js | 26 ++++++++++++++++---------- 2 files changed, 27 insertions(+), 10 deletions(-) (limited to 'engine/lib') diff --git a/engine/lib/languages.php b/engine/lib/languages.php index 7607ea3bf..0400843af 100644 --- a/engine/lib/languages.php +++ b/engine/lib/languages.php @@ -301,4 +301,15 @@ function get_missing_language_keys($language) { return false; } +/** + * Initialize the language library + * @access private + */ +function elgg_languages_init() { + $lang = get_current_language(); + elgg_register_simplecache_view("cache/js/languages/$lang"); +} + +elgg_register_event_handler('init', 'system', 'elgg_languages_init'); + register_translations(dirname(dirname(dirname(__FILE__))) . "/languages/"); diff --git a/js/lib/languages.js b/js/lib/languages.js index ae7ba63e2..bfa858364 100644 --- a/js/lib/languages.js +++ b/js/lib/languages.js @@ -26,16 +26,22 @@ elgg.add_translation = function(lang, translations) { elgg.reload_all_translations = function(language) { var lang = language || elgg.get_language(); - elgg.getJSON('ajax/view/js/languages', { - data: { - language: lang - }, - success: function(json) { - elgg.add_translation(lang, json); - elgg.config.languageReady = true; - elgg.initWhenReady(); - } - }); + var url, options; + if (elgg.config.simplecache_enabled) { + url = 'cache/js/default/languages/' + lang + '.' + elgg.config.lastcache + '.js'; + options = {}; + } else { + url = 'ajax/view/js/languages'; + options = {data: {language: lang}}; + } + + options['success'] = function(json) { + elgg.add_translation(lang, json); + elgg.config.languageReady = true; + elgg.initWhenReady(); + }; + + elgg.getJSON(url, options); }; /** -- cgit v1.2.3 From dfaa80f0a44afe6faed0212e61c3edef48afc64d Mon Sep 17 00:00:00 2001 From: cash Date: Wed, 14 Dec 2011 20:02:25 -0500 Subject: Fixes #3341 removed xml-rpc code from Elgg - see xml-rpc plugin if you need an xml-rpc endpoint --- engine/classes/ElggSite.php | 2 - engine/classes/XMLRPCArrayParameter.php | 56 --------- engine/classes/XMLRPCBase64Parameter.php | 28 ----- engine/classes/XMLRPCBoolParameter.php | 30 ----- engine/classes/XMLRPCCall.php | 62 ---------- engine/classes/XMLRPCDateParameter.php | 33 ----- engine/classes/XMLRPCDoubleParameter.php | 29 ----- engine/classes/XMLRPCErrorResponse.php | 36 ------ engine/classes/XMLRPCIntParameter.php | 29 ----- engine/classes/XMLRPCParameter.php | 16 --- engine/classes/XMLRPCResponse.php | 71 ----------- engine/classes/XMLRPCStringParameter.php | 30 ----- engine/classes/XMLRPCStructParameter.php | 55 --------- engine/classes/XMLRPCSuccessResponse.php | 22 ---- engine/handlers/page_handler.php | 8 +- engine/handlers/xml-rpc_handler.php | 44 ------- engine/lib/xml-rpc.php | 203 ------------------------------- engine/start.php | 2 +- htaccess_dist | 3 - install/ElggInstaller.php | 2 +- languages/en.php | 9 -- views/xml/xml-rpc/output.php | 11 -- 22 files changed, 8 insertions(+), 773 deletions(-) delete mode 100644 engine/classes/XMLRPCArrayParameter.php delete mode 100644 engine/classes/XMLRPCBase64Parameter.php delete mode 100644 engine/classes/XMLRPCBoolParameter.php delete mode 100644 engine/classes/XMLRPCCall.php delete mode 100644 engine/classes/XMLRPCDateParameter.php delete mode 100644 engine/classes/XMLRPCDoubleParameter.php delete mode 100644 engine/classes/XMLRPCErrorResponse.php delete mode 100644 engine/classes/XMLRPCIntParameter.php delete mode 100644 engine/classes/XMLRPCParameter.php delete mode 100644 engine/classes/XMLRPCResponse.php delete mode 100644 engine/classes/XMLRPCStringParameter.php delete mode 100644 engine/classes/XMLRPCStructParameter.php delete mode 100644 engine/classes/XMLRPCSuccessResponse.php delete mode 100644 engine/handlers/xml-rpc_handler.php delete mode 100644 engine/lib/xml-rpc.php delete mode 100644 views/xml/xml-rpc/output.php (limited to 'engine/lib') diff --git a/engine/classes/ElggSite.php b/engine/classes/ElggSite.php index 5c44d4076..0d03cbd28 100644 --- a/engine/classes/ElggSite.php +++ b/engine/classes/ElggSite.php @@ -421,8 +421,6 @@ class ElggSite extends ElggEntity { 'action/security/refreshtoken', 'ajax/view/js/languages', 'upgrade\.php', - 'xml-rpc\.php', - 'mt/mt-xmlrpc\.cgi', 'css/.*', 'js/.*' ); diff --git a/engine/classes/XMLRPCArrayParameter.php b/engine/classes/XMLRPCArrayParameter.php deleted file mode 100644 index a8edccba7..000000000 --- a/engine/classes/XMLRPCArrayParameter.php +++ /dev/null @@ -1,56 +0,0 @@ -addField($v); - } - } - } - - /** - * Add a field to the container. - * - * @param XMLRPCParameter $value The value. - * - * @return void - */ - public function addField(XMLRPCParameter $value) { - if (!is_array($this->value)) { - $this->value = array(); - } - - $this->value[] = $value; - } - - /** - * Converts XML array to string - * - * @return string - */ - function __toString() { - $params = ""; - foreach ($this->value as $value) { - $params .= "$value"; - } - - return "$params"; - } -} diff --git a/engine/classes/XMLRPCBase64Parameter.php b/engine/classes/XMLRPCBase64Parameter.php deleted file mode 100644 index 7db0a761c..000000000 --- a/engine/classes/XMLRPCBase64Parameter.php +++ /dev/null @@ -1,28 +0,0 @@ -value = base64_encode($blob); - } - - /** - * Convert to string - * - * @return string - */ - function __toString() { - return "{$value}"; - } -} diff --git a/engine/classes/XMLRPCBoolParameter.php b/engine/classes/XMLRPCBoolParameter.php deleted file mode 100644 index 607841cb8..000000000 --- a/engine/classes/XMLRPCBoolParameter.php +++ /dev/null @@ -1,30 +0,0 @@ -value = (bool)$value; - } - - /** - * Convert to string - * - * @return string - */ - function __toString() { - $code = ($this->value) ? "1" : "0"; - return "{$code}"; - } -} diff --git a/engine/classes/XMLRPCCall.php b/engine/classes/XMLRPCCall.php deleted file mode 100644 index 8eeba0c29..000000000 --- a/engine/classes/XMLRPCCall.php +++ /dev/null @@ -1,62 +0,0 @@ -_parse($xml); - } - - /** - * Return the method name associated with the call. - * - * @return string - */ - public function getMethodName() { return $this->methodname; } - - /** - * Return the parameters. - * Returns a nested array of XmlElement. - * - * @see XmlElement - * @return array - */ - public function getParameters() { return $this->params; } - - /** - * Parse the xml into its components according to spec. - * This first version is a little primitive. - * - * @param string $xml XML - * - * @return void - */ - private function _parse($xml) { - $xml = xml_to_object($xml); - - // sanity check - if ((isset($xml->name)) && (strcasecmp($xml->name, "methodCall") != 0)) { - throw new CallException(elgg_echo('CallException:NotRPCCall')); - } - - // method name - $this->methodname = $xml->children[0]->content; - - // parameters - $this->params = $xml->children[1]->children; - } -} diff --git a/engine/classes/XMLRPCDateParameter.php b/engine/classes/XMLRPCDateParameter.php deleted file mode 100644 index 93bbbd8f5..000000000 --- a/engine/classes/XMLRPCDateParameter.php +++ /dev/null @@ -1,33 +0,0 @@ -value = $timestamp; - - if (!$timestamp) { - $this->value = time(); - } - } - - /** - * Convert to string - * - * @return string - */ - function __toString() { - $value = date('c', $this->value); - return "{$value}"; - } -} diff --git a/engine/classes/XMLRPCDoubleParameter.php b/engine/classes/XMLRPCDoubleParameter.php deleted file mode 100644 index b7834650e..000000000 --- a/engine/classes/XMLRPCDoubleParameter.php +++ /dev/null @@ -1,29 +0,0 @@ -value = (float)$value; - } - - /** - * Convert to string - * - * @return string - */ - function __toString() { - return "{$this->value}"; - } -} diff --git a/engine/classes/XMLRPCErrorResponse.php b/engine/classes/XMLRPCErrorResponse.php deleted file mode 100644 index 425c075cc..000000000 --- a/engine/classes/XMLRPCErrorResponse.php +++ /dev/null @@ -1,36 +0,0 @@ -addParameter( - new XMLRPCStructParameter( - array ( - 'faultCode' => new XMLRPCIntParameter($code), - 'faultString' => new XMLRPCStringParameter($message) - ) - ) - ); - } - - /** - * Output to XML. - * - * @return string - */ - public function __toString() { - return "{$this->parameters[0]}"; - } -} diff --git a/engine/classes/XMLRPCIntParameter.php b/engine/classes/XMLRPCIntParameter.php deleted file mode 100644 index 0fc146165..000000000 --- a/engine/classes/XMLRPCIntParameter.php +++ /dev/null @@ -1,29 +0,0 @@ -value = (int)$value; - } - - /** - * Convert to string - * - * @return string - */ - function __toString() { - return "{$this->value}"; - } -} diff --git a/engine/classes/XMLRPCParameter.php b/engine/classes/XMLRPCParameter.php deleted file mode 100644 index ffbad8082..000000000 --- a/engine/classes/XMLRPCParameter.php +++ /dev/null @@ -1,16 +0,0 @@ -parameters)) { - $this->parameters = array(); - } - - $this->parameters[] = $param; - } - - /** - * Add an integer - * - * @param int $value Value - * - * @return void - */ - public function addInt($value) { - $this->addParameter(new XMLRPCIntParameter($value)); - } - - /** - * Add a string - * - * @param string $value Value - * - * @return void - */ - public function addString($value) { - $this->addParameter(new XMLRPCStringParameter($value)); - } - - /** - * Add a double - * - * @param int $value Value - * - * @return void - */ - public function addDouble($value) { - $this->addParameter(new XMLRPCDoubleParameter($value)); - } - - /** - * Add a boolean - * - * @param bool $value Value - * - * @return void - */ - public function addBoolean($value) { - $this->addParameter(new XMLRPCBoolParameter($value)); - } -} diff --git a/engine/classes/XMLRPCStringParameter.php b/engine/classes/XMLRPCStringParameter.php deleted file mode 100644 index 35b28214b..000000000 --- a/engine/classes/XMLRPCStringParameter.php +++ /dev/null @@ -1,30 +0,0 @@ -value = $value; - } - - /** - * Convert to XML string - * - * @return string - */ - function __toString() { - $value = htmlentities($this->value); - return "{$value}"; - } -} diff --git a/engine/classes/XMLRPCStructParameter.php b/engine/classes/XMLRPCStructParameter.php deleted file mode 100644 index 694ddf5df..000000000 --- a/engine/classes/XMLRPCStructParameter.php +++ /dev/null @@ -1,55 +0,0 @@ - $v) { - $this->addField($k, $v); - } - } - } - - /** - * Add a field to the container. - * - * @param string $name The name of the field. - * @param XMLRPCParameter $value The value. - * - * @return void - */ - public function addField($name, XMLRPCParameter $value) { - if (!is_array($this->value)) { - $this->value = array(); - } - - $this->value[$name] = $value; - } - - /** - * Convert to string - * - * @return string - */ - function __toString() { - $params = ""; - foreach ($this->value as $k => $v) { - $params .= "$k$v"; - } - - return "$params"; - } -} diff --git a/engine/classes/XMLRPCSuccessResponse.php b/engine/classes/XMLRPCSuccessResponse.php deleted file mode 100644 index e02e82c5c..000000000 --- a/engine/classes/XMLRPCSuccessResponse.php +++ /dev/null @@ -1,22 +0,0 @@ -parameters as $param) { - $params .= "$param\n"; - } - - return "$params"; - } -} diff --git a/engine/handlers/page_handler.php b/engine/handlers/page_handler.php index 1ed295b7d..7eca37bb1 100644 --- a/engine/handlers/page_handler.php +++ b/engine/handlers/page_handler.php @@ -13,12 +13,16 @@ * * cache * * services * * export - * * mt - * * xml-rpc.php + * * js + * * css * * rewrite.php * * tag (deprecated, reserved for backwards compatibility) * * pg (deprecated, reserved for backwards compatibility) * + * These additionally are reserved for the xml-rpc plugin + * * mt + * * xml-rpc.php + * * {@link page_handler()} explodes the pages string by / and sends it to * the page handler function as registered by {@link elgg_register_page_handler()}. * If a valid page handler isn't found, plugins have a chance to provide a 404. diff --git a/engine/handlers/xml-rpc_handler.php b/engine/handlers/xml-rpc_handler.php deleted file mode 100644 index 2ee29e5b7..000000000 --- a/engine/handlers/xml-rpc_handler.php +++ /dev/null @@ -1,44 +0,0 @@ - $result))); diff --git a/engine/lib/xml-rpc.php b/engine/lib/xml-rpc.php deleted file mode 100644 index bfe1a8645..000000000 --- a/engine/lib/xml-rpc.php +++ /dev/null @@ -1,203 +0,0 @@ -name == 'param') { - $object = $object->children[0]->children[0]; - } - - switch ($object->name) { - case 'string': - return $object->content; - - case 'array': - foreach ($object->children[0]->children as $child) { - $value[] = xmlrpc_scalar_value($child); - } - return $value; - - case 'struct': - foreach ($object->children as $child) { - if (isset($child->children[1]->children[0])) { - $value[$child->children[0]->content] = xmlrpc_scalar_value($child->children[1]->children[0]); - } else { - $value[$child->children[0]->content] = $child->children[1]->content; - } - } - return $value; - - case 'boolean': - return (boolean) $object->content; - - case 'i4': - case 'int': - return (int) $object->content; - - case 'double': - return (double) $object->content; - - case 'dateTime.iso8601': - return (int) strtotime($object->content); - - case 'base64': - return base64_decode($object->content); - - case 'value': - return xmlrpc_scalar_value($object->children[0]); - - default: - // @todo unsupported, throw an error - return false; - } -} - -// Functions for adding handlers ////////////////////////////////////////////////////////// - -/** XML-RPC Handlers */ -global $XML_RPC_HANDLERS; -$XML_RPC_HANDLERS = array(); - -/** - * Register a method handler for a given XML-RPC method. - * - * @param string $method Method parameter. - * @param string $handler The handler function. This function accepts - * one XMLRPCCall object and must return a XMLRPCResponse object. - * - * @return bool - */ -function register_xmlrpc_handler($method, $handler) { - global $XML_RPC_HANDLERS; - - $XML_RPC_HANDLERS[$method] = $handler; -} - -/** - * Trigger a method call and pass the relevant parameters to the funciton. - * - * @param XMLRPCCall $parameters The call and parameters. - * - * @return XMLRPCCall - * @access private - */ -function trigger_xmlrpc_handler(XMLRPCCall $parameters) { - global $XML_RPC_HANDLERS; - - // Go through and see if we have a handler - if (isset($XML_RPC_HANDLERS[$parameters->getMethodName()])) { - $handler = $XML_RPC_HANDLERS[$parameters->getMethodName()]; - $result = $handler($parameters); - - if (!($result instanceof XMLRPCResponse)) { - $msg = elgg_echo('InvalidParameterException:UnexpectedReturnFormat', - array($parameters->getMethodName())); - throw new InvalidParameterException($msg); - } - - // Result in right format, return it. - return $result; - } - - // if no handler then throw exception - $msg = elgg_echo('NotImplementedException:XMLRPCMethodNotImplemented', - array($parameters->getMethodName())); - throw new NotImplementedException($msg); -} - -/** - * PHP Error handler function. - * This function acts as a wrapper to catch and report PHP error messages. - * - * @see http://uk3.php.net/set-error-handler - * - * @param int $errno Error number - * @param string $errmsg Human readable message - * @param string $filename Filename - * @param int $linenum Line number - * @param array $vars Vars - * - * @return void - * @access private - */ -function _php_xmlrpc_error_handler($errno, $errmsg, $filename, $linenum, $vars) { - $error = date("Y-m-d H:i:s (T)") . ": \"" . $errmsg . "\" in file " - . $filename . " (line " . $linenum . ")"; - - switch ($errno) { - case E_USER_ERROR: - error_log("ERROR: " . $error); - - // Since this is a fatal error, we want to stop any further execution but do so gracefully. - throw new Exception("ERROR: " . $error); - break; - - case E_WARNING : - case E_USER_WARNING : - error_log("WARNING: " . $error); - break; - - default: - error_log("DEBUG: " . $error); - } -} - -/** - * PHP Exception handler for XMLRPC. - * - * @param Exception $exception The exception - * - * @return void - * @access private - */ -function _php_xmlrpc_exception_handler($exception) { - - error_log("*** FATAL EXCEPTION (XML-RPC) *** : " . $exception); - - $code = $exception->getCode(); - - if ($code == 0) { - $code = -32400; - } - - $result = new XMLRPCErrorResponse($exception->getMessage(), $code); - - $vars = array('result' => $result); - - $content = elgg_view("xml-rpc/output", $vars); - - echo elgg_view_page($exception->getMessage(), $content); -} diff --git a/engine/start.php b/engine/start.php index 00bdc3197..454dc7377 100644 --- a/engine/start.php +++ b/engine/start.php @@ -100,7 +100,7 @@ $lib_files = array( 'opendd.php', 'pagehandler.php', 'pam.php', 'plugins.php', 'private_settings.php', 'relationships.php', 'river.php', 'sites.php', 'statistics.php', 'tags.php', 'user_settings.php', 'users.php', - 'upgrade.php', 'web_services.php', 'widgets.php', 'xml.php', 'xml-rpc.php', + 'upgrade.php', 'web_services.php', 'widgets.php', 'xml.php', //backwards compatibility 'deprecated-1.7.php', 'deprecated-1.8.php', diff --git a/htaccess_dist b/htaccess_dist index 526299b94..88285f81b 100644 --- a/htaccess_dist +++ b/htaccess_dist @@ -115,9 +115,6 @@ RewriteRule ^services\/api\/([A-Za-z0-9\_\-]+)\/(.*)$ engine/handlers/service_ha RewriteRule ^export\/([A-Za-z]+)\/([0-9]+)\/?$ engine/handlers/export_handler.php?view=$1&guid=$2 RewriteRule ^export\/([A-Za-z]+)\/([0-9]+)\/([A-Za-z]+)\/([A-Za-z0-9\_]+)\/$ engine/handlers/export_handler.php?view=$1&guid=$2&type=$3&idname=$4 -RewriteRule xml-rpc.php engine/handlers/xml-rpc_handler.php -RewriteRule mt/mt-xmlrpc.cgi engine/handlers/xml-rpc_handler.php - # rule for rewrite module test during install - can be removed after installation RewriteRule ^rewrite.php$ install.php diff --git a/install/ElggInstaller.php b/install/ElggInstaller.php index d556ba744..367d23b4d 100644 --- a/install/ElggInstaller.php +++ b/install/ElggInstaller.php @@ -790,7 +790,7 @@ class ElggInstaller { 'private_settings.php', 'relationships.php', 'river.php', 'sites.php', 'statistics.php', 'tags.php', 'user_settings.php', 'users.php', 'upgrade.php', 'web_services.php', - 'widgets.php', 'xml.php', 'xml-rpc.php', 'deprecated-1.7.php', + 'widgets.php', 'xml.php', 'deprecated-1.7.php', 'deprecated-1.8.php', ); diff --git a/languages/en.php b/languages/en.php index 036ca8883..17587b178 100644 --- a/languages/en.php +++ b/languages/en.php @@ -208,10 +208,6 @@ $english = array( 'SecurityException:InvalidAPIKey' => "Invalid or missing API Key.", 'NotImplementedException:CallMethodNotImplemented' => "Call method '%s' is currently not supported.", - 'NotImplementedException:XMLRPCMethodNotImplemented' => "XML-RPC method call '%s' not implemented.", - 'InvalidParameterException:UnexpectedReturnFormat' => "Call to method '%s' returned an unexpected result.", - 'CallException:NotRPCCall' => "Call does not appear to be a valid XML-RPC call", - 'PluginException:NoPluginName' => "The plugin name could not be found", 'SecurityException:authenticationfailed' => "User could not be authenticated", @@ -1079,11 +1075,6 @@ If you requested this, click on the link below. Otherwise ignore this email. 'user:default_access:success' => "Your new default access level was saved.", 'user:default_access:failure' => "Your new default access level could not be saved.", -/** - * XML-RPC - */ - 'xmlrpc:noinputdata' => "Input data missing", - /** * Comments */ diff --git a/views/xml/xml-rpc/output.php b/views/xml/xml-rpc/output.php deleted file mode 100644 index 4276029d1..000000000 --- a/views/xml/xml-rpc/output.php +++ /dev/null @@ -1,11 +0,0 @@ - Date: Mon, 12 Dec 2011 19:24:07 +0400 Subject: fixes elgg_get_user_validation_status() always returning null --- 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 3a86c1faa..beabcbb59 100644 --- a/engine/lib/users.php +++ b/engine/lib/users.php @@ -1021,7 +1021,7 @@ function elgg_get_user_validation_status($user_guid) { return; } - if ($md->value) { + if ($md[0]->value) { return true; } -- cgit v1.2.3 From c529671a522dea0dcfc280815092ee1f5127b92b Mon Sep 17 00:00:00 2001 From: Cash Costello Date: Sat, 17 Dec 2011 08:43:49 -0500 Subject: Fixes #4190 accepting full urls with non-ascii characters --- engine/lib/output.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'engine/lib') diff --git a/engine/lib/output.php b/engine/lib/output.php index 989eca60e..6554481f5 100644 --- a/engine/lib/output.php +++ b/engine/lib/output.php @@ -234,7 +234,7 @@ function elgg_clean_vars(array $vars = array()) { * * @example * elgg_normalize_url(''); // 'http://my.site.com/' - * elgg_normalize_url('dashboard'); // 'http://my.site.com/dashboard' + * elgg_normalize_url('dashboard'); // 'http://my.site.com/dashboard' * elgg_normalize_url('http://google.com/'); // no change * elgg_normalize_url('//google.com/'); // no change * @@ -257,6 +257,11 @@ function elgg_normalize_url($url) { $validated = filter_var($url, FILTER_VALIDATE_URL); } + // work around for handling absoluate IRIs (RFC 3987) - see #4190 + if (!$validated && (strpos($url, 'http:') === 0) || (strpos($url, 'https:') === 0)) { + $validated = true; + } + if ($validated) { // all normal URLs including mailto: return $url; -- cgit v1.2.3 From a41f00224a0b5bc241b569138f4562bae4b811dd Mon Sep 17 00:00:00 2001 From: cash Date: Sat, 17 Dec 2011 16:10:06 -0500 Subject: moved user settings extensions to user_settings library --- engine/lib/user_settings.php | 7 +++++++ engine/lib/users.php | 7 ------- 2 files changed, 7 insertions(+), 7 deletions(-) (limited to 'engine/lib') diff --git a/engine/lib/user_settings.php b/engine/lib/user_settings.php index c71670357..af30d8f0d 100644 --- a/engine/lib/user_settings.php +++ b/engine/lib/user_settings.php @@ -346,6 +346,13 @@ function usersettings_init() { elgg_register_plugin_hook_handler('usersettings:save', 'user', 'users_settings_save'); elgg_register_action("usersettings/save"); + + // extend the account settings form + elgg_extend_view('forms/account/settings', 'core/settings/account/name', 100); + elgg_extend_view('forms/account/settings', 'core/settings/account/password', 100); + elgg_extend_view('forms/account/settings', 'core/settings/account/email', 100); + elgg_extend_view('forms/account/settings', 'core/settings/account/language', 100); + elgg_extend_view('forms/account/settings', 'core/settings/account/default_access', 100); } elgg_register_event_handler('init', 'system', 'usersettings_init'); diff --git a/engine/lib/users.php b/engine/lib/users.php index beabcbb59..1b3cca799 100644 --- a/engine/lib/users.php +++ b/engine/lib/users.php @@ -1562,13 +1562,6 @@ function users_init() { elgg_register_widget_type('friends', elgg_echo('friends'), elgg_echo('friends:widget:description')); - // extend the account settings form - elgg_extend_view('forms/account/settings', 'core/settings/account/name', 100); - elgg_extend_view('forms/account/settings', 'core/settings/account/password', 100); - elgg_extend_view('forms/account/settings', 'core/settings/account/email', 100); - elgg_extend_view('forms/account/settings', 'core/settings/account/language', 100); - elgg_extend_view('forms/account/settings', 'core/settings/account/default_access', 100); - // Register the user type elgg_register_entity_type('user', ''); -- cgit v1.2.3 From d784d088ddfd6cc0d74f79539872921c358b75cb Mon Sep 17 00:00:00 2001 From: Ismayil Khayredinov Date: Thu, 15 Dec 2011 13:20:56 +0100 Subject: Fixes 4209: jquery.form.js library loading --- engine/lib/views.php | 1 - mod/developers/start.php | 14 ++++++++------ mod/embed/start.php | 1 + 3 files changed, 9 insertions(+), 7 deletions(-) (limited to 'engine/lib') diff --git a/engine/lib/views.php b/engine/lib/views.php index d3c9ff551..b938dd60e 100644 --- a/engine/lib/views.php +++ b/engine/lib/views.php @@ -1598,7 +1598,6 @@ function elgg_views_boot() { elgg_load_js('jquery'); elgg_load_js('jquery-ui'); - elgg_load_js('jquery.form'); elgg_load_js('elgg'); elgg_register_simplecache_view('js/lightbox'); diff --git a/mod/developers/start.php b/mod/developers/start.php index 2e3df7663..79ec0655a 100644 --- a/mod/developers/start.php +++ b/mod/developers/start.php @@ -23,6 +23,8 @@ function developers_init() { elgg_register_js('jquery.jstree', 'mod/developers/vendors/jsTree/jquery.jstree.js', 'footer'); elgg_register_css('jquery.jstree', 'mod/developers/vendors/jsTree/themes/default/style.css'); + elgg_load_js('jquery.form'); + elgg_register_js('elgg.dev', 'js/developers/developers.js', 'footer'); elgg_load_js('elgg.dev'); } @@ -166,13 +168,13 @@ function developers_theme_preview_controller($page) { $pages = array( 'buttons', - 'components', - 'forms', - 'grid', + 'components', + 'forms', + 'grid', 'icons', - 'modules', - 'navigation', - 'typography', + 'modules', + 'navigation', + 'typography', ); foreach ($pages as $page_name) { diff --git a/mod/embed/start.php b/mod/embed/start.php index 015c0c0e4..7c070fa75 100644 --- a/mod/embed/start.php +++ b/mod/embed/start.php @@ -49,6 +49,7 @@ function embed_longtext_menu($hook, $type, $items, $vars) { elgg_load_js('lightbox'); elgg_load_css('lightbox'); + elgg_load_js('jquery.form'); elgg_load_js('elgg.embed'); return $items; -- cgit v1.2.3 From bd5c0005158ca136fe87b34dacdf75491e69ed03 Mon Sep 17 00:00:00 2001 From: Ismayil Khayredinov Date: Thu, 15 Dec 2011 05:20:57 +0100 Subject: Fix #4200: Converting widgets controls into an elgg menu --- engine/lib/navigation.php | 50 +++++++++++++++++++++++ js/lib/ui.widgets.js | 2 +- views/default/css/elements/modules.php | 15 ------- views/default/css/elements/navigation.php | 24 ++++++++++- views/default/object/widget/elements/controls.php | 49 ++++------------------ 5 files changed, 82 insertions(+), 58 deletions(-) (limited to 'engine/lib') diff --git a/engine/lib/navigation.php b/engine/lib/navigation.php index 176790188..956ca220a 100644 --- a/engine/lib/navigation.php +++ b/engine/lib/navigation.php @@ -384,6 +384,55 @@ function elgg_entity_menu_setup($hook, $type, $return, $params) { return $return; } +/** + * Widget menu is a set of widget controls + * @access private + */ +function elgg_widget_menu_setup($hook, $type, $return, $params) { + + $widget = $params['entity']; + $show_edit = elgg_extract('show_edit', $params, true); + + $collapse = array( + 'name' => 'collapse', + 'text' => ' ', + 'href' => "#elgg-widget-content-$widget->guid", + 'class' => 'elgg-widget-collapse-button', + 'rel' => 'toggle', + 'priority' => 1 + ); + $return[] = ElggMenuItem::factory($collapse); + + if ($widget->canEdit()) { + $delete = array( + 'name' => 'delete', + 'text' => elgg_view_icon('delete-alt'), + 'title' => elgg_echo('widget:delete', array($widget->getTitle())), + 'href' => "action/widgets/delete?widget_guid=$widget->guid", + 'is_action' => true, + 'class' => 'elgg-widget-delete-button', + 'id' => "elgg-widget-delete-button-$widget->guid", + 'priority' => 900 + ); + $return[] = ElggMenuItem::factory($delete); + + if ($show_edit) { + $edit = array( + 'name' => 'settings', + 'text' => elgg_view_icon('settings-alt'), + 'title' => elgg_echo('widget:edit'), + 'href' => "#widget-edit-$widget->guid", + 'class' => "elgg-widget-edit-button", + 'rel' => 'toggle', + 'priority' => 800, + ); + $return[] = ElggMenuItem::factory($edit); + } + } + + return $return; +} + /** * Adds a delete link to "generic_comment" annotations * @access private @@ -418,6 +467,7 @@ function elgg_nav_init() { elgg_register_plugin_hook_handler('prepare', 'menu:site', 'elgg_site_menu_setup'); elgg_register_plugin_hook_handler('register', 'menu:river', 'elgg_river_menu_setup'); elgg_register_plugin_hook_handler('register', 'menu:entity', 'elgg_entity_menu_setup'); + elgg_register_plugin_hook_handler('register', 'menu:widget', 'elgg_widget_menu_setup'); elgg_register_plugin_hook_handler('register', 'menu:annotation', 'elgg_annotation_menu_setup'); } diff --git a/js/lib/ui.widgets.js b/js/lib/ui.widgets.js index f12ae02c1..a44585843 100644 --- a/js/lib/ui.widgets.js +++ b/js/lib/ui.widgets.js @@ -107,7 +107,7 @@ elgg.ui.widgets.move = function(event, ui) { * @return void */ elgg.ui.widgets.remove = function(event) { - var $widget = $(this).parent().parent(); + var $widget = $(this).closest('.elgg-module-widget'); // if widget type is single instance type, enable the add buton var type = $widget.attr('class'); diff --git a/views/default/css/elements/modules.php b/views/default/css/elements/modules.php index ef85d4dd5..7750c208f 100644 --- a/views/default/css/elements/modules.php +++ b/views/default/css/elements/modules.php @@ -158,16 +158,7 @@ .elgg-module-widget.elgg-state-draggable > .elgg-head { cursor: move; } -.elgg-module-widget > .elgg-head a { - position: absolute; - top: 4px; - display: inline-block; - width: 18px; - height: 18px; - padding: 2px 2px 0 0; -} a.elgg-widget-collapse-button { - left: 5px; color: #c5c5c5; } a.elgg-widget-collapse-button:hover, @@ -181,12 +172,6 @@ a.elgg-widget-collapse-button:before { a.elgg-widget-collapsed:before { content: "\25BA"; } -a.elgg-widget-delete-button { - right: 5px; -} -a.elgg-widget-edit-button { - right: 25px; -} .elgg-module-widget > .elgg-body { background-color: white; width: 100%; diff --git a/views/default/css/elements/navigation.php b/views/default/css/elements/navigation.php index d5b20896a..62f370069 100644 --- a/views/default/css/elements/navigation.php +++ b/views/default/css/elements/navigation.php @@ -534,4 +534,26 @@ *************************************** */ .elgg-menu-extras { margin-bottom: 15px; -} \ No newline at end of file +} + +/* *************************************** + WIDGET MENU +*************************************** */ +.elgg-menu-widget > li { + position: absolute; + top: 4px; + display: inline-block; + width: 18px; + height: 18px; + padding: 2px 2px 0 0; +} + +.elgg-menu-widget > .elgg-menu-item-collapse { + left: 5px; +} +.elgg-menu-widget > .elgg-menu-item-delete { + right: 5px; +} +.elgg-menu-widget > .elgg-menu-item-settings { + right: 25px; +} diff --git a/views/default/object/widget/elements/controls.php b/views/default/object/widget/elements/controls.php index 866dcc787..d1d630c4f 100644 --- a/views/default/object/widget/elements/controls.php +++ b/views/default/object/widget/elements/controls.php @@ -6,44 +6,11 @@ * @uses $vars['show_edit'] Whether to show the edit button (true) */ -$widget = $vars['widget']; -$show_edit = elgg_extract('show_edit', $vars, true); - -$params = array( - 'text' => ' ', - 'href' => "#elgg-widget-content-$widget->guid", - 'class' => 'elgg-widget-collapse-button', - 'rel' => 'toggle', -); -$collapse_link = elgg_view('output/url', $params); - -$delete_link = $edit_link = ''; -if ($widget->canEdit()) { - $params = array( - 'text' => elgg_view_icon('delete-alt'), - 'title' => elgg_echo('widget:delete', array($widget->getTitle())), - 'href' => "action/widgets/delete?widget_guid=$widget->guid", - 'is_action' => true, - 'is_trusted' => true, - 'class' => 'elgg-widget-delete-button', - 'id' => "elgg-widget-delete-button-$widget->guid" - ); - $delete_link = elgg_view('output/url', $params); - - if ($show_edit) { - $params = array( - 'text' => elgg_view_icon('settings-alt'), - 'title' => elgg_echo('widget:edit'), - 'href' => "#widget-edit-$widget->guid", - 'class' => "elgg-widget-edit-button", - 'rel' => 'toggle', - ); - $edit_link = elgg_view('output/url', $params); - } -} - -echo <<<___END - $collapse_link - $delete_link - $edit_link -___END; +echo elgg_view_menu('widget', array( + 'entity' => elgg_extract('widget', $vars), + 'params' => array( + 'show_edit' => elgg_extract('show_edit', $vars, true) + ), + 'sort_by' => 'priority', + 'class' => 'elgg-menu-hz', +)); -- cgit v1.2.3 From f003120fba687d14630b690c50e2316f717eca7d Mon Sep 17 00:00:00 2001 From: cash Date: Mon, 19 Dec 2011 20:49:30 -0500 Subject: added more spacing to error layout --- engine/lib/pagehandler.php | 2 ++ views/default/css/elements/layout.php | 3 +++ views/default/page/layouts/error.php | 6 ++++++ 3 files changed, 11 insertions(+) (limited to 'engine/lib') diff --git a/engine/lib/pagehandler.php b/engine/lib/pagehandler.php index 16be6e3b2..ffcfc5b6a 100644 --- a/engine/lib/pagehandler.php +++ b/engine/lib/pagehandler.php @@ -114,6 +114,8 @@ function elgg_unregister_page_handler($handler) { /** * Serve an error page * + * @todo not sending status codes yet + * * @param string $hook The name of the hook * @param string $type The type of the hook * @param bool $result The current value of the hook diff --git a/views/default/css/elements/layout.php b/views/default/css/elements/layout.php index 42d898439..25a2bffb7 100644 --- a/views/default/css/elements/layout.php +++ b/views/default/css/elements/layout.php @@ -81,6 +81,9 @@ .elgg-layout-two-sidebar { background: transparent url(_graphics/two_sidebar_background.gif) repeat-y right top; } +.elgg-layout-error { + margin-top: 20px; +} .elgg-sidebar { position: relative; padding: 20px 10px; diff --git a/views/default/page/layouts/error.php b/views/default/page/layouts/error.php index 5b3109964..cdce28a8e 100644 --- a/views/default/page/layouts/error.php +++ b/views/default/page/layouts/error.php @@ -3,4 +3,10 @@ * Error layout */ +$class = 'elgg-layout-error'; +if (isset($vars['class'])) { + $class = "$class {$vars['class']}"; +} +$vars['class'] = $class; + echo elgg_view('page/layouts/one_column', $vars); -- cgit v1.2.3 From 41ae1fb2732f56ad0bb01cb0450c7517df06494e Mon Sep 17 00:00:00 2001 From: cash Date: Mon, 19 Dec 2011 21:27:02 -0500 Subject: Fixes #4184 dashboard default widgets should work and widgets should be created regardless of access --- engine/lib/widgets.php | 87 ++++++++++++++++++++++++-------------------------- 1 file changed, 41 insertions(+), 46 deletions(-) (limited to 'engine/lib') diff --git a/engine/lib/widgets.php b/engine/lib/widgets.php index 5d18a16b0..46f34391a 100644 --- a/engine/lib/widgets.php +++ b/engine/lib/widgets.php @@ -332,14 +332,14 @@ function elgg_default_widgets_init() { * @param string $event The event * @param string $type The type of object * @param object $entity The entity being created - * @return null + * @return void * @access private */ function elgg_create_default_widgets($event, $type, $entity) { $default_widget_info = elgg_get_config('default_widget_info'); if (!$default_widget_info || !$entity) { - return null; + return; } $type = $entity->getType(); @@ -347,53 +347,48 @@ function elgg_create_default_widgets($event, $type, $entity) { // event is already guaranteed by the hook registration. // need to check subtype and type. - foreach ($default_widget_info as $temp) { - if ($temp['entity_type'] == $type) { - if ($temp['entity_subtype'] == ELGG_ENTITIES_ANY_VALUE || $temp['entity_subtype'] == $subtype) { - $info = $temp; - break; + foreach ($default_widget_info as $info) { + if ($info['entity_type'] == $type) { + if ($info['entity_subtype'] == ELGG_ENTITIES_ANY_VALUE || $info['entity_subtype'] == $subtype) { + + // need to be able to access everything + $old_ia = elgg_set_ignore_access(true); + elgg_push_context('create_default_widgets'); + + // pull in by widget context with widget owners as the site + // not using elgg_get_widgets() because it sorts by columns and we don't care right now. + $options = array( + 'type' => 'object', + 'subtype' => 'widget', + 'owner_guid' => elgg_get_site_entity()->guid, + 'private_setting_name' => 'context', + 'private_setting_value' => $info['widget_context'], + 'limit' => 0 + ); + + $widgets = elgg_get_entities_from_private_settings($options); + + foreach ($widgets as $widget) { + // change the container and owner + $new_widget = clone $widget; + $new_widget->container_guid = $entity->guid; + $new_widget->owner_guid = $entity->guid; + + // pull in settings + $settings = get_all_private_settings($widget->guid); + + foreach ($settings as $name => $value) { + $new_widget->$name = $value; + } + + $new_widget->save(); + } + + elgg_set_ignore_access($old_ia); + elgg_pop_context(); } } } - - // need to be able to access everything - $old_ia = elgg_get_ignore_access(true); - elgg_push_context('create_default_widgets'); - - // pull in by widget context with widget owners as the site - // not using elgg_get_widgets() because it sorts by columns and we don't care right now. - $options = array( - 'type' => 'object', - 'subtype' => 'widget', - 'owner_guid' => elgg_get_site_entity()->guid, - 'private_setting_name' => 'context', - 'private_setting_value' => $info['widget_context'], - 'limit' => 0 - ); - - $widgets = elgg_get_entities_from_private_settings($options); - - foreach ($widgets as $widget) { - // change the container and owner - $new_widget = clone $widget; - $new_widget->container_guid = $entity->guid; - $new_widget->owner_guid = $entity->guid; - - // pull in settings - $settings = get_all_private_settings($widget->guid); - - foreach ($settings as $name => $value) { - $new_widget->$name = $value; - } - - $new_widget->save(); - } - - elgg_get_ignore_access($old_ia); - elgg_pop_context(); - - // failure here shouldn't stop the event. - return null; } /** -- cgit v1.2.3 From 5e5b3705a5ca7b66dfe386490c5570af88b49009 Mon Sep 17 00:00:00 2001 From: Cash Costello Date: Tue, 20 Dec 2011 07:32:11 -0500 Subject: Fixes #4211 removes calendar library --- engine/lib/calendar.php | 571 ----------------------------------------- engine/lib/deprecated-1.9.php | 582 ++++++++++++++++++++++++++++++++++++++++++ engine/start.php | 6 +- install/ElggInstaller.php | 4 +- 4 files changed, 587 insertions(+), 576 deletions(-) delete mode 100644 engine/lib/calendar.php create mode 100644 engine/lib/deprecated-1.9.php (limited to 'engine/lib') diff --git a/engine/lib/calendar.php b/engine/lib/calendar.php deleted file mode 100644 index 9a06c5292..000000000 --- a/engine/lib/calendar.php +++ /dev/null @@ -1,571 +0,0 @@ -site_guid; - } - - $where = array(); - - if (is_array($type)) { - $tempwhere = ""; - if (sizeof($type)) { - foreach ($type as $typekey => $subtypearray) { - foreach ($subtypearray as $subtypeval) { - $typekey = sanitise_string($typekey); - if (!empty($subtypeval)) { - $subtypeval = (int) get_subtype_id($typekey, $subtypeval); - } else { - $subtypeval = 0; - } - if (!empty($tempwhere)) { - $tempwhere .= " or "; - } - $tempwhere .= "(e.type = '{$typekey}' and e.subtype = {$subtypeval})"; - } - } - } - if (!empty($tempwhere)) { - $where[] = "({$tempwhere})"; - } - } else { - $type = sanitise_string($type); - $subtype = get_subtype_id($type, $subtype); - - if ($type != "") { - $where[] = "e.type='$type'"; - } - - if ($subtype !== "") { - $where[] = "e.subtype=$subtype"; - } - } - - if ($owner_guid != "") { - if (!is_array($owner_guid)) { - $owner_array = array($owner_guid); - $owner_guid = (int) $owner_guid; - $where[] = "e.owner_guid = '$owner_guid'"; - } else if (sizeof($owner_guid) > 0) { - $owner_array = array_map('sanitise_int', $owner_guid); - // Cast every element to the owner_guid array to int - $owner_guid = implode(",", $owner_guid); - $where[] = "e.owner_guid in ({$owner_guid})"; - } - if (is_null($container_guid)) { - $container_guid = $owner_array; - } - } - - if ($site_guid > 0) { - $where[] = "e.site_guid = {$site_guid}"; - } - - if (!is_null($container_guid)) { - if (is_array($container_guid)) { - foreach ($container_guid as $key => $val) { - $container_guid[$key] = (int) $val; - } - $where[] = "e.container_guid in (" . implode(",", $container_guid) . ")"; - } else { - $container_guid = (int) $container_guid; - $where[] = "e.container_guid = {$container_guid}"; - } - } - - // Add the calendar stuff - $cal_join = " - JOIN {$CONFIG->dbprefix}metadata cal_start on e.guid=cal_start.entity_guid - JOIN {$CONFIG->dbprefix}metastrings cal_start_name on cal_start.name_id=cal_start_name.id - JOIN {$CONFIG->dbprefix}metastrings cal_start_value on cal_start.value_id=cal_start_value.id - - JOIN {$CONFIG->dbprefix}metadata cal_end on e.guid=cal_end.entity_guid - JOIN {$CONFIG->dbprefix}metastrings cal_end_name on cal_end.name_id=cal_end_name.id - JOIN {$CONFIG->dbprefix}metastrings cal_end_value on cal_end.value_id=cal_end_value.id - "; - $where[] = "cal_start_name.string='calendar_start'"; - $where[] = "cal_start_value.string>=$start_time"; - $where[] = "cal_end_name.string='calendar_end'"; - $where[] = "cal_end_value.string <= $end_time"; - - - if (!$count) { - $query = "SELECT e.* from {$CONFIG->dbprefix}entities e $cal_join where "; - } else { - $query = "SELECT count(e.guid) as total from {$CONFIG->dbprefix}entities e $cal_join where "; - } - foreach ($where as $w) { - $query .= " $w and "; - } - - $query .= get_access_sql_suffix('e'); // Add access controls - - if (!$count) { - $query .= " order by n.calendar_start $order_by"; - // Add order and limit - if ($limit) { - $query .= " limit $offset, $limit"; - } - $dt = get_data($query, "entity_row_to_elggstar"); - - return $dt; - } else { - $total = get_data_row($query); - return $total->total; - } -} - -/** - * Return the notable entities for a given time period based on an item of metadata. - * - * @param int $start_time The start time as a unix timestamp. - * @param int $end_time The end time as a unix timestamp. - * @param mixed $meta_name Metadata name - * @param mixed $meta_value Metadata value - * @param string $entity_type The type of entity to look for, eg 'site' or 'object' - * @param string $entity_subtype The subtype of the entity. - * @param int $owner_guid Owner GUID - * @param int $limit Limit - * @param int $offset Offset - * @param string $order_by Optional ordering. - * @param int $site_guid Site to get entities for. Default 0 = current site. -1 = any. - * @param bool $count If true, returns count instead of entities. (Default: false) - * - * @return int|array A list of entities, or a count if $count is set to true - * @access private - */ -function get_notable_entities_from_metadata($start_time, $end_time, $meta_name, $meta_value = "", -$entity_type = "", $entity_subtype = "", $owner_guid = 0, $limit = 10, $offset = 0, $order_by = "", -$site_guid = 0, $count = false) { - - global $CONFIG; - - $meta_n = get_metastring_id($meta_name); - $meta_v = get_metastring_id($meta_value); - - $start_time = (int)$start_time; - $end_time = (int)$end_time; - $entity_type = sanitise_string($entity_type); - $entity_subtype = get_subtype_id($entity_type, $entity_subtype); - $limit = (int)$limit; - $offset = (int)$offset; - if ($order_by == "") { - $order_by = "e.time_created desc"; - } - $order_by = sanitise_string($order_by); - $site_guid = (int) $site_guid; - if ((is_array($owner_guid) && (count($owner_guid)))) { - foreach ($owner_guid as $key => $guid) { - $owner_guid[$key] = (int) $guid; - } - } else { - $owner_guid = (int) $owner_guid; - } - - if ($site_guid == 0) { - $site_guid = $CONFIG->site_guid; - } - - //$access = get_access_list(); - - $where = array(); - - if ($entity_type != "") { - $where[] = "e.type='$entity_type'"; - } - - if ($entity_subtype) { - $where[] = "e.subtype=$entity_subtype"; - } - - if ($meta_name != "") { - $where[] = "m.name_id='$meta_n'"; - } - - if ($meta_value != "") { - $where[] = "m.value_id='$meta_v'"; - } - - if ($site_guid > 0) { - $where[] = "e.site_guid = {$site_guid}"; - } - - if (is_array($owner_guid)) { - $where[] = "e.container_guid in (" . implode(",", $owner_guid) . ")"; - } else if ($owner_guid > 0) { - $where[] = "e.container_guid = {$owner_guid}"; - } - - // Add the calendar stuff - $cal_join = " - JOIN {$CONFIG->dbprefix}metadata cal_start on e.guid=cal_start.entity_guid - JOIN {$CONFIG->dbprefix}metastrings cal_start_name on cal_start.name_id=cal_start_name.id - JOIN {$CONFIG->dbprefix}metastrings cal_start_value on cal_start.value_id=cal_start_value.id - - JOIN {$CONFIG->dbprefix}metadata cal_end on e.guid=cal_end.entity_guid - JOIN {$CONFIG->dbprefix}metastrings cal_end_name on cal_end.name_id=cal_end_name.id - JOIN {$CONFIG->dbprefix}metastrings cal_end_value on cal_end.value_id=cal_end_value.id - "; - - $where[] = "cal_start_name.string='calendar_start'"; - $where[] = "cal_start_value.string>=$start_time"; - $where[] = "cal_end_name.string='calendar_end'"; - $where[] = "cal_end_value.string <= $end_time"; - - if (!$count) { - $query = "SELECT distinct e.* "; - } else { - $query = "SELECT count(distinct e.guid) as total "; - } - - $query .= "from {$CONFIG->dbprefix}entities e" - . " JOIN {$CONFIG->dbprefix}metadata m on e.guid = m.entity_guid $cal_join where"; - - foreach ($where as $w) { - $query .= " $w and "; - } - - // Add access controls - $query .= get_access_sql_suffix("e"); - $query .= ' and ' . get_access_sql_suffix("m"); - - if (!$count) { - // Add order and limit - $query .= " order by $order_by limit $offset, $limit"; - return get_data($query, "entity_row_to_elggstar"); - } else { - if ($row = get_data_row($query)) { - return $row->total; - } - } - - return false; -} - -/** - * Return the notable entities for a given time period based on their relationship. - * - * @param int $start_time The start time as a unix timestamp. - * @param int $end_time The end time as a unix timestamp. - * @param string $relationship The relationship eg "friends_of" - * @param int $relationship_guid The guid of the entity to use query - * @param bool $inverse_relationship Reverse the normal function of the query to say - * "give me all entities for whom $relationship_guid is a - * $relationship of" - * @param string $type Entity type - * @param string $subtype Entity subtype - * @param int $owner_guid Owner GUID - * @param string $order_by Optional Order by - * @param int $limit Limit - * @param int $offset Offset - * @param boolean $count If true returns a count of entities (default false) - * @param int $site_guid Site to get entities for. Default 0 = current site. -1 = any - * - * @return array|int|false An array of entities, or the number of entities, or false on failure - * @access private - */ -function get_noteable_entities_from_relationship($start_time, $end_time, $relationship, -$relationship_guid, $inverse_relationship = false, $type = "", $subtype = "", $owner_guid = 0, -$order_by = "", $limit = 10, $offset = 0, $count = false, $site_guid = 0) { - - global $CONFIG; - - $start_time = (int)$start_time; - $end_time = (int)$end_time; - $relationship = sanitise_string($relationship); - $relationship_guid = (int)$relationship_guid; - $inverse_relationship = (bool)$inverse_relationship; - $type = sanitise_string($type); - $subtype = get_subtype_id($type, $subtype); - $owner_guid = (int)$owner_guid; - if ($order_by == "") { - $order_by = "time_created desc"; - } - $order_by = sanitise_string($order_by); - $limit = (int)$limit; - $offset = (int)$offset; - $site_guid = (int) $site_guid; - if ($site_guid == 0) { - $site_guid = $CONFIG->site_guid; - } - - //$access = get_access_list(); - - $where = array(); - - if ($relationship != "") { - $where[] = "r.relationship='$relationship'"; - } - if ($relationship_guid) { - $where[] = $inverse_relationship ? - "r.guid_two='$relationship_guid'" : "r.guid_one='$relationship_guid'"; - } - if ($type != "") { - $where[] = "e.type='$type'"; - } - if ($subtype) { - $where[] = "e.subtype=$subtype"; - } - if ($owner_guid != "") { - $where[] = "e.container_guid='$owner_guid'"; - } - if ($site_guid > 0) { - $where[] = "e.site_guid = {$site_guid}"; - } - - // Add the calendar stuff - $cal_join = " - JOIN {$CONFIG->dbprefix}metadata cal_start on e.guid=cal_start.entity_guid - JOIN {$CONFIG->dbprefix}metastrings cal_start_name on cal_start.name_id=cal_start_name.id - JOIN {$CONFIG->dbprefix}metastrings cal_start_value on cal_start.value_id=cal_start_value.id - - JOIN {$CONFIG->dbprefix}metadata cal_end on e.guid=cal_end.entity_guid - JOIN {$CONFIG->dbprefix}metastrings cal_end_name on cal_end.name_id=cal_end_name.id - JOIN {$CONFIG->dbprefix}metastrings cal_end_value on cal_end.value_id=cal_end_value.id - "; - $where[] = "cal_start_name.string='calendar_start'"; - $where[] = "cal_start_value.string>=$start_time"; - $where[] = "cal_end_name.string='calendar_end'"; - $where[] = "cal_end_value.string <= $end_time"; - - // Select what we're joining based on the options - $joinon = "e.guid = r.guid_one"; - if (!$inverse_relationship) { - $joinon = "e.guid = r.guid_two"; - } - - if ($count) { - $query = "SELECT count(distinct e.guid) as total "; - } else { - $query = "SELECT distinct e.* "; - } - $query .= " from {$CONFIG->dbprefix}entity_relationships r" - . " JOIN {$CONFIG->dbprefix}entities e on $joinon $cal_join where "; - - foreach ($where as $w) { - $query .= " $w and "; - } - // Add access controls - $query .= get_access_sql_suffix("e"); - if (!$count) { - $query .= " order by $order_by limit $offset, $limit"; // Add order and limit - return get_data($query, "entity_row_to_elggstar"); - } else { - if ($count = get_data_row($query)) { - return $count->total; - } - } - return false; -} - -/** - * Get all entities for today. - * - * @param string $type The type of entity (eg "user", "object" etc) - * @param string $subtype The arbitrary subtype of the entity - * @param int $owner_guid The GUID of the owning user - * @param string $order_by The field to order by; by default, time_created desc - * @param int $limit The number of entities to return; 10 by default - * @param int $offset The indexing offset, 0 by default - * @param boolean $count If true returns a count of entities (default false) - * @param int $site_guid Site to get entities for. Default 0 = current site. -1 = any - * @param mixed $container_guid Container(s) to get entities from (default: any). - * - * @return array|false - * @access private - */ -function get_todays_entities($type = "", $subtype = "", $owner_guid = 0, $order_by = "", -$limit = 10, $offset = 0, $count = false, $site_guid = 0, $container_guid = null) { - - $day_start = get_day_start(); - $day_end = get_day_end(); - - return get_notable_entities($day_start, $day_end, $type, $subtype, $owner_guid, $order_by, - $limit, $offset, $count, $site_guid, $container_guid); -} - -/** - * Get entities for today from metadata. - * - * @param mixed $meta_name Metadata name - * @param mixed $meta_value Metadata value - * @param string $entity_type The type of entity to look for, eg 'site' or 'object' - * @param string $entity_subtype The subtype of the entity. - * @param int $owner_guid Owner GUID - * @param int $limit Limit - * @param int $offset Offset - * @param string $order_by Optional ordering. - * @param int $site_guid Site to get entities for. Default 0 = current site. -1 = any. - * @param bool $count If true, returns count instead of entities. (Default: false) - * - * @return int|array A list of entities, or a count if $count is set to true - * @access private - */ -function get_todays_entities_from_metadata($meta_name, $meta_value = "", $entity_type = "", -$entity_subtype = "", $owner_guid = 0, $limit = 10, $offset = 0, $order_by = "", $site_guid = 0, -$count = false) { - - $day_start = get_day_start(); - $day_end = get_day_end(); - - return get_notable_entities_from_metadata($day_start, $day_end, $meta_name, $meta_value, - $entity_type, $entity_subtype, $owner_guid, $limit, $offset, $order_by, $site_guid, $count); -} - -/** - * Get entities for today from a relationship - * - * @param string $relationship The relationship eg "friends_of" - * @param int $relationship_guid The guid of the entity to use query - * @param bool $inverse_relationship Reverse the normal function of the query to say - * "give me all entities for whom $relationship_guid is a - * $relationship of" - * @param string $type Entity type - * @param string $subtype Entity subtype - * @param int $owner_guid Owner GUID - * @param string $order_by Optional Order by - * @param int $limit Limit - * @param int $offset Offset - * @param boolean $count If true returns a count of entities (default false) - * @param int $site_guid Site to get entities for. Default 0 = current site. -1 = any - * - * @return array|int|false An array of entities, or the number of entities, or false on failure - * @access private - */ -function get_todays_entities_from_relationship($relationship, $relationship_guid, -$inverse_relationship = false, $type = "", $subtype = "", $owner_guid = 0, -$order_by = "", $limit = 10, $offset = 0, $count = false, $site_guid = 0) { - - $day_start = get_day_start(); - $day_end = get_day_end(); - - return get_notable_entities_from_relationship($day_start, $day_end, $relationship, - $relationship_guid, $inverse_relationship, $type, $subtype, $owner_guid, $order_by, - $limit, $offset, $count, $site_guid); -} - -/** - * Returns a viewable list of entities for a given time period. - * - * @see elgg_view_entity_list - * - * @param int $start_time The start time as a unix timestamp. - * @param int $end_time The end time as a unix timestamp. - * @param string $type The type of entity (eg "user", "object" etc) - * @param string $subtype The arbitrary subtype of the entity - * @param int $owner_guid The GUID of the owning user - * @param int $limit The number of entities to return; 10 by default - * @param boolean $fullview Whether or not to display the full view (default: true) - * @param boolean $listtypetoggle Whether or not to allow gallery view - * @param boolean $navigation Display pagination? Default: true - * - * @return string A viewable list of entities - * @access private - */ -function list_notable_entities($start_time, $end_time, $type= "", $subtype = "", $owner_guid = 0, -$limit = 10, $fullview = true, $listtypetoggle = false, $navigation = true) { - - $offset = (int) get_input('offset'); - $count = get_notable_entities($start_time, $end_time, $type, $subtype, - $owner_guid, "", $limit, $offset, true); - - $entities = get_notable_entities($start_time, $end_time, $type, $subtype, - $owner_guid, "", $limit, $offset); - - return elgg_view_entity_list($entities, $count, $offset, $limit, - $fullview, $listtypetoggle, $navigation); -} - -/** - * Return a list of today's entities. - * - * @see list_notable_entities - * - * @param string $type The type of entity (eg "user", "object" etc) - * @param string $subtype The arbitrary subtype of the entity - * @param int $owner_guid The GUID of the owning user - * @param int $limit The number of entities to return; 10 by default - * @param boolean $fullview Whether or not to display the full view (default: true) - * @param boolean $listtypetoggle Whether or not to allow gallery view - * @param boolean $navigation Display pagination? Default: true - * - * @return string A viewable list of entities - * @access private - */ -function list_todays_entities($type= "", $subtype = "", $owner_guid = 0, $limit = 10, -$fullview = true, $listtypetoggle = false, $navigation = true) { - - $day_start = get_day_start(); - $day_end = get_day_end(); - - return list_notable_entities($day_start, $day_end, $type, $subtype, $owner_guid, $limit, - $fullview, $listtypetoggle, $navigation); -} diff --git a/engine/lib/deprecated-1.9.php b/engine/lib/deprecated-1.9.php new file mode 100644 index 000000000..31d03428f --- /dev/null +++ b/engine/lib/deprecated-1.9.php @@ -0,0 +1,582 @@ +site_guid; + } + + $where = array(); + + if (is_array($type)) { + $tempwhere = ""; + if (sizeof($type)) { + foreach ($type as $typekey => $subtypearray) { + foreach ($subtypearray as $subtypeval) { + $typekey = sanitise_string($typekey); + if (!empty($subtypeval)) { + $subtypeval = (int) get_subtype_id($typekey, $subtypeval); + } else { + $subtypeval = 0; + } + if (!empty($tempwhere)) { + $tempwhere .= " or "; + } + $tempwhere .= "(e.type = '{$typekey}' and e.subtype = {$subtypeval})"; + } + } + } + if (!empty($tempwhere)) { + $where[] = "({$tempwhere})"; + } + } else { + $type = sanitise_string($type); + $subtype = get_subtype_id($type, $subtype); + + if ($type != "") { + $where[] = "e.type='$type'"; + } + + if ($subtype !== "") { + $where[] = "e.subtype=$subtype"; + } + } + + if ($owner_guid != "") { + if (!is_array($owner_guid)) { + $owner_array = array($owner_guid); + $owner_guid = (int) $owner_guid; + $where[] = "e.owner_guid = '$owner_guid'"; + } else if (sizeof($owner_guid) > 0) { + $owner_array = array_map('sanitise_int', $owner_guid); + // Cast every element to the owner_guid array to int + $owner_guid = implode(",", $owner_guid); + $where[] = "e.owner_guid in ({$owner_guid})"; + } + if (is_null($container_guid)) { + $container_guid = $owner_array; + } + } + + if ($site_guid > 0) { + $where[] = "e.site_guid = {$site_guid}"; + } + + if (!is_null($container_guid)) { + if (is_array($container_guid)) { + foreach ($container_guid as $key => $val) { + $container_guid[$key] = (int) $val; + } + $where[] = "e.container_guid in (" . implode(",", $container_guid) . ")"; + } else { + $container_guid = (int) $container_guid; + $where[] = "e.container_guid = {$container_guid}"; + } + } + + // Add the calendar stuff + $cal_join = " + JOIN {$CONFIG->dbprefix}metadata cal_start on e.guid=cal_start.entity_guid + JOIN {$CONFIG->dbprefix}metastrings cal_start_name on cal_start.name_id=cal_start_name.id + JOIN {$CONFIG->dbprefix}metastrings cal_start_value on cal_start.value_id=cal_start_value.id + + JOIN {$CONFIG->dbprefix}metadata cal_end on e.guid=cal_end.entity_guid + JOIN {$CONFIG->dbprefix}metastrings cal_end_name on cal_end.name_id=cal_end_name.id + JOIN {$CONFIG->dbprefix}metastrings cal_end_value on cal_end.value_id=cal_end_value.id + "; + $where[] = "cal_start_name.string='calendar_start'"; + $where[] = "cal_start_value.string>=$start_time"; + $where[] = "cal_end_name.string='calendar_end'"; + $where[] = "cal_end_value.string <= $end_time"; + + + if (!$count) { + $query = "SELECT e.* from {$CONFIG->dbprefix}entities e $cal_join where "; + } else { + $query = "SELECT count(e.guid) as total from {$CONFIG->dbprefix}entities e $cal_join where "; + } + foreach ($where as $w) { + $query .= " $w and "; + } + + $query .= get_access_sql_suffix('e'); // Add access controls + + if (!$count) { + $query .= " order by n.calendar_start $order_by"; + // Add order and limit + if ($limit) { + $query .= " limit $offset, $limit"; + } + $dt = get_data($query, "entity_row_to_elggstar"); + + return $dt; + } else { + $total = get_data_row($query); + return $total->total; + } +} + +/** + * Return the notable entities for a given time period based on an item of metadata. + * + * @param int $start_time The start time as a unix timestamp. + * @param int $end_time The end time as a unix timestamp. + * @param mixed $meta_name Metadata name + * @param mixed $meta_value Metadata value + * @param string $entity_type The type of entity to look for, eg 'site' or 'object' + * @param string $entity_subtype The subtype of the entity. + * @param int $owner_guid Owner GUID + * @param int $limit Limit + * @param int $offset Offset + * @param string $order_by Optional ordering. + * @param int $site_guid Site to get entities for. Default 0 = current site. -1 = any. + * @param bool $count If true, returns count instead of entities. (Default: false) + * + * @return int|array A list of entities, or a count if $count is set to true + * @access private + * @deprecated 1.9 + */ +function get_notable_entities_from_metadata($start_time, $end_time, $meta_name, $meta_value = "", +$entity_type = "", $entity_subtype = "", $owner_guid = 0, $limit = 10, $offset = 0, $order_by = "", +$site_guid = 0, $count = false) { + elgg_deprecated_notice('get_notable_entities_from_metadata() has been deprecated', 1.9); + + global $CONFIG; + + $meta_n = get_metastring_id($meta_name); + $meta_v = get_metastring_id($meta_value); + + $start_time = (int)$start_time; + $end_time = (int)$end_time; + $entity_type = sanitise_string($entity_type); + $entity_subtype = get_subtype_id($entity_type, $entity_subtype); + $limit = (int)$limit; + $offset = (int)$offset; + if ($order_by == "") { + $order_by = "e.time_created desc"; + } + $order_by = sanitise_string($order_by); + $site_guid = (int) $site_guid; + if ((is_array($owner_guid) && (count($owner_guid)))) { + foreach ($owner_guid as $key => $guid) { + $owner_guid[$key] = (int) $guid; + } + } else { + $owner_guid = (int) $owner_guid; + } + + if ($site_guid == 0) { + $site_guid = $CONFIG->site_guid; + } + + //$access = get_access_list(); + + $where = array(); + + if ($entity_type != "") { + $where[] = "e.type='$entity_type'"; + } + + if ($entity_subtype) { + $where[] = "e.subtype=$entity_subtype"; + } + + if ($meta_name != "") { + $where[] = "m.name_id='$meta_n'"; + } + + if ($meta_value != "") { + $where[] = "m.value_id='$meta_v'"; + } + + if ($site_guid > 0) { + $where[] = "e.site_guid = {$site_guid}"; + } + + if (is_array($owner_guid)) { + $where[] = "e.container_guid in (" . implode(",", $owner_guid) . ")"; + } else if ($owner_guid > 0) { + $where[] = "e.container_guid = {$owner_guid}"; + } + + // Add the calendar stuff + $cal_join = " + JOIN {$CONFIG->dbprefix}metadata cal_start on e.guid=cal_start.entity_guid + JOIN {$CONFIG->dbprefix}metastrings cal_start_name on cal_start.name_id=cal_start_name.id + JOIN {$CONFIG->dbprefix}metastrings cal_start_value on cal_start.value_id=cal_start_value.id + + JOIN {$CONFIG->dbprefix}metadata cal_end on e.guid=cal_end.entity_guid + JOIN {$CONFIG->dbprefix}metastrings cal_end_name on cal_end.name_id=cal_end_name.id + JOIN {$CONFIG->dbprefix}metastrings cal_end_value on cal_end.value_id=cal_end_value.id + "; + + $where[] = "cal_start_name.string='calendar_start'"; + $where[] = "cal_start_value.string>=$start_time"; + $where[] = "cal_end_name.string='calendar_end'"; + $where[] = "cal_end_value.string <= $end_time"; + + if (!$count) { + $query = "SELECT distinct e.* "; + } else { + $query = "SELECT count(distinct e.guid) as total "; + } + + $query .= "from {$CONFIG->dbprefix}entities e" + . " JOIN {$CONFIG->dbprefix}metadata m on e.guid = m.entity_guid $cal_join where"; + + foreach ($where as $w) { + $query .= " $w and "; + } + + // Add access controls + $query .= get_access_sql_suffix("e"); + $query .= ' and ' . get_access_sql_suffix("m"); + + if (!$count) { + // Add order and limit + $query .= " order by $order_by limit $offset, $limit"; + return get_data($query, "entity_row_to_elggstar"); + } else { + if ($row = get_data_row($query)) { + return $row->total; + } + } + + return false; +} + +/** + * Return the notable entities for a given time period based on their relationship. + * + * @param int $start_time The start time as a unix timestamp. + * @param int $end_time The end time as a unix timestamp. + * @param string $relationship The relationship eg "friends_of" + * @param int $relationship_guid The guid of the entity to use query + * @param bool $inverse_relationship Reverse the normal function of the query to say + * "give me all entities for whom $relationship_guid is a + * $relationship of" + * @param string $type Entity type + * @param string $subtype Entity subtype + * @param int $owner_guid Owner GUID + * @param string $order_by Optional Order by + * @param int $limit Limit + * @param int $offset Offset + * @param boolean $count If true returns a count of entities (default false) + * @param int $site_guid Site to get entities for. Default 0 = current site. -1 = any + * + * @return array|int|false An array of entities, or the number of entities, or false on failure + * @access private + * @deprecated 1.9 + */ +function get_noteable_entities_from_relationship($start_time, $end_time, $relationship, +$relationship_guid, $inverse_relationship = false, $type = "", $subtype = "", $owner_guid = 0, +$order_by = "", $limit = 10, $offset = 0, $count = false, $site_guid = 0) { + elgg_deprecated_notice('get_noteable_entities_from_relationship() has been deprecated', 1.9); + + global $CONFIG; + + $start_time = (int)$start_time; + $end_time = (int)$end_time; + $relationship = sanitise_string($relationship); + $relationship_guid = (int)$relationship_guid; + $inverse_relationship = (bool)$inverse_relationship; + $type = sanitise_string($type); + $subtype = get_subtype_id($type, $subtype); + $owner_guid = (int)$owner_guid; + if ($order_by == "") { + $order_by = "time_created desc"; + } + $order_by = sanitise_string($order_by); + $limit = (int)$limit; + $offset = (int)$offset; + $site_guid = (int) $site_guid; + if ($site_guid == 0) { + $site_guid = $CONFIG->site_guid; + } + + //$access = get_access_list(); + + $where = array(); + + if ($relationship != "") { + $where[] = "r.relationship='$relationship'"; + } + if ($relationship_guid) { + $where[] = $inverse_relationship ? + "r.guid_two='$relationship_guid'" : "r.guid_one='$relationship_guid'"; + } + if ($type != "") { + $where[] = "e.type='$type'"; + } + if ($subtype) { + $where[] = "e.subtype=$subtype"; + } + if ($owner_guid != "") { + $where[] = "e.container_guid='$owner_guid'"; + } + if ($site_guid > 0) { + $where[] = "e.site_guid = {$site_guid}"; + } + + // Add the calendar stuff + $cal_join = " + JOIN {$CONFIG->dbprefix}metadata cal_start on e.guid=cal_start.entity_guid + JOIN {$CONFIG->dbprefix}metastrings cal_start_name on cal_start.name_id=cal_start_name.id + JOIN {$CONFIG->dbprefix}metastrings cal_start_value on cal_start.value_id=cal_start_value.id + + JOIN {$CONFIG->dbprefix}metadata cal_end on e.guid=cal_end.entity_guid + JOIN {$CONFIG->dbprefix}metastrings cal_end_name on cal_end.name_id=cal_end_name.id + JOIN {$CONFIG->dbprefix}metastrings cal_end_value on cal_end.value_id=cal_end_value.id + "; + $where[] = "cal_start_name.string='calendar_start'"; + $where[] = "cal_start_value.string>=$start_time"; + $where[] = "cal_end_name.string='calendar_end'"; + $where[] = "cal_end_value.string <= $end_time"; + + // Select what we're joining based on the options + $joinon = "e.guid = r.guid_one"; + if (!$inverse_relationship) { + $joinon = "e.guid = r.guid_two"; + } + + if ($count) { + $query = "SELECT count(distinct e.guid) as total "; + } else { + $query = "SELECT distinct e.* "; + } + $query .= " from {$CONFIG->dbprefix}entity_relationships r" + . " JOIN {$CONFIG->dbprefix}entities e on $joinon $cal_join where "; + + foreach ($where as $w) { + $query .= " $w and "; + } + // Add access controls + $query .= get_access_sql_suffix("e"); + if (!$count) { + $query .= " order by $order_by limit $offset, $limit"; // Add order and limit + return get_data($query, "entity_row_to_elggstar"); + } else { + if ($count = get_data_row($query)) { + return $count->total; + } + } + return false; +} + +/** + * Get all entities for today. + * + * @param string $type The type of entity (eg "user", "object" etc) + * @param string $subtype The arbitrary subtype of the entity + * @param int $owner_guid The GUID of the owning user + * @param string $order_by The field to order by; by default, time_created desc + * @param int $limit The number of entities to return; 10 by default + * @param int $offset The indexing offset, 0 by default + * @param boolean $count If true returns a count of entities (default false) + * @param int $site_guid Site to get entities for. Default 0 = current site. -1 = any + * @param mixed $container_guid Container(s) to get entities from (default: any). + * + * @return array|false + * @access private + * @deprecated 1.9 + */ +function get_todays_entities($type = "", $subtype = "", $owner_guid = 0, $order_by = "", +$limit = 10, $offset = 0, $count = false, $site_guid = 0, $container_guid = null) { + elgg_deprecated_notice('get_todays_entities() has been deprecated', 1.9); + + $day_start = get_day_start(); + $day_end = get_day_end(); + + return get_notable_entities($day_start, $day_end, $type, $subtype, $owner_guid, $order_by, + $limit, $offset, $count, $site_guid, $container_guid); +} + +/** + * Get entities for today from metadata. + * + * @param mixed $meta_name Metadata name + * @param mixed $meta_value Metadata value + * @param string $entity_type The type of entity to look for, eg 'site' or 'object' + * @param string $entity_subtype The subtype of the entity. + * @param int $owner_guid Owner GUID + * @param int $limit Limit + * @param int $offset Offset + * @param string $order_by Optional ordering. + * @param int $site_guid Site to get entities for. Default 0 = current site. -1 = any. + * @param bool $count If true, returns count instead of entities. (Default: false) + * + * @return int|array A list of entities, or a count if $count is set to true + * @access private + * @deprecated 1.9 + */ +function get_todays_entities_from_metadata($meta_name, $meta_value = "", $entity_type = "", +$entity_subtype = "", $owner_guid = 0, $limit = 10, $offset = 0, $order_by = "", $site_guid = 0, +$count = false) { + elgg_deprecated_notice('get_todays_entities_from_metadata() has been deprecated', 1.9); + + $day_start = get_day_start(); + $day_end = get_day_end(); + + return get_notable_entities_from_metadata($day_start, $day_end, $meta_name, $meta_value, + $entity_type, $entity_subtype, $owner_guid, $limit, $offset, $order_by, $site_guid, $count); +} + +/** + * Get entities for today from a relationship + * + * @param string $relationship The relationship eg "friends_of" + * @param int $relationship_guid The guid of the entity to use query + * @param bool $inverse_relationship Reverse the normal function of the query to say + * "give me all entities for whom $relationship_guid is a + * $relationship of" + * @param string $type Entity type + * @param string $subtype Entity subtype + * @param int $owner_guid Owner GUID + * @param string $order_by Optional Order by + * @param int $limit Limit + * @param int $offset Offset + * @param boolean $count If true returns a count of entities (default false) + * @param int $site_guid Site to get entities for. Default 0 = current site. -1 = any + * + * @return array|int|false An array of entities, or the number of entities, or false on failure + * @access private + * @deprecated 1.9 + */ +function get_todays_entities_from_relationship($relationship, $relationship_guid, +$inverse_relationship = false, $type = "", $subtype = "", $owner_guid = 0, +$order_by = "", $limit = 10, $offset = 0, $count = false, $site_guid = 0) { + elgg_deprecated_notice('get_todays_entities_from_relationship() has been deprecated', 1.9); + + $day_start = get_day_start(); + $day_end = get_day_end(); + + return get_notable_entities_from_relationship($day_start, $day_end, $relationship, + $relationship_guid, $inverse_relationship, $type, $subtype, $owner_guid, $order_by, + $limit, $offset, $count, $site_guid); +} + +/** + * Returns a viewable list of entities for a given time period. + * + * @see elgg_view_entity_list + * + * @param int $start_time The start time as a unix timestamp. + * @param int $end_time The end time as a unix timestamp. + * @param string $type The type of entity (eg "user", "object" etc) + * @param string $subtype The arbitrary subtype of the entity + * @param int $owner_guid The GUID of the owning user + * @param int $limit The number of entities to return; 10 by default + * @param boolean $fullview Whether or not to display the full view (default: true) + * @param boolean $listtypetoggle Whether or not to allow gallery view + * @param boolean $navigation Display pagination? Default: true + * + * @return string A viewable list of entities + * @access private + * @deprecated 1.9 + */ +function list_notable_entities($start_time, $end_time, $type= "", $subtype = "", $owner_guid = 0, +$limit = 10, $fullview = true, $listtypetoggle = false, $navigation = true) { + elgg_deprecated_notice('list_notable_entities() has been deprecated', 1.9); + + $offset = (int) get_input('offset'); + $count = get_notable_entities($start_time, $end_time, $type, $subtype, + $owner_guid, "", $limit, $offset, true); + + $entities = get_notable_entities($start_time, $end_time, $type, $subtype, + $owner_guid, "", $limit, $offset); + + return elgg_view_entity_list($entities, $count, $offset, $limit, + $fullview, $listtypetoggle, $navigation); +} + +/** + * Return a list of today's entities. + * + * @see list_notable_entities + * + * @param string $type The type of entity (eg "user", "object" etc) + * @param string $subtype The arbitrary subtype of the entity + * @param int $owner_guid The GUID of the owning user + * @param int $limit The number of entities to return; 10 by default + * @param boolean $fullview Whether or not to display the full view (default: true) + * @param boolean $listtypetoggle Whether or not to allow gallery view + * @param boolean $navigation Display pagination? Default: true + * + * @return string A viewable list of entities + * @access private + * @deprecated 1.9 + */ +function list_todays_entities($type= "", $subtype = "", $owner_guid = 0, $limit = 10, +$fullview = true, $listtypetoggle = false, $navigation = true) { + elgg_deprecated_notice('list_todays_entities() has been deprecated', 1.9); + + $day_start = get_day_start(); + $day_end = get_day_end(); + + return list_notable_entities($day_start, $day_end, $type, $subtype, $owner_guid, $limit, + $fullview, $listtypetoggle, $navigation); +} diff --git a/engine/start.php b/engine/start.php index 454dc7377..1decc5d80 100644 --- a/engine/start.php +++ b/engine/start.php @@ -92,7 +92,7 @@ $lib_files = array( // these need to be loaded first. 'database.php', 'actions.php', - 'admin.php', 'annotations.php', 'calendar.php', + 'admin.php', 'annotations.php', 'configuration.php', 'cron.php', 'entities.php', 'export.php', 'extender.php', 'filestore.php', 'group.php', 'location.php', 'mb_wrapper.php', 'memcache.php', 'metadata.php', @@ -102,8 +102,8 @@ $lib_files = array( 'statistics.php', 'tags.php', 'user_settings.php', 'users.php', 'upgrade.php', 'web_services.php', 'widgets.php', 'xml.php', - //backwards compatibility - 'deprecated-1.7.php', 'deprecated-1.8.php', + // backward compatibility + 'deprecated-1.7.php', 'deprecated-1.8.php', 'deprecated-1.9.php' ); foreach ($lib_files as $file) { diff --git a/install/ElggInstaller.php b/install/ElggInstaller.php index 367d23b4d..2070f15e9 100644 --- a/install/ElggInstaller.php +++ b/install/ElggInstaller.php @@ -780,7 +780,7 @@ class ElggInstaller { 'database.php', 'actions.php', 'admin.php', 'annotations.php', - 'calendar.php', 'cron.php', 'entities.php', + 'cron.php', 'entities.php', 'extender.php', 'filestore.php', 'group.php', 'location.php', 'mb_wrapper.php', 'memcache.php', 'metadata.php', 'metastrings.php', @@ -791,7 +791,7 @@ class ElggInstaller { 'sites.php', 'statistics.php', 'tags.php', 'user_settings.php', 'users.php', 'upgrade.php', 'web_services.php', 'widgets.php', 'xml.php', 'deprecated-1.7.php', - 'deprecated-1.8.php', + 'deprecated-1.8.php', 'deprecated-1.9.php' ); foreach ($lib_files as $file) { -- cgit v1.2.3