Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

[#4063] Add unsubscribe option for logged-in users who have subscribe…

…d to a thread
  • Loading branch information...
commit 051cbe90b47292a0e0ca547b07ac3dac330e4af8 1 parent 866c881
Shaun McCormick authored
View
2  _build/build.transport.php
@@ -36,7 +36,7 @@
/* define package */
define('PKG_NAME','Quip');
define('PKG_NAME_LOWER','quip');
-define('PKG_VERSION','2.0.0');
+define('PKG_VERSION','2.0.1');
define('PKG_RELEASE','pl');
/* define sources */
View
4 core/components/quip/docs/changelog.txt
@@ -1,5 +1,9 @@
Changelog for Quip.
+Quip 2.0.1
+======================================
+- [#4063] Add unsubscribe option for logged-in users who have subscribed to a thread
+
Quip 2.0.0
======================================
- Add extraAutoLinksAttributes property for specifying attributes to add to auto-converted links
View
4 core/components/quip/elements/chunks/quipaddcomment.chunk.tpl
@@ -28,8 +28,10 @@
</div>
<div class="quip-fld">
+ [[+unsubscribe:default=`
<label for="quip-comment-notify-[[+idprefix]]">[[%quip.notify_me]]:<span class="quip-error">[[+error.notify]]</span></label>
- <input type="checkbox" value="1" name="notify" id="quip-comment-notify-[[+idprefix]]" [[+notify:if=`[[+notify]]`:eq=`1`:then=`checked="checked"`]] />
+ <input type="checkbox" value="1" name="notify" id="quip-comment-notify-[[+idprefix]]" [[+notifyChecked]] />
+ `]]
<br />
</div>
View
1  core/components/quip/elements/chunks/quipunsubscribe.chunk.tpl
@@ -0,0 +1 @@
+<a href="[[+unsubscribeUrl]]">[[%quip.unsubscribe_me]]</a>
View
33 core/components/quip/elements/snippets/snippet.quipreply.php
@@ -67,6 +67,7 @@
$allowedTags = $modx->getOption('quip.allowed_tags',$scriptProperties,'<br><b><i>');
$preHooks = $modx->getOption('preHooks',$scriptProperties,'');
$postHooks = $modx->getOption('postHooks',$scriptProperties,'');
+$unsubscribeAction = $modx->getOption('unsubscribeAction',$scriptProperties,'quip_unsubscribe');
/* get parent and auth */
$parent = $modx->getOption('quip_parent',$_REQUEST,$modx->getOption('parent',$scriptProperties,0));
@@ -134,10 +135,25 @@
$placeholders = array_merge($placeholders,$fields);
}
}
+/* display moderated success message */
if (isset($_GET['quip_approved']) && $_GET['quip_approved'] == 0) {
$placeholders['successMsg'] = $modx->lexicon('quip.comment_will_be_moderated');
}
+/* handle unsubscribing from thread */
+if (!empty($_GET[$unsubscribeAction]) && $modx->user->hasSessionContext($modx->context->get('key'))) {
+ $profile = $modx->user->getOne('Profile');
+ if ($profile) {
+ $notify = $modx->getObject('quipCommentNotify',array(
+ 'email' => $profile->get('email'),
+ 'thread' => $thread,
+ ));
+ if ($notify && $notify->remove()) {
+ $placeholders['successMsg'] = $modx->lexicon('quip.unsubscribed');
+ }
+ }
+}
+
/* if using recaptcha, load recaptcha html if user is not logged in */
$disableRecaptchaWhenLoggedIn = (boolean)$modx->getOption('disableRecaptchaWhenLoggedIn',$scriptProperties,true);
$useRecaptcha = (boolean)$modx->getOption('recaptcha',$scriptProperties,false);
@@ -160,6 +176,7 @@
$phs = array_merge($placeholders,array(
'username' => $modx->user->get('username'),
));
+ $phs['unsubscribe'] = '';
/* prefill fields */
$profile = $modx->user->getOne('Profile');
@@ -167,6 +184,21 @@
$phs['name'] = !empty($fields['name']) ? $fields['name'] : $profile->get('fullname');
$phs['email'] = !empty($fields['email']) ? $fields['email'] : $profile->get('email');
$phs['website'] = !empty($fields['website']) ? $fields['website'] : $profile->get('website');
+
+ /* allow for unsubscribing for logged-in users */
+ if ($modx->user->hasSessionContext($modx->context->get('key'))) {
+ $notify = $modx->getObject('quipCommentNotify',array(
+ 'email' => $profile->get('email'),
+ 'thread' => $thread,
+ ));
+ if ($notify) {
+ $phs['notifyId'] = $notify->get('id');
+ $phs['unsubscribe'] = $quip->getChunk('quipUnsubscribe',$phs);
+ $params = $modx->request->getParameters();
+ $params[$unsubscribeAction] = 1;
+ $phs['unsubscribeUrl'] = $modx->makeUrl($modx->resource->get('id'),'',$params);
+ }
+ }
}
/* if requirePreview == false, auto-can post */
@@ -176,6 +208,7 @@
$phs['post_action'] = $postAction;
$phs['preview_action'] = $previewAction;
$phs['allowed_tags'] = $allowedTags;
+ $phs['notifyChecked'] = !empty($fields['notify']) ? ' checked="checked"' : '';
$replyForm = $quip->getChunk($addCommentTpl,$phs);
} else if (!$stillOpen) {
View
2  core/components/quip/lexicon/en/default.inc.php
@@ -140,6 +140,8 @@
$_lang['quip.unapproved'] = 'Unapproved';
$_lang['quip.unapproved_comments'] = 'Unapproved Comments';
$_lang['quip.unapproved_comments_msg'] = 'Moderate any unapproved comments here.';
+$_lang['quip.unsubscribe_me'] = 'Unsubscribe Me from this Thread';
+$_lang['quip.unsubscribed'] = 'You have been unsubscribed from this Thread. Thanks!';
$_lang['quip.username_said'] = '<strong>[[+username]]</strong> said:';
$_lang['quip.view'] = 'View';
$_lang['quip.website'] = 'Website';
Please sign in to comment.
Something went wrong with that request. Please try again.