Index: trunk/extensions/CategoryWatch/CategoryWatch.php |
— | — | @@ -15,7 +15,7 @@ |
16 | 16 | |
17 | 17 | if (!defined('MEDIAWIKI')) die('Not an entry point.'); |
18 | 18 | |
19 | | -define('CATEGORYWATCH_VERSION', '0.1.0, 2008-09-03'); |
| 19 | +define('CATEGORYWATCH_VERSION', '0.1.1, 2008-09-04'); |
20 | 20 | |
21 | 21 | $wgCategoryWatchNotifyEditor = false; |
22 | 22 | |
— | — | @@ -69,31 +69,34 @@ |
70 | 70 | $sub = array_diff($this->before, $this->after); |
71 | 71 | |
72 | 72 | # Notify watchers of each cat about the addition or removal of this article |
73 | | - $page = $article->getTitle()->getText(); |
74 | | - if (count($add) == 1 && count($sub) == 1) { |
75 | | - $add = array_shift($add); |
76 | | - $sub = array_shift($sub); |
| 73 | + if (count($add) > 0 || count($sub) > 0) { |
| 74 | + $enotif = new EmailNotification(); # ensure UserMailer class is autoloaded |
| 75 | + $page = $article->getTitle()->getText(); |
| 76 | + if (count($add) == 1 && count($sub) == 1) { |
| 77 | + $add = array_shift($add); |
| 78 | + $sub = array_shift($sub); |
77 | 79 | |
78 | | - $title = Title::newFromText($add, NS_CATEGORY); |
79 | | - $message = wfMsg('categorywatch-catmovein', $page, $add, $sub); |
80 | | - $this->notifyWatchers($title, $user, $message); |
| 80 | + $title = Title::newFromText($add, NS_CATEGORY); |
| 81 | + $message = wfMsg('categorywatch-catmovein', $page, $add, $sub); |
| 82 | + $this->notifyWatchers($title, $user, $message); |
81 | 83 | |
82 | | - $title = Title::newFromText($sub, NS_CATEGORY); |
83 | | - $message = wfMsg('categorywatch-catmoveout', $page, $sub, $add); |
84 | | - $this->notifyWatchers($title, $user, $message); |
85 | | - } |
86 | | - else { |
87 | | - |
88 | | - foreach ($add as $cat) { |
89 | | - $title = Title::newFromText($cat, NS_CATEGORY); |
90 | | - $message = wfMsg('categorywatch-catadd', $page, $cat); |
| 84 | + $title = Title::newFromText($sub, NS_CATEGORY); |
| 85 | + $message = wfMsg('categorywatch-catmoveout', $page, $sub, $add); |
91 | 86 | $this->notifyWatchers($title, $user, $message); |
92 | 87 | } |
| 88 | + else { |
93 | 89 | |
94 | | - foreach ($sub as $cat) { |
95 | | - $title = Title::newFromText($cat, NS_CATEGORY); |
96 | | - $message = wfMsg('categorywatch-catsub', $page, $cat); |
97 | | - $this->notifyWatchers($title, $user, $message); |
| 90 | + foreach ($add as $cat) { |
| 91 | + $title = Title::newFromText($cat, NS_CATEGORY); |
| 92 | + $message = wfMsg('categorywatch-catadd', $page, $cat); |
| 93 | + $this->notifyWatchers($title, $user, $message); |
| 94 | + } |
| 95 | + |
| 96 | + foreach ($sub as $cat) { |
| 97 | + $title = Title::newFromText($cat, NS_CATEGORY); |
| 98 | + $message = wfMsg('categorywatch-catsub', $page, $cat); |
| 99 | + $this->notifyWatchers($title, $user, $message); |
| 100 | + } |
98 | 101 | } |
99 | 102 | } |
100 | 103 | |