[pLog-svn] r5105 - in plugins/branches/lifetype-1.2/unported: . moblog moblog/class/action moblog/class/log moblog/class/moblog moblog/locale moblog/templates

oscar at devel.lifetype.net oscar at devel.lifetype.net
Thu Mar 15 18:34:53 EDT 2007


Author: oscar
Date: 2007-03-15 18:34:53 -0400 (Thu, 15 Mar 2007)
New Revision: 5105

Modified:
   plugins/branches/lifetype-1.2/unported/moblog.php
   plugins/branches/lifetype-1.2/unported/moblog/class/action/adminmoblogbatchpluginsettingsaction.class.php
   plugins/branches/lifetype-1.2/unported/moblog/class/action/adminmoblogbatchpluginupdatesettingsaction.class.php
   plugins/branches/lifetype-1.2/unported/moblog/class/action/adminmoblogpluginsettingsaction.class.php
   plugins/branches/lifetype-1.2/unported/moblog/class/action/adminmoblogpluginupdatesettingsaction.class.php
   plugins/branches/lifetype-1.2/unported/moblog/class/log/mobloglogger.class.php
   plugins/branches/lifetype-1.2/unported/moblog/class/moblog/moblogrequest.class.php
   plugins/branches/lifetype-1.2/unported/moblog/locale/locale_en_UK.php
   plugins/branches/lifetype-1.2/unported/moblog/pluginmoblog.class.php
   plugins/branches/lifetype-1.2/unported/moblog/templates/moblogbatchsettings.template
Log:
Moblog plugin ported to LT 1.2.


Modified: plugins/branches/lifetype-1.2/unported/moblog/class/action/adminmoblogbatchpluginsettingsaction.class.php
===================================================================
--- plugins/branches/lifetype-1.2/unported/moblog/class/action/adminmoblogbatchpluginsettingsaction.class.php	2007-03-15 20:07:00 UTC (rev 5104)
+++ plugins/branches/lifetype-1.2/unported/moblog/class/action/adminmoblogbatchpluginsettingsaction.class.php	2007-03-15 22:34:53 UTC (rev 5105)
@@ -1,16 +1,18 @@
 <?php
 
-	lt_include( PLOG_CLASS_PATH."class/action/admin/siteadminaction.class.php" );
+	lt_include( PLOG_CLASS_PATH."class/action/admin/adminaction.class.php" );
 	lt_include( PLOG_CLASS_PATH."plugins/moblog/class/view/adminmoblogbatchpluginsettingsview.class.php" );
 
 	/**
 	 * doesn't do almost anything :))
 	 */
-	class AdminMoblogBatchPluginSettingsAction extends SiteAdminAction
+	class AdminMoblogBatchPluginSettingsAction extends AdminAction
 	{
 		function AdminMoblogBatchPluginSettingsAction( $actionInfo, $request )
 		{
-			$this->SiteAdminAction( $actionInfo, $request );
+			$this->AdminAction( $actionInfo, $request );
+			
+			$this->requireAdminPermission( "manage_admin_plugins" );
 		}
 
 		function perform()

Modified: plugins/branches/lifetype-1.2/unported/moblog/class/action/adminmoblogbatchpluginupdatesettingsaction.class.php
===================================================================
--- plugins/branches/lifetype-1.2/unported/moblog/class/action/adminmoblogbatchpluginupdatesettingsaction.class.php	2007-03-15 20:07:00 UTC (rev 5104)
+++ plugins/branches/lifetype-1.2/unported/moblog/class/action/adminmoblogbatchpluginupdatesettingsaction.class.php	2007-03-15 22:34:53 UTC (rev 5105)
@@ -1,17 +1,19 @@
 <?php
 
-	lt_include( PLOG_CLASS_PATH."class/action/admin/siteadminaction.class.php" );
+	lt_include( PLOG_CLASS_PATH."class/action/admin/adminaction.class.php" );
 	lt_include( PLOG_CLASS_PATH."plugins/moblog/class/view/adminmoblogbatchpluginsettingsview.class.php" );
 	lt_include( PLOG_CLASS_PATH."plugins/moblog/class/moblog/moblogconstants.properties.php" );
 
-	class AdminMoblogBatchPluginUpdateSettingsAction extends SiteAdminAction
+	class AdminMoblogBatchPluginUpdateSettingsAction extends AdminAction
 	{
 	
 	   var $_pluginEnabled;
 
 		function AdminMoblogBatchPluginUpdateSettingsAction( $actionInfo, $request )
 		{
-			$this->SiteAdminAction( $actionInfo, $request );
+			$this->AdminAction( $actionInfo, $request );
+			
+			$this->requireAdminPermission( "manage_admin_plugins" );			
 		}
 	
 		function validate()

Modified: plugins/branches/lifetype-1.2/unported/moblog/class/action/adminmoblogpluginsettingsaction.class.php
===================================================================
--- plugins/branches/lifetype-1.2/unported/moblog/class/action/adminmoblogpluginsettingsaction.class.php	2007-03-15 20:07:00 UTC (rev 5104)
+++ plugins/branches/lifetype-1.2/unported/moblog/class/action/adminmoblogpluginsettingsaction.class.php	2007-03-15 22:34:53 UTC (rev 5105)
@@ -1,16 +1,16 @@
 <?php
 
-	lt_include( PLOG_CLASS_PATH."class/action/admin/blogowneradminaction.class.php" );
+	lt_include( PLOG_CLASS_PATH."class/action/admin/adminaction.class.php" );
 	lt_include( PLOG_CLASS_PATH."plugins/moblog/class/view/adminmoblogpluginsettingsview.class.php" );
 
 	/**
 	 * doesn't do almost anything :))
 	 */
-	class AdminMoblogPluginSettingsAction extends BlogOwnerAdminAction
+	class AdminMoblogPluginSettingsAction extends AdminAction
 	{
 		function AdminMoblogPluginSettingsAction( $actionInfo, $request )
 		{
-			$this->BlogOwnerAdminAction( $actionInfo, $request );
+			$this->AdminAction( $actionInfo, $request );
 		}
 
 		function perform()

Modified: plugins/branches/lifetype-1.2/unported/moblog/class/action/adminmoblogpluginupdatesettingsaction.class.php
===================================================================
--- plugins/branches/lifetype-1.2/unported/moblog/class/action/adminmoblogpluginupdatesettingsaction.class.php	2007-03-15 20:07:00 UTC (rev 5104)
+++ plugins/branches/lifetype-1.2/unported/moblog/class/action/adminmoblogpluginupdatesettingsaction.class.php	2007-03-15 22:34:53 UTC (rev 5105)
@@ -1,17 +1,17 @@
 <?php
 
-	lt_include( PLOG_CLASS_PATH."class/action/admin/blogowneradminaction.class.php" );
+	lt_include( PLOG_CLASS_PATH."class/action/admin/adminaction.class.php" );
 	lt_include( PLOG_CLASS_PATH."plugins/moblog/class/view/adminmoblogpluginsettingsview.class.php" );
 	lt_include( PLOG_CLASS_PATH."plugins/moblog/class/moblog/moblogconstants.properties.php" );
 
-	class AdminMoblogPluginUpdateSettingsAction extends BlogOwnerAdminAction
+	class AdminMoblogPluginUpdateSettingsAction extends AdminAction
 	{
 	
 	   var $_pluginEnabled;
 
 		function AdminMoblogPluginUpdateSettingsAction( $actionInfo, $request )
 		{
-			$this->BlogOwnerAdminAction( $actionInfo, $request );
+			$this->AdminAction( $actionInfo, $request );
 		}
 	
 		function validate()
@@ -23,7 +23,7 @@
 			// check how images should be embedded
 			$this->_previewType = $this->_request->getValue( "resourcePreviewType" );
 			if( $this->_previewType < MOBLOG_EMBED_SMALL_PREVIEW ||
-			    $this->_previewType > MOBLOG_EMBED_FULL_SIZE )
+			    $this->_previewType > MOBLOG_EMBED_FULL_SIZE_VIEW )
 			    $this->_previewType = MOBLOG_EMBED_SMALL_PREVIEW;		    
 
 			return true;

Modified: plugins/branches/lifetype-1.2/unported/moblog/class/log/mobloglogger.class.php
===================================================================
--- plugins/branches/lifetype-1.2/unported/moblog/class/log/mobloglogger.class.php	2007-03-15 20:07:00 UTC (rev 5104)
+++ plugins/branches/lifetype-1.2/unported/moblog/class/log/mobloglogger.class.php	2007-03-15 22:34:53 UTC (rev 5105)
@@ -17,6 +17,7 @@
 		{
 			$config =& Config::getConfig();
 			if( $config->getValue( "moblog_logging_enabled" )) {
+				include_once( PLOG_CLASS_PATH."class/logger/loggermanager.class.php" );
 				$logger =& LoggerManager::getLogger();
 				$logger->debug( $message );		
 			}

Modified: plugins/branches/lifetype-1.2/unported/moblog/class/moblog/moblogrequest.class.php
===================================================================
--- plugins/branches/lifetype-1.2/unported/moblog/class/moblog/moblogrequest.class.php	2007-03-15 20:07:00 UTC (rev 5104)
+++ plugins/branches/lifetype-1.2/unported/moblog/class/moblog/moblogrequest.class.php	2007-03-15 22:34:53 UTC (rev 5105)
@@ -3,14 +3,14 @@
     lt_include( PLOG_CLASS_PATH."plugins/moblog/class/moblog/mimeDecode.class.php" );
     lt_include( PLOG_CLASS_PATH."plugins/moblog/class/moblog/moblogconstants.properties.php" );
     lt_include( PLOG_CLASS_PATH."plugins/moblog/class/log/mobloglogger.class.php" );
-    lt_include( PLOG_CLASS_PATH."class/data/textfilter.class.php" );
-    
-    /**
-     * the following strings will be filtered out from moblogged messages. At least in case
-     * of Finnish Elisa operator, every message is sent including this annoying notice
-     */
-    $_moblog_filter_out = Array(
-      "This is a HTML message, sorry"
+    lt_include( PLOG_CLASS_PATH."class/data/textfilter.class.php" );
+    
+    /**
+     * the following strings will be filtered out from moblogged messages. At least in case
+     * of Finnish Elisa operator, every message is sent including this annoying notice
+     */
+    $_moblog_filter_out = Array(
+      "This is a HTML message, sorry"
     );
 
     /**
@@ -35,16 +35,14 @@
         var $_inputEncoding;
         
         function MoblogRequest( $request )
-        {
-            
-        
-            $this->_message = $request["message"];
+        {                  
+            isset( $request["message"] ) ? $this->_message = $request["message"] : $this->_message = 0;
             // it is possible to specify a default user id in the POSTed email message via
             // curl, so that the amount of stuff that we need to type in the email is reduced
             // to only the user password. This basically means that email addresses configured to be used
             // by a default user and blog id cannot be used as 'gateways'
-            $this->_blogId = $request["blogId"];
-            $this->_user = $request["user"];
+            isset( $request["blogId"] ) ? $this->_blogId = $request["blogId"] : $this->_blogId = "";
+            isset( $request["user"] ) ? $this->_user = $request["user"] : $this->_user = "";
             
             MoblogLogger::log( "From REQUEST: user = ".$this->_user." - blogId = ".$this->_blogId );
             
@@ -140,11 +138,11 @@
             $body = str_replace($host[0], "", $body );
             
             // strip off a standard .sig. Properly formed .sigs start with '-- ' on a new line.
-            list($body, $sig) = explode("\n-- ", $body);
-            
-            global $_moblog_filter_out;
-            foreach( $_moblog_filter_out as $str ) {
-                $body = str_replace( $str, '', $body );
+            list($body, $sig) = explode("\n-- ", $body);
+            
+            global $_moblog_filter_out;
+            foreach( $_moblog_filter_out as $str ) {
+                $body = str_replace( $str, '', $body );
             }
             
             MoblogLogger::log( "parseBody ---> body = $body" );
@@ -187,9 +185,9 @@
                         // GalleryResources::addResource only deals with uploaded files, so we'll
                         // have to pretend that this is one of them!
                         $config =& Config::getConfig();
-                        // $tmpFolder = $config->getValue( "temp_folder" );
-                        // $tmpFolderName = $tmpFolder."/".md5(microtime());
-                        $tmpFolderName = $config->getValue( "temp_folder" );
+                        $tmpFolder = $config->getValue( "temp_folder" );
+                        $tmpFolderName = $tmpFolder."/".md5(microtime());
+                        //$tmpFolderName = $config->getValue( "temp_folder" );
                         File::createDir( $tmpFolderName );
                         MoblogLogger::log( "Creating temp folder = $tmpFolderName" );
                         $fileName = stripslashes($part->ctype_parameters["name"]);
@@ -204,7 +202,7 @@
                                                    
                         $fileName = str_replace( "\"", "", $fileName );
                         $fileName = str_replace( "'", "", $fileName );
-                        $tmpName = $tmpFolderName."/".md5(microtime())."_".$fileName;
+                        $tmpName = $tmpFolderName."/".$fileName;
                         $fileName = urldecode( $fileName );
                         
 			            if ( MOBLOG_FORCE_ENCODE_TO_UTF8 )

Modified: plugins/branches/lifetype-1.2/unported/moblog/locale/locale_en_UK.php
===================================================================
--- plugins/branches/lifetype-1.2/unported/moblog/locale/locale_en_UK.php	2007-03-15 20:07:00 UTC (rev 5104)
+++ plugins/branches/lifetype-1.2/unported/moblog/locale/locale_en_UK.php	2007-03-15 22:34:53 UTC (rev 5105)
@@ -7,4 +7,16 @@
 $messages["moblog_resources_help"] = "Uploading resources such as images and videos is also supported by this implementation. In which album would you like files to be classified?";
 $messages["moblog_image_preview_type_help"] = "When embedding images in moblogged posts, how should the image be embedded?'";
 
+$messages["moblogbatch_mailserver_help"] = "SMTP server that contains the messages that should be posted to the blog";
+$messages["moblogbatch_port_help"] = "Port where the SMTP server is running";
+$messages["moblogbatch_username_help"] = "Username that should be used to authenticate against the SMTP server";
+$messages["moblogbatch_password_help"] = "Password that should be used to authenticate against the SMTP server";
+$messages["moblogbatch_pseudobatch_help"] = "How often should messages be checked, in minutes";
+$messages["moblogbatch_lastupdate_help"] = "tbd";
+
+$messages["small_preview"] = "Small preview";
+$messages["medium_preview"] = "Medium preview";
+$messages["full_size"] = "Full size picture";
+
+$messages["moblogBatchSettings"] = "Moblog Batch";
 ?>
\ No newline at end of file

Modified: plugins/branches/lifetype-1.2/unported/moblog/pluginmoblog.class.php
===================================================================
--- plugins/branches/lifetype-1.2/unported/moblog/pluginmoblog.class.php	2007-03-15 20:07:00 UTC (rev 5104)
+++ plugins/branches/lifetype-1.2/unported/moblog/pluginmoblog.class.php	2007-03-15 22:34:53 UTC (rev 5105)
@@ -9,11 +9,12 @@
     class PluginMoblog extends PluginBase
     {
     
-        function PluginMoblog()
+        function PluginMoblog( $source )
         {
             $this->id = "moblog";
             $this->author = "The LifeType Project";
             $this->locales = Array();
+			$this->version = "20070315";
             $this->desc = "
 Send a message with the following format ('start' and 'end' messages not included!):<br/>
 <br/>
@@ -37,24 +38,25 @@
 		function init()
 		{
 			// register the filter
-			$this->registerFilter( "MoblogBatchFilter" );
-			
-			// register actions
-			$this->registerAdminAction( "moblogSettings", "AdminMoblogPluginSettingsAction" );
-			$this->registerAdminAction( "updateMoblogSettings", "AdminMoblogPluginUpdateSettingsAction" );
-			$this->registerAdminAction( "moblogbatchSettings", "AdminMoblogBatchPluginSettingsAction" );
-			$this->registerAdminAction( "updateMoblogBatchSettings", "AdminMoblogBatchPluginUpdateSettingsAction" );
+			if( $this->getSource() == "index" ) {
+				$this->registerFilter( "MoblogBatchFilter" );
+			}
+			else {
+				// register actions
+				$this->registerAdminAction( "moblogSettings", "AdminMoblogPluginSettingsAction" );
+				$this->registerAdminAction( "updateMoblogSettings", "AdminMoblogPluginUpdateSettingsAction" );
+				$this->registerAdminAction( "moblogbatchSettings", "AdminMoblogBatchPluginSettingsAction" );
+				$this->registerAdminAction( "updateMoblogBatchSettings", "AdminMoblogBatchPluginUpdateSettingsAction" );
 
 
-			// register menu entries
-			$this->addMenuEntry( "/menu/controlCenter/manageSettings",   // menu path
-                                             "moblogSettings",    // menu id
-                                             "admin.php?op=moblogSettings",     // url
-                                             "Moblog",    // text to show
-                                             true,       // can't...
-                                             false       // ...remember :)
-                                            );
-			$this->addMenuEntry( "/menu/adminSettings/GlobalSettings", "moblogbatchSettings", "admin.php?op=moblogbatchSettings", "" );                                            
+				// register menu entries
+				$this->addMenuEntry( "/menu/controlCenter/manageSettings",   // menu path
+	                                             "moblogSettings",    // menu id
+	                                             "admin.php?op=moblogSettings",     // url
+	                                             "Moblog"    // text to show
+	                                            );
+				$this->addMenuEntry( "/menu/adminSettings/GlobalSettings", "moblogbatchSettings", "admin.php?op=moblogbatchSettings", "" );
+			}
 		}        
     }
 ?>
\ No newline at end of file

Modified: plugins/branches/lifetype-1.2/unported/moblog/templates/moblogbatchsettings.template
===================================================================
--- plugins/branches/lifetype-1.2/unported/moblog/templates/moblogbatchsettings.template	2007-03-15 20:07:00 UTC (rev 5104)
+++ plugins/branches/lifetype-1.2/unported/moblog/templates/moblogbatchsettings.template	2007-03-15 22:34:53 UTC (rev 5105)
@@ -6,37 +6,37 @@
   {include file="$admintemplatepath/successmessage.template"}
   {include file="$admintemplatepath/errormessage.template"} 
   <div class="field">
-   <label for="mailServer">{$locale->tr("label_mailserver")}</label>
+   <label for="mailServer">{$locale->tr("mailserver")}</label>
    <span class="required">*</span>
-   <div class="formHelp">{$locale->tr("moblogbatch_mailserver")}</div>
+   <div class="formHelp">{$locale->tr("moblogbatch_mailserver_help")}</div>
    <input class="text" type="text" name="mailServer" id="mailServer" value="{$mailServer}" width="30" />
   </div>
 
   <div class="field">
-   <label for="port">{$locale->tr("label_port")}</label>
+   <label for="port">{$locale->tr("port")}</label>
    <span class="required">*</span>
-   <div class="formHelp">{$locale->tr("moblogbatch_port")}</div>
+   <div class="formHelp">{$locale->tr("moblogbatch_port_help")}</div>
    <input class="text" type="text" name="port" id="port" value="{$port}" width="10" />
   </div>  
 
   <div class="field">
-   <label for="userName">{$locale->tr("label_username")}</label>
+   <label for="userName">{$locale->tr("username")}</label>
    <span class="required">*</span>
-   <div class="formHelp">{$locale->tr("moblogbatch_username")}</div>
+   <div class="formHelp">{$locale->tr("moblogbatch_username_help")}</div>
    <input class="text" type="text" name="userName" id="userName" value="{$userName}" width="30" />
   </div>
 
   <div class="field">
-   <label for="password">{$locale->tr("label_password")}</label>
+   <label for="password">{$locale->tr("password")}</label>
    <span class="required">*</span>
-   <div class="formHelp">{$locale->tr("moblogbatch_password")}</div>
+   <div class="formHelp">{$locale->tr("moblogbatch_password_help")}</div>
    <input class="text" type="text" name="password" id="password" value="{$password}" width="30" />
   </div>    
   
   <div class="field">
-   <label for="pseudoBatch">{$locale->tr("label_pseudobatch")}</label>
+   <label for="pseudoBatch">{$locale->tr("pseudobatch")}</label>
    <span class="required"></span>
-   <div class="formHelp">{$locale->tr("moblogbatch_pseudobatch")}</div>
+   <div class="formHelp">{$locale->tr("moblogbatch_pseudobatch_help")}</div>
    <select name="pseudoBatch" id="pseudoBatch">
     <option value="Off" {if $pseudoBatch=="Off"}selected="selected"{/if}>{$locale->tr("moblogbatch_off")}</option>
     <option value="10" {if $pseudoBatch==10}selected="selected"{/if}>10</option>
@@ -51,9 +51,9 @@
   </div>
   
   <div class="field">
-   <label for="lastUpdate">{$locale->tr("label_lastupdate")}</label>
+   <label for="lastUpdate">{$locale->tr("lastupdate")}</label>
    <span class="required">*</span>
-   <div class="formHelp">{$locale->tr("moblogbatch_lastupdate")}</div>
+   <div class="formHelp">{$locale->tr("moblogbatch_lastupdate_help")}</div>
    <input class="text" type="text" name="lastUpdate" id="lastUpdate" value="{$lastUpdate}" width="10" />
   </div>
   

Modified: plugins/branches/lifetype-1.2/unported/moblog.php
===================================================================
--- plugins/branches/lifetype-1.2/unported/moblog.php	2007-03-15 20:07:00 UTC (rev 5104)
+++ plugins/branches/lifetype-1.2/unported/moblog.php	2007-03-15 22:34:53 UTC (rev 5105)
@@ -38,7 +38,8 @@
     
     // get the request
     $request = HttpVars::getRequest();
-    $message = $request["message"];    
+	isset( $request["message"] ) ? $message = $request["message"] : $message = "";
+    
     if( $message == "" ) {
         MoblogLogger::log( "There was no message!" );
         die();
@@ -146,11 +147,10 @@
     }
     
     //
-    // now check if the user has permissions over the blog
+    // now check if the user is allowed to post in the given blog
     //
-$userPermissions = new UserPermissions();
-    $userPerm = $userPermissions->getUserPermissions( $userInfo->getId(), $blogInfo->getId());
-    if( !$userPerm ) {
+	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."
@@ -209,13 +209,16 @@
     $res = new GalleryResources();
     $resourceIds = Array();
     foreach( $attachments as $attachment ) {
-        MoblogLogger::log( "-- Processing attachment ".$attachment->getFileName());
-        $result = $res->addResource( $blogInfo->getId(), $albumId, $attachment->getFileName(), $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???");
+		}
     }
     
     //



More information about the pLog-svn mailing list