meeting-room-booking-system / mrbs-code

MRBS application code
Other
127 stars 62 forks source link

How do I change create_by as an admin #2390

Open jberanek opened 5 years ago

jberanek commented 5 years ago

Hello,

I want to set so admins can change for whom is the room reserved(create_by). I wrote this:

function create_field_create_by($disabled = FALSE) {
    global $create_by, $is_admin, $users;

    echo "<div id=\"div_create_by\">\n";
    if($is_admin){
        $options = array();
        // go through the areas and create the options
        foreach ($users as $u) {
            $options[$u['id']] = $u['name'];
        }

        $params = array('label' => get_vocab("reserving_for") . ":",
            'name' => 'create_by',                        
            'field' => 'entry.create_by',
            'options' => $options,
            'force_assoc' => TRUE);

        generate_select($params);
    } 
    else {
        $params = array('label' => get_vocab("reserving_for") . ":",
            'name' => 'create_by',
            'field' => 'entry.create_by',
            'value' => $create_by,
            'type' => 'text',
            'attributes' => 'readonly',
            'pattern' => REGEX_TEXT_POS,
            'disabled' => $disable_field,
            'mandatory' => TRUE);

        generate_input($params);
    }
    echo "</div>\n";
}

It's kinda working but when I select any name in the select box as an admin, it will always save the book as the original user that created it, not the name I selected...

Any thoughts?

Reported by: *anonymous

Original Ticket: mrbs/support-requests/1687

jberanek commented 5 years ago

If you download the latest code from the default branch you will find that this feature has already been implemented. It will involve a database upgrade so take backups first.

Original comment by: campbell-m

jberanek commented 5 years ago

There is a config setting which enables and disables this feature. Can't remember if it is enabled by default. I think it is, but check in systemdefaults.inc.php.

Original comment by: campbell-m

jberanek commented 5 years ago

Oh boy, I gotta upgrade this system.

Thanks!!

Original comment by: *anonymous

jberanek commented 5 years ago

Just to be clear, I meant that you'll need to download the latest development code from the default branch which you can get from here.

Original comment by: campbell-m