Index: trunk/extensions/MoodBar/MoodBar.hooks.php |
— | — | @@ -7,7 +7,6 @@ |
8 | 8 | * @param $output OutputPage |
9 | 9 | * @param $skin Skin |
10 | 10 | */ |
11 | | - |
12 | 11 | public static function onPageDisplay( &$output, &$skin ) { |
13 | 12 | if ( self::shouldShowMoodbar( $output, $skin ) ) { |
14 | 13 | $output->addModules( array( 'ext.moodBar.init', 'ext.moodBar.tooltip', 'ext.moodBar.core' ) ); |
— | — | @@ -27,31 +26,28 @@ |
28 | 27 | * @return bool |
29 | 28 | */ |
30 | 29 | public static function onMarkItemAsHelpful( $mahaction, $type, $item, $User, &$isAbleToMark ) { |
31 | | - |
32 | 30 | if ( $User->isAnon() ) { |
33 | 31 | $isAbleToMark = false; |
34 | 32 | return true; |
35 | 33 | } |
36 | 34 | |
37 | 35 | if ( $type == 'mbresponse' ) { |
38 | | - |
39 | 36 | switch ( $mahaction ) { |
40 | | - |
41 | 37 | case 'mark': |
42 | 38 | $dbr = wfGetDB( DB_SLAVE ); |
43 | 39 | |
44 | | - $res = $dbr->selectRow( array( 'moodbar_feedback', 'moodbar_feedback_response' ), |
45 | | - array( 'mbf_id' ), |
46 | | - array( 'mbf_id = mbfr_mbf_id', |
47 | | - 'mbfr_id' => intval( $item ), |
48 | | - 'mbf_user_id' => $User->getId() |
49 | | - ), __METHOD__ ); |
| 40 | + $res = $dbr->selectRow( |
| 41 | + array( 'moodbar_feedback', 'moodbar_feedback_response' ), |
| 42 | + array( 'mbf_id' ), |
| 43 | + array( 'mbf_id = mbfr_mbf_id', |
| 44 | + 'mbfr_id' => intval( $item ), |
| 45 | + 'mbf_user_id' => $User->getId() |
| 46 | + ), __METHOD__ ); |
50 | 47 | |
51 | 48 | if ( $res === false ) { |
52 | 49 | $isAbleToMark = false; |
53 | 50 | } |
54 | 51 | break; |
55 | | - |
56 | 52 | case 'unmark': |
57 | 53 | default: |
58 | 54 | //We will leve the MarkAsHelpFul extension to check if the user has unmark right |
— | — | @@ -60,7 +56,6 @@ |
61 | 57 | } |
62 | 58 | |
63 | 59 | return true; |
64 | | - |
65 | 60 | } |
66 | 61 | |
67 | 62 | /** |
— | — | @@ -78,9 +73,9 @@ |
79 | 74 | if ( $skin->getSkinName() !== 'vector' ) { |
80 | 75 | return false; |
81 | 76 | } |
| 77 | + |
82 | 78 | global $wgUser; |
83 | 79 | $user = $wgUser; |
84 | | - |
85 | 80 | if ( $user->isAnon() ) { |
86 | 81 | return false; |
87 | 82 | } |
— | — | @@ -128,22 +123,20 @@ |
129 | 124 | */ |
130 | 125 | public static function onLoadExtensionSchemaUpdates( $updater = null ) { |
131 | 126 | $dir = dirname(__FILE__) . '/sql'; |
132 | | - $updater->addExtensionTable( 'moodbar_feedback', "$dir/MoodBar.sql" ); |
133 | 127 | |
| 128 | + $updater->addExtensionTable( 'moodbar_feedback', "$dir/MoodBar.sql" ); |
134 | 129 | $updater->addExtensionField( 'moodbar_feedback', 'mbf_user_editcount', "$dir/mbf_user_editcount.sql" ); |
135 | | - |
136 | 130 | $updater->addExtensionIndex( 'moodbar_feedback', 'mbf_type_timestamp_id', "$dir/AddIDToIndexes.sql" ); |
| 131 | + $updater->addExtensionUpdate( array( |
| 132 | + 'dropIndex', |
| 133 | + 'moodbar_feedback', |
| 134 | + 'mbf_userid_ip_timestamp', |
| 135 | + "$dir/AddIDToIndexes2.sql", true |
| 136 | + ) ); |
137 | 137 | |
138 | | - $updater->addExtensionUpdate( array( 'dropIndex', 'moodbar_feedback', |
139 | | - 'mbf_userid_ip_timestamp', "$dir/AddIDToIndexes2.sql", true ) |
140 | | - ); |
141 | | - |
142 | 138 | $updater->addExtensionIndex( 'moodbar_feedback', 'mbfr_timestamp_id', "$dir/mbf_timestamp_id.sql" ); |
143 | | - |
144 | 139 | $updater->addExtensionField( 'moodbar_feedback', 'mbf_hidden_state', "$dir/mbf_hidden_state.sql" ); |
145 | | - |
146 | 140 | $updater->addExtensionTable( 'moodbar_feedback_response', "$dir/moodbar_feedback_response.sql" ); |
147 | | - |
148 | 141 | $updater->addExtensionIndex( 'moodbar_feedback_response', 'mbfr_timestamp_id', "$dir/mbfr_timestamp_id_index.sql" ); |
149 | 142 | |
150 | 143 | return true; |