Radicore Forum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » RADICORE development » Bug Reports » mnu_user - getData returns bad data?
mnu_user - getData returns bad data? [message #296] Wed, 27 September 2006 01:27 Go to next message
ljkbrost is currently offline  ljkbrost
Messages: 59
Registered: April 2006
Member
When I use the following code I don't get the results that I expect.

Run 1:
$theTable = new mnu_user();
$theUserData = $theTable->getData("user_id LIKE 'NonExistantUser'");
print_r($theUserData);

Results:

Array
(
[0] => 1
)


Versus:

Run 2:
$theTable = new mnu_user();
$theUserData = $theTable->getData("user_id LIKE 'MGR'");
print_r($theUserData);

Results:

Array
(
[0] => Array
(
[user_id] => MGR
[user_name] => MGR
[user_password] => Nz-3jN6+lK@Ii^DE
[role_id] => GLOBAL
[pswd_chg_date] => 2004-08-01
[pswd_chg_time] => 16:51:04
[pswd_count] => 7
[in_use] => Y
[is_disabled] => N
[logon_date] => 2006-09-26
[logon_time] => 22:35:14
[language_code] =>
[start_date] => 2003-01-01
[end_date] => 9999-12-31
[ip_address] => 127.0.0.1
[email_addr] =>
[created_date] => 2003-01-01 12:00:00
[created_user] => AJM
[revised_date] => 2005-11-02 18:05:54
[revised_user] => AJM
)

)


I would expect the first result to return nothing. I am using v1.16 of the framework and think I have tracked the problem down to the mnu_user.class.inc and the _cm_post_getData(...) function.

if ($encrypt_flag == true) {
if (is_array(key($rows))) {
foreach ($rows as $row => $rowdata) {
// insert dummy field to say that data is currently encrypted
$rows[$row]['pswd_is_encrypted'] = true;
// do not output any passwords
//unset($rows[$row]['user_password']);
} // foreach
} else {
$rows['pswd_is_encrypted'] = true;
} // if

} // if

The function looks like it is trying to determine if the result is an array of records versus a single record. I think the 'else' clause has a problem and should do a second check on the size of $rows to ensure that it has at least one element before setting the $rows['pswd_is_encrypted'].

My fix:

if ($encrypt_flag == true) {
if (is_array(key($rows))) {
foreach ($rows as $row => $rowdata) {
// insert dummy field to say that data is currently encrypted
$rows[$row]['pswd_is_encrypted'] = true;
// do not output any passwords
//unset($rows[$row]['user_password']);
} // foreach
} else {
if(sizeof($rows) > 0) {
$rows['pswd_is_encrypted'] = true;
}
} // if

} // if


I'm not sure if my fix is correct as I'm not sure what the code is intended to do.

Cheers,


Kyle Brost
----
Re: mnu_user - getData returns bad data? [message #297 is a reply to message #296] Wed, 27 September 2006 05:24 Go to previous messageGo to next message
AJM is currently offline  AJM
Messages: 2371
Registered: April 2006
Location: Surrey, UK
Senior Member
Part of that code is now redundant and should be:
if ($encrypt_flag == true) {
    foreach ($rows as $row => $rowdata) {
        // insert dummy field to say that data is currently encrypted
        $rows[$row]['pswd_is_encrypted'] = true;
    } // foreach
} // if

Attached is an updated version of the file.


Previous Topic: REVISED_DATE and REVISED_USER not being updated
Next Topic: Custome validation error
Goto Forum:
  


Current Time: Fri Nov 29 02:46:13 EST 2024

Total time taken to generate the page: 0.01009 seconds