mirror of
https://github.com/FH-Complete/FHC-Core.git
synced 2026-07-20 00:12:15 +00:00
Added a permissions array to all the controllers that extends FHC_Controller
This commit is contained in:
@@ -2,25 +2,30 @@
|
||||
|
||||
if (! defined('BASEPATH')) exit('No direct script access allowed');
|
||||
|
||||
class UDF extends FHC_Controller
|
||||
class UDF extends FHC_Controller
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
parent::__construct(
|
||||
array(
|
||||
'index' => 'basis/person:r',
|
||||
'saveUDF' => 'basis/person:w'
|
||||
)
|
||||
);
|
||||
|
||||
// Load session library
|
||||
$this->load->library('session');
|
||||
|
||||
|
||||
// Loads the UDF library
|
||||
$this->load->library('UDFLib');
|
||||
|
||||
//
|
||||
|
||||
//
|
||||
$this->load->model('person/Person_model', 'PersonModel');
|
||||
$this->load->model('crm/Prestudent_model', 'PrestudentModel');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
@@ -33,7 +38,7 @@ class UDF extends FHC_Controller
|
||||
}
|
||||
unset($this->session->person_id);
|
||||
}
|
||||
|
||||
|
||||
$prestudent_id = $this->input->get('prestudent_id');
|
||||
if (isset($this->session->prestudent_id))
|
||||
{
|
||||
@@ -43,16 +48,16 @@ class UDF extends FHC_Controller
|
||||
}
|
||||
unset($this->session->prestudent_id);
|
||||
}
|
||||
|
||||
|
||||
$result = null;
|
||||
if (isset($this->session->result))
|
||||
{
|
||||
$result = clone $this->session->result;
|
||||
$this->session->set_userdata('result', null);
|
||||
}
|
||||
|
||||
|
||||
$data = array('result' => $result);
|
||||
|
||||
|
||||
if (isset($person_id) && is_numeric($person_id))
|
||||
{
|
||||
if ($this->PersonModel->hasUDF())
|
||||
@@ -62,7 +67,7 @@ class UDF extends FHC_Controller
|
||||
$data['personUdfs'] = $personUdfs;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (isset($prestudent_id) && is_numeric($prestudent_id))
|
||||
{
|
||||
if ($this->PrestudentModel->hasUDF())
|
||||
@@ -72,54 +77,54 @@ class UDF extends FHC_Controller
|
||||
$data['prestudentUdfs'] = $prestudentUdfs;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$this->load->view('system/udf', $data);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
*/
|
||||
public function saveUDF()
|
||||
{
|
||||
$udfs = $this->input->post();
|
||||
$validation = $this->_validate($udfs);
|
||||
|
||||
|
||||
$userdata = array(
|
||||
'person_id' => $udfs['person_id'],
|
||||
'prestudent_id' => $udfs['prestudent_id']
|
||||
);
|
||||
|
||||
|
||||
if (isSuccess($validation))
|
||||
{
|
||||
// Load model UDF_model
|
||||
$this->load->model('system/UDF_model', 'UDFModel');
|
||||
|
||||
|
||||
$result = $this->UDFModel->saveUDFs($udfs);
|
||||
|
||||
|
||||
$userdata['result'] = $result;
|
||||
}
|
||||
else
|
||||
{
|
||||
$userdata['result'] = $validation;
|
||||
}
|
||||
|
||||
|
||||
$this->session->set_userdata($userdata);
|
||||
redirect('system/UDF');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
*/
|
||||
private function _validate($udfs)
|
||||
{
|
||||
$validation = error('person_id or prestudent_id is missing');
|
||||
|
||||
|
||||
if((isset($udfs['person_id']) && !(is_null($udfs['person_id'])) && ($udfs['person_id'] != ''))
|
||||
|| (isset($udfs['prestudent_id']) && !(is_null($udfs['prestudent_id'])) && ($udfs['prestudent_id'] != '')))
|
||||
{
|
||||
$validation = success(true);
|
||||
}
|
||||
|
||||
|
||||
return $validation;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user