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
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 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.
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.
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.
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".
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', ',');
function ew_UserFormatDateTime($field, $default) {
$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', ',');
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.
If you enable "Include common files" option for your custom file, then the code in step 2 above will work properly.