mirror of
https://github.com/FH-Complete/FHC-Core.git
synced 2026-07-23 09:52:22 +00:00
Merge branch 'ci' of https://github.com/FH-Complete/FHC-Core into ci
Conflicts: application/core/FHC_Model.php
This commit is contained in:
@@ -36,6 +36,32 @@ class Dms extends APIv1_Controller
|
||||
$dms_id = $this->get('dms_id');
|
||||
$version = $this->get('version');
|
||||
|
||||
if (isset($dms_id))
|
||||
{
|
||||
$result = $this->_getDms($dms_id, $version);
|
||||
if (is_object($result) && $result->error == EXIT_SUCCESS && is_array($result->retval) && count($result->retval) > 0)
|
||||
{
|
||||
if (($fileContent = $this->_readFile($result->retval[0]->filename)) != false)
|
||||
{
|
||||
$result->retval[0]->file_content = $fileContent;
|
||||
}
|
||||
}
|
||||
|
||||
$this->response($result, REST_Controller::HTTP_OK);
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->response();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private function _getDms($dms_id, $version)
|
||||
{
|
||||
$result = null;
|
||||
|
||||
if (isset($dms_id))
|
||||
{
|
||||
$result = $this->DmsModel->addJoin('campus.tbl_dms_version', 'dms_id');
|
||||
@@ -58,6 +84,40 @@ class Dms extends APIv1_Controller
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function postDms()
|
||||
{
|
||||
if ($this->_validate($this->post()))
|
||||
{
|
||||
if (isset($this->post()['dms_id']))
|
||||
{
|
||||
if ($this->_saveFileOnUpdate($this->post()))
|
||||
{
|
||||
$result = $this->DmsModel->update($this->post()['dms_id'], $this->_dmsFieldsArray($this->post()));
|
||||
if ($result->error == EXIT_SUCCESS)
|
||||
{
|
||||
$result = $this->DmsModel->updateDmsVersion($this->post()['dms_id'], $this->_dmsVersionFieldsArray($this->post()));
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (($fileName = $this->_saveFileOnInsert($this->post())) !== false)
|
||||
{
|
||||
$result = $this->DmsModel->insert($this->_dmsFieldsArray($this->post()));
|
||||
if ($result->error == EXIT_SUCCESS)
|
||||
{
|
||||
$result = $this->DmsModel->insertDmsVersion($this->_dmsVersionFieldsArray($this->post(), $result->retval, $fileName));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$this->response($result, REST_Controller::HTTP_OK);
|
||||
}
|
||||
@@ -70,39 +130,139 @@ class Dms extends APIv1_Controller
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function postDms()
|
||||
private function _dmsFieldsArray($dms)
|
||||
{
|
||||
if ($this->_validate($this->post()))
|
||||
$fieldsArray = array('oe_kurzbz', 'dokument_kurzbz', 'kategorie_kurzbz');
|
||||
$returnArray = array();
|
||||
|
||||
foreach ($fieldsArray as $value)
|
||||
{
|
||||
if (isset($this->post()['dms_id']))
|
||||
if (isset($dms[$value]))
|
||||
{
|
||||
$result = $this->DmsModel->update($this->post()['dms_id'], $this->post());
|
||||
|
||||
if ($result->error == EXIT_SUCCESS)
|
||||
{
|
||||
$result = $this->DmsModel->updateDmsVersion($this->post()['dms_id'], $this->post());
|
||||
}
|
||||
$returnArray[$value] = $dms[$value];
|
||||
}
|
||||
else
|
||||
{
|
||||
$result = $this->DmsModel->insert($this->post());
|
||||
|
||||
if ($result->error == EXIT_SUCCESS)
|
||||
{
|
||||
$result = $this->DmsModel->insertDmsVersion($this->post());
|
||||
}
|
||||
}
|
||||
|
||||
$this->response($result, REST_Controller::HTTP_OK);
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->response();
|
||||
}
|
||||
|
||||
return $returnArray;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private function _dmsVersionFieldsArray($dms, $dms_id = null, $fileName = null)
|
||||
{
|
||||
$fieldsArray = array(
|
||||
'version',
|
||||
'mimetype',
|
||||
'name',
|
||||
'beschreibung',
|
||||
'letzterzugriff',
|
||||
'insertamum',
|
||||
'insertvon',
|
||||
'updateamum',
|
||||
'updatevon'
|
||||
);
|
||||
$returnArray = array();
|
||||
|
||||
foreach ($fieldsArray as $value)
|
||||
{
|
||||
if (isset($dms[$value]))
|
||||
{
|
||||
$returnArray[$value] = $dms[$value];
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($dms_id))
|
||||
{
|
||||
$returnArray['dms_id'] = $dms_id;
|
||||
}
|
||||
if (isset($fileName))
|
||||
{
|
||||
$returnArray['filename'] = $fileName;
|
||||
}
|
||||
|
||||
return $returnArray;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private function _saveFileOnUpdate($dms)
|
||||
{
|
||||
$result = $this->_getDms($dms['dms_id'], $dms['version']);
|
||||
if (is_object($result) && $result->error == EXIT_SUCCESS && is_array($result->retval) && count($result->retval) > 0)
|
||||
{
|
||||
$fileName = DMS_PATH . $result->retval[0]->filename;
|
||||
|
||||
if (($fileContent = base64_decode($dms['file_content'])))
|
||||
{
|
||||
if (file_put_contents($fileName, $fileContent))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private function _saveFileOnInsert($dms)
|
||||
{
|
||||
$fileName = uniqid() . '.' . pathinfo($dms['name'], PATHINFO_EXTENSION);
|
||||
$FileNamePath = DMS_PATH . $fileName;
|
||||
|
||||
if (($fileContent = base64_decode($dms['file_content'])))
|
||||
{
|
||||
if ($fileHandle = fopen($FileNamePath, 'w'))
|
||||
{
|
||||
if(fwrite($fileHandle, $fileContent))
|
||||
{
|
||||
fclose($fileHandle);
|
||||
return $fileName;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private function _readFile($fileName)
|
||||
{
|
||||
$fileNamePath = DMS_PATH . $fileName;
|
||||
if (file_exists($fileNamePath))
|
||||
{
|
||||
if ($fileHandle = fopen($fileNamePath, 'r'))
|
||||
{
|
||||
$cTmpHEX = '';
|
||||
while (!feof($fileHandle))
|
||||
{
|
||||
$cTmpHEX .= fread($fileHandle, 8192);
|
||||
}
|
||||
fclose($fileHandle);
|
||||
return base64_encode($cTmpHEX);
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private function _validate($dms = NULL)
|
||||
{
|
||||
if (!isset($dms['file_content']) || (isset($dms['file_content']) && $dms['file_content'] == ''))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (!isset($dms['name']) || (isset($dms['name']) && $dms['name'] == ''))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -65,6 +65,27 @@ class Prestudent extends APIv1_Controller
|
||||
$this->response();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function getLastStatus()
|
||||
{
|
||||
$prestudent_id = $this->get('prestudent_id');
|
||||
$studiensemester_kurzbz = $this->get('studiensemester_kurzbz');
|
||||
$status_kurzbz = $this->get('status_kurzbz');
|
||||
|
||||
if (isset($prestudent_id))
|
||||
{
|
||||
$result = $this->PrestudentModel->getLastStatus($prestudent_id, $studiensemester_kurzbz, $status_kurzbz);
|
||||
|
||||
$this->response($result, REST_Controller::HTTP_OK);
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->response();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
|
||||
@@ -46,6 +46,32 @@ class Statistik extends APIv1_Controller
|
||||
$this->response();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function getAll()
|
||||
{
|
||||
$this->StatistikModel->addOrder($this->get('order'));
|
||||
|
||||
$result = $this->StatistikModel->loadWhole();
|
||||
|
||||
$this->response($result, REST_Controller::HTTP_OK);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function getMenueArray()
|
||||
{
|
||||
$this->StatistikModel->addOrder('gruppe');
|
||||
$this->StatistikModel->addOrder('bezeichnung');
|
||||
$this->StatistikModel->addOrder('statistik_kurzbz');
|
||||
|
||||
$result = $this->StatistikModel->loadWhole();
|
||||
|
||||
$this->response($result, REST_Controller::HTTP_OK);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
|
||||
@@ -24,7 +24,7 @@ class Adresse extends APIv1_Controller
|
||||
{
|
||||
parent::__construct();
|
||||
// Load model PersonModel
|
||||
$this->load->model('person/adresse_model', 'AdresseModel');
|
||||
$this->load->model('person/Adresse_model', 'AdresseModel');
|
||||
// Load set the uid of the model to let to check the permissions
|
||||
$this->AdresseModel->setUID($this->_getUID());
|
||||
}
|
||||
@@ -67,4 +67,4 @@ class Adresse extends APIv1_Controller
|
||||
$this->response();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -46,6 +46,31 @@ class Ort extends APIv1_Controller
|
||||
$this->response();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function getAll()
|
||||
{
|
||||
$raumtyp_kurzbz = $this->get('raumtyp_kurzbz');
|
||||
|
||||
$this->OrtModel->addOrder('ort_kurzbz');
|
||||
|
||||
if (!is_null($raumtyp_kurzbz) && $raumtyp_kurzbz != '')
|
||||
{
|
||||
$result = $this->OrtModel->addJoin('public.tbl_ortraumtyp', 'ort_kurzbz');
|
||||
if ($result->error == EXIT_SUCCESS)
|
||||
{
|
||||
$result = $this->OrtModel->loadWhere(array('raumtyp_kurzbz' => $raumtyp_kurzbz));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$result = $this->OrtModel->loadWhole();
|
||||
}
|
||||
|
||||
$this->response($result, REST_Controller::HTTP_OK);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
|
||||
@@ -0,0 +1,167 @@
|
||||
<?php
|
||||
|
||||
if (!defined('BASEPATH'))
|
||||
exit('No direct script access allowed');
|
||||
|
||||
class TblStudiengang extends FHC_Controller
|
||||
{
|
||||
function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->load->model('organisation/studiengang_model');
|
||||
$this->load->library('form_validation');
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
$keyword = '';
|
||||
$this->load->library('pagination');
|
||||
|
||||
$config['base_url'] = base_url() . 'studiengang/index/';
|
||||
$config['total_rows'] = $this->studiengang_model->total_rows();
|
||||
$config['per_page'] = 10;
|
||||
$config['uri_segment'] = 3;
|
||||
$config['suffix'] = '.html';
|
||||
$config['first_url'] = base_url() . 'studiengang.html';
|
||||
$this->pagination->initialize($config);
|
||||
|
||||
$start = $this->uri->segment(3, 0);
|
||||
$studiengang = $this->studiengang_model->index_limit($config['per_page'], $start);
|
||||
|
||||
$data = array(
|
||||
'studiengang_data' => $studiengang,
|
||||
'keyword' => $keyword,
|
||||
'pagination' => $this->pagination->create_links(),
|
||||
'total_rows' => $config['total_rows'],
|
||||
'start' => $start,
|
||||
);
|
||||
|
||||
$this->load->view('tbl_studiengang_list', $data);
|
||||
}
|
||||
|
||||
public function search()
|
||||
{
|
||||
$keyword = $this->uri->segment(3, $this->input->post('keyword', TRUE));
|
||||
$this->load->library('pagination');
|
||||
|
||||
if ($this->uri->segment(2)=='search') {
|
||||
$config['base_url'] = base_url() . 'studiengang/search/' . $keyword;
|
||||
} else {
|
||||
$config['base_url'] = base_url() . 'studiengang/index/';
|
||||
}
|
||||
|
||||
$config['total_rows'] = $this->studiengang_model->search_total_rows($keyword);
|
||||
$config['per_page'] = 10;
|
||||
$config['uri_segment'] = 4;
|
||||
$config['suffix'] = '.html';
|
||||
$config['first_url'] = base_url() . 'studiengang/search/'.$keyword.'.html';
|
||||
$this->pagination->initialize($config);
|
||||
|
||||
$start = $this->uri->segment(4, 0);
|
||||
$studiengang = $this->studiengang_model->search_index_limit($config['per_page'], $start, $keyword);
|
||||
|
||||
$data = array(
|
||||
'studiengang_data' => $studiengang,
|
||||
'keyword' => $keyword,
|
||||
'pagination' => $this->pagination->create_links(),
|
||||
'total_rows' => $config['total_rows'],
|
||||
'start' => $start,
|
||||
);
|
||||
$this->load->view('tbl_studiengang_list', $data);
|
||||
}
|
||||
|
||||
public function read($id)
|
||||
{
|
||||
$row = $this->studiengang_model->get_by_id($id);
|
||||
if ($row) {
|
||||
$data = array(
|
||||
);
|
||||
$this->load->view('tbl_studiengang_read', $data);
|
||||
} else {
|
||||
$this->session->set_flashdata('message', 'Record Not Found');
|
||||
redirect(site_url('studiengang'));
|
||||
}
|
||||
}
|
||||
|
||||
public function create()
|
||||
{
|
||||
$data = array(
|
||||
'button' => 'Create',
|
||||
'action' => site_url('studiengang/create_action'),
|
||||
);
|
||||
$this->load->view('tbl_studiengang_form', $data);
|
||||
}
|
||||
|
||||
public function create_action()
|
||||
{
|
||||
$this->_rules();
|
||||
|
||||
if ($this->form_validation->run() == FALSE) {
|
||||
$this->create();
|
||||
} else {
|
||||
$data = array(
|
||||
);
|
||||
|
||||
$this->studiengang_model->insert($data);
|
||||
$this->session->set_flashdata('message', 'Create Record Success');
|
||||
redirect(site_url('studiengang'));
|
||||
}
|
||||
}
|
||||
|
||||
public function update($id)
|
||||
{
|
||||
$row = $this->studiengang_model->get_by_id($id);
|
||||
|
||||
if ($row) {
|
||||
$data = array(
|
||||
'button' => 'Update',
|
||||
'action' => site_url('studiengang/update_action'),
|
||||
);
|
||||
$this->load->view('tbl_studiengang_form', $data);
|
||||
} else {
|
||||
$this->session->set_flashdata('message', 'Record Not Found');
|
||||
redirect(site_url('studiengang'));
|
||||
}
|
||||
}
|
||||
|
||||
public function update_action()
|
||||
{
|
||||
$this->_rules();
|
||||
|
||||
if ($this->form_validation->run() == FALSE) {
|
||||
$this->update($this->input->post('', TRUE));
|
||||
} else {
|
||||
$data = array(
|
||||
);
|
||||
|
||||
$this->studiengang_model->update($this->input->post('', TRUE), $data);
|
||||
$this->session->set_flashdata('message', 'Update Record Success');
|
||||
redirect(site_url('studiengang'));
|
||||
}
|
||||
}
|
||||
|
||||
public function delete($id)
|
||||
{
|
||||
$row = $this->studiengang_model->get_by_id($id);
|
||||
|
||||
if ($row) {
|
||||
$this->studiengang_model->delete($id);
|
||||
$this->session->set_flashdata('message', 'Delete Record Success');
|
||||
redirect(site_url('studiengang'));
|
||||
} else {
|
||||
$this->session->set_flashdata('message', 'Record Not Found');
|
||||
redirect(site_url('studiengang'));
|
||||
}
|
||||
}
|
||||
|
||||
public function _rules()
|
||||
{
|
||||
|
||||
$this->form_validation->set_rules('', '', 'trim');
|
||||
$this->form_validation->set_error_delimiters('<span class="text-danger">', '</span>');
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
/* End of file Studiengang.php */
|
||||
/* Location: ./application/controllers/Studiengang.php */
|
||||
@@ -1,14 +1,15 @@
|
||||
<?php
|
||||
if (! defined('BASEPATH')) exit('No direct script access allowed');
|
||||
|
||||
class Message extends FHC_Controller {
|
||||
class Message extends FHC_Controller
|
||||
{
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
//$this->load->library('Messaging');
|
||||
$this->load->model('person/Person_model');
|
||||
$this->load->model('system/Message_model');
|
||||
$this->load->library('messaging');
|
||||
//$this->load->model('person/Person_model');
|
||||
//$this->load->model('system/Message_model');
|
||||
}
|
||||
|
||||
public function index()
|
||||
@@ -25,20 +26,20 @@ class Message extends FHC_Controller {
|
||||
$v = $this->load->view('test.php', $data);
|
||||
}
|
||||
|
||||
public function view($id)
|
||||
public function view($msg_id)
|
||||
{
|
||||
//$messages = $this->Message_model->getMessages();
|
||||
$msg = $this->Message_model->load($id);
|
||||
$msg = $this->messaging->getMessage($msg_id);
|
||||
//var_dump($msg);
|
||||
if ($msg->error)
|
||||
show_error($msg->retval);
|
||||
if (count($msg->retval) != 1)
|
||||
show_error('Nachricht nicht vorhanden! ID: '.$id);
|
||||
show_error('Nachricht nicht vorhanden! ID: '.$msg_id);
|
||||
|
||||
$data = array
|
||||
(
|
||||
'message' => $msg->retval[0]
|
||||
);
|
||||
var_dump($data);
|
||||
var_dump($data['message']);
|
||||
$v = $this->load->view('system/message', $data);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user