Changeset 1310 in ExiteCMS for trunk/forum/viewthread.php
- Timestamp:
- 02/27/08 10:29:52 (4 years ago)
- File:
-
- 1 edited
-
trunk/forum/viewthread.php (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/forum/viewthread.php
r1307 r1310 194 194 // include the users own posts 195 195 $result = dbquery(" 196 SELECT count(*) as unread, tr.thread_ last_read196 SELECT count(*) as unread, tr.thread_first_read, tr.thread_last_read 197 197 FROM ".$db_prefix."posts p 198 198 LEFT JOIN ".$db_prefix."threads_read tr ON p.thread_id = tr.thread_id … … 200 200 AND tr.thread_id = '".$thread_id."' 201 201 AND (p.post_datestamp > ".$settings['unread_threshold']." OR p.post_edittime > ".$settings['unread_threshold'].") 202 AND (p.post_datestamp > tr.thread_last_read OR p.post_edittime > tr.thread_last_read) 202 AND ((p.post_datestamp > tr.thread_last_read OR p.post_edittime > tr.thread_last_read) 203 OR (p.post_datestamp < tr.thread_first_read OR (p.post_edittime != 0 AND p.post_edittime < tr.thread_first_read))) 203 204 GROUP BY tr.thread_id 204 205 "); … … 206 207 // filter the users own posts 207 208 $result = dbquery(" 208 SELECT count(*) as unread, tr.thread_ last_read209 SELECT count(*) as unread, tr.thread_first_read, tr.thread_last_read 209 210 FROM ".$db_prefix."posts p 210 211 LEFT JOIN ".$db_prefix."threads_read tr ON p.thread_id = tr.thread_id … … 214 215 AND tr.thread_id = '".$thread_id."' 215 216 AND (p.post_datestamp > ".$settings['unread_threshold']." OR p.post_edittime > ".$settings['unread_threshold'].") 216 AND (p.post_datestamp > tr.thread_last_read OR p.post_edittime > tr.thread_last_read) 217 AND ((p.post_datestamp > tr.thread_last_read OR p.post_edittime > tr.thread_last_read) 218 OR (p.post_datestamp < tr.thread_first_read OR (p.post_edittime != 0 AND p.post_edittime < tr.thread_first_read))) 217 219 GROUP BY tr.thread_id 218 220 "); … … 221 223 $data = dbarray($result); 222 224 $variables['unread_posts'] = $data['unread']; 225 $thread_first_read = $data['thread_first_read']; 223 226 $thread_last_read = $data['thread_last_read']; 224 227 } else { 225 228 $variables['unread_posts'] = 0; 229 $thread_first_read = 0; 226 230 $thread_last_read = time(); 227 231 } 228 232 } else { 229 233 $variables['unread_posts'] = 0; 234 $thread_first_read = 0; 230 235 $thread_last_read = time(); 231 236 } … … 243 248 $variables['thread_has_poll'] = fpm_view(); 244 249 245 // last_post_datestamp, needed to update threads_read later 250 // init first_post_datestamp, needed to update threads_read later 251 $first_post_datestamp = 4294967295; 252 253 // init last_post_datestamp, needed to update threads_read later 246 254 $last_post_datestamp = 0; 247 255 … … 278 286 } 279 287 // check if this post is read or unread 280 $data['unread'] = $data['post_datestamp'] > $thread_last_read || $data['post_edittime'] > $thread_last_read; 288 $data['unread'] = $data['post_datestamp'] > $thread_last_read || $data['post_edittime'] > $thread_last_read || $data['post_datestamp'] < $thread_first_read || ($data['post_edittime'] != 0 && $data['post_edittime'] < $thread_first_read) ; 289 290 // update first_post_datestamp 291 if ($data['post_edittime'] == 0) { 292 $first_post_datestamp = min($data['post_datestamp'], $first_post_datestamp); 293 } else { 294 $first_post_datestamp = min($data['post_datestamp'], $data['post_edittime'], $first_post_datestamp); 295 } 281 296 282 297 // update last_post_datestamp … … 392 407 } 393 408 394 // update the threads_read record for this user and thread when the last_post_datestamp is newer 395 if (iMEMBER && $last_post_datestamp) { 396 $result = dbquery("UPDATE ".$db_prefix."threads_read SET thread_last_read = '".$last_post_datestamp."' WHERE user_id = '".$userdata['user_id']."' AND thread_id = '".$thread_id."' AND thread_last_read < '".$last_post_datestamp."'"); 409 if (iMEMBER) { 410 // update the threads_read record for this user and thread when the first_post_datestamp is older 411 if ($first_post_datestamp) { 412 $result = dbquery("UPDATE ".$db_prefix."threads_read SET thread_first_read = '".$first_post_datestamp."' WHERE user_id = '".$userdata['user_id']."' AND thread_id = '".$thread_id."' AND thread_first_read > '".$first_post_datestamp."'"); 413 } 414 // update the threads_read record for this user and thread when the last_post_datestamp is newer 415 if ($last_post_datestamp) { 416 $result = dbquery("UPDATE ".$db_prefix."threads_read SET thread_last_read = '".$last_post_datestamp."' WHERE user_id = '".$userdata['user_id']."' AND thread_id = '".$thread_id."' AND thread_last_read < '".$last_post_datestamp."'"); 417 } 397 418 } 398 419
Note: See TracChangeset
for help on using the changeset viewer.
