]> git.mjollnir.org Git - s9y.git/commitdiff
Abstract PEAR HTTP_Request calls so that plugins can modify the input data
authorgarvinhicking <garvinhicking>
Thu, 12 Jan 2006 15:39:37 +0000 (15:39 +0000)
committergarvinhicking <garvinhicking>
Thu, 12 Jan 2006 15:39:37 +0000 (15:39 +0000)
docs/NEWS
include/admin/images.inc.php
include/functions_trackbacks.inc.php
plugins/serendipity_event_spartacus/serendipity_event_spartacus.php
plugins/serendipity_event_weblogping/serendipity_event_weblogping.php

index ac6e9debf490124a0cc93e87abd087483b0eea61..8d6427e6f492df9cd42335098b8c12ff1eba3b00 100644 (file)
--- a/docs/NEWS
+++ b/docs/NEWS
@@ -3,6 +3,10 @@
 Version 1.0 ()
 ------------------------------------------------------------------------
 
+   * Add new plugin hook "backend_http_request" which passes PEAR 
+     HTTP_Request options to plugins for modification. $addData contains
+     the source of where a request is being made (garvinhicking)
+
    * Make WordPress importer not fail on the missing "user_level" column
      for WordPress 2.0 (garvinhicking)
 
index c7c8a7a8d935ce83eb812149a7ad67f3c2d17c87..4d57de9310b03e895d7f450d209c2ec4e8bf073a 100644 (file)
@@ -174,7 +174,9 @@ switch ($serendipity['GET']['adminAction']) {
             echo '(' . $target . ') ' . ERROR_FILE_EXISTS_ALREADY;
         } else {
             require_once S9Y_PEAR_PATH . 'HTTP/Request.php';
-            $req = &new HTTP_Request($serendipity['POST']['imageurl']);
+            $options = array();
+            serendipity_plugin_api::hook_event('backend_http_request', $options, 'image');
+            $req = &new HTTP_Request($serendipity['POST']['imageurl'], $options);
             // Try to get the URL
 
             if (PEAR::isError($req->sendRequest()) || $req->getResponseCode() != '200') {
index 82c012310458704a4fd4f735f93d10800a80e888..96138270cfb55f1e1a875b17c2b3f25b49d80480 100644 (file)
@@ -84,7 +84,9 @@ function _serendipity_send($loc, $data) {
 
     $uri = $target['scheme'] . '://' . $target['host'] . ':' . $target['port'] . $target['path'] . $target['query'];
     require_once S9Y_PEAR_PATH . 'HTTP/Request.php';
-    $req = &new HTTP_Request($uri, array('allowRedirects' => true, 'maxRedirects' => 5, 'method' => 'POST'));
+    $options = array('allowRedirects' => true, 'maxRedirects' => 5, 'method' => 'POST');
+    serendipity_plugin_api::hook_event('backend_http_request', $options, 'trackback_send');
+    $req = &new HTTP_Request($uri, $options);
     $req->addRawPostData($data, true);
     $res = $req->sendRequest();
 
@@ -190,7 +192,9 @@ global $serendipity;
     $parsed_loc = $u['scheme'] . '://' . $u['host'] . $port . $u['path'];
 
     require_once S9Y_PEAR_PATH . 'HTTP/Request.php';
-    $req = &new HTTP_Request($parsed_loc, array('allowRedirects' => true, 'maxRedirects' => 5, 'method' => 'GET'));
+    $options = array('allowRedirects' => true, 'maxRedirects' => 5, 'method' => 'GET');
+    serendipity_plugin_api::hook_event('backend_http_request', $options, 'trackback_detect');
+    $req = &new HTTP_Request($parsed_loc, $options);
     $res = $req->sendRequest();
 
     if (PEAR::isError($res)) {
index 20e3591f79896763c9365f5d3e6337fe834bfb0b..ec27fb1a77c25f6f5e46f1e51ae6154faa9674b3 100644 (file)
@@ -254,7 +254,9 @@ class serendipity_event_spartacus extends serendipity_event
             echo '<br />';
         } else {
             require_once S9Y_PEAR_PATH . 'HTTP/Request.php';
-            $req = &new HTTP_Request($url);
+            $options = array();
+            serendipity_plugin_api::hook_event('backend_http_request', $options, 'spartacus');
+            $req = &new HTTP_Request($url, $options);
 
             if (PEAR::isError($req->sendRequest()) || $req->getResponseCode() != '200') {
                 printf(PLUGIN_EVENT_SPARTACUS_FETCHERROR, $url);
index 83edbf4d3308bad8b7e7122b6c962c2b36cfb194..7acdca27790a343195ef0d8b628ce46fbd8d5d9c 100644 (file)
@@ -196,7 +196,9 @@ class serendipity_event_weblogping extends serendipity_event
 
                             # 15 second timeout may not be long enough for weblogs.com
                             $message->createPayload();
-                            $req = new HTTP_Request("http://".$service['host'].$service['path']);
+                            $options = array();
+                            serendipity_plugin_api::hook_event('backend_http_request', $options, 'weblogping');
+                            $req = new HTTP_Request("http://".$service['host'].$service['path'], $options);
                             $req->setMethod(HTTP_REQUEST_METHOD_POST);
                             $req->addHeader("Content-Type", "text/xml");
                             if (strtoupper(LANG_CHARSET) != 'UTF-8') {