/** * Return the section decision * Internal function to return an meeting object from a row. Simplified * not to include object settings. * @param $row array * @return section_decision_id */ function &_returnMeetingSectionDecisionFromRow(&$row) { $meetingSectionDecision = new MeetingSectionDecision(); $meetingSectionDecision->setMeetingId($row['meeting_id']); $meetingSectionDecision->setSectionDecisionId($row['section_decision_id']); HookRegistry::call('MeetingSectionDecsisionDAO::_returnMeetingSectionDecisionFromRow', array(&$meetingSectionDecision, &$row)); return $meetingSectionDecision; }
function saveMeeting($meetingId, $sectionDecisionsId, $meetingDate, $meetingLength, $investigator, $location = null, $final = null) { $user =& Request::getUser(); $journal =& Request::getJournal(); $journalId = $journal->getId(); $meetingDao =& DAORegistry::getDAO('MeetingDAO'); /** * Parse date * */ if ($meetingDate != null) { $meetingDateParts = explode('-', $meetingDate); $tmp = explode(' ', $meetingDateParts[2]); $meetingTime = $tmp[1]; $meetingTimeMarker = $tmp[2]; $meetingTimeParts = explode(':', $meetingTime); $hour = intval($meetingTimeParts[0]); if (strcasecmp($meetingTimeMarker, 'pm') == 0) { if ($hour != 12) { $hour += 12; } } else { if ($hour == 12) { $hour = 0; } } $meetingDate = mktime($hour, (int) $meetingTimeParts[1], 0, (int) $meetingDateParts[1], (int) $meetingDateParts[2], (int) $meetingDateParts[0]); } $hasChanged = false; if ($meetingId == null || $meetingId == 0) { $isNew = true; $meeting = new Meeting(); } else { $isNew = false; $meeting = $meetingDao->getMeetingById($meetingId); if ($meetingDate - strtotime($meeting->getDate()) != 0) { $hasChanged = true; } elseif ($location != $meeting->getLocation()) { $hasChanged = true; } } $meeting->setUploader($user->getSecretaryCommitteeId()); $meeting->setDate($meetingDate); $meeting->setLength($meetingLength); $meeting->setLocation($location); $meeting->setInvestigator($investigator); $meeting->setMinutesStatus(MINUTES_STATUS_INCOMPLETE); if ($final) { $meeting->setStatus(STATUS_FINAL); } elseif ($isNew) { $meeting->setStatus(STATUS_NEW); } else { $meeting->setStatus(STATUS_RESCHEDULED); } if ($isNew) { $meeting->setId($meetingDao->insertMeeting($meeting)); } // Set attendances if ($isNew || $hasChanged) { $ercReviewersDao =& DAORegistry::getDAO('ErcReviewersDAO'); // Insert Attendance of the external reviewers & Investigators $articleDao =& DAORegistry::getDAO('ArticleDAO'); $sectionDecisionDao =& DAORegistry::getDAO('SectionDecisionDAO'); foreach ($sectionDecisionsId as $sectionDecisionId) { // For external reviewers $sectionDecision =& $sectionDecisionDao->getSectionDecision($sectionDecisionId); $reviewAssignments =& $sectionDecision->getReviewAssignments(); foreach ($reviewAssignments as $reviewAssignment) { $isReviewer = $ercReviewersDao->ercReviewerExists($journalId, $user->getSecretaryCommitteeId(), $reviewAssignment->getReviewerId()); if (!$isReviewer) { $meetingAttendance = new MeetingAttendance(); $meetingAttendance->setMeetingId($meeting->getId()); $meetingAttendance->setUserId($reviewAssignment->getReviewerId()); $meetingAttendance->setTypeOfUser(MEETING_EXTERNAL_REVIEWER); $meetingAttendance->setIsAttending(MEETING_NO_REPLY); $meetingAttendance->setWasPresent(MEETING_NO_REPLY); $meetingAttendance->setReasonForAbsence(''); $meeting->addMeetingAttendance($meetingAttendance); } } // For investigator if ($investigator == 1) { $article =& $articleDao->getArticle($sectionDecision->getArticleId()); $meetingAttendance = new MeetingAttendance(); $meetingAttendance->setMeetingId($meeting->getId()); $meetingAttendance->setUserId($article->getUserId()); $meetingAttendance->setTypeOfUser(MEETING_INVESTIGATOR); $meetingAttendance->setIsAttending(MEETING_NO_REPLY); $meetingAttendance->setWasPresent(MEETING_NO_REPLY); $meetingAttendance->setReasonForAbsence(''); $meeting->addMeetingAttendance($meetingAttendance); } } // Insert Attendance of the reviewers $reviewers =& $ercReviewersDao->getReviewersBySectionId($journalId, $user->getSecretaryCommitteeId()); foreach ($reviewers as $reviewer) { $meetingAttendance = new MeetingAttendance(); $meetingAttendance->setMeetingId($meeting->getId()); $meetingAttendance->setUserId($reviewer->getId()); $meetingAttendance->setTypeOfUser(MEETING_ERC_MEMBER); $meetingAttendance->setIsAttending(MEETING_NO_REPLY); $meetingAttendance->setWasPresent(MEETING_NO_REPLY); $meetingAttendance->setReasonForAbsence(''); $meeting->addMeetingAttendance($meetingAttendance); } // Insert Attendance of the secretary(ies) $sectionEditorsDao =& DAORegistry::getDAO('SectionEditorsDAO'); $secretaries =& $sectionEditorsDao->getEditorsBySectionId($journalId, $user->getSecretaryCommitteeId()); foreach ($secretaries as $secretary) { $meetingAttendance = new MeetingAttendance(); $meetingAttendance->setMeetingId($meeting->getId()); $meetingAttendance->setUserId($reviewer->getId()); if (!$secretary->getId() == $user->getId()) { $meetingAttendance->setIsAttending(MEETING_REPLY_ATTENDING); } else { $meetingAttendance->setIsAttending(MEETING_NO_REPLY); } $meetingAttendance->setWasPresent(MEETING_NO_REPLY); $meetingAttendance->setReasonForAbsence(''); $meeting->addMeetingAttendance($meetingAttendance); } } /** * Store submissions to be discussed */ if (count($sectionDecisionsId) > 0) { $oldSectionDecisions = $meeting->getMeetingSectionDecisions(); foreach ($oldSectionDecisions as $oldSectionDecision) { $isHere = false; for ($i = 0; $i < count($sectionDecisionsId); $i++) { if ($oldSectionDecision->getSectionDecisionId() == $sectionDecisionsId[$i]) { $isHere = true; } } if (!$isHere) { $meeting->removeMeetingSectionDecision($oldSectionDecision->getSectionDecisionId()); } } for ($i = 0; $i < count($sectionDecisionsId); $i++) { $isHere = false; foreach ($oldSectionDecisions as $oldSectionDecision) { if ($oldSectionDecision->getSectionDecisionId() == $sectionDecisionsId[$i]) { $isHere = true; } } if (!$isHere) { $meetingSectionDecision = new MeetingSectionDecision(); $meetingSectionDecision->setMeetingId($meeting->getId()); $meetingSectionDecision->setSectionDecisionId($sectionDecisionsId[$i]); $meeting->addMeetingSectionDecision($meetingSectionDecision); } } } $meetingDao->updateMeeting($meeting); if ($final) { Request::redirect(null, null, 'notifyUsersMeeting', array($meeting->getId(), 'MEETING_FINAL')); } elseif ($isNew) { Request::redirect(null, null, 'notifyUsersMeeting', array($meeting->getId(), 'MEETING_NEW')); } elseif ($hasChanged) { Request::redirect(null, null, 'notifyUsersMeeting', array($meeting->getId(), 'MEETING_CHANGE')); } else { Request::redirect(null, null, 'viewMeeting', array($meeting->getId())); } return $meeting->getId(); }