[pLog-svn] r6864 - in plugins/branches/lifetype-1.2/moblog: . class/action class/moblog class/view install locale templates

jondaley at devel.lifetype.net jondaley at devel.lifetype.net
Wed Apr 15 15:14:31 EDT 2009


Author: jondaley
Date: 2009-04-15 15:14:31 -0400 (Wed, 15 Apr 2009)
New Revision: 6864

Modified:
   plugins/branches/lifetype-1.2/moblog/class/action/adminmoblogbatchpluginupdatesettingsaction.class.php
   plugins/branches/lifetype-1.2/moblog/class/action/adminmoblogpluginupdatesettingsaction.class.php
   plugins/branches/lifetype-1.2/moblog/class/moblog/moblogrequest.class.php
   plugins/branches/lifetype-1.2/moblog/class/view/adminmoblogpluginsettingsview.class.php
   plugins/branches/lifetype-1.2/moblog/install/moblog.php
   plugins/branches/lifetype-1.2/moblog/locale/locale_en_UK.php
   plugins/branches/lifetype-1.2/moblog/pluginmoblog.class.php
   plugins/branches/lifetype-1.2/moblog/templates/pluginsettings.template
Log:
update for 1.2 (adding configurationKeys) and now with validation - let's not let people trivially hack us, shall we?  Various requests from bornheim.net.  Some not completed yet (article categories and global category to be specified in the phone message.

Modified: plugins/branches/lifetype-1.2/moblog/class/action/adminmoblogbatchpluginupdatesettingsaction.class.php
===================================================================
--- plugins/branches/lifetype-1.2/moblog/class/action/adminmoblogbatchpluginupdatesettingsaction.class.php	2009-04-15 18:32:07 UTC (rev 6863)
+++ plugins/branches/lifetype-1.2/moblog/class/action/adminmoblogbatchpluginupdatesettingsaction.class.php	2009-04-15 19:14:31 UTC (rev 6864)
@@ -18,6 +18,7 @@
 	
 		function validate()
 		{
+                // TODO: validate this
 		    $this->_mailServer = $this->_request->getValue( "mailServer" );
 		    $this->_port = $this->_request->getValue( "port" );
 			$this->_userName = $this->_request->getValue( "userName" );

Modified: plugins/branches/lifetype-1.2/moblog/class/action/adminmoblogpluginupdatesettingsaction.class.php
===================================================================
--- plugins/branches/lifetype-1.2/moblog/class/action/adminmoblogpluginupdatesettingsaction.class.php	2009-04-15 18:32:07 UTC (rev 6863)
+++ plugins/branches/lifetype-1.2/moblog/class/action/adminmoblogpluginupdatesettingsaction.class.php	2009-04-15 19:14:31 UTC (rev 6864)
@@ -3,28 +3,49 @@
 	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" );
+    lt_include( PLOG_CLASS_PATH."class/data/validator/integervalidator.class.php" );
+    lt_include( PLOG_CLASS_PATH."class/data/validator/arrayvalidator.class.php" );
 
 	class AdminMoblogPluginUpdateSettingsAction extends AdminAction
 	{
 	
-	   var $_pluginEnabled;
-
+        var $_pluginEnabled;
+        var $_categoryIds;
+        var $_albumId;
+        var $_previewType;
+        var $_globalArticleCategoryId;
+        
 		function AdminMoblogPluginUpdateSettingsAction( $actionInfo, $request )
 		{
 			$this->AdminAction( $actionInfo, $request );
+        	$this->registerFieldValidator("categoryIds", new ArrayValidator(new IntegerValidator()));
+        	$this->registerFieldValidator("pluginEnabled", new IntegerValidator(), true);
+        	$this->registerFieldValidator("albumId", new IntegerValidator());
+        	$this->registerFieldValidator("resourcePreviewType", new IntegerValidator());
+        	$this->registerFieldValidator("globalArticleCategoryId", new IntegerValidator());
+
+			$view = new AdminMoblogPluginSettingsView( $this->_blogInfo, $this->_userInfo );
+        	$view->setErrorMessage( $this->_locale->tr("moblog_error_updating_settings"));
+        	$this->setValidationErrorView( $view );
 		}
 	
 		function validate()
 		{
-		    $this->_pluginEnabled = $this->_request->getValue( "pluginEnabled" );
-			$this->_categoryId = $this->_request->getValue( "categoryId" );
+            if(!parent::validate())
+                return false;
+            
+            $this->_pluginEnabled = $this->_request->getValue( "pluginEnabled" );
+            $this->_pluginEnabled = ($this->_pluginEnabled != "" );
+
+			$this->_categoryIds = $this->_request->getValue( "categoryIds" );
 			$this->_albumId = $this->_request->getValue( "albumId" );
-			$this->_password = $this->_request->getValue( "password" );
+            $this->_globalArticleCategoryId = $this->_request->getValue( "globalArticleCategoryId" );
+
 			// 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_VIEW )
-			    $this->_previewType = MOBLOG_EMBED_SMALL_PREVIEW;		    
+			    $this->_previewType = MOBLOG_EMBED_SMALL_PREVIEW;
 
 			return true;
 		}
@@ -33,7 +54,9 @@
 		{		
 			// save the settings
 			$blogSettings = $this->_blogInfo->getSettings();
-			$blogSettings->setValue( "plugin_moblog_article_category_id", $this->_categoryId );
+                // note, the following preference is singular (without the 's' for backward compatibility)
+			$blogSettings->setValue( "plugin_moblog_article_category_id", $this->_categoryIds );
+			$blogSettings->setValue( "plugin_moblog_global_article_category_id", $this->_globalArticleCategoryId );
 			$blogSettings->setValue( "plugin_moblog_gallery_resource_album_id", $this->_albumId );
 			$blogSettings->setValue( "plugin_moblog_resource_preview_type", $this->_previewType );					
 			$blogSettings->setValue( "plugin_moblog_enabled", $this->_pluginEnabled );

Modified: plugins/branches/lifetype-1.2/moblog/class/moblog/moblogrequest.class.php
===================================================================
--- plugins/branches/lifetype-1.2/moblog/class/moblog/moblogrequest.class.php	2009-04-15 18:32:07 UTC (rev 6863)
+++ plugins/branches/lifetype-1.2/moblog/class/moblog/moblogrequest.class.php	2009-04-15 19:14:31 UTC (rev 6864)
@@ -48,7 +48,6 @@
             isset( $request["user"] ) ? $this->_user = $request["user"] : $this->_user = "";
             isset( $request["password"] ) ? $this->_pass = $request["password"] : $this->_pass = "";
             
-            MoblogLogger::log( "From REQUEST: user = ".$this->_user." - blogId = ".$this->_blogId." - pass = ".$this->_pass );
             
             // parse the mime message
             $decode = new Mail_mimeDecode( $this->_message, "\r\n" );

Modified: plugins/branches/lifetype-1.2/moblog/class/view/adminmoblogpluginsettingsview.class.php
===================================================================
--- plugins/branches/lifetype-1.2/moblog/class/view/adminmoblogpluginsettingsview.class.php	2009-04-15 18:32:07 UTC (rev 6863)
+++ plugins/branches/lifetype-1.2/moblog/class/view/adminmoblogpluginsettingsview.class.php	2009-04-15 19:14:31 UTC (rev 6864)
@@ -24,7 +24,7 @@
 			// fetch the current settings
 			$blogSettings = $this->_blogInfo->getSettings();			
 			$pluginEnabled = $blogSettings->getValue( "plugin_moblog_enabled" );
-			$categoryId = $blogSettings->getValue( "plugin_moblog_article_category_id" );
+			$categoryIds = $blogSettings->getValue( "plugin_moblog_article_category_id" );
 			$albumId = $blogSettings->getValue( "plugin_moblog_gallery_resource_album_id" );
 			$resourcePreviewType = $blogSettings->getValue( "plugin_moblog_resource_preview_type" );
 
@@ -37,7 +37,7 @@
 			
 			// finally pass all these things to the templates
 			$this->setValue( "pluginEnabled", $pluginEnabled );			
-			$this->setValue( "categoryId", $categoryId );
+			$this->setValue( "categoryIds", $categoryIds );
 			$this->setValue( "albumId", $albumId );
 			$this->setValue( "albums", $blogAlbums );
 			$this->setValue( "categories", $blogCategories );

Modified: plugins/branches/lifetype-1.2/moblog/install/moblog.php
===================================================================
--- plugins/branches/lifetype-1.2/moblog/install/moblog.php	2009-04-15 18:32:07 UTC (rev 6863)
+++ plugins/branches/lifetype-1.2/moblog/install/moblog.php	2009-04-15 19:14:31 UTC (rev 6864)
@@ -11,7 +11,7 @@
     define( "MOBLOG_DEBUG", false );
     
     // bring in some code that we need
-    include( PLOG_CLASS_PATH."class/bootstrap.php" );    
+    include_once( 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" );

Modified: plugins/branches/lifetype-1.2/moblog/locale/locale_en_UK.php
===================================================================
--- plugins/branches/lifetype-1.2/moblog/locale/locale_en_UK.php	2009-04-15 18:32:07 UTC (rev 6863)
+++ plugins/branches/lifetype-1.2/moblog/locale/locale_en_UK.php	2009-04-15 19:14:31 UTC (rev 6864)
@@ -8,12 +8,14 @@
 $messages["enable_plugin"] = "Enable plugin";
 $messages["enable_moblog_plugin_help"] = "Enable the moblog plugin.";
 $messages["moblog_plugin_settings_saved_ok"] = "Moblog settings saved successfully!";
-$messages["moblog_articles_help"] = "In which category would you like articles posted to be categorized?";
-$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_articles_help"] = "Which categories should articles be posted in?";
+$messages["moblog_resources_help"] = "Which album should resources (such as images and videos) be uploaded to?";
 $messages["small_preview"] = "Small preview";
 $messages["medium_preview"] = "Medium preview";
 $messages["full_size"] = "Full size picture";
 $messages["moblog_image_preview_type_help"] = "When embedding images in moblogged posts, how should the image be embedded?'";
+$messages['moblog_global_article_category_help'] = 'Which site-wide category should articles be posted in?';
+$messages["moblog_error_updating_settings"] = "There was an error updating the settings.";
 
 //
 // Moblog Batch Strings
@@ -30,7 +32,7 @@
 $messages["moblogbatch_pseudobatch"] = "Pseudobatch";
 $messages["moblogbatch_pseudobatch_help"] = "How often should messages be checked, in minutes. Set the pseudobatch to 'disabled' if you are using a server-side batch (aka cronjob) to check for new moblogs.";
 $messages["moblogbatch_lastupdate"] = "Last Update";
-$messages["moblogbatch_lastupdate_help"] = "Last time Moblog Batch was checking for new articles.";
+$messages["moblogbatch_lastupdate_help"] = "Last time Moblog Batch checked for new articles.";
 $messages["moblogbatch_off"] = "disabled";
 $messages["moblogbatch_settings_saved_ok"] = "Moblog Batch settings saved successfully!";
 

Modified: plugins/branches/lifetype-1.2/moblog/pluginmoblog.class.php
===================================================================
--- plugins/branches/lifetype-1.2/moblog/pluginmoblog.class.php	2009-04-15 18:32:07 UTC (rev 6863)
+++ plugins/branches/lifetype-1.2/moblog/pluginmoblog.class.php	2009-04-15 19:14:31 UTC (rev 6864)
@@ -14,17 +14,15 @@
             $this->id = "moblog";
             $this->author = "The Lifetype Project";
             $this->locales = Array();
-			$this->version = "20071028";
+			$this->version = "20090415";
             $this->desc = "
 Send a message with the following format ('start' and 'end' messages not included!):<br/>
 <br/>
 --- start of moblog message format ---<br/>
-<br/>
 USER: your-lifetype-username<br/>
 PASS: your-lifetype-password<br/>
 BLOG: your-lifetype-blog-name or BLOGID: id-of-your-blog<br/>
-TOPIC: your-subject (optional)
-<br/>
+TOPIC: your-subject (optional)<br/>
 --- end of moblog message format ---<br/>
 <br/>
 The subject of the mail will be used as the subject for the article as long as there is no TOPIC set.<br/>
@@ -82,5 +80,29 @@
 				$perms->addPermission( $perm );
 			}			
 		}       
+
+		function getPluginConfigurationKeys()
+		{
+			lt_include( PLOG_CLASS_PATH."class/data/validator/integervalidator.class.php" );
+
+			return( Array(
+				Array( "name" => "plugin_moblog_enabled", "type" => "boolean" ),
+				Array( "name" => "plugin_moblog_resource_preview_type",
+                       "validator" => new IntegerValidator(),
+                       "type" => "integer",
+                       "allowEmpty" => true),
+
+                    // Note: this API doesn't allow multiple IDs to be set, ie. no nested validators, like:
+                    //  new ArrayValidator(new IntegerValidator())
+                Array( "name" => "plugin_moblog_article_category_ids",
+                       "validator" => new IntegerValidator(),
+                       "type" => "integer",
+                       "allowEmpty" => true),
+				Array( "name" => "plugin_moblog_gallery_resource_album_ids",
+                       "validator" => new IntegerValidator(),
+                       "type" => "integer",
+                       "allowEmpty" => true),
+			));
+		}
     }
 ?>

Modified: plugins/branches/lifetype-1.2/moblog/templates/pluginsettings.template
===================================================================
--- plugins/branches/lifetype-1.2/moblog/templates/pluginsettings.template	2009-04-15 18:32:07 UTC (rev 6863)
+++ plugins/branches/lifetype-1.2/moblog/templates/pluginsettings.template	2009-04-15 19:14:31 UTC (rev 6864)
@@ -3,26 +3,37 @@
 <form id="pluginMoblogSettings" method="post" action="admin.php">
  <fieldset class="inputField">
   <legend>{$locale->tr("moblogSettings")}</legend>
-  {include file="$admintemplatepath/successmessage.template"}
-  {include file="$admintemplatepath/errormessage.template"}  
+  {include file="$admintemplatepath/formvalidate.template"}
+
   <div class="field">
    <label for="pluginEnabled">{$locale->tr("enable_plugin")}</label>
    <div class="formHelp">
     <input type="checkbox" name="pluginEnabled" value="1"  class="checkbox" {if $pluginEnabled}checked="checked"{/if} />
     {$locale->tr("enable_moblog_plugin_help")}
+	{include file="$admintemplatepath/validate.template" field="pluginEnabled" message=$locale->tr("error_incorrect_value")}			
    </div> 
   </div>
   
   <!-- article categories -->
   <div class="field">
-   <label for="categoryId">{$locale->tr("posts")}</label>
+   <label for="categoryIds">{$locale->tr("posts")}</label>
    <div class="formHelp">{$locale->tr("moblog_articles_help")}</div>
-   <select name="categoryId">
+   <select name="categoryIds[]" multiple="multiple" size="5">
     {foreach from=$categories item=category}
-	<option value="{$category->getId()}" {if $categoryId == $category->getId()}selected="selected"{/if}>{$category->getName()}</option>
+     <option value="{$category->getId()}" {foreach from=$categoryIds item=categoryId}{if $category->getId() == $categoryId} selected="selected" {/if}{/foreach}>{$category->getName()}</option>
 	{/foreach}
    </select>
-  </div> 
+	{include file="$admintemplatepath/validate.template" field="categoryIds" message=$locale->tr("error_incorrect_value")}			
+
+	<div class="formHelp">{$locale->tr("moblog_global_article_category_help")}</div>
+    <select name="globalArticleCategoryId" id="globalArticleCategoryId">
+	  <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}
+    </select>
+    {include file="$admintemplatepath/validate.template" field=globalArticleCategoryId message=$locale->tr("error_no_global_article_category_selected")}	   
+   </div>   
   
  <!-- album categories -->
  <div class="field">
@@ -33,6 +44,7 @@
     <option value="{$album->getId()}" {if $albumId == $album->getId()}selected="selected"{/if}>{$album->getName()}</option>
    {/foreach}
   </select>
+	{include file="$admintemplatepath/validate.template" field="albumId" message=$locale->tr("error_incorrect_value")}			
   <br/>
    <div class="formHelp">{$locale->tr("moblog_image_preview_type_help")}</div>
     <select name="resourcePreviewType">
@@ -40,6 +52,7 @@
      <option value="2" {if $resourcePreviewType==2}selected="selected"{/if}>{$locale->tr("medium_preview")}</option>
      <option value="3" {if $resourcePreviewType==3}selected="selected"{/if}>{$locale->tr("full_size")}</option>
     </select>
+	{include file="$admintemplatepath/validate.template" field="resourcePreviewType" message=$locale->tr("error_incorrect_value")}			
  </div>  
   
 </fieldset>



More information about the pLog-svn mailing list