https://www.icyphoenix.com/viewtopic.php?f=35&t=9378
-----------------------------------
LordPsyan
Tue 06 Jan, 2015 16:12

Cms_config_vars
-----------------------------------
Why does this function return nothing? if I change $authdb=$cms_config_vars['rs_config_adb'][$block_id]; to $authdb="auth"; it returns auth and works perfectly... except I want to be able to change that via cms block edit, instead of modifying the file every time. This code I have placed in usercp_register.php (I am trying to add username\pass\email to another database during registration. everything works perfectly if I hard code the database name, but I want it pulled from cms_config_vars)

[code linenumbers=false]
			function get_authdb($authdb)
			{
				global $cms_config_vars, $block_id;
				$authdb=$cms_config_vars['rs_config_adb'][$block_id];
				return $authdb;
			}
[/code]

Thanks.


-----------------------------------
Informpro
Fri 09 Jan, 2015 12:41

Re: Cms_config_vars
-----------------------------------
I'd suggest you try

[code]$cms_config_vars = get_cms_config();[/code]

instead. Maybe the variable hasn't been "loaded", and get_cms_config() will cache it anyhow.


-----------------------------------
LordPsyan
Fri 09 Jan, 2015 22:49

Re: Cms_config_vars
-----------------------------------
[quote user="Informpro" post="59979"]I'd suggest you try

[code]$cms_config_vars = get_cms_config();[/code]

instead. Maybe the variable hasn't been "loaded", and get_cms_config() will cache it anyhow.[/quote]

Thanks for the reply. I tried that both inside and outside of the function, and neither did anything. 

It doesn't make sense. I used $cms_config_vars  in a block, and it worked fine.


-----------------------------------
Mighty Gorgon
Sat 10 Jan, 2015 09:17

Re: Cms_config_vars
-----------------------------------
Hi,
I have created a specific function for bridging Icy Phoenix with any other software and being able to keep track of user data changed (such as email and password).

The function is in class_users.php:
[code linenumbers=false]	/*
	* User profile update: this function is called when username, email and password are changed in a user profile
	*/
	function profile_update($target_profile_data)
	{
		global $db, $config, $user, $lang;

		/*
		$target_profile_data = array(
			'user_id' => '',
			'username' => '',
			'password' => '',
			'email' => ''
		);
		*/
		//print_r($target_profile_data);

		return true;
	}
[/code]

The work is still incomplete, because I should have coded a hook where customized files could be hooked, but didn't do that so far... anyway the function is still a great helper, since it is connected to any crucial data change in a user profile.

Regarding your issue, try to print the var just to make sure that the var has been properly "globalized".

Try to add this somewhere [c]print_r($cms_config_vars);[/c]


Alternatively pass the DB throug a $_POST var.


-----------------------------------
LordPsyan
Sat 10 Jan, 2015 19:20

Re: Cms_config_vars
-----------------------------------
I figured out an easier way to do this. Was so simple. I just added a few lines to config.php and pulled it from there. Wow how simple. I modified the installer to add those lines during install, so everything is working. This solves MY problem, but does not solve the problem of pulling data from that database, and why it doesn't work. Thanks for all the advice


-----------------------------------
Mighty Gorgon
Wed 21 Jan, 2015 12:57

Re: Cms_config_vars
-----------------------------------
Usually for this kind of setup I only use different tables prefix on the same DB, so I minimize the problems and the necessity to declare a brand new DB class to connect on the other DB.

I don't know how are you trying to connect, but make sure that the other DB is accessible and that the DB object is instantiated correctly.


