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 XPressME plugin */ |
---|
78 | $plugin_current = "xpressme/xpressme.php"; |
---|
79 | update_option('active_plugins', array($plugin_current)); |
---|
80 | include_once(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 | $sync_messg = ''; |
---|
89 | xpress_user_sync($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 | |
---|
96 | // create views table |
---|
97 | $xp_prefix = $mydirname; |
---|
98 | if ($xp_prefix == 'wordpress'){ |
---|
99 | $xp_prefix = 'wp'; |
---|
100 | } |
---|
101 | $views_table = XOOPS_DB_PREFIX . '_' . $xp_prefix .'_views' ; |
---|
102 | |
---|
103 | $charset_collate = ''; |
---|
104 | if ( version_compare(mysql_get_server_info(), '4.1.0', '>=') ) { |
---|
105 | if ( ! empty($wpdb->charset) ) |
---|
106 | $charset_collate = "DEFAULT CHARACTER SET $wpdb->charset"; |
---|
107 | if ( ! empty($wpdb->collate) ) |
---|
108 | $charset_collate .= " COLLATE $wpdb->collate"; |
---|
109 | } |
---|
110 | $views_queries ="CREATE TABLE $views_table ( |
---|
111 | post_id bigint(20) unsigned NOT NULL default '0', |
---|
112 | post_views bigint(20) unsigned NOT NULL default '0', |
---|
113 | KEY post_id (post_id) |
---|
114 | )$charset_collate;"; |
---|
115 | |
---|
116 | dbDelta($views_queries); |
---|
117 | |
---|
118 | $d3forum_link = XOOPS_DB_PREFIX . '_' . $xp_prefix .'_d3forum_link' ; |
---|
119 | $views_queries ="CREATE TABLE $d3forum_link ( |
---|
120 | comment_ID bigint(20) unsigned NOT NULL default '0', |
---|
121 | post_id int(10) unsigned NOT NULL default '0' , |
---|
122 | wp_post_ID bigint(20) unsigned NOT NULL default '0', |
---|
123 | KEY post_id (post_id) |
---|
124 | )$charset_collate;"; |
---|
125 | dbDelta($views_queries); |
---|
126 | |
---|
127 | $group_role = XOOPS_DB_PREFIX . '_' . $xp_prefix .'_group_role' ; |
---|
128 | $views_queries ="CREATE TABLE $group_role ( |
---|
129 | groupid smallint(5) unsigned NOT NULL default '0', |
---|
130 | name varchar(50) NOT NULL default '' , |
---|
131 | description text NOT NULL default '', |
---|
132 | group_type varchar(10) NOT NULL default '' , |
---|
133 | role varchar(20) NOT NULL default '' , |
---|
134 | KEY groupid (groupid) |
---|
135 | )$charset_collate;"; |
---|
136 | dbDelta($views_queries); |
---|
137 | |
---|
138 | // make templates |
---|
139 | // include_once XOOPS_ROOT_PATH . '/modules/' . $mydirname . '/include/xpress_templates.php' ; |
---|
140 | // $ret = xpress_install_templates($mid,$mydirname); |
---|
141 | |
---|
142 | return true ; |
---|
143 | } |
---|
144 | endif; |
---|
145 | |
---|
146 | if( ! function_exists( 'xpress_message_append_oninstall' ) ) : |
---|
147 | function xpress_message_append_oninstall( &$module_obj , &$log ) |
---|
148 | { |
---|
149 | if( is_array( @$GLOBALS['ret'] ) ) { |
---|
150 | foreach( $GLOBALS['ret'] as $message ) { |
---|
151 | $log->add( strip_tags( $message ) ) ; |
---|
152 | } |
---|
153 | } |
---|
154 | |
---|
155 | // use mLog->addWarning() or mLog->addError() if necessary |
---|
156 | } |
---|
157 | endif; |
---|
158 | |
---|
159 | ?> |
---|