diff --git a/application/controllers/api/v1/CheckUserAuth.php b/application/controllers/api/v1/CheckUserAuth.php new file mode 100644 index 000000000..a793845a7 --- /dev/null +++ b/application/controllers/api/v1/CheckUserAuth.php @@ -0,0 +1,44 @@ +load->model('CheckUserAuth_model', 'CheckUserAuthModel'); + } + + public function getCheckByUsernamePassword() + { + $username = $this->get("username"); + $password = $this->get("password"); + + if (isset($username) && isset($password)) + { + $result = $this->CheckUserAuthModel->checkByUsernamePassword($username, $password); + + $this->response($result, REST_Controller::HTTP_OK); + } + else + { + $this->response(); + } + } +} \ No newline at end of file diff --git a/application/controllers/api/v1/crm/Akte.php b/application/controllers/api/v1/crm/Akte.php index cd52b97f5..9569cc68d 100644 --- a/application/controllers/api/v1/crm/Akte.php +++ b/application/controllers/api/v1/crm/Akte.php @@ -46,6 +46,28 @@ class Akte extends APIv1_Controller $this->response(); } } + + /** + * @return void + */ + public function getAkten() + { + $person_id = $this->get('person_id'); + $dokument_kurzbz = $this->get('dokument_kurzbz'); + $stg_kz = $this->get('stg_kz'); + $prestudent_id = $this->get('prestudent_id'); + + if (isset($person_id)) + { + $result = $this->AkteModel->getAkten($person_id, $dokument_kurzbz, $stg_kz, $prestudent_id); + + $this->response($result, REST_Controller::HTTP_OK); + } + else + { + $this->response(); + } + } /** * @return void diff --git a/application/controllers/api/v1/person/Kontakt.php b/application/controllers/api/v1/person/Kontakt.php index 9c08518b2..799061ce4 100644 --- a/application/controllers/api/v1/person/Kontakt.php +++ b/application/controllers/api/v1/person/Kontakt.php @@ -53,6 +53,22 @@ class Kontakt extends APIv1_Controller } } + public function getOnlyKontakt() + { + $kontakt_id = $this->get("kontakt_id"); + + if (isset($kontakt_id)) + { + $result = $this->KontaktModel->loadWhere(array('kontakt_id' => $kontakt_id)); + + $this->response($result, REST_Controller::HTTP_OK); + } + else + { + $this->response(); + } + } + public function getKontaktByPersonID() { $person_id = $this->get("person_id"); diff --git a/application/libraries/FHC_Auth.php b/application/libraries/FHC_Auth.php index 255ff6b1d..17cfd65f6 100644 --- a/application/libraries/FHC_Auth.php +++ b/application/libraries/FHC_Auth.php @@ -26,8 +26,16 @@ require_once FCPATH.'include/AddonAuthentication.php'; // ------------------------------------------------------------------------ -class FHC_Auth +class FHC_Auth extends authentication { + /** + * Construct + */ + public function __construct() + { + parent::__construct(); + } + /** * Auth Username, Password over FH-Complete * @@ -37,8 +45,7 @@ class FHC_Auth */ public function basicAuthentication($username, $password) { - $auth = new authentication(); - if ($auth->checkpassword($username, $password)) + if ($this->checkpassword($username, $password)) { return true; } @@ -49,6 +56,9 @@ class FHC_Auth } /** + * + * TO BE UPDATED + * * Get the md5 hashed password by the addon username * * @param string $username addon username diff --git a/application/models/CheckUserAuth_model.php b/application/models/CheckUserAuth_model.php new file mode 100644 index 000000000..acf9c3723 --- /dev/null +++ b/application/models/CheckUserAuth_model.php @@ -0,0 +1,18 @@ +load->library('fhc_auth'); + } + + public function checkByUsernamePassword($username, $password) + { + return $this->_success($this->fhc_auth->checkpassword($username, $password)); + } +} \ No newline at end of file diff --git a/application/models/crm/Akte_model.php b/application/models/crm/Akte_model.php index c844de435..b679c161b 100644 --- a/application/models/crm/Akte_model.php +++ b/application/models/crm/Akte_model.php @@ -1,7 +1,7 @@ dbTable = 'public.tbl_akte'; $this->pk = 'akte_id'; } -} + + /** + * + */ + public function getAkten($person_id, $dokument_kurzbz = null, $stg_kz = null, $prestudent_id = null) + { + // Checks if the operation is permitted by the API caller + if (! $this->fhc_db_acl->isBerechtigt($this->acl['public.tbl_akte'], 's')) + return $this->_error(lang('fhc_'.FHC_NORIGHT).' -> '.$this->acl['public.tbl_akte'], FHC_MODEL_ERROR); + + if (! $this->fhc_db_acl->isBerechtigt($this->acl['public.tbl_dokument'], 's')) + return $this->_error(lang('fhc_'.FHC_NORIGHT).' -> '.$this->acl['public.tbl_dokument'], FHC_MODEL_ERROR); + + if (! $this->fhc_db_acl->isBerechtigt($this->acl['public.tbl_dokumentstudiengang'], 's')) + return $this->_error(lang('fhc_'.FHC_NORIGHT).' -> '.$this->acl['public.tbl_dokumentstudiengang'], FHC_MODEL_ERROR); + + if (! $this->fhc_db_acl->isBerechtigt($this->acl['public.tbl_dokumentprestudent'], 's')) + return $this->_error(lang('fhc_'.FHC_NORIGHT).' -> '.$this->acl['public.tbl_dokumentprestudent'], FHC_MODEL_ERROR); + + $query = 'SELECT akte_id, + person_id, + dokument_kurzbz, + mimetype, + erstelltam, + gedruckt, + titel_intern, + anmerkung_intern, + titel, bezeichnung, + updateamum, + insertamum, + updatevon, + insertvon, + uid, + dms_id, + anmerkung, + nachgereicht, + CASE WHEN inhalt is not null THEN true ELSE false END as inhalt_vorhanden + FROM public.tbl_akte + WHERE person_id = ?'; + + $parametersArray = array($person_id); + + if (!is_null($dokument_kurzbz)) + { + $query .= ' AND dokument_kurzbz = ?'; + array_push($parametersArray, $dokument_kurzbz); + } + + if (!is_null($stg_kz) && !is_null($prestudent_id)) + { + $query .= ' AND dokument_kurzbz NOT IN ( + SELECT dokument_kurzbz + FROM public.tbl_dokument JOIN public.tbl_dokumentstudiengang USING (dokument_kurzbz) + WHERE studiengang_kz = ? + ) + AND dokument_kurzbz NOT IN (\'Zeugnis\') + AND dokument_kurzbz NOT IN ( + SELECT dokument_kurzbz + FROM public.tbl_dokumentprestudent JOIN public.tbl_dokument USING (dokument_kurzbz) + WHERE prestudent_id = ? + )'; + array_push($parametersArray, $stg_kz, $prestudent_id); + } + + $query .= ' ORDER BY erstelltam'; + + $result = $this->db->query($query, $parametersArray); + + if (is_object($result)) + return $this->_success($result->result()); + else + return $this->_error($this->db->error(), FHC_DB_ERROR); + } +} \ No newline at end of file diff --git a/ci_db_extra.php b/ci_db_extra.php index 9185454de..1ab1ccaa1 100755 --- a/ci_db_extra.php +++ b/ci_db_extra.php @@ -121,4 +121,28 @@ trait db_extra } return $string; } -} + + public function db_num_fields($result=null) + { + if(is_null($result)) + return pg_num_fields($this->db_result); + else + return pg_num_fields($result); + } + + public function convert_html_chars($value) + { + return htmlspecialchars($value); + } + + /** + * Liefert den Feldnamen mit index i + */ + public function db_field_name($result=null, $i) + { + if(is_null($result)) + return pg_field_name($this->db_result, $i); + else + return pg_field_name($result, $i); + } +} \ No newline at end of file