64 lines
2.1 KiB
PHP
64 lines
2.1 KiB
PHP
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
|
|
|
|
class Extrainfo extends MY_controller {
|
|
public $rootpath;
|
|
function __construct(){
|
|
parent::__construct();
|
|
$models = array('ijkpartituur/ModReferenties','');
|
|
$this->load->model($models);
|
|
$this->rootpath = $_SERVER['DOCUMENT_ROOT'];
|
|
if ( ! $this->check_online_status() ) {
|
|
echo json_encode( array('offline' => TRUE) );
|
|
die;
|
|
};// if
|
|
}
|
|
public function index(){
|
|
}
|
|
public function getRefs(){
|
|
if (!$this->userid) return;
|
|
$type = $this->clean_input('soort');
|
|
$zoek =$this->clean_input("zoek");
|
|
if ($zoek === 'undefined' ) {$zoek=false ;} ;
|
|
$refs = $this->ModReferenties->get_refs($type,$zoek);
|
|
echo json_encode(array('refs' =>$refs,
|
|
'admin' =>$this->super));
|
|
}
|
|
public function newLitRef(){
|
|
$data["soort"]=$this->uri->segment(4);
|
|
if ($data["soort"] <= 0 ){ $data["soort"] = 1; }
|
|
$data["srtlink"]='ext.ref';
|
|
$newID = $this->ModReferenties->insert_record($data);
|
|
$ref = $this->ModReferenties->get_record_by_id($newID);
|
|
echo json_encode($ref);
|
|
}
|
|
public function saveRef(){
|
|
if (!$this->userid) return;
|
|
|
|
$id = $this->clean_input("id");
|
|
$link = $this->clean_input("link");
|
|
$srtlink = $this->clean_input("srtlink");
|
|
if ($srtlink == "url") {
|
|
if ( strpos($link, "http://")=== 0 or strpos($link, "https://") === 0) { }
|
|
else {$link="http://".$link ;};
|
|
};
|
|
$data= array('naam' => $this->input->post("naam"),
|
|
'link' => $link,
|
|
'opmerking' => $this->input->post("opmerking"),
|
|
'srtlink' => $this->input->post("srtlink"));
|
|
$this->ModReferenties->update_record($data, $id);
|
|
}
|
|
public function delRef() {
|
|
if ($this->Autorisaties_model->check_autorisaties($this->userrole, WRITER) <=0 ) return;
|
|
$id = $this->uri->segment(4);
|
|
//als de referentie verwijst naar een document, delete het document
|
|
$file = $this->ModReferenties->get_record_by_id($id);
|
|
|
|
if ($file) {
|
|
if ($file->hashnaam) {
|
|
$this->load->helper("file");
|
|
unlink($this->rootpath.'/docs/'.$file->hashnaam.$file->doc_extension);
|
|
};
|
|
};
|
|
$this->ModReferenties->delete_record($id);
|
|
}
|
|
} // einde class Extrainfo
|