From 465e809be9a7b9bbf06feb7f47814582eadb0cf4 Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Sun, 5 Aug 2012 20:59:58 +0200 Subject: renamed mailfromnon to mailfromnobody, use in subscriptions --- inc/subscription.php | 2 ++ 1 file changed, 2 insertions(+) (limited to 'inc/subscription.php') diff --git a/inc/subscription.php b/inc/subscription.php index d1ee0397a..b4e5d2edd 100644 --- a/inc/subscription.php +++ b/inc/subscription.php @@ -373,6 +373,7 @@ function subscription_send_list($subscriber_mail, $ids, $ns_id) { * @param string $id The page or namespace id * @param string $template The name of the mail template * + * @return bool * @author Adrian Lang */ function subscription_send($subscriber_mail, $replaces, $subject, $id, $template) { @@ -387,6 +388,7 @@ function subscription_send($subscriber_mail, $replaces, $subject, $id, $template $mail->bcc($subscriber_mail); $mail->subject($subject); $mail->setBody($text,$trep); + $mail->from($conf['mailfromnobody']); $mail->setHeader( 'List-Unsubscribe', '<'.wl($id,array('do'=>'subscribe'),true,'&').'>', -- cgit v1.2.3 From c0ec69288a7ae838ba9f3da6cc5069d6abe33e15 Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Sat, 11 Aug 2012 22:38:19 +0200 Subject: some minor cleanups in subscription.php --- inc/subscription.php | 60 ++++++++++++++++++++++++++++++++-------------------- 1 file changed, 37 insertions(+), 23 deletions(-) (limited to 'inc/subscription.php') diff --git a/inc/subscription.php b/inc/subscription.php index d1ee0397a..1f1aedfa4 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 + * * @param string $id The target page or namespace, specified by id; Namespaces * are identified by appending a colon. - * - * @author Adrian Lang + * @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 * @param string $id The target page or namespace, specified by id; Namespaces * are identified by appending a colon. - * - * @author Adrian Lang + * @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 * @param string $id The target page or namespace, specified by id; Namespaces * are identified by appending a colon. - * - * @author Adrian Lang + * @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 + * * @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 + * @return bool */ function subscription_set($user, $page, $style, $data = null, $overwrite = false) { @@ -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 * @see function subscription_regex for $pre documentation * - * @author Adrian Lang + * @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 + * * @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 + * @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 + * @author Adrian Lang + * + * @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 - * @author Adrian Lang + * @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 + * * @param string $subscriber_mail The target mail address * @param array $id The ID * @param int $lastupdate Time of the last notification - * - * @author Adrian Lang */ 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 + * * @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 */ 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 + * * @param string $subscriber_mail The target mail address * @param array $replaces Predefined parameters used to parse the * template @@ -372,11 +388,9 @@ 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 + * @return bool */ function subscription_send($subscriber_mail, $replaces, $subject, $id, $template) { - global $conf; global $lang; $text = rawLocale($template); -- cgit v1.2.3 From 0a78cb463952660f3bb257dd3dd030db725cd4f4 Mon Sep 17 00:00:00 2001 From: Michael Hamann Date: Fri, 7 Sep 2012 21:06:57 +0200 Subject: Fix the test if a subscription already exists FS#2580 This fixes the test for existing subscriptions by not only testing if the subscription for the deepest namespace level is for the current page but by simply testing all levels. Test case is included, it fails without this change. --- inc/subscription.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'inc/subscription.php') diff --git a/inc/subscription.php b/inc/subscription.php index 1bee1152e..029d93e66 100644 --- a/inc/subscription.php +++ b/inc/subscription.php @@ -132,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); -- cgit v1.2.3 From bd4e4c94416613145edca00156831fb283024684 Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Tue, 18 Sep 2012 20:28:03 +0200 Subject: add linebreaks and escaping in digest HTML mails FS#2606 this is a temporary and somewhat ugly fix. digest subscriptions should make use of the inline format just as the 'every' subscriptions do. But it makes sense to implement it correctly in the subscription branch instead and not introduce new code in the RC. --- inc/subscription.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'inc/subscription.php') diff --git a/inc/subscription.php b/inc/subscription.php index 029d93e66..6b201c266 100644 --- a/inc/subscription.php +++ b/inc/subscription.php @@ -396,12 +396,14 @@ function subscription_send($subscriber_mail, $replaces, $subject, $id, $template $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', -- cgit v1.2.3