[pLog-svn] r6199 - in plugins/branches/lifetype-1.2/submissions: . class/action class/view locale templates

reto at devel.lifetype.net reto at devel.lifetype.net
Sun Mar 2 09:49:15 EST 2008


Author: reto
Date: 2008-03-02 09:49:15 -0500 (Sun, 02 Mar 2008)
New Revision: 6199

Added:
   plugins/branches/lifetype-1.2/submissions/locale/locale_de_DE.php
Modified:
   plugins/branches/lifetype-1.2/submissions/class/action/addsubmissionaction.class.php
   plugins/branches/lifetype-1.2/submissions/class/action/adminsubmissionspluginupdatesettingsaction.class.php
   plugins/branches/lifetype-1.2/submissions/class/view/adminsubmissionspluginsettingsview.class.php
   plugins/branches/lifetype-1.2/submissions/locale/locale_en_UK.php
   plugins/branches/lifetype-1.2/submissions/locale/locale_zh_TW.php
   plugins/branches/lifetype-1.2/submissions/pluginsubmissions.class.php
   plugins/branches/lifetype-1.2/submissions/readme.txt
   plugins/branches/lifetype-1.2/submissions/templates/pluginsettings.template
Log:
Updates to the submission plugin:
- Option to let the blog owner notify of new submissions
- localized custom field descriptions
- added german locale
- fixed some typos in the custom field ID
- added global admin settings



Modified: plugins/branches/lifetype-1.2/submissions/class/action/addsubmissionaction.class.php
===================================================================
--- plugins/branches/lifetype-1.2/submissions/class/action/addsubmissionaction.class.php	2008-02-29 16:07:42 UTC (rev 6198)
+++ plugins/branches/lifetype-1.2/submissions/class/action/addsubmissionaction.class.php	2008-03-02 14:49:15 UTC (rev 6199)
@@ -7,6 +7,9 @@
 	lt_include( PLOG_CLASS_PATH."class/dao/customfields/customfields.class.php" );
 	lt_include( PLOG_CLASS_PATH."class/dao/customfields/customfieldsvalues.class.php" );	
 	lt_include( PLOG_CLASS_PATH."class/dao/articles.class.php" );
+	lt_include( PLOG_CLASS_PATH."class/dao/permissions.class.php" );
+	lt_include( PLOG_CLASS_PATH."class/dao/userpermissions.class.php" );
+	lt_include( PLOG_CLASS_PATH."class/mail/emailservice.class.php" );
     
     /**
      * Checks an incoming submission and adds it to the database if all is correct
@@ -96,6 +99,12 @@
 			
 			// add the article to the db, finally
 			if( $articles->addArticle( $article )) {
+			    
+			    // notify registred blog authors if notifications are enabled
+			    $blogSettings = $this->_blogInfo->getSettings();
+			    if ($blogSettings->getValue( "plugin_submissions_notifications_enabled" ) === true) {
+			        $this->notifyNewSubmission();
+				}
 				$this->_view = new PluginTemplatedView( $this->_blogInfo, "submissions", "accepted" );
 			}
 			else {
@@ -107,5 +116,31 @@
 			
             return true;
         }
+        
+		/**
+		 * Sends a notification message to the blog owner to inform him
+		 * that a new article has just been submitted
+		 *
+		 * @private
+		 */
+		function notifyNewSubmission()
+		{
+
+			$user =& $this->_blogInfo->getOwnerInfo();
+		
+			$config =& Config::getConfig();
+            $message = new EmailMessage();
+            $message->setFrom( $config->getValue( "post_notification_source_address" ));
+            $message->setSubject( $this->_locale->tr("plugin_submissions_notification_subject" ));
+            $message->setCharset( $this->_locale->getCharset());
+            $message->setBody( $this->_locale->tr("plugin_submissions_notifications_body" ) );
+			
+	        $service = new EmailService();
+
+            $message->setTo( $user->getEmail());
+	        $service->sendMessage( $message );
+
+		}
+        
     }
-?>
\ No newline at end of file
+?>

Modified: plugins/branches/lifetype-1.2/submissions/class/action/adminsubmissionspluginupdatesettingsaction.class.php
===================================================================
--- plugins/branches/lifetype-1.2/submissions/class/action/adminsubmissionspluginupdatesettingsaction.class.php	2008-02-29 16:07:42 UTC (rev 6198)
+++ plugins/branches/lifetype-1.2/submissions/class/action/adminsubmissionspluginupdatesettingsaction.class.php	2008-03-02 14:49:15 UTC (rev 6199)
@@ -11,6 +11,7 @@
 	
 		var $_pluginEnabled;
 		var $_htmlareaEnabled;
+		var $_notificationEnabled;
 
     	/**
          * Constructor. If nothing else, it also has to call the constructor of the parent
@@ -30,22 +31,25 @@
             
             $this->_htmlareaEnabled = $this->_request->getValue( "htmlareaEnabled" );
             $this->_htmlareaEnabled = ($this->_htmlareaEnabled != "" );            
-			
+
+            $this->_notificationEnabled = $this->_request->getValue( "notificationEnabled" );
+            $this->_notificationEnabled = ($this->_htmlareaEnabled != "" );  
+
 			return true;
 		}
 		
 		/**
-		 * checks if the fields already exist and if not, creates them
+		 * creates the custom fields
 		 */
 		function _createFields()
 		{
 			$customFields = new CustomFields();
 			$blogFields = $customFields->getBlogCustomFields( $this->_blogInfo->getId());
 			
-			// check if the checkbox fields exists
+			
 			if( !array_key_exists( "submittedBy", $blogFields )) {
 				$customFieldSubmittedBy = new CustomField( "submittedBy", 
-				                                           "Submissition sent by",
+				                                           $this->_locale->tr("plugin_submissions_submitter" ),
 														   CUSTOM_FIELD_TEXTBOX,
 														   $this->_blogInfo->getId(),
 														   false,
@@ -58,10 +62,10 @@
 				$customFields->updateCustomField( $protectedField );
 			}
 			
-			// check if the field for the password exists
+			
 			if( !array_key_exists( "submitterAddress", $blogFields )) {
 				$customFieldSubmitterAddress = new CustomField( "submitterAddress", 
-				                                                "Email address of submitter",
+				                                                $this->_locale->tr("plugin_submissions_submitter_email" ),
 												      		    CUSTOM_FIELD_TEXTBOX,
 														        $this->_blogInfo->getId(),
 																false,
@@ -78,7 +82,7 @@
 		}
 		
 		/**
-		 * checks if the fields already exist and if so, disables them (sets them to be "hidden")
+		 * Updates the custom fields
 		 */
 		function _updateFields()
 		{
@@ -112,6 +116,7 @@
 			$blogSettings = $this->_blogInfo->getSettings();
 			$blogSettings->setValue( "plugin_submissions_enabled", $this->_pluginEnabled );
 			$blogSettings->setValue( "plugin_submissions_htmlarea_enabled", $this->_htmlareaEnabled );
+			$blogSettings->setValue( "plugin_submissions_notifications_enabled", $this->_notificationEnabled );
 			$this->_blogInfo->setSettings( $blogSettings );
 			
 			// update the settings in the db, and make sure that everything went fine
@@ -145,4 +150,4 @@
             return true;
         }
     }
-?>
\ No newline at end of file
+?>

Modified: plugins/branches/lifetype-1.2/submissions/class/view/adminsubmissionspluginsettingsview.class.php
===================================================================
--- plugins/branches/lifetype-1.2/submissions/class/view/adminsubmissionspluginsettingsview.class.php	2008-02-29 16:07:42 UTC (rev 6198)
+++ plugins/branches/lifetype-1.2/submissions/class/view/adminsubmissionspluginsettingsview.class.php	2008-03-02 14:49:15 UTC (rev 6199)
@@ -19,12 +19,14 @@
 			$blogSettings = $this->_blogInfo->getSettings();
 			$pluginEnabled = $blogSettings->getValue( "plugin_submissions_enabled" );
 			$htmlareaEnabled = $blogSettings->getValue( "plugin_submissions_htmlarea_enabled" );
+			$notificationsEnabled = $blogSettings->getValue( "plugin_submissions_notifications_enabled" );
 			
 			// create a view and export the settings to the template
 			$this->setValue( "pluginEnabled", $pluginEnabled );
 			$this->setValue( "htmlareaEnabled", $htmlareaEnabled );
+			$this->setValue( "notificationsEnabled", $notificationsEnabled );
 			
 			parent::render();
 		}
 	}
-?>
\ No newline at end of file
+?>

Added: plugins/branches/lifetype-1.2/submissions/locale/locale_de_DE.php
===================================================================
--- plugins/branches/lifetype-1.2/submissions/locale/locale_de_DE.php	                        (rev 0)
+++ plugins/branches/lifetype-1.2/submissions/locale/locale_de_DE.php	2008-03-02 14:49:15 UTC (rev 6199)
@@ -0,0 +1,37 @@
+<?php
+$messages["submissionsPluginSettings"] = "Beitr&auml;ge";
+$messages["submissions"] = "Beitr&auml;ge von Besuchern";
+
+$messages["submissions_plugin_enabled"] = "Plugin aktivieren";
+$messages["submissions_plugin"] = "Beitr&auml;ge Plugin";
+
+$messages["submissions_htmlarea_enabled"] = "Den WYSIWYG-Editor f&uuml;r Beitr&auml;ge aktivieren";
+$messages["submissions_settings_saved_ok"] = "Einstellungen erfolgreich gespeichert!";
+$messages["error_submissions_not_enabled"] = "Bitte aktivieren Sie das Beitr&auml;ge Plugin zuerst.";
+$messages["error_submission_no_topic"] = "Tragen Sie einen Betreff ein.";
+$messages["error_submission_no_text"] = "Tragen Sie Inhalt ein.";
+$messages["error_submission_no_category"] = "Sie m&uuml;ssen mindestens eine Kategorie ausw&auml;hlen.";
+$messages["submission_accepted_ok"] = "Ihr Beitrag wurde erfolgreich &uuml;bermittelt!";
+
+$messages["label_configuration"] = "Konfiguration";
+$messages["label_enable"] = "aktivieren";
+$messages["label_htmlarea_enabled"] = "Editor aktivieren";
+
+$messages["your_name"] = "Ihr Name (optional): ";
+$messages["your_email_address"] = "Ihre E-Mail (optional): ";
+$messages["story_topic"] = "Betreff: ";
+$messages["story_contents"] = "Beitrag: ";
+$messages["submit_story"] = "Beitrag senden";
+$messages["post_status_external_submission"] = "unmoderiert";
+
+$messages["label_submissions_notifications_enabled"] = "Benachrichtigung aktivieren";
+$messages["submissions_notifications_enabled"] = "E-Mail Benachrichtigung f&uuml; den Blog besitzer aktivieren.";
+
+$messages["plugin_submissions_notification_subject"] = "[LifeType] Neuer Beitrag";
+$messages["plugin_submissions_notifications_body"] = "Hallo,
+Sie haben einen neuen Beitrag erhalten. Melden Sie sich an Ihrem Blog an, um den Beitrag zu moderieren.
+
+Viel Spass!";
+$messages["plugin_submissions_submitter"] = "Beitrag gesendet von";
+$messages["plugin_submissions_submitter_email"] = "E-Mail Adresse des Authors";
+?>

Modified: plugins/branches/lifetype-1.2/submissions/locale/locale_en_UK.php
===================================================================
--- plugins/branches/lifetype-1.2/submissions/locale/locale_en_UK.php	2008-02-29 16:07:42 UTC (rev 6198)
+++ plugins/branches/lifetype-1.2/submissions/locale/locale_en_UK.php	2008-03-02 14:49:15 UTC (rev 6199)
@@ -24,4 +24,15 @@
 $messages["submit_story"] = "Submit Story";
 $messages["post_status_external_submission"] = "Unmoderated";
 
-?>
\ No newline at end of file
+$messages["label_submissions_notifications_enabled"] = "Enable notification";
+$messages["submissions_notifications_enabled"] = "Enable e-mail notifications for the blog owner.";
+
+$messages["plugin_submissions_notification_subject"] = "[LifeType] New submisstion for your blog";
+$messages["plugin_submissions_notifications_body"] = "Hello,
+You received a new submission. Log in to your blog to moderate the submission.
+
+Have a nice day!";
+$messages["plugin_submissions_submitter"] = "Submission sent by";
+$messages["plugin_submissions_submitter_email"] = "E-Mail address of submitter";
+
+?>

Modified: plugins/branches/lifetype-1.2/submissions/locale/locale_zh_TW.php
===================================================================
--- plugins/branches/lifetype-1.2/submissions/locale/locale_zh_TW.php	2008-02-29 16:07:42 UTC (rev 6198)
+++ plugins/branches/lifetype-1.2/submissions/locale/locale_zh_TW.php	2008-03-02 14:49:15 UTC (rev 6199)
@@ -22,5 +22,16 @@
 $messages["story_topic"] = "文章標題:";
 $messages["story_contents"] = "文章內容:";
 $messages["submit_story"] = "送出文章";
-$messages["post_status_external_submission"] = "未審核";
-?>
\ No newline at end of file
+$messages["post_status_external_submission"] = "未審核";
+
+$messages["label_submissions_notifications_enabled"] = "Enable notification";
+$messages["submissions_notifications_enabled"] = "Enable e-mail notifications for the blog owner.";
+
+$messages["plugin_submissions_notification_subject"] = "[LifeType] New submisstion for your blog";
+$messages["plugin_submissions_notifications_body"] = "Hello,
+You received a new submission. Log in to your blog to moderate the submission.
+
+Have a nice day!";
+$messages["plugin_submissions_submitter"] = "Submission sent by";
+$messages["plugin_submissions_submitter_email"] = "E-Mail address of submitter";
+?>

Modified: plugins/branches/lifetype-1.2/submissions/pluginsubmissions.class.php
===================================================================
--- plugins/branches/lifetype-1.2/submissions/pluginsubmissions.class.php	2008-02-29 16:07:42 UTC (rev 6198)
+++ plugins/branches/lifetype-1.2/submissions/pluginsubmissions.class.php	2008-03-02 14:49:15 UTC (rev 6199)
@@ -19,7 +19,7 @@
 			$this->id = "submissions";
 			$this->desc = "Allows visitors to submit stories to the blog.";
 			$this->author = "The LifeType Project";
-			$this->version = "20070423";
+			$this->version = "20080228";
 			
 			$this->init();
 		}
@@ -36,6 +36,7 @@
 			$this->registerAdminAction( "pluginSubmissionsUpdateSettings", "AdminSubmissionsPluginUpdateSettingsAction" );
 			
 			// add a couple of menu entries
+			//$this->addMenuEntry( "/menu/Manage/managePosts", "submissionsPluginSettings", "admin.php?op=submissionsPluginSettings", "submissionsPluginSettings", array(), array("plugin_submission"), false );
 			$this->addMenuEntry( "/menu/Manage/managePosts", "submissionsPluginSettings", "admin.php?op=submissionsPluginSettings", "", true, false );
 		}
 
@@ -44,6 +45,7 @@
 		    $blogSettings = $this->blogInfo->getSettings();
 		    $this->pluginEnabled = $blogSettings->getValue( "plugin_submissions_enabled" );
 		    $this->htmlareaEnabled = $blogSettings->getValue( "plugin_submissions_htmlarea_enabled" );
+		    $this->notificationsEnabled = $blogSettings->getValue( "plugin_submissions_notifications_enabled" );
 	    }
 	    
 	    function isEnabled()
@@ -56,6 +58,11 @@
 	        return $this->htmlareaEnabled;
 	    }
 
+	    function isNotificationsEnabled()
+	    {
+	        return $this->notificationsEnabled;
+	    }
+
         function pluginTemplatePage()
         {
  			$rg = new RawRequestGenerator($this->blogInfo);
@@ -66,6 +73,18 @@
             $templatePage = $rg->getIndexUrl().$rg->getRequest();
 
             return $templatePage;
-        }	    		
+        }
+        
+        function getPluginConfigurationKeys(){
+
+            return (Array(
+                        Array("name" => "plugin_submissions_enabled",
+                              "type" => "boolean"),
+                        Array("name" => "plugin_submissions_htmlarea_enabled",
+                              "type" => "boolean"),
+                        Array("name" => "plugin_submissions_notifications_enabled",
+                              "type" => "boolean")
+                        ));
+        }	
 	}  
-?>
\ No newline at end of file
+?>

Modified: plugins/branches/lifetype-1.2/submissions/readme.txt
===================================================================
--- plugins/branches/lifetype-1.2/submissions/readme.txt	2008-02-29 16:07:42 UTC (rev 6198)
+++ plugins/branches/lifetype-1.2/submissions/readme.txt	2008-03-02 14:49:15 UTC (rev 6199)
@@ -7,9 +7,6 @@
 
 Install:
 2. Configure and enable the Submissions plugin in your LifeType control center
-3. Use $submissions->pluginTemplatePage() to get submissions template page url
+3. Use {$submissions->pluginTemplatePage()} in your template to get the url to the submissions page
 
-Usage:
-Use the following URL to call your LifeType Submission Plugin Page
-http://your-plog/index.php?op=submissionForm&blogId=1
-
+

Modified: plugins/branches/lifetype-1.2/submissions/templates/pluginsettings.template
===================================================================
--- plugins/branches/lifetype-1.2/submissions/templates/pluginsettings.template	2008-02-29 16:07:42 UTC (rev 6198)
+++ plugins/branches/lifetype-1.2/submissions/templates/pluginsettings.template	2008-03-02 14:49:15 UTC (rev 6199)
@@ -9,7 +9,11 @@
    <label for="pluginEnabled">{$locale->tr("label_enable")}</label>
    <span class="required"></span>
    <div class="formHelp">
-    <input class="checkbox" type="checkbox" name="pluginEnabled" id="pluginEnabled" {if $pluginEnabled} checked="checked" {/if} value="1" />{$locale->tr("submissions_plugin_enabled")}
+    <input class="checkbox" type="checkbox" name="pluginEnabled" id="pluginEnabled" {if $pluginEnabled} checked="checked" {/if}
+     {user_cannot_override
+           key=plugin_submissions_enabled}disabled="disabled"
+     {/user_cannot_override}
+     value="1" />{$locale->tr("submissions_plugin_enabled")}
    </div>
   </div>
 
@@ -17,10 +21,27 @@
    <label for="htmlareaEnabled">{$locale->tr("label_htmlarea_enabled")}</label>
    <span class="required"></span>
    <div class="formHelp">
-    <input class="checkbox" type="checkbox" name="htmlareaEnabled" id="htmlareaEnabled" {if $htmlareaEnabled} checked="checked" {/if} value="1" />{$locale->tr("submissions_htmlarea_enabled")}
+    <input class="checkbox" type="checkbox" name="htmlareaEnabled" id="htmlareaEnabled" {if $htmlareaEnabled} checked="checked" {/if}
+     {user_cannot_override
+           key=plugin_submissions_htmlarea_enabled}disabled="disabled"
+     {/user_cannot_override}
+     value="1" />{$locale->tr("submissions_htmlarea_enabled")}
    </div>
   </div>  
- 
+
+  <div class="field">
+   <label for="notificationsEnabled">{$locale->tr("label_submissions_notifications_enabled")}</label>
+   <span class="required"></span>
+   <div class="formHelp">
+    <input class="checkbox" type="checkbox" name="notificationsEnabled" id="notificationsEnabled" {if $notificationsEnabled} checked="checked" {/if}
+     {user_cannot_override
+           key=plugin_submissions_notifications_enabled}disabled="disabled"
+     {/user_cannot_override}
+     value="1" />{$locale->tr("submissions_notifications_enabled")}
+   </div>
+  </div> 
+
+
  </fieldset>
  
  <div class="buttons">  
@@ -30,4 +51,4 @@
  </div>
 </form>
 {include file="$admintemplatepath/footernavigation.template"}
-{include file="$admintemplatepath/footer.template"}
\ No newline at end of file
+{include file="$admintemplatepath/footer.template"}



More information about the pLog-svn mailing list