offer fileupload and comments
This commit is contained in:
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
/**
|
||||
* Created by Pensare Software.
|
||||
* User: Theo Weijmer
|
||||
* Date: 10/01/2018
|
||||
* Time: 20:22
|
||||
*/
|
||||
|
||||
class DocumentsController extends MY_Controller {
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
if ( AUTHENTICATED == FALSE ) die( 'NO ACCESS' );
|
||||
|
||||
$models = [];
|
||||
$libraries = [];
|
||||
|
||||
$this->load->model( $models );
|
||||
$this->load->library( $libraries );
|
||||
}
|
||||
|
||||
public function getDocuments( $foreignID, $tablename )
|
||||
{
|
||||
$documents = Document::getDocuments( $foreignID, $tablename );
|
||||
|
||||
$this->json( $documents );
|
||||
}
|
||||
|
||||
public function downloadDocument( $documentID )
|
||||
{
|
||||
$this->load->helper( 'download' );
|
||||
|
||||
$document = Document::find( $documentID );
|
||||
|
||||
$data = file_get_contents( MYROOTPATH . 'documents/' . $document->storagename );
|
||||
|
||||
force_download( $document->originalname, $data );
|
||||
}
|
||||
|
||||
public function removeDocument( $documentID )
|
||||
{
|
||||
$document = Document::find( $documentID );
|
||||
|
||||
unlink( MYROOTPATH . 'documents/' . $document->storagename );
|
||||
|
||||
Document::whereId( $documentID )->delete();
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user