[geeklog-cvs] geeklog: Nicer handling of comment unsubcriptions

geeklog-cvs at lists.geeklog.net geeklog-cvs at lists.geeklog.net
Mon Apr 13 06:47:45 EDT 2009


details:   http://project.geeklog.net/cgi-bin/hgweb.cgi/rev/60b129e9336d
changeset: 6935:60b129e9336d
user:      Dirk Haun <dirk at haun-online.de>
date:      Mon Apr 13 10:52:56 2009 +0200
description:
Nicer handling of comment unsubcriptions

diffstat:

4 files changed, 63 insertions(+), 22 deletions(-)
language/english.php       |    6 +++-
language/english_utf-8.php |    6 +++-
public_html/comment.php    |   19 +++++++++++++--
system/lib-comment.php     |   54 +++++++++++++++++++++++++++++++-------------

diffs (175 lines):

diff -r a815234a6238 -r 60b129e9336d language/english.php
--- a/language/english.php	Mon Apr 13 10:07:09 2009 +0200
+++ b/language/english.php	Mon Apr 13 10:52:56 2009 +0200
@@ -218,7 +218,9 @@
     38 => "A reply has been made to your comment '%s'.",
     39 => 'You may view the comment thread at the following address:',
     40 => 'If you wish to receive no further notifications of replies, visit the following link:',
-    41 => 'Hello %s,'
+    41 => 'Hello %s,',
+    42 => 'Unsubscribe',
+    43 => 'Unsubscribe from reply notifications'
 );
 
 ###############################################################################
@@ -1147,7 +1149,7 @@
     13 => 'Your topic has been successfully saved.',
     14 => 'The topic and all its stories and blocks have been successfully deleted.',
     15 => 'Your comment has been submitted for review and will be published when approved by a moderator.',
-    16 => 'You have been unsubscribed. You will no longer be notified of new replies',
+    16 => 'You have been unsubscribed. You will no longer be notified of new replies.',
     17 => '',
     18 => '',
     19 => '',
diff -r a815234a6238 -r 60b129e9336d language/english_utf-8.php
--- a/language/english_utf-8.php	Mon Apr 13 10:07:09 2009 +0200
+++ b/language/english_utf-8.php	Mon Apr 13 10:52:56 2009 +0200
@@ -218,7 +218,9 @@
     38 => "A reply has been made to your comment '%s'.",
     39 => 'You may view the comment thread at the following address:',
     40 => 'If you wish to receive no further notifications of replies, visit the following link:',
-    41 => 'Hello %s,'
+    41 => 'Hello %s,',
+    42 => 'Unsubscribe',
+    43 => 'Unsubscribe from reply notifications'
 );
 
 ###############################################################################
@@ -1147,7 +1149,7 @@
     13 => 'Your topic has been successfully saved.',
     14 => 'The topic and all its stories and blocks have been successfully deleted.',
     15 => 'Your comment has been submitted for review and will be published when approved by a moderator.',
-    16 => 'You have been unsubscribed. You will no longer be notified of new replies',
+    16 => 'You have been unsubscribed. You will no longer be notified of new replies.',
     17 => '',
     18 => '',
     19 => '',
diff -r a815234a6238 -r 60b129e9336d public_html/comment.php
--- a/public_html/comment.php	Mon Apr 13 10:07:09 2009 +0200
+++ b/public_html/comment.php	Mon Apr 13 10:52:56 2009 +0200
@@ -255,7 +255,10 @@
             break;
     }
 
-    return COM_siteHeader('menu', $title) . $display . COM_siteFooter();
+    return COM_siteHeader('menu', $title)
+           . COM_showMessageFromParameter()
+           . $display
+           . COM_siteFooter();
 }
 
 /**
@@ -406,12 +409,22 @@
     break;
 
 case 'unsubscribe':
+    $cid = 0;
     $key = COM_applyFilter($_GET['key']);
     if (! empty($key)) {
         $key = addslashes($key);
-        DB_delete($_TABLES['commentnotifications'], 'deletehash',
-                  $key, $_CONF['site_url'] . '/index.php?msg=16');
+        $cid = DB_getItem($_TABLES['commentnotifications'], 'cid',
+                          "deletehash = '$key'");
+        if (! empty($cid)) {
+            $redirecturl = $_CONF['site_url']
+                         . '/comment.php?mode=view&cid=' . $cid
+                         . '&format=nested&msg=16';
+            DB_delete($_TABLES['commentnotifications'], 'deletehash', $key,
+                      $redirecturl);
+            exit;
+        }
     }
+    $display = COM_refresh($_CONF['site_url'] . '/index.php');
     break;
 
 default:  // New Comment
diff -r a815234a6238 -r 60b129e9336d system/lib-comment.php
--- a/system/lib-comment.php	Mon Apr 13 10:07:09 2009 +0200
+++ b/system/lib-comment.php	Mon Apr 13 10:52:56 2009 +0200
@@ -415,27 +415,43 @@
         $template->set_var( 'type', $A['type'] );
 
         // COMMENT edit rights
+        $edit_option = false;
         if (isset($A['uid']) && isset($_USER['uid'])
                 && ($_USER['uid'] == $A['uid']) && ($_CONF['comment_edit'] == 1)
                 && ((time() - $A['nice_date']) < $_CONF['comment_edittime'])
                 && (DB_getItem($_TABLES['comments'], 'COUNT(*)',
                                "pid = {$A['cid']}") == 0)) {
             $edit_option = true;
-            if ( empty($token)) {
+            if (empty($token)) {
                 $token = SEC_createToken();
             }
-        } else if ( SEC_hasRights( 'comment.moderate' )) { 
+        } elseif (SEC_hasRights('comment.moderate')) { 
             $edit_option = true;
-        } else {
-            $edit_option = false;
         }
         
-        //edit link
+        // edit link
+        $edit = '';
         if ($edit_option) {
             $editlink = $_CONF['site_url'] . '/comment.php?mode=edit&cid='
                 . $A['cid'] . '&sid=' . $A['sid'] . '&type=' . $type
                 . '&' . CSRF_TOKEN . '=' . $token;
-            $edit = COM_createLink( $LANG01[4], $editlink) . ' | ';
+            $edit = COM_createLink($LANG01[4], $editlink) . ' | ';
+        }
+
+        // unsubscribe link
+        $unsubscribe = '';
+        if (($_CONF['allow_reply_notifications'] == 1) && !COM_isAnonUser()
+                && isset($A['uid']) && isset($_USER['uid'])
+                && ($_USER['uid'] == $A['uid'])) {
+            $hash = DB_getItem($_TABLES['commentnotifications'], 'deletehash',
+                               "cid = {$A['cid']} AND uid = {$_USER['uid']}");
+            if (! empty($hash)) {
+                $unsublink = $_CONF['site_url']
+                           . '/comment.php?mode=unsubscribe&key=' . $hash;
+                $unsubattr = array('title' => $LANG03[43]);
+                $unsubscribe = COM_createLink($LANG03[42], $unsublink,
+                                              $unsubattr) . ' | ';
+            }
         }
 
         // if deletion is allowed, displays delete link
@@ -464,18 +480,26 @@
                 }
             }
 
+            if (! empty($unsubscribe)) {
+                $deloption .= $unsubscribe;
+            }
+
             $template->set_var('delete_option', $deloption);
         } elseif ($edit_option) {
-            $template->set_var('delete_option', $edit);
-        } elseif (!empty( $_USER['username'])) {
-            $reportthis_link = $_CONF['site_url']
-                . '/comment.php?mode=report&cid=' . $A['cid']
-                . '&type=' . $type;
-            $report_attr = array('title' => $LANG01[110]);
-            $reportthis = COM_createLink($LANG01[109], $reportthis_link, $report_attr) . ' | ';
-            $template->set_var( 'delete_option', $reportthis );
+            $template->set_var('delete_option', $edit . $unsubscribe);
+        } elseif (! COM_isAnonUser()) {
+            $reportthis = '';
+            if ($A['uid'] != $_USER['uid']) {
+                $reportthis_link = $_CONF['site_url']
+                    . '/comment.php?mode=report&cid=' . $A['cid']
+                    . '&type=' . $type;
+                $report_attr = array('title' => $LANG01[110]);
+                $reportthis = COM_createLink($LANG01[109], $reportthis_link,
+                                             $report_attr) . ' | ';
+            }
+            $template->set_var('delete_option', $reportthis . $unsubscribe);
         } else {
-            $template->set_var( 'delete_option', '' );
+            $template->set_var('delete_option', '');
         }
         
         //and finally: format the actual text of the comment, but check only the text, not sig or edit



More information about the geeklog-cvs mailing list