XPressME Integration Kit

Trac


Ignore:
Timestamp:
Apr 4, 2009, 6:47:22 PM (15 years ago)
Author:
toemon
Message:

#14 マルチユーザーモードの実装

Location:
trunk/wp-content/plugins/xpressme/include
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-content/plugins/xpressme/include/custom_functions.php

    r154 r155  
    11<?php 
     2function xpress_selected_author($show=true ) { 
     3        $output = ''; 
     4        $author_cookie = get_xpress_dir_name() . "_select_author" ; 
     5        if (!empty($_COOKIE[$author_cookie])){ 
     6                $uid = intval($_COOKIE[$author_cookie]); 
     7                $user_info = get_userdata($uid); 
     8                $output = $user_info->display_name; 
     9        } 
     10        if (empty($show)) 
     11                return $output; 
     12        else 
     13                echo $output; 
     14                 
     15} 
    216         
    317function xpress_list_pings($trackback, $args, $depth) { 
     
    199213} 
    200214 
     215function xpress_is_multi_user(){ 
     216        global $xpress_config; 
     217        return $xpress_config->is_multi_user; 
     218} 
     219 
     220 
    201221function xpress_substr($str, $start, $length, $trimmarker = '...') 
    202222{ 
     
    352372function xpress_conditional_title($display = true) 
    353373{ 
     374        $selected_author = xpress_selected_author(false); 
     375         
    354376        $output = __('Main', 'xpressme'); 
    355377        if (is_category()) 
     
    363385        if (is_year()) 
    364386                $output = sprintf(__('Archive for %s|Yearly archive page', 'xpressme'), get_the_time(__('Y', 'xpressme'))); 
    365         if (is_author()) 
    366                 $output = sprintf(__('Archive for the &#8216;%s&#8217; Author', 'xpressme'), get_author_name( get_query_var('author'))); 
     387        if (is_author()){ 
     388                if (empty($selected_author)) 
     389                        $output = sprintf(__('Archive for the &#8216;%s&#8217; Author', 'xpressme'), get_author_name( get_query_var('author'))); 
     390        } 
    367391        if (is_search()) 
    368392                $output = sprintf(__('Search Results of word &#8216;%s&#8217;', 'xpressme'), get_search_query()); 
     393         
     394        if (!empty($selected_author)) 
     395        $output = sprintf(__('Article of %s', 'xpressme'), $selected_author) . ' - ' . $output; 
    369396                 
    370397        if ($display)  
  • trunk/wp-content/plugins/xpressme/include/xpress_common_functions.php

    r147 r155  
    235235} 
    236236 
     237function 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 
     260function 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} 
    237292?> 
Note: See TracChangeset for help on using the changeset viewer.