16 import(
'lib.pkp.classes.scheduledTask.ScheduledTask');
20 private $_roleIds = [ROLE_ID_MANAGER, ROLE_ID_SUB_EDITOR];
23 private $_sleepEvery = 100;
26 private $_sleepBy = 2;
32 public function getName() :
string
34 return __(
'admin.scheduledTask.statisticsReport');
43 import(
'lib.pkp.classes.notification.managerDelegate.EditorialReportNotificationManager');
49 for ($contexts = $contextDao->getAll(
true); $context = $contexts->next(); ) {
51 [LOCALE_COMPONENT_PKP_USER, LOCALE_COMPONENT_PKP_MANAGER, LOCALE_COMPONENT_PKP_SUBMISSION, LOCALE_COMPONENT_PKP_COMMON, LOCALE_COMPONENT_APP_COMMON],
52 $context->getPrimaryLocale()
55 $editorialReportNotificationManager->initialize(
57 new DateTimeImmutable(
'first day of previous month midnight'),
58 new DateTimeImmutable(
'first day of this month midnight')
60 $notifiedUsersSet = [];
61 foreach ($this->_roleIds as $roleId) {
62 for ($userGroups = $userGroupDao->getByRoleId($context->getId(), $roleId); $userGroup = $userGroups->next(); ) {
63 for ($users = $userGroupDao->getUsersById($userGroup->getId(), $context->getId()); $user = $users->next(); ) {
64 if (isset($notifiedUsersSet[$user->getId()])) {
67 $editorialReportNotificationManager->notify($user);
68 $notifiedUsersSet[$user->getId()] = 0;
69 if (!(++$sentMessages % $this->_sleepEvery)) {
70 sleep($this->_sleepBy);