]> gitweb.fluxo.info Git - lorea/elgg.git/commitdiff
Fixes #2719. Removing hack from bookmarks add. Now appends http:// to www.example...
authorbrettp <brettp@36083f99-b078-4883-b0ff-0f9b5a30f544>
Mon, 21 Feb 2011 00:38:27 +0000 (00:38 +0000)
committerbrettp <brettp@36083f99-b078-4883-b0ff-0f9b5a30f544>
Mon, 21 Feb 2011 00:38:27 +0000 (00:38 +0000)
git-svn-id: http://code.elgg.org/elgg/trunk@8378 36083f99-b078-4883-b0ff-0f9b5a30f544

mod/bookmarks/actions/bookmarks/save.php
mod/messageboard/actions/add.php
mod/messageboard/views/default/messageboard/js.php

index 02280838d45fb171941cfc1b90e82fe0e785e473..2f4f7b685fdd9eb5f6fd84d6b77724ea5c31e163 100644 (file)
@@ -18,17 +18,10 @@ $container_guid = get_input('container_guid', elgg_get_logged_in_user_guid());
 
 elgg_make_sticky_form('bookmarks');
 
-$normalized = elgg_normalize_url($address);
-
-// slight hack.  If the original link wasn't to this site, they probably didn't mean to post
-// a relative link.  deny the action.
-$site_url = elgg_get_site_entity()->url;
-$test = str_replace($site_url, '', $normalized);
-
-if (trim($address, '/') == trim($test, '/')) {
-       $address = '';
-} else {
-       $address = $normalized;
+// don't use elgg_normalize_url() because we don't want
+// relative links resolved to this site.
+if ($address && !preg_match("#^((ht|f)tps?:)?//#i", $address)) {
+       $address = "http://$address";
 }
 
 if (!$title || !$address || !filter_var($address, FILTER_VALIDATE_URL)) {
index 55bc5775a090bf94da82f2695501f1be5d6d2f25..971dd22fc56721d0e7c64e45c27d035c35a00668 100644 (file)
@@ -15,24 +15,17 @@ if ($owner && !empty($message_content)) {
        if ($result) {
                system_message(elgg_echo("messageboard:posted"));
 
-               // push the newest content out if using ajax
-               $is_ajax = array_key_exists('HTTP_X_REQUESTED_WITH', $_SERVER) && $_SERVER['HTTP_X_REQUESTED_WITH'] == 'XMLHttpRequest';
-               if ($is_ajax) {
-                       // always return the entity with the full ul and li
-                       // this is parsed out as needed by js.
-                       // if this is the only post we need to return the entire ul
-                       $options = array(
-                               'annotations_name' => 'messageboard',
-                               'guid' => $owner->getGUID(),
-                               'limit' => $num_display,
-                               'pagination' => false,
-                               'reverse_order_by' => true,
-                               'limit' => 1
-                       );
-
-                       $output = elgg_list_annotations($options);
-                       echo json_encode(array('post' => $output));
-               }
+               $options = array(
+                       'annotations_name' => 'messageboard',
+                       'guid' => $owner->getGUID(),
+                       'limit' => $num_display,
+                       'pagination' => false,
+                       'reverse_order_by' => true,
+                       'limit' => 1
+               );
+
+               $output = elgg_list_annotations($options);
+               echo $output;
 
        } else {
                register_error(elgg_echo("messageboard:failure"));
index 0ec56d7d9ea65c3dd8980d237f0e79014624e2ee..c638044083f7bc72ec859a289f8c71c7921076b4 100644 (file)
@@ -23,9 +23,9 @@ elgg.messageboard.submit = function(e) {
                        var ul = form.next('ul.elgg-annotation-list');
 
                        if (ul.length < 1) {
-                               form.parent().append(json.output.post);
+                               form.parent().append(json.output);
                        } else {
-                               ul.prepend($(json.output.post).find('li:first'));
+                               ul.prepend($(json.output).find('li:first'));
                        };
                        form.find('textarea').val('');
                }