Sending email to all reviewers

Hello,

First, not to forget: I am using the OJS 2.4.1-1.

I would like to extend the editors notify users (Home->Editor->Notify Users) functionality with a possibility to send email notification to all reviewers. That is to add a new radio button “All reviewers” on the “Send Email” page.

I have basically copied the code from the “All readers” option in several files, but I think the most important is the “IssueManagementHandler.inc.php” file. The new code I have added is:

            case 'allReviewers':
                $recipients =& $roleDao->getUsersByRoleId(
                    ROLE_ID_REVIEWER,
                    $journal->getId()
                );
                break;

The problem is that I don’t get any reviewers listed (in the “Send email” page it says 0 users). If I change the “ROLE_ID_REVIEWER” to the “ROLE_ID_READER” it works correctly.

Any idea what I am doing wrong? I would expect that just changing the role ID is enough that the call “getUsersByRoleID” returns users with the selected role ID, but obviously not.

Regards, Primož

Hi @primozs,

Have you checked your PHP error log e.g. for warnings? I wonder if you’ll find an undefined constant warning there.

Regards,
Alec Smecher
Public Knowledge Project Team

Hi @asmecher ,

Good point, I forgot to check the log file, but I was sure the constant is OK.

However, I have checked the log and nothing there. The point is that I have tried with the value itself as well, with the value that works directly in DB with an SQL statement.

Regards, Primož

Hi @primozs,

I would suggest turning on the debug option in your config.inc.php (warning – this will dump the full SQL query list to the browser for all users), capturing the resulting database query, and testing it manually on your database.

Regards,
Alec Smecher
Public Knowledge Project Team

1 Like

Hi @asmecher ,

Thank you for the very good answer.

After turning on the debug I suspect I am not looking into correct files. I don’t get the SQL statement I should.

Now I have a situation where I have changed the IssueManagementHandler.inc.php, in the notifyUsers I modified the case "“AllReaders” so that it should return all reviewers (the role define is ROLE_ID_REVIEWER). So I should get a list of reviewers instead of readers for this case. But the SQL statement still contains the role for readers in stead of reviewers.

So I guess the IssueManagementHandler.inc.php file is not the correct one. Am I right? Which file is that the one I should change?

Oh, I have done clear all data cache and clear template cache…

Best regards, Primož

Hi @primozs,

Would you be willing to post your modifications on a github fork? It would be much easier to look them over that way.

Regards,
Alec Smecher
Public Knowledge Project Team

Hi @asmecher,

I am sorry I am not good enough with the GitHub :frowning: But I simplified my changes so it is very easy to understand.

I have “undo” all the changes and changed only the file “IssueManagementHandler.inc.php”. What I would like to try is to get a list of reviewers instead of a list of readers.

My understanding is that the template “notifyUsers.tpl” calls “IssueManagementHandler.inc.php”, precisely that the code

 <tr valign="top">
     <td><input type="radio" id="allReaders" name="whichUsers" value="allReaders"/></td>
     <td class="label">
         <label for="allReaders">{translate key="editor.notifyUsers.allReaders" count=$allReadersCount|default:0}</label>
     </td>
 </tr>

calls the code

case 'allReaders':
                    $recipients =& $roleDao->getUsersByRoleId(
                        ROLE_ID_REVIEWER, /*ROLE_ID_READER,*/
                        $journal->getId()
                    );

So I changed the ROLE_ID_READER to ROLE_ID_REVIEWER as you can see above.

The problem is that the SQL debug shows the SQL statement

(mysql): SELECT COUNT(DISTINCT(user_id)) FROM roles WHERE journal_id = 1 AND role_id = 1048576

that is the define for the ROLE_ID_READER instead of

(mysql): SELECT COUNT(DISTINCT(user_id)) FROM roles WHERE journal_id = 1 AND role_id = 4096

which is the define for the ROLE_ID_REVIEWER

So I guess I have not figured out correct way to do this. I think I am looking into wrong files…

Best regards, Primož

Hi @primozs,

Is it possible that you’re just missing the break after your new case block?

Regards,
Alec Smecher
Public Knowledge Project Team

Hi @asmecher
Thank you for your help. After some more looking in to the code it turned out that my first attempt has been in right direction, but not all changes have been done.

Beside the code changes above there is another location in the IssueManagementHandler.inc.php that has to be changed/added. That is at the end of the function NotifyUsers in the call $email->displayEditForm where the array has to be extended with the reviewers element:

                'allReadersCount' => $roleDao->getJournalUsersCount($journal->getId(), ROLE_ID_READER),
                'allReviewersCount' => $roleDao->getJournalUsersCount($journal->getId(), ROLE_ID_REVIEWER),

Now it works!

Regards, Primož

1 Like