]> gitweb.fluxo.info Git - lorea/elgg.git/commitdiff
Deprecated elgg_validate_action_url() by elgg_add_action_tokens_to_url(). Updated...
authorbrettp <brettp@36083f99-b078-4883-b0ff-0f9b5a30f544>
Sun, 21 Feb 2010 22:04:32 +0000 (22:04 +0000)
committerbrettp <brettp@36083f99-b078-4883-b0ff-0f9b5a30f544>
Sun, 21 Feb 2010 22:04:32 +0000 (22:04 +0000)
git-svn-id: http://code.elgg.org/elgg/trunk@3962 36083f99-b078-4883-b0ff-0f9b5a30f544

CHANGES.txt
engine/lib/elgglib.php
views/default/output/confirmlink.php
views/default/output/url.php
views/default/page_elements/spotlight.php

index 4fcd086e37235e26f62eb10bc001391d998553ec..9d81e92500e15d9a43a273ffe170903df3a2e64b 100644 (file)
@@ -46,6 +46,7 @@ http://code.elgg.org/elgg/.....
   * Added elgg_http_add_url_query_elements().
   * Added elgg_register_tag_metadata_name() and elgg_get_registered_tag_metadata_names();
   * Added ElggEntity::getTags().
+  * Added elgg_add_action_tokens_to_url().
 
  Services API:
   * Separated user and api authenticate processing
index 09940082ccdbe82cbff3bab37ba18e552a9baafe..5f3bfc9f925328124fe844a78eb9feddd8ff3e86 100644 (file)
@@ -2099,7 +2099,7 @@ function run_function_once($functionname, $timelastupdatedcheck = 0) {
 /**
  * Sends a notice about deprecated use of a function, view, etc.
  * Note: This will ALWAYS at least log a warning.  Don't use to pre-deprecate things.
- * This assume we are releasing in order and deprecating according to policy.
+ * This assumes we are releasing in order and deprecating according to policy.
  *
  * @param str $msg Message to log / display.
  * @param str $version human-readable *release* version the function was deprecated. No bloody A, B, (R)C, or D.
@@ -2110,7 +2110,7 @@ function elgg_deprecated_notice($msg, $dep_version) {
        // if it's a major release behind, visual and logged
        // if it's a 2 minor releases behind, visual and logged
        // if it's 1 minor release behind, logged.
-       // bugfixes don't matter because you're not deprecating between the, RIGHT?
+       // bugfixes don't matter because you're not deprecating between them, RIGHT?
 
        if (!$dep_version) {
                return FALSE;
@@ -2137,12 +2137,19 @@ function elgg_deprecated_notice($msg, $dep_version) {
 
        $msg = "Deprecated in $dep_version: $msg";
 
-       elgg_log($msg, 'WARNING');
-
        if ($visual) {
                register_error($msg);
        }
 
+       // Get a file and line number for the log. Never show this in the UI.
+       // Skip over the function that sent this notice and see who called the deprecated
+       // function itself.
+       $backtrace = debug_backtrace();
+       $caller = $backtrace[1];
+       $msg .= " (Called from {$caller['file']}:{$caller['line']})";
+
+       elgg_log($msg, 'WARNING');
+
        return TRUE;
 }
 
@@ -2553,33 +2560,43 @@ function elgg_http_build_url(array $parts) {
        return $string;
 }
 
+
 /**
- * Ensures action tokens are present in the given link
+ * Adds action tokens to URL
  *
  * @param str $link Full action URL
- * @return str Validated URL
+ * @return str URL with action tokens
  * @since 1.7
  */
-function elgg_validate_action_url($link) {
-       $url = parse_url($link);
+function elgg_add_action_tokens_to_url($url) {
+       $components = parse_url($url);
 
-       if (isset($url['query'])) {
-               $query = elgg_parse_str($url['query']);
+       if (isset($components['query'])) {
+               $query = elgg_parse_str($components['query']);
        } else {
                $query = array();
        }
 
        if (isset($query['__elgg_ts']) && isset($query['__elgg_token'])) {
-               return $link;
+               return $url;
        }
 
        // append action tokens to the existing query
        $query['__elgg_ts'] = time();
        $query['__elgg_token'] = generate_action_token($query['__elgg_ts']);
-       $url['query'] = http_build_query($query);
+       $components['query'] = http_build_query($query);
 
        // rebuild the full url
-       return elgg_http_build_url($url);
+       return elgg_http_build_url($components);
+}
+
+/**
+ * @deprecated 1.7 final
+ */
+function elgg_validate_action_url($url) {
+       elgg_deprecated_notice('elgg_validate_action_url had a short life. Use elgg_add_action_tokens_to_url() instead.', '1.7b');
+
+       return elgg_add_action_tokens_to_url($url);
 }
 
 /**
index 9377426ad62b517e05d8f807d5b89124088570bd..3370320ed7567f0682f6bbf0e100df36c8adcac1 100644 (file)
@@ -20,7 +20,7 @@ if (!$confirm) {
 }
 
 // always generate missing action tokens
-$link = elgg_validate_action_url($vars['href']);
+$link = elgg_add_action_tokens_to_url($vars['href']);
 
 if (isset($vars['class']) && $vars['class']) {
        $class = 'class="' . $vars['class'] . '"';
index a2e659854a389872f8f68d85f657e54fc0187e5f..7d993c49ef6ce3657d2dae2cfbd7026c9b503ddd 100644 (file)
@@ -25,7 +25,7 @@ $url = trim($vars['href']);
 
 if (!empty($url)) {
        if (array_key_exists('is_action', $vars) && $vars['is_action']) {
-               $url = elgg_validate_action_url($url);
+               $url = elgg_add_action_tokens_to_url($url);
        }
 
        if (array_key_exists('target', $vars) && $vars['target']) {
index 1c32f9b1d9bad083094dc3f97d973969e7b4480a..0c7e49c0f3cdc99a21a778adb26fd41991c754f6 100644 (file)
        }
        if ($closed) {
 ?>
-               <a href="javascript:void(0);" class="toggle_box_contents" onClick="$.post('<?php echo elgg_validate_action_url("{$vars['url']}action/user/spotlight?closed=false"); ?>')">+</a>
+               <a href="javascript:void(0);" class="toggle_box_contents" onClick="$.post('<?php echo elgg_add_action_tokens_to_url("{$vars['url']}action/user/spotlight?closed=false"); ?>')">+</a>
 <?php
                } else {
 ?>
-               <a href="javascript:void(0);" class="toggle_box_contents" onClick="$.post('<?php echo elgg_validate_action_url("{$vars['url']}action/user/spotlight?closed=true"); ?>')">-</a>
+               <a href="javascript:void(0);" class="toggle_box_contents" onClick="$.post('<?php echo elgg_add_action_tokens_to_url("{$vars['url']}action/user/spotlight?closed=true"); ?>')">-</a>
 <?php
 
                }