summaryrefslogtreecommitdiff
path: root/inc/subscription.php
diff options
context:
space:
mode:
authorAndreas Gohr <andi@splitbrain.org>2012-11-08 23:15:08 +0100
committerAndreas Gohr <andi@splitbrain.org>2012-11-08 23:15:08 +0100
commit04924b7a9d090c0814cfff3e6706263e4d5a46e8 (patch)
treed83fc6b5683fbc9c639bfd1832f96dca2f3c8646 /inc/subscription.php
parent1ea7a6bada66fc9b7a45f61b4892e4ea23196d89 (diff)
parenta731ed1d6736ca405b3559adfd9500affcc59412 (diff)
downloadrpg-04924b7a9d090c0814cfff3e6706263e4d5a46e8.tar.gz
rpg-04924b7a9d090c0814cfff3e6706263e4d5a46e8.tar.bz2
Merge branch 'master' into proxyconnect
* master: (169 commits) added PCRE UTF-8 checks to do=check FS#2636 avoid multiple paralell update checks fix regression bug in HTTPClient FS#2621 changed PAGEUTILS_ID_HIDEPAGE to has BEFORE/AFTER TarLib code cleanup TarLib: fixed appending in non-dynamic mode fixed third method of adding files in TarLib fix lone zero block in TarLib created archives fix use of constructor in TarLib Slovak language update Korean language update Latvian language update added event PAGEUTILS_ID_HIDEPAGE added test for isHiddenPage() removed redundant variables in tpl_include_page() (because of 3ff8773b) added cut off points for mobile devices as parameters to style.ini Corrected typo: ruke -> rule Persian language update Spanish language update russian language update ...
Diffstat (limited to 'inc/subscription.php')
-rw-r--r--inc/subscription.php68
1 files changed, 43 insertions, 25 deletions
diff --git a/inc/subscription.php b/inc/subscription.php
index d1ee0397a..6b201c266 100644
--- a/inc/subscription.php
+++ b/inc/subscription.php
@@ -20,10 +20,11 @@
* Get the name of the metafile tracking subscriptions to target page or
* namespace
*
+ * @author Adrian Lang <lang@cosmocode.de>
+ *
* @param string $id The target page or namespace, specified by id; Namespaces
* are identified by appending a colon.
- *
- * @author Adrian Lang <lang@cosmocode.de>
+ * @return string
*/
function subscription_filename($id) {
$meta_fname = '.mlist';
@@ -39,16 +40,23 @@ function subscription_filename($id) {
/**
* Lock subscription info for an ID
*
+ * @author Adrian Lang <lang@cosmocode.de>
* @param string $id The target page or namespace, specified by id; Namespaces
* are identified by appending a colon.
- *
- * @author Adrian Lang <lang@cosmocode.de>
+ * @return string
*/
function subscription_lock_filename ($id){
global $conf;
return $conf['lockdir'].'/_subscr_' . md5($id) . '.lock';
}
+/**
+ * Creates a lock file for writing subscription data
+ *
+ * @todo add lock time parameter to io_lock() and use this instead
+ * @param $id
+ * @return bool
+ */
function subscription_lock($id) {
global $conf;
$lock = subscription_lock_filename($id);
@@ -70,10 +78,10 @@ function subscription_lock($id) {
/**
* Unlock subscription info for an ID
*
+ * @author Adrian Lang <lang@cosmocode.de>
* @param string $id The target page or namespace, specified by id; Namespaces
* are identified by appending a colon.
- *
- * @author Adrian Lang <lang@cosmocode.de>
+ * @return bool
*/
function subscription_unlock($id) {
$lockf = subscription_lock_filename($id);
@@ -92,6 +100,8 @@ function subscription_unlock($id) {
* returned if a subscription should be deleted but the user is not subscribed
* and the subscription meta file exists.
*
+ * @author Adrian Lang <lang@cosmocode.de>
+ *
* @param string $user The subscriber or unsubscriber
* @param string $page The target object (page or namespace), specified by
* id; Namespaces are identified by a trailing colon.
@@ -99,8 +109,7 @@ function subscription_unlock($id) {
* “every”, “digest”, and “list”.
* @param string $data An optional data blob
* @param bool $overwrite Whether an existing subscription may be overwritten
- *
- * @author Adrian Lang <lang@cosmocode.de>
+ * @return bool
*/
function subscription_set($user, $page, $style, $data = null,
$overwrite = false) {
@@ -123,7 +132,7 @@ function subscription_set($user, $page, $style, $data = null,
// Delete subscription if one exists and $overwrite is true. If $overwrite
// is false, fail.
$subs = subscription_find($page, array('user' => $user));
- if (count($subs) > 0 && array_pop(array_keys($subs)) === $page) {
+ if (count($subs) > 0 && isset($subs[$page])) {
if (!$overwrite) {
msg(sprintf($lang['subscr_already_subscribed'], $user,
prettyprint_id($page)), -1);
@@ -149,12 +158,12 @@ function subscription_set($user, $page, $style, $data = null,
* This function searches all relevant subscription files for a page or
* namespace.
*
- * @param string $page The target object’s (namespace or page) id
- * @param array $pre A hash of predefined values
- *
+ * @author Adrian Lang <lang@cosmocode.de>
* @see function subscription_regex for $pre documentation
*
- * @author Adrian Lang <lang@cosmocode.de>
+ * @param string $page The target object’s (namespace or page) id
+ * @param array $pre A hash of predefined values
+ * @return array
*/
function subscription_find($page, $pre) {
// Construct list of files which may contain relevant subscriptions.
@@ -231,13 +240,15 @@ function get_info_subscribed() {
/**
* Construct a regular expression parsing a subscription definition line
*
+ * @author Adrian Lang <lang@cosmocode.de>
+ *
* @param array $pre A hash of predefined values; “user”, “style”, and
* “data” may be set to limit the results to
* subscriptions matching these parameters. If
* “escaped” is true, these fields are inserted into the
* regular expression without escaping.
*
- * @author Adrian Lang <lang@cosmocode.de>
+ * @return string complete regexp including delimiters
*/
function subscription_regex($pre = array()) {
if (!isset($pre['escaped']) || $pre['escaped'] === false) {
@@ -258,15 +269,18 @@ function subscription_regex($pre = array()) {
*
* This is the default action for COMMON_NOTIFY_ADDRESSLIST.
*
+ * @author Steven Danz <steven-danz@kc.rr.com>
+ * @author Adrian Lang <lang@cosmocode.de>
+ *
+ * @todo this does NOT return a string but uses a reference to write back, either fix function or docs
* @param array $data Containing $id (the page id), $self (whether the author
* should be notified, $addresslist (current email address
* list)
- *
- * @author Steven Danz <steven-danz@kc.rr.com>
- * @author Adrian Lang <lang@cosmocode.de>
+ * @return string
*/
function subscription_addresslist(&$data){
global $conf;
+ /** @var auth_basic $auth */
global $auth;
$id = $data['id'];
@@ -303,11 +317,11 @@ function subscription_addresslist(&$data){
*
* Sends a digest mail showing a bunch of changes.
*
+ * @author Adrian Lang <lang@cosmocode.de>
+ *
* @param string $subscriber_mail The target mail address
* @param array $id The ID
* @param int $lastupdate Time of the last notification
- *
- * @author Adrian Lang <lang@cosmocode.de>
*/
function subscription_send_digest($subscriber_mail, $id, $lastupdate) {
$n = 0;
@@ -339,11 +353,11 @@ function subscription_send_digest($subscriber_mail, $id, $lastupdate) {
*
* Sends a list mail showing a list of changed pages.
*
+ * @author Adrian Lang <lang@cosmocode.de>
+ *
* @param string $subscriber_mail The target mail address
* @param array $ids Array of ids
* @param string $ns_id The id of the namespace
- *
- * @author Adrian Lang <lang@cosmocode.de>
*/
function subscription_send_list($subscriber_mail, $ids, $ns_id) {
if (count($ids) === 0) return;
@@ -365,6 +379,8 @@ function subscription_send_list($subscriber_mail, $ids, $ns_id) {
/**
* Helper function for sending a mail
*
+ * @author Adrian Lang <lang@cosmocode.de>
+ *
* @param string $subscriber_mail The target mail address
* @param array $replaces Predefined parameters used to parse the
* template
@@ -372,21 +388,23 @@ function subscription_send_list($subscriber_mail, $ids, $ns_id) {
* prefix “mail_”)
* @param string $id The page or namespace id
* @param string $template The name of the mail template
- *
- * @author Adrian Lang <lang@cosmocode.de>
+ * @return bool
*/
function subscription_send($subscriber_mail, $replaces, $subject, $id, $template) {
- global $conf;
global $lang;
+ global $conf;
$text = rawLocale($template);
$trep = array_merge($replaces, array('PAGE' => $id));
+ $hrep = $trep;
+ $hrep['DIFF'] = nl2br(htmlspecialchars($hrep['DIFF']));
$subject = $lang['mail_' . $subject] . ' ' . $id;
$mail = new Mailer();
$mail->bcc($subscriber_mail);
$mail->subject($subject);
- $mail->setBody($text,$trep);
+ $mail->setBody($text,$trep,$hrep);
+ $mail->from($conf['mailfromnobody']);
$mail->setHeader(
'List-Unsubscribe',
'<'.wl($id,array('do'=>'subscribe'),true,'&').'>',