XPressME Integration Kit

Trac

Changeset 96 for trunk/include


Ignore:
Timestamp:
Mar 6, 2009, 5:16:22 PM (15 years ago)
Author:
toemon
Message:

途中経過でインストール、アップデートできなくなってしまっていたバグ修正
イベント通知の部分をFix、(ゲストのモジュールアクセス権限がないと通知できないのは直らない)
ブロックのキャッシュを見直し、キャッシュがない場合と、ブロックオプションが変更された場合にリフレッシュする機能を追加
ブロックキャッシュの更新にてポスト削除時のイベントをDB削除前にとっていたバグを修正。

Location:
trunk/include
Files:
1 deleted
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/oninstall.php

    r89 r96  
    5151        wp_cache_flush(); 
    5252        make_db_current_silent(); 
     53        $ret[] = "The data base of wordpress was made by prefix $table_prefix."; 
    5354         
    5455        $option_desc = __('WordPress web address'); 
     
    6768        update_option("home", $site_url); 
    6869        update_option("siteurl", $site_url); 
     70        update_option("what_to_show", "posts"); 
     71        update_option('default_pingback_flag', 0); 
     72        $ret[] = 'The initial data was written in the data base of wordpress.'; 
     73         
    6974        update_option("template", "xpress_default"); 
    7075        update_option("stylesheet", "xpress_default"); 
    71         update_option("what_to_show", "posts"); 
    72  
     76        $ret[] = 'The default theme of wordpress was set to xpress_default.'; 
    7377        /* add new option for uploads */ 
    7478//      update_option('uploads_use_yearmonth_folders', 1); 
    7579//      update_option('upload_path', $module->getVar("dirname")); 
    7680         
     81                 
     82// Admin User Data write 
     83        // Change uid field 
     84        $wpdb->query("ALTER TABLE $wpdb->posts CHANGE `post_author` `post_author` mediumint(8) NOT NULL DEFAULT '0'"); 
     85        $user_name = is_object($GLOBALS["xoopsUser"])?$GLOBALS["xoopsUser"]->getVar("uname"):'admin'; 
     86        $email = is_object($GLOBALS["xoopsUser"])?$GLOBALS["xoopsUser"]->getVar("email"):'foo@exsample.com'; 
     87        $pass_md5 = is_object($GLOBALS["xoopsUser"])?$GLOBALS["xoopsUser"]->getVar("pass"):''; 
     88         
     89        $user_id = username_exists($user_name); 
     90        if ( !$user_id ) { 
     91                $random_password = 'admin'; 
     92                $user_id = wp_create_user($user_name, $random_password, $email); 
     93        } else { 
     94                $random_password = __('User already exists.  Password inherited.'); 
     95        } 
     96 
     97        $user = new WP_User($user_id); 
     98        $user->set_role('administrator'); 
     99        'User ' . $user_name . ' of the administrator was made.'; 
     100        // over write xoops md5 password  
     101        $sql = "UPDATE $wpdb->users SET user_pass ='$pass_md5' WHERE ID = $user_id"; 
     102        $wpdb->query($sql); 
     103        $ret[] = 'The password of XOOPS was copied.'; 
     104        // Set Default data 
     105        wp_install_defaults($user_id); 
     106        $ret[] = 'The first sample post & comment was written.'; 
     107//          generate_page_uri_index(); 
     108 
    77109        /* activate the XPressME plugin */ 
    78110        $plugin_current = "xpressme/xpressme.php"; 
     
    80112        include_once(dirname(__FILE__) . '/../wp-content/plugins/'.$plugin_current); 
    81113        do_action('activate_'.$plugin_current); 
    82                  
    83 // Admin User Data write 
    84         // Change uid field 
    85         $wpdb->query("ALTER TABLE $wpdb->posts CHANGE `post_author` `post_author` mediumint(8) NOT NULL DEFAULT '0'"); 
    86         $ID = is_object($GLOBALS["xoopsUser"])?$GLOBALS["xoopsUser"]->getVar("uid"):1; 
    87 //      require_once($mydirpath . '/include/user_sync.php'); 
    88         $sync_messg = ''; 
    89 //      user_sync_to_wordpress($ID,$sync_messg);                //this function in XPressME plugin  
    90  
    91         // Set Default data 
    92                 wp_install_defaults($ID); 
    93 //          generate_page_uri_index(); 
    94  
    95                  
     114        $ret[] = 'The xpressme plug-in was activated.'; 
     115         
    96116        // create views table 
    97117        $xp_prefix = $mydirname; 
     
    115135 
    116136        dbDelta($views_queries); 
     137        $ret[] = "$views_table table of XPressME was made."; 
     138 
    117139         
    118140        $d3forum_link = XOOPS_DB_PREFIX . '_' . $xp_prefix .'_d3forum_link' ; 
     
    124146                )$charset_collate;"; 
    125147        dbDelta($views_queries); 
     148        $ret[] = "$d3forum_link table of XPressME was made."; 
    126149         
    127150        $group_role = XOOPS_DB_PREFIX . '_' . $xp_prefix .'_group_role' ; 
     
    136159                )$charset_collate;"; 
    137160        dbDelta($views_queries); 
     161        $ret[] = "$group_role table of XPressME was made."; 
     162 
    138163        $sql = "INSERT INTO $group_role (groupid, role) VALUES (1, 'administrator')"; 
    139164        $wpdb->query($sql); 
  • trunk/include/onupdate.php

    r89 r96  
    4646                }                                
    4747        } 
     48 
    4849        /* activate the tag plugin */ 
    4950        $plugin_current = "xpressme/xpressme.php"; 
  • trunk/include/request_url.php

    r95 r96  
    1313 */ 
    1414function check_page_call($check_file =''){ 
    15         global $xoops_config; 
     15        global $xoops_config;   // not object at install 
    1616        if (empty($check_file)) return false; 
    17         $xpress_page =  $xoops_config->module_name . '/' . $check_file; 
     17        $xpress_page =  basename(dirname(dirname(__FILE__))) . '/' . $check_file; 
    1818        $php_script_name = $_SERVER['SCRIPT_NAME']; 
    1919        $php_query_string = $_SERVER['QUERY_STRING']; 
     
    4949        return $ret; 
    5050} 
     51 
     52function is_xpress_install_call(){ 
     53        $action = 'action=ModuleInstall&dirname='; 
     54        $php_script_name = $_SERVER['SCRIPT_NAME']; 
     55        $php_query_string = $_SERVER['QUERY_STRING']; 
     56        if (strstr($php_query_string,$action) !== false) return true; 
     57        return false; 
     58} 
    5159?> 
  • trunk/include/xpress_block_render.php

    r95 r96  
    9999        } 
    100100         
     101    function xpress_block_cache_found($mydirname,$block_name) 
     102    { 
     103        global $xoops_config; 
     104        if(defined('XOOPS_ROOT_PATH')){ 
     105                $cache_dir = XOOPS_ROOT_PATH . '/cache/'; 
     106        } else { 
     107                $cache_dir = $xoops_config->xoops_root_path . '/cache/'; 
     108        } 
     109        $xml_name = $block_name . '.xml'; 
     110 
     111        $filename = $cache_dir .$mydirname . '_' . $xml_name; 
     112                $cache_time = 0; 
     113//        if (file_exists($filename) && ((time() - filemtime($filename)) < $cache_time)) { 
     114        if (file_exists($filename)) { 
     115            return true; 
     116       } else { 
     117                        return false; 
     118                } 
     119    }  
     120         
    101121        function xpress_block_render($mydirname,$block_function_name,$options) 
    102122        { 
     
    108128                $blockID =get_block_id($mydirname,$func_file,$options);          
    109129 
    110                 if (!is_null($wpdb)){ 
     130                $this_url = '/modules/'. $mydirname; 
     131                $call_url = $_SERVER['REQUEST_URI']; 
     132                if (strstr($call_url,$this_url)){ 
    111133                        xpress_block_css_set($mydirname); 
    112134                         
     
    114136                        require_once $block_theme_file; 
    115137                        $block = $call_theme_function_name($options);           //The block name and the called function name should be assumed to be the same name.  
    116  
    117 // Not Cache Write Now.  Becose Cache Write On WordPress Event                   
    118 //                      xpress_block_cache_write($mydirname,$cache_title. $blockID, $block);   
    119138                } else { 
    120                         $xml = xpress_block_cache_read($mydirname,$cache_title. $blockID); 
    121                         $block = $xml['block']; 
     139                        if (xpress_block_cache_found($mydirname,$cache_title. $blockID)){ 
     140                                $xml = xpress_block_cache_read($mydirname,$cache_title. $blockID); 
     141                                $block = $xml['block']; 
     142                        } else { 
     143                                $block['err_message'] = sprintf(_MB_XPRESS_BLOCK_CACHE_ERR, '<a href="' . XOOPS_URL . '/modules/' . $mydirname . '">' . $mydirname .'</a>'); 
     144                        } 
    122145                } 
    123146 
  • trunk/include/xpress_cache.php

    r95 r96  
    11<?php 
    22         
     3if(!function_exists("xpress_cache_found")): 
     4    function xpress_cache_found($filename) 
     5    { 
     6                $cache_time = 0; 
     7//        if (file_exists($filename) && ((time() - filemtime($filename)) < $cache_time)) { 
     8        if (file_exists($filename)) { 
     9            return true; 
     10       } else { 
     11                        return false; 
     12                } 
     13    }  
     14endif; 
     15 
    316if(!function_exists("xpress_cache_read")): 
    417    function xpress_cache_read($mydirname,$collation_key) 
    518    { 
    619        global $xoops_config; 
    7                 $cache_dir = $xoops_config->xoops_root_path . '/cache/'; 
    8                 $cache_time = 0; 
     20        if(defined('XOOPS_ROOT_PATH')){ 
     21                $cache_dir = XOOPS_ROOT_PATH . '/cache/'; 
     22        } else { 
     23                $cache_dir = $xoops_config->xoops_root_path . '/cache/'; 
     24        } 
    925        $filename = $cache_dir .$mydirname . '_' . $collation_key; 
    10 //        if (file_exists($filename) && ((time() - filemtime($filename)) < $cache_time)) { 
    11         if (file_exists($filename)) { 
     26        if (xpress_cache_found($filename)) { 
    1227            return file_get_contents($filename); 
    1328       } else { 
  • trunk/include/xpress_debug_log.php

    r95 r96  
    5757    } 
    5858} 
     59 
     60function xpress_error_handler($errno,$errstr,$errfile,$errline,$errcontext) { 
     61        $module_dirpath = dirname(dirname(__FILE__)); 
     62        $root_path = dirname(dirname(dirname(dirname(__FILE__)))); 
     63         
     64        $show_backtrace = true; 
     65 
     66        // Time stamp of error entry 
     67        $dt = date("Y-m-d H:i:s (T)"); 
     68 
     69        // define an assoc array of error string 
     70        // in reality the only entries we should 
     71        // consider are E_WARNING, E_NOTICE, E_USER_ERROR, 
     72        // E_USER_WARNING and E_USER_NOTICE 
     73        $errortype = array ( 
     74                E_ERROR          => "Error", 
     75                E_WARNING        => "Warning", 
     76                E_PARSE          => "Parsing Error", 
     77                E_NOTICE          => "Notice", 
     78                E_CORE_ERROR      => "Core Error", 
     79                E_CORE_WARNING    => "Core Warning", 
     80                E_COMPILE_ERROR  => "Compile Error", 
     81                E_COMPILE_WARNING => "Compile Warning", 
     82                E_USER_ERROR      => "User Error", 
     83                E_USER_WARNING    => "User Warning", 
     84                E_USER_NOTICE    => "User Notice", 
     85                E_STRICT          => "Runtime Notice" 
     86        ); 
     87        if (strstr($errstr, 'Use of undefined constant xpress_debug_message - assumed') !== false) return; 
     88        // set of errors for which a var trace will be saved 
     89        $user_errors = array(E_USER_ERROR, E_USER_WARNING, E_USER_NOTICE); 
     90 
     91        $err = "<errorentry>\n"; 
     92        $err .= "\t<datetime>" . $dt . "</datetime>\n"; 
     93        $err .= "\t<errornum>" . $errno . "</errornum>\n"; 
     94        $err .= "\t<errortype>" . $errortype[$errno] . "</errortype>\n"; 
     95        $err .= "\t<errormsg>" . $errstr . "</errormsg>\n"; 
     96        $err .= "\t<scriptname>" . $errfile . "</scriptname>\n"; 
     97        $err .= "\t<scriptlinenum>" . $errline . "</scriptlinenum>\n"; 
     98        $err .= "\t<errcontext>" . $errcontext . "</errcontext>\n"; 
     99 
     100        if (in_array($errno, $user_errors)) { 
     101                $err .= "\t<vartrace>" . wddx_serialize_value($vars, "Variables") . "</vartrace>\n"; 
     102        } 
     103        $err .= "</errorentry>\n\n"; 
     104 
     105        $err_trace = ''; 
     106        if ($show_backtrace){    
     107                $backtraces = array_reverse(debug_backtrace()); 
     108                $err_trace .= "BACK TRACE\n"; 
     109                foreach($backtraces as $backtrace){ 
     110                        $trace = @$backtrace['file']. "\tLINE(" . @$backtrace['line'] . ")\t" . @$backtrace['function']  . "()\n"; 
     111                        $trace = str_replace($root_path,"",$trace); 
     112                        $trace = str_replace("\\","/",$trace); 
     113                        $trace = str_replace($root_path,"",$trace); 
     114                        $trace = "\t" . $trace; 
     115                        $err_trace .= $trace; 
     116                } 
     117        } 
     118        $head = "\n***** XPressME ERROR LOG ****************************************************************************************************\n"; 
     119        $message = $head . $err . $err_trace; 
     120        $_debug_file = $module_dirpath . '/wp-content/xpress_error.log'; 
     121        if ($errno != E_STRICT) { 
     122                $_fp = fopen($_debug_file, 'a'); 
     123                fwrite($_fp, $message);  
     124                fclose($_fp); 
     125        } 
     126} 
    59127?> 
  • trunk/include/xpress_render.php

    r61 r96  
    1010        $pattern = "<style[^>]*?>(.*)<\/style>"; 
    1111        preg_match("/".$pattern."/s",  $head_str, $style_matches); 
    12         $style = $style_matches[0]; 
     12        if (empty($style_matches[0])) 
     13                $style = ''; 
     14        else 
     15                $style = $style_matches[0]; 
    1316  
    1417        $pattern = "<link(.*)>"; 
     
    9598//rendering for the module header and the body 
    9699function xpress_render($contents){ 
    97         global $xoopsTpl; 
    98         include XOOPS_ROOT_PATH."/header.php"; 
    99         $page_title = $GLOBALS["xoopsModule"]->getVar("name")." ".wp_title('&raquo;', false);    
     100        global $xoops_config , $xoopsTpl; 
     101        include $xoops_config->xoops_root_path ."/header.php"; 
     102        $page_title = $GLOBALS["xoopsModule"]->getVar("name")." ".wp_title('&raquo;', false); 
    100103        $xoopsTpl->assign('xoops_module_header', get_xpress_module_header($contents)); 
    101104        $xoopsTpl->assign('xoops_pagetitle', $page_title); 
    102105        $xoopsTpl->assign('xpress_body_contents', get_body($contents)); 
    103106        echo get_body($contents); 
     107        require_once( ABSPATH .'/include/xpress_breadcrumbs.php' ); 
     108        include $xoops_config->xoops_root_path . '/footer.php'; 
    104109} 
    105110 
Note: See TracChangeset for help on using the changeset viewer.