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;
         }
     }
 }
Beispiel #2
0
 public function getFileDetails()
 {
     if (strchr($this->requestId, '_')) {
         list($this->requestId, $revisionId) = explode('_', $this->requestId);
         $fileSize = $this->globalFunctions->displayFilesize($this->config->item('revisionDir') . $this->requestId . '/' . $this->requestId . '_' . $revisionId);
     }
     $fileDataObj = new Document_Model($this->requestId);
     $archived = $fileDataObj->isArchived();
     $publishable = $fileDataObj->isPublishable();
     $this->globalFunctions->checkUserPermission($this->requestId, $this->config->item('VIEW_RIGHT'), $fileDataObj);
     $userPermsObj = new User_Perms_Model();
     $userPermissionObj = new Userpermission_Model();
     $userObj = new User_Model($fileDataObj->getOwner());
     // display details - calls the parent function in functions.php
     $ownerId = $fileDataObj->getOwner();
     $category = $fileDataObj->getCategoryName();
     $ownerFullName = $fileDataObj->getOwnerFullName();
     $owner = $ownerFullName[1] . ', ' . $ownerFullName[0];
     $realName = $fileDataObj->getRealName();
     $created = $fileDataObj->getCreatedDate();
     $description = $fileDataObj->getDescription();
     $comment = $fileDataObj->getComment();
     $status = $fileDataObj->getStatus();
     $reviewer = $fileDataObj->getReviewerName();
     $location = $fileDataObj->getLocation();
     $fileExt = $fileDataObj->getExt();
     $file = $fileDataObj->getBaseName();
     $thumbnail = $fileDataObj->getThumbnail();
     $lmimetype = File_Model::mimeByExt($fileExt);
     $viewFileLink = $this->config->item('dataDir') . $location;
     $historyLink = 'history/' . $this->requestId;
     $viewInBrowser = null;
     $fileUnderReview = $publishable == -1 ? true : false;
     $editFileLink = null;
     if ($status == 0 && !$publishable && $userPermsObj->canView($this->requestId)) {
         $fileUnlocked = true;
     } else {
         $fileUnlocked = false;
     }
     if ($status > 0) {
         // status != 0 -> file checked out to another user. status = uid of the check-out person
         // query to find out who...
         $checkoutPersonObj = $fileDataObj->getCheckerOBJ();
         $fullName = $checkoutPersonObj->getFullName();
     }
     switch ($fileExt) {
         case 'html':
         case 'php':
             $viewInBrowser = base_url() . $this->config->item('dataDir') . 'pdf/' . $file . '.pdf';
             break;
         case 'pdf':
             $viewInBrowser = base_url() . $this->config->item('dataDir') . $location;
             break;
         case 'doc':
         case 'docx':
             $viewInBrowser = base_url() . $this->config->item('dataDir') . $file . '.pdf';
             break;
     }
     //Get the information for the files revision history
     if (!empty($revisionId)) {
         $historyResult = $fileDataObj->getRevisionHistory($revisionId);
     } else {
         $historyResult = $fileDataObj->getCurrentRevision();
     }
     //get the number of revisions.
     $rows = $historyResult->num_rows();
     (array) ($fileHistory = null);
     foreach ($historyResult->result() as $row) {
         $revision = $row->revision;
         if (is_file($this->config->item('revisionDir') . $this->requestId . '/' . $this->requestId . "_{$revision}" . '.' . $fileExt)) {
             $revision = '<a href="details/' . $this->requestId . "_{$revision}" . '"><div class="revision">' . ($revision + 1) . '</div></a>';
         }
         $fileHistory[] = array('lastName' => $row->last_name, 'firstName' => $row->first_name, 'modifiedOn' => $row->modified_on, 'note' => $row->note, 'revision' => $revision);
     }
     if (!is_array($fileHistory)) {
         $fileHistory[] = array('lastName' => 'Info', 'firstName' => 'No ', 'modifiedOn' => 'No Info', 'note' => 'No Info', 'revision' => 'No Info');
         $revision = '?';
     }
     // Lets figure out which buttons to show
     if ($status == 0 or $status == -1 && $fileDataObj->isOwner($this->session->id)) {
         // check if user has modify rights
         if ($userPermissionObj->getAuthority($this->requestId, $fileDataObj) >= $this->config->item('WRITE_RIGHT') && !isset($revisionId) && !$archived) {
             // if so, display link for checkout
             $checkOutLink = site_url() . 'checkout/downloadfile/' . $this->requestId;
             $accessRight = 'modify';
             switch ($fileExt) {
                 case 'php':
                 case 'html':
                 case 'htm':
                     $editFileLink = site_url() . 'editor/' . $this->requestId;
                     break;
                 default:
                     break;
             }
         }
         if ($userPermissionObj->getAuthority($this->requestId, $fileDataObj) >= $this->config->item('ADMIN_RIGHT') && !@isset($revisionId) && !$archived) {
             if (!$archived) {
                 $deleteLink = 1;
             } else {
                 $deleteLink = 0;
             }
             $editLink = site_url() . 'details/editFileDetails/' . $this->requestId;
         }
     }
     // corrections
     if ($description == '') {
         $description = 'No description available.';
     }
     if ($comment == '') {
         $comment = 'No author comments available.';
     }
     if ($archived) {
         $fileName = $this->config->item('revisionDir') . $location;
         $fileSize = $this->globalFunctions->displayFilesize($fileName);
     } else {
         $fileName = $this->config->item('dataDir') . $location;
         if (!isset($fileSize)) {
             $fileSize = $this->globalFunctions->displayFilesize($fileName);
         }
     }
     $fileDetail = array('fileUnlocked' => $fileUnlocked, 'realName' => $realName, 'category' => $category, 'fileSize' => $fileSize, 'created' => $this->globalFunctions->fixDate($created), 'ownerEmail' => $userObj->getEmailAddress(), 'owner' => $owner, 'ownerFullname' => $owner, 'description' => wordwrap($description, 50, '<br />'), 'comment' => wordwrap($comment, 50, '<br />'), 'revision' => $revision, 'fileUnderReview' => $fileUnderReview, 'reviewer' => $reviewer, 'status' => $status, 'location' => $location, 'fileInfo' => $lmimetype, 'file' => $file, 'ext' => $fileExt, 'checkOutLink' => $checkOutLink, 'editLink' => $editLink, 'editFileLink' => $editFileLink, 'accessRight' => $accessRight, 'fileHistory' => $fileHistory, 'deleteLink' => $deleteLink, 'viewInBrowser' => $viewInBrowser, 'thumbnail' => $thumbnail);
     return json_encode($fileDetail);
 }