Bug v. 7.13? Duplicate meeting, I change the assigned user and the calendar shows me double

It is a bug that I have found in Version 7.13 that I use.

Steps to reproduce the error:

Create a meeting and assign it to yourself.

If I later duplicate the meeting and change the date and assign it to another user, the duplicate meeting appears double in the calendar if I have the 2 users selected in the list of calendar users.

The correct thing is that only one record was seen, not repeated twice. It can cause confusion.

Do you know what could be the cause of that?

If anyone else can help, I’ve also posted on Github.

if you have investigated, then you can fix the “meetings_users” table in after save hook of Meetings module.

Thanks for the help.

When saving the duplicate and edited meeting by changing the assignee, the “meetings_users” table creates two meeting records with 2 “user_ids”: the id of the old assignee and the id of the new assignee. This makes it look repeated in the calendar when we have chosen a shared month and see the records of all users in the calendar settings.

In addition, a single record is created in the “meetings” table with the meeting and the assigned user in “assigned_user_id”.

How could I create a logic hook with after_save_method that sets the value delete = 1 in the record of the “meetings_users” table when the “assigned_user_id” of the “meetings” table is not equal to the “user_id” of the “meetings_users” table ?

That’s the situation where logic_hook should be triggered after save to clean up this issue, but I don’t know how to do it :frowning:

I have managed to solve the problem for myself.

Go to modules/Meetings/MeetingFormBase.php and comment or remove all this code:

//add assigned user and current user if this is the first time bean is saved
        if (empty($focus->id) && !empty($_REQUEST['return_module']) && $_REQUEST['return_module'] =='Meetings' && !empty($_REQUEST['return_action']) && $_REQUEST['return_action'] =='DetailView') {
            //if return action is set to detail view and return module to meeting, then this is from the long form, do not add the assigned user (only the current user)
            //The current user is already added to UI and we want to give the current user the option of opting out of meeting.
            //add current user if the assigned to user is different than current user.
            if ($current_user->id != $_POST['assigned_user_id']) {
                $_POST['user_invitees'] .= ','.$_POST['assigned_user_id'].', ';
                $_POST['user_invitees'] = str_replace(',,', ',', $_POST['user_invitees']);
            }
        } elseif (empty($focus->id)) {
            //this is not from long form so add assigned and current user automatically as there is no invitee list UI.
            //This call could be through an ajax call from subpanels or shortcut bar
            if (!isset($_POST['user_invitees'])) {
                $_POST['user_invitees'] = '';
            }

            $_POST['user_invitees'] .= ','.$_POST['assigned_user_id'].', ';

            //add current user if the assigned to user is different than current user.
            if ($current_user->id != $_POST['assigned_user_id'] && $_REQUEST['module'] != "Calendar") {
                $_POST['user_invitees'] .= ','.$current_user->id.', ';
            }

            //remove any double comma's introduced during appending
            $_POST['user_invitees'] = str_replace(',,', ',', $_POST['user_invitees']);
        }

I don’t send invites or use meeting invites or reminders, so this code is not necessary for me and this is where I get duplicate meetings on my calendar.

It’s not quite right.

Now when duplicating and changing the assigned to the meeting in the “Meetings_users” table, it only makes a record, always putting as “user_id” the id of the person who creates or duplicates the record and not the assigned user, which means that they are not seen in the calendar records assigned to another user when “view only records from that user” is selected in the calendar settings :confused:

I’ve managed to modify the above snippet so that duplicating meetings and changing the assigned user doesn’t create double calendar entries:

 //add assigned user and current user if this is the first time bean is saved
        if (empty($focus->id) && !empty($_REQUEST['return_module']) && $_REQUEST['return_module'] =='Meetings' && !empty($_REQUEST['return_action']) && $_REQUEST['return_action'] =='DetailView') {
            //if return action is set to detail view and return module to meeting, then this is from the long form, do not add the assigned user (only the current user)
            //The current user is already added to UI and we want to give the current user the option of opting out of meeting.
            //add current user if the assigned to user is different than current user.
            if ($current_user->id != $_POST['assigned_user_id']) {
                $_POST['user_invitees'] = str_replace(',,', ',', $_POST['assigned_user_id']);
            }
        } {
         

            //remove any double comma's introduced during appending
            $_POST['user_invitees'] = str_replace(',,', ',', $_POST['assigned_user_id']);
        }

There’s probably a cleaner way of achieving this, later in that same function. The values that are being set there will change the way the rest of the (very long) function works. If you can get to the place that makes the difference, and guard it with a simple condition (“when duplicating meeting”), that would be ideal.

Any way, nice work getting this far :muscle: