Index: trunk/extensions/WikiLove/WikiLove.php |
— | — | @@ -67,7 +67,9 @@ |
68 | 68 | $wgAPIModules['wikiLove'] = 'WikiLoveApi'; |
69 | 69 | |
70 | 70 | // default user options |
| 71 | +$wgWikiLoveGlobal = false; |
71 | 72 | $wgWikiLoveTabIcon = true; |
| 73 | +$wgWikiLoveLogging = false; |
72 | 74 | |
73 | 75 | // resources |
74 | 76 | $wikiLoveTpl = array( |
Index: trunk/extensions/WikiLove/WikiLove.api.php |
— | — | @@ -1,7 +1,7 @@ |
2 | 2 | <?php |
3 | 3 | class WikiLoveApi extends ApiBase { |
4 | 4 | public function execute() { |
5 | | - global $wgRequest; |
| 5 | + global $wgRequest, $wgWikiLoveLogging; |
6 | 6 | |
7 | 7 | $params = $this->extractRequestParams(); |
8 | 8 | |
— | — | @@ -16,9 +16,13 @@ |
17 | 17 | } |
18 | 18 | |
19 | 19 | if ( stripos( $params['text'], $params['template'] ) === false ) { |
20 | | - // error |
| 20 | + $this->dieUsage( 'Template could not be found in the message!', 'invalidtemplate' ); |
21 | 21 | } |
22 | 22 | |
| 23 | + if ( $wgWikiLoveLogging ) { |
| 24 | + $this->saveInDb( $talk, $params['subject'], $params['text'], $params['type'], $params['template'] ); |
| 25 | + } |
| 26 | + |
23 | 27 | $api = new ApiMain( new FauxRequest( array( |
24 | 28 | 'action' => 'edit', |
25 | 29 | 'title' => $talk->getFullText(), |
— | — | @@ -37,8 +41,6 @@ |
38 | 42 | $talk->setFragment( '#' . $params['subject'] ); |
39 | 43 | $this->getResult()->addValue( 'redirect', 'pageName', $talk->getPrefixedDBkey() ); |
40 | 44 | $this->getResult()->addValue( 'redirect', 'fragment', $talk->getFragmentForURL() ); |
41 | | - |
42 | | - $this->saveInDb( $talk, $params['subject'], $params['text'], $params['type'], $params['template'] ); |
43 | 45 | } |
44 | 46 | |
45 | 47 | /** |
— | — | @@ -128,6 +130,10 @@ |
129 | 131 | 'code' => 'nologging', |
130 | 132 | 'info' => 'Warning: action was not logged!' |
131 | 133 | ), |
| 134 | + array( |
| 135 | + 'code' => 'invalidtemplate', |
| 136 | + 'info' => 'Template could not be found in the message!' |
| 137 | + ), |
132 | 138 | ) ); |
133 | 139 | } |
134 | 140 | |