r107528 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r107527‎ | r107528 | r107529 >
Date:21:02, 28 December 2011
Author:catrope
Status:ok
Tags:
Comment:
1.18wmf1: Update MoodBar to trunk state
Modified paths:
  • /branches/wmf/1.18wmf1/extensions/MoodBar (modified) (history)
  • /branches/wmf/1.18wmf1/extensions/MoodBar/ApiFeedbackDashboardResponse.php (modified) (history)
  • /branches/wmf/1.18wmf1/extensions/MoodBar/ApiMoodBarSetUserEmail.php (modified) (history)
  • /branches/wmf/1.18wmf1/extensions/MoodBar/ApiQueryMoodBarComments.php (modified) (history)
  • /branches/wmf/1.18wmf1/extensions/MoodBar/FeedbackResponseItem.php (modified) (history)
  • /branches/wmf/1.18wmf1/extensions/MoodBar/MoodBar.hooks.php (modified) (history)
  • /branches/wmf/1.18wmf1/extensions/MoodBar/MoodBar.php (modified) (history)
  • /branches/wmf/1.18wmf1/extensions/MoodBar/sql/MoodBar.sql (modified) (history)
  • /branches/wmf/1.18wmf1/extensions/MoodBar/sql/moodbar_feedback_response.sql (modified) (history)

Diff [purge]

Index: branches/wmf/1.18wmf1/extensions/MoodBar/ApiMoodBarSetUserEmail.php
@@ -2,69 +2,65 @@
33
44
55 class ApiMoodBarSetUserEmail extends ApiBase {
6 -
 6+
77 public function execute() {
88 global $wgUser, $wgAuth, $wgEnableEmail, $wgEmailAuthentication;
9 -
 9+
1010 if ( $wgUser->isAnon() ) {
1111 $this->dieUsage( "You don't have permission to do that", 'permission-denied' );
1212 }
13 -
 13+
1414 $params = $this->extractRequestParams();
1515
1616 $error = false;
17 -
 17+
1818 switch ( $params['mbaction']) {
19 -
 19+
2020 case 'setemail':
2121 if ( !$wgAuth->allowPropChange( 'emailaddress' ) ) {
22 - $error = wfMsgExt( 'cannotchangeemail', 'parseinline' );
23 - }
24 - else {
 22+ $error = wfMsgExt( 'cannotchangeemail', 'parseinline' );
 23+ } else {
2524 //only set email if user does not have email on profile yet
2625 if ( !$wgUser->getEmail() ) {
27 -
 26+
2827 if ( !isset( $params['email'] ) || !Sanitizer::validateEmail( $params['email'] ) ) {
2928 $error = wfMsgExt( 'invalidemailaddress', 'parseinline' ) ;
3029 }
3130 else {
3231 list( $status, $info ) = self::trySetUserEmail( $wgUser, $params['email'] );
33 -
 32+
3433 // Status Object
3534 if ( $status !== true ) {
3635 $error = $status->getWikiText( $info );
 36+ } else {
 37+ $wgUser->saveSettings();
3738 }
38 - else {
39 - $wgUser->saveSettings();
40 - }
4139 }
42 -
 40+
4341 }
4442 }
45 - break;
46 -
 43+ break;
 44+
4745 case 'resendverification':
4846 //only sends the email if the email has not been verified
4947 if ( $wgEnableEmail && $wgEmailAuthentication && $wgUser->getEmail() && !$wgUser->isEmailConfirmed() ) {
5048 $status = $wgUser->sendConfirmationMail( 'set' );
5149 if ( !$status->isGood() ) {
5250 $error = $status->getWikiText( 'mailerror' );
53 - }
 51+ }
5452 }
55 - break;
56 -
 53+ break;
 54+
5755 default:
5856 throw new MWApiMoodBarSetUserEmailInvalidActionException( "Action {$params['mbaction']} not implemented" );
59 - break;
60 -
6157 }
62 -
 58+
6359 if ( $error === false ) {
6460 $result = array( 'result' => 'success' );
6561 } else {
6662 $result = array( 'result' => 'error', 'error' => $error );
6763 }
68 -
 64+
6965 $this->getResult()->addValue( null, $this->getModuleName(), $result );
7066 }
7167
@@ -95,8 +91,6 @@
9692 return array( true, $info );
9793 }
9894
99 -
100 -
10195 public function needsToken() {
10296 return true;
10397 }
@@ -114,11 +108,11 @@
115109 'resendverification',
116110 ),
117111 ),
118 -
 112+
119113 'email' => array(
120114 ApiBase::PARAM_TYPE => 'string'
121115 ),
122 -
 116+
123117 'token' => array(
124118 ApiBase::PARAM_REQUIRED => true,
125119 ),
Index: branches/wmf/1.18wmf1/extensions/MoodBar/ApiFeedbackDashboardResponse.php
@@ -1,22 +1,22 @@
22 <?php
33
44 class ApiFeedbackDashboardResponse extends ApiBase {
5 -
 5+
66 private $EnotifUserTalk;
77 private $EnotifWatchlist;
8 -
 8+
99 public function execute() {
1010 global $wgRequest, $wgUser;
11 -
 11+
1212 if ( $wgUser->isAnon() ) {
1313 $this->dieUsage( "You don't have permission to do that", 'permission-denied' );
1414 }
1515 if ( $wgUser->isBlocked( false ) ) {
1616 $this->dieUsageMsg( array( 'blockedtext' ) );
1717 }
18 -
 18+
1919 $params = $this->extractRequestParams();
20 -
 20+
2121 //Response Object
2222 $item = MBFeedbackResponseItem::create( array() );
2323
@@ -27,73 +27,73 @@
2828 }
2929 }
3030
31 - $item->setProperties( $setParams );
 31+ $item->setProperties( $setParams );
3232 $item->save();
33 -
 33+
3434 $commenter = $item->getProperty('feedbackitem')->getProperty('user');
35 -
 35+
3636 if ( $commenter !== null && $commenter->isAnon() == false ) {
3737 $talkPage = $commenter->getTalkPage();
38 -
 38+
3939 $response = Parser::cleanSigInSig($params['response']);
40 -
 40+
4141 $feedback_link = wfMessage('moodbar-feedback-response-title')->inContentLanguage()->
42 - params( SpecialPage::getTitleFor( 'FeedbackDashboard', $item->getProperty('feedback') )->
43 - getPrefixedText() )->escaped();
44 -
 42+ params( SpecialPage::getTitleFor( 'FeedbackDashboard', $item->getProperty('feedback') )->
 43+ getPrefixedText() )->escaped();
 44+
4545 $summary = wfMessage('moodbar-feedback-edit-summary')->inContentLanguage()->
46 - rawParams( $item->getProperty('feedback'), $response)->escaped();
47 -
48 - $this->disableUserTalkEmailNotification();
49 -
 46+ rawParams( $item->getProperty('feedback'), $response)->escaped();
 47+
 48+ $this->disableUserTalkEmailNotification();
 49+
5050 $id = intval( $item->getProperty( 'id' ) );
5151 $api = new ApiMain( new FauxRequest( array(
5252 'action' => 'edit',
5353 'title' => $talkPage->getFullText(),
5454 'appendtext' => ( $talkPage->exists() ? "\n\n" : '' ) .
5555 $feedback_link . "\n" .
56 - '<span id="feedback-dashboard-response-' . $id . '"></span>' . "\n\n" .
 56+ '<span id="feedback-dashboard-response-' . $id . '">&nbsp;</span>' . "\n\n" .
5757 $response . "\n\n~~~~\n\n" .
58 - '<span class="markashelpful-item" data-markashelpful-item="' . $id . '" data-markashelpful-type="mbresponse"></span>',
 58+ '<span class="markashelpful-item" data-markashelpful-item="' . $id . '" data-markashelpful-type="mbresponse">&nbsp;</span>',
5959 'token' => $params['token'],
6060 'summary' => $summary,
6161 'notminor' => true,
6262 ), true, array( 'wsEditToken' => $wgRequest->getSessionData( 'wsEditToken' ) ) ), true );
63 -
 63+
6464 $api->execute();
65 -
 65+
6666 $this->restoreUserTalkEmailNotification();
67 -
68 - global $wgLang;
69 -
 67+
 68+ global $wgLang;
 69+
7070 $EMailNotif = new MoodBarHTMLEmailNotification();
7171 $EMailNotif->notifyOnRespond( $wgUser, $talkPage, wfTimestampNow(), $item->getProperty('feedback'), $wgLang->truncate( $response, 250 ) );
72 -
 72+
7373 }
74 -
 74+
7575 $result = array( 'result' => 'success' );
76 - $this->getResult()->addValue( null, $this->getModuleName(), $result );
 76+ $this->getResult()->addValue( null, $this->getModuleName(), $result );
7777 }
78 -
 78+
7979 /**
80 - * temporarily disable the talk page email notification
 80+ * temporarily disable the talk page email notification
8181 * for user and watchers
8282 */
8383 private function disableUserTalkEmailNotification() {
8484 global $wgEnotifUserTalk, $wgEnotifWatchlist;
8585
8686 $this->EnotifUserTalk = $wgEnotifUserTalk;
87 - $this->EnotifWatchlist = $wgEnotifWatchlist;
88 -
89 - $wgEnotifUserTalk = $wgEnotifWatchlist = false;
 87+ $this->EnotifWatchlist = $wgEnotifWatchlist;
 88+
 89+ $wgEnotifUserTalk = $wgEnotifWatchlist = false;
9090 }
91 -
 91+
9292 /**
9393 * restore the default state of talk page email notification
9494 */
9595 private function restoreUserTalkEmailNotification() {
9696 global $wgEnotifUserTalk, $wgEnotifWatchlist;
97 -
 97+
9898 if ( !is_null( $this->EnotifUserTalk ) ) {
9999 $wgEnotifUserTalk = $this->EnotifUserTalk;
100100 }
@@ -101,7 +101,7 @@
102102 $wgEnotifWatchlist = $this->EnotifWatchlist;
103103 }
104104 }
105 -
 105+
106106 public function needsToken() {
107107 return true;
108108 }
@@ -160,5 +160,5 @@
161161 public function getDescription() {
162162 return 'Allows users to submit response to a feedback about their experiences on the site';
163163 }
164 -
 164+
165165 }
Index: branches/wmf/1.18wmf1/extensions/MoodBar/MoodBar.hooks.php
@@ -15,52 +15,52 @@
1616
1717 return true;
1818 }
19 -
 19+
2020 /**
2121 * Determines if this user has right to mark an feedback response as helpful, only the user who wrote the
2222 * feedback can mark the response as helpful
2323 * @param $mahaction string - mark/unmark
2424 * @param $type string - the object type to be marked
25 - * @param $item int - an item of $type to be marked
 25+ * @param $item int - an item of $type to be marked
2626 * @param $User User Object - the User in current session
2727 * @param $isAbleToMark bool - determine whether the user is able to mark the item
2828 * @return bool
2929 */
3030 public static function onMarkItemAsHelpful( $mahaction, $type, $item, $User, &$isAbleToMark ) {
31 -
 31+
3232 if ( $User->isAnon() ) {
3333 $isAbleToMark = false;
3434 return true;
3535 }
36 -
 36+
3737 if ( $type == 'mbresponse' ) {
38 -
 38+
3939 switch ( $mahaction ) {
40 -
 40+
4141 case 'mark':
4242 $dbr = wfGetDB( DB_SLAVE );
43 -
44 - $res = $dbr->selectRow( array( 'moodbar_feedback', 'moodbar_feedback_response' ),
 43+
 44+ $res = $dbr->selectRow( array( 'moodbar_feedback', 'moodbar_feedback_response' ),
4545 array( 'mbf_id' ),
46 - array( 'mbf_id = mbfr_mbf_id',
47 - 'mbfr_id' => intval( $item ),
48 - 'mbf_user_id' => $User->getId() ),
49 - __METHOD__ );
50 -
 46+ array( 'mbf_id = mbfr_mbf_id',
 47+ 'mbfr_id' => intval( $item ),
 48+ 'mbf_user_id' => $User->getId() ),
 49+ __METHOD__ );
 50+
5151 if ( $res === false ) {
5252 $isAbleToMark = false;
5353 }
54 - break;
55 -
 54+ break;
 55+
5656 case 'unmark':
5757 default:
5858 //We will leve the MarkAsHelpFul extension to check if the user has unmark right
59 - break;
 59+ break;
6060 }
6161 }
62 -
 62+
6363 return true;
64 -
 64+
6565 }
6666
6767 /**
@@ -127,45 +127,31 @@
128128 * @param $updater DatabasEUpdater
129129 */
130130 public static function onLoadExtensionSchemaUpdates( $updater = null ) {
131 - $updater->addExtensionUpdate( array( 'addTable', 'moodbar_feedback',
132 - dirname(__FILE__).'/sql/MoodBar.sql', true ) );
 131+ $dir = dirname(__FILE__) . '/sql/';
 132+ $updater->addExtensionTable( 'moodbar_feedback', $dir . 'MoodBar.sql' );
133133
134 - $updater->addExtensionUpdate( array( 'addField', 'moodbar_feedback',
135 - 'mbf_user_editcount', dirname(__FILE__).'/sql/mbf_user_editcount.sql', true )
136 - );
 134+ $updater->addExtensionField( 'moodbar_feedback', 'mbf_user_editcount', $dir . 'mbf_user_editcount.sql' );
137135
138 - $db = $updater->getDB();
139 - if ( $db->tableExists( 'moodbar_feedback' ) &&
140 - $db->indexExists( 'moodbar_feedback', 'type_timestamp', __METHOD__ ) )
141 - {
142 - $updater->addExtensionUpdate( array( 'addIndex', 'moodbar_feedback',
143 - 'mbf_type_timestamp_id', dirname( __FILE__ ) . '/sql/AddIDToIndexes.sql', true )
144 - );
145 - }
 136+ $updater->addExtensionIndex( 'moodbar_feedback', 'mbf_type_timestamp_id', $dir . 'AddIDToIndexes.sql' );
 137+
146138 $updater->addExtensionUpdate( array( 'dropIndex', 'moodbar_feedback',
147 - 'mbf_timestamp', dirname( __FILE__ ) . '/sql/AddIDToIndexes2.sql', true )
 139+ 'mbf_userid_ip_timestamp', $dir . 'AddIDToIndexes2.sql', true )
148140 );
149141
150 - $updater->addExtensionUpdate( array( 'addIndex', 'moodbar_feedback',
151 - 'mbf_timestamp_id', dirname( __FILE__ ) . '/sql/mbf_timestamp_id.sql', true )
152 - );
 142+ $updater->addExtensionIndex( 'moodbar_feedback', 'mbfr_timestamp_id', $dir . 'mbf_timestamp_id.sql' );
153143
154 - $updater->addExtensionUpdate( array( 'addField', 'moodbar_feedback',
155 - 'mbf_hidden_state', dirname(__FILE__).'/sql/mbf_hidden_state.sql', true ) );
156 -
157 - $updater->addExtensionUpdate( array( 'addTable', 'moodbar_feedback_response',
158 - dirname(__FILE__).'/sql/moodbar_feedback_response.sql', true ) );
 144+ $updater->addExtensionField( 'moodbar_feedback', 'mbf_hidden_state', $dir . 'mbf_hidden_state.sql' );
159145
160 - $updater->addExtensionUpdate( array( 'addIndex', 'moodbar_feedback_response',
161 - 'mbfr_timestamp_id', dirname( __FILE__ ) . '/sql/mbfr_timestamp_id_index.sql', true )
162 - );
163 -
 146+ $updater->addExtensionTable( 'moodbar_feedback_response', $dir . 'moodbar_feedback_response.sql' );
 147+
 148+ $updater->addExtensionIndex( 'moodbar_feedback_response', 'mbfr_timestamp_id', $dir . 'mbfr_timestamp_id_index.sql' );
 149+
164150 return true;
165151 }
166152
167153 /**
168154 * Gets the MoodBar testing bucket that a user is in.
169 - * @param $user The user to check
 155+ * @param $user User The user to check
170156 * @return array of bucket names
171157 */
172158 public static function getUserBuckets( $user ) {
Index: branches/wmf/1.18wmf1/extensions/MoodBar/sql/MoodBar.sql
@@ -1,20 +1,20 @@
22 CREATE TABLE /*_*/moodbar_feedback (
33 mbf_id int unsigned NOT NULL PRIMARY KEY auto_increment, -- Primary key
44 mbf_type varchar(32) binary NOT NULL, -- Type of feedback
5 -
 5+
66 -- User who provided the feedback
77 mbf_user_id int unsigned NOT NULL, -- User ID, or zero
88 mbf_user_ip varchar(255) binary NULL, -- If anonymous, user's IP address
99 mbf_user_editcount int unsigned NOT NULL, -- Edit count of the user
10 -
 10+
1111 -- Page where the feedback was received
1212 -- Nullable.
1313 mbf_namespace int,
1414 mbf_title varchar(255) binary,
15 -
 15+
1616 -- The feedback itself
1717 mbf_comment varchar(255) binary,
18 -
 18+
1919 -- Options and context
2020 -- Whether or not the feedback item is hidden
2121 -- 0 = No; 255 = Yes (other values reserved for partial hiding)
Index: branches/wmf/1.18wmf1/extensions/MoodBar/sql/moodbar_feedback_response.sql
@@ -1,18 +1,18 @@
22 CREATE TABLE /*_*/moodbar_feedback_response (
33 mbfr_id int unsigned NOT NULL PRIMARY KEY auto_increment, -- Primary key
4 -
 4+
55 mbfr_mbf_id int unsigned NOT NULL, -- Primary key of moodbar_feedback table
6 -
 6+
77 -- User who provided the response
88 mbfr_user_id int unsigned NOT NULL, -- User ID, or zero
99 mbfr_user_ip varbinary(40) NULL, -- If anonymous, user's IP address
10 -
 10+
1111 mbfr_commenter_editcount int unsigned NOT NULL, -- number of edit for the user who writes the feedback
1212 mbfr_user_editcount int unsigned NOT NULL, -- number of edit for the responder
13 -
 13+
1414 -- The response itself
1515 mbfr_response_text text NOT NULL,
16 -
 16+
1717 -- Options and context
1818 mbfr_timestamp varchar(14) binary NOT NULL, -- When response was received
1919 mbfr_anonymous tinyint unsigned NOT NULL DEFAULT 0, -- Anonymity
@@ -23,3 +23,4 @@
2424 ) /*$wgDBTableOptions*/;
2525
2626 CREATE INDEX /*i*/mbfr_mbf_id ON /*_*/moodbar_feedback_response (mbfr_mbf_id);
 27+CREATE INDEX /*i*/mbfr_timestamp_id ON /*_*/moodbar_feedback_response (mbfr_mbf_id, mbfr_timestamp, mbfr_id);
Index: branches/wmf/1.18wmf1/extensions/MoodBar/ApiQueryMoodBarComments.php
@@ -4,12 +4,12 @@
55 public function __construct( $query, $moduleName ) {
66 parent::__construct( $query, $moduleName, 'mbc' );
77 }
8 -
 8+
99 public function execute() {
10 - global $wgLang, $wgUser;
 10+ global $wgUser;
1111 $params = $this->extractRequestParams();
1212 $prop = array_flip( $params['prop'] );
13 -
 13+
1414 // Build the query
1515 $this->addTables( array( 'moodbar_feedback', 'user' ) );
1616 $this->addJoinConds( array( 'user' => array( 'LEFT JOIN', 'user_id=mbf_user_id' ) ) );
@@ -28,40 +28,40 @@
2929 $this->addWhere( 'mbf_user_ip IS NULL' );
3030 }
3131 }
32 -
 32+
3333 if ( $params['continue'] !== null ) {
3434 $this->applyContinue( $params['continue'], $params['dir'] == 'older' );
3535 }
36 -
 36+
3737 // Add ORDER BY mbf_timestamp {ASC|DESC}, mbf_id {ASC|DESC}
3838 $this->addWhereRange( 'mbf_timestamp', $params['dir'], null, null );
3939 $this->addWhereRange( 'mbf_id', $params['dir'], null, null );
4040 $this->addOption( 'LIMIT', $params['limit'] + 1 );
41 -
 41+
4242 if ( $params['myresponse'] == '1' && !$wgUser->isAnon() ) {
4343 $this->addTables( array( 'moodbar_feedback_response' ) );
4444 $this->addJoinConds( array( 'moodbar_feedback_response' => array( 'INNER JOIN', 'mbf_id=mbfr_mbf_id' ) ) );
4545 $this->addWhereFld( 'mbfr_user_id', $wgUser->getId() );
4646 $this->addOption( 'GROUP BY', 'mbf_id' );
4747 }
48 -
 48+
4949 if ( ! $wgUser->isAllowed( 'moodbar-admin' ) ) {
5050 $this->addWhereFld( 'mbf_hidden_state', 0 );
5151 }
52 -
 52+
5353 $res = $this->select( __METHOD__ );
5454 $result = $this->getResult();
5555 $count = 0;
56 -
 56+
5757 $response = SpecialFeedbackDashboard::getResponseSummary( $res );
58 -
 58+
5959 foreach ( $res as $row ) {
6060 if ( ++$count > $params['limit'] ) {
6161 // We've reached the one extra which shows that there are additional rows. Stop here
6262 $this->setContinueEnumParameter( 'continue', $this->getContinue( $row ) );
6363 break;
6464 }
65 -
 65+
6666 $vals = $this->extractRowInfo( $row, $prop, $response );
6767 $fit = $result->addValue( array( 'query', $this->getModuleName() ), null, $vals );
6868 if ( !$fit ) {
@@ -71,19 +71,19 @@
7272 }
7373 $result->setIndexedTagName_internal( array( 'query', $this->getModuleName() ), 'comment' );
7474 }
75 -
 75+
7676 protected function getContinue( $row ) {
7777 $ts = wfTimestamp( TS_MW, $row->mbf_timestamp );
7878 return "$ts|{$row->mbf_id}";
7979 }
80 -
 80+
8181 protected function applyContinue( $continue, $sortDesc ) {
8282 $vals = explode( '|', $continue, 3 );
8383 if ( count( $vals ) !== 2 ) {
8484 // TODO this should be a standard message in ApiBase
8585 $this->dieUsage( 'Invalid continue param. You should pass the original value returned by the previous query', 'badcontinue' );
8686 }
87 -
 87+
8888 $db = $this->getDB();
8989 $ts = $db->addQuotes( $db->timestamp( $vals[0] ) );
9090 $id = intval( $vals[1] );
@@ -94,15 +94,15 @@
9595 "mbf_id $op= $id)"
9696 );
9797 }
98 -
 98+
9999 protected function extractRowInfo( $row, $prop, $response = array() ) {
100100 global $wgUser;
101 -
 101+
102102 $r = array();
103 -
 103+
104104 $showHidden = isset($prop['hidden']) && $wgUser->isAllowed('moodbar-admin');
105105 $isHidden = $row->mbf_hidden_state > 0;
106 -
 106+
107107 if ( isset( $prop['metadata'] ) ) {
108108 $r += array(
109109 'id' => intval( $row->mbf_id ),
@@ -115,18 +115,18 @@
116116 }
117117 if ( isset( $prop['formatted'] ) ) {
118118 $params = array();
119 -
 119+
120120 if ( $wgUser->isAllowed( 'moodbar-admin' ) ) {
121121 $params[] = 'admin';
122122 }
123 -
 123+
124124 if ( $isHidden && $showHidden ) {
125125 $params[] = 'show-anyway';
126126 }
127 -
 127+
128128 $r['formatted'] = SpecialFeedbackDashboard::formatListItem( $row, $params, $response );
129129 }
130 -
 130+
131131 if ( $isHidden && !$showHidden ) {
132132 unset($r['userid']);
133133 unset($r['username']);
@@ -134,7 +134,7 @@
135135 ApiResult::setContent( $r, '' );
136136 $r['hidden'] = true;
137137 }
138 -
 138+
139139 return $r;
140140 }
141141
@@ -164,7 +164,7 @@
165165 ApiBase::PARAM_TYPE => 'user',
166166 ),
167167 'myresponse' => array(
168 - ApiBase::PARAM_TYPE => array( '1' , '0' ),
 168+ ApiBase::PARAM_TYPE => array( '1' , '0' ),
169169 ),
170170 'prop' => array(
171171 ApiBase::PARAM_TYPE => array( 'metadata', 'formatted', 'hidden' ),
@@ -196,7 +196,7 @@
197197 public function getDescription() {
198198 return 'List all feedback comments submitted through the MoodBar extension.';
199199 }
200 -
 200+
201201 public function getCacheMode( $params ) {
202202 return isset($params['prop']['hidden']) ? 'private' : 'public';
203203 }
Index: branches/wmf/1.18wmf1/extensions/MoodBar/FeedbackResponseItem.php
@@ -13,17 +13,17 @@
1414 // Feedback response essentials
1515 'id', // ID in the database for response
1616 'feedback', // ID in the database for moodbar_feedback
17 - 'feedbackitem', // the feedback that the user responds to
 17+ 'feedbackitem', // the feedback that the user responds to
1818 'user', // user object
1919 'anonymize',
20 - 'commenter-editcount', // Number of edit for the user writes the feedback
21 - 'user-editcount', // Number of edit for the responder
22 - 'response', // The response itself
23 - 'timestamp', // When response was received
24 - 'system', // Operating System
25 - 'useragent' , // User-Agent header
26 - 'locale', // The locale of the user's browser
27 - 'editmode' // Whether or not the user was editing
 20+ 'commenter-editcount', // Number of edit for the user writes the feedback
 21+ 'user-editcount', // Number of edit for the responder
 22+ 'response', // The response itself
 23+ 'timestamp', // When response was received
 24+ 'system', // Operating System
 25+ 'useragent' , // User-Agent header
 26+ 'locale', // The locale of the user's browser
 27+ 'editmode' // Whether or not the user was editing
2828 );
2929 /**
3030 * Default constructor.
@@ -57,7 +57,7 @@
5858 */
5959 protected function initialiseNew( $info ) {
6060 global $wgUser;
61 -
 61+
6262 $template = array(
6363 'user' => $wgUser,
6464 'timestamp' => wfTimestampNow(),
@@ -94,12 +94,12 @@
9595 'system' => 'mbfr_system_type',
9696 'locale' => 'mbfr_locale',
9797 'editmode' => 'mbfr_editing',
98 - 'commenter-editcount',
99 - 'user-editcount'
 98+ 'commenter-editcount',
 99+ 'user-editcount'
100100 );
101 -
 101+
102102 $properties = array();
103 -
 103+
104104 foreach( $propMappings as $property => $field ) {
105105 if ( isset( $row->$field ) ) {
106106 $properties[$property] = $row->$field;
@@ -117,7 +117,7 @@
118118 }
119119
120120 $this->setProperties( $properties );
121 -
 121+
122122 }
123123
124124 /**
@@ -205,21 +205,19 @@
206206 * @return The MBFeedbackItem's new ID.
207207 */
208208 public function save() {
209 -
 209+
210210 $user = $this->getProperty('user');
211 -
 211+
212212 // Add edit count if necessary
213 - if ( $this->getProperty('user-editcount') === null && $user !== null )
214 - {
 213+ if ( $this->getProperty('user-editcount') === null && $user !== null ) {
215214 $this->setProperty( 'user-editcount', $user->isAnon() ? 0 : $user->getEditCount() );
216 -
217 - }
218 -
 215+ }
 216+
219217 if($this->getProperty('commenter-editcount') === null) {
220218 $commenter = $this->getProperty('feedbackitem')->getProperty('user');
221219 $this->setProperty( 'commenter-editcount', $commenter->isAnon() ? 0 : $commenter->getEditCount() );
222220 }
223 -
 221+
224222 $dbw = wfGetDB( DB_MASTER );
225223
226224 $row = array(
@@ -237,8 +235,7 @@
238236 if($user->isAnon()) {
239237 $row['mbfr_user_id'] = 0;
240238 $row['mbfr_user_ip'] = $user->getName();
241 - }
242 - else {
 239+ } else {
243240 $row['mbfr_user_id'] = $user->getId();
244241 }
245242
@@ -260,7 +257,7 @@
261258 public static function getValidTypes() {
262259 return self::$validTypes;
263260 }
264 -
 261+
265262 /**
266263 * Set the Feedback Item this Response is associated to
267264 * @param $mbf_id mbfr_mbf_id in moodbar_feedback_response table
@@ -268,17 +265,17 @@
269266 */
270267 protected function setFeedbackItem($mbf_id) {
271268 $dbr = wfGetDB( DB_SLAVE );
272 -
 269+
273270 $row = $dbr->selectRow( 'moodbar_feedback', '*',
274271 array( 'mbf_id' => $mbf_id ), __METHOD__ );
275 -
 272+
276273 if( $row !== false ) {
277 - $this->setProperties( array ( 'feedbackitem' => MBFeedbackItem::load( $row ) ) );
 274+ $this->setProperties( array ( 'feedbackitem' => MBFeedbackItem::load( $row ) ) );
278275 return true;
279276 }
280277 else {
281 - return false;
282 - }
 278+ return false;
 279+ }
283280 }
284281
285282 }
Index: branches/wmf/1.18wmf1/extensions/MoodBar/MoodBar.php
@@ -16,6 +16,7 @@
1717 // Object model
1818 $wgAutoloadClasses['MBFeedbackItem'] = dirname(__FILE__).'/FeedbackItem.php';
1919 $wgAutoloadClasses['MBFeedbackResponseItem'] = dirname(__FILE__).'/FeedbackResponseItem.php';
 20+$wgAutoloadClasses['MWFeedbackResponseItemPropertyException'] = dirname(__FILE__).'/FeedbackResponseItem.php';
2021 $wgAutoloadClasses['MoodBarFormatter'] = dirname(__FILE__).'/Formatter.php';
2122 $wgAutoloadClasses['MoodBarHTMLEmailNotification'] = dirname(__FILE__).'/include/MoodBarHTMLEmailNotification.php';
2223 $wgAutoloadClasses['MoodBarHTMLMailerJob'] = dirname( __FILE__ ) . '/include/MoodBarHTMLMailerJob.php';
@@ -30,6 +31,7 @@
3132 $wgAutoloadClasses['ApiFeedbackDashboardResponse'] = dirname(__FILE__).'/ApiFeedbackDashboardResponse.php';
3233 $wgAPIModules['feedbackdashboardresponse'] = 'ApiFeedbackDashboardResponse';
3334 $wgAutoloadClasses['ApiMoodBarSetUserEmail'] = dirname(__FILE__).'/ApiMoodBarSetUserEmail.php';
 35+$wgAutoloadClasses['MWApiMoodBarSetUserEmailInvalidActionException'] = dirname(__FILE__).'/ApiMoodBarSetUserEmail.php';
3436 $wgAPIModules['moodbarsetuseremail'] = 'ApiMoodBarSetUserEmail';
3537
3638 // Hooks
@@ -209,11 +211,11 @@
210212 'response-back-text',
211213 'response-preview-text',
212214 'response-preview-text',
213 - 'response-ajax-action-head',
 215+ 'response-ajax-action-head',
214216 'response-ajax-action-body',
215217 'response-ajax-success-head',
216218 'response-ajax-success-body',
217 - 'response-ajax-error-head',
 219+ 'response-ajax-error-head',
218220 'response-ajax-error-body',
219221 ),
220222 );
@@ -253,4 +255,5 @@
254256 'infoUrl' => 'http://www.mediawiki.org/wiki/MoodBar',
255257 'privacyUrl' => 'about:blank',
256258 'disableExpiration' => 365,
257 -);
\ No newline at end of file
 259+);
 260+
Property changes on: branches/wmf/1.18wmf1/extensions/MoodBar
___________________________________________________________________
Modified: svn:mergeinfo
258261 Merged /trunk/extensions/MoodBar:r107520-107527

Status & tagging log