public function rejectFile($data) { if (is_array($data['files'])) { foreach ($data['files'] as $file) { $checkBox[] = array('id' => $file); } } else { $checkBox[] = array('id' => $data['files']); } $reviewerComments = 'To= ' . $data['form']['to'] . ';Subject= ' . $data['form']['subject'] . ' ;Comments= ' . $data['form']['comments']; $date = date('M-d-Y H:i'); $fullName = $this->session->firstName . ' ' . $this->session->lastName; $reviewerEmail = $this->session->email; $reviewerPhone = $this->session->phone; $reviewerDept = $this->userObj->getDeptName(); if ($this->session->admin) { $idArray = $this->userObj->getAllRevieweeIds(); } else { $idArray = $this->userObj->getRevieweeIds(); } foreach ($checkBox as $key => $value) { // Check to make sure the current file_id is in their list of reviewable ID's if (in_array($value, $idArray)) { $fileId = $value['id']; $newFileObj = new Document_Model($fileId); $newUserObj = new User_Model($newFileObj->getOwner()); $mailTo = $newUserObj->getEmailAddress(); $deptId = $newFileObj->getDepartment(); if (isset($data['form']['sendToUsers'][0]) && in_array('owner', $data['form']['sendToUsers'])) { $data['form']['sendToUsers'] = array_slice($data['form']['sendToUsers'], 1); $emailData = array('reviewer' => $fullName, 'title' => 'Author', 'fileName' => $newFileObj->getRealName(), 'status' => 'Rejected', 'data' => date('l \\t\\h\\e jS'), 'msg' => ' was rejected the document repository.', 'email' => $reviewerEmail, 'siteName' => $this->config->item('site_name'), 'phoneNumber' => $reviewerPhone, 'department' => $reviewerDept, 'comments' => $data['form']['comments']); $body = $this->load->view('emails/publish_file_email_view', $emailData, true); $subject = $newFileObj->getRealName() . ' has been rejected by ' . $fullName; $this->email->setFrom($reviewerEmail, $fullName); $this->email->addAddress($mailTo, $fullName); $this->email->Subject = $subject; $this->email->msgHTML($body); $this->email->send(); } $newFileObj->Publishable(-1); $newFileObj->setReviewerComments($reviewerComments); AccessLog_Model::addLogEntry($fileId, 'R'); echo json_encode(array('status' => 'success', 'msg' => 'File Status successfully updated.')); } else { echo json_encode(array('status' => 'error', 'msg' => 'You cannot alter this files status.')); exit; } } }
public function emailPeople($id) { $fileObj = new Document_Model($id); /** * Send out email notifications to reviewers */ $fullName = $this->session->firstName . ' ' . $this->session->lastName; $from = $this->session->email; $phone = $this->session->phone; $department = $fileObj->getDepartment(); $departmentName = Department_Model::getDepartmentById($department); $reviewerList = $this->reviewer->getReviewersForDepartment($department) ? $this->reviewer->getReviewersForDepartment($department) : null; $userList = null; $emailList = null; if (null !== $reviewerList) { $userList = $this->emailModel->getEmailUserObj($reviewerList) ? $this->emailModel->getEmailUserObj($reviewerList) : null; } if (null !== $userList) { $emailList = $this->emailModel->getEmailList($userList) ? $this->emailModel->getEmailList($userList) : null; } $newArray = array(); $usedEmails = array(); if (null !== $emailList) { foreach ($emailList as $email) { if (!in_array($email['email'], $usedEmails)) { $usedEmails[] = $email['email']; $newArray[] = $email; } } $emailList = $newArray; unset($newArray, $usedEmails); $comment = $fileObj->getComment(); if ($comment === '') { $comment = 'No Comments.'; } $date = date('M-d-Y H:i'); $emailData = array('uploader' => $fullName, 'title' => 'Reviewer', 'fileName' => $fileObj->getRealName(), 'status' => 'Pending', 'date' => date('l \\t\\h\\e jS'), 'msg' => 'was submitted into the document repository by', 'email' => $from, 'phoneNumber' => $phone, 'department' => $departmentName[0]->name, 'comment' => $comment); $body = $this->load->view('emails/new_file_submission', $emailData, true); $subject = $fileObj->getRealName() . ' has been submitted by ' . $fullName; foreach ($emailList as $email) { if ($email['email'] != '' && $email['fullname'] != '') { $this->email->from($from, $fullName); $this->email->to($email['email'], $email['fullname']); $this->email->subject = $subject; $this->email->message($body); $this->email->send(); } } } }