[pLog-svn] r3996 - in plog/trunk: . class/action/admin class/dao
class/dao/userdata class/gallery/dao class/gallery/resizers
class/net class/net/xmlrpc class/summary/dao
class/template/smarty/plugins class/test/tests/extra
class/test/tests/net class/test/tests/net/xmlrpc
class/test/tests/summary class/test/tests/summary/dao locale
templates/admin templates/summary/rss
mark at devel.lifetype.net
mark at devel.lifetype.net
Tue Sep 19 17:41:39 GMT 2006
Author: mark
Date: 2006-09-19 17:41:39 +0000 (Tue, 19 Sep 2006)
New Revision: 3996
Added:
plog/trunk/class/net/xmlrpc/xmlrpcserver.class.php
plog/trunk/class/test/tests/extra/xmlrpcserver_test.class.php
plog/trunk/class/test/tests/net/xmlrpc/
plog/trunk/class/test/tests/net/xmlrpc/xmlrpcserver_test.class.php
plog/trunk/class/test/tests/summary/dao/
plog/trunk/class/test/tests/summary/dao/summarystats_test.class.php
Removed:
plog/trunk/class/test/tests/net/xmlrpc/xmlrpcserver_test.class.php
plog/trunk/class/test/tests/summary/dao/summarystats_test.class.php
Modified:
plog/trunk/class/action/admin/adminadduseraction.class.php
plog/trunk/class/dao/articlecategories.class.php
plog/trunk/class/dao/articlecategory.class.php
plog/trunk/class/dao/userdata/baseuserdataprovider.class.php
plog/trunk/class/dao/userdata/phpbb2userdataprovider.class.php
plog/trunk/class/dao/userdata/simplepostnukeuserdataprovider.class.php
plog/trunk/class/gallery/dao/galleryresources.class.php
plog/trunk/class/gallery/resizers/galleryabstractresizer.class.php
plog/trunk/class/gallery/resizers/galleryresizer.class.php
plog/trunk/class/net/prettyrequestgenerator.class.php
plog/trunk/class/net/xmlrpc/IXR_Library.lib.php
plog/trunk/class/summary/dao/summarystats.class.php
plog/trunk/class/template/smarty/plugins/function.pager.php
plog/trunk/locale/locale_ca_ES.php
plog/trunk/templates/admin/editpost.template
plog/trunk/templates/admin/editposts.template
plog/trunk/templates/summary/rss/blogs_rss10.template
plog/trunk/templates/summary/rss/blogs_rss20.template
plog/trunk/wizard.php
plog/trunk/xmlrpc.php
Log:
Merge the changes from LifeType branch 1.1.1 (From SVN Rev. 3968:3995)
Modified: plog/trunk/class/action/admin/adminadduseraction.class.php
===================================================================
--- plog/trunk/class/action/admin/adminadduseraction.class.php 2006-09-19 16:18:36 UTC (rev 3995)
+++ plog/trunk/class/action/admin/adminadduseraction.class.php 2006-09-19 17:41:39 UTC (rev 3996)
@@ -38,7 +38,7 @@
$this->registerFieldValidator( "userEmail", new EmailValidator());
$this->registerFieldValidator( "userStatus", new IntegerValidator());
$this->registerField( "userFullName" );
- $this->registerFieldValidator( "blogId", new IntegerValidator());
+ $this->registerFieldValidator( "blogId", new IntegerValidator(), true );
$this->registerField( "blogName" );
$view = new AdminAddUserView( $this->_blogInfo );
$this->setValidationErrorView( $view );
Modified: plog/trunk/class/dao/articlecategories.class.php
===================================================================
--- plog/trunk/class/dao/articlecategories.class.php 2006-09-19 16:18:36 UTC (rev 3995)
+++ plog/trunk/class/dao/articlecategories.class.php 2006-09-19 17:41:39 UTC (rev 3996)
@@ -226,7 +226,7 @@
* @return False if error or the article category identifier if successful.
* @see Category
*/
- function addArticleCategory( $articleCategory )
+ function addArticleCategory( &$articleCategory )
{
if(( $result = $this->add( $articleCategory, Array( CACHE_ARTICLE_CATEGORIES => "getId" )))) {
$this->_cache->removeData( $articleCategory->getBlogId(), CACHE_ARTICLE_CATEGORIES_BLOG );
Modified: plog/trunk/class/dao/articlecategory.class.php
===================================================================
--- plog/trunk/class/dao/articlecategory.class.php 2006-09-19 16:18:36 UTC (rev 3995)
+++ plog/trunk/class/dao/articlecategory.class.php 2006-09-19 17:41:39 UTC (rev 3996)
@@ -23,6 +23,7 @@
var $_lastModification;
var $_blog;
var $_mangledName;
+ var $_articles;
/**
* Creates an article category.
Modified: plog/trunk/class/dao/userdata/baseuserdataprovider.class.php
===================================================================
--- plog/trunk/class/dao/userdata/baseuserdataprovider.class.php 2006-09-19 16:18:36 UTC (rev 3995)
+++ plog/trunk/class/dao/userdata/baseuserdataprovider.class.php 2006-09-19 17:41:39 UTC (rev 3996)
@@ -142,13 +142,15 @@
{
include_once( PLOG_CLASS_PATH."class/dao/userinfo.class.php" );
+ isset( $query_result["properties"] ) ? $properties = unserialize( $query_result["properties"] ) : $properties = Array();
+
$userInfo = new UserInfo( $query_result["user"],
$query_result["password"],
$query_result["email"],
$query_result["about"],
$query_result["full_name"],
$query_result["resource_picture_id"],
- unserialize($query_result["properties"]),
+ $properties,
$query_result["id"]);
// set some permissions
Modified: plog/trunk/class/dao/userdata/phpbb2userdataprovider.class.php
===================================================================
--- plog/trunk/class/dao/userdata/phpbb2userdataprovider.class.php 2006-09-19 16:18:36 UTC (rev 3995)
+++ plog/trunk/class/dao/userdata/phpbb2userdataprovider.class.php 2006-09-19 17:41:39 UTC (rev 3996)
@@ -170,6 +170,7 @@
"welcome" );
$t = new Timestamp();
$article->setDateObject( $t );
+ $article->setInSummary( false );
$articles = new Articles();
$articles->addArticle( $article );
}
Modified: plog/trunk/class/dao/userdata/simplepostnukeuserdataprovider.class.php
===================================================================
--- plog/trunk/class/dao/userdata/simplepostnukeuserdataprovider.class.php 2006-09-19 16:18:36 UTC (rev 3995)
+++ plog/trunk/class/dao/userdata/simplepostnukeuserdataprovider.class.php 2006-09-19 17:41:39 UTC (rev 3996)
@@ -164,6 +164,7 @@
"welcome" ); // slug
$t = new Timestamp();
$article->setDateObject( $t );
+ $article->setInSummary( false );
$articles = new Articles();
$articles->addArticle( $article );
}
Modified: plog/trunk/class/gallery/dao/galleryresources.class.php
===================================================================
--- plog/trunk/class/gallery/dao/galleryresources.class.php 2006-09-19 16:18:36 UTC (rev 3995)
+++ plog/trunk/class/gallery/dao/galleryresources.class.php 2006-09-19 17:41:39 UTC (rev 3996)
@@ -439,7 +439,7 @@
if( $resourceType == GALLERY_RESOURCE_IMAGE )
$flags = $flags|GALLERY_RESOURCE_PREVIEW_AVAILABLE;
- $info = $this->_filterMetadata( $metadata, $resourceType );
+ $info = $this->_filterMetadata( $metadata, $resourceType );
// add the record to the database
$fileName = $upload->getFileName();
@@ -467,15 +467,31 @@
// and finally, we can generate the thumbnail only if the file is an image, of course :)
if( $resourceType == GALLERY_RESOURCE_IMAGE ) {
- include_once( PLOG_CLASS_PATH."class/gallery/resizers/gallerythumbnailgenerator.class.php" );
- GalleryThumbnailGenerator::generateResourceThumbnail( $resFile, $resourceId, $ownerId );
- GalleryThumbnailGenerator::generateResourceMediumSizeThumbnail( $resFile, $resourceId, $ownerId );
- // call this method only if the settings are right
+ include_once( PLOG_CLASS_PATH."class/gallery/resizers/gallerythumbnailgenerator.class.php" );
+
include_once( PLOG_CLASS_PATH."class/config/config.class.php" );
- $config =& Config::getConfig();
- $previewHeight = $config->getValue( "final_size_thumbnail_height", 0 );
- $previewWidth = $config->getValue( "final_size_thumbnail_width", 0 );
- if( $previewHeight != 0 && $previewWidth != 0 ) {
+ $config =& Config::getConfig();
+
+ $imgWidth = $info["video"]["resolution_x"];
+ $imgHeight = $info["video"]["resolution_y"];
+
+ $previewHeight = $config->getValue( "thumbnail_height", GALLERY_DEFAULT_THUMBNAIL_HEIGHT );
+ $previewWidth = $config->getValue( "thumbnail_width", GALLERY_DEFAULT_THUMBNAIL_WIDTH );
+ if( $imgHeight > $previewHeight || $imgWidth > $previewWidth ) {
+ GalleryThumbnailGenerator::generateResourceThumbnail( $resFile, $resourceId, $ownerId );
+ }
+
+ $medPreviewHeight = $config->getValue( "medium_size_thumbnail_height", GALLERY_DEFAULT_MEDIUM_SIZE_THUMBNAIL_HEIGHT );
+ $medPreviewWidth = $config->getValue( "medium_size_thumbnail_width", GALLERY_DEFAULT_MEDIUM_SIZE_THUMBNAIL_WIDTH );
+ if( $imgHeight > $medPreviewHeight || $imgWidth > $medPreviewWidth ) {
+ GalleryThumbnailGenerator::generateResourceMediumSizeThumbnail( $resFile, $resourceId, $ownerId );
+ }
+
+ // call this method only if the settings are right and the image is bigger than the final size(s)
+ $finalPreviewHeight = $config->getValue( "final_size_thumbnail_height", 0 );
+ $finalPreviewWidth = $config->getValue( "final_size_thumbnail_width", 0 );
+ if(($previewHeight != 0 && $previewWidth != 0) &&
+ ($imgHeight > $finalPreviewHeight || $imgWidth > $finalPreviewWidth )) {
GalleryThumbnailGenerator::generateResourceFinalSizeThumbnail( $resFile, $resourceId, $ownerId );
// we have to recalculate the metadata because the image could be different... This is a bit cumbersome
// and repeats code. We know, thanks.
Modified: plog/trunk/class/gallery/resizers/galleryabstractresizer.class.php
===================================================================
--- plog/trunk/class/gallery/resizers/galleryabstractresizer.class.php 2006-09-19 16:18:36 UTC (rev 3995)
+++ plog/trunk/class/gallery/resizers/galleryabstractresizer.class.php 2006-09-19 17:41:39 UTC (rev 3996)
@@ -9,24 +9,35 @@
* the skeleton of the functions that should be implemented by the generators
* themselves.
*/
- class GalleryAbstractResizer
+ class GalleryAbstractResizer
{
var $_image;
var $_outputMethod;
+ var $_keepAspectRatio;
/**
* Constructor.
*
*/
function GalleryAbstractResizer( $image, $outputMethod )
- {
-
-
+ {
$this->_image = $image;
$this->_outputMethod = $outputMethod;
+ $this->_keepAspectRatio = true;
}
+ /**
+ * Informs the resizer to keep the aspect ratio of the image when resizing, although
+ * this value may be ignored by the resizer and it depends on the implementation.
+ *
+ * @param keepAspectRatio Whether to keep the aspect ratio
+ */
+ function setKeepAspectRatio( $keepAspectRatio )
+ {
+ $this->_keepAspectRatio = $keepAspectRatio;
+ }
+
/**
* Generates the thumbnail
* Uses the values set in the constructor regarding the width, height and output format
Modified: plog/trunk/class/gallery/resizers/galleryresizer.class.php
===================================================================
--- plog/trunk/class/gallery/resizers/galleryresizer.class.php 2006-09-19 16:18:36 UTC (rev 3995)
+++ plog/trunk/class/gallery/resizers/galleryresizer.class.php 2006-09-19 17:41:39 UTC (rev 3996)
@@ -106,7 +106,7 @@
$config =& Config::getConfig();
return $config->getValue( "thumbnail_format" );
}
-
+
/**
* Generates a thumbnail.
*
@@ -140,6 +140,7 @@
$outFile = $fileNoExt.".".$this->_defaultOutputFormat;
}
+ $generatorClassObject->setKeepAspectRatio( $keepAspectRatio );
$imgThumb = $generatorClassObject->generate( $outFile, $width, $height );
return $imgThumb;
Modified: plog/trunk/class/net/prettyrequestgenerator.class.php
===================================================================
--- plog/trunk/class/net/prettyrequestgenerator.class.php 2006-09-19 16:18:36 UTC (rev 3995)
+++ plog/trunk/class/net/prettyrequestgenerator.class.php 2006-09-19 17:41:39 UTC (rev 3996)
@@ -150,11 +150,11 @@
*
* @return Returns the url where the blog is running.
*/
- function blogLink( $blogInfo = null )
+ function blogLink( $blogInfo = null, $ignoreSubdomainSettings = false )
{
$config =& Config::getConfig();
// if subdomains are enabled, there is no need to do much more here...
- if( $config->getValue( "subdomains_enabled" )) {
+ if( $config->getValue( "subdomains_enabled" ) && !$ignoreSubdomainSettings ) {
$link = $this->getBaseUrl();
}
else {
@@ -382,12 +382,10 @@
}
else {
// if none of the above, we should at least get a link to the blog!
- $url = $this->blogLink();
+ $url = $this->blogLink( null, true );
}
- $pageFormat = "/page/";
-
- return( $url.$pageFormat );
+ return( $url."/page/" );
}
/**
Modified: plog/trunk/class/net/xmlrpc/IXR_Library.lib.php
===================================================================
--- plog/trunk/class/net/xmlrpc/IXR_Library.lib.php 2006-09-19 16:18:36 UTC (rev 3995)
+++ plog/trunk/class/net/xmlrpc/IXR_Library.lib.php 2006-09-19 17:41:39 UTC (rev 3996)
@@ -123,6 +123,7 @@
var $faultString;
var $methodName;
var $params;
+ var $rawmessage;
// Current variable stacks
var $_arraystructs = array(); // The stack used to keep track of the current array/struct
var $_arraystructstypes = array(); // Stack keeping track of if things are structs or array
@@ -135,6 +136,7 @@
var $_parser;
function IXR_Message ($message) {
$this->message = $message;
+ $this->rawmessage = $message;
}
function parse() {
// first remove the XML declaration
Copied: plog/trunk/class/net/xmlrpc/xmlrpcserver.class.php (from rev 3995, plog/branches/lifetype-1.1.1/class/net/xmlrpc/xmlrpcserver.class.php)
Modified: plog/trunk/class/summary/dao/summarystats.class.php
===================================================================
--- plog/trunk/class/summary/dao/summarystats.class.php 2006-09-19 16:18:36 UTC (rev 3995)
+++ plog/trunk/class/summary/dao/summarystats.class.php 2006-09-19 17:41:39 UTC (rev 3996)
@@ -239,11 +239,6 @@
if($globaArticleCategoryId != ALL_GLOBAL_ARTICLE_CATEGORIES)
$query .= " AND a.global_category_id = '".Db::qstr($globaArticleCategoryId)."'";
- //$query .= " GROUP BY a.id ORDER BY a.date DESC";
- /**
- * :TODO:
- * do we really need the GROUP BY? Why? MySQL does a better job without..
- */
$query .= " ORDER BY a.date DESC";
if( $maxPosts <= 0 )
@@ -345,20 +340,18 @@
return $count;
}
- function getNow() {
+ function getNow()
+ {
include_once( PLOG_CLASS_PATH.'class/data/timestamp.class.php' );
$time = new Timestamp();
- $now = $time->getYear().$time->getMonth();
- if( $time->getDay() < 10 )
- $now .= "0";
- $now .= $time->getDay();
- $now .= "235959";
+ $now = $time->getTimestamp();
return $now;
}
- function getStartTime( $duration ) {
+ function getStartTime( $duration )
+ {
include_once( PLOG_CLASS_PATH.'class/data/timestamp.class.php' );
$time = new Timestamp();
Modified: plog/trunk/class/template/smarty/plugins/function.pager.php
===================================================================
--- plog/trunk/class/template/smarty/plugins/function.pager.php 2006-09-19 16:18:36 UTC (rev 3995)
+++ plog/trunk/class/template/smarty/plugins/function.pager.php 2006-09-19 17:41:39 UTC (rev 3996)
@@ -67,13 +67,20 @@
$prevText = "«".$locale->tr( "previous_post" );
}
+ // number of pages shown in the beginning
+ isset( $params["beginning"] ) ? $beginning = $params["beginning"] : $beginning = 3;
+ // number of pages shown in the middle
+ isset( $params["middle"] ) ? $middle = $params["middle"] : $middle = 5;
+ // Number of pages shown in the end
+ isset( $params["end"] ) ? $end = $params["end"] : $end = 3;
+
$base_url = $pager->getBaseUrl();
$total_pages = $pager->getTotalPages();
$per_page = $pager->getRegsForPage();
$start_item = 1;
$add_prevnext_text = true;
- $on_page = $pager->getCurrentPage();
+ $on_page = $pager->getCurrentPage();
$page_string = '';
@@ -81,9 +88,9 @@
if ( $total_pages == 1 )
return '';
- if ( $total_pages > 10 )
+ if ( $total_pages > ($beginning + 1 + $middle + 1 + $middle + 1 + $end ))
{
- $init_page_max = ( $total_pages > 3 ) ? 3 : $total_pages;
+ $init_page_max = ( $total_pages > $beginning ) ? $beginning : $total_pages;
for($i = 1; $i < $init_page_max + 1; $i++) {
$page_string .= ( $i == $on_page ) ? "<span class=\"pagerCurrent\">$i</span>" : "<a class=\"pagerLink\" href=\"{$base_url}{$i}\">$i</a>";
@@ -92,33 +99,32 @@
}
}
- if ( $total_pages > 3 ) {
- if ( $on_page > 1 && $on_page < $total_pages ) {
- $page_string .= ( $on_page > 5 ) ? ' ... ' : $separator;
+ if ( $on_page > 1 && $on_page < $total_pages ) {
+ $page_string .= ( $on_page > ($beginning + $middle + 1) ) ? ' ... ' : $separator;
- $init_page_min = ( $on_page > 4 ) ? $on_page : 5;
- $init_page_max = ( $on_page < $total_pages - 4 ) ? $on_page : $total_pages - 4;
+ $init_page_min = ( $on_page > ($beginning + $middle) ) ? $on_page : ($beginning + $middle + 1 );
+ $init_page_max = ( $on_page < $total_pages - ($end + 1) ) ? $on_page : $total_pages - ($end + $middle);
- for($i = $init_page_min - 1; $i < $init_page_max + 2; $i++) {
- $page_string .= ( $i == $on_page ) ? "<span class=\"pagerCurrent\">$i</span>" : "<a class=\"pagerLink\" href=\"{$base_url}{$i}\">$i</a>";
- if ( $i < $init_page_max + 1 ) {
- $page_string .= $separator;
- }
- }
- $page_string .= ( $on_page < $total_pages - 4 ) ? ' ... ' : $separator;
- }
- else {
- $page_string .= ' ... ';
- }
-
- for($i = $total_pages - 2; $i < $total_pages + 1; $i++) {
+ for($i = $init_page_min - $middle; $i < $init_page_max + ($middle + 1); $i++) {
$page_string .= ( $i == $on_page ) ? "<span class=\"pagerCurrent\">$i</span>" : "<a class=\"pagerLink\" href=\"{$base_url}{$i}\">$i</a>";
- if( $i < $total_pages ) {
+ if ( $i < $init_page_max + 1 ) {
$page_string .= $separator;
}
}
+
+ $page_string .= ( $on_page < $total_pages - ($end + $middle) ) ? ' ... ' : $separator;
}
+ else {
+ $page_string .= ' ... ';
+ }
+
+ for($i = $total_pages - ($end - 1); $i < $total_pages + 1; $i++) {
+ $page_string .= ( $i == $on_page ) ? "<span class=\"pagerCurrent\">$i</span>" : "<a class=\"pagerLink\" href=\"{$base_url}{$i}\">$i</a>";
+ if( $i < $total_pages ) {
+ $page_string .= $separator;
+ }
+ }
}
else {
for($i = 1; $i < $total_pages + 1; $i++) {
Copied: plog/trunk/class/test/tests/extra/xmlrpcserver_test.class.php (from rev 3995, plog/branches/lifetype-1.1.1/class/test/tests/extra/xmlrpcserver_test.class.php)
Copied: plog/trunk/class/test/tests/net/xmlrpc (from rev 3995, plog/branches/lifetype-1.1.1/class/test/tests/net/xmlrpc)
Deleted: plog/trunk/class/test/tests/net/xmlrpc/xmlrpcserver_test.class.php
===================================================================
--- plog/branches/lifetype-1.1.1/class/test/tests/net/xmlrpc/xmlrpcserver_test.class.php 2006-09-19 16:18:36 UTC (rev 3995)
+++ plog/trunk/class/test/tests/net/xmlrpc/xmlrpcserver_test.class.php 2006-09-19 17:41:39 UTC (rev 3996)
@@ -1,553 +0,0 @@
-<?php
-
- include_once( PLOG_CLASS_PATH."class/test/helpers/lifetypetestcase.class.php" );
- include_once( PLOG_CLASS_PATH."class/config/config.class.php" );
- include_once( PLOG_CLASS_PATH."class/dao/blogs.class.php" );
- include_once( PLOG_CLASS_PATH."class/dao/bloginfo.class.php" );
- include_once( PLOG_CLASS_PATH."class/dao/users.class.php" );
- include_once( PLOG_CLASS_PATH."class/dao/userinfo.class.php" );
- include_once( PLOG_CLASS_PATH."class/dao/articlecategories.class.php" );
- include_once( PLOG_CLASS_PATH."class/dao/articlecategory.class.php" );
- include_once( PLOG_CLASS_PATH."class/dao/articles.class.php" );
- include_once( PLOG_CLASS_PATH."class/dao/userstatus.class.php" );
- include_once( PLOG_CLASS_PATH."class/net/xmlrpc/IXR_Library.lib.php" );
- include_once( PLOG_CLASS_PATH."class/net/url.class.php" );
- include_once( PLOG_CLASS_PATH."class/locale/locales.class.php" );
-
- /**
- * Unit test cases for xmlrpc.php
- */
- class XmlRpcServer_Test extends LifeTypeTestCase
- {
- /**
- * dummy blog we'll be using during the tests
- */
- var $blog;
-
- /**
- * dummy blog owner
- */
- var $owner;
-
- /**
- * dummy category
- */
- var $cat;
-
- /**
- * URL pointing to this server's xmlrpc.php
- */
-
- function setUp()
- {
- // create the blog owner
- $this->owner = new UserInfo( md5(time()), // name
- "password", // password
- "whatever at whatever.com", // email address
- "", // about
- "" );
- $users = new Users();
- if( !$users->addUser( $this->owner )) {
- throw( new Exception( "Error adding test user" ));
- die();
- }
-
- // load a UTF-8 locale
- $zhLocale =& Locales::getLocale( "zh_CN" );
-
- // create the test blog
- $blogs = new Blogs();
- $this->blog = null;
- $this->blog = new BlogInfo( "test blog",
- $this->owner->getId(),
- "",
- new BlogSettings());
- $this->blog->setLocale( $zhLocale );
- if( !$blogs->addBlog( $this->blog )) {
- throw( new Exception( "Error adding test blog!" ));
- die();
- }
-
- // add a default category
- $this->cat = new ArticleCategory( "General",
- "Description for category General",
- $this->blog->getId(),
- true );
- $cats = new ArticleCategories();
- if( !$cats->addArticleCategory( $this->cat )) {
- throw( new Exception( "Error adding test category!" ));
- die();
- }
-
- // get the URL pointing to xmlrpc.php
- $config =& Config::getConfig();
- $this->url = $config->getValue( "base_url" )."/xmlrpc.php";
- }
-
- function tearDown()
- {
- $users = new Users();
- $users->deleteUser( $this->owner->getId());
-
- $blogs = new Blogs();
- $blogs->deleteBlog( $this->blog->getId());
-
- $cats = new ArticleCategories();
- $cats->deleteCategory( $this->cat->getId(), $this->blog->getId());
- }
-
- /**
- * test the blogger.newPost method call
- */
- function testBloggerNewPost()
- {
- $c = new IXR_Client( $this->url );
- $res = $c->query( "blogger.newPost",
- "appkey",
- $this->blog->getId(),
- $this->owner->getUsername(),
- "password",
- "blah blah",
- true );
-
- // see that the call was successful
- $this->assertTrue( $res, "Unable to query ".$this->url." with method blogger.newPost" );
-
- // get the post id and check it in the db
- $artId = $c->getResponse();
- $articles = new Articles();
- $article = $articles->getArticle( $artId );
- $this->assertTrue( $article, "Could not load article with id = ".$artId );
- if( !$article )
- return;
- // check that the post has the expected values
- $this->assertEquals( "blah blah", $article->getText());
- $this->assertEquals( "blah blah", $article->getTopic());
-
- // delete the article
- $articles->deleteArticle( $artId, $this->owner->getId(), $this->blog->getId(), true );
-
- // get the response and see that it has the right encoding
- $this->assertTrue( $this->checkResponseEncoding( $c->message->rawmessage, $this->blog),
- "The blog encoding and the response of the XMLRPC request did not match!" );
-
- /** test the embedded topic feature **/
- $res = $c->query( "blogger.newPost",
- "appkey",
- $this->blog->getId(),
- $this->owner->getUsername(),
- "password",
- "topic\nblah blah",
- true );
-
- // see that the call was successful
- $this->assertTrue( $res, "Unable to query ".$this->url." with method blogger.newPost" );
-
- // get the post id and check it in the db
- $artId = $c->getResponse();
- $articles = new Articles();
- $article = $articles->getArticle( $artId );
- $this->assertTrue( $article, "Could not load article with id = ".$artId );
- if( !$article )
- return;
- // check that the post has the expected values
- $this->assertEquals( "blah blah", $article->getText());
- $this->assertEquals( "topic", $article->getTopic());
-
- // delete the article
- $articles->deleteArticle( $artId, $this->owner->getId(), $this->blog->getId(), true );
-
- // get the response and see that it has the right encoding
- $this->assertTrue( $this->checkResponseEncoding( $c->message->rawmessage, $this->blog),
- "The blog encoding and the response of the XMLRPC request did not match!" );
-
- }
-
- /**
- * test the blogger.getUserInfo method cal
- */
- function testBloggerGetUserInfo()
- {
- $c = new IXR_Client( $this->url );
- $res = $c->query( "blogger.getUserInfo",
- "appkey",
- $this->owner->getUsername(),
- "password" );
-
- // see that the call was successful
- $this->assertTrue( $res, "Unable to query ".$this->url." with method blogger.getUserInfo" );
-
- // and check the data in the response
- $userData = $c->getResponse();
-
- $this->assertEquals( $this->owner->getUsername(), $userData["nickname"], "The user nickname did not match!" );
- $this->assertEquals( $this->owner->getUsername(), $userData["firstname"], "The user firstname did not match!" );
- $this->assertEquals( $this->owner->getEmail(), $userData["email"], "The user email address did not match!" );
- $this->assertEquals( $this->owner->getId(), $userData["userid"], "The user id did not match!" );
-
- // get the response and see that it has the right encoding
- $this->assertTrue( $this->checkResponseEncoding( $c->message->rawmessage, $this->blog ),
- "The blog encoding and the response of the XMLRPC request did not match!" );
- }
-
- /**
- * test the blogger.getUserInfo method call
- */
- function testBloggerGetUsersBlogs()
- {
- $c = new IXR_Client( $this->url );
- $res = $c->query( "blogger.getUsersBlogs",
- "appkey",
- $this->owner->getUsername(),
- "password" );
-
- // see that the call was successful
- $this->assertTrue( $res, "Unable to query ".$this->url." with method blogger.getUsersBlogs" );
-
- // and check the data in the response
- $blogs = $c->getResponse();
- // there should be only one blog
- $this->assertEquals( $this->blog->getId(), $blogs[0]["blogid"] );
- $this->assertEquals( $this->blog->getBlog(), $blogs[0]["blogName"] );
- $url = $this->blog->getBlogRequestGenerator();
- $this->assertEquals( $url->blogLink(), $blogs[0]["url"] );
-
- // get the response and see that it has the right encoding
- $this->assertTrue( $this->checkResponseEncoding( $c->message->rawmessage, $this->blog ),
- "The blog encoding and the response of the XMLRPC request did not match!" );
- }
-
- /**
- * test the blogger.editPost method call
- */
- function testBloggerEditPost()
- {
- // create a new post first
- $article = new Article(
- "topic",
- "text",
- Array( $this->cat->getId()),
- $this->owner->getId(),
- $this->blog->getId(),
- POST_STATUS_PUBLISHED,
- 0
- );
- $articles = new Articles();
- $this->assertTrue( $articles->addArticle( $article ), "Unable to add a new article" );
-
- // make the method call
- $c = new IXR_Client( $this->url );
- $res = $c->query( "blogger.editPost",
- "appkey",
- $article->getId(),
- $this->owner->getUsername(),
- "password",
- "updated text",
- true );
-
- // see that the call was successful
- $this->assertTrue( $res, "Unable to query ".$this->url." with method blogger.editPost" );
-
- // check the data in the response and make sure we got a 'true'
- $success = $c->getResponse();
- $this->assertTrue( $success, "XMLRPC server returned error while updating the post" );
-
- // check that the post was successfully updated
- $updatedArticle = $articles->getArticle( $article->getId());
- // check that the text is the updated version
- $this->assertEquals( "updated text", $updatedArticle->getText());
- $this->assertEquals( "updated text", $updatedArticle->getTopic());
-
- // get the response and see that it has the right encoding
- $this->assertTrue( $this->checkResponseEncoding( $c->message->rawmessage, $this->blog ),
- "The blog encoding and the response of the XMLRPC request did not match!" );
-
- /*** test the embedded topic feature ***/
-
- // make the method call
- $c = new IXR_Client( $this->url );
- $res = $c->query( "blogger.editPost",
- "appkey",
- $article->getId(),
- $this->owner->getUsername(),
- "password",
- "topic\nupdated text",
- true );
-
- // see that the call was successful
- $this->assertTrue( $res, "Unable to query ".$this->url." with method blogger.editPost" );
-
- // check the data in the response and make sure we got a 'true'
- $success = $c->getResponse();
- $this->assertTrue( $success, "XMLRPC server returned error while updating the post" );
-
- // check that the post was successfully updated
- $updatedArticle = $articles->getArticle( $article->getId());
- // check that the text is the updated version
- $this->assertEquals( "updated text", $updatedArticle->getText(), "Article text did not mach the expected text!" );
- $this->assertEquals( "topic", $updatedArticle->getTopic(), "Article topic was not set correctly" );
-
- // get the response and see that it has the right encoding
- $this->assertTrue( $this->checkResponseEncoding( $c->message->rawmessage, $this->blog ),
- "The blog encoding and the response of the XMLRPC request did not match!" );
-
- // delete the post
- $articles->deleteArticle( $updatedArticle->getId(), $this->owner->getId(), $this->blog->getId());
- }
-
- /**
- * Test case the blogger.deletePost method call
- */
- function testBloggerDeletePost()
- {
- // create a new post first
- $article = new Article(
- "topic",
- "text",
- Array( $this->cat->getId()),
- $this->owner->getId(),
- $this->blog->getId(),
- POST_STATUS_PUBLISHED,
- 0
- );
- $articles = new Articles();
- $this->assertTrue( $articles->addArticle( $article ), "Unable to add a new test article" );
-
- // make the method call
- $c = new IXR_Client( $this->url );
- $res = $c->query( "blogger.deletePost",
- "appkey",
- $article->getId(),
- $this->owner->getUsername(),
- "password",
- true );
-
- // see that the call was successful
- $this->assertTrue( $res, "Unable to query ".$this->url." with method blogger.deletePost" );
-
- // make sure that the call returned ok
- $response = $c->getResponse();
- $this->assertTrue( $response, "blogger.deletePost did not return true" );
-
- // check that the post was marked as 'deleted' in the database
- $updatedArticle = $articles->getArticle( $article->getId());
- $this->assertEquals( $updatedArticle->getStatus(),
- POST_STATUS_DELETED,
- "Article was not properly deleted after calling blogger.deletePost" );
-
- // get the response and see that it has the right encoding
- $this->assertTrue( $this->checkResponseEncoding( $c->message->rawmessage, $this->blog ),
- "The blog encoding and the response of the XMLRPC request did not match!" );
- }
-
- /**
- * test case for blogger.getRecentPosts
- */
- function testBloggerGetRecentPosts()
- {
- // create a new post first
- $article = new Article(
- "topic",
- "text",
- Array( $this->cat->getId()),
- $this->owner->getId(),
- $this->blog->getId(),
- POST_STATUS_PUBLISHED,
- 0
- );
- $articles = new Articles();
- $this->assertTrue( $articles->addArticle( $article ), "Unable to add the first tet article" );
- $article2 = new Article(
- "topic 2",
- "text 2",
- Array( $this->cat->getId()),
- $this->owner->getId(),
- $this->blog->getId(),
- POST_STATUS_PUBLISHED,
- 0
- );
- $this->assertTrue( $articles->addArticle( $article ), "Unable to add the second test article" );
-
- // make the method call
- $c = new IXR_Client( $this->url );
- $res = $c->query( "blogger.getRecentPosts",
- "appkey",
- $this->blog->getId(),
- $this->owner->getUsername(),
- "password",
- 10 );
-
- // see that the call was successful
- $this->assertTrue( $res, "Unable to query ".$this->url." with method blogger.getRecentPosts" );
-
- // make sure that the call returned ok
- $response = $c->getResponse();
- $this->assertTrue( $response, "blogger.getRecentPosts did not return a valid response" );
- // and make sure that we got two articles
- $this->assertEquals( 2, count($response), "The number of articles returned by blogger.getRecentPosts is not correct" );
-
- // get the response and see that it has the right encoding
- $this->assertTrue( $this->checkResponseEncoding( $c->message->rawmessage, $this->blog ),
- "The blog encoding and the response of the XMLRPC request did not match!" );
-
- // delete the articles
- $articles->deleteArticle( $article->getId(), $this->owner->getId(), $this->blog->getId(), true );
- $articles->deleteArticle( $article2->getId(), $this->owner->getId(), $this->blog->getId(), true );
- }
-
- /**
- * test case for blogger.getPost
- */
- function testBloggerGetPost()
- {
- // create a new post first
- $article = new Article(
- "topic",
- "text",
- Array( $this->cat->getId()),
- $this->owner->getId(),
- $this->blog->getId(),
- POST_STATUS_PUBLISHED,
- 0
- );
- $articles = new Articles();
- $this->assertTrue( $articles->addArticle( $article ), "Unable to add a new test article" );
-
- // make the method call
- $c = new IXR_Client( $this->url );
- $res = $c->query( "blogger.getPost",
- "appkey",
- $article->getId(),
- $this->owner->getUsername(),
- "password" );
-
- // see that the call was successful
- $this->assertTrue( $res, "Unable to query ".$this->url." with method blogger.getPost" );
-
- // make sure that the call returned ok
- $response = $c->getResponse();
- $this->assertTrue( $response, "blogger.getPost did not return a valid response" );
-
- // and now compare that the returned values match with what we expected
- $this->assertEquals( $this->owner->getId(), $response["userid"], "The user id of the article does not match" );
- $this->assertEquals( "topic\ntext", $response["content"] );
- $this->assertEquals( $article->getId(), $response["postid"] );
-
- $this->assertTrue( $articles->deleteArticle( $article->getId(), $this->owner->getId(), $this->blog->getId(), true ),
- "Error deleting article" );
-
- // get the response and see that it has the right encoding
- $this->assertTrue( $this->checkResponseEncoding( $c->message->rawmessage, $this->blog ),
- "The blog encoding and the response of the XMLRPC request did not match!" );
- }
-
- /**
- * test case for the metaWeblog.getPost method call
- */
- function testMetaWeblogGetPost()
- {
- // create a new post first
- $article = new Article(
- "topic",
- "text",
- Array( $this->cat->getId()),
- $this->owner->getId(),
- $this->blog->getId(),
- POST_STATUS_PUBLISHED,
- 0
- );
- $articles = new Articles();
- $this->assertTrue( $articles->addArticle( $article ), "Unable to add a new test article" );
-
- // make the method call
- $c = new IXR_Client( $this->url );
- $res = $c->query( "metaWeblog.getPost",
- $article->getId(),
- $this->owner->getUsername(),
- "password" );
-
- // see that the call was successful
- $this->assertTrue( $res, "Unable to query ".$this->url." with method metaweblog.getPost" );
-
- // make sure that the call returned ok
- $response = $c->getResponse();
- $this->assertTrue( $response, "metaWeblog.getPost did not return a valid response" );
-
- // and now compare that the returned values match with what we expected
- $this->assertEquals( $this->owner->getId(), $response["userid"], "The user id of the article does not match" );
- $this->assertEquals( "topic", $article->getTopic(), "The topic of the post does not match" );
- $this->assertEquals( "text", $article->getText(), "The text of the article does not match" );
- $this->assertEquals( $article->getId(), $response["postid"] );
- $url = $this->blog->getBlogRequestGenerator();
- $this->assertEquals( $url->postLink( $article ), $response["link"], "The post permalink does not match" );
- $this->assertEquals( $url->postPermalink( $article ), $response["permaLink"], "The post permalink does not match" );
-
- $this->assertTrue( $articles->deleteArticle( $article->getId(), $this->owner->getId(), $this->blog->getId(), true ),
- "Error deleting article" );
-
- // get the response and see that it has the right encoding
- $this->assertTrue( $this->checkResponseEncoding( $c->message->rawmessage, $this->blog ),
- "The blog encoding and the response of the XMLRPC request did not match!" );
- }
-
- /**
- * Test the metaWeblog.getCategories
- */
- function testMetaWeblogGetCategories()
- {
- // make the method call
- $c = new IXR_Client( $this->url );
- $res = $c->query( "metaWeblog.getCategories",
- $this->blog->getId(),
- $this->owner->getUsername(),
- "password" );
-
- // see that the call was successful
- $this->assertTrue( $res, "Unable to query ".$this->url." with method metaweblog.getCategories" );
-
- // make sure that the call returned ok
- $response = $c->getResponse();
- $this->assertTrue( $response, "metaWeblog.getCategories did not return a valid response" );
-
- // there should only be one category
- $this->assertTrue(( count( $response ) == 1 ), "There should only be one category returned by metaWeblog.getCategories" );
-
- // check that the category settings are correct
- $this->assertEquals( $this->cat->getName(), key($response), "The category name did not match" );
- $this->assertEquals( $this->cat->getDescription(), $response["General"]["description"], "The category description did not match" );
- $url = $this->blog->getBlogRequestGenerator();
- $url->setXHTML( false );
- $this->assertEquals( $url->categoryLink( $this->cat ), $response["General"]["htmlUrl"], "The category link did not match" );
-
- // get the response and see that it has the right encoding
- $this->assertTrue( $this->checkResponseEncoding( $c->message->rawmessage, $this->blog ),
- "The blog encoding and the response of the XMLRPC request did not match!" );
- }
-
- function testMetaWeblogGetRecentPosts()
- {
-
- }
-
- /**
- * @private
- */
- function checkResponseEncoding( $response, $blog )
- {
- // check the character encoding in the response
- $numMatches = preg_match( "/<\\?xml.*version=\"1.0\".*encoding=\"(.*)\".*\?>.*/i",
- $response,
- $matches );
- if( $numMatches != 1 )
- return false;
-
- $encoding = $matches[1];
-
- // check that the blog encoding and what we got in the response is the same
- $locale = $this->blog->getLocale();
- $blogEncoding = $locale->getCharSet();
-
- return( $locale->getCharset() == $encoding );
- }
- }
-?>
\ No newline at end of file
Copied: plog/trunk/class/test/tests/net/xmlrpc/xmlrpcserver_test.class.php (from rev 3995, plog/branches/lifetype-1.1.1/class/test/tests/net/xmlrpc/xmlrpcserver_test.class.php)
Copied: plog/trunk/class/test/tests/summary/dao (from rev 3995, plog/branches/lifetype-1.1.1/class/test/tests/summary/dao)
Deleted: plog/trunk/class/test/tests/summary/dao/summarystats_test.class.php
===================================================================
--- plog/branches/lifetype-1.1.1/class/test/tests/summary/dao/summarystats_test.class.php 2006-09-19 16:18:36 UTC (rev 3995)
+++ plog/trunk/class/test/tests/summary/dao/summarystats_test.class.php 2006-09-19 17:41:39 UTC (rev 3996)
@@ -1,131 +0,0 @@
-<?php
-
- include_once( PLOG_CLASS_PATH."class/test/helpers/lifetypetestcase.class.php" );
- include_once( PLOG_CLASS_PATH."class/dao/article.class.php" );
- include_once( PLOG_CLASS_PATH."class/dao/blogs.class.php" );
- include_once( PLOG_CLASS_PATH."class/dao/bloginfo.class.php" );
- include_once( PLOG_CLASS_PATH."class/dao/users.class.php" );
- include_once( PLOG_CLASS_PATH."class/dao/userinfo.class.php" );
- include_once( PLOG_CLASS_PATH."class/dao/articlecategories.class.php" );
- include_once( PLOG_CLASS_PATH."class/dao/articlecategory.class.php" );
- include_once( PLOG_CLASS_PATH."class/dao/articles.class.php" );
- include_once( PLOG_CLASS_PATH."class/dao/userstatus.class.php" );
- include_once( PLOG_CLASS_PATH."class/summary/dao/summarystats.class.php" );
-
- /**
- * Unit test cases for the SummaryStats class
- */
- class SummaryStats_Test extends LifeTypeTestCase
- {
- /**
- * dummy blog we'll be using during the tests
- */
- var $blog;
-
- /**
- * dummy blog owner
- */
- var $owner;
-
- /**
- * dummy category
- */
- var $cat;
-
- /**
- * URL pointing to this server's xmlrpc.php
- */
-
- function setUp()
- {
- // create the blog owner
- $this->owner = new UserInfo( md5(time()), // name
- "password", // password
- "whatever at whatever.com", // email address
- "", // about
- "" );
- $users = new Users();
- if( !$users->addUser( $this->owner )) {
- throw( new Exception( "Error adding test user" ));
- die();
- }
-
- // create the test blog
- $blogs = new Blogs();
- $this->blog = null;
- $this->blog = new BlogInfo( "test blog",
- $this->owner->getId(),
- "",
- new BlogSettings());
- if( !$blogs->addBlog( $this->blog )) {
- throw( new Exception( "Error adding test blog!" ));
- die();
- }
-
- // add a default category
- $this->cat = new ArticleCategory( "General",
- "",
- $this->blog->getId(),
- true );
- $cats = new ArticleCategories();
- if( !$cats->addArticleCategory( $this->cat )) {
- throw( new Exception( "Error adding test category!" ));
- die();
- }
- }
-
- function tearDown()
- {
- $users = new Users();
- $users->deleteUser( $this->owner->getId());
-
- $blogs = new Blogs();
- $blogs->deleteBlog( $this->blog->getId());
-
- $cats = new ArticleCategories();
- $cats->deleteCategory( $this->cat->getId(), $this->blog->getId());
- }
-
- /**
- * Test case for SummaryStats::getRecentArticles and mantis case 1052
- * (http://bugs.lifetype.net/view.php?id=1052)
- */
- function testGetRecentArticlesIgnoreFuturePosts()
- {
- // create a new post first
- $article = new Article(
- "topic",
- "text",
- Array( $this->cat->getId()),
- $this->owner->getId(),
- $this->blog->getId(),
- POST_STATUS_PUBLISHED,
- 0
- );
- // set the date within 5 minutes
- //$t = Timestamp::getTimestampWithOffset( new Timestamp(), 2 );
- $t = new Timestamp();
- $t->addSeconds( 5 * 60 );
- $article->setDateObject( $t );
-
- // save the article and check
- $articles = new Articles();
- $this->assertTrue( $articles->addArticle( $article ), "Unable to add a new test article" );
-
- // load the list of recent posts and check that the one we've just added, which
- // has a date in the future, isn't there
- $stats = new SummaryStats();
- $posts = $stats->getRecentArticles();
- $i = 0;
- $found = false;
- while( $i < count( $posts ) && !$found ) {
- $found = ($posts[$i]->getId() == $article->getId());
- $i++;
- }
-
- $this->assertFalse( $found, "A post with date in the future was returned by getRecentPosts" );
-
- $this->assertTrue( $articles->deleteArticle( $article->getId(), $this->owner->getId(), $this->blog->getId()));
- }
- }
-?>
\ No newline at end of file
Copied: plog/trunk/class/test/tests/summary/dao/summarystats_test.class.php (from rev 3995, plog/branches/lifetype-1.1.1/class/test/tests/summary/dao/summarystats_test.class.php)
Modified: plog/trunk/locale/locale_ca_ES.php
===================================================================
--- plog/trunk/locale/locale_ca_ES.php 2006-09-19 16:18:36 UTC (rev 3995)
+++ plog/trunk/locale/locale_ca_ES.php 2006-09-19 17:41:39 UTC (rev 3996)
@@ -498,7 +498,7 @@
$messages['oldest_first'] = 'Els més antic primer';
$messages['newest_first'] = 'Els més recent primer';
$messages['categories_order'] = 'Ordre de les categories';
-$messages['categories_order_help'] = 'Ordre dels comentaris a la pàgina principal';
+$messages['categories_order_help'] = 'Ordre de les categories a la pàgina principal';
$messages['most_recent_updated_first'] = 'El més recent primer';
$messages['alphabetical_order'] = 'Ordre alfabètic';
$messages['reverse_alphabetical_order'] = 'Ordre alfabètic invers';
Modified: plog/trunk/templates/admin/editpost.template
===================================================================
--- plog/trunk/templates/admin/editpost.template 2006-09-19 16:18:36 UTC (rev 3995)
+++ plog/trunk/templates/admin/editpost.template 2006-09-19 17:41:39 UTC (rev 3996)
@@ -123,7 +123,7 @@
<span class="required">*</span>
<div class="formHelp">{$locale->tr("global_article_category_help")}</div>
<select name="globalArticleCategoryId" id="globalArticleCategoryId" size="1" style="width:100%">
- <option value="0">{$locale->tr("none")}</option>
+ <option value="0" {if 0 == $globalArticleCategoryId} selected="selected" {/if}>{$locale->tr("none")}</option>
{foreach from=$globalcategories item=globalcategory}
<option value="{$globalcategory->getId()}" {if $globalcategory->getId() == $globalArticleCategoryId} selected="selected" {/if}>{$globalcategory->getName()}</option>
{/foreach}
Modified: plog/trunk/templates/admin/editposts.template
===================================================================
--- plog/trunk/templates/admin/editposts.template 2006-09-19 16:18:36 UTC (rev 3995)
+++ plog/trunk/templates/admin/editposts.template 2006-09-19 17:41:39 UTC (rev 3996)
@@ -38,8 +38,8 @@
<br />
<select name="showUser" id="showUser">
<option value="0" {if $currentuser == 0} selected="selected" {/if}>{$locale->tr("author_all")}</option>
- {foreach from=$users item=user}
- <option value="{$user->getId()}" {if $currentuser == $user->getId()} selected="selected" {/if}>{$user->getUsername()}</option>
+ {foreach from=$users item=bloguser}
+ <option value="{$bloguser->getId()}" {if $currentuser == $bloguser->getId()} selected="selected" {/if}>{$bloguser->getUsername()}</option>
{/foreach}
</select>
</div>
Modified: plog/trunk/templates/summary/rss/blogs_rss10.template
===================================================================
--- plog/trunk/templates/summary/rss/blogs_rss10.template 2006-09-19 16:18:36 UTC (rev 3995)
+++ plog/trunk/templates/summary/rss/blogs_rss10.template 2006-09-19 17:41:39 UTC (rev 3996)
@@ -16,7 +16,7 @@
<title>{$blog->getBlog()|escape}</title>
<dc:title>{$blog->getBlog()|escape}</dc:title>
<description>{$blog->getAbout()|escape}</description>
- <link>{$url->blogLink}</link>
+ <link>{$url->blogLink()}</link>
{assign var="blogDate" value=$blog->getCreateDateObject()}
<dc:date>{$locale->formatDate($blogDate, "%Y-%m-%d %H:%M:%S")}</dc:date>
{assign var="blogOwner" value=$blog->getOwnerInfo()}
Modified: plog/trunk/templates/summary/rss/blogs_rss20.template
===================================================================
--- plog/trunk/templates/summary/rss/blogs_rss20.template 2006-09-19 16:18:36 UTC (rev 3995)
+++ plog/trunk/templates/summary/rss/blogs_rss20.template 2006-09-19 17:41:39 UTC (rev 3996)
@@ -5,7 +5,7 @@
<title>Your service title</title>
<description>Your service description</description>
<link>{$url->getBaseUrl(false)}/summary.php</link>
- <generator>LifeType 1.0</generator>
+ <generator>LifeType 1.1</generator>
{foreach from=$blogs item=blog}
{assign var=url value=$blog->getBlogRequestGenerator()}
<item>
Modified: plog/trunk/wizard.php
===================================================================
--- plog/trunk/wizard.php 2006-09-19 16:18:36 UTC (rev 3995)
+++ plog/trunk/wizard.php 2006-09-19 17:41:39 UTC (rev 3996)
@@ -1785,11 +1785,11 @@
// build the insert query
$insert = "INSERT INTO ".$this->dbPrefix."articles_comments
(article_id, blog_id, topic, text, date, user_email, user_url, user_name, parent_id,
- client_ip, send_notification, status, spam_rate, normalized_text, normalized_topic,
- type)
+ client_ip, send_notification, status, spam_rate, properties, normalized_text, normalized_topic, type)
VALUES (".$row["article_id"].",".$row["blog_id"].",'".Db::qstr($row["title"])."','".
Db::qstr($row["excerpt"])."','".$row["date"]."','','".$row["url"]."','".
Db::qstr($row["blog_name"])."', '0', '0.0.0.0','0', '0', '0','".
+ serialize(array())."','".
Textfilter::urlize( $row["excerpt"] )."','".
Textfilter::urlize( $row["title"] )."','2')";
Modified: plog/trunk/xmlrpc.php
===================================================================
--- plog/trunk/xmlrpc.php 2006-09-19 16:18:36 UTC (rev 3995)
+++ plog/trunk/xmlrpc.php 2006-09-19 17:41:39 UTC (rev 3996)
@@ -4,946 +4,8 @@
define( "PLOG_CLASS_PATH", dirname(__FILE__)."/");
}
-
- // include required classes, dont know what, but it works for me :-)
-
- include_once( PLOG_CLASS_PATH."class/net/xmlrpc/IXR_Library.lib.php" );
- include_once( PLOG_CLASS_PATH."class/config/config.class.php" );
- include_once( PLOG_CLASS_PATH."class/database/db.class.php" );
- include_once( PLOG_CLASS_PATH."class/dao/users.class.php");
- include_once( PLOG_CLASS_PATH."class/dao/article.class.php");
- include_once( PLOG_CLASS_PATH."class/dao/articles.class.php");
- include_once( PLOG_CLASS_PATH."class/dao/articlecategories.class.php");
- include_once( PLOG_CLASS_PATH."class/dao/users.class.php" );
- include_once( PLOG_CLASS_PATH."class/dao/blogs.class.php" );
- include_once( PLOG_CLASS_PATH."class/template/cachecontrol.class.php" );
- include_once( PLOG_CLASS_PATH."class/gallery/dao/galleryalbums.class.php" );
- include_once( PLOG_CLASS_PATH."class/gallery/dao/galleryresources.class.php" );
- include_once( PLOG_CLASS_PATH."class/plugin/pluginmanager.class.php" );
+ include_once( PLOG_CLASS_PATH."class/net/xmlrpc/xmlrpcserver.class.php" );
+ $server = new XmlRpcServer();
- // init database
- $_db = new Db;
- $adodb = $_db->getDb();
-
- // config object
- $config =& Config::getConfig();
-
- // users object
- $users = new Users;
-
- // articles object
- $articles = new Articles;
-
- // category object
- $category = new ArticleCategories;
-
- // blog object
- $blogsG = new Blogs;
-
-
-
- function newPost($args)
- {
- global $users, $articles, $category, $blogsG;
- $appkey = $args[0];
- $blogid = $args[1];
- $username = $args[2];
- $password = $args[3];
- $content = $args[4];
- $publish = $args[5]; // true post&publish | false post only
- /*
- int postid
- */
-
- // -mhe todo security
-
- $auth = $users->authenticateUser( $username, $password );
-
- if ($auth)
- {
- if ($publish)
- {
- $status = POST_STATUS_PUBLISHED;
- } else
- {
- $status = POST_STATUS_DRAFT;
- }
-
- // Get the default category
- $cats = $category->getBlogCategories($blogid);
-
- // some protection again blogs without categories
- if( !$cats ) {
- return new IXR_Error(-1, 'This blog does not have categories!');
- }
-
- foreach($cats as $cat)
- {
- $idCategory = $cat->getId();
- // Stop here, we have a category
- break;
- }
-
- // ecto sends the topic as <title>blah blah</title>rest of the body
- if( preg_match( "/<title>(.*)<\/title>(.*)/i", $content, $matches )) {
- $title = $matches[1];
- $content = $matches[2];
- }
- else {
- $dummy = explode("\n", $content);
- $title = $dummy[0];
- unset($dummy[0]);
- $content = implode("\n", $dummy);
- unset($dummy);
- }
-
- $userInfo = $users->getUserInfoFromUsername( $username );
-
- $article = new Article(
- $title,
- $content, // text
- Array( $idCategory ), // catid
- $userInfo->getId(), // userid
- $blogid, // blogid
- $status,
- 0, // numread
- Array( "comments_enabled" => true ) // enable comments
- );
-
- $article->setDate(date("YmdHis"));
-
- $blogInfo = $blogsG->getBlogInfo( $blogid );
-
- // Get the plugin manager
- $plugMgr =& PluginManager::getPluginManager();
- $plugMgr->setBlogInfo( $blogInfo);
- $plugMgr->setUserInfo( $userInfo );
- $plugMgr->loadPlugins();
- // Send the PRE_POST_POST_ADD message
- $plugMgr->notifyEvent( EVENT_PRE_POST_ADD, Array( "article" => &$article ));
-
- $postid = $articles->addArticle($article);
-
- if ($postid != 0) {
- // The post was successful
- // Send the EVENT_POST_POST_ADD messages to the plugins
- $plugMgr->notifyEvent( EVENT_POST_POST_ADD, Array( "article" => &$article ));
- CacheControl::resetBlogCache( $blogid );
-
- $blogSettings = $blogInfo->getSettings();
-
- // Add article notifcations if this is specified by the default setting.
- if ($blogSettings->getValue( "default_send_notification" ))
- {
- require_once( PLOG_CLASS_PATH."class/dao/articlenotifications.class.php" );
-
- $artNotifications = new ArticleNotifications();
- $artNotifications->addNotification( $postid, $blogid, $userInfo->getId());
- }
-
-
- return sprintf( "%d", $postid );
- }
- else {
- return new IXR_Error(-1, 'Internal error occured creating your post!');
- }
- }
- else {
- return new IXR_Error(-1, 'You did not provide the correct password');
- }
- }
-
- function metaWeblogNewPost($args)
- {
- global $users, $articles, $category, $blogsG;
- $blogid = $args[0];
- $username = $args[1];
- $password = $args[2];
- $content = $args[3];
- $publish = $args[4]; // true post&publish | false post only
- /*
- int postid
- */
-
- // -mhe todo security
-
- $auth = $users->authenticateUser( $username, $password);
-
- if ($auth)
- {
- if ($publish)
- {
- $status = POST_STATUS_PUBLISHED;
- } else
- {
- $status = POST_STATUS_DRAFT;
- }
-
- // Get the default category
- //$cats = $category->getBlogCategories($blogid);
- //foreach($cats as $cat)
- //{
- // $idCategory = $cat->_id;
- // // Stop here, we have a category
- // break;
- //}
-
- $title = $content["title"];
- $body = $content["description"];
- $catList = $content["categories"];
- $categoryName = NULL;
-
- //
- // :KLUDGE:
- // not exactly the smartest and fastest bit of code ever but it seems to work :-)
- //
- $categories = Array();
- $cats = $category->getBlogCategories($blogid);
-
- // some protection again blogs without categories
- if( !$cats ) {
- return new IXR_Error(-1, 'This blog does not have categories!');
- }
-
- if ( $catList != NULL )
- {
- foreach( $catList as $categoryName ) {
- foreach( $cats as $blogCategory ) {
- $categoryName = trim($categoryName);
- if ( strcmp( $categoryName, $blogCategory->getName()) == 0 )
- {
- $categories[] = $blogCategory->getId();
- }
- }
- }
- }
- else {
- // if no category, let's pick a random one
- $blogCategory = array_pop( $cats );
- $categories[] = $blogCategory->getId();
- }
-
- $userInfo = $users->getUserInfoFromUsername( $username );
-
- $article = new Article(
- $title,
- $body, // text
- $categories, // catid
- $userInfo->getId(), // userid
- $blogid, // blogid
- $status,
- 0, // numread
- Array( "comments_enabled" => true ) // enable comments
- );
-
- $dateCreated = $content['dateCreated'];
-
- // there must be a bug in the xmlrpc library, we're getting an object in $dateCreated
- // that does not have a type or anyhting, but it still is an object... kinda weird. Anyway,
- // clients like ecto do not allow to change the time an article is posted so this is not
- // too annoying, *yet*
- if (!empty($dateCreated))
- {
- // Convert the UTC time to local time, since articleDate is in local time
- $ar = localtime ( $dateCreated->getTimestamp() );
- $ar[5] += 1900; $ar[4]++;
- $localTimeStamp = gmmktime ( $ar[2], $ar[1], $ar[0], $ar[4], $ar[3], $ar[5], $ar[8] );
- $articleDate = date("YmdHis", $localTimeStamp);
- } else
- {
- $articleDate = date("YmdHis");
- }
-
- $article->setDate($articleDate);
-
- $blogInfo = $blogsG->getBlogInfo( $blogid );
-
-
- // Get the plugin manager
- $plugMgr =& PluginManager::getPluginManager();
- $plugMgr->setBlogInfo( $blogInfo );
- $plugMgr->setUserInfo( $userInfo );
- $plugMgr->loadPlugins();
- // Send the PRE_POST_POST_ADD message
- $plugMgr->notifyEvent( EVENT_PRE_POST_ADD, Array( "article" => &$article ));
-
- $postid = $articles->addArticle($article);
- if ($postid != 0)
- {
- // The post was successful
-
- // Send the EVENT_POST_POST_ADD messages to the plugins
- $plugMgr->notifyEvent( EVENT_POST_POST_ADD, Array( "article" => &$article ));
-
- CacheControl::resetBlogCache( $blogid );
-
- $blogSettings = $blogInfo->getSettings();
-
- // Add article notifcations if this is specified by the default setting.
- if ($blogSettings->getValue( "default_send_notification" ))
- {
- require_once( PLOG_CLASS_PATH."class/dao/articlenotifications.class.php" );
-
- $artNotifications = new ArticleNotifications();
- $artNotifications->addNotification( $postid, $blogid, $userInfo->getId());
- }
-
- return sprintf( "%d", $postid );
- } else
- {
- return new IXR_Error(-1, 'Internal error occured creating your post!');
- }
- } else
- {
- return new IXR_Error(-1, 'You did not provide the correct password');
- }
- }
-
- function metaWeblogGetCategories($args)
- {
- global $users, $category, $blogsG;
- $blogid = $args[0];
- $username = $args[1];
- $password = $args[2];
- /*
- "description" =>
- "htmlUrl" =>
- "rssUrl" =>
- */
-
-
- $auth = $users->authenticateUser( $username, $password );
-
- if ($auth)
- {
- $cats = $category->getBlogCategories($blogid);
- $ret = array();
- foreach($cats as $cat)
- {
- $dummy = array();
- $dummy["description"] = $cat->_name;
-
- // We can't use $cat->_url becuase it is not set, so
- // we have to do this in long way
- $blogInfo = $blogsG->getBlogInfo( $blogid );
- $url = $blogInfo->getBlogRequestGenerator();
- // disable the generation of xhtml content or else the IXR_XMLRPC library will
- // escape things twice!
- $url->setXHTML( false );
-
- $dummy["htmlUrl"] = $url->categoryLink( $cat );
- $dummy["rssUrl"] = "http://";
- $ret[$cat->_name] = $dummy;
- }
- return $ret;
- } else
- {
- return new IXR_Error(-1, 'You did not provide the correct password');
- }
- }
-
-
- function getPost($args)
- {
- global $users, $articles;
- $appkey = $args[0];
- $postid = $args[1];
- $username = $args[2];
- $password = $args[3];
-
- /*
- "userid" =>
- "dateCreated" =>
- "content" =>
- "postid" =>
- */
-
- $auth = $users->authenticateUser($username,$password);
- if ($auth)
- {
- $userInfo = $users->getUserInfoFromUsername( $username );
-
- $item = $articles->getBlogArticle($postid,
- -1, // blogId
- true, // includeHiddenFields
- -1, // date
- -1, // categoryId
- $userInfo->getId());
- $dateObject = $item->getDateObject();
- include_once( PLOG_CLASS_PATH."class/data/timestamp.class.php" );
- // Get the unix time stamp
- $time = $dateObject->getTimestamp(DATE_FORMAT_UNIXTIME);
-
- $dummy = array();
- $dummy["userid"] = $item->_userInfo->_id;
- $dummy["dateCreated"] = new IXR_Date($time);
- $dummy["content"] = $item->_topic . "\r\n" . $item->_text . " ";
- $dummy["postid"] = $item->_id;
- return $dummy;
- } else
- {
- return new IXR_Error(-1, 'You did not provide the correct password');
- }
- }
-
- function metaWeblogGetPost($args)
- {
- global $users, $articles;
- $postid = $args[0];
- $username = $args[1];
- $password = $args[2];
-
- /*
- "userid" =>
- "dateCreated" =>
- "content" =>
- "postid" =>
- */
-
- $auth = $users->authenticateUser($username,$password);
-
- if ($auth)
- {
- include_once( PLOG_CLASS_PATH."class/data/timestamp.class.php" );
-
- $userInfo = $users->getUserInfoFromUsername( $username );
-
- $item = $articles->getBlogArticle($postid,
- -1, // blogId
- true, // includeHiddenFields
- -1, // date
- -1, // categoryId
- $userInfo->getId());
-
- $dateObject = $item->getDateObject();
- // Get the unix time stamp
- $time = $dateObject->getTimestamp(DATE_FORMAT_UNIXTIME);
-
- $articleCat = $item->getCategory();
-
- $blogId = $item->getBlog();
- $blogs = new Blogs();
- $blogInfo = $blogs->getBlogInfo( $blogId );
- $url = $blogInfo->getBlogRequestGenerator();
-
- $dummy = array();
- $dummy["userid"] = $item->_userInfo->_id;
- $dummy["dateCreated"] = new IXR_Date($time);
- $dummy["title"] = $item->_topic;
- $dummy["description"] = $item->_text;
- $dummy["postid"] = $item->_id;
-
- $dummy["link"] = $url->postLink( $item );
- $dummy["permaLink"] = $url->postPermalink( $item );
-
- $catArray = array();
- foreach( $item->getCategories() as $category ) {
- $catArray[] = $category->getName();
- }
- $dummy["categories"] = $catArray;
- return $dummy;
- } else
- {
- return new IXR_Error(-1, 'You did not provide the correct password');
- }
- }
-
- function editPost($args)
- {
- global $users, $articles, $blogsG;
-
- $appkey = $args[0];
- $postid = $args[1];
- $username = $args[2];
- $password = $args[3];
- $content = $args[4];
- $publish = $args[5];
-
- /*
- boolean, true or false
- */
-
- $auth = $users->authenticateUser($username,$password);
- if ($auth)
- {
- $userInfo = $users->getUserInfoFromUsername( $username );
-
- if ($publish)
- {
- $status = POST_STATUS_PUBLISHED;
- } else
- {
- $status = POST_STATUS_DRAFT;
- }
-
- // fake topic
- $dummy = explode("\n", $content);
- $title = $dummy[0];
- unset($dummy[0]);
- $content = implode("\n", $dummy);
- unset($dummy);
-
- $article = $articles->getBlogArticle($postid,
- -1, // blogId
- true, // includeHiddenFields
- -1, // date
- -1, // categoryId
- $userInfo->getId());
- $article->setText($content);
- $article->setTopic($title);
- $article->setStatus($status);
-
- // Get the plugin manager
- $plugMgr =& PluginManager::getPluginManager();
- $plugMgr->setBlogInfo( $blogsG->getBlogInfo( $article->getBlog() ) );
- $plugMgr->setUserInfo( $userInfo );
- $plugMgr->loadPlugins();
- // Send the EVENT_PRE_POST_UPDATE message
- $plugMgr->notifyEvent( EVENT_PRE_POST_UPDATE, Array( "article" => &$article ));
-
- $articles->updateArticle($article);
-
- // Send the EVENT_POST_POST_UPDATE messages to the plugins
- $plugMgr->notifyEvent( EVENT_POST_POST_UPDATE, Array( "article" => &$article ));
-
- $blogid = $article->getBlog();
- CacheControl::resetBlogCache( $blogid );
-
- return true;
- } else
- {
- return new IXR_Error(-1, 'You did not provide the correct password');
- }
- }
-
- function metaWeblogEditPost($args)
- {
- global $users, $articles, $category, $blogsG;
-
- $postid = $args[0];
- $username = $args[1];
- $password = $args[2];
- $content = $args[3];
- $publish = $args[4];
-
- /*
- boolean, true or false
- */
-
- $auth = $users->authenticateUser($username,$password);
- if ($auth)
- {
- $userInfo = $users->getUserInfoFromUsername( $username );
-
- if ($publish)
- {
- $status = POST_STATUS_PUBLISHED;
- } else
- {
- $status = POST_STATUS_DRAFT;
- }
-
- $title = $content["title"];
- $body = $content["description"];
-
- $article = $articles->getBlogArticle($postid,
- -1, // blogId
- true, // includeHiddenFields
- -1, // date
- -1, // categoryId
- $userInfo->getId());
-
- $catList = $content["categories"];
- //
- // :KLUDGE:
- // not exactly the smartest and fastest bit of code ever but it seems to work :-)
- //
- $categories = Array();
- $blogid = $article->getBlog();
- $cats = $category->getBlogCategories($blogid);
- if ( $catList != NULL )
- {
- foreach( $catList as $categoryName ) {
- foreach( $cats as $blogCategory ) {
- $categoryName = trim($categoryName);
- if ( strcmp( $categoryName, $blogCategory->getName()) == 0 )
- {
- $categories[] = $blogCategory->getId();
- }
- }
- }
- }
- else {
- // if no category, let's pick a random one
- $blogCategory = array_pop( $cats );
- $categories[] = $blogCategory->getId();
- }
-
- $article->setText($body);
- $article->setTopic($title);
- $article->setStatus($status);
- $article->setCategoryIds( $categories );
-
- // Get the plugin manager
- $plugMgr =& PluginManager::getPluginManager();
- $plugMgr->setBlogInfo( $blogsG->getBlogInfo( $blogid ) );
- $plugMgr->setUserInfo( $userInfo );
- $plugMgr->loadPlugins();
- // Send the EVENT_PRE_POST_UPDATE message
- $plugMgr->notifyEvent( EVENT_PRE_POST_UPDATE, Array( "article" => &$article ));
-
- $articles->updateArticle($article);
-
- // Send the EVENT_POST_POST_UPDATE messages to the plugins
- $plugMgr->notifyEvent( EVENT_POST_POST_UPDATE, Array( "article" => &$article ));
-
- CacheControl::resetBlogCache( $blogid );
-
- return true;
- } else
- {
- return new IXR_Error(-1, 'You did not provide the correct password');
- }
- }
-
- function deletePost($args)
- {
- global $users, $articles, $blogsG;
-
- $appkey = $args[0];
- $postid = $args[1];
- $username = $args[2];
- $password = $args[3];
- $publish = $args[4];
-
- // -mhe todo
- $auth = $users->authenticateUser($username,$password);
- if ($auth)
- {
- $userInfo = $users->getUserInfoFromUsername( $username );
-
- $article = $articles->getBlogArticle($postid,
- -1, // blogId
- true, // includeHiddenFields
- -1, // date
- -1, // categoryId
- $userInfo->getId());
-
- // Get the plugin manager
- $plugMgr =& PluginManager::getPluginManager();
- $plugMgr->setBlogInfo( $blogsG->getBlogInfo( $article->getBlog() ) );
- $plugMgr->setUserInfo( $userInfo );
- $plugMgr->loadPlugins();
- // Send the EVENT_PRE_POST_DELETE message
- $plugMgr->notifyEvent( EVENT_PRE_POST_DELETE, Array( "article" => &$article ));
-
- $articles->deleteArticle(
- $postid,
- $userInfo->getId(), // userid
- $article->getBlog()
- );
-
- // Send the EVENT_POST_POST_DELETE messages to the plugins
- $plugMgr->notifyEvent( EVENT_POST_POST_DELETE, Array( "article" => &$article ));
-
- $blogid = $article->getBlog();
- CacheControl::resetBlogCache( $blogid );
-
- return true;
- } else
- {
- return new IXR_Error(-1, 'You did not provide the correct password');
- }
- }
-
- function getRecentPosts($args)
- {
- global $users, $articles;
- /*
- "userid" =>
- "dateCreated" =>
- "content" =>
- "postid" =>
- */
- $appkey = $args[0];
- $blogid = $args[1];
- $username = $args[2];
- $password = $args[3];
- $number = $args[4];
-
- $auth = $users->authenticateUser($username,$password);
- if ($auth)
- {
- $ret = array();
- $list = $articles->getBlogArticles(
- $blogid,
- -1,
- $number,
- -1
- );
-
- foreach($list as $item)
- {
- $dateObject = $item->getDateObject();
- include_once( PLOG_CLASS_PATH."class/data/timestamp.class.php" );
- // Get the unix time stamp
- $time = $dateObject->getTimestamp(DATE_FORMAT_UNIXTIME);
-
- $dummy = array();
- $dummy["userid"] = $item->_userInfo->_id;
- $dummy["dateCreated"] = new IXR_Date($time);
- $dummy["content"] = $item->_topic . "\r\n" . $item->_text . " ";
- $dummy["postid"] = $item->_id;
-
- $ret[] = $dummy;
- }
- return $ret;
- } else
- {
- return new IXR_Error(-1, 'You did not provide the correct password');
- }
- }
-
- function metaWeblogGetRecentPosts($args)
- {
- global $users, $articles;
- /*
- "userid" =>
- "dateCreated" =>
- "content" =>
- "postid" =>
- */
- $blogid = $args[0];
- $username = $args[1];
- $password = $args[2];
- $number = $args[3];
-
- $auth = $users->authenticateUser($username,$password);
-
- if ($auth)
- {
- $ret = array();
- $list = $articles->getBlogArticles(
- $blogid,
- -1, // date
- $number, // number of articles
- -1 // category id
- );
-
- foreach($list as $item)
- {
- $dateObject = $item->getDateObject();
- include_once( PLOG_CLASS_PATH."class/data/timestamp.class.php" );
- // Get the unix time stamp
- $time = $dateObject->getTimestamp(DATE_FORMAT_UNIXTIME);
-
- $articleCat = $item->getCategory();
-
- $dummy = array();
- $dummy["userid"] = $item->_userInfo->_id;
- $dummy["dateCreated"] = new IXR_Date($time);
- $dummy["title"] = $item->_topic;
- $dummy["description"] = $item->_text;
- $dummy["postid"] = $item->_id;
-
- $blogId = $item->getBlog();
- $blogs = new Blogs();
- $blogInfo = $blogs->getBlogInfo( $blogId );
- $url = $blogInfo->getBlogRequestGenerator();
- $dummy["link"] = $url->postLink( $item );
- $dummy["permaLink"] = $url->postPermalink( $item );
-
- $catArray = array();
- $catArray[] = $articleCat->getName();
- $dummy["categories"] = $catArray;
-
- $ret[] = $dummy;
- }
- return $ret;
- } else
- {
- return new IXR_Error(-1, 'You did not provide the correct password');
- }
- }
-
- function metaWeblogNewMediaObject($args)
- {
- global $users, $articles, $blogsG;
- /*
- "userid" =>
- "dateCreated" =>
- "content" =>
- "postid" =>
- */
- $blogid = $args[0];
- $username = $args[1];
- $password = $args[2];
- $file = $args[3];
-
- $auth = $users->authenticateUser($username,$password);
- if ($auth)
- {
- // Save this file to the tmp directory
-
- // Create a temp file
- // Get the temp directory
- /**if (!$tmp_dir = get_cfg_var('upload_tmp_dir')) {
- $tmp_dir = dirname(tempnam('/tmp', ''));
- }*/
- $config =& Config::getConfig();
- $tmp_dir = $config->getTempFolder();
-
- // Remove all characters that would need to be urlencoded
- // This may not be necessary, but this was causing problems when given file
- // names with spaces in it.
- $tempFile = ereg_replace("[^a-zA-Z0-9._-]", "_", basename($file['name']));
- // Make the tmp name
- $tempFile = $tmp_dir . '/' . $tempFile;
-
- // Open the file
- if (!$handle = fopen( $tempFile, "wb" ) ) {
- return new IXR_Error(-1, 'Could not open file');
- }
-
- // It appears that the data has already been decoded, no need to call base64_decode
- $decodedBits = $file['bits'];
- // Write the data to the file
- if ( fwrite( $handle, $decodedBits ) === false ) {
- return new IXR_Error(-1, 'Could not write to file');
- }
-
- // Close the file
- fclose($handle);
-
- // let the gallery library do its work...
- $resources = new GalleryResources();
-
- // Get the first album for this blog
- $albums = new GalleryAlbums();
- // get the list of albums for this blog
- $albumArray = $albums->getUserAlbums( $blogid );
- if ( $albumArray == NULL || count( $albumArray ) == 0 ) {
- return new IXR_Error(-1, 'Could not find album');
- }
-
- // Add the resource to the first album
- $resId = $resources->addResourceFromDisk( $blogid, $albumArray[0]->getId(),
- basename($file['name']), $tempFile );
- // Get the resource from the id
- $resource = $resources->getResource( $resId, $blogid, $albumArray[0]->getId() );
- // Now we need to get the url for the resource
- $blogInfo = $blogsG->getBlogInfo( $blogid );
- $url = $blogInfo->getBlogRequestGenerator();
-
- $ret = $url->resourceDownloadLink( $resource );
-
- return $ret;
- } else
- {
- return new IXR_Error(-1, 'You did not provide the correct password');
- }
- }
-
- function getUserInfo($args)
- {
- $appkeyp = $args[0];
- $username = $args[1];
- $password = $args[2];
- /*
- "nickname" =>
- "firstname" =>
- "lastname" =>
- "email" =>
- "userid" =>
- "url" =>
- */
-
- $users = new Users();
-
- $auth = $users->authenticateUser( $username, $password );
-
- if ($auth)
- {
- $userInfo = $users->getUserInfoFromUsername( $username );
-
- $ret = array();
- $ret["nickname"] = $userInfo->getUsername();
- $ret["firstname"] = $userInfo->getUsername();
- $ret["lastname"] = "";
- $ret["email"] = $userInfo->getEmail();
- $ret["userid"] = $userInfo->getId();
- $ret["url"] = "";
- return $ret;
- } else
- {
- return new IXR_Error(-1, 'You did not provide the correct password');
- }
- }
-
- function getUsersBlogs($args)
- {
- global $users, $category;
- $appkey = $args[0];
- $username = $args[1];
- $password = $args[2];
- /*
- "blogName" =>
- "url" =>
- "blogid" =>
- */
-
- $auth = $users->authenticateUser( $username, $password );
-
- if ($auth)
- {
- $userInfo = $users->getUserInfoFromUsername( $username );
-
- $blogs = $users->getUsersBlogs($userInfo->getId());
- $ret = array();
- foreach($blogs as $blog)
- {
- $dummy = array();
- $dummy["blogid"] = $blog->_id;
- $dummy["blogName"] = $blog->_blog;
- $url = $blog->getBlogRequestGenerator();
- $dummy["url"] = $url->blogLink();
- $ret[] = $dummy;
- }
- return $ret;
- } else
- {
- return new IXR_Error(-1, 'You did not provide the correct password');
- }
- }
-
- if ($config->getValue("xmlrpc_api_enabled"))
- {
- $xmlrpc = new IXR_Server(
- array (
- "blogger.newPost" => "newPost",
- "blogger.getUserInfo" => "getUserInfo",
- "blogger.getPost" => "getPost",
- "blogger.editPost" => "editPost",
- "blogger.deletePost" => "deletePost",
- "blogger.getRecentPosts" => "getRecentPosts",
- "blogger.getUserInfo" => "getUserInfo",
- "blogger.getUsersBlogs" => "getUsersBlogs",
- "metaWeblog.newPost" => "metaWeblogNewPost",
- "metaWeblog.editPost" => "metaWeblogEditPost",
- "metaWeblog.getPost" => "metaWeblogGetPost",
- "metaWeblog.getRecentPosts" => "metaWeblogGetRecentPosts",
- "metaWeblog.getCategories" => "metaWeblogGetCategories",
- "metaWeblog.newMediaObject" => "metaWeblogNewMediaObject"
- )
- );
- } else
- {
- // xmlrpc_api disabled, no methods configured
- $xmlrpc = new IXR_Server(
- array (
- )
- );
-
- }
?>
More information about the pLog-svn
mailing list