CurrentUserInfo in Custom file

This public forum is for user-to-user discussions of PHPMaker. Note that this is not support forum.
Post Reply
btrade
User
Posts: 357

CurrentUserInfo in Custom file

Post by btrade »

Hi,

How can I to use the CurrentUserInfo in custom file or userfn13.php ? I have error in this file

echo CurrentUserInfo('t_level_id');
( ! ) Warning: Creating default object from empty value in J:\home\site\www\search\ewshared13.php on line 1540


arbei
User
Posts: 9354

Post by arbei »

Can you show the code around ewshared13.php line 1540?

Normally, enabled the option "include common files" and "Use Existing Table" in [Security] and the CurrentUserIfo() will work fine.


btrade
User
Posts: 357

Post by btrade »

arbei wrote:
Normally, enabled the option "include common files" and "Use Existing Table" in [Security]
and the CurrentUserIfo() will work fine.

This is enabled.

echo CurrentUserInfo('login');
The function work in all scripts.
This dont work only in custom files.

( ! ) Warning: Creating default object from empty value in J:\home\translator\www\backoffice\ewshared13.php on line 1522
( ! ) Fatal error: Call to undefined method stdClass::Execute() in J:\home\translator\www\backoffice\ewshared13.php on line 1523

// Load recordset
if (!function_exists('ew_LoadRecordset')) {

function &ew_LoadRecordset($SQL, $c = NULL) {
	if (is_string($c))
		$c = &Conn($c);
	$conn = ($c) ? $c : $GLOBALS["conn"];
	$conn->raiseErrorFn = $GLOBALS["EW_ERROR_FN"];
	$rs = $conn->Execute($SQL);
	$conn->raiseErrorFn = '';
	return $rs;
}

}

I use the data of Linked Table for autorization.


danielc
User
Posts: 1601

Post by danielc »

Normally, enabled the option "include common files" and "Use Existing Table" in [Security] and the CurrentUserIfo() will work fine.

Make sure you have enabled the option "include common files". When you create a new Custom File from your PHPMaker project, then you should see "Include common files" option in the "Custom File" dialog box.

If you write the code in Custom File (Content), rememeber to use:
<?php echo CurrentUserInfo("t_level_id"); ?>

Also, the field name is case sensitive.


btrade
User
Posts: 357

Post by btrade »

I use <?php echo CurrentUserInfo("t_level_id"); ?> in userfn13.php and i have error

( ! ) Warning: Creating default object from empty value in J:\home\site\www\search\ewshared13.php on line 1540


mobhar
User
Posts: 11702

Post by mobhar »

Please note that the generated code in "userfn13.php" file is PHP code and basically the code in this file is the global functions that you wrote in "Global Code" of server event. You don't need to enclose it with PHP tags anymore.

In addition, in which line did you put that code, and what for? You should use that code in your own global function from "Global Code" section, and not customizing the generated "userfn13.php" file.


btrade
User
Posts: 357

Post by btrade »

mobhar wrote:
Please note that the generated code in "userfn13.php" file is PHP code and basically
the code in this file is the global functions that you wrote in "Global Code" of
server event. You don't need to enclose it with PHP tags anymore.

I understand it.

In addition, in which line did you put that code, and what for? You should use that
code in your own global function from "Global Code" section, and not customizing
the generated "userfn13.php" file.

I use this function to extract data from a table of user profile. This function works in the project in other files. It does not work only in "Global Code".


mobhar
User
Posts: 11702

Post by mobhar »

Then please post your code in "Global Code" for more discussion.


btrade
User
Posts: 357

Post by btrade »

function ew_UserFormatDateTime($field, $default) {

		$dbhelper =& DbHelper(DB_ACCOUNT);
		//$row = $dbhelper->ExecuteScalar("SELECT `".$field."` FROM `account_profiles_params` WHERE `profiles_id` = '" .CurrentUserID()."' ");
		$row = CurrentUserInfo($field);
		if ($row > 0) {
			return $row;
		} else {
			return $default;
		}
	}
	$ew_User_DATE_FORMAT = ew_UserFormatDateTime('date_format', 7);
	$ew_User_TIME_FORMAT = ew_UserFormatDateTime('time_format', 4);
	$ew_User_TIZO_FORMAT = ew_UserFormatDateTime('time_zone', 161);
	$ew_User_ZONE_FORMAT = ew_UserTimeZone($ew_User_TIZO_FORMAT);
	$ew_User_CDAT_FORMAT = ew_UserCalendar('calendar', $ew_User_DATE_FORMAT);
	$ew_User_CTIM_FORMAT = ew_UserCalendar('calendar', $ew_User_TIME_FORMAT);
	$ew_User_MDAT_FORMAT = ew_UserCalendar('mask', $ew_User_DATE_FORMAT);
	$ew_User_MTIM_FORMAT = ew_UserCalendar('mask', $ew_User_TIME_FORMAT);
	$ew_User_PDAT_FORMAT = ew_UserCalendar('placeholder', $ew_User_DATE_FORMAT);
	$ew_User_PTIM_FORMAT = ew_UserCalendar('placeholder', $ew_User_TIME_FORMAT);
	$ew_User_POINT_FORMAT = ew_UserFormatDateTime('mon_decimal_point', ',');

arbei
User
Posts: 9354

Post by arbei »

btrade wrote:
function ew_UserFormatDateTime($field, $default) {

		$dbhelper =& DbHelper(DB_ACCOUNT);

You should pass a string value or a variable to the DbHelper function.

For Example:
$dbhelper = &DbHelper("DB");


mobhar
User
Posts: 11702

Post by mobhar »

  1. No need to use dbhelper in "Global Code". Just change your code as follows:

function ew_UserFormatDateTime($field, $default) {
$row = CurrentUserInfo($field);
if ($row > 0) {
return $row;
} else {
return $default;
}
}

  1. Move this following code from "Global Code" section into your custom file (remember to enclose it with PHP tags):

$ew_User_DATE_FORMAT = ew_UserFormatDateTime('date_format', 7);
$ew_User_TIME_FORMAT = ew_UserFormatDateTime('time_format', 4);
$ew_User_TIZO_FORMAT = ew_UserFormatDateTime('time_zone', 161);
$ew_User_ZONE_FORMAT = ew_UserTimeZone($ew_User_TIZO_FORMAT);
$ew_User_CDAT_FORMAT = ew_UserCalendar('calendar', $ew_User_DATE_FORMAT);
$ew_User_CTIM_FORMAT = ew_UserCalendar('calendar', $ew_User_TIME_FORMAT);
$ew_User_MDAT_FORMAT = ew_UserCalendar('mask', $ew_User_DATE_FORMAT);
$ew_User_MTIM_FORMAT = ew_UserCalendar('mask', $ew_User_TIME_FORMAT);
$ew_User_PDAT_FORMAT = ew_UserCalendar('placeholder', $ew_User_DATE_FORMAT);
$ew_User_PTIM_FORMAT = ew_UserCalendar('placeholder', $ew_User_TIME_FORMAT);
$ew_User_POINT_FORMAT = ew_UserFormatDateTime('mon_decimal_point', ',');

  1. In addition, make sure the other functions above such as "ew_UserTimeZone" and "ew_UserCalendar" have been already defined in "Global Code" just like "ew_UserFormatDateTime" function above.

  2. If you enable "Include common files" option for your custom file, then the code in step 2 above will work properly.


btrade
User
Posts: 357

Post by btrade »

Thanks guys


Post Reply