Index: trunk/extensions/LiquidThreads/classes/LqtNewMessages.php |
— | — | @@ -60,25 +60,39 @@ |
61 | 61 | $rootWhere = $dbw->makeList( $rootWhere, LIST_AND ); |
62 | 62 | |
63 | 63 | $where_clause = $dbw->makeList( array( $talkpageWhere, $rootWhere ), LIST_OR ); |
| 64 | + |
| 65 | + // <= 1.15 compatibility, it kinda sucks having to do all this up here. |
| 66 | + $tables = array( 'watchlist', 'user_message_state' ); |
| 67 | + $joins = array( 'user_message_state' => |
| 68 | + array( 'left join', |
| 69 | + array( 'ums_user=wl_user', 'ums_thread' => $t->id() ) ) ); |
| 70 | + $fields = array( 'wl_user', 'ums_user', 'ums_read_timestamp' ); |
| 71 | + |
| 72 | + $oldPrefCompat = false; |
| 73 | + global $wgVersion; |
| 74 | + if ( version_compare( $wgVersion, '1.15', '<=' ) ) { |
| 75 | + $oldPrefCompat = true; |
| 76 | + |
| 77 | + $tables[] = 'user'; |
| 78 | + $joins['user'] = array( 'left join', 'user_id=wl_user' ); |
| 79 | + $fields[] = 'user_options'; |
| 80 | + } else { |
| 81 | + $tables[] = 'user_properties'; |
| 82 | + $joins['user_properties'] = |
| 83 | + array( |
| 84 | + 'left join', |
| 85 | + array( 'up_user=wl_user', |
| 86 | + 'up_property' => 'lqtnotifytalk', |
| 87 | + ) |
| 88 | + ); |
| 89 | + $fields[] = 'up_value'; |
| 90 | + } |
64 | 91 | |
65 | 92 | // Pull users to update the message state for, including whether or not a |
66 | 93 | // user_message_state row exists for them, and whether or not to send an email |
67 | 94 | // notification. |
68 | 95 | $dbr = wfGetDB( DB_SLAVE ); |
69 | | - $res = $dbr->select( array( 'watchlist', 'user_message_state', 'user_properties' ), |
70 | | - array( 'wl_user', 'ums_user', 'ums_read_timestamp', 'up_value' ), |
71 | | - $where_clause, __METHOD__, array(), |
72 | | - array( 'user_message_state' => |
73 | | - array( 'left join', array( 'ums_user=wl_user', |
74 | | - 'ums_thread' => $t->id() ) ), |
75 | | - 'user_properties' => array( |
76 | | - 'left join', |
77 | | - array( 'up_user=wl_user', |
78 | | - 'up_property' => 'lqtnotifytalk', |
79 | | - ) |
80 | | - ), |
81 | | - ) |
82 | | - ); |
| 96 | + $res = $dbr->select( $tables, $fields, $where_clause, __METHOD__, array(), $joins); |
83 | 97 | |
84 | 98 | $insert_rows = array(); |
85 | 99 | $update_tuples = array(); |
— | — | @@ -99,8 +113,20 @@ |
100 | 114 | ); |
101 | 115 | } |
102 | 116 | |
103 | | - if ( ( is_null($row->up_value) && User::getDefaultOption( 'lqtnotifytalk' ) ) |
104 | | - || $row->up_value ) { |
| 117 | + $wantsTalkNotification = false; |
| 118 | + |
| 119 | + if ( $oldPrefCompat ) { |
| 120 | + $decodedOptions = self::decodeUserOptions( $row->user_options ); |
| 121 | + |
| 122 | + $wantsTalkNotification = ( is_null( $decodedOptions['lqtnotifytalk'] ) && |
| 123 | + User::getDefaultOption( 'lqtnotifytalk' ) ) || $row->up_value; |
| 124 | + } else { |
| 125 | + $wantsTalkNotification = |
| 126 | + (is_null($row->up_value) && User::getDefaultOption( 'lqtnotifytalk' ) ) |
| 127 | + || $row->up_value; |
| 128 | + } |
| 129 | + |
| 130 | + if ( $wantsTalkNotification ) { |
105 | 131 | $notify_users[] = $row->wl_user; |
106 | 132 | } |
107 | 133 | } |
— | — | @@ -134,6 +160,21 @@ |
135 | 161 | } |
136 | 162 | } |
137 | 163 | |
| 164 | + // Would refactor User::decodeOptions, but the whole point is that this is |
| 165 | + // compatible with old code :) |
| 166 | + static function decodeUserOptions( $str ) { |
| 167 | + $opts = array(); |
| 168 | + $a = explode( "\n", $str ); |
| 169 | + foreach ( $a as $s ) { |
| 170 | + $m = array(); |
| 171 | + if ( preg_match( "/^(.[^=]*)=(.*)$/", $s, $m ) ) { |
| 172 | + $opts[$m[1]] = $m[2]; |
| 173 | + } |
| 174 | + } |
| 175 | + |
| 176 | + return $opts; |
| 177 | + } |
| 178 | + |
138 | 179 | static function notifyUsersByMail( $t, $watching_users, $timestamp, $type ) { |
139 | 180 | wfLoadExtensionMessages( 'LiquidThreads' ); |
140 | 181 | $messages = array( |
Index: trunk/extensions/LiquidThreads/pages/TalkpageView.php |
— | — | @@ -407,7 +407,9 @@ |
408 | 408 | function getNavigationBar() { |
409 | 409 | global $wgStylePath, $wgContLang; |
410 | 410 | |
411 | | - if ( !$this->isNavigationBarShown() ) return ''; |
| 411 | + if ( method_exists( $this, 'isNavigationBarShown' ) && |
| 412 | + !$this->isNavigationBarShown() ) |
| 413 | + return ''; |
412 | 414 | |
413 | 415 | $path = "$wgStylePath/common/images"; |
414 | 416 | $labels = array( |