- Timestamp:
- Apr 4, 2009, 6:47:22 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-content/plugins/xpressme/include/xpress_common_functions.php
r147 r155 235 235 } 236 236 237 function xpress_set_author_cookie() 238 { 239 $author_cookie = get_xpress_dir_name() . "_select_author" ; 240 if(xpress_is_multi_user()){ 241 if (empty($_GET)){ 242 // $GLOBALS["wp_xoops_author"] = null; 243 setcookie($author_cookie, 0); 244 $_COOKIE[$author_cookie] = 0; 245 246 } else { 247 $auth = intval( @$_GET["author"] ); 248 if ($auth > 0){ 249 setcookie($author_cookie, $auth); 250 $_COOKIE[$author_cookie] = $auth; 251 } 252 } 253 }else{ 254 // $GLOBALS["wp_xoops_author"] = null; 255 setcookie($author_cookie, 0); 256 $_COOKIE[$author_cookie] = 0; 257 } 258 } 259 260 function xpress_query_filter(&$query) 261 { 262 $author_cookie = get_xpress_dir_name() . "_select_author" ; 263 264 if (strpos($query,'SELECT') !==0) return $query; 265 266 $select_pattern = "SELECT(.*)post_author(.*)FROM"; 267 if (preg_match ( "/".$select_pattern."/i", $query, $select_match )) 268 return $query; 269 270 $query = preg_replace('/\s\s+/', ' ', $query); 271 if (!empty($_COOKIE[$author_cookie])){ 272 $pattern = "WHERE(.*)post_type(.*)=(.*)'post'"; 273 if ( preg_match ( "/".$pattern."/i", $query, $match ) ){ 274 $where_str = "$match[0]"; 275 $where_arry = split(' ',$where_str); 276 $post_prefix = ''; 277 foreach ($where_arry as $p){ 278 if ( preg_match ( "/post_type/", $p, $match3 ) ){ 279 $post_prefix = preg_replace("/post_type/", "", $p); 280 break; 281 } 282 } 283 preg_match ( "/post_type(.*)/", $where_str, $p_match ); 284 $patern = $p_match[0]; 285 $replace = $patern . " AND {$post_prefix}post_author = " . intval($_COOKIE[$author_cookie]) . " "; 286 $query = preg_replace("/$patern/", $replace, $query); 287 } 288 } 289 // xpress_show_sql_quary($query); 290 return $query; 291 } 237 292 ?>
Note: See TracChangeset
for help on using the changeset viewer.