[pLog-svn] r2870 - in plog/trunk: class/action/admin class/controller class/summary/action class/summary/mail imgs/admin locale templates/admin

oscar at devel.lifetype.net oscar at devel.lifetype.net
Sun Jan 29 19:45:07 GMT 2006


Author: oscar
Date: 2006-01-29 19:45:07 +0000 (Sun, 29 Jan 2006)
New Revision: 2870

Added:
   plog/trunk/class/action/admin/adminresendconfirmationaction.class.php
   plog/trunk/class/summary/mail/summarymailer.class.php
   plog/trunk/imgs/admin/icon_mail-16.png
Modified:
   plog/trunk/class/controller/admincontrollermap.properties.php
   plog/trunk/class/summary/action/dofinishregister.class.php
   plog/trunk/locale/locale_en_UK.php
   plog/trunk/templates/admin/siteblogs.template
Log:
Added feature request 810 (http://bugs.lifetype.net/view.php?id=810), so that confirmation mails can be resent from the admin interface.

Added: plog/trunk/class/action/admin/adminresendconfirmationaction.class.php
===================================================================
--- plog/trunk/class/action/admin/adminresendconfirmationaction.class.php	2006-01-29 18:55:29 UTC (rev 2869)
+++ plog/trunk/class/action/admin/adminresendconfirmationaction.class.php	2006-01-29 19:45:07 UTC (rev 2870)
@@ -0,0 +1,69 @@
+<?php
+
+	include_once( PLOG_CLASS_PATH."class/action/admin/siteadminaction.class.php" );
+    include_once( PLOG_CLASS_PATH."class/view/admin/adminsiteblogslistview.class.php" );
+    include_once( PLOG_CLASS_PATH."class/view/admin/admineditsiteblogview.class.php" );
+    include_once( PLOG_CLASS_PATH."class/data/validator/integervalidator.class.php" );
+    include_once( PLOG_CLASS_PATH."class/dao/blogs.class.php" );
+
+    /**
+     * \ingroup Action
+     * @private
+     *
+     * Action that shows a form to change the settings of a blog.
+     */
+    class AdminResendConfirmationAction extends SiteAdminAction 
+	{
+
+    	var $_editBlogId;
+
+    	/**
+         * Constructor. If nothing else, it also has to call the constructor of the parent
+         * class, BlogAction with the same parameters
+         */
+        function AdminResendConfirmationAction( $actionInfo, $request )
+        {
+        	$this->SiteAdminAction( $actionInfo, $request );
+			
+			// data validation
+			$this->registerFieldValidator( "blogId", new IntegerValidator());
+			$view = new AdminSiteBlogsListView( $this->_blogInfo );
+			$view->setErrorMessage( $this->_locale->tr("error_incorrect_blog_id" ));
+			$this->setValidationErrorView( $view );
+        }
+
+        /**
+         * Carries out the specified action
+         */
+        function perform()
+        {
+        	// get the blog and its settings
+        	$this->_editBlogId = $this->_request->getValue( "blogId" );			
+            $blogs = new Blogs();
+            $blogInfo = $blogs->getBlogInfo( $this->_editBlogId);
+
+            if( !$blogInfo ) {
+            	$this->_view = new AdminSiteBlogsListView( $this->_blogInfo );
+                $this->_view->setErrorMessage( $this->_locale->tr("error_incorrect_blog_id" ));
+                $this->setCommonData();
+                return false;
+            }
+
+			$this->notifyEvent( EVENT_BLOG_LOADED, Array( "blog" => &$blogInfo ));
+
+			// now that we have the right blog loaded, regenerate the confirmation email
+			include_once( PLOG_CLASS_PATH."class/summary/mail/summarymailer.class.php" );
+			
+			// load the blog owner
+			$blogOwner = $blogInfo->getOwnerInfo();
+			// generate and send the right link
+			SummaryMailer::sendConfirmationEmail( $blogOwner->getUsername());
+			// print a confirmation message
+			$this->_view->setSuccessMessage( $this->_locale->tr( "confirmation_message_resent_ok" ));
+			$this->setCommonData();
+
+            // better to return true if everything fine
+            return true;
+        }
+    }
+?>

Modified: plog/trunk/class/controller/admincontrollermap.properties.php
===================================================================
--- plog/trunk/class/controller/admincontrollermap.properties.php	2006-01-29 18:55:29 UTC (rev 2869)
+++ plog/trunk/class/controller/admincontrollermap.properties.php	2006-01-29 19:45:07 UTC (rev 2870)
@@ -276,4 +276,6 @@
   	$actions["editGlobalArticleCategory"] = "AdminEditGlobalArticleCategoryAction";
   	// updates the category
   	$actions["updateGlobalArticleCategory"] = "AdminUpdateGlobalArticleCategoryAction";	
+	// resend the confirmation email
+	$actions["resendConfirmation"] = "AdminResendConfirmationAction";
 ?>

Modified: plog/trunk/class/summary/action/dofinishregister.class.php
===================================================================
--- plog/trunk/class/summary/action/dofinishregister.class.php	2006-01-29 18:55:29 UTC (rev 2869)
+++ plog/trunk/class/summary/action/dofinishregister.class.php	2006-01-29 19:45:07 UTC (rev 2870)
@@ -1,7 +1,6 @@
 <?php
 
     include_once( PLOG_CLASS_PATH."class/summary/action/registeraction.class.php" );
-    include_once( PLOG_CLASS_PATH."class/summary/mail/confirmemailmessage.class.php" );
     include_once( PLOG_CLASS_PATH."class/template/cachecontrol.class.php" );    
     include_once( PLOG_CLASS_PATH."class/dao/articlecategories.class.php" );
     include_once( PLOG_CLASS_PATH."class/dao/users.class.php" );
@@ -10,7 +9,7 @@
     include_once( PLOG_CLASS_PATH."class/dao/userinfo.class.php" );
     include_once( PLOG_CLASS_PATH."class/dao/article.class.php" );
 	include_once( PLOG_CLASS_PATH."class/dao/articles.class.php" );
-	include_once( PLOG_CLASS_PATH."class/mail/emailservice.class.php" );
+	include_once( PLOG_CLASS_PATH."class/summary/mail/summarymailer.class.php" );
 
     /**
      * finish the user and blog registration process
@@ -59,7 +58,8 @@
         /**
          * create the user
          */
-        function createUser(){
+        function createUser()
+		{
             // all data is already correct
             $this->userName = $this->_request->getValue("userName");
             $this->userFullName = $this->_request->getValue("userFullName");
@@ -97,7 +97,8 @@
         /**
          * create the blog
          */
-        function createBlog($userId){
+        function createBlog($userId)
+		{
             $this->blogName = stripslashes($this->_request->getValue("blogName"));
             $this->blogLocale = $this->_request->getValue("blogLocale");
             $this->templateId = $this->_request->getValue("templateId");
@@ -174,12 +175,13 @@
         /**
          * finished registaration
          */
-        function doneRegister(){
+        function doneRegister()
+		{
             $this->_view = new SummaryView("registerstep5");
             
             if($this->need_confirm == 1){
                 $this->_view->setValue("need_email_confirm",1);
-                $this->sendConfirmEmail();
+                $this->sendConfirmationEmail( $this->userName );
             }
             else {
                 // add the blog object to the template
@@ -190,53 +192,6 @@
             return true;
         }
         //}}}
-
-        //{{{function sendConfirmEmail(){
-        /**
-         * send confirm email to user.
-         * user will active his/her account according to this email
-         */
-        function sendConfirmEmail(){
-            $activeCode = $this->generateActiveCode();
-
-            // store the active code to the backend db in the properties field of user table
-            $users = new Users();
-            $userInfo = $users->getUserInfoFromUsername($this->userName);
-            $userInfo->setProperties(Array("activeCode"=>$activeCode));
-            $users->updateUser($userInfo);
-
-
-            $message = new ConfirmEmailMessage();
-            $message->setFrom( $this->_config->getValue( "post_notification_source_address" ));
-            $message->addTo( $this->userEmail);
-            $message->setSubject( "pLog user registration confirmation for: ".$this->userName);
-            $message->setUsername($this->userName);
-            $message->setActiveCode($activeCode);
-
-            // create active Link
-            $base_url = $this->_config->getValue("base_url");
-            $message->setActiveLink($base_url."/summary.php?op=activeAccount&username="
-                    .$this->userName."&activeCode=".$activeCode);
-            $message->createBody();
-
-            $service = new EmailService();
-            $service->sendMessage( $message );
-
-        }
-        //}}}
-
-        //{{{function generateActiveCode(){
-        /**
-         * generate a random active code based on current time
-         * @return a string that random generated
-         * @access private
-         */
-        function generateActiveCode(){
-            srand((double)microtime() * 10000000);  
-            $activeCode = md5(time() . rand(1, 10000000));
-            return $activeCode;
-        }
-        //}}}
     }
 
     /*

Added: plog/trunk/class/summary/mail/summarymailer.class.php
===================================================================
--- plog/trunk/class/summary/mail/summarymailer.class.php	2006-01-29 18:55:29 UTC (rev 2869)
+++ plog/trunk/class/summary/mail/summarymailer.class.php	2006-01-29 19:45:07 UTC (rev 2870)
@@ -0,0 +1,57 @@
+<?php
+	
+	class SummaryMailer
+	{
+        /**
+         * send confirm email to user.
+         * user will activate his/her account according to this email
+		 *
+		 * @static
+         */
+        function sendConfirmationEmail( $userName ) 
+		{
+			include_once( PLOG_CLASS_PATH."class/summary/mail/confirmemailmessage.class.php" );		
+			include_once( PLOG_CLASS_PATH."class/config/config.class.php" );
+			include_once( PLOG_CLASS_PATH."class/mail/emailservice.class.php" );			
+
+            $activeCode = SummaryMailer::generateActiveCode();
+
+            // store the active code to the backend db in the properties field of user table
+            $users = new Users();
+            $userInfo = $users->getUserInfoFromUsername( $userName );
+            $userInfo->setProperties(Array("activeCode"=>$activeCode));
+            $users->updateUser($userInfo);
+
+
+			$config =& Config::getConfig();
+            $message = new ConfirmEmailMessage();
+            $message->setFrom( $config->getValue( "post_notification_source_address" ));
+            $message->addTo( $userInfo->getEmail());
+            $message->setSubject( "pLog user registration confirmation for: ".$userName);
+            $message->setUsername($userName);
+            $message->setActiveCode($activeCode);
+
+            // create active Link
+            $base_url = $config->getValue("base_url");
+            $message->setActiveLink($base_url."/summary.php?op=activeAccount&username="
+                    .$userName."&activeCode=".$activeCode);
+            $message->createBody();
+
+            $service = new EmailService();
+            $service->sendMessage( $message );
+        }
+		
+        /**
+         * generate a random active code based on current time
+         * @return a string that random generated
+         * @access private
+		 * @static
+         */
+        function generateActiveCode()
+		{
+            srand((double)microtime() * 10000000);  
+            $activeCode = md5(time() . rand(1, 10000000));
+            return $activeCode;
+        }
+	}
+?>
\ No newline at end of file

Added: plog/trunk/imgs/admin/icon_mail-16.png
===================================================================
(Binary files differ)


Property changes on: plog/trunk/imgs/admin/icon_mail-16.png
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Modified: plog/trunk/locale/locale_en_UK.php
===================================================================
--- plog/trunk/locale/locale_en_UK.php	2006-01-29 18:55:29 UTC (rev 2869)
+++ plog/trunk/locale/locale_en_UK.php	2006-01-29 19:45:07 UTC (rev 2870)
@@ -976,4 +976,6 @@
 $messages['hide_option_panel'] = 'Hide Options';
 
 $messages['quick_launches'] = 'Quick Launches';
+
+$messages['confirmation_message_resent_ok'] = 'Confirmation message resent successfully.';
 ?>
\ No newline at end of file

Modified: plog/trunk/templates/admin/siteblogs.template
===================================================================
--- plog/trunk/templates/admin/siteblogs.template	2006-01-29 18:55:29 UTC (rev 2869)
+++ plog/trunk/templates/admin/siteblogs.template	2006-01-29 19:45:07 UTC (rev 2870)
@@ -74,6 +74,9 @@
         <div class="list_action_button">
          <a href="?op=deleteBlog&amp;blogId={$siteblog->getId()}"><img src="imgs/admin/icon_delete-16.png" alt="{$locale->tr("delete")}" /></a>
          <a href="?op=editBlog&amp;blogId={$siteblog->getId()}"><img src="imgs/admin/icon_edit-16.png" alt="{$locale->tr("edit_blog")}" /></a>
+		 {if $siteblog->getStatus() == 3}
+         <a href="?op=resendConfirmation&amp;blogId={$siteblog->getId()}"><img src="imgs/admin/icon_mail-16.png" alt="{$locale->tr("resend_confirmation_blog")}" /></a>
+		 {/if}
         </div>
       </tr>
      {/foreach}



More information about the pLog-svn mailing list