[Customisation Database Commits] [customisation-db] Allow author to subscribe to queue discussion when submitting revision. Ticket #62310.
Cesar G
prototech91 at gmail.com
Sun Apr 15 12:58:02 BST 2012
commit 2aebb42459cc94bab4729acae8317d00fed9acd9
Author: Cesar G <prototech91 at gmail.com>
Date: Mon Apr 2 15:06:03 2012 -0700
Allow author to subscribe to queue discussion when submitting revision. Ticket #62310.
diff --git a/titania/contributions/revision.php b/titania/contributions/revision.php
index 08f4a63..df64552 100644
--- a/titania/contributions/revision.php
+++ b/titania/contributions/revision.php
@@ -234,6 +234,14 @@ if ($step == 1)
$queue->queue_allow_repack = $queue_allow_repack;
$queue->submit();
+
+ $subscribe_author = request_var('subscribe_author', false);
+
+ // Subscribe author to queue discussion topic
+ if ($subscribe_author)
+ {
+ titania_subscriptions::subscribe(TITANIA_TOPIC, $queue->queue_discussion_topic_id);
+ }
}
if (!titania_types::$types[titania::$contrib->contrib_type]->clean_and_restore_root)
@@ -490,18 +498,37 @@ if ($step == 0 || sizeof($error))
}
}
+ $allow_subscription = $author_subscribed = false;
+
+ if (titania::$config->use_queue && titania_types::$types[titania::$contrib->contrib_type]->use_queue)
+ {
+ $allow_subscription = true;
+ $queue->contrib_id = titania::$contrib->contrib_id;
+
+ // Get queue discussion topic id if it exists
+ $queue->get_queue_discussion_topic(true);
+ }
+
+ if (isset($queue->queue_discussion_topic_id))
+ {
+ // Is the author subscribed already?
+ $author_subscribed = titania_subscriptions::is_subscribed(TITANIA_TOPIC, $queue->queue_discussion_topic_id);
+ }
+
$revision_attachment = new titania_attachment(TITANIA_CONTRIB, titania::$contrib->contrib_id);
phpbb::$template->assign_vars(array(
'REVISION_NAME' => utf8_normalize_nfc(request_var('revision_name', '', true)),
'REVISION_VERSION' => utf8_normalize_nfc(request_var('revision_version', '', true)),
'REVISION_LICENSE' => utf8_normalize_nfc(request_var('revision_license', '', true)),
'REVISION_CUSTOM_LICENSE' => utf8_normalize_nfc(request_var('revision_custom_license', '', true)),
- 'QUEUE_ALLOW_REPACK' => request_var('queue_allow_repack', 1),
+ 'QUEUE_ALLOW_REPACK' => request_var('queue_allow_repack', false),
'NEXT_STEP' => 1,
+ 'S_CAN_SUBSCRIBE' => ($author_subscribed || !$allow_subscription) ? false : true,
'S_CUSTOM_LICENSE' => (utf8_normalize_nfc(request_var('revision_license', '', true)) == phpbb::$user->lang['CUSTOM_LICENSE']) ? true : false,
'S_ALLOW_CUSTOM_LICENSE' => (titania_types::$types[titania::$contrib->contrib_type]->license_allow_custom) ? true : false,
+ 'SUBSCRIBE_AUTHOR' => request_var('subscribe_author', false),
));
// Assign separately so we can output some data first
diff --git a/titania/includes/objects/queue.php b/titania/includes/objects/queue.php
index e656ff3..5096f2d 100644
--- a/titania/includes/objects/queue.php
+++ b/titania/includes/objects/queue.php
@@ -558,9 +558,11 @@ class titania_queue extends titania_message_object
/**
* Get the queue discussion topic or create one if needed
*
+ * @param bool $check_only Return false if topic does not exist instead of creating it
+ *
* @return titania_topic object
*/
- public function get_queue_discussion_topic()
+ public function get_queue_discussion_topic($check_only = false)
{
$sql = 'SELECT * FROM ' . TITANIA_TOPICS_TABLE . '
WHERE parent_id = ' . $this->contrib_id . '
@@ -573,9 +575,14 @@ class titania_queue extends titania_message_object
{
$topic = new titania_topic;
$topic->__set_array($row);
+ $this->queue_discussion_topic_id = $topic->topic_id;
return $topic;
}
+ else if ($check_only)
+ {
+ return false;
+ }
// No queue discussion topic...so we must create one
titania::add_lang('posting');
@@ -596,6 +603,7 @@ class titania_queue extends titania_message_object
));
$post->generate_text_for_storage(true, true, true);
$post->submit();
+ $this->queue_discussion_topic_id = $post->topic->topic_id;
return $post->topic;
}
diff --git a/titania/language/en/contributions.php b/titania/language/en/contributions.php
index a2e3c2f..7d0f8b5 100644
--- a/titania/language/en/contributions.php
+++ b/titania/language/en/contributions.php
@@ -185,6 +185,7 @@ $lang = array_merge($lang, array(
'SELECT_PHPBB_BRANCH' => 'Select phpBB branch',
'SUBDIRECTORY_LIMIT' => 'Packages are not allowed to be more than 50 subdirectories deep at any point.',
'SUBMIT_NEW_REVISION' => 'Submit and add new revision',
+ 'SUBSCRIBE_QUEUE_DISCUSSION' => 'Subscribe to queue discussion topic',
'SUBSCRIPTION_REQUEST' => 'Would you like to subscribe to the contribution in order to receive e-mail notifications about new versions and security vulnerabilities?',
'TOO_MANY_TRANSLATOR_LINKS' => 'You are currently using %d external links within the TRANSLATION/TRANSLATION_INFO line. Please only include <strong>one link</strong>. Including two links is allowed on a case-by-case basis - please post within the translations forum noting your reasoning behind putting more external links within the line.',
diff --git a/titania/styles/default/template/contributions/contribution_revision.html b/titania/styles/default/template/contributions/contribution_revision.html
index 2cf989b..b6a18cd 100644
--- a/titania/styles/default/template/contributions/contribution_revision.html
+++ b/titania/styles/default/template/contributions/contribution_revision.html
@@ -83,8 +83,14 @@
<fieldset class="fields2">
<dl>
<dt><label for="queue_allow_repack">{L_QUEUE_ALLOW_REPACK}:</label><br /><span>{L_QUEUE_ALLOW_REPACK_EXPLAIN}</span></dt>
- <dd><input type="checkbox" id="queue_allow_repack" name="queue_allow_repack" value="1"<!-- IF QUEUE_ALLOW_REPACK --> checked="checked"<!-- ENDIF --> /></dd>
+ <dd><input type="checkbox" id="queue_allow_repack" name="queue_allow_repack" value="1"<!-- IF ((ERROR_MSG and QUEUE_ALLOW_REPACK) or not ERROR_MSG) --> checked="checked"<!-- ENDIF --> /></dd>
</dl>
+ <!-- IF S_CAN_SUBSCRIBE -->
+ <dl>
+ <dt><label for="subscribe_author">{L_SUBSCRIBE_QUEUE_DISCUSSION}</label></dd>
+ <dd><input type="checkbox" id="subscribe_author" name="subscribe_author"<!-- IF ((ERROR_MSG and SUBSCRIBE_AUTHOR) or not ERROR_MSG) --> checked="checked"<!-- ENDIF --> /></dd>
+ </dl>
+ <!-- ENDIF -->
<dl>
<dt><br /><label for="message">{L_QUEUE_NOTES}:</label><br /><span>{L_QUEUE_NOTES_EXPLAIN}</span></dt>
</dl>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://code.phpbb.com/pipermail/customisationdb-commits/attachments/20120415/ad625d01/attachment-0001.html>
More information about the customisationdb-commits
mailing list