Changeset 494420
- Timestamp:
- 01/24/2012 04:04:16 AM (14 years ago)
- Location:
- vbpress/trunk
- Files:
-
- 2 added
- 3 edited
-
core/views/option_field_auto_login_vb_user.php (added)
-
core/views/option_field_sync_wp_users_into_vb.php (added)
-
core/views/settings.php (modified) (1 diff)
-
readme.txt (modified) (3 diffs)
-
vbpress.php (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
vbpress/trunk/core/views/settings.php
r403077 r494420 7 7 </form> 8 8 9 <?php if ( !empty( $options['vbpress_enabled'] ) ) { ?>9 <?php if ( false && !empty( $options['vbpress_enabled'] ) ) { ?> 10 10 <h2><?php _e( 'vBulletin Status', 'vbpress' ); ?></h2> 11 11 <?php if ( !empty( $current_user_info ) ) { ?> -
vbpress/trunk/readme.txt
r403077 r494420 3 3 Tags: vbulletin, integrate, forum, bridge, vb, login, merge, member, user, thread, post, comment 4 4 Requires at least: 3.0.5 5 Tested up to: 3. 1.46 Stable tag: 0. 1.0-25 Tested up to: 3.3.1 6 Stable tag: 0.2 7 7 8 8 vBPress seamlessly integrates WordPress with vBulletin … … 11 11 12 12 [vBPress](http://www.vbpress.com/) is a WordPress plugin that seamlessly integrates WordPress with vBulletin. 13 14 PLEASE NOTE: This plugin is still under active development and is not yet fully functional. Set your expectations accordingly.15 13 16 14 == Installation == … … 23 21 = There's not much, what's going on? = 24 22 25 It's version 0. 1.0. Patience.23 It's version 0.3. Patience. 26 24 27 25 == Changelog == 26 27 = 0.2 = 28 * Added setting to create vBulletin user account when a WordPress user account is created 29 * Added setting to enable auto-login 28 30 29 31 = 0.1.0-2 = -
vbpress/trunk/vbpress.php
r403077 r494420 35 35 function Vbpress() { 36 36 37 // Create settings menu in admin control panel 37 38 add_action( 'admin_menu', array( $this, 'admin_menu' ) ); 39 40 $options = get_option( 'vbpress_options' ); 41 42 // Create user hook 43 if ( !empty( $options['sync_wp_users_into_vb'] ) ) { 44 add_action( 'user_register', array( $this, 'create_vb_user' ) ); 45 add_action( 'wp_authenticate', array( $this, 'update_vb_password_on_authenticate' ) ); 46 } 47 48 // Auto-login hook 49 if ( !empty( $options['auto_login_vb_user'] ) ) { 50 add_action( 'wp_login', array( $this, 'login_vb_user' ) ); 51 } 38 52 39 53 } … … 59 73 $vbpress_settings = Vbpress_Settings::init(); 60 74 $hook = add_menu_page( 'vBPress', 'vBPress', 'manage_options', 'vbpress_settings', array( &$vbpress_settings, 'settings' ), '' ); 75 } 76 77 /** 78 * Create a vBulletin user and associate it to the WP account 79 */ 80 function create_vb_user( $wp_user_id ) { 81 82 $wp_user_data = get_userdata( $wp_user_id ); 83 84 $vb_user_id = Vbpress_Vb::create_user( $wp_user_id, $wp_user_data->user_email, $wp_user_data->user_login, wp_generate_password( 12, false ) ); 85 86 if ( !empty( $vb_user_id ) ) { 87 update_user_meta( $wp_user_id, 'vbulletin_user_id', $vb_user_id ); 88 } 89 } 90 91 /** 92 * There's no way to get the user's raw password when registering. This 93 * function attempts to snag it upon login so that vB can be updated. 94 */ 95 function update_vb_password_on_authenticate( $user_login ) { 96 97 if ( empty( $user_login ) ) { return; } 98 99 $wp_user_data = get_userdatabylogin( $user_login ); 100 $vb_user_id = get_user_meta( $wp_user_data->ID, 'vbulletin_user_id', true ); 101 102 Vbpress_Vb::set_user_password( $vb_user_id, $_POST['pwd'] ); 103 104 } 105 106 /** 107 * Logs in the vBulletin user associated with the WordPress user 108 */ 109 function login_vb_user( $user_login ) { 110 111 $wp_user_data = get_userdatabylogin( $user_login ); 112 $vb_user_id = get_user_meta( $wp_user_data->ID, 'vbulletin_user_id', true ); 113 114 if ( empty( $vb_user_id ) ) { 115 return; 116 } 117 118 Vbpress_Vb::login_user_by_id( $vb_user_id ); 61 119 } 62 120 } … … 98 156 * logged-in user 99 157 */ 158 function create_user( $wp_user_id, $email, $username, $password ) { 159 160 $vb_user_data =& datamanager_init( 'User', $GLOBALS['vbulletin'], ERRTYPE_ARRAY ); 161 $vb_user_data->set( 'email', $email ); 162 $vb_user_data->set( 'username', $username ); 163 $vb_user_data->set( 'password', $password ); 164 165 $vb_user_data->pre_save(); 166 167 if ( empty( $vb_user_data->errors ) ) { 168 return $vb_user_data->save(); 169 } else { 170 // TODO: Error, vBulletin threw errors when attempting to create user 171 } 172 173 } 174 175 /** 176 * If available, returns an array of user info for the currently 177 * logged-in user 178 */ 100 179 function get_current_user_info() { 101 180 if ( !empty($this->vbulletin->userinfo['userid']) ) { … … 113 192 return fetch_userinfo($user_id); 114 193 } 194 195 /** 196 * Logs in the vBulletin user associated with the WordPress user 197 */ 198 function login_user_by_id( $vb_user_id ) { 199 200 $options = get_option( 'vbpress_options' ); 201 202 if ( empty( $options['vbulletin_path'] ) || !file_exists( $options['vbulletin_path'] . '/includes/functions_login.php' ) ) { 203 return; 204 } 205 206 include_once( $options['vbulletin_path'] . '/includes/functions_login.php' ); 207 $GLOBALS['vbulletin']->userinfo = verify_id( 'user', $vb_user_id, true, true, 0 ); 208 process_new_login( null, 0, null ); 209 $GLOBALS['vbulletin']->session->save(); 210 211 } 212 213 /** 214 * Logs in the vBulletin user associated with the WordPress user 215 */ 216 function set_user_password( $vb_user_id, $user_pass ) { 217 218 $vb_user_data =& datamanager_init( 'User', $GLOBALS['vbulletin'], ERRTYPE_ARRAY ); 219 $vb_user_data->set_existing( Vbpress_Vb::get_user_info( $vb_user_id ) ); 220 $vb_user_data->set( 'password', $_POST['pwd'] ); 221 $vb_user_data->pre_save(); 222 223 if ( empty( $vb_user_data->errors ) ) { 224 $vb_user_data->save(); 225 } else { 226 // TODO: Error, vBulletin threw errors when attempting to create user 227 } 228 229 } 115 230 116 231 } … … 145 260 add_settings_field( 'vbpress_enabled', __( 'Enable vBPress', 'vbpress' ), array( $this, 'output_option_vbpress_enabled' ), 'vbpress', 'vbpress_options_general' ); 146 261 add_settings_field( 'vbulletin_path', __( 'vBulletin Path', 'vbpress' ), array( $this, 'output_option_vbulletin_path' ), 'vbpress', 'vbpress_options_general' ); 262 add_settings_field( 'sync_wp_users_into_vb', __( 'Sync WordPress Users Into vBulletin', 'vbpress' ), array( $this, 'output_option_sync_wp_users_into_vb' ), 'vbpress', 'vbpress_options_general' ); 263 add_settings_field( 'auto_login_vb_user', __( 'Automatically log in to vBulletin', 'vbpress' ), array( $this, 'output_option_auto_login_vb_user' ), 'vbpress', 'vbpress_options_general' ); 147 264 } 148 265 … … 186 303 $options = get_option( 'vbpress_options' ); 187 304 require( dirname( __FILE__ ) . '/core/views/option_field_vbulletin_path.php' ); 305 } 306 307 /** 308 * Output option field HTML 309 */ 310 function output_option_sync_wp_users_into_vb() { 311 $options = get_option( 'vbpress_options' ); 312 require( dirname( __FILE__ ) . '/core/views/option_field_sync_wp_users_into_vb.php' ); 313 } 314 315 /** 316 * Output option field HTML 317 */ 318 function output_option_auto_login_vb_user() { 319 $options = get_option( 'vbpress_options' ); 320 require( dirname( __FILE__ ) . '/core/views/option_field_auto_login_vb_user.php' ); 188 321 } 189 322
Note: See TracChangeset
for help on using the changeset viewer.