Changeset 2362 in ExiteCMS for trunk/includes/ajax.response.php
- Timestamp:
- 07/29/10 16:45:09 (22 months ago)
- File:
-
- 1 edited
-
trunk/includes/ajax.response.php (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/includes/ajax.response.php
r2164 r2362 89 89 // make sure we have json_encode and json_decode available 90 90 require_once "json_include.php"; 91 header("Content-Type:application/json; charset=utf-8"); 91 92 if (iMEMBER) { 92 93 // return the user record datastore … … 104 105 } 105 106 } 107 break; 108 case "counters": 109 if (!iMEMBER) { 110 $pms = $posts = 0; 111 $pmtext = $posttext = ""; 112 } else { 113 $pms = dbcount("(pmindex_id)", "pm_index", "pmindex_user_id='".$userdata['user_id']."' AND pmindex_to_id='".$userdata['user_id']."' AND pmindex_read_datestamp = '0'"); 114 if ($pms == 1) { 115 $pmtext = sprintf($locale['085'], $pms); 116 } else { 117 $pmtext = sprintf($locale['086'], $pms); 118 } 119 if ($userdata['user_posts_unread']) { 120 $result = dbquery(" 121 SELECT count(*) as unread 122 FROM ".$db_prefix."posts p 123 INNER JOIN ".$db_prefix."forums f ON p.forum_id = f.forum_id 124 INNER JOIN ".$db_prefix."threads_read tr ON p.thread_id = tr.thread_id 125 WHERE ".groupaccess('f.forum_access')." 126 AND tr.user_id = '".$userdata['user_id']."' 127 AND (p.post_datestamp > ".$settings['unread_threshold']." OR p.post_edittime > ".$settings['unread_threshold'].") 128 AND ((p.post_datestamp > tr.thread_last_read OR p.post_edittime > tr.thread_last_read) 129 OR (p.post_datestamp < tr.thread_first_read OR (p.post_edittime != 0 AND p.post_edittime < tr.thread_first_read)))" 130 ); 131 } else { 132 $result = dbquery(" 133 SELECT count(*) as unread 134 FROM ".$db_prefix."posts p 135 INNER JOIN ".$db_prefix."forums f ON p.forum_id = f.forum_id 136 INNER JOIN ".$db_prefix."threads_read tr ON p.thread_id = tr.thread_id 137 WHERE ".groupaccess('f.forum_access')." 138 AND tr.user_id = '".$userdata['user_id']."' 139 AND p.post_author != '".$userdata['user_id']."' 140 AND p.post_edituser != '".$userdata['user_id']."' 141 AND (p.post_datestamp > ".$settings['unread_threshold']." OR p.post_edittime > ".$settings['unread_threshold'].") 142 AND ((p.post_datestamp > tr.thread_last_read OR p.post_edittime > tr.thread_last_read) 143 OR (p.post_datestamp < tr.thread_first_read OR (p.post_edittime != 0 AND p.post_edittime < tr.thread_first_read)))" 144 ); 145 } 146 $posts = ($result ? mysql_result($result, 0) : 0); 147 if ($posts == 1) { 148 $posttext = sprintf($locale['088'], $posts); 149 } else { 150 $posttext = sprintf($locale['089'], $posts); 151 } 152 } 153 // make sure we have json_encode and json_decode available 154 require_once "json_include.php"; 155 // send the results back 156 header("Content-Type:application/json; charset=utf-8"); 157 echo json_encode(array('pmcount' => $pms, 'pmtext' => $pmtext, 'postcount' => $posts, 'posttext' => $posttext)); 106 158 break; 107 159 case "pm": … … 211 263 mysql_close(); 212 264 } 213 ?>
Note: See TracChangeset
for help on using the changeset viewer.
