Go Back   vb.org Archive > Community Discussions > Modification Requests/Questions (Unpaid)
  #1  
Old 06-03-2008, 12:53 AM
psylenced psylenced is offline
 
Join Date: May 2008
Posts: 33
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Importing custom fields (solved)

I have decided to write a process to allow users to log in under their old password instead of forcing everyone to run "forget password".

How i am doing that is creating 2 custom fields in user called importpassword and importsalt.

The way it'll work is hook the login failure, check these secondary fields and then allow the login. If this passes it'll update the password to the vb format and then clear those fields. I have got that basically working - it currently works with a hardcoded password of '12345' to log in as anyone.

The only issue i have is getting the data into the 2 fields i've created in user using the import.

I tried first add_custom_field/value but that ended up adding fields to the profile fields table which is not what i want.

I have modified the insert sql query to include the 2 extra fields and added this bit of code in:

Code:
            $try->set_value('nonmandatory', 'importpassword',            $user_details['Password']);
            $try->set_value('nonmandatory', 'importsalt',                $user_details['Salt']);
Except the fields are coming over blank. Is there something that i'm missing? Or is there an easier way to do this?

Cheers

Please note - i need no help with the plugin creation, only the alteration of the import system to include 2 extra fields.

--------------- Added [DATE]1212490995[/DATE] at [TIME]1212490995[/TIME] ---------------

Ok, finally got this working.

I will outline the steps if anyone in the future is wanting to import additional fields into the 'user' table.

1. Add 2 extra fields into DB, nullable.

2. In file: ImpExData.php, function is_valid.

Change:
Code:
			foreach (($this->_values[$this->_datatype]['nonmandatory']) AS $key => $value)
			{
to:
Code:
			foreach (($this->_values[$this->_datatype]['nonmandatory']) AS $key => $value)
			{
				// Skip additional fields
				if($key == 'importpassword' || $key == 'importsalt')
				{
					continue;
				}

3. In file: ImpExData.php, function set_value

Change:
Code:
	function set_value($section, $name, $value)
	{
		if (@array_key_exists($name, $this->_values[$this->_datatype][$section]))
to:
Code:
	function set_value($section, $name, $value)
	{
		// Check field but skip additional fields
		if (@array_key_exists($name, $this->_values[$this->_datatype][$section]) ||  $name == 'importpassword' || $name == 'importsalt')


4. In file: ImpExData.php, function import_user (around line 2205 - be careful similar line earlier)

Change:
Code:
						autosubscribe, profilepicrevision
to:
Code:
						autosubscribe, profilepicrevision, importpassword, importsalt

5. In file: ImpExData.php, function import_user (around line 2253 - be careful similar line earlier)

Change:
Code:
						'" . $this->get_value('nonmandatory', 'profilepicrevision') . "'
					)
				";
to:
Code:
						'" . $this->get_value('nonmandatory', 'profilepicrevision') . "',
						'" . $this->get_value('nonmandatory', 'importpassword') . "',
						'" . $this->get_value('nonmandatory', 'importsalt') . "'
					)
				";

6. In file: 004.php, function resume

Change:
Code:
			$try->set_value('nonmandatory', 'timezoneoffset',			$user_details['Time_offset_hours']);
			$try->set_value('nonmandatory', 'pmpopup',					$user_details['PM_notify']);
			$try->set_value('nonmandatory', 'options',					$this->_default_user_permissions);
to:
Code:
			$try->set_value('nonmandatory', 'timezoneoffset',			$user_details['Time_offset_hours']);
			$try->set_value('nonmandatory', 'pmpopup',					$user_details['PM_notify']);
			$try->set_value('nonmandatory', 'options',					$this->_default_user_permissions);

			/// Additional Fields
			$try->set_value('nonmandatory', 'importpassword',			$user_details['Password']);
			$try->set_value('nonmandatory', 'importsalt',				$user_details['Salt']);

And that should allow to the 2 extra fields (importpassword, importsalt), to be imported from old database into the new database's 'user' table without causing any errors.

Please note: try at your own risk - no support offered.
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 01:36 PM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.03113 seconds
  • Memory Usage 2,173KB
  • Queries Executed 13 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (11)bbcode_code
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (1)post_thanks_box
  • (1)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (1)post_thanks_postbit_info
  • (1)postbit
  • (1)postbit_onlinestatus
  • (1)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_postinfo_query
  • fetch_postinfo
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete