Index: branches/wmf/1.18wmf1/extensions/MoodBar/ApiMoodBarSetUserEmail.php |
— | — | @@ -2,69 +2,65 @@ |
3 | 3 | |
4 | 4 | |
5 | 5 | class ApiMoodBarSetUserEmail extends ApiBase { |
6 | | - |
| 6 | + |
7 | 7 | public function execute() { |
8 | 8 | global $wgUser, $wgAuth, $wgEnableEmail, $wgEmailAuthentication; |
9 | | - |
| 9 | + |
10 | 10 | if ( $wgUser->isAnon() ) { |
11 | 11 | $this->dieUsage( "You don't have permission to do that", 'permission-denied' ); |
12 | 12 | } |
13 | | - |
| 13 | + |
14 | 14 | $params = $this->extractRequestParams(); |
15 | 15 | |
16 | 16 | $error = false; |
17 | | - |
| 17 | + |
18 | 18 | switch ( $params['mbaction']) { |
19 | | - |
| 19 | + |
20 | 20 | case 'setemail': |
21 | 21 | if ( !$wgAuth->allowPropChange( 'emailaddress' ) ) { |
22 | | - $error = wfMsgExt( 'cannotchangeemail', 'parseinline' ); |
23 | | - } |
24 | | - else { |
| 22 | + $error = wfMsgExt( 'cannotchangeemail', 'parseinline' ); |
| 23 | + } else { |
25 | 24 | //only set email if user does not have email on profile yet |
26 | 25 | if ( !$wgUser->getEmail() ) { |
27 | | - |
| 26 | + |
28 | 27 | if ( !isset( $params['email'] ) || !Sanitizer::validateEmail( $params['email'] ) ) { |
29 | 28 | $error = wfMsgExt( 'invalidemailaddress', 'parseinline' ) ; |
30 | 29 | } |
31 | 30 | else { |
32 | 31 | list( $status, $info ) = self::trySetUserEmail( $wgUser, $params['email'] ); |
33 | | - |
| 32 | + |
34 | 33 | // Status Object |
35 | 34 | if ( $status !== true ) { |
36 | 35 | $error = $status->getWikiText( $info ); |
| 36 | + } else { |
| 37 | + $wgUser->saveSettings(); |
37 | 38 | } |
38 | | - else { |
39 | | - $wgUser->saveSettings(); |
40 | | - } |
41 | 39 | } |
42 | | - |
| 40 | + |
43 | 41 | } |
44 | 42 | } |
45 | | - break; |
46 | | - |
| 43 | + break; |
| 44 | + |
47 | 45 | case 'resendverification': |
48 | 46 | //only sends the email if the email has not been verified |
49 | 47 | if ( $wgEnableEmail && $wgEmailAuthentication && $wgUser->getEmail() && !$wgUser->isEmailConfirmed() ) { |
50 | 48 | $status = $wgUser->sendConfirmationMail( 'set' ); |
51 | 49 | if ( !$status->isGood() ) { |
52 | 50 | $error = $status->getWikiText( 'mailerror' ); |
53 | | - } |
| 51 | + } |
54 | 52 | } |
55 | | - break; |
56 | | - |
| 53 | + break; |
| 54 | + |
57 | 55 | default: |
58 | 56 | throw new MWApiMoodBarSetUserEmailInvalidActionException( "Action {$params['mbaction']} not implemented" ); |
59 | | - break; |
60 | | - |
61 | 57 | } |
62 | | - |
| 58 | + |
63 | 59 | if ( $error === false ) { |
64 | 60 | $result = array( 'result' => 'success' ); |
65 | 61 | } else { |
66 | 62 | $result = array( 'result' => 'error', 'error' => $error ); |
67 | 63 | } |
68 | | - |
| 64 | + |
69 | 65 | $this->getResult()->addValue( null, $this->getModuleName(), $result ); |
70 | 66 | } |
71 | 67 | |
— | — | @@ -95,8 +91,6 @@ |
96 | 92 | return array( true, $info ); |
97 | 93 | } |
98 | 94 | |
99 | | - |
100 | | - |
101 | 95 | public function needsToken() { |
102 | 96 | return true; |
103 | 97 | } |
— | — | @@ -114,11 +108,11 @@ |
115 | 109 | 'resendverification', |
116 | 110 | ), |
117 | 111 | ), |
118 | | - |
| 112 | + |
119 | 113 | 'email' => array( |
120 | 114 | ApiBase::PARAM_TYPE => 'string' |
121 | 115 | ), |
122 | | - |
| 116 | + |
123 | 117 | 'token' => array( |
124 | 118 | ApiBase::PARAM_REQUIRED => true, |
125 | 119 | ), |
Index: branches/wmf/1.18wmf1/extensions/MoodBar/ApiFeedbackDashboardResponse.php |
— | — | @@ -1,22 +1,22 @@ |
2 | 2 | <?php |
3 | 3 | |
4 | 4 | class ApiFeedbackDashboardResponse extends ApiBase { |
5 | | - |
| 5 | + |
6 | 6 | private $EnotifUserTalk; |
7 | 7 | private $EnotifWatchlist; |
8 | | - |
| 8 | + |
9 | 9 | public function execute() { |
10 | 10 | global $wgRequest, $wgUser; |
11 | | - |
| 11 | + |
12 | 12 | if ( $wgUser->isAnon() ) { |
13 | 13 | $this->dieUsage( "You don't have permission to do that", 'permission-denied' ); |
14 | 14 | } |
15 | 15 | if ( $wgUser->isBlocked( false ) ) { |
16 | 16 | $this->dieUsageMsg( array( 'blockedtext' ) ); |
17 | 17 | } |
18 | | - |
| 18 | + |
19 | 19 | $params = $this->extractRequestParams(); |
20 | | - |
| 20 | + |
21 | 21 | //Response Object |
22 | 22 | $item = MBFeedbackResponseItem::create( array() ); |
23 | 23 | |
— | — | @@ -27,73 +27,73 @@ |
28 | 28 | } |
29 | 29 | } |
30 | 30 | |
31 | | - $item->setProperties( $setParams ); |
| 31 | + $item->setProperties( $setParams ); |
32 | 32 | $item->save(); |
33 | | - |
| 33 | + |
34 | 34 | $commenter = $item->getProperty('feedbackitem')->getProperty('user'); |
35 | | - |
| 35 | + |
36 | 36 | if ( $commenter !== null && $commenter->isAnon() == false ) { |
37 | 37 | $talkPage = $commenter->getTalkPage(); |
38 | | - |
| 38 | + |
39 | 39 | $response = Parser::cleanSigInSig($params['response']); |
40 | | - |
| 40 | + |
41 | 41 | $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 | + |
45 | 45 | $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 | + |
50 | 50 | $id = intval( $item->getProperty( 'id' ) ); |
51 | 51 | $api = new ApiMain( new FauxRequest( array( |
52 | 52 | 'action' => 'edit', |
53 | 53 | 'title' => $talkPage->getFullText(), |
54 | 54 | 'appendtext' => ( $talkPage->exists() ? "\n\n" : '' ) . |
55 | 55 | $feedback_link . "\n" . |
56 | | - '<span id="feedback-dashboard-response-' . $id . '"></span>' . "\n\n" . |
| 56 | + '<span id="feedback-dashboard-response-' . $id . '"> </span>' . "\n\n" . |
57 | 57 | $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"> </span>', |
59 | 59 | 'token' => $params['token'], |
60 | 60 | 'summary' => $summary, |
61 | 61 | 'notminor' => true, |
62 | 62 | ), true, array( 'wsEditToken' => $wgRequest->getSessionData( 'wsEditToken' ) ) ), true ); |
63 | | - |
| 63 | + |
64 | 64 | $api->execute(); |
65 | | - |
| 65 | + |
66 | 66 | $this->restoreUserTalkEmailNotification(); |
67 | | - |
68 | | - global $wgLang; |
69 | | - |
| 67 | + |
| 68 | + global $wgLang; |
| 69 | + |
70 | 70 | $EMailNotif = new MoodBarHTMLEmailNotification(); |
71 | 71 | $EMailNotif->notifyOnRespond( $wgUser, $talkPage, wfTimestampNow(), $item->getProperty('feedback'), $wgLang->truncate( $response, 250 ) ); |
72 | | - |
| 72 | + |
73 | 73 | } |
74 | | - |
| 74 | + |
75 | 75 | $result = array( 'result' => 'success' ); |
76 | | - $this->getResult()->addValue( null, $this->getModuleName(), $result ); |
| 76 | + $this->getResult()->addValue( null, $this->getModuleName(), $result ); |
77 | 77 | } |
78 | | - |
| 78 | + |
79 | 79 | /** |
80 | | - * temporarily disable the talk page email notification |
| 80 | + * temporarily disable the talk page email notification |
81 | 81 | * for user and watchers |
82 | 82 | */ |
83 | 83 | private function disableUserTalkEmailNotification() { |
84 | 84 | global $wgEnotifUserTalk, $wgEnotifWatchlist; |
85 | 85 | |
86 | 86 | $this->EnotifUserTalk = $wgEnotifUserTalk; |
87 | | - $this->EnotifWatchlist = $wgEnotifWatchlist; |
88 | | - |
89 | | - $wgEnotifUserTalk = $wgEnotifWatchlist = false; |
| 87 | + $this->EnotifWatchlist = $wgEnotifWatchlist; |
| 88 | + |
| 89 | + $wgEnotifUserTalk = $wgEnotifWatchlist = false; |
90 | 90 | } |
91 | | - |
| 91 | + |
92 | 92 | /** |
93 | 93 | * restore the default state of talk page email notification |
94 | 94 | */ |
95 | 95 | private function restoreUserTalkEmailNotification() { |
96 | 96 | global $wgEnotifUserTalk, $wgEnotifWatchlist; |
97 | | - |
| 97 | + |
98 | 98 | if ( !is_null( $this->EnotifUserTalk ) ) { |
99 | 99 | $wgEnotifUserTalk = $this->EnotifUserTalk; |
100 | 100 | } |
— | — | @@ -101,7 +101,7 @@ |
102 | 102 | $wgEnotifWatchlist = $this->EnotifWatchlist; |
103 | 103 | } |
104 | 104 | } |
105 | | - |
| 105 | + |
106 | 106 | public function needsToken() { |
107 | 107 | return true; |
108 | 108 | } |
— | — | @@ -160,5 +160,5 @@ |
161 | 161 | public function getDescription() { |
162 | 162 | return 'Allows users to submit response to a feedback about their experiences on the site'; |
163 | 163 | } |
164 | | - |
| 164 | + |
165 | 165 | } |
Index: branches/wmf/1.18wmf1/extensions/MoodBar/MoodBar.hooks.php |
— | — | @@ -15,52 +15,52 @@ |
16 | 16 | |
17 | 17 | return true; |
18 | 18 | } |
19 | | - |
| 19 | + |
20 | 20 | /** |
21 | 21 | * Determines if this user has right to mark an feedback response as helpful, only the user who wrote the |
22 | 22 | * feedback can mark the response as helpful |
23 | 23 | * @param $mahaction string - mark/unmark |
24 | 24 | * @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 |
26 | 26 | * @param $User User Object - the User in current session |
27 | 27 | * @param $isAbleToMark bool - determine whether the user is able to mark the item |
28 | 28 | * @return bool |
29 | 29 | */ |
30 | 30 | public static function onMarkItemAsHelpful( $mahaction, $type, $item, $User, &$isAbleToMark ) { |
31 | | - |
| 31 | + |
32 | 32 | if ( $User->isAnon() ) { |
33 | 33 | $isAbleToMark = false; |
34 | 34 | return true; |
35 | 35 | } |
36 | | - |
| 36 | + |
37 | 37 | if ( $type == 'mbresponse' ) { |
38 | | - |
| 38 | + |
39 | 39 | switch ( $mahaction ) { |
40 | | - |
| 40 | + |
41 | 41 | case 'mark': |
42 | 42 | $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' ), |
45 | 45 | 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 | + |
51 | 51 | if ( $res === false ) { |
52 | 52 | $isAbleToMark = false; |
53 | 53 | } |
54 | | - break; |
55 | | - |
| 54 | + break; |
| 55 | + |
56 | 56 | case 'unmark': |
57 | 57 | default: |
58 | 58 | //We will leve the MarkAsHelpFul extension to check if the user has unmark right |
59 | | - break; |
| 59 | + break; |
60 | 60 | } |
61 | 61 | } |
62 | | - |
| 62 | + |
63 | 63 | return true; |
64 | | - |
| 64 | + |
65 | 65 | } |
66 | 66 | |
67 | 67 | /** |
— | — | @@ -127,45 +127,31 @@ |
128 | 128 | * @param $updater DatabasEUpdater |
129 | 129 | */ |
130 | 130 | 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' ); |
133 | 133 | |
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' ); |
137 | 135 | |
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 | + |
146 | 138 | $updater->addExtensionUpdate( array( 'dropIndex', 'moodbar_feedback', |
147 | | - 'mbf_timestamp', dirname( __FILE__ ) . '/sql/AddIDToIndexes2.sql', true ) |
| 139 | + 'mbf_userid_ip_timestamp', $dir . 'AddIDToIndexes2.sql', true ) |
148 | 140 | ); |
149 | 141 | |
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' ); |
153 | 143 | |
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' ); |
159 | 145 | |
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 | + |
164 | 150 | return true; |
165 | 151 | } |
166 | 152 | |
167 | 153 | /** |
168 | 154 | * 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 |
170 | 156 | * @return array of bucket names |
171 | 157 | */ |
172 | 158 | public static function getUserBuckets( $user ) { |
Index: branches/wmf/1.18wmf1/extensions/MoodBar/sql/MoodBar.sql |
— | — | @@ -1,20 +1,20 @@ |
2 | 2 | CREATE TABLE /*_*/moodbar_feedback ( |
3 | 3 | mbf_id int unsigned NOT NULL PRIMARY KEY auto_increment, -- Primary key |
4 | 4 | mbf_type varchar(32) binary NOT NULL, -- Type of feedback |
5 | | - |
| 5 | + |
6 | 6 | -- User who provided the feedback |
7 | 7 | mbf_user_id int unsigned NOT NULL, -- User ID, or zero |
8 | 8 | mbf_user_ip varchar(255) binary NULL, -- If anonymous, user's IP address |
9 | 9 | mbf_user_editcount int unsigned NOT NULL, -- Edit count of the user |
10 | | - |
| 10 | + |
11 | 11 | -- Page where the feedback was received |
12 | 12 | -- Nullable. |
13 | 13 | mbf_namespace int, |
14 | 14 | mbf_title varchar(255) binary, |
15 | | - |
| 15 | + |
16 | 16 | -- The feedback itself |
17 | 17 | mbf_comment varchar(255) binary, |
18 | | - |
| 18 | + |
19 | 19 | -- Options and context |
20 | 20 | -- Whether or not the feedback item is hidden |
21 | 21 | -- 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 @@ |
2 | 2 | CREATE TABLE /*_*/moodbar_feedback_response ( |
3 | 3 | mbfr_id int unsigned NOT NULL PRIMARY KEY auto_increment, -- Primary key |
4 | | - |
| 4 | + |
5 | 5 | mbfr_mbf_id int unsigned NOT NULL, -- Primary key of moodbar_feedback table |
6 | | - |
| 6 | + |
7 | 7 | -- User who provided the response |
8 | 8 | mbfr_user_id int unsigned NOT NULL, -- User ID, or zero |
9 | 9 | mbfr_user_ip varbinary(40) NULL, -- If anonymous, user's IP address |
10 | | - |
| 10 | + |
11 | 11 | mbfr_commenter_editcount int unsigned NOT NULL, -- number of edit for the user who writes the feedback |
12 | 12 | mbfr_user_editcount int unsigned NOT NULL, -- number of edit for the responder |
13 | | - |
| 13 | + |
14 | 14 | -- The response itself |
15 | 15 | mbfr_response_text text NOT NULL, |
16 | | - |
| 16 | + |
17 | 17 | -- Options and context |
18 | 18 | mbfr_timestamp varchar(14) binary NOT NULL, -- When response was received |
19 | 19 | mbfr_anonymous tinyint unsigned NOT NULL DEFAULT 0, -- Anonymity |
— | — | @@ -23,3 +23,4 @@ |
24 | 24 | ) /*$wgDBTableOptions*/; |
25 | 25 | |
26 | 26 | 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 @@ |
5 | 5 | public function __construct( $query, $moduleName ) { |
6 | 6 | parent::__construct( $query, $moduleName, 'mbc' ); |
7 | 7 | } |
8 | | - |
| 8 | + |
9 | 9 | public function execute() { |
10 | | - global $wgLang, $wgUser; |
| 10 | + global $wgUser; |
11 | 11 | $params = $this->extractRequestParams(); |
12 | 12 | $prop = array_flip( $params['prop'] ); |
13 | | - |
| 13 | + |
14 | 14 | // Build the query |
15 | 15 | $this->addTables( array( 'moodbar_feedback', 'user' ) ); |
16 | 16 | $this->addJoinConds( array( 'user' => array( 'LEFT JOIN', 'user_id=mbf_user_id' ) ) ); |
— | — | @@ -28,40 +28,40 @@ |
29 | 29 | $this->addWhere( 'mbf_user_ip IS NULL' ); |
30 | 30 | } |
31 | 31 | } |
32 | | - |
| 32 | + |
33 | 33 | if ( $params['continue'] !== null ) { |
34 | 34 | $this->applyContinue( $params['continue'], $params['dir'] == 'older' ); |
35 | 35 | } |
36 | | - |
| 36 | + |
37 | 37 | // Add ORDER BY mbf_timestamp {ASC|DESC}, mbf_id {ASC|DESC} |
38 | 38 | $this->addWhereRange( 'mbf_timestamp', $params['dir'], null, null ); |
39 | 39 | $this->addWhereRange( 'mbf_id', $params['dir'], null, null ); |
40 | 40 | $this->addOption( 'LIMIT', $params['limit'] + 1 ); |
41 | | - |
| 41 | + |
42 | 42 | if ( $params['myresponse'] == '1' && !$wgUser->isAnon() ) { |
43 | 43 | $this->addTables( array( 'moodbar_feedback_response' ) ); |
44 | 44 | $this->addJoinConds( array( 'moodbar_feedback_response' => array( 'INNER JOIN', 'mbf_id=mbfr_mbf_id' ) ) ); |
45 | 45 | $this->addWhereFld( 'mbfr_user_id', $wgUser->getId() ); |
46 | 46 | $this->addOption( 'GROUP BY', 'mbf_id' ); |
47 | 47 | } |
48 | | - |
| 48 | + |
49 | 49 | if ( ! $wgUser->isAllowed( 'moodbar-admin' ) ) { |
50 | 50 | $this->addWhereFld( 'mbf_hidden_state', 0 ); |
51 | 51 | } |
52 | | - |
| 52 | + |
53 | 53 | $res = $this->select( __METHOD__ ); |
54 | 54 | $result = $this->getResult(); |
55 | 55 | $count = 0; |
56 | | - |
| 56 | + |
57 | 57 | $response = SpecialFeedbackDashboard::getResponseSummary( $res ); |
58 | | - |
| 58 | + |
59 | 59 | foreach ( $res as $row ) { |
60 | 60 | if ( ++$count > $params['limit'] ) { |
61 | 61 | // We've reached the one extra which shows that there are additional rows. Stop here |
62 | 62 | $this->setContinueEnumParameter( 'continue', $this->getContinue( $row ) ); |
63 | 63 | break; |
64 | 64 | } |
65 | | - |
| 65 | + |
66 | 66 | $vals = $this->extractRowInfo( $row, $prop, $response ); |
67 | 67 | $fit = $result->addValue( array( 'query', $this->getModuleName() ), null, $vals ); |
68 | 68 | if ( !$fit ) { |
— | — | @@ -71,19 +71,19 @@ |
72 | 72 | } |
73 | 73 | $result->setIndexedTagName_internal( array( 'query', $this->getModuleName() ), 'comment' ); |
74 | 74 | } |
75 | | - |
| 75 | + |
76 | 76 | protected function getContinue( $row ) { |
77 | 77 | $ts = wfTimestamp( TS_MW, $row->mbf_timestamp ); |
78 | 78 | return "$ts|{$row->mbf_id}"; |
79 | 79 | } |
80 | | - |
| 80 | + |
81 | 81 | protected function applyContinue( $continue, $sortDesc ) { |
82 | 82 | $vals = explode( '|', $continue, 3 ); |
83 | 83 | if ( count( $vals ) !== 2 ) { |
84 | 84 | // TODO this should be a standard message in ApiBase |
85 | 85 | $this->dieUsage( 'Invalid continue param. You should pass the original value returned by the previous query', 'badcontinue' ); |
86 | 86 | } |
87 | | - |
| 87 | + |
88 | 88 | $db = $this->getDB(); |
89 | 89 | $ts = $db->addQuotes( $db->timestamp( $vals[0] ) ); |
90 | 90 | $id = intval( $vals[1] ); |
— | — | @@ -94,15 +94,15 @@ |
95 | 95 | "mbf_id $op= $id)" |
96 | 96 | ); |
97 | 97 | } |
98 | | - |
| 98 | + |
99 | 99 | protected function extractRowInfo( $row, $prop, $response = array() ) { |
100 | 100 | global $wgUser; |
101 | | - |
| 101 | + |
102 | 102 | $r = array(); |
103 | | - |
| 103 | + |
104 | 104 | $showHidden = isset($prop['hidden']) && $wgUser->isAllowed('moodbar-admin'); |
105 | 105 | $isHidden = $row->mbf_hidden_state > 0; |
106 | | - |
| 106 | + |
107 | 107 | if ( isset( $prop['metadata'] ) ) { |
108 | 108 | $r += array( |
109 | 109 | 'id' => intval( $row->mbf_id ), |
— | — | @@ -115,18 +115,18 @@ |
116 | 116 | } |
117 | 117 | if ( isset( $prop['formatted'] ) ) { |
118 | 118 | $params = array(); |
119 | | - |
| 119 | + |
120 | 120 | if ( $wgUser->isAllowed( 'moodbar-admin' ) ) { |
121 | 121 | $params[] = 'admin'; |
122 | 122 | } |
123 | | - |
| 123 | + |
124 | 124 | if ( $isHidden && $showHidden ) { |
125 | 125 | $params[] = 'show-anyway'; |
126 | 126 | } |
127 | | - |
| 127 | + |
128 | 128 | $r['formatted'] = SpecialFeedbackDashboard::formatListItem( $row, $params, $response ); |
129 | 129 | } |
130 | | - |
| 130 | + |
131 | 131 | if ( $isHidden && !$showHidden ) { |
132 | 132 | unset($r['userid']); |
133 | 133 | unset($r['username']); |
— | — | @@ -134,7 +134,7 @@ |
135 | 135 | ApiResult::setContent( $r, '' ); |
136 | 136 | $r['hidden'] = true; |
137 | 137 | } |
138 | | - |
| 138 | + |
139 | 139 | return $r; |
140 | 140 | } |
141 | 141 | |
— | — | @@ -164,7 +164,7 @@ |
165 | 165 | ApiBase::PARAM_TYPE => 'user', |
166 | 166 | ), |
167 | 167 | 'myresponse' => array( |
168 | | - ApiBase::PARAM_TYPE => array( '1' , '0' ), |
| 168 | + ApiBase::PARAM_TYPE => array( '1' , '0' ), |
169 | 169 | ), |
170 | 170 | 'prop' => array( |
171 | 171 | ApiBase::PARAM_TYPE => array( 'metadata', 'formatted', 'hidden' ), |
— | — | @@ -196,7 +196,7 @@ |
197 | 197 | public function getDescription() { |
198 | 198 | return 'List all feedback comments submitted through the MoodBar extension.'; |
199 | 199 | } |
200 | | - |
| 200 | + |
201 | 201 | public function getCacheMode( $params ) { |
202 | 202 | return isset($params['prop']['hidden']) ? 'private' : 'public'; |
203 | 203 | } |
Index: branches/wmf/1.18wmf1/extensions/MoodBar/FeedbackResponseItem.php |
— | — | @@ -13,17 +13,17 @@ |
14 | 14 | // Feedback response essentials |
15 | 15 | 'id', // ID in the database for response |
16 | 16 | '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 |
18 | 18 | 'user', // user object |
19 | 19 | '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 |
28 | 28 | ); |
29 | 29 | /** |
30 | 30 | * Default constructor. |
— | — | @@ -57,7 +57,7 @@ |
58 | 58 | */ |
59 | 59 | protected function initialiseNew( $info ) { |
60 | 60 | global $wgUser; |
61 | | - |
| 61 | + |
62 | 62 | $template = array( |
63 | 63 | 'user' => $wgUser, |
64 | 64 | 'timestamp' => wfTimestampNow(), |
— | — | @@ -94,12 +94,12 @@ |
95 | 95 | 'system' => 'mbfr_system_type', |
96 | 96 | 'locale' => 'mbfr_locale', |
97 | 97 | 'editmode' => 'mbfr_editing', |
98 | | - 'commenter-editcount', |
99 | | - 'user-editcount' |
| 98 | + 'commenter-editcount', |
| 99 | + 'user-editcount' |
100 | 100 | ); |
101 | | - |
| 101 | + |
102 | 102 | $properties = array(); |
103 | | - |
| 103 | + |
104 | 104 | foreach( $propMappings as $property => $field ) { |
105 | 105 | if ( isset( $row->$field ) ) { |
106 | 106 | $properties[$property] = $row->$field; |
— | — | @@ -117,7 +117,7 @@ |
118 | 118 | } |
119 | 119 | |
120 | 120 | $this->setProperties( $properties ); |
121 | | - |
| 121 | + |
122 | 122 | } |
123 | 123 | |
124 | 124 | /** |
— | — | @@ -205,21 +205,19 @@ |
206 | 206 | * @return The MBFeedbackItem's new ID. |
207 | 207 | */ |
208 | 208 | public function save() { |
209 | | - |
| 209 | + |
210 | 210 | $user = $this->getProperty('user'); |
211 | | - |
| 211 | + |
212 | 212 | // Add edit count if necessary |
213 | | - if ( $this->getProperty('user-editcount') === null && $user !== null ) |
214 | | - { |
| 213 | + if ( $this->getProperty('user-editcount') === null && $user !== null ) { |
215 | 214 | $this->setProperty( 'user-editcount', $user->isAnon() ? 0 : $user->getEditCount() ); |
216 | | - |
217 | | - } |
218 | | - |
| 215 | + } |
| 216 | + |
219 | 217 | if($this->getProperty('commenter-editcount') === null) { |
220 | 218 | $commenter = $this->getProperty('feedbackitem')->getProperty('user'); |
221 | 219 | $this->setProperty( 'commenter-editcount', $commenter->isAnon() ? 0 : $commenter->getEditCount() ); |
222 | 220 | } |
223 | | - |
| 221 | + |
224 | 222 | $dbw = wfGetDB( DB_MASTER ); |
225 | 223 | |
226 | 224 | $row = array( |
— | — | @@ -237,8 +235,7 @@ |
238 | 236 | if($user->isAnon()) { |
239 | 237 | $row['mbfr_user_id'] = 0; |
240 | 238 | $row['mbfr_user_ip'] = $user->getName(); |
241 | | - } |
242 | | - else { |
| 239 | + } else { |
243 | 240 | $row['mbfr_user_id'] = $user->getId(); |
244 | 241 | } |
245 | 242 | |
— | — | @@ -260,7 +257,7 @@ |
261 | 258 | public static function getValidTypes() { |
262 | 259 | return self::$validTypes; |
263 | 260 | } |
264 | | - |
| 261 | + |
265 | 262 | /** |
266 | 263 | * Set the Feedback Item this Response is associated to |
267 | 264 | * @param $mbf_id mbfr_mbf_id in moodbar_feedback_response table |
— | — | @@ -268,17 +265,17 @@ |
269 | 266 | */ |
270 | 267 | protected function setFeedbackItem($mbf_id) { |
271 | 268 | $dbr = wfGetDB( DB_SLAVE ); |
272 | | - |
| 269 | + |
273 | 270 | $row = $dbr->selectRow( 'moodbar_feedback', '*', |
274 | 271 | array( 'mbf_id' => $mbf_id ), __METHOD__ ); |
275 | | - |
| 272 | + |
276 | 273 | if( $row !== false ) { |
277 | | - $this->setProperties( array ( 'feedbackitem' => MBFeedbackItem::load( $row ) ) ); |
| 274 | + $this->setProperties( array ( 'feedbackitem' => MBFeedbackItem::load( $row ) ) ); |
278 | 275 | return true; |
279 | 276 | } |
280 | 277 | else { |
281 | | - return false; |
282 | | - } |
| 278 | + return false; |
| 279 | + } |
283 | 280 | } |
284 | 281 | |
285 | 282 | } |
Index: branches/wmf/1.18wmf1/extensions/MoodBar/MoodBar.php |
— | — | @@ -16,6 +16,7 @@ |
17 | 17 | // Object model |
18 | 18 | $wgAutoloadClasses['MBFeedbackItem'] = dirname(__FILE__).'/FeedbackItem.php'; |
19 | 19 | $wgAutoloadClasses['MBFeedbackResponseItem'] = dirname(__FILE__).'/FeedbackResponseItem.php'; |
| 20 | +$wgAutoloadClasses['MWFeedbackResponseItemPropertyException'] = dirname(__FILE__).'/FeedbackResponseItem.php'; |
20 | 21 | $wgAutoloadClasses['MoodBarFormatter'] = dirname(__FILE__).'/Formatter.php'; |
21 | 22 | $wgAutoloadClasses['MoodBarHTMLEmailNotification'] = dirname(__FILE__).'/include/MoodBarHTMLEmailNotification.php'; |
22 | 23 | $wgAutoloadClasses['MoodBarHTMLMailerJob'] = dirname( __FILE__ ) . '/include/MoodBarHTMLMailerJob.php'; |
— | — | @@ -30,6 +31,7 @@ |
31 | 32 | $wgAutoloadClasses['ApiFeedbackDashboardResponse'] = dirname(__FILE__).'/ApiFeedbackDashboardResponse.php'; |
32 | 33 | $wgAPIModules['feedbackdashboardresponse'] = 'ApiFeedbackDashboardResponse'; |
33 | 34 | $wgAutoloadClasses['ApiMoodBarSetUserEmail'] = dirname(__FILE__).'/ApiMoodBarSetUserEmail.php'; |
| 35 | +$wgAutoloadClasses['MWApiMoodBarSetUserEmailInvalidActionException'] = dirname(__FILE__).'/ApiMoodBarSetUserEmail.php'; |
34 | 36 | $wgAPIModules['moodbarsetuseremail'] = 'ApiMoodBarSetUserEmail'; |
35 | 37 | |
36 | 38 | // Hooks |
— | — | @@ -209,11 +211,11 @@ |
210 | 212 | 'response-back-text', |
211 | 213 | 'response-preview-text', |
212 | 214 | 'response-preview-text', |
213 | | - 'response-ajax-action-head', |
| 215 | + 'response-ajax-action-head', |
214 | 216 | 'response-ajax-action-body', |
215 | 217 | 'response-ajax-success-head', |
216 | 218 | 'response-ajax-success-body', |
217 | | - 'response-ajax-error-head', |
| 219 | + 'response-ajax-error-head', |
218 | 220 | 'response-ajax-error-body', |
219 | 221 | ), |
220 | 222 | ); |
— | — | @@ -253,4 +255,5 @@ |
254 | 256 | 'infoUrl' => 'http://www.mediawiki.org/wiki/MoodBar', |
255 | 257 | 'privacyUrl' => 'about:blank', |
256 | 258 | 'disableExpiration' => 365, |
257 | | -); |
\ No newline at end of file |
| 259 | +); |
| 260 | + |
Property changes on: branches/wmf/1.18wmf1/extensions/MoodBar |
___________________________________________________________________ |
Modified: svn:mergeinfo |
258 | 261 | Merged /trunk/extensions/MoodBar:r107520-107527 |