]> git.pld-linux.org Git - packages/dokuwiki.git/blob - dokuwiki-notifyns.patch
Up to 20230404a
[packages/dokuwiki.git] / dokuwiki-notifyns.patch
1 --- dokuwiki-2013-05-10/inc/common.php~ 2013-05-28 22:43:32.565530521 +0300
2 +++ dokuwiki-2013-05-10/inc/common.php  2013-05-28 22:47:27.455072897 +0300
3 @@ -902,6 +902,34 @@
4    return $date;
5  }
6  
7 +
8 +/**
9 + * Returns notify address for page $id
10 + *
11 + * @param  string  $id       The changed page
12 + * @param  mixed   $notify   The address (string) or rules where to notify
13 + *
14 + * @author Elan Ruusamäe <glen@delfi.ee>
15 + */
16 +function notifyNS($id, $notify) {
17 +  if (empty($notify)) {
18 +    return '';
19 +  }
20 +
21 +  if (is_string($notify)) {
22 +    return $notify;
23 +  }
24 +
25 +  // process $notify for pages
26 +  foreach ($notify as $rule => $address) {
27 +    if (preg_match('/'.$rule.'/ui',':'.$id)) {
28 +      return $address;
29 +    }
30 +  }
31 +
32 +  return '';
33 +}
34 +
35  /**
36   * Sends a notify mail on page change
37   *
38 @@ -1162,10 +1162,10 @@
39  
40      // decide if there is something to do, eg. whom to mail
41      if($who == 'admin') {
42 -        if(empty($conf['notify'])) return false; //notify enabled?
43          if($conf['useacl'] && $_SERVER['REMOTE_USER'] && $minor) return; //skip minors
44          $tpl = 'mailtext';
45 -        $to  = $conf['notify'];
46 +        $to  = notifyNS($id, $conf['notify']);
47 +        if(empty($to)) return; //notify enabled?
48      } elseif($who == 'subscribers') {
49          if(!actionOK('subscribe')) return false; //subscribers enabled?
50          if($conf['useacl'] && $_SERVER['REMOTE_USER'] && $minor) return false; //skip minors
51 --- dokuwiki-2014-05-06/inc/media.php~  2014-05-06 15:09:52.000000000 +0300
52 +++ dokuwiki-2014-05-06/inc/media.php   2014-05-08 11:24:16.977561680 +0300
53 @@ -573,10 +573,11 @@
54   */
55  function media_notify($id,$file,$mime,$old_rev=false){
56      global $conf;
57 -    if(empty($conf['notify'])) return false; //notify enabled?
58 +    $to = notifyNS($id, $conf['notify']);
59 +    if(empty($to)) return false; //notify enabled?
60  
61      $subscription = new Subscription();
62 -    return $subscription->send_media_diff($conf['notify'], 'uploadmail', $id, $old_rev);
63 +    return $subscription->send_media_diff($to, 'uploadmail', $id, $old_rev);
64  }
65  
66  /**
67 --- dokuwiki-2013-05-10/inc/subscription.php~   2013-05-10 15:45:54.000000000 +0300
68 +++ dokuwiki-2013-05-10/inc/subscription.php    2013-05-28 22:50:30.872112776 +0300
69 @@ -484,7 +484,8 @@
70       */
71      public function send_register($login, $fullname, $email) {
72          global $conf;
73 -        if(empty($conf['registernotify'])) return false;
74 +        $to = notifyNS($id, $conf['registernotify']);
75 +        if(empty($to)) return false;
76  
77          $trep = array(
78              'NEWUSER' => $login,
79 @@ -493,7 +494,7 @@
80          );
81  
82          return $this->send(
83 -            $conf['registernotify'],
84 +            $to,
85              'new_user',
86              $login,
87              'registermail',
88 @@ -672,7 +672,8 @@
89  
90                  $level = auth_aclcheck($id, $user, $userinfo['grps']);
91                  if($level >= AUTH_READ) {
92 -                    if(strcasecmp($userinfo['mail'], $conf['notify']) != 0) { //skip user who get notified elsewhere
93 +                    $to = notifyNS($id, $conf['notify']);
94 +                    if(strcasecmp($userinfo['mail'], $to) != 0) { //skip user who get notified elsewhere
95                          $result[$user] = $userinfo['mail'];
96                      }
97                  }
This page took 0.099489 seconds and 3 git commands to generate.