r88183 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r88182‎ | r88183 | r88184 >
Date:14:18, 15 May 2011
Author:janpaul123
Status:ok
Tags:
Comment:
API and setup cleanup
Modified paths:
  • /trunk/extensions/WikiLove/WikiLove.api.php (modified) (history)
  • /trunk/extensions/WikiLove/WikiLove.php (modified) (history)

Diff [purge]

Index: trunk/extensions/WikiLove/WikiLove.php
@@ -67,7 +67,9 @@
6868 $wgAPIModules['wikiLove'] = 'WikiLoveApi';
6969
7070 // default user options
 71+$wgWikiLoveGlobal = false;
7172 $wgWikiLoveTabIcon = true;
 73+$wgWikiLoveLogging = false;
7274
7375 // resources
7476 $wikiLoveTpl = array(
Index: trunk/extensions/WikiLove/WikiLove.api.php
@@ -1,7 +1,7 @@
22 <?php
33 class WikiLoveApi extends ApiBase {
44 public function execute() {
5 - global $wgRequest;
 5+ global $wgRequest, $wgWikiLoveLogging;
66
77 $params = $this->extractRequestParams();
88
@@ -16,9 +16,13 @@
1717 }
1818
1919 if ( stripos( $params['text'], $params['template'] ) === false ) {
20 - // error
 20+ $this->dieUsage( 'Template could not be found in the message!', 'invalidtemplate' );
2121 }
2222
 23+ if ( $wgWikiLoveLogging ) {
 24+ $this->saveInDb( $talk, $params['subject'], $params['text'], $params['type'], $params['template'] );
 25+ }
 26+
2327 $api = new ApiMain( new FauxRequest( array(
2428 'action' => 'edit',
2529 'title' => $talk->getFullText(),
@@ -37,8 +41,6 @@
3842 $talk->setFragment( '#' . $params['subject'] );
3943 $this->getResult()->addValue( 'redirect', 'pageName', $talk->getPrefixedDBkey() );
4044 $this->getResult()->addValue( 'redirect', 'fragment', $talk->getFragmentForURL() );
41 -
42 - $this->saveInDb( $talk, $params['subject'], $params['text'], $params['type'], $params['template'] );
4345 }
4446
4547 /**
@@ -128,6 +130,10 @@
129131 'code' => 'nologging',
130132 'info' => 'Warning: action was not logged!'
131133 ),
 134+ array(
 135+ 'code' => 'invalidtemplate',
 136+ 'info' => 'Template could not be found in the message!'
 137+ ),
132138 ) );
133139 }
134140

Status & tagging log