[pLog-svn] r6784 - in plugins/branches/lifetype-1.2/unported/subscribe: . class/dao class/security locale templates

jondaley at devel.lifetype.net jondaley at devel.lifetype.net
Sun Feb 1 09:14:06 EST 2009


Author: jondaley
Date: 2009-02-01 09:14:06 -0500 (Sun, 01 Feb 2009)
New Revision: 6784

Modified:
   plugins/branches/lifetype-1.2/unported/subscribe/class/dao/subscriptions.class.php
   plugins/branches/lifetype-1.2/unported/subscribe/class/security/subscribefilter.class.php
   plugins/branches/lifetype-1.2/unported/subscribe/locale/locale_en_UK.php
   plugins/branches/lifetype-1.2/unported/subscribe/pluginsubscribe.class.php
   plugins/branches/lifetype-1.2/unported/subscribe/templates/register.template
Log:
now works with authenticated commenters.  removed handy SQL builders, since they no longer exist - too bad.  One locale message was moved to the admin section, so we need our own copy

Modified: plugins/branches/lifetype-1.2/unported/subscribe/class/dao/subscriptions.class.php
===================================================================
--- plugins/branches/lifetype-1.2/unported/subscribe/class/dao/subscriptions.class.php	2009-02-01 13:31:52 UTC (rev 6783)
+++ plugins/branches/lifetype-1.2/unported/subscribe/class/dao/subscriptions.class.php	2009-02-01 14:14:06 UTC (rev 6784)
@@ -57,14 +57,9 @@
         while($row = $result->FetchRow()){
             $address = $row["address"];
             $code = Subscriptions::_getConfirmationCode($address);
-            
-            $query = Db::buildUpdateQuery("subscribe",
-                                          array("confirm" => $code),
-                                          array("address" => $address));
-            
+            $query = "UPDATE ${prefix}subscribe SET confirm='$code' WHERE address='$address'";
             if(!$db->Execute($query))
                 return false;
-
         }
 
         
@@ -86,10 +81,9 @@
     function confirmSubscription($confirmation){
         lt_include( PLOG_CLASS_PATH."class/database/db.class.php" );
         $db =& Db::getDb();
-        $query = Db::buildUpdateQuery("subscribe",
-                                      array("active" => 1),
-                                      array("confirm" => $confirmation));
+        $prefix = Db::getPrefix();
         
+        $query = "UPDATE ${prefix}subscribe SET active=1 WHERE confirm='$confirmation'";
         if(!$db->Execute($query))
             return false;
 
@@ -110,12 +104,10 @@
 
         foreach($ids as $id){
             $db =& Db::getDb();
-            $query = Db::buildInsertQuery("subscribe",
-                                          array("objid" => $id,
-                                                "active" => 0,
-                                                "type" => $type,
-                                                "address" => $address,
-                                                "confirm" => $confirmation));
+            $prefix = Db::getPrefix();
+
+            $query = "INSERT INTO ${prefix}subscribe (objid, active, type, address, confirm) ".
+                "VALUES('$id', 0, '$type', '$address', '$confirmation')";
             $result = $db->Execute($query);
             if(!$result)
                 return false;
@@ -131,9 +123,8 @@
         lt_include( PLOG_CLASS_PATH."class/database/db.class.php" );
 
         $db =& Db::getDb();
-        $query = Db::buildDeleteQuery("subscribe",
-                                      "confirm",
-                                      $confirmation);
+        $prefix = Db::getPrefix();
+        $query = "DELETE FROM ${prefix}subscribe WHERE confirm='$confirmation'";
         $result = $db->Execute($query);
         if(!$result)
             return false;
@@ -160,10 +151,6 @@
         $query .= "objid=0)";
 
         $db =& Db::getDb();
-//        $query = Db::buildSelectQuery("subscribe",
-//                                      "address",
-//                                      array("active" => 1,
-//                                            "type" => $type,
 
         $result = $db->Execute($query);
         if( !$result )

Modified: plugins/branches/lifetype-1.2/unported/subscribe/class/security/subscribefilter.class.php
===================================================================
--- plugins/branches/lifetype-1.2/unported/subscribe/class/security/subscribefilter.class.php	2009-02-01 13:31:52 UTC (rev 6783)
+++ plugins/branches/lifetype-1.2/unported/subscribe/class/security/subscribefilter.class.php	2009-02-01 14:14:06 UTC (rev 6784)
@@ -44,6 +44,11 @@
                 // email is required: validate it.
             $emailAddress = $request->getValue("userEmail");
 
+                // check if they are already logged in (ie. an authenticated commenter)
+            $userInfo = SessionManager::getUserInfoFromSession();  
+            if($emailAddress == "" && $userInfo){
+                $emailAddress = $userInfo->getEmail();
+            }
             lt_include( PLOG_CLASS_PATH."class/data/validator/emailvalidator.class.php" );
 
             $emailValidator = new EmailValidator();

Modified: plugins/branches/lifetype-1.2/unported/subscribe/locale/locale_en_UK.php
===================================================================
--- plugins/branches/lifetype-1.2/unported/subscribe/locale/locale_en_UK.php	2009-02-01 13:31:52 UTC (rev 6783)
+++ plugins/branches/lifetype-1.2/unported/subscribe/locale/locale_en_UK.php	2009-02-01 14:14:06 UTC (rev 6784)
@@ -36,4 +36,6 @@
 
 $messages["subscribe_email_removal"] = "Click on the following link to remove all subscriptions to this blog:\n%s";
 
+$messages['subscribe_email_help'] = 'Email address where notifications will be sent.';
+
 ?>
\ No newline at end of file

Modified: plugins/branches/lifetype-1.2/unported/subscribe/pluginsubscribe.class.php
===================================================================
--- plugins/branches/lifetype-1.2/unported/subscribe/pluginsubscribe.class.php	2009-02-01 13:31:52 UTC (rev 6783)
+++ plugins/branches/lifetype-1.2/unported/subscribe/pluginsubscribe.class.php	2009-02-01 14:14:06 UTC (rev 6784)
@@ -197,6 +197,13 @@
                 if(isset($request["subscribe"])){
                         // We already validated this
                     $emailAddress = $request["userEmail"];
+
+                        // check if they are already logged in (ie. an authenticated commenter)
+                    $userInfo = SessionManager::getUserInfoFromSession();  
+                    if($emailAddress == "" && $userInfo){
+                        $emailAddress = $userInfo->getEmail();
+                    }
+                    
                         // save subscription info to database
                     if(Subscriptions::addSubscriptions(array($comment->getArticleId()),
                                                         SUBSCRIBE_COMMENTS_IN_POST,

Modified: plugins/branches/lifetype-1.2/unported/subscribe/templates/register.template
===================================================================
--- plugins/branches/lifetype-1.2/unported/subscribe/templates/register.template	2009-02-01 13:31:52 UTC (rev 6783)
+++ plugins/branches/lifetype-1.2/unported/subscribe/templates/register.template	2009-02-01 14:14:06 UTC (rev 6784)
@@ -9,7 +9,7 @@
   {include file="$admintemplatepath/errormessage.template"}
 
     <div class="field">
-      <div class="formHelp">{$locale->tr("email_help")}</div>
+      <div class="formHelp">{$locale->tr("subscribe_email_help")}</div>
       <input type="text" name="subscribeEmail" value="{$subscribeEmail}" 
              id="subscribeEmail" />
       {include file="$admintemplatepath/validate.template" field=subscribeEmail



More information about the pLog-svn mailing list