Index: trunk/extensions/EmailArticle/EmailArticle.php |
— | — | @@ -13,7 +13,7 @@ |
14 | 14 | |
15 | 15 | if (!defined('MEDIAWIKI')) die('Not an entry point.'); |
16 | 16 | |
17 | | -define('EMAILARTICLE_VERSION','1.0.10, 2008-05-30'); |
| 17 | +define('EMAILARTICLE_VERSION', '1.1.0, 2008-06-04'); |
18 | 18 | |
19 | 19 | $wgEmailArticleGroup = 'sysop'; # Users must belong to this group to send emails (empty string means anyone can send) |
20 | 20 | $wgEmailArticleContactsCat = ''; # This specifies the name of a category containing categories of contact articles |
Index: trunk/extensions/EmailArticle/EmailArticle_body.php |
— | — | @@ -15,14 +15,16 @@ |
16 | 16 | |
17 | 17 | public function __construct() { |
18 | 18 | global $wgEmailArticleGroup; |
19 | | - SpecialPage::SpecialPage('EmailArticle',$wgEmailArticleGroup); |
| 19 | + SpecialPage::SpecialPage('EmailArticle', $wgEmailArticleGroup); |
20 | 20 | } |
21 | 21 | |
22 | | - # Override SpecialPage::execute($param = '') |
| 22 | + /** |
| 23 | + * Override SpecialPage::execute($param = '') |
| 24 | + */ |
23 | 25 | function execute($param) { |
24 | | - global $wgOut,$wgUser,$wgEmailArticleContactsCat,$wgGroupPermissions,$wgSitename,$wgEmailArticleCss,$wgEmailArticleAllowAllUsers; |
| 26 | + global $wgOut, $wgUser, $wgEmailArticleContactsCat, $wgGroupPermissions, $wgSitename, $wgEmailArticleCss, $wgEmailArticleAllowAllUsers; |
25 | 27 | $db =& wfGetDB(DB_SLAVE); |
26 | | - $param = str_replace('_',' ',$param); |
| 28 | + $param = str_replace('_', ' ', $param); |
27 | 29 | |
28 | 30 | wfLoadExtensionMessages( 'EmailArticle' ); |
29 | 31 | |
— | — | @@ -39,14 +41,14 @@ |
40 | 42 | $this->css = isset($_REQUEST['ea-css']) ? $_REQUEST['ea-css'] : $wgEmailArticleCss; |
41 | 43 | |
42 | 44 | # Bail if no article title to send has been specified |
43 | | - if ($this->title) $wgOut->addWikiText(wfMsg('ea-heading',$this->title)); |
| 45 | + if ($this->title) $wgOut->addWikiText(wfMsg('ea-heading', $this->title)); |
44 | 46 | else return $wgOut->addWikiText(wfMsg('ea-noarticle')); |
45 | 47 | |
46 | 48 | # If the send button was clicked, attempt to send and exit |
47 | 49 | if (isset($_REQUEST['ea-send'])) return $this->send(); |
48 | 50 | |
49 | 51 | # Render form |
50 | | - $special = Title::makeTitle(NS_SPECIAL,'EmailArticle'); |
| 52 | + $special = Title::makeTitle(NS_SPECIAL, 'EmailArticle'); |
51 | 53 | $wgOut->addHTML(wfElement('form',array( |
52 | 54 | 'class' => 'EmailArticle', |
53 | 55 | 'action' => $special->getLocalURL('action=submit'), |
— | — | @@ -124,9 +126,9 @@ |
125 | 127 | $wgOut->addHTML("</fieldset>"); |
126 | 128 | |
127 | 129 | # Submit buttons & hidden values |
128 | | - $wgOut->addHTML(wfElement('input',array('type' => 'submit','name' => 'ea-send', 'value' => wfMsg('ea-send')))); |
129 | | - $wgOut->addHTML(wfElement('input',array('type' => 'submit','name' => 'ea-show', 'value' => wfMsg('ea-show')))); |
130 | | - $wgOut->addHTML(wfElement('input',array('type' => 'hidden','name' => 'ea-title','value' => $this->title))); |
| 130 | + $wgOut->addHTML(wfElement('input', array('type' => 'submit', 'name' => 'ea-send', 'value' => wfMsg('ea-send')))); |
| 131 | + $wgOut->addHTML(wfElement('input', array('type' => 'submit', 'name' => 'ea-show', 'value' => wfMsg('ea-show')))); |
| 132 | + $wgOut->addHTML(wfElement('input', array('type' => 'hidden', 'name' => 'ea-title', 'value' => $this->title))); |
131 | 133 | |
132 | 134 | $wgOut->addHTML('</form>'); |
133 | 135 | |
— | — | @@ -136,13 +138,13 @@ |
137 | 139 | |
138 | 140 | # Send the message to the recipients (or just list them if arg = false) |
139 | 141 | function send($send = true) { |
140 | | - global $wgOut,$wgUser,$wgParser,$wgServer,$wgScript,$wgArticlePath,$wgScriptPath, |
141 | | - $wgEmailArticleCss,$wgEmailArticleGroup,$wgEmailArticleAllowRemoteAddr,$wgEmailArticleAllowAllUsers; |
| 142 | + global $wgOut, $wgUser, $wgParser, $wgServer, $wgScript, $wgArticlePath, $wgScriptPath, |
| 143 | + $wgEmailArticleCss, $wgEmailArticleGroup, $wgEmailArticleAllowRemoteAddr, $wgEmailArticleAllowAllUsers; |
142 | 144 | |
143 | 145 | # Set error and bail if user not in postmaster group, and request not from trusted address |
144 | | - if ($wgEmailArticleGroup && !in_array($wgEmailArticleGroup,$wgUser->getGroups()) && !in_array($_SERVER['REMOTE_ADDR'],$wgEmailArticleAllowRemoteAddr)) { |
| 146 | + if ($wgEmailArticleGroup && !in_array($wgEmailArticleGroup, $wgUser->getGroups()) && !in_array($_SERVER['REMOTE_ADDR'], $wgEmailArticleAllowRemoteAddr)) { |
145 | 147 | $denied = wfMsg('ea-denied'); |
146 | | - $wgOut->addWikiText(wfMsg('ea-error',$this->title, $denied )); |
| 148 | + $wgOut->addWikiText(wfMsg('ea-error', $this->title, $denied )); |
147 | 149 | return false; |
148 | 150 | } |
149 | 151 | |
— | — | @@ -168,14 +170,14 @@ |
169 | 171 | $group = $db->addQuotes($this->group); |
170 | 172 | $result = $this->group == 'user' |
171 | 173 | ? $db->select('user', 'user_email', 'user_email != \'\'', __METHOD__) |
172 | | - : $db->select(array('user', 'user_groups'), 'user_email', 'ug_user = user_id AND ug_group = $group', __METHOD__); |
| 174 | + : $db->select(array('user', 'user_groups'), 'user_email', "ug_user = user_id AND ug_group = $group", __METHOD__); |
173 | 175 | if ($result instanceof ResultWrapper) $result = $result->result; |
174 | 176 | if ($result) while ($row = $db->fetchRow($result)) $this->addRecipient($row[0]); |
175 | 177 | } |
176 | 178 | |
177 | 179 | # Recipients from list (expand templates in wikitext) |
178 | | - $list = $wgParser->preprocess($this->list,$title,$opt); |
179 | | - foreach (preg_split("/[\\x00-\\x1f,;*]+/",$list) as $item) $this->addRecipient($item); |
| 180 | + $list = $wgParser->preprocess($this->list, $title, $opt); |
| 181 | + foreach (preg_split("/[\\x00-\\x1f,;*]+/", $list) as $item) $this->addRecipient($item); |
180 | 182 | |
181 | 183 | # Compose the wikitext content of the article to send |
182 | 184 | $article = new Article($title); |
— | — | @@ -186,11 +188,11 @@ |
187 | 189 | if ($this->textonly == '') { |
188 | 190 | |
189 | 191 | # Parse the wikitext using absolute URL's for local article links |
190 | | - $tmp = array($wgArticlePath,$wgScriptPath,$wgScript); |
| 192 | + $tmp = array($wgArticlePath, $wgScriptPath, $wgScript); |
191 | 193 | $wgArticlePath = $wgServer.$wgArticlePath; |
192 | 194 | $wgScriptPath = $wgServer.$wgScriptPath; |
193 | 195 | $wgScript = $wgServer.$wgScript; |
194 | | - $message = $wgParser->parse($message,$title,$opt,true,true)->getText(); |
| 196 | + $message = $wgParser->parse($message, $title, $opt, true, true)->getText(); |
195 | 197 | list($wgArticlePath,$wgScriptPath,$wgScript) = $tmp; |
196 | 198 | |
197 | 199 | # Get CSS content if any |
— | — | @@ -218,29 +220,31 @@ |
219 | 221 | $mail->Body = $message; |
220 | 222 | $mail->IsHTML(!$this->textonly); |
221 | 223 | } |
222 | | - else $msg = wfMsg('ea-listrecipients',$count); |
| 224 | + else $msg = wfMsg('ea-listrecipients', $count); |
223 | 225 | |
224 | 226 | # Loop through recipients sending or adding to list |
225 | 227 | foreach ($this->recipients as $recipient) $send ? $mail->AddAddress($recipient) : $msg .= "\n*[mailto:$recipient $recipient]"; |
226 | 228 | |
227 | 229 | if ($send) { |
228 | | - if ($state = $mail->Send()) $msg = wfMsg('ea-sent',$this->title,$count,$wgUser->getName()); |
229 | | - else $msg = wfMsg('ea-error',$this->title,$mail->ErrorInfo); |
| 230 | + if ($state = $mail->Send()) $msg = wfMsg('ea-sent', $this->title, $count, $wgUser->getName()); |
| 231 | + else $msg = wfMsg('ea-error', $this->title, $mail->ErrorInfo); |
230 | 232 | } |
231 | 233 | else $state = $count; |
232 | 234 | } |
233 | | - else $msg = wfMsg('ea-error',$this->title,wfMsg('ea-norecipients')); |
| 235 | + else $msg = wfMsg('ea-error', $this->title, wfMsg('ea-norecipients')); |
234 | 236 | |
235 | 237 | $wgOut->addWikiText($msg); |
236 | 238 | return $state; |
237 | 239 | } |
238 | 240 | |
239 | | - # Add a recipient the list |
240 | | - # - accepts title objects for article containing email address, or string of actual address |
| 241 | + /** |
| 242 | + * Add a recipient the list |
| 243 | + * - accepts title objects for article containing email address, or string of actual address |
| 244 | + */ |
241 | 245 | function addRecipient($recipient) { |
242 | 246 | if (is_object($recipient) && $recipient->exists()) { |
243 | 247 | $article = new Article($recipient); |
244 | | - if (preg_match('/[a-z0-9_.-]+@[a-z0-9_.-]+/i',$article->getContent(),$emails)) $recipient = $emails[0]; |
| 248 | + if (preg_match('/[a-z0-9_.-]+@[a-z0-9_.-]+/i', $article->getContent(), $emails)) $recipient = $emails[0]; |
245 | 249 | else $recipient = ''; |
246 | 250 | } |
247 | 251 | if ($valid = User::isValidEmailAddr($recipient)) $this->recipients[] = $recipient; |