public function authorizeFile($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'); $getFullName = $this->userObj->getFullName(); $fullName = $getFullName[0] . ' ' . $getFullName[1]; $reviewerEmail = $this->userObj->getEmailAddress(); $reviewerPhone = $this->userObj->getPhoneNumber(); $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(); $userName = $newUserObj->getFullName(); $userFullName = $userName[0] . ' ' . $userName[1]; $deptId = $newFileObj->getDepartment(); // Build email for author notification if (isset($data['form']['sendToUsers'][0]) && in_array('owner', $data['form']['sendToUsers'])) { // Lets unset this now so the new array will just be user_id's $data['form']['sendToUsers'] = array_slice($data['form']['sendToUsers'], 1); $emailData = array('reviewer' => $fullName, 'title' => 'Author', 'fileName' => $newFileObj->getRealName(), 'status' => 'Authorized', 'date' => date('l \\t\\h\\e jS'), 'msg' => ' was accepted into 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 accepted by ' . $fullName; $this->email->setFrom($reviewerEmail, $fullName); $this->email->addAddress($mailTo, $userFullName); $this->email->Subject = $subject; $this->email->msgHTML($body); $this->email->send(); } $newFileObj->Publishable(1); $newFileObj->setReviewerComments($reviewerComments); AccessLog_Model::addLogEntry($fileId, 'Y'); } else { echo json_encode(array('status' => 'error', 'msg' => 'You cannot alter this files status.')); exit; } } echo json_encode(array('status' => 'success', 'msg' => 'File Status successfully updated.')); }
/** * return owner's full name in an array where index=0 corresponds to the last name * and index=1 corresponds to the first name * @return mixed */ public function getOwnerFullName() { $userObj = new User_Model($this->owner); return $userObj->getFullName(); }
/** * return the username of the reviewer * @return bool */ public function getReviewerName() { $reviewerId = $this->getReviewerID(); if (isset($reviewerId)) { $userObj = new User_Model($reviewerId); return $userObj->getFullName(); } return false; }