private function onCreateAttachment() { if ($this->_accessLevel < ACCESS_LEVEL_EDIT) { CommonErrors::fatal(COMMONERROR_PERMISSION, $this, 'Invalid user level for action.'); } /* Bail out if we don't have a valid candidate ID. */ if (!$this->isRequiredIDValid('candidateID', $_POST)) { CommonErrors::fatalModal(COMMONERROR_BADINDEX, $this, 'Invalid candidate ID.'); } /* Bail out if we don't have a valid resume status. */ if (!$this->isRequiredIDValid('resume', $_POST, true) || $_POST['resume'] < 0 || $_POST['resume'] > 1) { CommonErrors::fatalModal(COMMONERROR_RECORDERROR, $this, 'Invalid resume status.'); } $candidateID = $_POST['candidateID']; if ($_POST['resume'] == '1') { $isResume = true; } else { $isResume = false; } if (!eval(Hooks::get('CANDIDATE_ON_CREATE_ATTACHMENT_PRE'))) { return; } $attachmentCreator = new AttachmentCreator($this->_siteID); $attachmentCreator->createFromUpload(DATA_ITEM_CANDIDATE, $candidateID, 'file', false, $isResume); if ($attachmentCreator->isError()) { CommonErrors::fatalModal(COMMONERROR_FILEERROR, $this, $attachmentCreator->getError()); return; //$this->fatalModal($attachmentCreator->getError()); } if ($attachmentCreator->duplicatesOccurred()) { $this->fatalModal('This attachment has already been added to this candidate.'); } $isTextExtractionError = $attachmentCreator->isTextExtractionError(); $textExtractionErrorMessage = $attachmentCreator->getTextExtractionError(); $resumeText = $attachmentCreator->getExtractedText(); if (!eval(Hooks::get('CANDIDATE_ON_CREATE_ATTACHMENT_POST'))) { return; } $this->_template->assign('resumeText', $resumeText); $this->_template->assign('isFinishedMode', true); $this->_template->assign('candidateID', $candidateID); $this->_template->display('./modules/candidates/CreateAttachmentModal.tpl'); }