Exemple #1
0
 public function index()
 {
     $docId = $this->uri->segment(2);
     $docObj = new Document_Model($docId);
     $modules = $docObj->getModules();
     if (!is_array($modules)) {
         $location = FCPATH . $this->config->item('dataDir') . $docObj->getLocation();
         if (is_file($location)) {
             $data = array('id' => $docId, 'file' => $location);
             $this->load->view('editor/editor_view', $data);
         } else {
             $this->session->set_flashdata('error', 'There was an error trying to open this file for editing.');
             redirect($_SERVER['HTTP_REFERER']);
         }
     }
     $mods = array();
     foreach ($modules as $mod) {
         $modObj = new Module_Model($mod->id);
         $category = $modObj->getCategory();
         $loc = $modObj->getLocation();
         $location = FCPATH . $this->config->item('moduleDir') . $category . '/files/' . $loc;
         $mods[] = array('id' => $mod->id, 'category' => $category, 'location' => $location);
     }
     $data = array('id' => $docId, 'modules' => $mods);
     $this->load->view('editor/editor_view', $data);
 }
 public function liveSearch($search)
 {
     $searchString = preg_replace("/[^A-Za-z0-9]/", " ", $search);
     if (strlen($searchString) >= 1 && $searchString !== ' ') {
         if (!$this->session->admin) {
             $this->db->where('owner', $this->session->id);
             $this->db->or_where('department', $this->session->department);
         }
         $this->db->select();
         $this->db->like('realname', $searchString, 'both');
         $this->db->or_like('description', $searchString, 'both');
         $this->db->where('publishable', 1);
         $this->db->limit(10);
         $query = $this->db->get('documents');
         if ($query->num_rows() !== 0) {
             foreach ($query->result() as $row) {
                 $fileDataObj = new Document_Model($row->id);
                 $data[] = array('id' => $row->id, 'realname' => $row->realname, 'category' => $fileDataObj->getCategoryName(), 'owner' => $fileDataObj->getOwnerName(), 'description' => $row->description, 'thumbnail' => $fileDataObj->getThumbnail(), 'detailsLink' => site_url() . 'details/' . $row->id);
             }
             echo json_encode($data);
         } else {
             $output = array('status' => 'error', 'msg' => 'No Results Found');
             echo json_encode($output);
         }
     }
 }
Exemple #3
0
 public function newThumbnail($docId)
 {
     $documentObj = new Document_Model($docId);
     $fileExt = $documentObj->getExt();
     //The obfuscated file name, stored in the location column
     $docName = $documentObj->getLocation();
     //The docName without the file extention
     $baseName = $documentObj->getBaseName();
     switch ($fileExt) {
         case 'pdf':
             $url = base_url() . $this->config->item('dataDir') . $docName;
             $newImage = $this->config->item('dataDir') . 'thumbnails/' . $baseName . '.jpg';
             if (extension_loaded('imagick')) {
                 //create a thumbnail from the screenshot
                 $thumb = new Imagick($url . [0]);
                 $thumb->thumbnailImage(400, 0);
                 $thumb->writeImage($newImage);
                 $msg = array('status' => 'success', 'msg' => 'Thumbnail was successfully created.');
                 echo json_encode($msg);
             } else {
                 $msg = array('status' => 'error', 'msg' => 'You must have ImageMagick installed to convert a pdf to thumbnail image.');
                 echo json_encode($msg);
             }
             break;
         case 'html':
         case 'php':
         case 'htm':
             //create PDF from HTML
             $html = $this->load->file(FCPATH . $this->config->item('dataDir') . $docName, true);
             //create thumbnail from HTML
             $options = array('format' => 'jpg', 'user-style-sheet' => FCPATH . 'assets/css/bootstrap.css', 'load-error-handling' => 'skip');
             $newImage = $this->config->item('dataDir') . 'thumbnails/' . $baseName . '.jpg';
             $this->image->generateFromHtml($html, $newImage, $options, true);
             $msg = array('status' => 'success', 'msg' => 'Successfully created a thumbnail of your file.');
             echo json_encode($msg);
             break;
         case 'png':
         case 'jpg':
             $config['source_image'] = $this->config->item('dataDir') . $docName;
             $config['new_image'] = $this->config->item('dataDir') . 'thumbnails/' . $docName;
             $config['maintain_ratio'] = true;
             $config['height'] = 200;
             $this->load->library('image_lib', $config);
             if (!$this->image_lib->resize()) {
                 $msg = array('status' => 'error', 'msg' => 'There was an error trying to resize the image.');
                 echo json_encode($msg);
             } else {
                 $msg = array('status' => 'success', 'msg' => 'Successfully created a thumbnail of your image.');
                 echo json_encode($msg);
             }
             break;
         default:
             $msg = array('status' => 'error', 'msg' => 'This filetype is currently not supported for making thumbnails.');
             echo json_encode($msg);
             break;
     }
 }
Exemple #4
0
 public function reSubmit()
 {
     $fileId = $this->uri->segment(3);
     if (isset($fileId)) {
         $fileObj = new Document_Model($fileId);
         $fileObj->Publishable(0);
     }
     $msg = array('status' => 'success', 'msg' => 'File was successfully resubmitted for review');
     echo json_encode($msg);
 }
Exemple #5
0
 public function unDeleteFile()
 {
     $fileId = $this->uri->segment(3);
     $fileDataObj = new Document_Model($fileId);
     if ($this->session->admin) {
         $this->delete->unDeleteFile($fileId);
     } elseif ($fileDataObj->isOwner($this->session->id)) {
         $this->delete->unDeleteFile($fileId);
     } else {
         $this->session->set_flashdata('error', 'You can not un-delete this file.');
         redirect($_SERVER['HTTP_REFERRER']);
     }
 }
 public function permDeleteFiles($fileId)
 {
     $this->load->helper('file');
     $userPermObj = new User_Perms_Model($this->session->id);
     if (!$userPermObj->userObj->isRoot()) {
         $error = array('status' => 'error', 'msg' => 'You do not have permission to delete this file');
         return json_encode($error);
         exit;
     }
     // all ok, proceed!
     if (isset($fileId)) {
         if ($userPermObj->canAdmin($fileId)) {
             $fileObj = new Document_Model($fileId);
             $location = $fileObj->getLocation();
             // delete from db
             $data = array('id' => $fileId);
             $this->db->delete('documents', $data);
             $this->db->delete('log', $data);
             $data = array('fid' => $fileId);
             $this->db->delete('dept_perms', $data);
             $this->db->delete('user_perms', $data);
             $realName = $fileObj->getBaseName();
             $ext = $fileObj->getExt();
             if (is_file($this->config->item('archiveDir') . $location)) {
                 unlink($this->config->item('archiveDir') . $location);
             }
             if (is_file($this->config->item('dataDir') . 'pdf/' . $realName . '.pdf')) {
                 unlink($this->config->item('dataDir') . 'pdf/' . $realName . '.pdf');
             }
             if (is_file($this->config->item('dataDir') . 'thumbnails/' . $realName . '.png')) {
                 unlink($this->config->item('dataDir') . 'thumbnails/' . $realName . '.png');
             }
             if ($ext == 'docx') {
                 if (is_file($this->config->item('archiveDir') . $realName . '.odt')) {
                     unlink($this->config->item('archiveDir') . $realName . '.odt');
                 }
                 if (is_file($this->config->item('archiveDir') . $realName . '.html')) {
                     unlink($this->config->item('archiveDir') . $realName . '.html');
                 }
             }
             if (is_dir($this->config->item('revisionDir') . $fileId . '/')) {
                 delete_files($this->config->item('revisionDir') . $fileId . '/', true);
             }
             return true;
         }
     }
     return false;
 }
Exemple #7
0
 public function doUploadAjax()
 {
     $post = $this->input->post();
     $fileDataObj = new Document_Model($post['id']);
     $location = $fileDataObj->getLocation();
     $this->load->library('upload');
     $config['upload_path'] = $this->config->item('dataDir') . 'tmp';
     $config['allowed_types'] = 'gif|jpg|png|php|html|pdf|doc|docx|odt|odp|ods|csv|xml|xls|xlsx|ppt';
     $this->upload->initialize($config);
     if (!$this->upload->do_upload('userfile')) {
         $error = array('status' => 'error', 'msg' => $this->upload->display_errors('', ''));
         echo json_encode($error);
         exit;
     } else {
         $data = $this->upload->data();
         $fileInfo = array('formData' => $post, 'fileData' => $data);
         $this->checkin->checkInFile($fileInfo);
     }
 }
 public function updateDocument($id)
 {
     $docObj = new Document_Model($id);
     $location = $docObj->getLocation();
     $baseName = $docObj->getBaseName();
     $html = $this->load->file(FCPATH . $this->config->item('dataDir') . $location, true);
     $this->image->setBinary($this->config->item('image_binary'));
     $options = array('format' => 'jpg', 'user-style-sheet' => FCPATH . 'assets/css/bootstrap.css', 'load-error-handling' => 'skip');
     $newImage = $this->config->item('dataDir') . 'thumbnails/' . $baseName . '.jpg';
     $this->image->generateFromHtml($html, $newImage, $options, true);
     $options = array('viewport-size' => '1250', 'load-error-handling' => 'skip');
     $newPdf = $this->config->item('dataDir') . 'pdf/' . $baseName . '.pdf';
     $this->pdf->setBinary($this->config->item('pdf_binary'));
     $this->pdf->generateFromHtml($html, $newPdf, $options, true);
     $config['source_image'] = $newImage;
     $config['maintain_ratio'] = true;
     $config['height'] = 200;
     $this->load->library('image_lib', $config);
     $this->image_lib->resize();
 }
Exemple #9
0
 public function index()
 {
     $docObj = new Document_Model($this->docId);
     $location = $docObj->getLocation();
     $fileExt = $docObj->getExt();
     $baseName = $docObj->getBaseName();
     switch ($fileExt) {
         case 'html':
         case 'php':
             $url = base_url() . $this->config->item('dataDir') . 'pdf/' . $baseName . '.pdf';
             break;
         case 'doc':
         case 'docx':
             $url = base_url() . $this->config->item('dataDir') . $baseName . '.odt';
             break;
         case 'pdf':
             $url = base_url() . $this->config->item('dataDir') . $location;
             break;
     }
     header('Location:' . base_url() . 'assets/js/viewer#' . $url);
 }
Exemple #10
0
 public function newPdf($docId)
 {
     $documentObj = new Document_Model($docId);
     $fileExt = $documentObj->getExt();
     //The obfuscated file name, stored in the location column
     $docName = $documentObj->getLocation();
     //The docName without the file extention
     $baseName = $documentObj->getBaseName();
     switch ($fileExt) {
         case 'html':
         case 'php':
         case 'htm':
             $html = $this->load->file(FCPATH . $this->config->item('dataDir') . $docName, true);
             $newPdf = FCPATH . $this->config->item('dataDir') . 'pdf/' . $baseName . '.pdf';
             $options = array('viewport-size' => '1250', 'user-style-sheet' => FCPATH . 'assets/css/bootstrap.css', 'load-error-handling' => 'skip');
             $this->pdf->generateFromHtml($html, $newPdf, $options, true);
             $msg = array('status' => 'success', 'msg' => 'Successfully created a new pdf of your file.');
             echo json_encode($msg);
             break;
         case 'png':
         case 'jpg':
         case 'gif':
         case 'tif':
         case 'bmp':
             $html = '<html><body><div class="container"><img class="img-responsive" src=" ' . FCPATH . $this->config->item('dataDir') . $docName . ' "></div></body></html>';
             $newPdf = FCPATH . $this->config->item('dataDir') . 'pdf/' . $baseName . '.pdf';
             $options = array('viewport-size' => '1250', 'user-style-sheet' => FCPATH . 'assets/css/bootstrap.css', 'load-error-handling' => 'skip');
             $this->pdf->generateFromHtml($html, $newPdf, $options, true);
             $msg = array('status' => 'success', 'msg' => 'Successfully created a new pdf of your file.');
             echo json_encode($msg);
             break;
         default:
             $msg = array('status' => 'error', 'msg' => 'This filetype is currently not supported for making pdfs.');
             echo json_encode($msg);
             break;
     }
 }
 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 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);
 }
 /**
  * return a boolean on whether or not this department
  * has admin right to the file whose ID is $dataId
  * @param int $dataId
  * @return bool
  */
 public function canAdmin($dataId)
 {
     $filedata = new Document_Model($dataId);
     //check  to see if this department doesn't have a forbidden right or
     //if this file is publishable
     if (!$this->isForbidden($dataId) or !$filedata->isPublishable()) {
         // return whether or not this deptartment can admin the file
         if ($this->canDept($dataId, $this->config->item('ADMIN_RIGHT'))) {
             return true;
         } else {
             return false;
         }
     }
     return false;
 }
Exemple #14
0
 /**
  *Get number of files by user
  */
 public function fileCountOwner()
 {
     $this->db->select('id,owner,COUNT(*) as cnt');
     $this->db->group_by('owner');
     $query = $this->db->get('documents');
     if ($query->num_rows() > 0) {
         $own = array();
         foreach ($query->result() as $row) {
             $fileObj = new Document_Model($row->id);
             $owner = $fileObj->getOwnerName();
             $own[] = array('owner' => $owner, 'count' => $row->cnt);
         }
         echo json_encode($own);
     } else {
         $msg = array('status' => 'error', 'msg' => 'There were no files to gather data on.');
         echo json_encode($msg);
         exit;
     }
 }
 public function checkInFile(array $data = null)
 {
     $id = $data['formData']['id'];
     $fileDataObj = new Document_Model($id);
     $location = $fileDataObj->getLocation();
     if ($fileDataObj->getError() == '' && $fileDataObj->getStatus() == $this->uid) {
         //look to see how many revision are there
         $result = $fileDataObj->getTotalRevisions();
         $revisionNumber = count($result);
         // if revision dir not available, create it
         if (!is_dir($this->config->item('revisionDir'))) {
             if (!mkdir($this->config->item('revisionDir'), 0775)) {
                 $error = array('status' => 'error', 'msg' => 'Could not create the Revision Directory');
                 echo json_encode($error);
                 exit;
             }
         }
         //creates the revision directory folder for the specific file being revised
         if (!is_dir($this->config->item('revisionDir') . $id)) {
             if (!mkdir($this->config->item('revisionDir') . $id, 0775)) {
                 $error = array('status' => 'error', 'msg' => 'Could not create the Revision Directory ' . $this->config->item('revisionDir') . $id);
                 echo json_encode($error);
                 exit;
             }
         }
         //creates the revision directory pdf folder for the specific file being revised
         if (!is_dir($this->config->item('revisionDir') . $id . '/pdf')) {
             if (!mkdir($this->config->item('revisionDir') . $id . '/pdf', 0775)) {
                 $error = array('status' => 'error', 'msg' => 'Could not create the Revision Directory ' . $this->config->item('revisionDir') . $id . '/pdf');
                 echo json_encode($error);
                 exit;
             }
         }
         //creates the revision directory thumbnail folder for the specific file being revised
         if (!is_dir($this->config->item('revisionDir') . $id . '/thumbnails')) {
             if (!mkdir($this->config->item('revisionDir') . $id . '/thumbnails', 0775)) {
                 $error = array('status' => 'error', 'msg' => 'Could not create the Revision Directory ' . $this->config->item('revisionDir') . $id . '/thumbnails');
                 echo json_encode($error);
                 exit;
             }
         }
         $fileExt = $fileDataObj->getExt();
         $baseName = $fileDataObj->getBaseName();
         $fileName = $this->config->item('dataDir') . $location;
         $pdf = $this->config->item('dataDir') . 'pdf/' . $baseName . '.pdf';
         $thumb = $this->config->item('dataDir') . 'thumbnails/' . $baseName . '.png';
         $revPdf = $this->config->item('revisionDir') . $id . '/pdf/' . $id . '_' . ($revisionNumber - 1) . '.pdf';
         $revThumb = $this->config->item('revisionDir') . $id . '/thumbnails/' . $id . '_' . ($revisionNumber - 1) . '.png';
         /*if there is a pdf copy the pdf to the appropriate
          *revision directory and then delete old pdf
          */
         if (file_exists($pdf)) {
             if (!copy($pdf, $revPdf)) {
                 $error = array('status' => 'error', 'msg' => 'There was an error copying  ' . $pdf . ' to ' . $revPdf);
                 echo json_encode($error);
             } else {
                 unlink($pdf);
             }
         }
         /*if there is a thumbnail copy the thumbnail to the
          *appropriate revision directory and delete old thumbnail
          */
         if (file_exists($thumb)) {
             if (!copy($thumb, $revThumb)) {
                 $error = array('status' => 'error', 'msg' => 'There was an error copying  ' . $thumb . ' to ' . $revThumb);
                 echo json_encode($error);
             } else {
                 unlink($thumb);
             }
         }
         //read and close
         $fileHandler = fopen($fileName, "r");
         $fileContent = fread($fileHandler, filesize($fileName));
         fclose($fileHandler);
         //write and close
         $fileHandler = fopen($this->config->item('revisionDir') . $id . '/' . $id . '_' . ($revisionNumber - 1) . '.' . $fileExt, "w");
         fwrite($fileHandler, $fileContent);
         fclose($fileHandler);
         // all OK, proceed!
         $userName = $this->userObj->getUserName();
         //update revision log set the current revision to the next number
         $fileDataObj->updateCurrentRevision($revisionNumber);
         //add a new revision and set to current
         $fileDataObj->insertNewRevision($userName, $data['formData']['note']);
         //complete the file check in process
         $fileDataObj->checkIn($publishable, $data['fileData']['file_name']);
         // rename and save file
         if (!copy($data['fileData']['full_path'], $this->config->item('dataDir') . $location)) {
             $error = array('status' => 'error', 'msg' => 'We were unable to successfully copy the checked in file to the file directory');
             echo json_encode($error);
         } else {
             unlink($data['fileData']['full_path']);
             $msg = array('status' => 'success', 'msg' => 'We successfully uploaded the checked in file,
                  and create a revision directory for the previous version.');
             echo json_encode($msg);
         }
         AccessLog_Model::addLogEntry($id, 'I');
     }
 }
Exemple #16
0
 public function createObjectFromData($row)
 {
     $document = new Document_Model();
     $document->setId($row->id);
     $document->setSubject($row->subject);
     $document->setDescription($row->description);
     $document->setFrom($row->from);
     $document->setAttachment($row->attachment);
     $document->setStatus($row->status);
     $document->setReferenceNumber($row->referenceNumber);
     $document->setDueDate($row->dueDate);
     $document->setDeadline($row->deadline);
     $document->setDue15Days($row->due15Days);
     $document->setDateReceived($row->dateReceived);
     $document->setAction($row->action);
     return $document;
 }
Exemple #17
0
 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();
             }
         }
     }
 }