ID_User (Update)

Iganothor

New member
I've changed the config.php to allow everyone to change and update values even if they didn't create it, but is there a way to track who made an update? So they log in, then if they update or change any information it will swap the ID-User with whoever updated it last rather than who originally created it? Kinda of a Update_ID_User option?

Thank you for any help you can offer,
 

DebbieS

DaDaBIK Guru
I don't know. Sorry, I have not played much with the auth or user id portion of DaDaBIK -- we are using it in only one of our installs and it is a very simple/basic implementation. Perhaps others on the board have expanded the auth more and can provide some insight.

 

Moonrakre

New member
I too would like to do this. My users are taking cash against an existing database of runners and so I would like to know how much cash each user should be paying into the pot. So if anyone has an answer this would be much valued, please

 

eugenio

Administrator
Staff member
Moonrakre wrote:

> I too would like to do this. My users are taking cash against
> an existing database of runners and so I would like to know how
> much cash each user should be paying into the pot. So if
> anyone has an answer this would be much valued, please

config.php:

$enable_authentication = 1;

$enable_update_authorization = 0;

$enable_browse_authorization = 0;

Bye,

 

Moonrakre

New member
Thank you Eugenio.

This doesn't appear to do what I need. It allows users to login and change records but doesn't record who last changed the records.

This may be overkill, but I think I need to do the following:-

In business_logic.php
find
function update_record($_FILES, $_POST, $fields_labels_ar, $table_name, $table_internal_name, $where_field, $where_value, $update_type)

a few lines down add $current_user to the global statement viz:
global $conn, $ext_updated_field, $quote, $use_limit_in_update, $upload_directory, $current_user;

Then Find:
// no, since I don't handle select_multiple anymore, I delete isset, and anyway it was not correct because for a file $_POST[$field_name_temp] is not set
if ($fields_labels_ar[$i][$field_to_check] == "1" or $fields_labels_ar[$i]["type_field"] == "update_date"){ // if the field is in the form or need to be inserted because it's an update data

And change the if statement to include the ID_user instance:
if ($fields_labels_ar[$i][$field_to_check] == "1" or $fields_labels_ar[$i]["type_field"] == "update_date" or $fields_labels_ar[$i]["type_field"] == "ID_user"){ // if the field is in the form or need to be inserted because it's an update data or ID_user

Then before case 'select_single': add a new case:

case "ID_user":
$sql .= $quote.$field_name_temp.$quote." = "; // add the field name to the sql statement
$sql .= "'".$current_user."', "; // add the field name to the sql statement
break;

Note that there are some implications on the auth user setup, because this changes the owner of the record to the updater.

This seems to work on my installation, could someone check it out for me please as I am not much of a coder.

Best wishes

Adrian

 

eugenio

Administrator
Staff member
Hi Adrian,
yes you are right DaDaBIK only put the username during the insert operation.

I have not analyzed nor tested your mod but it seems correct to me.


Bye,

 

rboatright

New member
But, if multiple people edit the record, you're only going to have the LAST editor recorded.

If you really need to record transactions, you're going to need a more-complex transactions model using a header/detail model where users can only ADD records debiting or crediting the total.

 

uwec

New member
Very simple soloution:

Create a simple text field , and generate its content whith the following function.

In custom_functions.php :

[pre]
/**
Returns the current User for a calculated field.
*/
function dadabik_calculate_current_user($parameters) {
global $current_user;
return $current_user;
}

And add the function to the field.

So its updated on creation and update.
[/pre]
 
Top