[pLog-svn] r6706 - in plugins/branches/lifetype-1.2: . atom atom/install bin mobile mobile/install moblog moblog/install
jondaley at devel.lifetype.net
jondaley at devel.lifetype.net
Fri Jul 25 11:59:39 EDT 2008
Author: jondaley
Date: 2008-07-25 11:59:39 -0400 (Fri, 25 Jul 2008)
New Revision: 6706
Added:
plugins/branches/lifetype-1.2/atom/install/
plugins/branches/lifetype-1.2/atom/install/atom.php
plugins/branches/lifetype-1.2/mobile/install/
plugins/branches/lifetype-1.2/mobile/install/mobile.php
plugins/branches/lifetype-1.2/moblog/install/
plugins/branches/lifetype-1.2/moblog/install/moblog.php
plugins/branches/lifetype-1.2/moblog/install/moblogbatch.php
Removed:
plugins/branches/lifetype-1.2/atom.php
plugins/branches/lifetype-1.2/mobile.php
plugins/branches/lifetype-1.2/moblog.php
plugins/branches/lifetype-1.2/moblogbatch.php
Modified:
plugins/branches/lifetype-1.2/bin/build.sh
Log:
I think all of these files should be inside the specific plugin directory, rather than at the top of the tree
Copied: plugins/branches/lifetype-1.2/atom/install/atom.php (from rev 6704, plugins/branches/lifetype-1.2/atom.php)
===================================================================
--- plugins/branches/lifetype-1.2/atom/install/atom.php (rev 0)
+++ plugins/branches/lifetype-1.2/atom/install/atom.php 2008-07-25 15:59:39 UTC (rev 6706)
@@ -0,0 +1,53 @@
+<?php
+
+ /**
+ * atom entry point for plog
+ */
+
+ if (!defined( "PLOG_CLASS_PATH" )) {
+ define( "PLOG_CLASS_PATH", dirname(__FILE__)."/");
+ }
+
+ include( PLOG_CLASS_PATH."class/bootstrap.php" );
+
+ lt_include( PLOG_CLASS_PATH."plugins/atom/class/xml/atom/atomserver.class.php" );
+ lt_include( PLOG_CLASS_PATH."plugins/atom/class/logger/atomlogger.class.php" );
+ lt_include( PLOG_CLASS_PATH."class/config/config.class.php" );
+
+ // some of our settings are in the configuration
+ $config =& Config::getConfig();
+
+ AtomLogger::Log( "** Starting **" );
+ AtomLogger::Log( " Request URI: ".$_SERVER["REQUEST_URI"] );
+
+ // process the incoming request
+ $server = new AtomServer();
+ $server->processRequest( new AtomRequest());
+
+ // get the response and send it back to the client
+ $response = $server->getResponse();
+
+ // this is not good so let's at least show something
+ if( $response == null ) {
+ // sent the headers only if we are configured to do so
+ if( !$config->getValue( "atom_dont_set_headers" ))
+ header( "HTTP 500 Internal Server Error" );
+
+ die("Unexpected Atom exception");
+ }
+
+ // some servers don't like us messing around with headers so let's make it optional
+ if( !$config->getValue( "atom_dont_set_headers" )) {
+ // first send the headers and then the text of the response
+ foreach( $response->getHeaders() as $header )
+ header( $header );
+
+ // send the content type header
+ header( "Content-Type: ".$response->getContentType());
+ }
+
+ print( $response->getOutput());
+
+ AtomLogger::Log( " Response sent: ".$response->getOutput());
+ AtomLogger::Log( "** End **" );
+?>
\ No newline at end of file
Property changes on: plugins/branches/lifetype-1.2/atom/install/atom.php
___________________________________________________________________
Added: svn:mergeinfo
+
Deleted: plugins/branches/lifetype-1.2/atom.php
===================================================================
--- plugins/branches/lifetype-1.2/atom.php 2008-07-25 15:51:12 UTC (rev 6705)
+++ plugins/branches/lifetype-1.2/atom.php 2008-07-25 15:59:39 UTC (rev 6706)
@@ -1,53 +0,0 @@
-<?php
-
- /**
- * atom entry point for plog
- */
-
- if (!defined( "PLOG_CLASS_PATH" )) {
- define( "PLOG_CLASS_PATH", dirname(__FILE__)."/");
- }
-
- include( PLOG_CLASS_PATH."class/bootstrap.php" );
-
- lt_include( PLOG_CLASS_PATH."plugins/atom/class/xml/atom/atomserver.class.php" );
- lt_include( PLOG_CLASS_PATH."plugins/atom/class/logger/atomlogger.class.php" );
- lt_include( PLOG_CLASS_PATH."class/config/config.class.php" );
-
- // some of our settings are in the configuration
- $config =& Config::getConfig();
-
- AtomLogger::Log( "** Starting **" );
- AtomLogger::Log( " Request URI: ".$_SERVER["REQUEST_URI"] );
-
- // process the incoming request
- $server = new AtomServer();
- $server->processRequest( new AtomRequest());
-
- // get the response and send it back to the client
- $response = $server->getResponse();
-
- // this is not good so let's at least show something
- if( $response == null ) {
- // sent the headers only if we are configured to do so
- if( !$config->getValue( "atom_dont_set_headers" ))
- header( "HTTP 500 Internal Server Error" );
-
- die("Unexpected Atom exception");
- }
-
- // some servers don't like us messing around with headers so let's make it optional
- if( !$config->getValue( "atom_dont_set_headers" )) {
- // first send the headers and then the text of the response
- foreach( $response->getHeaders() as $header )
- header( $header );
-
- // send the content type header
- header( "Content-Type: ".$response->getContentType());
- }
-
- print( $response->getOutput());
-
- AtomLogger::Log( " Response sent: ".$response->getOutput());
- AtomLogger::Log( "** End **" );
-?>
\ No newline at end of file
Modified: plugins/branches/lifetype-1.2/bin/build.sh
===================================================================
--- plugins/branches/lifetype-1.2/bin/build.sh 2008-07-25 15:51:12 UTC (rev 6705)
+++ plugins/branches/lifetype-1.2/bin/build.sh 2008-07-25 15:59:39 UTC (rev 6706)
@@ -80,30 +80,7 @@
TEMPLATENAME=_all_plugins
zip -qr ${CURFOLDER}/${VERSION}_${TEMPLATENAME}.zip .
else
-
- #
- # some plugins have special requirements... This is not very scalable and needs to be
- # modified every time one of these plugins is added, but this will have to do for
- # the time being
- #
- case $TEMPLATENAME in
- karma)
- FILES="karma.php $TEMPLATENAME"
- ;;
- moblog)
- FILES="moblog.php moblogbatch.php $TEMPLATENAME"
- ;;
- atom)
- FILES="atom.php $TEMPLATENAME"
- ;;
- mobile)
- FILES="mobile.php $TEMPLATENAME"
- ;;
- *)
- FILES="$TEMPLATENAME"
- esac
-
- zip -r ${CURFOLDER}/${VERSION}_${TEMPLATENAME}.zip $FILES
+ zip -r ${CURFOLDER}/${VERSION}_${TEMPLATENAME}.zip $TEMPLATENAME
fi
if [ "$UPLOAD" == "1" ]; then
Copied: plugins/branches/lifetype-1.2/mobile/install/mobile.php (from rev 6704, plugins/branches/lifetype-1.2/mobile.php)
===================================================================
--- plugins/branches/lifetype-1.2/mobile/install/mobile.php (rev 0)
+++ plugins/branches/lifetype-1.2/mobile/install/mobile.php 2008-07-25 15:59:39 UTC (rev 6706)
@@ -0,0 +1,29 @@
+<?php
+ // please enable the line below if you are having memory issues
+ //ini_set('memory_limit', "16M");
+
+ if (!defined( "PLOG_CLASS_PATH" )) {
+ define( "PLOG_CLASS_PATH", dirname(__FILE__)."/");
+ }
+ if( !defined( "MOBILE_PLOG_CLASS_PATH" )) {
+ define( "MOBILE_PLOG_CLASS_PATH", PLOG_CLASS_PATH."plugins/mobile/" );
+ }
+
+ include( PLOG_CLASS_PATH."class/bootstrap.php" );
+ lt_include( MOBILE_PLOG_CLASS_PATH."class/controller/mobilecontroller.class.php" );
+ lt_include( PLOG_CLASS_PATH."class/net/http/httpvars.class.php" );
+
+ ini_set("arg_seperator.output", "&");
+ ini_set("magic_quotes_runtime", 0 );
+
+ //
+ // a few more constants, please change them if needed
+ //
+ define( "MOBILE_PLOG_NUM_COMMENTS_PER_PAGE", 5 );
+ define( "MOBILE_PLOG_NUM_POSTS_PER_PAGE", 5 );
+
+ $controller = new MobileController();
+
+ // give control to the, ehem, controller :)
+ $controller->process( HttpVars::getRequest());
+?>
Property changes on: plugins/branches/lifetype-1.2/mobile/install/mobile.php
___________________________________________________________________
Added: svn:mergeinfo
+
Deleted: plugins/branches/lifetype-1.2/mobile.php
===================================================================
--- plugins/branches/lifetype-1.2/mobile.php 2008-07-25 15:51:12 UTC (rev 6705)
+++ plugins/branches/lifetype-1.2/mobile.php 2008-07-25 15:59:39 UTC (rev 6706)
@@ -1,29 +0,0 @@
-<?php
- // please enable the line below if you are having memory issues
- //ini_set('memory_limit', "16M");
-
- if (!defined( "PLOG_CLASS_PATH" )) {
- define( "PLOG_CLASS_PATH", dirname(__FILE__)."/");
- }
- if( !defined( "MOBILE_PLOG_CLASS_PATH" )) {
- define( "MOBILE_PLOG_CLASS_PATH", PLOG_CLASS_PATH."plugins/mobile/" );
- }
-
- include( PLOG_CLASS_PATH."class/bootstrap.php" );
- lt_include( MOBILE_PLOG_CLASS_PATH."class/controller/mobilecontroller.class.php" );
- lt_include( PLOG_CLASS_PATH."class/net/http/httpvars.class.php" );
-
- ini_set("arg_seperator.output", "&");
- ini_set("magic_quotes_runtime", 0 );
-
- //
- // a few more constants, please change them if needed
- //
- define( "MOBILE_PLOG_NUM_COMMENTS_PER_PAGE", 5 );
- define( "MOBILE_PLOG_NUM_POSTS_PER_PAGE", 5 );
-
- $controller = new MobileController();
-
- // give control to the, ehem, controller :)
- $controller->process( HttpVars::getRequest());
-?>
Copied: plugins/branches/lifetype-1.2/moblog/install/moblog.php (from rev 6704, plugins/branches/lifetype-1.2/moblog.php)
===================================================================
--- plugins/branches/lifetype-1.2/moblog/install/moblog.php (rev 0)
+++ plugins/branches/lifetype-1.2/moblog/install/moblog.php 2008-07-25 15:59:39 UTC (rev 6706)
@@ -0,0 +1,320 @@
+<?php
+
+ // define the entry point
+ if (!defined( "PLOG_CLASS_PATH" )) {
+ define( "PLOG_CLASS_PATH", dirname(__FILE__)."/");
+ }
+
+ //
+ // set this to false if you want logging enabled
+ //
+ define( "MOBLOG_DEBUG", false );
+
+ // bring in some code that we need
+ include( PLOG_CLASS_PATH."class/bootstrap.php" );
+ lt_include( PLOG_CLASS_PATH."class/dao/blogs.class.php" );
+ lt_include( PLOG_CLASS_PATH."class/dao/users.class.php" );
+ lt_include( PLOG_CLASS_PATH."class/file/file.class.php" );
+ lt_include( PLOG_CLASS_PATH."class/data/timestamp.class.php" );
+ lt_include( PLOG_CLASS_PATH."class/net/http/httpvars.class.php" );
+ lt_include( PLOG_CLASS_PATH."class/dao/articles.class.php" );
+ lt_include( PLOG_CLASS_PATH."class/data/timestamp.class.php" );
+ lt_include( PLOG_CLASS_PATH."class/config/config.class.php" );
+ lt_include( PLOG_CLASS_PATH."class/gallery/dao/galleryresources.class.php" );
+ lt_include( PLOG_CLASS_PATH."class/gallery/dao/galleryalbums.class.php" );
+ lt_include( PLOG_CLASS_PATH."plugins/moblog/class/log/mobloglogger.class.php" );
+ lt_include( PLOG_CLASS_PATH."plugins/moblog/class/moblog/moblogrequest.class.php" );
+ lt_include( PLOG_CLASS_PATH."plugins/moblog/class/moblog/moblogresponse.class.php" );
+ lt_include( PLOG_CLASS_PATH."plugins/moblog/class/moblog/moblogconstants.properties.php" );
+ lt_include( PLOG_CLASS_PATH."class/template/cachecontrol.class.php" );
+ lt_include( PLOG_CLASS_PATH."class/dao/userpermissions.class.php" );
+ lt_include( PLOG_CLASS_PATH."class/dao/articlecategories.class.php" );
+ lt_include( PLOG_CLASS_PATH."class/dao/articlenotifications.class.php" );
+ lt_include( PLOG_CLASS_PATH."class/file/fileupload.class.php" );
+
+ // initialize the logging system
+ MoblogLogger::log( "-- Initialized");
+
+ // get the request
+ $request = HttpVars::getRequest();
+ isset( $request["message"] ) ? $message = $request["message"] : $message = "";
+
+ if( $message == "" ) {
+ MoblogLogger::log( "There was no message!" );
+ die();
+ }
+
+ // check if we need to remove any quotes..
+ if( get_magic_quotes_gpc()) {
+ $message = stripslashes( $message );
+ }
+
+ MoblogLogger::log("-- message --");
+ MoblogLogger::log($message);
+ MoblogLogger::log("-- message end --");
+
+ // parse the message
+ $request = new MoblogRequest( $request );
+
+ // let's see what we get...
+ MoblogLogger::log( "user = '".$request->getUser()."'");
+ // uncomment the following if you want to see passwords... :)
+ //MoblogLogger::log( "pass = ".$request->getPassword()."'");
+ MoblogLogger::log( "blog id = ".$request->getBlogId());
+ MoblogLogger::log( "topic = ".$request->getTopic());
+ MoblogLogger::log( "reply to = ".$request->getReplyTo());
+ MoblogLogger::log( "body = ".$request->getBody());
+
+ //
+ // start processing the message...
+ //
+
+ //
+ // first, try to authenticate the user
+ //
+ $users = new Users();
+ if( $users->authenticateUser( $request->getUser(), $request->getPassword())) {
+ $userInfo = $users->getUserInfoFromUsername( $request->getUser());
+ }
+ else {
+ $response = new MoblogResponse( $request->getReplyTo(),
+ "LifeType Moblog: Error",
+ "User or password are not correct."
+ );
+ MoblogLogger::log( "User ".$request->getUser()." did not authenticate correctly." );
+ $response->send();
+ return false;
+ }
+
+ //
+ // if user was authenticated, then proceed... and the first thing we should do
+ // is see if the blog id is correct and if the user has permissions in that
+ // blog
+ //
+ $blogs = new Blogs();
+ if( $request->getBlogId() == "" ) {
+ // user gave a blog name instead of a blog id
+ $allBlogs = $blogs->getAllBlogs( BLOG_STATUS_ACTIVE, ALL_BLOG_CATEGORIES );
+ if( $allBlogs ) {
+ $found = false;
+ $blogName = stripslashes($request->getBlogName());
+ while( !$found && !empty($allBlogs)) {
+ $blogInfo = array_pop( $allBlogs );
+ if( strcasecmp($blogInfo->getBlog(), $blogName) == 0 ) {
+ $found = true;
+ MoblogLogger::log( "Blog '".$blogInfo->getBlog()."' found with id = '".$blogInfo->getId()."'");
+ }
+ }
+
+ if( !$found ) {
+ $response = new MoblogResponse( $request->getReplyTo(),
+ "LifeType Moblog: Error",
+ "Incorrect blog."
+ );
+ MoblogLogger::log( "Blog ".$request->getBlogId()." does not exist." );
+ $response->send();
+ return false;
+ }
+ }
+ }
+ else {
+ $blogInfo = $blogs->getBlogInfo( $request->getBlogId());
+ if( !$blogInfo ) {
+ $response = new MoblogResponse( $request->getReplyTo(),
+ "LifeType Moblog: Error",
+ "Incorrect blog identifier."
+ );
+ MoblogLogger::log( "Blog ".$request->getBlogId()." is not valid." );
+ $response->send();
+ return false;
+ }
+ }
+
+ //
+ // check if the plugin has been enabled for this blog
+ //
+ $blogSettings = $blogInfo->getSettings();
+ $pluginEnabled = $blogSettings->getValue( "plugin_moblog_enabled" );
+ if( !$pluginEnabled ) {
+ $response = new MoblogResponse( $request->getReplyTo(),
+ "LifeType Moblog: Error",
+ "The plugin has not been enabled for this blog."
+ );
+ MoblogLogger::log( "Plugin not enabled for blog ".$request->getBlogId());
+ $response->send();
+ return false;
+ }
+
+ //
+ // now check if the user is allowed to post in the given blog
+ //
+ if( !$userInfo->hasPermissionByName( "add_post", $blogInfo->getId()) &&
+ $blogInfo->getOwnerId() != $userInfo->getId()) {
+ $response = new MoblogResponse( $request->getReplyTo(),
+ "LifeType Moblog: Error",
+ "You have no permissions in the given blog."
+ );
+ MoblogLogger::log( "User '".$request->getUser()."' has no permissions in blog ".$request->getBlogId());
+ $response->send();
+ return false;
+ }
+
+ //
+ // if everything's correct, then we can proceed to find if the category
+ // chosen by the user exists. Since there is no way to fetch a category by its name,
+ // we'll have to fetch them all and loop through them
+ //
+ $articleCategories = new ArticleCategories();
+ // load the category as defined in the plugin settings page
+ $categoryId = $blogSettings->getValue( "plugin_moblog_article_category_id" );
+ $category = $articleCategories->getCategory( $categoryId, $blogInfo->getId());
+ // if there was no such category, we should send an error and to make it more useful, send
+ // as part of the error message the list of available categories
+ if( !$category ) {
+ $response = new MoblogResponse( $request->getReplyTo(),
+ "LifeType Moblog: Error",
+ "The category does not exist."
+ );
+ MoblogLogger::log( "User '".$request->getUser()."' tried to use category '".$categoryId.
+ "' which does not exist.");
+ $response->send();
+ return false;
+ }
+
+ //
+ // finally, add the resources to the database
+ //
+
+ // first, create a new album to hold these attachments
+ $albums = new GalleryAlbums();
+ $userAlbums = $albums->getUserAlbums( $blogInfo->getId());
+ $t = new Timestamp();
+ $albumId = $blogSettings->getValue( "plugin_moblog_gallery_resource_album_id" );
+ $album = $albums->getAlbum( $albumId, $blogInfo->getId());
+ // check if the album was loaded
+ if( !$album ) {
+ $response = new MoblogResponse( $request->getReplyTo(),
+ "LifeType Moblog: Error",
+ "The album does not exist."
+ );
+ MoblogLogger::log( "User '".$request->getUser()."' tried to use album '".$albumId.
+ "' which does not exist.");
+ $response->send();
+ return false;
+ }
+ MoblogLogger::log( "Adding resources to album ".$album->getName());
+
+ $attachments = $request->getAttachments();
+ $res = new GalleryResources();
+ $resourceIds = Array();
+
+ if ( count($attachments) > 0) {
+ foreach( $attachments as $attachment ) {
+ MoblogLogger::log( "-- Processing attachment ".$attachment->getFileName()." - tmp filename = ".$attachment->getTmpName());
+ $result = $res->addResourceFromDisk( $blogInfo->getId(), $albumId, $attachment->getFileName(), $attachment->getTmpName());
+ MoblogLogger::log( " Completed: result = $result" );
+ if( $result ) {
+ // keep this for later
+ array_push( $resourceIds, $result );
+ }
+ else {
+ MoblogLogger::log("false???");
+ }
+ }
+ }
+ else {
+ MoblogLogger::log( " No Attachments found" );
+ }
+
+ //
+ // if everything went fine, we can now proceed and publish the post, finally!!!! :)
+ //
+
+ // before adding the article, we need to add some additional markup
+ // with links to the attachments that were sent
+ $rg = $blogInfo->getBlogRequestGenerator();
+ $postBody = $request->getBody()."<br/>";
+ $numItems = count($resourceIds);
+ $curItem = 0;
+ foreach( $resourceIds as $resId ) {
+ $resource = $res->getResource( $resId );
+ $markup = "<a id=\"res_".$resId."\" href=\"".$rg->resourceLink( $resource )."\">";
+ if( $resource->isImage()) {
+ $previewType = $blogSettings->getValue( "plugin_moblog_resource_preview_type" );
+ if( $previewType == MOBLOG_EMBED_MEDIUM_PREVIEW ) {
+ $link = $rg->resourceMediumSizePreviewLink( $resource );
+ $cssClass = "res_image_medium";
+ }
+ elseif( $previewType == MOBLOG_EMBED_FULL_SIZE_VIEW ) {
+ $link = $rg->resourceDownloadLink( $resource );
+ $cssClass = "res_image";
+ }
+ else {
+ $link = $rg->resourcePreviewLink( $resource );
+ $cssClass = "res_image_small";
+ }
+
+ $markup .= "<img class=\"$cssClass\" src=\"$link\" alt=\"".$resource->getDescription()."\" />";
+ }
+ else {
+ $markup .= $resource->getDescription();
+ }
+ $markup .= "</a>";
+ $curItem++;
+ if( $curItem < $numItems )
+ $markup .= "<br/><br/>";
+ MoblogLogger::log( "Adding markup $markup" );
+ $postBody .= $markup;
+ $postBody = TextFilter::autoP( trim( $postBody ));
+ $resNames .= $resource->getDescription();
+ }
+
+ // add the article
+ $articles = new Articles();
+ $article = new Article( $request->getTopic(),
+ $postBody,
+ Array( $category->getId()),
+ $userInfo->getId(),
+ $blogInfo->getId(),
+ POST_STATUS_PUBLISHED,
+ 0
+ );
+ $article->setDateObject( new Timestamp());
+ // enable or disable comments by default depending on the current config
+ $commentsEnabled = $blogSettings->getValue( "comments_enabled" );
+ $article->setCommentsEnabled( $commentsEnabled );
+
+ $result = $articles->addArticle( $article );
+
+ // add an article notification
+ $notifications = new ArticleNotifications();
+ $notifications->addNotification( $result, $blogInfo->getId(), $userInfo->getId());
+
+ // reset the cache in case it is enabled
+ CacheControl::resetBlogCache( $blogInfo->getId());
+
+ if( !$result ) {
+ $response = new MoblogResponse( $request->getReplyTo(),
+ "LifeType Moblog: Error",
+ "There was an error adding the post to the database."
+ );
+ MoblogLogger::log( "There was an error adding the post to the database.");
+ }
+ else {
+ lt_include( PLOG_CLASS_PATH."class/locale/locales.class.php" );
+ $config =& Config::getConfig();
+ $locale =& Locales::getLocale( $config->getValue("default_locale" ));
+
+ $responseBody = $locale->pr("moblog_body",$request->getTopic());
+ if( count($request->getAttachments()) > 0 ) {
+ $responseBody .= $locale->tr("moblog_attachments");
+ $responseBody .= $resNames;
+ }
+ $response = new MoblogResponse( $request->getReplyTo(), $locale->tr("moblog_mailsubject"), $responseBody );
+ MoblogLogger::log( "Post was successfully added to the database." );
+ }
+ $response->send();
+
+ // end of it...
+ MoblogLogger::log( "-- End");
+?>
Property changes on: plugins/branches/lifetype-1.2/moblog/install/moblog.php
___________________________________________________________________
Added: svn:mergeinfo
+
Copied: plugins/branches/lifetype-1.2/moblog/install/moblogbatch.php (from rev 6704, plugins/branches/lifetype-1.2/moblogbatch.php)
===================================================================
--- plugins/branches/lifetype-1.2/moblog/install/moblogbatch.php (rev 0)
+++ plugins/branches/lifetype-1.2/moblog/install/moblogbatch.php 2008-07-25 15:59:39 UTC (rev 6706)
@@ -0,0 +1,66 @@
+<?php
+
+ // define the entry point
+ if (!defined( "PLOG_CLASS_PATH" )) {
+ define( "PLOG_CLASS_PATH", dirname(__FILE__)."/");
+ }
+
+ // bring in some code that we need
+ include( PLOG_CLASS_PATH."class/bootstrap.php" );
+ lt_include( PLOG_CLASS_PATH."plugins/moblog/class/PEAR/Net/POP3.php" );
+ lt_include( PLOG_CLASS_PATH."plugins/moblog/class/PEAR/HTTP/Request.php");
+ lt_include( PLOG_CLASS_PATH."class/net/baserequestgenerator.class.php" );
+ lt_include( PLOG_CLASS_PATH."class/config/config.class.php" );
+
+ $config =& Config::getConfig();
+
+ $mailServer = $config->getValue('plugin_moblog_mailserver');
+ $port = $config->getValue('plugin_moblog_port');
+ $userName = $config->getValue('plugin_moblog_username');
+ $password = $config->getValue('plugin_moblog_password');
+
+ // pop3 connection and log-in
+ $pop3 =& new Net_POP3();
+
+ if(PEAR::isError( $ret= $pop3->connect($mailServer , $port ) )) {
+ echo "ERROR: " . $ret->getMessage() . "\n";
+ exit();
+ }
+
+ if(PEAR::isError( $ret= $pop3->login($userName , $password, 'USER' ) )){
+ echo "ERROR: " . $ret->getMessage() . "\n";
+ exit();
+ }
+
+ $messageNumber = $pop3->numMsg();
+
+ if ($messageNumber == 0) {
+ $pop3->disconnect();
+ die();
+ } else {
+ // get message list
+ $messageList = $pop3->getListing();
+ $messages = Array();
+
+ for ($cnt = 0; $cnt < count($messageList); $cnt++) {
+ $messages[$cnt] = $pop3->getMsg($messageList[$cnt]['msg_id']);
+ $pop3->deleteMsg($messageList[$cnt]['msg_id']);
+ }
+
+ // pop3 disconnect
+ $pop3->disconnect();
+
+ $config->setValue( "plugin_moblog_lastupdate", time() );
+ $config->save();
+
+ $url = &new BaseRequestGenerator();
+
+ for ($cnt = 0; $cnt < count($messages); $cnt++) {
+ $req = &new HTTP_Request($url->getBaseUrl(false)."/moblog.php");
+ $req->setMethod(HTTP_REQUEST_METHOD_POST);
+ $req->addPostData('message', $messages[$cnt]);
+ $req->sendRequest();
+ $response = $req->getResponseBody();
+ }
+ }
+?>
Property changes on: plugins/branches/lifetype-1.2/moblog/install/moblogbatch.php
___________________________________________________________________
Added: svn:mergeinfo
+
Deleted: plugins/branches/lifetype-1.2/moblog.php
===================================================================
--- plugins/branches/lifetype-1.2/moblog.php 2008-07-25 15:51:12 UTC (rev 6705)
+++ plugins/branches/lifetype-1.2/moblog.php 2008-07-25 15:59:39 UTC (rev 6706)
@@ -1,320 +0,0 @@
-<?php
-
- // define the entry point
- if (!defined( "PLOG_CLASS_PATH" )) {
- define( "PLOG_CLASS_PATH", dirname(__FILE__)."/");
- }
-
- //
- // set this to false if you want logging enabled
- //
- define( "MOBLOG_DEBUG", false );
-
- // bring in some code that we need
- include( PLOG_CLASS_PATH."class/bootstrap.php" );
- lt_include( PLOG_CLASS_PATH."class/dao/blogs.class.php" );
- lt_include( PLOG_CLASS_PATH."class/dao/users.class.php" );
- lt_include( PLOG_CLASS_PATH."class/file/file.class.php" );
- lt_include( PLOG_CLASS_PATH."class/data/timestamp.class.php" );
- lt_include( PLOG_CLASS_PATH."class/net/http/httpvars.class.php" );
- lt_include( PLOG_CLASS_PATH."class/dao/articles.class.php" );
- lt_include( PLOG_CLASS_PATH."class/data/timestamp.class.php" );
- lt_include( PLOG_CLASS_PATH."class/config/config.class.php" );
- lt_include( PLOG_CLASS_PATH."class/gallery/dao/galleryresources.class.php" );
- lt_include( PLOG_CLASS_PATH."class/gallery/dao/galleryalbums.class.php" );
- lt_include( PLOG_CLASS_PATH."plugins/moblog/class/log/mobloglogger.class.php" );
- lt_include( PLOG_CLASS_PATH."plugins/moblog/class/moblog/moblogrequest.class.php" );
- lt_include( PLOG_CLASS_PATH."plugins/moblog/class/moblog/moblogresponse.class.php" );
- lt_include( PLOG_CLASS_PATH."plugins/moblog/class/moblog/moblogconstants.properties.php" );
- lt_include( PLOG_CLASS_PATH."class/template/cachecontrol.class.php" );
- lt_include( PLOG_CLASS_PATH."class/dao/userpermissions.class.php" );
- lt_include( PLOG_CLASS_PATH."class/dao/articlecategories.class.php" );
- lt_include( PLOG_CLASS_PATH."class/dao/articlenotifications.class.php" );
- lt_include( PLOG_CLASS_PATH."class/file/fileupload.class.php" );
-
- // initialize the logging system
- MoblogLogger::log( "-- Initialized");
-
- // get the request
- $request = HttpVars::getRequest();
- isset( $request["message"] ) ? $message = $request["message"] : $message = "";
-
- if( $message == "" ) {
- MoblogLogger::log( "There was no message!" );
- die();
- }
-
- // check if we need to remove any quotes..
- if( get_magic_quotes_gpc()) {
- $message = stripslashes( $message );
- }
-
- MoblogLogger::log("-- message --");
- MoblogLogger::log($message);
- MoblogLogger::log("-- message end --");
-
- // parse the message
- $request = new MoblogRequest( $request );
-
- // let's see what we get...
- MoblogLogger::log( "user = '".$request->getUser()."'");
- // uncomment the following if you want to see passwords... :)
- //MoblogLogger::log( "pass = ".$request->getPassword()."'");
- MoblogLogger::log( "blog id = ".$request->getBlogId());
- MoblogLogger::log( "topic = ".$request->getTopic());
- MoblogLogger::log( "reply to = ".$request->getReplyTo());
- MoblogLogger::log( "body = ".$request->getBody());
-
- //
- // start processing the message...
- //
-
- //
- // first, try to authenticate the user
- //
- $users = new Users();
- if( $users->authenticateUser( $request->getUser(), $request->getPassword())) {
- $userInfo = $users->getUserInfoFromUsername( $request->getUser());
- }
- else {
- $response = new MoblogResponse( $request->getReplyTo(),
- "LifeType Moblog: Error",
- "User or password are not correct."
- );
- MoblogLogger::log( "User ".$request->getUser()." did not authenticate correctly." );
- $response->send();
- return false;
- }
-
- //
- // if user was authenticated, then proceed... and the first thing we should do
- // is see if the blog id is correct and if the user has permissions in that
- // blog
- //
- $blogs = new Blogs();
- if( $request->getBlogId() == "" ) {
- // user gave a blog name instead of a blog id
- $allBlogs = $blogs->getAllBlogs( BLOG_STATUS_ACTIVE, ALL_BLOG_CATEGORIES );
- if( $allBlogs ) {
- $found = false;
- $blogName = stripslashes($request->getBlogName());
- while( !$found && !empty($allBlogs)) {
- $blogInfo = array_pop( $allBlogs );
- if( strcasecmp($blogInfo->getBlog(), $blogName) == 0 ) {
- $found = true;
- MoblogLogger::log( "Blog '".$blogInfo->getBlog()."' found with id = '".$blogInfo->getId()."'");
- }
- }
-
- if( !$found ) {
- $response = new MoblogResponse( $request->getReplyTo(),
- "LifeType Moblog: Error",
- "Incorrect blog."
- );
- MoblogLogger::log( "Blog ".$request->getBlogId()." does not exist." );
- $response->send();
- return false;
- }
- }
- }
- else {
- $blogInfo = $blogs->getBlogInfo( $request->getBlogId());
- if( !$blogInfo ) {
- $response = new MoblogResponse( $request->getReplyTo(),
- "LifeType Moblog: Error",
- "Incorrect blog identifier."
- );
- MoblogLogger::log( "Blog ".$request->getBlogId()." is not valid." );
- $response->send();
- return false;
- }
- }
-
- //
- // check if the plugin has been enabled for this blog
- //
- $blogSettings = $blogInfo->getSettings();
- $pluginEnabled = $blogSettings->getValue( "plugin_moblog_enabled" );
- if( !$pluginEnabled ) {
- $response = new MoblogResponse( $request->getReplyTo(),
- "LifeType Moblog: Error",
- "The plugin has not been enabled for this blog."
- );
- MoblogLogger::log( "Plugin not enabled for blog ".$request->getBlogId());
- $response->send();
- return false;
- }
-
- //
- // now check if the user is allowed to post in the given blog
- //
- if( !$userInfo->hasPermissionByName( "add_post", $blogInfo->getId()) &&
- $blogInfo->getOwnerId() != $userInfo->getId()) {
- $response = new MoblogResponse( $request->getReplyTo(),
- "LifeType Moblog: Error",
- "You have no permissions in the given blog."
- );
- MoblogLogger::log( "User '".$request->getUser()."' has no permissions in blog ".$request->getBlogId());
- $response->send();
- return false;
- }
-
- //
- // if everything's correct, then we can proceed to find if the category
- // chosen by the user exists. Since there is no way to fetch a category by its name,
- // we'll have to fetch them all and loop through them
- //
- $articleCategories = new ArticleCategories();
- // load the category as defined in the plugin settings page
- $categoryId = $blogSettings->getValue( "plugin_moblog_article_category_id" );
- $category = $articleCategories->getCategory( $categoryId, $blogInfo->getId());
- // if there was no such category, we should send an error and to make it more useful, send
- // as part of the error message the list of available categories
- if( !$category ) {
- $response = new MoblogResponse( $request->getReplyTo(),
- "LifeType Moblog: Error",
- "The category does not exist."
- );
- MoblogLogger::log( "User '".$request->getUser()."' tried to use category '".$categoryId.
- "' which does not exist.");
- $response->send();
- return false;
- }
-
- //
- // finally, add the resources to the database
- //
-
- // first, create a new album to hold these attachments
- $albums = new GalleryAlbums();
- $userAlbums = $albums->getUserAlbums( $blogInfo->getId());
- $t = new Timestamp();
- $albumId = $blogSettings->getValue( "plugin_moblog_gallery_resource_album_id" );
- $album = $albums->getAlbum( $albumId, $blogInfo->getId());
- // check if the album was loaded
- if( !$album ) {
- $response = new MoblogResponse( $request->getReplyTo(),
- "LifeType Moblog: Error",
- "The album does not exist."
- );
- MoblogLogger::log( "User '".$request->getUser()."' tried to use album '".$albumId.
- "' which does not exist.");
- $response->send();
- return false;
- }
- MoblogLogger::log( "Adding resources to album ".$album->getName());
-
- $attachments = $request->getAttachments();
- $res = new GalleryResources();
- $resourceIds = Array();
-
- if ( count($attachments) > 0) {
- foreach( $attachments as $attachment ) {
- MoblogLogger::log( "-- Processing attachment ".$attachment->getFileName()." - tmp filename = ".$attachment->getTmpName());
- $result = $res->addResourceFromDisk( $blogInfo->getId(), $albumId, $attachment->getFileName(), $attachment->getTmpName());
- MoblogLogger::log( " Completed: result = $result" );
- if( $result ) {
- // keep this for later
- array_push( $resourceIds, $result );
- }
- else {
- MoblogLogger::log("false???");
- }
- }
- }
- else {
- MoblogLogger::log( " No Attachments found" );
- }
-
- //
- // if everything went fine, we can now proceed and publish the post, finally!!!! :)
- //
-
- // before adding the article, we need to add some additional markup
- // with links to the attachments that were sent
- $rg = $blogInfo->getBlogRequestGenerator();
- $postBody = $request->getBody()."<br/>";
- $numItems = count($resourceIds);
- $curItem = 0;
- foreach( $resourceIds as $resId ) {
- $resource = $res->getResource( $resId );
- $markup = "<a id=\"res_".$resId."\" href=\"".$rg->resourceLink( $resource )."\">";
- if( $resource->isImage()) {
- $previewType = $blogSettings->getValue( "plugin_moblog_resource_preview_type" );
- if( $previewType == MOBLOG_EMBED_MEDIUM_PREVIEW ) {
- $link = $rg->resourceMediumSizePreviewLink( $resource );
- $cssClass = "res_image_medium";
- }
- elseif( $previewType == MOBLOG_EMBED_FULL_SIZE_VIEW ) {
- $link = $rg->resourceDownloadLink( $resource );
- $cssClass = "res_image";
- }
- else {
- $link = $rg->resourcePreviewLink( $resource );
- $cssClass = "res_image_small";
- }
-
- $markup .= "<img class=\"$cssClass\" src=\"$link\" alt=\"".$resource->getDescription()."\" />";
- }
- else {
- $markup .= $resource->getDescription();
- }
- $markup .= "</a>";
- $curItem++;
- if( $curItem < $numItems )
- $markup .= "<br/><br/>";
- MoblogLogger::log( "Adding markup $markup" );
- $postBody .= $markup;
- $postBody = TextFilter::autoP( trim( $postBody ));
- $resNames .= $resource->getDescription();
- }
-
- // add the article
- $articles = new Articles();
- $article = new Article( $request->getTopic(),
- $postBody,
- Array( $category->getId()),
- $userInfo->getId(),
- $blogInfo->getId(),
- POST_STATUS_PUBLISHED,
- 0
- );
- $article->setDateObject( new Timestamp());
- // enable or disable comments by default depending on the current config
- $commentsEnabled = $blogSettings->getValue( "comments_enabled" );
- $article->setCommentsEnabled( $commentsEnabled );
-
- $result = $articles->addArticle( $article );
-
- // add an article notification
- $notifications = new ArticleNotifications();
- $notifications->addNotification( $result, $blogInfo->getId(), $userInfo->getId());
-
- // reset the cache in case it is enabled
- CacheControl::resetBlogCache( $blogInfo->getId());
-
- if( !$result ) {
- $response = new MoblogResponse( $request->getReplyTo(),
- "LifeType Moblog: Error",
- "There was an error adding the post to the database."
- );
- MoblogLogger::log( "There was an error adding the post to the database.");
- }
- else {
- lt_include( PLOG_CLASS_PATH."class/locale/locales.class.php" );
- $config =& Config::getConfig();
- $locale =& Locales::getLocale( $config->getValue("default_locale" ));
-
- $responseBody = $locale->pr("moblog_body",$request->getTopic());
- if( count($request->getAttachments()) > 0 ) {
- $responseBody .= $locale->tr("moblog_attachments");
- $responseBody .= $resNames;
- }
- $response = new MoblogResponse( $request->getReplyTo(), $locale->tr("moblog_mailsubject"), $responseBody );
- MoblogLogger::log( "Post was successfully added to the database." );
- }
- $response->send();
-
- // end of it...
- MoblogLogger::log( "-- End");
-?>
Deleted: plugins/branches/lifetype-1.2/moblogbatch.php
===================================================================
--- plugins/branches/lifetype-1.2/moblogbatch.php 2008-07-25 15:51:12 UTC (rev 6705)
+++ plugins/branches/lifetype-1.2/moblogbatch.php 2008-07-25 15:59:39 UTC (rev 6706)
@@ -1,66 +0,0 @@
-<?php
-
- // define the entry point
- if (!defined( "PLOG_CLASS_PATH" )) {
- define( "PLOG_CLASS_PATH", dirname(__FILE__)."/");
- }
-
- // bring in some code that we need
- include( PLOG_CLASS_PATH."class/bootstrap.php" );
- lt_include( PLOG_CLASS_PATH."plugins/moblog/class/PEAR/Net/POP3.php" );
- lt_include( PLOG_CLASS_PATH."plugins/moblog/class/PEAR/HTTP/Request.php");
- lt_include( PLOG_CLASS_PATH."class/net/baserequestgenerator.class.php" );
- lt_include( PLOG_CLASS_PATH."class/config/config.class.php" );
-
- $config =& Config::getConfig();
-
- $mailServer = $config->getValue('plugin_moblog_mailserver');
- $port = $config->getValue('plugin_moblog_port');
- $userName = $config->getValue('plugin_moblog_username');
- $password = $config->getValue('plugin_moblog_password');
-
- // pop3 connection and log-in
- $pop3 =& new Net_POP3();
-
- if(PEAR::isError( $ret= $pop3->connect($mailServer , $port ) )) {
- echo "ERROR: " . $ret->getMessage() . "\n";
- exit();
- }
-
- if(PEAR::isError( $ret= $pop3->login($userName , $password, 'USER' ) )){
- echo "ERROR: " . $ret->getMessage() . "\n";
- exit();
- }
-
- $messageNumber = $pop3->numMsg();
-
- if ($messageNumber == 0) {
- $pop3->disconnect();
- die();
- } else {
- // get message list
- $messageList = $pop3->getListing();
- $messages = Array();
-
- for ($cnt = 0; $cnt < count($messageList); $cnt++) {
- $messages[$cnt] = $pop3->getMsg($messageList[$cnt]['msg_id']);
- $pop3->deleteMsg($messageList[$cnt]['msg_id']);
- }
-
- // pop3 disconnect
- $pop3->disconnect();
-
- $config->setValue( "plugin_moblog_lastupdate", time() );
- $config->save();
-
- $url = &new BaseRequestGenerator();
-
- for ($cnt = 0; $cnt < count($messages); $cnt++) {
- $req = &new HTTP_Request($url->getBaseUrl(false)."/moblog.php");
- $req->setMethod(HTTP_REQUEST_METHOD_POST);
- $req->addPostData('message', $messages[$cnt]);
- $req->sendRequest();
- $response = $req->getResponseBody();
- }
- }
-?>
More information about the pLog-svn
mailing list