]> git.mjollnir.org Git - s9y.git/commitdiff
backports
authorgarvinhicking <garvinhicking>
Fri, 27 May 2005 09:36:48 +0000 (09:36 +0000)
committergarvinhicking <garvinhicking>
Fri, 27 May 2005 09:36:48 +0000 (09:36 +0000)
docs/NEWS
include/admin/category.inc.php
index.php
plugins/serendipity_event_spartacus/serendipity_event_spartacus.php
serendipity_xmlrpc.php

index 7589581c40086d0f0fa7720901b94eed94efab36..2c903e8eeea234b855d749653b3c0bd9f54c4173 100644 (file)
--- a/docs/NEWS
+++ b/docs/NEWS
@@ -3,6 +3,18 @@ svn di# $Id$
 Version 0.8.2 ()
 ------------------------------------------------------------------------
 
+    * Patch/Bug #1209410 by swiesinger: When using shortcut admin URL,
+      use https:// when specified by user
+
+    * Fix deleting categories when having privileges but not being
+      administrator (Patch #1205347, many thanks to Penny Leach)
+
+    * Increased level of output message from the Spartacus plugin
+      (garvinhicking)
+
+    * Patched XML-RPC functions, thanks to Tim Putnam. This should enable
+      XML-RPC services to properly fetch existing articles and edit them.
+
     * Fix Plugin API call performing too many unneeded SQL queries
       (garvinhicking)
 
index f81f3c261c85795a2af886df3c1a6a252d47bafb..bc53c0a53cd5c19e9ce8ab78b917d3844be730fd 100644 (file)
@@ -114,6 +114,7 @@ if ($serendipity['GET']['adminAction'] == 'doDelete') {
 
 <?php
     if ( $serendipity['GET']['adminAction'] == 'delete' ) {
+        $this_cat = serendipity_fetchCategoryInfo($serendipity['GET']['cid']);
         if ($serendipity['serendipityUserlevel'] >= USERLEVEL_CHIEF || $serendipity['authorid'] == $this_cat['authorid'] || $this_cat['authorid'] == '0') {
 ?>
         <form method="POST" name="serendipityCategory" action="?serendipity[adminModule]=category&amp;serendipity[adminAction]=doDelete&amp;serendipity[cid]=<?php echo $serendipity['GET']['cid'] ?>">
index fd982242df7383c43e5c8507e590fbc6d9fa332d..70ee5dfda9153d4c72c5feff14676b02305a6470 100644 (file)
--- a/index.php
+++ b/index.php
@@ -206,7 +206,11 @@ if (preg_match(PAT_ARCHIVES, $uri, $matches) || isset($serendipity['GET']['range
     print $data;
     exit;
 } else if (preg_match(PAT_ADMIN, $uri)) {
-    header("Location: {$serendipity['baseURL']}serendipity_admin.php");
+    $base = $serendipity['baseURL'];    
+    if (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') {        
+       $base = str_replace('http://', 'https://', $base);    
+    }    
+    header("Location: {$base}serendipity_admin.php");
     exit;
 } else if (preg_match(PAT_ARCHIVE, $uri)) {
     $serendipity['GET']['action'] = 'archives';
index 9b2597a06d81d0cdd62ae25fb3b8acd3e4d86aec..ca58fefbb15036b609ba216162c8dc2c72d221ad 100644 (file)
@@ -21,7 +21,11 @@ switch ($serendipity['lang']) {
         @define('PLUGIN_EVENT_SPARTACUS_FETCH', 'Hier klicken um ein neues %s aus dem Netz zu installieren.');
         @define('PLUGIN_EVENT_SPARTACUS_FETCHERROR', 'Die URL %s konnte nicht geöffnet werden. Möglicherweise existieren Server- oder Netzwerkprobleme.');
         @define('PLUGIN_EVENT_SPARTACUS_FETCHING', 'Versuche URL %s zu öffnen...');
+        @define('PLUGIN_EVENT_SPARTACUS_FETCHED_BYTES_URL', '%s bytes von obiger URL geladen. Speichere Inhalt als %s...');
+        @define('PLUGIN_EVENT_SPARTACUS_FETCHED_BYTES_CACHE', '%s bytes von bereits bestehender Datei geladen. Speichere Inhalt als %s...');
+        @define('PLUGIN_EVENT_SPARTACUS_FETCHED_DONE', 'Data successfully fetched.');
         break;
+
     case 'en':
     default:
         @define('PLUGIN_EVENT_SPARTACUS_NAME', 'Spartacus');
@@ -29,6 +33,9 @@ switch ($serendipity['lang']) {
         @define('PLUGIN_EVENT_SPARTACUS_FETCH', 'Click here to fetch a new %s from the Serendipity Online Repository');
         @define('PLUGIN_EVENT_SPARTACUS_FETCHERROR', 'The URL %s could not be opened. Maybe the Serendipity or SourceForge.net Server is down - we are sorry, you need to try again later.');
         @define('PLUGIN_EVENT_SPARTACUS_FETCHING', 'Trying to open URL %s...');
+        @define('PLUGIN_EVENT_SPARTACUS_FETCHED_BYTES_URL', 'Fetched %s bytes from the URL above. Saving file as %s...');
+        @define('PLUGIN_EVENT_SPARTACUS_FETCHED_BYTES_CACHE', 'Fetched %s bytes from already existing file on your server. Saving file as %s...');
+        @define('PLUGIN_EVENT_SPARTACUS_FETCHED_DONE', 'Data successfully fetched.');
         break;
 }
 
@@ -44,7 +51,7 @@ class serendipity_event_spartacus extends serendipity_event
         $propbag->add('description',   PLUGIN_EVENT_SPARTACUS_DESC);
         $propbag->add('stackable',     false);
         $propbag->add('author',        'Garvin Hicking');
-        $propbag->add('version',       '1.01');
+        $propbag->add('version',       '1.1');
         $propbag->add('requirements',  array(
             'serendipity' => '0.8',
             'smarty'      => '2.6.7',
@@ -120,23 +127,30 @@ class serendipity_event_spartacus extends serendipity_event
     }
 
     function &fetchfile($url, $target, $cacheTimeout = 0) {
-        printf(PLUGIN_EVENT_SPARTACUS_FETCHING, '<a href="' . $url . '">' . serendipity_truncateString($url, 68) . '</a>');
+        printf(PLUGIN_EVENT_SPARTACUS_FETCHING, '<a href="' . $url . '">' . basename($url) . '</a>');
         echo '<br />';
 
         if (file_exists($target) && filesize($target) > 0 && filemtime($target) >= (time()-$cacheTimeout)) {
             $data = file_get_contents($target);
+            printf(PLUGIN_EVENT_SPARTACUS_FETCHED_BYTES_CACHE, strlen($data), $target);
+            echo '<br />';
         } else {
             require_once S9Y_INCLUDE_PATH . 'bundled-libs/HTTP/Request.php';
             $req = &new HTTP_Request($url);
 
             if (PEAR::isError($req->sendRequest()) || $req->getResponseCode() != '200') {
                 printf(PLUGIN_EVENT_SPARTACUS_FETCHERROR, $url);
+                echo '<br />';
                 if (file_exists($target) && filesize($target) > 0) {
                     $data = file_get_contents($target);
+                    printf(PLUGIN_EVENT_SPARTACUS_FETCHED_BYTES_CACHE, strlen($data), $target);
+                    echo '<br />';
                 }
             } else {
                 // Fetch file
                 $data = $req->getResponseBody();
+                printf(PLUGIN_EVENT_SPARTACUS_FETCHED_BYTES_URL, strlen($data), $target);
+                echo '<br />';
                 $tdir = dirname($target);
                 if (!is_dir($tdir) && !$this->rmkdir($tdir)) {
                     printf(FILE_WRITE_ERROR, $tdir);
@@ -148,11 +162,14 @@ class serendipity_event_spartacus extends serendipity_event
 
                 if (!$fp) {
                     printf(FILE_WRITE_ERROR, $target);
+                    echo '<br />';
                     return false;
                 }
 
                 fwrite($fp, $data);
                 fclose($fp);
+                echo PLUGIN_EVENT_SPARTACUS_FETCHED_DONE;                
+                echo '<br />';
             }
         }
 
@@ -277,6 +294,7 @@ class serendipity_event_spartacus extends serendipity_event
         $pdir = $serendipity['serendipityPath'] . '/plugins/';
         if (!is_writable($pdir)) {
             printf(DIRECTORY_WRITE_ERROR, $pdir);
+            echo '<br />';
             return false;
         }
 
index d82df223f68baea4d8483e25a8d4fb76fd393ffa..9883a269c853a0fc5f21e65310ef980251ba6401 100644 (file)
@@ -46,7 +46,7 @@ $dispatches = array(
                     'metaWeblog.newMediaObject' =>
                         array('function' => 'metaWeblog_newMediaObject'),
                     'metaWeblog.getRecentPosts' =>
-                        array('function' => 'mt_getRecentPostTitles'),
+                        array('function' => 'metaWeblog_getRecentPosts'),
                     'mt.getRecentPostTitles' =>
                         array('function' => 'mt_getRecentPostTitles'),
                     'mt.getCategoryList' =>
@@ -118,9 +118,10 @@ function blogger_getRecentPosts($message) {
             array(
                   'postid'      => new XML_RPC_Value($entry['id'], 'string'),
                   'title'       => new XML_RPC_Value($entry['title'], 'string'),
+                  'content'                    => new XML_RPC_Value($entry['body'], 'string'),
                   'userid'      => new XML_RPC_Value($entry['authorid'], 'string'),
-                  'dateCreated' => new XML_RPC_Value(XML_RPC_iso8601_encode($entry['timestamp']), 'dateTime.iso8601'),
-                  'postid'      => new XML_RPC_Value($entry['id'], 'string')), 'struct');
+                  'dateCreated' => new XML_RPC_Value(XML_RPC_iso8601_encode($entry['timestamp']), 'dateTime.iso8601')
+                  ), 'struct');
     }
     $xml_entries = new XML_RPC_Value($xml_entries_vals, 'array');
     return new XML_RPC_Response($xml_entries);
@@ -168,6 +169,44 @@ function mt_getCategoryList($message) {
     return new XML_RPC_Response($xml_entries);
 }
 
+function metaWeblog_getRecentPosts($message) {
+    $val = $message->params[1];
+    $username = $val->getval();
+    $val = $message->params[2];
+    $password = $val->getval();
+    $val = $message->params[3];
+    $numposts = $val->getval();
+    if (!serendipity_authenticate_author($username, $password)) {
+        return new XML_RPC_Response('', 4, 'Authentication Failed');
+    }
+    $entries = serendipity_fetchEntries('', false, $numposts);
+    $xml_entries_vals = array();
+
+    foreach ($entries as $tentry) {
+        $entry = serendipity_fetchEntry('id', $tentry['id']);
+        $xml_entries_vals[] = new XML_RPC_Value(
+            array(
+                'dateCreated'       => new XML_RPC_Value(XML_RPC_iso8601_encode($entry['timestamp']), 'dateTime.iso8601'),
+                'postid'            => new XML_RPC_Value($entry['id'], 'string'),
+                'userid'            => new XML_RPC_Value($entry['authorid'], 'string'),
+                'description'       => new XML_RPC_Value($entry['body'], 'string'),
+                'mt_excerpt'        => new XML_RPC_Value('', 'string'),
+                'mt_allow_comments' => new XML_RPC_Value(1, 'int'),
+                'mt_text_more'         => new XML_RPC_Value($entry['extended'], 'string' ),
+                'mt_allow_pings'    => new XML_RPC_Value(1, 'int'),
+                'mt_convert_breaks' => new XML_RPC_Value('', 'string'),
+                'mt_keywords'       => new XML_RPC_Value('', 'string'),
+                'title'             => new XML_RPC_Value($entry['title'],'string'),
+                'permalink'         => new XML_RPC_Value(serendipity_archiveURL($entry['id'], $entry['title'], 'serendipityHTTPPath', true, array('timestamp' => $entry['timestamp'])), 'string'),
+                'link'              => new XML_RPC_Value(serendipity_archiveURL($entry['id'], $entry['title'], 'serendipityHTTPPath', true, array('timestamp' => $entry['timestamp'])), 'string')
+             ),
+            'struct');
+            
+     }
+    $xml_entries = new XML_RPC_Value($xml_entries_vals, 'array');
+    return new XML_RPC_Response($xml_entries);
+
+}
 function mt_getRecentPostTitles($message) {
     $val = $message->params[1];
     $username = $val->getval();
@@ -186,8 +225,7 @@ function mt_getRecentPostTitles($message) {
                 'postid'      => new XML_RPC_Value($entry['id'], 'string'),
                 'title'       => new XML_RPC_Value($entry['title'], 'string'),
                 'userid'      => new XML_RPC_Value($entry['authorid'], 'string'),
-                'dateCreated' => new XML_RPC_Value(XML_RPC_iso8601_encode($entry['timestamp']), 'dateTime.iso8601'),
-                'postid'      => new XML_RPC_Value($entry['id'], 'string')
+                'dateCreated' => new XML_RPC_Value(XML_RPC_iso8601_encode($entry['timestamp']), 'dateTime.iso8601')
             ),
             'struct');
     }
@@ -211,6 +249,12 @@ function blogger_newPost($message) {
     }
     $val = $message->params[4];
     $entry['body']  = $val->getval();
+    $val = $message->params[5];
+    $topublish = $val->getval();
+    if ($topublish == 1){
+        $entry['isdraft'] = 'false';
+    } else { $entry['isdraft'] = 'true'; }
+    
     $entry['allow_comments'] = $serendipity['allowCommentsDefault'];
     $entry['moderate_comments'] = $serendipity['moderateCommentsDefault'];
     $id = serendipity_updertEntry($entry);
@@ -244,9 +288,7 @@ function blogger_deletePost($message) {
     if (!serendipity_authenticate_author($username, $password)) {
         return new XML_RPC_Response('', 4, 'Authentication Failed');
     }
-    $val = $message->params[4];
-    $entry['body']  = $val->getval();
-    $entry['author'] = $username;
+    
     $id = serendipity_deleteEntry($entry['id']);
     return new XML_RPC_Response(new XML_RPC_Value(1, 'boolean'));
 }
@@ -289,13 +331,20 @@ function metaWeblog_newPost($message) {
     $val = $message->params[4];
     $publish = $val->getval();
 
+       
     $entry['categories']        = universal_fetchCategories($post_array['categories']);
     $entry['title']             = $post_array['title'];
     $entry['body']              = $post_array['description'];
     $entry['extended']          = $post_array['mt_text_more'];
     $entry['isdraft']           = ($publish == 0) ? 'true' : 'false';
-    $entry['allow_comments']    = $serendipity['allowCommentsDefault'];
+    if (isset($post_array['mt_allow_comments'])) {
+        $entry['allow_comments'] = $post_array['mt_allow_comments'];
+    } else {
+        $entry['allow_comments'] = $serendipity['allowCommentsDefault'];
+    }
+
     $entry['moderate_comments'] = $serendipity['moderateCommentsDefault'];
+    $entry['keywords'] = $post_array['mt_keywords'];
 
     $id = serendipity_updertEntry($entry);
 
@@ -342,7 +391,9 @@ function metaWeblog_editPost($message) {
     $val = $message->params[4];
     $publish = $val->getval();
 
-    $entry['categories']    = universal_fetchCategories($post_array['categories']);
+    if (isset($post_array['categories'])) {
+       $entry['categories'] = universal_fetchCategories($post_array['categories']);
+    }
     $entry['title']         = $post_array['title'];
     $entry['body']          = $post_array['description'];
     $entry['extended']      = $post_array['mt_text_more'];
@@ -355,6 +406,7 @@ function metaWeblog_editPost($message) {
     return new XML_RPC_Response(new XML_RPC_Value($id ? true : false, 'boolean'));
 }
 
+
 function metaWeblog_getPost($message) {
     global $serendipity;
     $val = $message->params[0];
@@ -368,9 +420,23 @@ function metaWeblog_getPost($message) {
     }
 
     $entry = serendipity_fetchEntry('id', $postid);
-    $entry = new XML_RPC_Value(metaWeblog_setEntry($entry), 'struct');
 
-    return new XML_RPC_Response($entry);
+    $tmp = new XML_RPC_Value(array(
+        'userid'            => new XML_RPC_Value($entry['authorid'], 'string'),
+        'dateCreated'       => new XML_RPC_Value(XML_RPC_iso8601_encode($entry['timestamp']), 'dateTime.iso8601'),
+        'postid'            => new XML_RPC_Value($postid, 'string'),
+        'description'       => new XML_RPC_Value($entry['body'], 'string'),
+        'title'             => new XML_RPC_Value($entry['title'],'string'),
+        'link'              => new XML_RPC_Value(serendipity_archiveURL($entry['id'], $entry['title'], 'baseURL', true, array('timestamp' => $entry['timestamp'])), 'string'),
+        'permalink'         => new XML_RPC_Value(serendipity_archiveURL($entry['id'], $entry['title'], 'baseURL', true, array('timestamp' => $entry['timestamp'])), 'string'),
+        'mt_excerpt'        => new XML_RPC_Value($entry['excerpt'], 'string'),
+        'mt_text_more'      => new XML_RPC_Value($entry['extended'], 'string'),
+        'mt_allow_comments' => new XML_RPC_Value($entry['allow_comments'], 'int'),
+        'mt_allow_pings'    => new XML_RPC_Value($entry['mt_allow_pings'], 'int'),
+        'mt_convert_breaks' => new XML_RPC_Value($entry['mt_convert_breaks'], 'string'),
+        'mt_keywords'       => new XML_RPC_Value($entry['mt_keywords'], 'string')), 'struct');
+
+    return new XML_RPC_Response($tmp);
 }
 
 function metaWeblog_deletePost($message) {
@@ -405,7 +471,10 @@ function metaWeblog_setPostCategories($message) {
     }
 
     $category_ids = universal_fetchCategories($categories->getval(), true);
-    serendipity_updateEntryCategories($postid, $category_ids);
+    $entry = serendipity_fetchEntry ( 'id', $postid );
+    $entry['categories'] = $category_ids;
+    $entry = serendipity_updertEntry ( $entry );
+    //serendipity_updateEntryCategories($postid, $category_ids);
     return new XML_RPC_Response(new XML_RPC_Value(1, 'boolean'));
 }
 
@@ -459,7 +528,7 @@ function metaWeblog_newMediaObject($message) {
     }
 
     $fp = fopen($full, 'w');
-    fwrite($fp, base64_decode($struct['bits']));
+    fwrite($fp, $struct['bits']);
     fclose($fp);
     $path = $serendipity['baseURL'] . $serendipity['uploadPath'] . $struct['name'];
     return new XML_RPC_Response(new XML_RPC_Value(array('url' => new XML_RPC_Value($path, 'string')), 'struct'));