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; } } }