| 1 | <?php | 
|---|
| 2 | $mydirpath = dirname(dirname(__FILE__)); | 
|---|
| 3 | $mydirname = basename($mydirpath); | 
|---|
| 4 | $lang = @$GLOBALS["xoopsConfig"]['language']; | 
|---|
| 5 | global $wp_db_version; | 
|---|
| 6 | include_once $mydirpath .'/wp-includes/version.php' ; | 
|---|
| 7 |  | 
|---|
| 8 | // language file (modinfo.php) | 
|---|
| 9 |  | 
|---|
| 10 | if( file_exists( $mydirpath .'/language/'.$lang.'/modinfo.php' ) ) { | 
|---|
| 11 |         include_once $mydirpath .'/language/'.$lang.'/modinfo.php' ; | 
|---|
| 12 | } else if( file_exists(  $mydirpath .'/language/english/modinfo.php' ) ) { | 
|---|
| 13 |         include_once $mydirpath .'/language/english/modinfo.php' ; | 
|---|
| 14 | } | 
|---|
| 15 |  | 
|---|
| 16 |  | 
|---|
| 17 | eval( ' function xoops_module_install_'.$mydirname.'( $module ) { return xpress_oninstall_base( $module , "'.$mydirname.'" ) ; } ' ) ; | 
|---|
| 18 |  | 
|---|
| 19 |  | 
|---|
| 20 | if( ! function_exists( 'xpress_oninstall_base' ) ) : | 
|---|
| 21 | function xpress_oninstall_base( $module , $mydirname ) | 
|---|
| 22 | { | 
|---|
| 23 |         // transations on module install | 
|---|
| 24 |  | 
|---|
| 25 |         global $ret ; // TODO :-D | 
|---|
| 26 |  | 
|---|
| 27 |         // for Cube 2.1 | 
|---|
| 28 |         if( defined( 'XOOPS_CUBE_LEGACY' ) ) { | 
|---|
| 29 |                 $root =& XCube_Root::getSingleton(); | 
|---|
| 30 |                 $root->mDelegateManager->add( 'Legacy.Admin.Event.ModuleInstall.' . ucfirst($mydirname) . '.Success' , 'xpress_message_append_oninstall' ) ; | 
|---|
| 31 |                 $ret = array() ; | 
|---|
| 32 |         } else { | 
|---|
| 33 |                 if( ! is_array( $ret ) ) $ret = array() ; | 
|---|
| 34 |         } | 
|---|
| 35 |  | 
|---|
| 36 |         $db =& Database::getInstance() ; | 
|---|
| 37 |         $mid = $module->getVar('mid') ; | 
|---|
| 38 |  | 
|---|
| 39 | //xpress | 
|---|
| 40 |         global $wpdb,$wp_rewrite, $wp_queries, $table_prefix, $wp_db_version, $wp_roles, $wp_query; | 
|---|
| 41 |         define("WP_INSTALLING", true); | 
|---|
| 42 |         $site_url= XOOPS_URL."/modules/".$mydirname; | 
|---|
| 43 |         $mydirpath = XOOPS_ROOT_PATH . '/modules/' . $mydirname; | 
|---|
| 44 |         $path = $mydirpath . '/'; | 
|---|
| 45 |         if (file_exists($path . 'wp-load.php')) { | 
|---|
| 46 |                 require_once $path . 'wp-load.php'; | 
|---|
| 47 |         } else { | 
|---|
| 48 |                 require_once $path . 'wp-config.php'; | 
|---|
| 49 |         } | 
|---|
| 50 |         include_once($mydirpath . '/wp-admin/upgrade-functions.php'); | 
|---|
| 51 |         wp_cache_flush(); | 
|---|
| 52 |         make_db_current_silent(); | 
|---|
| 53 |          | 
|---|
| 54 |         $option_desc = __('WordPress web address'); | 
|---|
| 55 |         $wpdb->query("INSERT INTO $wpdb->options (option_id, blog_id, option_name,option_value, autoload) VALUES ('1', '0', 'siteurl','$site_url', 'yes')");     | 
|---|
| 56 |         $wpdb->query("INSERT INTO $wpdb->options (option_id, blog_id, option_name,option_value, autoload) VALUES ('1', '0', 'home','$site_url', 'yes')"); | 
|---|
| 57 |  | 
|---|
| 58 |         populate_options(); | 
|---|
| 59 |         populate_roles(); | 
|---|
| 60 |          | 
|---|
| 61 | // Rewrite Option for Xpress | 
|---|
| 62 | //      update_option("blog_charset", wp_blog_charset()); | 
|---|
| 63 |         update_option('blogname', ucfirst($mydirname) . ' ' . _MI_XPRESS_NAME );         | 
|---|
| 64 |         update_option('blogdescription', 'WordPress for XOOPS'); | 
|---|
| 65 |         update_option("admin_email", $GLOBALS["xoopsConfig"]['adminmail']); | 
|---|
| 66 |         update_option("ping_sites", "http://rpc.pingomatic.com/\nhttp://ping.xoopsforge.com/"); | 
|---|
| 67 |         update_option("home", $site_url); | 
|---|
| 68 |         update_option("siteurl", $site_url); | 
|---|
| 69 |         update_option("template", "xpress_default"); | 
|---|
| 70 |         update_option("stylesheet", "xpress_default"); | 
|---|
| 71 |         update_option("what_to_show", "posts"); | 
|---|
| 72 |  | 
|---|
| 73 |         /* add new option for uploads */ | 
|---|
| 74 | //      update_option('uploads_use_yearmonth_folders', 1); | 
|---|
| 75 | //      update_option('upload_path', $module->getVar("dirname")); | 
|---|
| 76 |          | 
|---|
| 77 |         /* activate the tag plugin */ | 
|---|
| 78 |         $plugin_current = "xpressme/xpressme.php"; | 
|---|
| 79 |         update_option('active_plugins', array($plugin_current)); | 
|---|
| 80 |         include(dirname(__FILE__) . '/../wp-content/plugins/'.$plugin_current); | 
|---|
| 81 |         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 |         xpress_user_sync($ID); | 
|---|
| 89 |  | 
|---|
| 90 |         // Set Default data | 
|---|
| 91 |                 wp_install_defaults($ID); | 
|---|
| 92 | //          generate_page_uri_index(); | 
|---|
| 93 |  | 
|---|
| 94 |                  | 
|---|
| 95 |         // create views table | 
|---|
| 96 |         $xp_prefix = $mydirname; | 
|---|
| 97 |         if ($xp_prefix == 'wordpress'){ | 
|---|
| 98 |                 $xp_prefix = 'wp'; | 
|---|
| 99 |         } | 
|---|
| 100 |         $views_table = XOOPS_DB_PREFIX . '_' . $xp_prefix .'_views' ; | 
|---|
| 101 |  | 
|---|
| 102 |         $charset_collate = ''; | 
|---|
| 103 |         if ( version_compare(mysql_get_server_info(), '4.1.0', '>=') ) { | 
|---|
| 104 |                 if ( ! empty($wpdb->charset) ) | 
|---|
| 105 |                         $charset_collate = "DEFAULT CHARACTER SET $wpdb->charset"; | 
|---|
| 106 |                 if ( ! empty($wpdb->collate) ) | 
|---|
| 107 |                         $charset_collate .= " COLLATE $wpdb->collate"; | 
|---|
| 108 |         } | 
|---|
| 109 |         $views_queries ="CREATE TABLE $views_table ( | 
|---|
| 110 |                 post_id bigint(20) unsigned NOT NULL default '0', | 
|---|
| 111 |                 post_views bigint(20) unsigned NOT NULL default '0', | 
|---|
| 112 |                 KEY post_id (post_id) | 
|---|
| 113 |                 )$charset_collate;"; | 
|---|
| 114 |  | 
|---|
| 115 |         dbDelta($views_queries); | 
|---|
| 116 |          | 
|---|
| 117 |         $d3forum_link = XOOPS_DB_PREFIX . '_' . $xp_prefix .'_d3forum_link' ; | 
|---|
| 118 |         $views_queries ="CREATE TABLE $d3forum_link ( | 
|---|
| 119 |                 comment_ID bigint(20) unsigned NOT NULL default '0', | 
|---|
| 120 |                 post_id int(10) unsigned NOT NULL default '0' , | 
|---|
| 121 |                 wp_post_ID bigint(20) unsigned NOT NULL default '0', | 
|---|
| 122 |                 KEY post_id (post_id) | 
|---|
| 123 |                 )$charset_collate;"; | 
|---|
| 124 |         dbDelta($views_queries); | 
|---|
| 125 |                  | 
|---|
| 126 |         // make templates | 
|---|
| 127 | //      include_once XOOPS_ROOT_PATH . '/modules/' . $mydirname . '/include/xpress_templates.php' ; | 
|---|
| 128 | //      $ret = xpress_install_templates($mid,$mydirname); | 
|---|
| 129 |  | 
|---|
| 130 |         return true ; | 
|---|
| 131 | } | 
|---|
| 132 | endif; | 
|---|
| 133 |  | 
|---|
| 134 | if( ! function_exists( 'xpress_message_append_oninstall' ) ) : | 
|---|
| 135 | function xpress_message_append_oninstall( &$module_obj , &$log ) | 
|---|
| 136 | { | 
|---|
| 137 |         if( is_array( @$GLOBALS['ret'] ) ) { | 
|---|
| 138 |                 foreach( $GLOBALS['ret'] as $message ) { | 
|---|
| 139 |                         $log->add( strip_tags( $message ) ) ; | 
|---|
| 140 |                 } | 
|---|
| 141 |         } | 
|---|
| 142 |  | 
|---|
| 143 |         // use mLog->addWarning() or mLog->addError() if necessary | 
|---|
| 144 | } | 
|---|
| 145 | endif; | 
|---|
| 146 |  | 
|---|
| 147 | ?> | 
|---|