diff --git a/.gitignore b/.gitignore
index d0471e0b2..52e71e57b 100644
--- a/.gitignore
+++ b/.gitignore
@@ -9,11 +9,13 @@ documents/
.settings
.project
.buildpath
-tests/codeception.yml
-tests/codeception/api.suite.yml
-tests/codeception/functional.suite.yml
-tests/codeception/acceptance.suite.yml
+tests/codeception/codeception.yml
+tests/codeception/tests/api.suite.yml
+tests/codeception/tests/functional.suite.yml
+tests/codeception/tests/acceptance.suite.yml
tests/codeception/_support/_generated
tests/codeception/_output/*
!/tests/codeception/_output/.placeholder
/submodules/d3
+composer.lock
+bin
diff --git a/.gitmodules b/.gitmodules
index d2bd62ca4..41511b610 100644
--- a/.gitmodules
+++ b/.gitmodules
@@ -1,6 +1,3 @@
-[submodule "submodules/tablesorter"]
- path = submodules/tablesorter
- url = https://github.com/christianbach/tablesorter.git
[submodule "submodules/bootstrap"]
path = submodules/bootstrap
url = https://github.com/twbs/bootstrap.git
diff --git a/CHANGELOG.md b/CHANGELOG.md
new file mode 100755
index 000000000..336515567
--- /dev/null
+++ b/CHANGELOG.md
@@ -0,0 +1,63 @@
+# Change Log
+
+## [Unreleased]
+
+### Added
+
+- **[FAS]** Zusätzliches Feld für Uhrzeit bei Abschlussprüfung
+- **[FAS]** Reihungstest Dropdown zeigt verfügbare/belegte Plätze an
+- **[CORE]** Reihungstest Punkteübernahme oder Prozentpunkte ist konfigurierbar
+- **[CIS]** LVPlan Export für Excel
+- **[FAS]** Termine Karteireiter im FAS zeigt die Anmerkung aus dem LVPlan an
+- **[CIS]** Onlinebewerbungstool greift auf mehrsprachige Statusbezeichnungen zu.
+
+### Changed
+- **[FAS]** Dokumente Menü im FAS neu sortiert um den Lebenszyklus des Studierenden abzubilden
+- **[CORE]** LVPlan Update Mail ist nun zweisprachig Deutsch/Englisch
+- **[FAS]** Prüfungen im FAS werden nur noch vom aktuell ausgewählten Studiensemester angezeigt. Umschalten auf volle Ansicht möglich
+- **[CIS]** LVPlan Begrenzung der 4er Blockung aufgehoben.
+- **[CIS]** Im Menü 'Zeitsperren' Link zu Resturlaubsübersicht entfernt. Falls benötigt Verlinkung über CMS möglich.
+- **[CORE]** Removed NOT NULL constraint on 'verfasser\_uid' from public.tbl\_notiz
+
+### Updateinfo
+- **[FAS]** Für Lehraufträge muss eine Unoconv-Vorlage erstellt werden, da der für xsl-fo notwendige Seitenumbruch-Tag aus dem RDF entfernt wurde.
+- **[FAS]** Mehrsprachigkeitsspalte tbl_status.bezeichnung_mehrsprachig wird durch das Updatescript automatisch in den ersten beiden Sprachen mit der status_kurzbz vorbefüllt. Übersetzungen sind anzupassen.
+
+## [3.1.0] - 2015-11-12
+### Added
+
+- **[FAS]** Bei Noten können zusätzlich Punkte gespeichert werden. Notenschlüssel für Gesamtnote kann hinterlegt werden
+- **[FAS]** Anwesenheiten von Studierenden können erfasst werden
+- **[FAS]** Vertragsverwaltung bei Mitarbeiter
+- **[FAS]** Dokumente im FAS können mit SHIFT bzw STRG statt als PDF auch als DOC oder ODT erstellt werden
+- **[BERECHTIGUNG]** system/changeoutputformat Legt fest ob Dokumente als DOC/ODT exportiert werden dürfen
+- **[FAS]** Termine Karteireiter im FAS zeigt den LVPlan von Studierenden/Lehrveranstaltungen
+- **[FAS]** Bereits verplante Lektoren können vom FAS aus, aus dem LVPlan gelöscht werden. Zusätzlich wird im FAS angezeigt ob dieser Lektor bereits verplant ist
+- **[FAS]** Bereits verplante Gruppen können direkt vom FAS heraus aus dem LV-Plan gelöscht werden wenn diese bereits verplant wurden.
+- **[TEMPUS]** Drop auf Lehrstunde Feature für 2 Gruppen die zur selben Zeit im gleichen Raum unterricht haben (Setzt UNR gleich damit es nicht als kollision angezeigt wird)
+- **[TEMPUS]** Option zum Anzeigen von allen Einträgen damit auch Incominggruppen und Gruppen aus anderen Studiengängen sichtbar sind
+- **[FAS]** Bei Notizen können jetzt zusätzlich Dokumente hochgeladen werden
+- **[CORE]** Bei Dokumentenvorlagen können nun Style und content.xml auf einmal erfasst werden, Dokumente können deaktiviert werden, Eigene GUI im Vilesci zum Verwalten der Dokumentenvorlagen
+- **[CORE]** Mehrsprachigkeit bei diversen Tabellen (Dokumente, ZGV, ...) hinzugefügt
+
+### Fixed
+- **[TEMPUS]** Kollisionsfreie User werden in Verbandsansicht nicht mehr als Kollision angezeigt
+
+### Changed
+- **[FAS]** Stundenobergrenze für Lektoren kann jetzt pro Organisationseinheit festgelegt werden. (warn_semesterstunden_frei/fix tbl_organisationseinheit)
+- **[BERECHTIGUNG]** lv-plan/gruppenentfernen Lektorenänderung: Lektoren die bereits verplant sind können jetzt auch dann direkt im FAS geändert werden, wenn dadurch eine Kollision entsteht. Vorraussetzung dafür ist, dass ignore_kollision true ist. Wenn ignore_kollision false ist, dann ist die Lektorenänderung nicht mehr möglich. Vorher wurde der Lektor in diesem Fall nur im FAS geändert aber nicht im LVPlan.
+- **[FAS]** Ausstellungsstaat der ZGV wird jetzt getrennt für Bachelor und Master erfasst
+
+
+## [3.0.0] - 2015-02-13
+### Added
+
+- **[CORE]** Studienordnungen / Studienpläne
+- **[CORE]** Module
+- **[CIS]** CIS Redesign
+- **[CORE]** Unterstützung für Addons
+- **[FAS]** Notizsystem
+
+### Fixed
+
+- **[CORE]** Diverse Bugfixes
diff --git a/README.md b/README.md
index 1a417b114..8874b5778 100644
--- a/README.md
+++ b/README.md
@@ -1,4 +1,7 @@
# FH-Complete
+[](http://phpci.fhcomplete.org/project/view/1)
+
* [FH-Complete Homepage](http://www.fhcomplete.org)
* [Wiki](http://fhcomplete.technikum-wien.at/dokuwiki/)
+* [Changelog](CHANGELOG.md)
diff --git a/addons/template/cis/init.js.php b/addons/template/cis/init.js.php
new file mode 100644
index 000000000..174f620ed
--- /dev/null
+++ b/addons/template/cis/init.js.php
@@ -0,0 +1,44 @@
+
+ */
+/**
+ * Initialisierung des Addons
+ */
+?>
+if(typeof addon =='undefined')
+ var addon=Array();
+
+addon.push(
+{
+ init: function(page, params)
+ {
+ // Diese Funktion wird nach dem Laden der Seite im CIS aufgerufen
+
+ /*
+ switch(page)
+ {
+ case 'cis/private/tools/zeitaufzeichnung.php':
+ break;
+
+ default:
+ break;
+ }
+ */
+ }
+});
diff --git a/addons/template/vilesci/init.js.php b/addons/template/vilesci/init.js.php
new file mode 100644
index 000000000..5ac9310ca
--- /dev/null
+++ b/addons/template/vilesci/init.js.php
@@ -0,0 +1,44 @@
+
+ */
+/**
+ * Initialisierung des Addons
+ */
+?>
+if(typeof addon =='undefined')
+ var addon=Array();
+
+addon.push(
+{
+ init: function(page, params)
+ {
+ // Diese Funktion wird nach dem Laden der Seite im Vilesci aufgerufen
+
+ /*
+ switch(page)
+ {
+ case 'vilesci/lehre/lehrveranstaltung.php':
+ break;
+
+ default:
+ break;
+ }
+ */
+ }
+});
diff --git a/application/config/config.php b/application/config/config.php
index e07aeebbb..68b85b62f 100755
--- a/application/config/config.php
+++ b/application/config/config.php
@@ -508,14 +508,10 @@ $config['proxy_ips'] = '';
| Autoload Custom Controllers
|--------------------------------------------------------------------------
|
-Don't work so sometime delete this*/
-function __autoload($class)
-{
+| It's working, so don't delete this :D
+*/
+spl_autoload_register(function ($class) {
if (substr($class,0,3) !== 'CI_' && substr($class,0,4) !== 'FHC_')
- {
- if (file_exists($file = APPPATH . 'core/' . $class . '.php'))
- {
- require_once $file;
- }
- }
-}
+ if (file_exists($file = APPPATH . 'core/' . $class . '.php'))
+ require_once $file;
+});
diff --git a/application/config/constants.php b/application/config/constants.php
index 48283e223..92a784220 100755
--- a/application/config/constants.php
+++ b/application/config/constants.php
@@ -1,6 +1,24 @@
'basis/person',
+ 'public.tbl_prestudent' => 'basis/person',
+ 'public.tbl_organisationseinheit' => 'basis/organisationseinheit'
+,
+ 'public.tbl_sprache' => 'admin'
+);
diff --git a/application/config/rest.php b/application/config/rest.php
index 3e311e078..4f45858a8 100644
--- a/application/config/rest.php
+++ b/application/config/rest.php
@@ -119,7 +119,8 @@ $config['rest_auth'] = 'basic';
|
| Is login required and if so, the user store to use
|
-| '' Use config based users or wildcard testing
+| '' Use config based users or wildcard testing, only for testing purpose
+| it would be very unsecure to let unset in a production environment
| 'ldap' Use LDAP authentication
| 'library' Use a authentication library
|
@@ -139,13 +140,16 @@ $config['auth_source'] = 'library';
| In other cases override the function _perform_library_auth in your controller
|
| For digest authentication the library function should return already a stored
-| md5(username:restrealm:password) for that username
-|
-| e.g: md5('admin:REST API:1234') = '1e957ebc35631ab22d5bd6526bd14ea2'
+| password for that username, even if it is hashed
|
*/
$config['auth_library_class'] = 'FHC_Auth';
-$config['auth_library_function'] = 'auth';
+
+// rest_auth is basic
+$config['auth_library_function'] = 'basicAuthentication';
+
+// rest_auth is digest
+//$config['auth_library_function'] = 'digestAuthentication';
/*
|--------------------------------------------------------------------------
@@ -211,7 +215,7 @@ $config['auth_override_class_method_http']['Kontakt']['kontaktPerson']['get'] =
| Array of usernames and passwords for login, if ldap (even library) is configured this is ignored
|
*/
-$config['rest_valid_logins'] = ['admin' => '1234', 'test' => 'test'];
+//$config['rest_valid_logins'] = ['admin' => '1234', 'test' => 'test'];
/*
|--------------------------------------------------------------------------
@@ -228,7 +232,7 @@ $config['rest_valid_logins'] = ['admin' => '1234', 'test' => 'test'];
| restrict certain methods to IPs in your whitelist
|
*/
-$config['rest_ip_whitelist_enabled'] = TRUE;
+$config['rest_ip_whitelist_enabled'] = FALSE;
/*
|--------------------------------------------------------------------------
diff --git a/application/config/template.php b/application/config/template.php
new file mode 100644
index 000000000..5dbf44178
--- /dev/null
+++ b/application/config/template.php
@@ -0,0 +1,15 @@
+
+ * @see http://codeigniter.com/user_guide/general/urls.html
+ * @return void
+ */
+ public function index()
+ {
+ $this->session->uid='admin'; // Should normaly be set through auth
+ $this->load->model('person/Prestudent_model');
+ $id=null;
+
+ // Insert PreStudent
+ $data = array
+ (
+ 'aufmerksamdurch_kurzbz' => 'k.A.',
+ 'person_id' => 1,
+ 'studiengang_kz' => 0
+ );
+ $res = $this->Prestudent_model->insert($data);
+ if ($res->error)
+ echo 'Error: ',$res->error, ', Code: ',$res->code,' -> ',$res->msg,': ',$res->retval,'
';
+ else
+ $id=$res->retval;
+
+ // Update PreStudent
+ $data = array
+ (
+ 'zgvort' => 'Wien',
+ 'zgvdatum' => '2012-12-12',
+ 'facheinschlberuf' => true
+ );
+ $res = $this->Prestudent_model->update($id, $data);
+ if ($res->error)
+ echo 'Error: ',$res->error, ', Code: ',$res->code,' -> ',$res->msg,': ',$res->retval,'
';
+ else
+ $id=$res->retval;
+
+ // Replace PreStudent
+ /*$data = array
+ (
+ 'prestudent_id' => $id,
+ 'zgvmaort' => 'Linz',
+ 'zgvmadatum' => '2011-11-11',
+ 'facheinschlberuf' => false
+ );
+ $res = $this->Prestudent_model->replace($data);
+ if ($res->error)
+ echo 'Error: ',$res->error, ', Code: ',$res->code,' -> ',$res->msg,': ',$res->retval;
+ else
+ echo 'Error: ',$res->error, ', Code: ',$res->code,' -> ',$res->msg,': ',$res->retval;*/
+
+ // Load PreStudent
+ $res = $this->Prestudent_model->load($id);
+ if ($res->error)
+ echo 'Error: ',$res->error, ', Code: ',$res->code,' -> ',$res->msg,': ',$res->retval,'
';
+ else
+ var_dump($res->retval);
+
+ // Delete PreStudent
+ $res = $this->Prestudent_model->delete($id);
+ if ($res->error)
+ echo 'Error: ',$res->error, ', Code: ',$res->code,' -> ',$res->msg,': ',$res->retval,'
';
+ else
+ var_dump($res->retval);
+
+ $this->load->model('organisation/Organisationseinheit_model');
+ // Insert OE
+ $data = array
+ (
+ 'oe_kurzbz' => 'testoe',
+ 'bezeichnung' => 'testoe',
+ 'organisationseinheittyp_kurzbz' => 'Institut',
+ 'standort_id' => null
+ );
+ $res = $this->Organisationseinheit_model->insert($data);
+ if ($res->error)
+ echo 'Error: ',$res->error, ', Code: ',$res->code,' -> ',$res->msg,': ',$res->retval,'
';
+ else
+ $id = $data['oe_kurzbz'];
+ var_dump($res);
+
+ // Update PreStudent
+ $data = array
+ (
+ 'freigabegrenze' => 1234.56,
+ 'kurzzeichen' => 'TestOE',
+ 'lehre' => false
+ );
+ $res = $this->Organisationseinheit_model->update($id, $data);
+ if ($res->error)
+ echo 'Error: ',$res->error, ', Code: ',$res->code,' -> ',$res->msg,': ',$res->retval,'
';
+ else
+ $id=$res->retval;
+
+ // Delete PreStudent
+ $res = $this->Organisationseinheit_model->delete($id);
+ if ($res->error)
+ echo 'Error: ',$res->error, ', Code: ',$res->code,' -> ',$res->msg,': ',$res->retval,'
';
+ else
+ var_dump($res->retval);
+
+ $this->load->model('core/Sprache_model');
+ // Insert Sprache
+ $data = array
+ (
+ 'sprache' => 'test',
+ 'bezeichnung' => "{'testsprache'}",
+ 'locale' => 'te_TE',
+ 'content' => false
+ );
+ $res = $this->Sprache_model->insert($data);
+ if ($res->error)
+ echo 'Error: ',$res->error, ', Code: ',$res->code,' -> ',$res->msg,': ',$res->retval,'
';
+ else
+ $id = $data['sprache'];
+ var_dump($res);
+
+ // Update Sprache
+ $data = array
+ (
+ 'index' => 4,
+ 'bezeichnung' => "{'TestSprache', 'TestLanguage', 'TestSpanisch'}",
+ 'content' => true
+ );
+ $res = $this->Sprache_model->update($id, $data);
+ if ($res->error)
+ echo 'Error: ',$res->error, ', Code: ',$res->code,' -> ',$res->msg,': ',$res->retval,'
';
+ else
+ $id=$res->retval; //echo $id;
+
+ // Load Sprache
+ $res = $this->Sprache_model->load($id);
+ if ($res->error)
+ echo 'Error: ',$res->error, ', Code: ',$res->code,' -> ',$res->msg,': ',$res->retval,'
';
+ else
+ {
+ $result = $res->retval->result_object();
+ var_dump($this->Sprache_model->pgArrayPhp($result[0]->bezeichnung));
+ }
+
+ // Delete Sprache
+ $res = $this->Sprache_model->delete($id);
+ if ($res->error)
+ echo 'Error: ',$res->error, ', Code: ',$res->code,' -> ',$res->msg,': ',$res->retval,'
';
+ else
+ var_dump($res->retval);
+ }
+}
diff --git a/application/controllers/Vilesci.php b/application/controllers/Vilesci.php
index ab33260c1..3cbf06974 100755
--- a/application/controllers/Vilesci.php
+++ b/application/controllers/Vilesci.php
@@ -1,7 +1,7 @@
dbupdate())
- echo 'System-DB needs update!';
- else
- {
- $this->load->view('templates/header');
- $this->load->view('vilesci_frameset');
- $this->load->view('templates/footer');
- }
- }
-
- /**
- *
- * @return bool
- */
- private function __dbupdate()
- {
- // Check for update (codeigniter migration)
- $this->load->library('migration');
- if ($this->migration->current() === false)
- show_error($this->migration->error_string());
- if ($this->migration->current() != $this->migration->latest())
- return true;
- else
- return false;
+ $this->load->view('templates/header');
+ $this->load->view('vilesci_frameset');
+ $this->load->view('templates/footer');
}
}
diff --git a/application/controllers/api/v1/APIAuth.php b/application/controllers/api/v1/APIAuth.php
deleted file mode 100644
index 162b112d3..000000000
--- a/application/controllers/api/v1/APIAuth.php
+++ /dev/null
@@ -1,133 +0,0 @@
-methods['login_get']['limit'] = 500; // 500 requests per hour per user/key
-
- // Load helper
- //$this->load->helper('fhcauth');
- $this->load->library('session');
- $this->load->library('FHC_Auth');
- }
-
- /**
- * Checks user credentials and creates a new session
- *
- * @example normal account: http://wsp.fortyseeds.at/backend/api/userauth/login/username/foo%40bar.at/password/secret/device_id/abcdef123
- * @example OAuth Google: http://wsp.fortyseeds.at/backend/api/userauth/login/username/foo%40bar.at/device_id/abcdef123/google_token/qwert321
- * @example OAuth Facebook: http://wsp.fortyseeds.at/backend/api/userauth/login/username/foo%40bar.at/device_id/abcdef123/fb_token/qwert321
- * @return void JSON that indicates success/failure of login.
- */
- public function login_get()
- {
- $payload = array();
- $errormsg = "";
- $httpstatus = null;
- $username = urldecode($this->get('username'));
- $password = urldecode($this->get('password'));
-
- $account = $this->fhc_auth->auth($username, $password);
-
- // perform login checks
- if (!$account)
- $errormsg = "Auth not accepted!";
-
- if (empty($errormsg))
- {
- // generate new session
- $this->session->sess_regenerate();
- $token = session_id();
-
- $payload = [
- 'success' => true,
- 'message' => 'User successfully logged in',
- 'session_id' => $token
- ];
- $httpstatus = REST_Controller::HTTP_OK;
- }
- else
- {
- $payload = [
- 'success' => false,
- 'message' => $errormsg
- ];
- $httpstatus = REST_Controller::HTTP_UNAUTHORIZED;
- }
-
- // Set the response and exit
- $this->response($payload, $httpstatus);
- }
-
- /**
- * Logs out user by destroying session
- *
- * @example http://wsp.fortyseeds.at/backend/api/userauth/logout/username/foo%40bar.at/session_id/55afab8ba6f1b/device_id/abcdef123
- * @return void JSON that indicates success/failure of logout
- */
- public function logout_get()
- {
- $payload = array();
- $httpstatus = null;
- $token = $this->get('session_id');
- $username = urldecode($this->get('username'));
- $deviceid = $this->get('device_id');
- $account = $this->user_model->load($username);
-
- // destroy session
- if ($this->session_model->destroy($account, $token, $deviceid))
- {
- $payload = [
- 'success' => true,
- 'message' => 'user successfully logged out'
- ];
- $httpstatus = REST_Controller::HTTP_OK;
- }
- else
- {
- $payload = [
- 'success' => false,
- 'message' => 'user could not be logged out'
- ];
- $httpstatus = REST_Controller::HTTP_BAD_REQUEST;
- }
-
- // Set the response and exit
- $this->response($payload, $httpstatus);
- }
-}
diff --git a/application/controllers/api/v1/APIKey.php b/application/controllers/api/v1/APIKey.php
deleted file mode 100644
index b28712e8c..000000000
--- a/application/controllers/api/v1/APIKey.php
+++ /dev/null
@@ -1,316 +0,0 @@
- ['level' => 10, 'limit' => 10],
- 'index_delete' => ['level' => 10],
- 'level_post' => ['level' => 10],
- 'regenerate_post' => ['level' => 10],
- ];
-
- /**
- * Insert a key into the database
- *
- * @access public
- * @return void
- */
- public function index_put()
- {
- // Build a new key
- $key = $this->__generateKey();
-
- // If no key level provided, provide a generic key
- $level = $this->put('level') ? $this->put('level') : 1;
- $ignore_limits = ctype_digit($this->put('ignore_limits')) ? (int)$this->put('ignore_limits') : 1;
-
- // Insert the new key
- if ($this->_insert_key($key, ['level' => $level, 'ignore_limits' => $ignore_limits]))
- {
- $this->response([
- 'status' => true,
- 'key' => $key
- ], REST_Controller::HTTP_CREATED); // CREATED (201) being the HTTP response code
- }
- else
- {
- $this->response([
- 'status' => false,
- 'message' => 'Could not save the key'
- ], REST_Controller::HTTP_INTERNAL_SERVER_ERROR); // INTERNAL_SERVER_ERROR (500) being the HTTP response code
- }
- }
-
- /**
- * Remove a key from the database to stop it working
- *
- * @access public
- * @return void
- */
- public function index_delete()
- {
- $key = $this->delete('key');
-
- // Does this key exist?
- if (!$this->_key_exists($key))
- {
- // It doesn't appear the key exists
- $this->response([
- 'status' => false,
- 'message' => 'Invalid API key'
- ], REST_Controller::HTTP_BAD_REQUEST); // BAD_REQUEST (400) being the HTTP response code
- }
-
- // Destroy it
- $this->_delete_key($key);
-
- // Respond that the key was destroyed
- $this->response([
- 'status' => true,
- 'message' => 'API key was deleted'
- ], REST_Controller::HTTP_NO_CONTENT); // NO_CONTENT (204) being the HTTP response code
- }
-
- /**
- * Change the level
- *
- * @access public
- * @return void
- */
- public function level_post()
- {
- $key = $this->post('key');
- $new_level = $this->post('level');
-
- // Does this key exist?
- if (!$this->_key_exists($key))
- {
- // It doesn't appear the key exists
- $this->response([
- 'status' => false,
- 'message' => 'Invalid API key'
- ], REST_Controller::HTTP_BAD_REQUEST); // BAD_REQUEST (400) being the HTTP response code
- }
-
- // Update the key level
- if ($this->_update_key($key, ['level' => $new_level]))
- {
- $this->response([
- 'status' => true,
- 'message' => 'API key was updated'
- ], REST_Controller::HTTP_OK); // OK (200) being the HTTP response code
- }
- else
- {
- $this->response([
- 'status' => false,
- 'message' => 'Could not update the key level'
- ], REST_Controller::HTTP_INTERNAL_SERVER_ERROR); // INTERNAL_SERVER_ERROR (500) being the HTTP response code
- }
- }
-
- /**
- * Suspend a key
- *
- * @access public
- * @return void
- */
- public function suspend_post()
- {
- $key = $this->post('key');
-
- // Does this key exist?
- if (!$this->_key_exists($key))
- {
- // It doesn't appear the key exists
- $this->response([
- 'status' => false,
- 'message' => 'Invalid API key'
- ], REST_Controller::HTTP_BAD_REQUEST); // BAD_REQUEST (400) being the HTTP response code
- }
-
- // Update the key level
- if ($this->_update_key($key, ['level' => 0]))
- {
- $this->response([
- 'status' => true,
- 'message' => 'Key was suspended'
- ], REST_Controller::HTTP_OK); // OK (200) being the HTTP response code
- }
- else
- {
- $this->response([
- 'status' => false,
- 'message' => 'Could not suspend the user'
- ], REST_Controller::HTTP_INTERNAL_SERVER_ERROR); // INTERNAL_SERVER_ERROR (500) being the HTTP response code
- }
- }
-
- /**
- * Regenerate a key
- *
- * @access public
- * @return void
- */
- public function regenerate_post()
- {
- $old_key = $this->post('key');
- $key_details = $this->__getKey($old_key);
-
- // Does this key exist?
- if (!$key_details)
- {
- // It doesn't appear the key exists
- $this->response([
- 'status' => false,
- 'message' => 'Invalid API key'
- ], REST_Controller::HTTP_BAD_REQUEST); // BAD_REQUEST (400) being the HTTP response code
- }
-
- // Build a new key
- $new_key = $this->__generateKey();
-
- // Insert the new key
- if ($this->_insert_key($new_key, ['level' => $key_details->level, 'ignore_limits' => $key_details->ignore_limits]))
- {
- // Suspend old key
- $this->_update_key($old_key, ['level' => 0]);
-
- $this->response([
- 'status' => true,
- 'key' => $new_key
- ], REST_Controller::HTTP_CREATED); // CREATED (201) being the HTTP response code
- }
- else
- {
- $this->response([
- 'status' => false,
- 'message' => 'Could not save the key'
- ], REST_Controller::HTTP_INTERNAL_SERVER_ERROR); // INTERNAL_SERVER_ERROR (500) being the HTTP response code
- }
- }
-
- /* Helper Methods */
-
- /**
- * Generate a key
- *
- * @access private
- * @return void
- */
- private function __generateKey()
- {
- do
- {
- // Generate a random salt
- $salt = base_convert(bin2hex($this->security->get_random_bytes(64)), 16, 36);
-
- // If an error occurred, then fall back to the previous method
- if ($salt === false)
- {
- $salt = hash('sha256', time().mt_rand());
- }
-
- $new_key = substr($salt, 0, config_item('rest_key_length'));
- }
- while ($this->_key_exists($new_key));
-
- return $new_key;
- }
-
- /* Private Data Methods */
-
- /**
- * Get a key
- *
- * @access private
- * @param string $key The API-Key.
- * @return array
- */
- private function __getKey($key)
- {
- return $this->db
- ->where(config_item('rest_key_column'), $key)
- ->get(config_item('rest_keys_table'))
- ->row();
- }
-
- /**
- * Check if key exists
- *
- * @access private
- * @param string $key The API-Key.
- * @return bool
- */
- private function _key_exists($key)
- {
- return $this->db
- ->where(config_item('rest_key_column'), $key)
- ->count_all_results(config_item('rest_keys_table')) > 0;
- }
-
- /**
- * Insert a key
- *
- * @access private
- * @param string $key The API-Key.
- * @param array $data The API-Key-Data.
- * @return bool
- */
- private function _insert_key($key, $data)
- {
- $data[config_item('rest_key_column')] = $key;
- $data['date_created'] = function_exists('now') ? now() : time();
-
- return $this->db
- ->set($data)
- ->insert(config_item('rest_keys_table'));
- }
-
- /**
- * Update a key
- *
- * @access private
- * @param string $key The API-Key.
- * @param array $data The API-Key-Data.
- * @return bool
- */
- private function _update_key($key, $data)
- {
- return $this->db
- ->where(config_item('rest_key_column'), $key)
- ->update(config_item('rest_keys_table'), $data);
- }
-
- /**
- * Delete a key
- *
- * @access private
- * @param string $key The API-Key.
- * @return bool
- */
- private function _delete_key($key)
- {
- return $this->db
- ->where(config_item('rest_key_column'), $key)
- ->delete(config_item('rest_keys_table'));
- }
-
-}
diff --git a/application/controllers/api/v1/Kontakt.php b/application/controllers/api/v1/Kontakt.php
index 68c015804..7f9c05112 100644
--- a/application/controllers/api/v1/Kontakt.php
+++ b/application/controllers/api/v1/Kontakt.php
@@ -15,7 +15,7 @@
defined('BASEPATH') || exit('No direct script access allowed');
-class Kontakt extends REST_Controller
+class Kontakt extends APIv1_Controller
{
//public $session;
diff --git a/application/controllers/api/v1/Nation.php b/application/controllers/api/v1/Nation.php
new file mode 100644
index 000000000..2e0d1ef0e
--- /dev/null
+++ b/application/controllers/api/v1/Nation.php
@@ -0,0 +1,80 @@
+load->model('nation_model', 'NationModel');
+ // Load set the addonID of the model to let to check the permissions
+ $this->NationModel->setAddonID($this->_getAddonID());
+ }
+
+ public function getAll()
+ {
+ $result = $this->NationModel->getAll($this->get('ohnesperre'), $this->get('orderEnglish'));
+
+ if(is_object($result))
+ {
+ $payload = [
+ 'success' => TRUE,
+ 'message' => 'Nation found',
+ 'data' => $result->result()
+ ];
+ $httpstatus = REST_Controller::HTTP_OK;
+ }
+ else
+ {
+ $payload = [
+ 'success' => FALSE,
+ 'message' => 'Nation not found'
+ ];
+ $httpstatus = REST_Controller::HTTP_OK;
+ }
+
+ $this->response($payload, $httpstatus);
+ }
+
+ public function getBundesland()
+ {
+ $result = $this->NationModel->getBundesland();
+
+ if(is_object($result))
+ {
+ $payload = [
+ 'success' => TRUE,
+ 'message' => 'Bundesland found',
+ 'data' => $result->result()
+ ];
+ $httpstatus = REST_Controller::HTTP_OK;
+ }
+ else
+ {
+ $payload = [
+ 'success' => FALSE,
+ 'message' => 'Bundesland not found'
+ ];
+ $httpstatus = REST_Controller::HTTP_OK;
+ }
+
+ $this->response($payload, $httpstatus);
+ }
+}
\ No newline at end of file
diff --git a/application/controllers/api/v1/Person.php b/application/controllers/api/v1/Person.php
deleted file mode 100644
index b74bbce59..000000000
--- a/application/controllers/api/v1/Person.php
+++ /dev/null
@@ -1,207 +0,0 @@
-load->model('person/person_model');
- }
-
- public function person_get()
- {
- //if (!$this->session_model->validate($this->get('session_id'), $this->get('device_id')))
- // $this->response(array(['success' => false, 'message' => 'access denied']), REST_Controller::HTTP_UNAUTHORIZED);
-
- $code = $this->get('code');
- $email = $this->get('email');
- $person_id = $this->get('person_id');
-
- if ((!is_null($code)) && (!is_null($email)))
- {
- $result = $this->person_model->getPersonByCodeAndEmail($code, $email);
- }
- elseif (! is_null($code))
- {
- $result = $this->person_model->getPersonByCode($code, $email);
- }
- elseif (!is_null($person_id))
- {
- $result = $this->person_model->getPerson($person_id);
- }
- else
- {
- $result = $this->person_model->getPerson();
- }
-
- if (empty($result))
- {
- $payload = [
- 'success' => false,
- 'message' => 'Person not found'
- ];
- $httpstatus = REST_Controller::HTTP_OK;
- }
- else
- {
- // return all available persons
- $payload = [
- 'success' => true,
- 'message' => 'Persons found'
- ];
- $payload['data'] = $result;
- $httpstatus = REST_Controller::HTTP_OK;
- }
-
- // Set the response and exit
- $this->response($payload, $httpstatus);
- }
-
- public function personFromCode_post()
- {
- $code = $this->post('code');
- $email = $this->post('email');
- $person_id = $this->post('person_id');
-
- if ((!is_null($code)) && (!is_null($email)))
- {
- $result = $this->person_model->getPersonByCodeAndEmail($code, $email);
- }
- elseif (!is_null($person_id))
- {
- $result = $this->person_model->getPerson($person_id);
- }
- else
- {
- $result = $this->person_model->getPerson();
- }
-
- if (empty($result))
- {
- $payload = [
- 'success' => false,
- 'message' => 'Person not found'
- ];
- $httpstatus = REST_Controller::HTTP_OK;
- }
- else
- {
- // return all available persons
- $payload = [
- 'success' => true,
- 'message' => 'Persons found'
- ];
- $payload['data'] = $result;
- $httpstatus = REST_Controller::HTTP_OK;
- }
-
- // Set the response and exit
- $this->response($payload, $httpstatus);
- }
-
- public function person_post()
- {
- $result = $this->person_model->savePerson($this->post());
- if($result != FALSE)
- {
- $httpstatus = REST_Controller::HTTP_OK;
- $payload = [
- 'success' => true,
- 'message' => 'Person saved.'
- ];
- $payload['data'] = $result;
- }
- else
- {
- $payload = [
- 'success' => false,
- 'message' => 'Could not save person.'
- ];
- $httpstatus = REST_Controller::HTTP_OK;
- }
-
- $this->response($payload, $httpstatus);
- }
-
- public function personUpdate_post()
- {
- $result = $this->person_model->updatePerson($this->post());
- if($result != FALSE)
- {
- $httpstatus = REST_Controller::HTTP_OK;
- $payload = [
- 'success' => true,
- 'message' => 'Person updated.'
- ];
- $payload['data'] = $result;
- }
- else
- {
- $payload = [
- 'success' => false,
- 'message' => 'Could not update person.'
- ];
- $httpstatus = REST_Controller::HTTP_OK;
- }
- //
- $this->response($payload, $httpstatus);
- }
-
- public function checkBewerbung_get()
- {
- $result = $this->person_model->checkBewerbung($this->get("email"),$this->get("studiensemester_kurzbz"));
- $httpstatus = REST_Controller::HTTP_OK;
- $payload = [
- 'success' => true,
- 'message' => 'Bewerbung exists.'
- ];
- $payload['data'] = $result;
-
- $this->response($payload, $httpstatus);
- }
-
- public function checkZugangscodePerson_get()
- {
- $result = $this->person_model->checkZugangscodePerson($this->get("code"));
- $httpstatus = REST_Controller::HTTP_OK;
- if(!empty($result))
- {
- $payload = [
- 'success' => true,
- 'message' => 'Zugangscode exists.'
- ];
- $payload['data'] = $result;
- }
- else
- {
- $payload = [
- 'success' => false,
- 'message' => 'Zugangscode does not exist.'
- ];
- $httpstatus = REST_Controller::HTTP_OK;
- }
-
- $this->response($payload, $httpstatus);
- }
-}
diff --git a/application/controllers/api/v1/Test.php b/application/controllers/api/v1/Test.php
new file mode 100644
index 000000000..d575db173
--- /dev/null
+++ b/application/controllers/api/v1/Test.php
@@ -0,0 +1,50 @@
+ TRUE,
+ 'message' => 'API HTTP GET call test succeed'
+ ];
+ $httpstatus = REST_Controller::HTTP_OK;
+ $this->response($payload, $httpstatus);
+ }
+
+ /**
+ * Test HTTP POST method
+ * * It responses whith the HTTP status 200 and prints this JSON string
+ * {"success":true,"message":"API HTTP POST call test succeed"}
+ *
+ * @return void
+ */
+ public function postTest()
+ {
+ $payload = [
+ 'success' => TRUE,
+ 'message' => 'API HTTP POST call test succeed'
+ ];
+ $httpstatus = REST_Controller::HTTP_OK;
+ $this->response($payload, $httpstatus);
+ }
+}
diff --git a/application/controllers/api/v1/lehre/Studiengang.php b/application/controllers/api/v1/lehre/Studiengang.php
new file mode 100644
index 000000000..e85b6e601
--- /dev/null
+++ b/application/controllers/api/v1/lehre/Studiengang.php
@@ -0,0 +1,55 @@
+load->model('lehre/studiengang_model', 'StudiengangModel');
+ // Load set the addonID of the model to let to check the permissions
+ $this->StudiengangModel->setAddonID($this->_getAddonID());
+ }
+
+ public function getAllForBewerbung()
+ {
+ $result = $this->StudiengangModel->getAllForBewerbung();
+
+ if(is_object($result) && $result->num_rows() > 0)
+ {
+ $payload = [
+ 'success' => TRUE,
+ 'message' => 'Courses found',
+ 'data' => $result->result()
+ ];
+ $httpstatus = REST_Controller::HTTP_OK;
+ }
+ else
+ {
+ $payload = [
+ 'success' => FALSE,
+ 'message' => 'No courses found'
+ ];
+ $httpstatus = REST_Controller::HTTP_OK;
+ }
+
+ $this->response($payload, $httpstatus);
+ }
+}
\ No newline at end of file
diff --git a/application/controllers/api/v1/lehre/Studienplan.php b/application/controllers/api/v1/lehre/Studienplan.php
new file mode 100644
index 000000000..f0c831ee4
--- /dev/null
+++ b/application/controllers/api/v1/lehre/Studienplan.php
@@ -0,0 +1,55 @@
+load->model('lehre/studienplan_model', 'StudienplanModel');
+ // Load set the addonID of the model to let to check the permissions
+ $this->StudienplanModel->setAddonID($this->_getAddonID());
+ }
+
+ public function getStudienplaene()
+ {
+ $result = $this->StudienplanModel->getStudienplaene($this->get('studiengang_kz'));
+
+ if(is_object($result) && $result->num_rows() > 0)
+ {
+ $payload = [
+ 'success' => TRUE,
+ 'message' => 'Plan found',
+ 'data' => $result->result()
+ ];
+ $httpstatus = REST_Controller::HTTP_OK;
+ }
+ else
+ {
+ $payload = [
+ 'success' => FALSE,
+ 'message' => 'Plan not found'
+ ];
+ $httpstatus = REST_Controller::HTTP_OK;
+ }
+
+ $this->response($payload, $httpstatus);
+ }
+}
\ No newline at end of file
diff --git a/application/controllers/api/v1/person/Person.php b/application/controllers/api/v1/person/Person.php
index 02954c7e0..3f2c1704e 100644
--- a/application/controllers/api/v1/person/Person.php
+++ b/application/controllers/api/v1/person/Person.php
@@ -1,5 +1,4 @@
load->model('person/person_model');
- }
+ // Load model PersonModel
+ $this->load->model('person/person_model', 'PersonModel');
+ // Load set the addonID of the model to let to check the permissions
+ $this->PersonModel->setAddonID($this->_getAddonID());
+ }
/**
* @return void
*/
- public function person_get()
- {
- //if(!$this->session_model->validate($this->get('session_id'), $this->get('device_id')))
- // $this->response(array(['success' => false, 'message' => 'access denied']), REST_Controller::HTTP_UNAUTHORIZED);
-
+ public function getPerson()
+ {
+ $personID = $this->get('person_id');
$code = $this->get('code');
$email = $this->get('email');
- $person_id = $this->get('person_id');
- if ((!is_null($code)) && (!is_null($email)))
- {
- $result = $this->person_model->getPersonByCodeAndEmail($code, $email);
- }
- elseif (! is_null($code))
- {
- $result = $this->person_model->getPersonByCode($code);
- }
- elseif (! is_null($person_id))
- {
- $result = $this->person_model->getPerson($person_id);
- }
- else
- {
- $result = $this->person_model->getPerson();
- }
+ $result = $this->PersonModel->getPerson($personID, $code, $email);
- if ($result['err'])
- {
- $payload = [
- 'success' => false,
- 'message' => $result['msg'].': '.$result['retval']
- ];
- $httpstatus = REST_Controller::HTTP_OK;
- }
- else
- {
- // return all available persons
- $payload = [
- 'success' => true,
- 'message' => 'Persons found'
- ];
- $payload['data'] = $result;
- $httpstatus = REST_Controller::HTTP_OK;
- }
-
- if (empty($result))
+ if(is_object($result) && $result->num_rows() > 0)
{
$payload = [
- 'success' => false,
- 'message' => 'Person not found'
+ 'success' => TRUE,
+ 'message' => 'Person found',
+ 'data' => $result->result()
];
$httpstatus = REST_Controller::HTTP_OK;
}
else
{
- // return all available persons
$payload = [
- 'success' => true,
- 'message' => 'Persons found'
+ 'success' => FALSE,
+ 'message' => 'Person not found'
];
- $payload['data'] = $result;
$httpstatus = REST_Controller::HTTP_OK;
}
- // Set the response and exit
+
$this->response($payload, $httpstatus);
- }
+ }
- /**
+ /**
* @return void
*/
- public function person_post()
- {
- $result = $this->person_model->savePerson($this->post());
- if ($result != false)
+ public function postPerson()
+ {
+ $result = $this->PersonModel->savePerson($this->post());
+
+ if($result === TRUE)
{
$httpstatus = REST_Controller::HTTP_OK;
$payload = [
@@ -121,40 +85,40 @@ class Person extends APIv1_Controller
$httpstatus = REST_Controller::HTTP_OK;
}
$this->response($payload, $httpstatus);
- }
-
- /**
- * @return void
+ }
+
+ /**
+ *
*/
- public function personUpdate_post()
- {
- $result = $this->person_model->updatePerson($this->post());
- if ($result != false)
+ public function postPrestudent()
+ {
+ $result = $this->PersonModel->savePrestudent($this->post());
+
+ if($result === TRUE)
{
$httpstatus = REST_Controller::HTTP_OK;
$payload = [
'success' => true,
- 'message' => 'Person updated.'
+ 'message' => 'Interested student saved.'
];
- $payload['data'] = $result;
}
else
{
$payload = [
'success' => false,
- 'message' => 'Could not update person.'
+ 'message' => 'Could not save interested student.'
];
$httpstatus = REST_Controller::HTTP_OK;
}
$this->response($payload, $httpstatus);
- }
+ }
- /**
+ /**
* @return void
*/
- public function checkBewerbung_get()
- {
- $result = $this->person_model->checkBewerbung($this->get("email"), $this->get("studiensemester_kurzbz"));
+ public function getCheckBewerbung()
+ {
+ $result = $this->PersonModel->checkBewerbung($this->get("email"), $this->get("studiensemester_kurzbz"));
$httpstatus = REST_Controller::HTTP_OK;
$payload = [
'success' => true,
@@ -162,16 +126,16 @@ class Person extends APIv1_Controller
];
$payload['data'] = $result;
$this->response($payload, $httpstatus);
- }
+ }
- /**
+ /**
* @return void
*/
- public function checkZugangscodePerson_get()
- {
- $result = $this->person_model->checkZugangscodePerson($this->get("code"));
+ public function getCheckZugangscodePerson()
+ {
+ $result = $this->PersonModel->checkZugangscodePerson($this->get("code"));
$httpstatus = REST_Controller::HTTP_OK;
- if (!empty($result))
+ if(!empty($result))
{
$payload = [
'success' => true,
@@ -189,5 +153,5 @@ class Person extends APIv1_Controller
}
$this->response($payload, $httpstatus);
- }
+ }
}
diff --git a/application/controllers/person/Kontakt.php b/application/controllers/person/Kontakt.php
deleted file mode 100644
index dc6ec2e8d..000000000
--- a/application/controllers/person/Kontakt.php
+++ /dev/null
@@ -1,32 +0,0 @@
-load->model('kontakt/kontakt_model');
- }
-
- public function index()
- {
- $data['person'] = $this->person_model->getPersonen();
- $data['title'] = 'Personen Archiv';
-
- $this->load->view('templates/header', $data);
- $this->load->view('kontakt/index', $data);
- $this->load->view('templates/footer');
- }
-
- public function view($slug = null)
- {
- $data['person_item'] = $this->person_model->getPersonen($slug);
- if (empty($data['person_item']))
- show_404();
-
- $data['title'] = $data['person_item']->titelpre;
-
- $this->load->view('templates/header', $data);
- $this->load->view('kontakt/view', $data);
- $this->load->view('templates/footer');
- }
-}
diff --git a/application/controllers/person/Person.php b/application/controllers/person/Person.php
deleted file mode 100644
index ebad71c50..000000000
--- a/application/controllers/person/Person.php
+++ /dev/null
@@ -1,32 +0,0 @@
-load->model('person/person_model');
- }
-
- public function index()
- {
- $data['person'] = $this->person_model->getPersonen();
- $data['title'] = 'Personen Archiv';
-
- $this->load->view('templates/header', $data);
- $this->load->view('person/index', $data);
- $this->load->view('templates/footer');
- }
-
- public function view($slug = null)
- {
- $data['person_item'] = $this->person_model->getPersonen($slug);
- if (empty($data['person_item']))
- show_404();
-
- $data['title'] = $data['person_item']->titelpre;
-
- $this->load->view('templates/header', $data);
- $this->load->view('person/view', $data);
- $this->load->view('templates/footer');
- }
-}
diff --git a/application/core/APIv1_Controller.php b/application/core/APIv1_Controller.php
new file mode 100644
index 000000000..b33c5a530
--- /dev/null
+++ b/application/core/APIv1_Controller.php
@@ -0,0 +1,13 @@
+load->library('session'); // -> autoload
+ //$this->load->library('database'); -> autoload
+ }
+}
\ No newline at end of file
diff --git a/application/core/DB_Model.php b/application/core/DB_Model.php
new file mode 100644
index 000000000..e8905c630
--- /dev/null
+++ b/application/core/DB_Model.php
@@ -0,0 +1,233 @@
+dbTable = $dbTable;
+ $this->pk = $pk;
+ $this->load->database();
+ $this->acl = $this->config->item('fhc_acl');
+ }
+
+ /** ---------------------------------------------------------------
+ * Insert Data into DB-Table
+ *
+ * @param array $data DataArray for Insert
+ * @return array
+ */
+ public function insert($data)
+ {
+ // Check Class-Attributes
+ if(is_null($this->dbTable))
+ return $this->_error(lang('fhc_'.FHC_NODBTABLE), FHC_MODEL_ERROR);
+
+ // Check rights
+ if (! $this->fhc_db_acl->isBerechtigt((string)($this->acl[$this->dbTable]), 'i'))
+ return $this->_error(lang('fhc_'.FHC_NORIGHT).' -> '.$this->acl[$this->dbTable], FHC_MODEL_ERROR);
+
+ // DB-INSERT
+ if ($this->db->insert($this->dbTable, $data))
+ return $this->_success($this->db->insert_id());
+ else
+ return $this->_error($this->db->error(), FHC_DB_ERROR);
+ }
+
+ /** ---------------------------------------------------------------
+ * Replace Data in DB-Table
+ *
+ * @param array $data DataArray for Replacement
+ * @return array
+ */
+ public function replace($data)
+ {
+ // Check Class-Attributes
+ if(is_null($this->dbTable))
+ return $this->_error(lang('fhc_'.FHC_NODBTABLE), FHC_MODEL_ERROR);
+
+ // Check rights
+ if (! $this->fhc_db_acl->isBerechtigt((string)($this->acl[$this->dbTable]), 'ui'))
+ return $this->_error(lang('fhc_'.FHC_NORIGHT).' -> '.$this->acl[$this->dbTable], FHC_MODEL_ERROR);
+
+ // DB-REPLACE
+ if ($this->db->replace($this->dbTable, $data))
+ return $this->_success($this->db->insert_id());
+ else
+ return $this->_error($this->db->error(), FHC_DB_ERROR);
+ }
+
+ /** ---------------------------------------------------------------
+ * Update Data in DB-Table
+ *
+ * @param string $id PK for DB-Table
+ * @param array $data DataArray for Insert
+ * @return array
+ */
+ public function update($id, $data)
+ {
+ // Check Class-Attributes
+ if(is_null($this->dbTable))
+ return $this->_error(lang('fhc_'.FHC_NODBTABLE), FHC_MODEL_ERROR);
+ if(is_null($this->pk))
+ return $this->_error(lang('fhc_'.FHC_NOPK), FHC_MODEL_ERROR);
+
+ // Check rights
+ if (! $this->fhc_db_acl->isBerechtigt((string)($this->acl[$this->dbTable]), 'u'))
+ return $this->_error(lang('fhc_'.FHC_NORIGHT).' -> '.$this->acl[$this->dbTable], FHC_MODEL_ERROR);
+
+ // DB-UPDATE
+ $this->db->where($this->pk, $id);
+ if ($this->db->update($this->dbTable, $data))
+ return $this->_success($id);
+ else
+ return $this->_error($this->db->error(), FHC_DB_ERROR);
+ }
+
+ /** ---------------------------------------------------------------
+ * Load data from DB-Table
+ *
+ * @param string $id Primary Key for SELECT
+ * @return array
+ */
+ public function load($id)
+ {
+ // Check Class-Attributes
+ if(is_null($this->dbTable))
+ return $this->_error(lang('fhc_'.FHC_NODBTABLE), FHC_MODEL_ERROR);
+ if(is_null($this->pk))
+ return $this->_error(lang('fhc_'.FHC_NOPK), FHC_MODEL_ERROR);
+
+ // Check rights
+ if (! $this->fhc_db_acl->isBerechtigt((string)($this->acl[$this->dbTable]), 's'))
+ return $this->_error(lang('fhc_'.FHC_NORIGHT).' -> '.$this->acl[$this->dbTable], FHC_MODEL_ERROR);
+
+ // DB-SELECT
+ $result = $this->db->get_where($this->dbTable, array($this->pk => $id));
+ //var_dump($result);
+ if ($result)
+ return $this->_success($result);
+ else
+ return $this->_error($this->db->error(), FHC_DB_ERROR);
+ }
+
+ /** ---------------------------------------------------------------
+ * Delete data from DB-Table
+ *
+ * @param string $id Primary Key for DELETE
+ * @return array
+ */
+ public function delete($id)
+ {
+ // Check Class-Attributes
+ if(is_null($this->dbTable))
+ return $this->_error(lang('fhc_'.FHC_NODBTABLE), FHC_MODEL_ERROR);
+ if(is_null($this->pk))
+ return $this->_error(lang('fhc_'.FHC_NOPK), FHC_MODEL_ERROR);
+
+ // Check rights
+ if (! $this->fhc_db_acl->isBerechtigt($this->acl[$this->dbTable], 'd'))
+ return $this->_error(lang('fhc_'.FHC_NORIGHT).' -> '.$this->acl[$this->dbTable], FHC_MODEL_ERROR);
+
+ // DB-DELETE
+ if ($this->db->delete($this->dbTable, array($this->pk => $id)))
+ return $this->_success($id);
+ else
+ return $this->_error($this->db->error(), FHC_DB_ERROR);
+ }
+
+ /** ---------------------------------------------------------------
+ * Convert PG-Array to PHP-Array
+ *
+ * @param integer config.php error code numbers
+ * @return array
+ */
+ public function pgArrayPhp($s,$start=0,&$end=NULL)
+ {
+ if (empty($s) || $s[0]!='{') return NULL;
+ $return = array();
+ $br = 0;
+ $string = false;
+ $quote='';
+ $len = strlen($s);
+ $v = '';
+ for($i=$start+1; $i<$len;$i++)
+ {
+ $ch = $s[$i];
+ if (!$string && $ch=='}')
+ {
+ if ($v!=='' || !empty($return))
+ $return[] = $v;
+ $end = $i;
+ break;
+ }
+ else
+ if (!$string && $ch=='{')
+ $v = $this->pgArrayPhp($s,$i,$i);
+ else
+ if (!$string && $ch==',')
+ {
+ $return[] = $v;
+ $v = '';
+ }
+ else
+ if (!$string && ($ch=='"' || $ch=="'"))
+ {
+ $string = TRUE;
+ $quote = $ch;
+ }
+ else
+ if ($string && $ch==$quote && $s[$i-1]=="\\")
+ $v = substr($v,0,-1).$ch;
+ else
+ if ($string && $ch==$quote && $s[$i-1]!="\\")
+ $string = FALSE;
+ else
+ $v .= $ch;
+ }
+ return $return;
+ }
+
+ /** ---------------------------------------------------------------
+ * Invalid ID
+ *
+ * @param integer config.php error code numbers
+ * @return array
+ */
+ protected function _invalid_id($error = '')
+ {
+ return array(
+ 'err' => 1,
+ 'code' => $error,
+ 'msg' => lang('fhc_' . $error)
+ );
+ }
+
+ /**
+ * Method setAddonID
+ *
+ * @param $addonID
+ * @return void
+ */
+ public function setAddonID($addonID)
+ {
+ $this->_addonID = $addonID;
+ }
+
+ /**
+ * Method getAddonID
+ *
+ * @return string _addonID
+ */
+ public function getAddonID()
+ {
+ return $this->_addonID;
+ }
+}
diff --git a/application/core/FHC_Controller.php b/application/core/FHC_Controller.php
index 656dd4c1e..b08696193 100644
--- a/application/core/FHC_Controller.php
+++ b/application/core/FHC_Controller.php
@@ -8,17 +8,4 @@ class FHC_Controller extends CI_Controller
parent::__construct();
//$this->load->helper('language');
}
-}
-
-require_once APPPATH . '/libraries/REST_Controller.php';
-
-class APIv1_Controller extends REST_Controller
-{
- function __construct()
- {
- parent::__construct();
- //$this->load->library('session'); -> autoload
- //$this->load->library('database'); -> autoload
- }
-
-}
+}
\ No newline at end of file
diff --git a/application/core/FHC_Model.php b/application/core/FHC_Model.php
index 14377d13d..d9d8c6690 100644
--- a/application/core/FHC_Model.php
+++ b/application/core/FHC_Model.php
@@ -1,93 +1,50 @@
load->helper('language');
- $this->lang->load('fhcomplete');
- }
-
- /** ---------------------------------------------------------------
- * Success
- *
- * @param mixed $retval
- * @return array
- */
- protected function _success($retval = '', $message = FHC_SUCCESS)
- {
- return array(
- 'err' => 0,
- 'code' => FHC_SUCCESS,
- 'msg' => lang('fhc_' . $message),
- 'retval' => $retval
- );
- }
-
- /** ---------------------------------------------------------------
- * General Error
- *
- * @return array
- */
- protected function _general_error($retval = '', $message = FHC_ERR_GENERAL)
- {
- return array(
- 'err' => 1,
- 'code' => FHC_ERR_GENERAL,
- 'msg' => lang('fhc_'.$message),
- 'retval' => $retval
- );
- }
-}
-
-class DB_Model extends FHC_Model
-{
-
- protected $dbTable=null; // Name of the DB-Table for CI-Insert, -Update, ...
-
- function __construct($uid=null)
- {
- parent::__construct();
- $this->load->database();
- $this->load->helper('language');
- $this->lang->load('fhc_db');
-
- // UID must be set in Production Mode
- if (ENVIRONMENT=='production' && is_null($uid))
- log_message('error', 'UID must be set in Production Mode.');
- elseif (is_null($uid))
- log_message('info', 'UID is not set.');
-
- // Loading Tools for Access Control (Benutzerberechtigungen)
+ $this->lang->load('fhc_model');
+ //$this->load->helper('fhc_db_acl');
+ $this->lang->load('fhcomplete');
+ //$this->load->library('session');
+ if (is_null($uid))
+ $uid = $this->session->uid;
$this->load->library('FHC_DB_ACL',array('uid' => $uid));
- }
-
- public function insert($data)
- {
- if (! is_null($this->dbTable))
- {
- $this->db->insert($this->dbTable, $data);
- return true;
- }
- else
- return false;
}
/** ---------------------------------------------------------------
- * Invalid ID
- *
- * @param integer config.php error code numbers
- * @return array
- */
- protected function _invalid_id($error = '')
- {
- return array(
- 'err' => 1,
- 'code' => $error,
- 'msg' => lang('fhc_'.$error)
- );
- }
+ * Success
+ *
+ * @param mixed $retval
+ * @return array
+ */
+ protected function _success($retval, $message = FHC_SUCCESS)
+ {
+ $return = new stdClass();
+ $return->error = EXIT_SUCCESS;
+ $return->code = $message;
+ $return->msg = lang('fhc_' . $message);
+ $return->retval = $retval;
+ return $return;
+ }
+
+ /** ---------------------------------------------------------------
+ * General Error
+ *
+ * @return array
+ */
+ protected function _error($retval = '', $message = FHC_MODEL_ERROR)
+ {
+ $return = new stdClass();
+ $return->error = EXIT_MODEL;
+ $return->code = $message;
+ $return->msg = lang('fhc_' . $message);
+ $return->retval = $retval;
+ return $return;
+ }
}
diff --git a/application/helpers/fhc_db_acl_helper.php b/application/helpers/fhc_db_acl_helper.php
new file mode 100644
index 000000000..2456ea6b5
--- /dev/null
+++ b/application/helpers/fhc_db_acl_helper.php
@@ -0,0 +1,12 @@
+getBerechtigungen($uid);
+ return $bb->isBerechtigt($berechtigung_kurzbz, $art, $oe_kurzbz, $kostenstelle_id);*/
+
+ return TRUE;
+}
\ No newline at end of file
diff --git a/application/helpers/fhcdb_helper.php b/application/helpers/fhcdb_helper.php
index 8f86ea691..c5eee6800 100644
--- a/application/helpers/fhcdb_helper.php
+++ b/application/helpers/fhcdb_helper.php
@@ -428,3 +428,23 @@ function indexSort($a, $b)
{
return strcmp($a->index, $b->index);
}
+
+/**
+ * Bereitet ein Array von Elementen auf, damit es in der IN-Klausel eines
+ * Select Befehls verwendet werden kann.
+ */
+function dbImplode4SQL($array)
+{
+ $string = '';
+
+ foreach($array as $row)
+ {
+ if($string != '')
+ {
+ $string.=',';
+ }
+ $string.=$this->db_add_param($row);
+ }
+
+ return $string;
+}
\ No newline at end of file
diff --git a/application/language/de-AT/fhc_db_lang.php b/application/language/de-AT/fhc_db_lang.php
deleted file mode 100644
index 463582f53..000000000
--- a/application/language/de-AT/fhc_db_lang.php
+++ /dev/null
@@ -1,2 +0,0 @@
-checkpassword($username, $password))
+ if($auth->checkpassword($username, $password))
{
- //echo 'Auth-Method-True';
return true;
}
else
{
- //echo 'Auth-Method-False';
return false;
}
}
-}
+
+ /**
+ * Get the md5 hashed password by the addon username
+ *
+ * @param string $username addon username
+ * @return string md5 hashed string
+ */
+ public function digestAuthentication($username)
+ {
+ $aam = new AddonAuthentication();
+
+ return md5($aam->getPasswordByUsername($username));
+ }
+}
\ No newline at end of file
diff --git a/application/libraries/FHC_DB_ACL.php b/application/libraries/FHC_DB_ACL.php
index db906384e..729f1d1f9 100644
--- a/application/libraries/FHC_DB_ACL.php
+++ b/application/libraries/FHC_DB_ACL.php
@@ -43,10 +43,10 @@ class FHC_DB_ACL
* @param string $password
* @return bool
*/
- function __construct($uid)
+ function __construct($param)
{
$this->bb = new benutzerberechtigung();
- $this->uid = $uid;
+ $this->uid = $param['uid'];
}
function isBerechtigt($berechtigung_kurzbz, $art=null, $oe_kurzbz=null, $kostenstelle_id=null)
diff --git a/application/libraries/REST_Controller.php b/application/libraries/REST_Controller.php
index c9253079c..7caf4646d 100644
--- a/application/libraries/REST_Controller.php
+++ b/application/libraries/REST_Controller.php
@@ -351,8 +351,13 @@ abstract class REST_Controller extends CI_Controller {
self::HTTP_INTERNAL_SERVER_ERROR => 'INTERNAL SERVER ERROR',
self::HTTP_NOT_IMPLEMENTED => 'NOT IMPLEMENTED'
];
+
+ /**
+ *
+ */
+ protected $_addonID = NULL;
- /**
+ /**
* Extend this function to apply additional checking early on in the process
*
* @access protected
@@ -361,7 +366,7 @@ abstract class REST_Controller extends CI_Controller {
protected function early_checks()
{
}
-
+
/**
* Constructor for the REST API
*
@@ -528,7 +533,7 @@ abstract class REST_Controller extends CI_Controller {
{
$this->_allow = $this->_detect_api_key();
}
-
+
// Only allow ajax requests
if ($this->input->is_ajax_request() === FALSE && $this->config->item('rest_ajax_only'))
{
@@ -540,7 +545,7 @@ abstract class REST_Controller extends CI_Controller {
}
// When there is no specific override for the current class/method, use the default auth value set in the config
- if ($this->auth_override === FALSE && !($this->config->item('rest_enable_keys') && $this->_allow === TRUE))
+ if ($this->auth_override === FALSE && ($this->config->item('rest_enable_keys') && $this->_allow === TRUE))
{
$rest_auth = strtolower($this->config->item('rest_auth'));
switch ($rest_auth)
@@ -604,8 +609,10 @@ abstract class REST_Controller extends CI_Controller {
// Remove the supported format from the function name e.g. index.json => index
$object_called = preg_replace('/^(.*)\.(?:' . implode('|', array_keys($this->_supported_formats)) . ')$/', '$1', $object_called);
- $controller_method = $object_called . '_' . $this->request->method;
-
+ //$controller_method = $object_called . '_' . $this->request->method;
+ // CamelCase compliant
+ $controller_method = $this->request->method.ucfirst($object_called);
+
// Do we want to log this method (if allowed by config)?
$log_method = !(isset($this->methods[$controller_method]['log']) && $this->methods[$controller_method]['log'] === FALSE);
@@ -1900,6 +1907,25 @@ abstract class REST_Controller extends CI_Controller {
], self::HTTP_UNAUTHORIZED);
}
}
+
+ /**
+ * TO BE COMMENTED
+ */
+ private function _setAddonID($username)
+ {
+ if(!isset($this->_addonID) && isset($username))
+ {
+ $this->_addonID = $username;
+ }
+ }
+
+ /**
+ * @return int ID of the authenticated addon
+ */
+ protected function _getAddonID()
+ {
+ return $this->_addonID;
+ }
/**
* Prepares for basic authentication
@@ -1940,6 +1966,10 @@ abstract class REST_Controller extends CI_Controller {
{
$this->_force_login();
}
+ else // If logged
+ {
+ $this->_setAddonID($username);
+ }
}
/**
@@ -1978,12 +2008,19 @@ abstract class REST_Controller extends CI_Controller {
preg_match_all('@(username|nonce|uri|nc|cnonce|qop|response)=[\'"]?([^\'",]+)@', $digest_string, $matches);
$digest = (empty($matches[1]) || empty($matches[2])) ? [] : array_combine($matches[1], $matches[2]);
- // For digest authentication the library function should return already stored md5(username:restrealm:password) for that username @see rest.php::auth_library_function config
+ // For digest authentication the library function should return
+ // already stored password for that username, even if it is hashed
$username = $this->_check_login($digest['username'], TRUE);
- if (array_key_exists('username', $digest) === FALSE || $username === FALSE)
+ // If there no password
+ if (array_key_exists('username', $digest) === FALSE || $username === FALSE || $username === NULL)
{
$this->_force_login($unique_id);
}
+ // If the password was found for this username, generete the string md5('USERNAME:REALM:PASSWORD')
+ else
+ {
+ $username = md5($digest['username'].":".$this->config->item('rest_realm').":".$username);
+ }
$md5 = md5(strtoupper($this->request->method) . ':' . $digest['uri']);
$valid_response = md5($username . ':' . $digest['nonce'] . ':' . $digest['nc'] . ':' . $digest['cnonce'] . ':' . $digest['qop'] . ':' . $md5);
@@ -2148,5 +2185,4 @@ abstract class REST_Controller extends CI_Controller {
->get($this->config->item('rest_access_table'))
->num_rows() > 0;
}
-
-}
+}
\ No newline at end of file
diff --git a/application/libraries/Template.php b/application/libraries/Template.php
new file mode 100644
index 000000000..07bccd949
--- /dev/null
+++ b/application/libraries/Template.php
@@ -0,0 +1,629 @@
+_ci = & get_instance();
+
+ // set the default widget path with APPPATH
+ $this->_widget_path = APPPATH . 'widgets/';
+
+ if (!empty($config))
+ $this->initialize($config);
+
+ log_message('debug', 'Template library initialized');
+ }
+
+ /**
+ * Initialize with configuration array
+ * @param array $config
+ * @return Template
+ */
+ public function initialize($config = array())
+ {
+ foreach ($config as $key => $val)
+ $this->{'_' . $key} = $val;
+
+ if ($this->_widget_path == '')
+ $this->_widget_path = APPPATH . 'widgets/';
+
+ if ($this->_parser && !class_exists('CI_Parser'))
+ $this->_ci->load->library('parser');
+ }
+
+ /**
+ * Set a partial's content. This will create a new partial when not existing
+ * @param string $index
+ * @param mixed $value
+ */
+ public function __set($name, $value)
+ {
+ $this->partial($name)->set($value);
+ }
+
+ /**
+ * Access to partials for method chaining
+ * @param string $name
+ * @return mixed
+ */
+ public function __get($name)
+ {
+ return $this->partial($name);
+ }
+
+ /**
+ * Check if a partial exists
+ * @param string $index
+ * @return boolean
+ */
+ public function exists($index)
+ {
+ return array_key_exists($index, $this->_partials);
+ }
+
+ /**
+ * Set the template file
+ * @param string $template
+ */
+ public function set_template($template)
+ {
+ $this->_template = $template;
+ }
+
+ /**
+ * Publish the template with the current partials
+ * You can manually pass a template file with extra data, or use the default template from the config file
+ * @param string $template
+ * @param array $data
+ */
+ public function publish($template = FALSE, $data = array()) {
+ if (is_array($template) || is_object($template)) {
+ $data = $template;
+ } else if ($template) {
+ $this->_template = $template;
+ }
+
+ if (!$this->_template) {
+ show_error('There was no template file selected for the current template');
+ }
+
+ if (is_array($data) || is_object($data)) {
+ foreach ($data as $name => $content) {
+ $this->partial($name)->set($content);
+ }
+ }
+
+ unset($data);
+
+ if ($this->_parser) {
+ $this->_ci->parser->parse($this->_template, $this->_partials);
+ } else {
+ $this->_ci->load->view($this->_template, $this->_partials);
+ }
+ }
+
+ /**
+ * Create a partial object with an optional default content
+ * Can be usefull to use straight from the template file
+ * @param string $name
+ * @param string $default
+ * @return Partial
+ */
+ public function partial($name, $default = FALSE) {
+ if ($this->exists($name)) {
+ $partial = $this->_partials[$name];
+ } else {
+ // create new partial
+ $partial = new Partial($name);
+ if ($this->_cache_ttl) {
+ $partial->cache($this->_cache_ttl);
+ }
+
+ // detect local triggers
+ if (method_exists($this, 'trigger_' . $name)) {
+ $partial->bind($this, 'trigger_' . $name);
+ }
+
+ $this->_partials[$name] = $partial;
+ }
+
+ if (!$partial->content() && $default) {
+ $partial->set($default);
+ }
+
+ return $partial;
+ }
+
+ /**
+ * Create a widget object with optional parameters
+ * Can be usefull to use straight from the template file
+ * @param string $name
+ * @param array $data
+ * @return Widget
+ */
+ public function widget($name, $data = array()) {
+ $class = str_replace('.php', '', trim($name, '/'));
+
+ // determine path and widget class name
+ $path = $this->_widget_path;
+ if (($last_slash = strrpos($class, '/')) !== FALSE) {
+ $path += substr($class, 0, $last_slash);
+ $class = substr($class, $last_slash + 1);
+ }
+
+ // new widget
+ if(!class_exists($class)) {
+ // try both lowercase and capitalized versions
+ foreach (array(ucfirst($class), strtolower($class)) as $class) {
+ if (file_exists($path . $class . '.php')) {
+ include_once ($path . $class . '.php');
+
+ // found the file, stop looking
+ break;
+ }
+ }
+ }
+
+ if (!class_exists($class)) {
+ show_error("Widget '" . $class . "' was not found.");
+ }
+
+ return new $class($class, $data);
+ }
+
+ /**
+ * Enable cache for all partials with TTL, default TTL is 60
+ * @param int $ttl
+ * @param mixed $identifier
+ */
+ public function cache($ttl = 60, $identifier = '') {
+ foreach ($this->_partials as $partial) {
+ $partial->cache($ttl, $identifier);
+ }
+
+ $this->_cache_ttl = $ttl;
+ }
+
+ // ---- TRIGGERS -----------------------------------------------------------------
+
+ /**
+ * Stylesheet trigger
+ * @param string $source
+ */
+ public function trigger_stylesheet($url, $attributes = FALSE) {
+ // array support
+ if (is_array($url)) {
+ $return = '';
+ foreach ($url as $u) {
+ $return .= $this->trigger_stylesheet($u, $attributes);
+ }
+ return $return;
+ }
+
+ if (!stristr($url, 'http://') && !stristr($url, 'https://') && substr($url, 0, 2) != '//') {
+ $url = $this->_ci->config->item('base_url') . $url;
+ }
+
+ // legacy support for media
+ if (is_string($attributes)) {
+ $attributes = array('media' => $attributes);
+ }
+
+ if (is_array($attributes)) {
+ $attributeString = "";
+
+ foreach ($attributes as $key => $value) {
+ $attributeString .= $key . '="' . $value . '" ';
+ }
+
+ return '' . "\n\t";
+ } else {
+ return '' . "\n\t";
+ }
+ }
+
+ /**
+ * Javascript trigger
+ * @param string $source
+ */
+ public function trigger_javascript($url) {
+ // array support
+ if (is_array($url)) {
+ $return = '';
+ foreach ($url as $u) {
+ $return .= $this->trigger_javascript($u);
+ }
+ return $return;
+ }
+
+ if (!stristr($url, 'http://') && !stristr($url, 'https://') && substr($url, 0, 2) != '//') {
+ $url = $this->_ci->config->item('base_url') . $url;
+ }
+
+ return '' . "\n\t";
+ }
+
+ /**
+ * Meta trigger
+ * @param string $name
+ * @param mixed $value
+ * @param enum $type
+ */
+ public function trigger_meta($name, $value, $type = 'meta') {
+ $name = htmlspecialchars(strip_tags($name));
+ $value = htmlspecialchars(strip_tags($value));
+
+ if ($name == 'keywords' and !strpos($value, ',')) {
+ $content = preg_replace('/[\s]+/', ', ', trim($value));
+ }
+
+ switch ($type) {
+ case 'meta' :
+ $content = '' . "\n\t";
+ break;
+ case 'link' :
+ $content = '' . "\n\t";
+ break;
+ }
+
+ return $content;
+ }
+
+ /**
+ * Title trigger, keeps it clean
+ * @param string $name
+ * @param mixed $value
+ * @param enum $type
+ */
+ public function trigger_title($title) {
+ return htmlspecialchars(strip_tags($title));
+ }
+
+ /**
+ * Title trigger, keeps it clean
+ * @param string $name
+ * @param mixed $value
+ * @param enum $type
+ */
+ public function trigger_description($description) {
+ return htmlspecialchars(strip_tags($description));
+ }
+
+}
+
+class Partial
+{
+
+ protected $_ci, $_content, $_name, $_cache_ttl = 0, $_cached = false, $_identifier, $_trigger;
+ protected $_args = array();
+
+ /**
+ * Construct with optional parameters
+ * @param array $args
+ */
+ public function __construct($name, $args = array()) {
+ $this->_ci = &get_instance();
+ $this->_args = $args;
+ $this->_name = $name;
+ }
+
+ /**
+ * Gives access to codeigniter's functions from this class if needed
+ * This will be handy in extending classes
+ * @param string $index
+ */
+ function __get($name) {
+ return $this->_ci->$name;
+ }
+
+ /**
+ * Alias methods
+ */
+ function __call($name, $args) {
+ switch ($name) {
+ case 'default' :
+ return call_user_func_array(array($this, 'set_default'), $args);
+ break;
+ case 'add' :
+ return call_user_func_array(array($this, 'append'), $args);
+ break;
+ }
+ }
+
+ /**
+ * Returns the content when converted to a string
+ * @return string
+ */
+ public function __toString() {
+ return (string) $this->content();
+ }
+
+ /**
+ * Returns the content
+ * @return string
+ */
+ public function content() {
+ if ($this->_cache_ttl && !$this->_cached) {
+ $this->cache->save($this->cache_id(), $this->_content, $this->_cache_ttl);
+ }
+
+ return $this->_content;
+ }
+
+ /**
+ * Overwrite the content
+ * @param mixed $content
+ * @return Partial
+ */
+ public function set() {
+ if (!$this->_cached) {
+ $this->_content = (string) $this->trigger(func_get_args());
+ }
+
+ return $this;
+ }
+
+ /**
+ * Append something to the content
+ * @param mixed $content
+ * @return Partial
+ */
+ public function append() {
+ if (!$this->_cached) {
+ $this->_content .= (string) $this->trigger(func_get_args());
+ }
+
+ return $this;
+ }
+
+ /**
+ * Prepend something to the content
+ * @param mixed $content
+ * @return Partial
+ */
+ public function prepend() {
+ if (!$this->_cached) {
+ $this->_content = (string) $this->trigger(func_get_args()) . $this->_content;
+ }
+
+ return $this;
+ }
+
+ /**
+ * Set content if partial is empty
+ * @param mixed $default
+ * @return Partial
+ */
+ public function set_default($default) {
+ if (!$this->_cached) {
+ if (!$this->_content) {
+ $this->_content = $default;
+ }
+ }
+
+ return $this;
+ }
+
+ /**
+ * Load a view inside this partial, overwrite if wanted
+ * @param string $view
+ * @param array $data
+ * @param bool $overwrite
+ * @return Partial
+ */
+ public function view($view, $data = array(), $overwrite = false) {
+ if (!$this->_cached) {
+
+ // better object to array
+ if (is_object($data)) {
+ $array = array();
+ foreach ($data as $k => $v) {
+ $array[$k] = $v;
+ }
+ $data = $array;
+ }
+
+ $content = $this->_ci->load->view($view, $data, true);
+
+ if ($overwrite) {
+ $this->set($content);
+ } else {
+ $this->append($content);
+ }
+ }
+ return $this;
+ }
+
+ /**
+ * Parses a view inside this partial, overwrite if wanted
+ * @param string $view
+ * @param array $data
+ * @param bool $overwrite
+ * @return Partial
+ */
+ public function parse($view, $data = array(), $overwrite = false) {
+ if (!$this->_cached) {
+ if (!class_exists('CI_Parser')) {
+ $this->_ci->load->library('parser');
+ }
+
+ // better object to array
+ if (is_object($data)) {
+ $array = array();
+ foreach ($data as $k => $v) {
+ $array[$k] = $v;
+ }
+ $data = $array;
+ }
+
+ $content = $this->_ci->parser->parse($view, $data, true);
+
+ if ($overwrite) {
+ $this->set($content);
+ } else {
+ $this->append($content);
+ }
+ }
+
+ return $this;
+ }
+
+ /**
+ * Loads a widget inside this partial, overwrite if wanted
+ * @param string $name
+ * @param array $data
+ * @param bool $overwrite
+ * @return Partial
+ */
+ public function widget($name, $data = array(), $overwrite = false) {
+ if (!$this->_cached) {
+ $widget = $this->template->widget($name, $data);
+
+ if ($overwrite) {
+ $this->set($widget->content());
+ } else {
+ $this->append($widget->content());
+ }
+ }
+ return $this;
+ }
+
+ /**
+ * Enable cache with TTL, default TTL is 60
+ * @param int $ttl
+ * @param mixed $identifier
+ */
+ public function cache($ttl = 60, $identifier = '') {
+ if (!class_exists('CI_Cache')) {
+ $this->_ci->load->driver('cache', array('adapter' => 'file'));
+ }
+
+ $this->_cache_ttl = $ttl;
+ $this->_identifier = $identifier;
+
+ if ($cached = $this->_ci->cache->get($this->cache_id())) {
+ $this->_cached = true;
+ $this->_content = $cached;
+ }
+ return $this;
+ }
+
+ /**
+ * Used for cache identification
+ * @return string
+ */
+ private function cache_id() {
+ if ($this->_identifier) {
+ return $this->_name . '_' . $this->_identifier . '_' . md5(get_class($this) . implode('', $this->_args));
+ } else {
+ return $this->_name . '_' . md5(get_class($this) . implode('', $this->_args));
+ }
+ }
+
+ /**
+ * Trigger returns the result if a trigger is set
+ * @param array $args
+ * @return string
+ */
+ public function trigger($args) {
+ if (!$this->_trigger) {
+ return implode('', $args);
+ } else {
+ return call_user_func_array($this->_trigger, $args);
+ }
+ }
+
+ /**
+ * Bind a trigger function
+ * Can be used like bind($this, "function") or bind("function")
+ * @param mixed $arg
+ */
+ public function bind() {
+ if ($count = func_num_args()) {
+ if ($count >= 2) {
+ $args = func_get_args();
+ $obj = array_shift($args);
+ $func = array_pop($args);
+
+ foreach ($args as $trigger) {
+ $obj = $obj->$trigger;
+ }
+
+ $this->_trigger = array($obj, $func);
+ } else {
+ $args = func_get_args();
+ $this->_trigger = reset($args);
+ }
+ } else {
+ $this->_trigger = FALSE;
+ }
+ }
+}
+
+class Widget extends Partial
+{
+
+ /* (non-PHPdoc)
+ * @see Partial::content()
+ */
+ public function content() {
+ if (!$this->_cached) {
+ if (method_exists($this, 'display')) {
+ // capture output
+ ob_start();
+ $this->display($this->_args);
+ $buffer = ob_get_clean();
+
+ // if no content is produced but there was direct ouput we set
+ // that output as content
+ if (!$this->_content && $buffer) {
+ $this->set($buffer);
+ }
+ }
+ }
+
+ return parent::content();
+ }
+}
diff --git a/application/models/Nation_model.php b/application/models/Nation_model.php
new file mode 100644
index 000000000..cac2b2f8a
--- /dev/null
+++ b/application/models/Nation_model.php
@@ -0,0 +1,71 @@
+getAddonID(), 'nation'))
+ {
+ $result = $this->db->query($this->_getNationQuery($notLocked, $orderEnglish));
+ }
+
+ return $result;
+ }
+
+ /**
+ *
+ */
+ protected function _getNationQuery($notLocked = FALSE, $orderEnglish = FALSE)
+ {
+ $qry = "SELECT * FROM bis.tbl_nation";
+
+ if($notLocked)
+ {
+ $qry .= " WHERE sperre IS NULL";
+ }
+ if(!$orderEnglish)
+ {
+ $qry .= " ORDER BY kurztext";
+ }
+ else
+ {
+ $qry .= " ORDER BY engltext";
+ }
+
+ return $qry;
+ }
+
+ /**
+ *
+ */
+ public function getBundesland()
+ {
+ $result = NULL;
+
+ // Checks if the operation is permitted by the API caller
+ // All the code should be put inside this if statement
+ if(isAllowed($this->getAddonID(), 'nation'))
+ {
+ $result = $this->db->query($this->_bundeslandQuery);
+ }
+
+ return $result;
+ }
+}
\ No newline at end of file
diff --git a/application/models/core/Sprache_model.php b/application/models/core/Sprache_model.php
new file mode 100644
index 000000000..523bf1b87
--- /dev/null
+++ b/application/models/core/Sprache_model.php
@@ -0,0 +1,16 @@
+dbTable='public.tbl_sprache';
+ $this->pk='sprache';
+ }
+}
diff --git a/application/models/lehre/Studiengang_model.php b/application/models/lehre/Studiengang_model.php
new file mode 100644
index 000000000..3fcb6aa35
--- /dev/null
+++ b/application/models/lehre/Studiengang_model.php
@@ -0,0 +1,41 @@
+getAddonID(), 'course'))
+ {
+ $result = $this->db->query($allForBewerbungQuery);
+ }
+
+ return $result;
+ }
+}
\ No newline at end of file
diff --git a/application/models/lehre/Studienplan_model.php b/application/models/lehre/Studienplan_model.php
new file mode 100644
index 000000000..e003f84e4
--- /dev/null
+++ b/application/models/lehre/Studienplan_model.php
@@ -0,0 +1,32 @@
+getAddonID(), 'plan'))
+ {
+ $result = $this->db->query($studienplaeneQuery, array($studiengang_kz));
+ }
+
+ return $result;
+ }
+}
\ No newline at end of file
diff --git a/application/models/organisation/Organisationseinheit_model.php b/application/models/organisation/Organisationseinheit_model.php
new file mode 100644
index 000000000..2a90bf328
--- /dev/null
+++ b/application/models/organisation/Organisationseinheit_model.php
@@ -0,0 +1,16 @@
+dbTable='public.tbl_organisationseinheit';
+ $this->pk='oe_kurzbz';
+ }
+}
diff --git a/application/models/person/Person_model.php b/application/models/person/Person_model.php
index 1cfe356a9..73dab4b34 100644
--- a/application/models/person/Person_model.php
+++ b/application/models/person/Person_model.php
@@ -2,157 +2,828 @@
class Person_model extends DB_Model
{
- public function __construct($uid = null)
- {
- parent::__construct($uid);
- $this->dbTable = 'public.tbl_person';
- }
+ /**
+ *
+ */
+ public function __construct()
+ {
+ parent::__construct();
+ }
- public function getPerson($person_id = null)
- {
- if (is_null($person_id))
+ /**
+ *
+ */
+ public function getPerson($personId = NULL, $code = NULL, $email = NULL)
+ {
+ $result = NULL;
+
+ // Checks if the operation is permitted by the API caller
+ // All the code should be put inside this if statement
+ if(isAllowed($this->getAddonID(), 'person'))
{
- $query = $this->db->get_where('public.tbl_person', array());
- return $query->result_object();
+ if((isset($code)) && (isset($email)))
+ {
+ $result = $this->_getPersonByCodeAndEmail($code, $email);
+ }
+ elseif(isset($code))
+ {
+ $result = $this->_getPersonByCode($code);
+ }
+ else
+ {
+ $result = $this->_getPersonByID($personId);
+ }
}
- $query = $this->db->get_where('public.tbl_person', array('person_id' => $person_id));
- return $query->row_object();
- }
+
+ return $result;
+ }
+
+ /**
+ * @param int $personId Person ID
+ * @return object
+ */
+ private function _getPersonByID($personId = NULL)
+ {
+ $result = NULL;
+ $loadQuery = "SELECT person_id,
+ sprache,
+ anrede,
+ titelpost,
+ titelpre,
+ nachname,
+ vorname,
+ vornamen,
+ gebdatum,
+ gebort,
+ gebzeit,
+ foto,
+ anmerkung,
+ homepage,
+ svnr,
+ ersatzkennzeichen,
+ familienstand,
+ anzahlkinder,
+ aktiv,
+ insertamum,
+ insertvon,
+ updateamum,
+ updatevon,
+ ext_id,
+ geschlecht,
+ staatsbuergerschaft,
+ geburtsnation,
+ kurzbeschreibung,
+ zugangscode,
+ foto_sperre,
+ matr_nr
+ FROM public.tbl_person
+ WHERE person_id = ?";
+
+ if(isset($personId))
+ {
+ $result = $this->db->query($loadQuery, array($personId));
+ }
+
+ return $result;
+ }
- public function getPersonByCodeAndEmail($code, $email)
- {
-// if ($this->fhc_db_acl->bb->isBerechtigt('person', 'suid'))
-// {
- $this->db->select("*")
- ->from('public.tbl_person p')
- ->join("public.tbl_kontakt k", "k.person_id=p.person_id")
- ->where("p.zugangscode", $code)
- ->where("k.kontakt", $email);
-
- return $this->db->get()->result_object();
-// }
- }
+ /**
+ *
+ */
+ private function _getPersonByCodeAndEmail($code = NULL, $email = NULL)
+ {
+ $result = NULL;
+ $query = "SELECT *
+ FROM public.tbl_person p JOIN public.tbl_kontakt k USING (person_id)
+ WHERE p.zugangscode = ?
+ AND k.kontakt = ?";
+
+ if((isset($code)) && (isset($email)))
+ {
+ $result = $this->db->query($query, array($code, $email));
+ }
- public function getPersonByCode($code)
- {
-// if ($this->fhc_db_acl->bb->isBerechtigt('person', 'suid'))
-// {
- $query = $this->db->get_where('public.tbl_person', array('zugangscode' => $code));
- return $query->result_object();
-// }
- }
+ return $result;
+ }
- /**
- * Laedt Personendaten eine BenutzerUID
- * @param string $uid DB-Attr: tbl_benutzer.uid .
- * @return bool
- */
- public function getPersonFromBenutzerUID($uid)
- {
+ /**
+ *
+ */
+ private function _getPersonByCode($code = NULL)
+ {
+ $result = NULL;
+ $query = "SELECT *
+ FROM public.tbl_person p
+ WHERE p.zugangscode = ?";
+
+ if(isset($code))
+ {
+ $result = $this->db->query($query, array($code));
+ }
- if (!$this->fhc_db_acl->bb->isBerechtigt('person', 's'))
+ return $result;
+ }
+
+ /**
+ *
+ */
+ public function savePerson($person = NULL)
+ {
+ $result = FALSE;
+
+ // Checks if the operation is permitted by the API caller
+ // All the code should be put inside this if statement
+ if(isAllowed($this->getAddonID(), 'person'))
+ {
+ if($this->_validate($person))
+ {
+ if(isset($person['person_id']))
+ {
+ $result = $this->_updatePerson($person);
+ }
+ else
+ {
+ $result = $this->_insertPerson($person);
+ }
+ }
+ }
+
+ return $result;
+ }
+
+ /**
+ *
+ */
+ private function _insertPerson($person)
+ {
+ $this->db->trans_begin(); // Start DB transaction
+
+ $insertQuery = "INSERT INTO public.tbl_person (
+ sprache,
+ anrede,
+ titelpost,
+ titelpre,
+ nachname,
+ vorname,
+ vornamen,
+ gebdatum,
+ gebort,
+ gebzeit,
+ foto,
+ anmerkung,
+ homepage,
+ svnr,
+ ersatzkennzeichen,
+ familienstand,
+ anzahlkinder,
+ aktiv,
+ insertamum,
+ insertvon,
+ updateamum,
+ updatevon,
+ geschlecht,
+ geburtsnation,
+ staatsbuergerschaft,
+ kurzbeschreibung,
+ zugangscode,
+ foto_sperre,
+ matr_nr
+ ) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?,
+ ?, ?, ?, ?, ?, ?, ?, ?, ?, ?,
+ ?, ?, ?, ?, ?, ?, ?, ?, ?)";
+
+ $sqlParametersArray = array($person['sprache'],
+ $person['anrede'],
+ $person['titelpost'],
+ $person['titelpre'],
+ $person['nachname'],
+ $person['vorname'],
+ $person['vornamen'],
+ $person['gebdatum'],
+ $person['gebort'],
+ $person['gebzeit'],
+ $person['foto'],
+ $person['anmerkung'],
+ $person['homepage'],
+ $person['svnr'],
+ $person['ersatzkennzeichen'],
+ $person['familienstand'],
+ $person['anzahlkinder'],
+ $person['aktiv'],
+ "now()",
+ $person['insertvon'],
+ "now()",
+ $person['updatevon'],
+ $person['geschlecht'],
+ $person['geburtsnation'],
+ $person['staatsbuergerschaft'],
+ $person['kurzbeschreibung'],
+ $person['zugangscode'],
+ $person['foto_sperre'],
+ $person['matr_nr']);
+
+ $result = $this->db->query($insertQuery, $sqlParametersArray);
+
+ // Check DB transaction result
+ if($this->db->trans_status() === FALSE)
+ {
+ $this->db->trans_rollback();
+ $result = FALSE;
+ }
+ else
+ {
+ $this->db->trans_commit();
+ $result = TRUE;
+ }
+
+ return $result;
+ }
+
+ /**
+ *
+ */
+ private function _updatePerson($person)
+ {
+ $this->db->trans_begin(); // Start DB transaction
+
+ $updateQuery = "UPDATE public.tbl_person SET
+ sprache = ?,
+ anrede = ?,
+ titelpost = ?,
+ titelpre = ?,
+ nachname = ?,
+ vorname = ?,
+ vornamen = ?,
+ gebdatum = ?,
+ gebort = ?,
+ gebzeit = ?,
+ foto = ?,
+ anmerkung = ?,
+ homepage = ?,
+ svnr = ?,
+ ersatzkennzeichen = ?,
+ familienstand = ?,
+ anzahlkinder = ?,
+ aktiv = ?,
+ updateamum = ?,
+ updatevon = ?,
+ geschlecht = ?,
+ geburtsnation = ?,
+ staatsbuergerschaft = ?,
+ kurzbeschreibung = ?,
+ foto_sperre = ?,
+ zugangscode = ?,
+ matr_nr = ?
+ WHERE person_id = ?";
+
+ $sqlParametersArray = array($person['sprache'],
+ $person['anrede'],
+ $person['titelpost'],
+ $person['titelpre'],
+ $person['nachname'],
+ $person['vorname'],
+ $person['vornamen'],
+ $person['gebdatum'],
+ $person['gebort'],
+ $person['gebzeit'],
+ $person['foto'],
+ $person['anmerkung'],
+ $person['homepage'],
+ $person['svnr'],
+ $person['ersatzkennzeichen'],
+ $person['familienstand'],
+ $person['anzahlkinder'],
+ $person['aktiv'],
+ "now()",
+ $person['updatevon'],
+ $person['geschlecht'],
+ $person['geburtsnation'],
+ $person['staatsbuergerschaft'],
+ $person['kurzbeschreibung'],
+ $person['foto_sperre'],
+ $person['zugangscode'],
+ $person['matr_nr'],
+ $person['person_id']);
+
+ $result = $this->db->query($updateQuery, $sqlParametersArray);
+
+ // Check DB transaction result
+ if($this->db->trans_status() === FALSE)
+ {
+ $this->db->trans_rollback();
+ $result = FALSE;
+ }
+ else
+ {
+ $this->db->trans_commit();
+ $result = TRUE;
+ }
+
+ return $result;
+ }
+
+ /**
+ *
+ */
+ public function savePrestudent($interestedStudent = NULL)
+ {
+ // Checks if the operation is permitted by the API caller
+ // All the code should be put inside this if statement
+ if(isAllowed($this->getAddonID(), 'person'))
+ {
+ return $this->_savePrestudent($interestedStudent);
+ }
+ }
+
+ /**
+ * Method saveInterestedStudent
+ *
+ * @return bool true when everything goes right, otherwise false
+ */
+ private function _savePrestudent($interestedStudent = NULL)
+ {
+ if(!isset($interestedStudent))
+ {
+ return FALSE;
+ }
+
+ if($interestedStudent['zgvmas_code'] && $interestedStudent['zgvmanation'])
+ {
+ $interestedStudent['ausstellungsstaat'] = $interestedStudent['zgvmanation'];
+ }
+ elseif($interestedStudent['zgv_code'] && $interestedStudent['zgvnation'])
+ {
+ $interestedStudent['ausstellungsstaat'] = $interestedStudent['zgvnation'];
+ }
+
+ //Variablen auf Gueltigkeit pruefen
+ if(isset($interestedStudent['prestudent_id']) && $interestedStudent['punkte'] > 9999.9999)
+ {
+ //$this->errormsg = 'Reihungstestgesamtpunkte should be no bigger than 9999.9999';
+ return FALSE;
+ }
+ if($interestedStudent['rt_punkte1'] > 9999.9999)
+ {
+ //$this->errormsg = 'Reihungstestpunkte1 should be no bigger than 9999.9999';
+ return FALSE;
+ }
+ if($interestedStudent['rt_punkte2'] > 9999.9999)
+ {
+ //$this->errormsg = 'Reihungstestpunkte2 should be no bigger than 9999.9999';
+ return FALSE;
+ }
+ if($interestedStudent['rt_punkte3'] > 9999.9999)
+ {
+ //$this->errormsg = 'Reihungstestpunkte3 should be no bigger than 9999.9999';
+ return FALSE;
+ }
+
+ $this->db->trans_begin(); // Start DB transaction
+
+ // If prestudent_id is NOT set it's an insert
+ if(!isset($interestedStudent['prestudent_id']))
+ {
+ $insertQuery = "INSERT INTO public.tbl_prestudent (
+ aufmerksamdurch_kurzbz,
+ person_id,
+ studiengang_kz,
+ berufstaetigkeit_code,
+ ausbildungcode,
+ zgv_code,
+ zgvort,
+ zgvdatum,
+ zgvnation,
+ zgvmas_code,
+ zgvmaort,
+ zgvmadatum,
+ zgvmanation,
+ aufnahmeschluessel,
+ facheinschlberuf,
+ reihungstest_id,
+ anmeldungreihungstest,
+ reihungstestangetreten,
+ rt_gesamtpunkte,
+ rt_punkte1,
+ rt_punkte2,
+ rt_punkte3,
+ bismelden,
+ insertamum,
+ insertvon,
+ updateamum,
+ updatevon,
+ anmerkung,
+ dual,
+ ausstellungsstaat,
+ mentor
+ ) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?,
+ ?, ?, ?, ?, ?, ?, ?, ?, ?, ?,
+ ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
+
+ $sqlParametersArray = array($interestedStudent['aufmerksamdurch_kurzbz'],
+ $interestedStudent['person_id'],
+ $interestedStudent['studiengang_kz'],
+ $interestedStudent['berufstaetigkeit_code'],
+ $interestedStudent['ausbildungcode'],
+ $interestedStudent['zgv_code'],
+ $interestedStudent['zgvort'],
+ $interestedStudent['zgvdatum'],
+ $interestedStudent['zgvnation'],
+ $interestedStudent['zgvmas_code'],
+ $interestedStudent['zgvmaort'],
+ $interestedStudent['zgvmadatum'],
+ $interestedStudent['zgvmanation'],
+ $interestedStudent['aufnahmeschluessel'],
+ $interestedStudent['facheinschlberuf'],
+ $interestedStudent['reihungstest_id'],
+ $interestedStudent['anmeldungreihungstest'],
+ $interestedStudent['reihungstestangetreten'],
+ $interestedStudent['rt_gesamtpunkte'],
+ $interestedStudent['rt_punkte1'],
+ $interestedStudent['rt_punkte2'],
+ $interestedStudent['rt_punkte3'],
+ $interestedStudent['bismelden'],
+ $interestedStudent['insertamum'],
+ $interestedStudent['insertvon'],
+ $interestedStudent['updateamum'],
+ $interestedStudent['updatevon'],
+ $interestedStudent['anmerkung'],
+ $interestedStudent['dual'],
+ $interestedStudent['ausstellungsstaat'],
+ $interestedStudent['mentor']);
+
+ $result = $this->db->query($insertQuery, $sqlParametersArray);
+ }
+ // otherwise it's an update
+ else
+ {
+ $updateQuery = "UPDATE public.tbl_prestudent SET
+ aufmerksamdurch_kurzbz = ?,
+ person_id = ?,
+ studiengang_kz = ?,
+ berufstaetigkeit_code = ?,
+ ausbildungcode = ?,
+ zgv_code = ?,
+ zgvort = ?,
+ zgvdatum = ?,
+ zgvnation = ?,
+ zgvmas_code = ?,
+ zgvmaort = ?,
+ zgvmadatum = ?,
+ zgvmanation = ?,
+ aufnahmeschluessel = ?,
+ facheinschlberuf = ?,
+ reihungstest_id = ?,
+ anmeldungreihungstest = ?,
+ reihungstestangetreten = ?,
+ rt_gesamtpunkte = ?,
+ rt_punkte1 = ?,
+ rt_punkte2 = ?,
+ rt_punkte3 = ?,
+ bismelden = ?,
+ updateamum = ?,
+ updatevon = ?,
+ anmerkung = ?,
+ mentor = ?,
+ dual = ?,
+ ausstellungsstaat = ?
+ WHERE prestudent_id = ?";
+
+ $sqlParametersArray = array($interestedStudent['aufmerksamdurch_kurzbz'],
+ $interestedStudent['person_id'],
+ $interestedStudent['studiengang_kz'],
+ $interestedStudent['berufstaetigkeit_code'],
+ $interestedStudent['ausbildungcode'],
+ $interestedStudent['zgv_code'],
+ $interestedStudent['zgvort'],
+ $interestedStudent['zgvdatum'],
+ $interestedStudent['zgvnation'],
+ $interestedStudent['zgvmas_code'],
+ $interestedStudent['zgvmaort'],
+ $interestedStudent['zgvmadatum'],
+ $interestedStudent['zgvmanation'],
+ $interestedStudent['aufnahmeschluessel'],
+ $interestedStudent['facheinschlberuf'],
+ $interestedStudent['reihungstest_id'],
+ $interestedStudent['anmeldungreihungstest'],
+ $interestedStudent['reihungstestangetreten'],
+ $interestedStudent['punkte'],
+ $interestedStudent['rt_punkte1'],
+ $interestedStudent['rt_punkte2'],
+ $interestedStudent['rt_punkte3'],
+ $interestedStudent['bismelden'],
+ $interestedStudent['updateamum'],
+ $interestedStudent['updatevon'],
+ $interestedStudent['anmerkung'],
+ $interestedStudent['mentor'],
+ $interestedStudent['dual'],
+ $interestedStudent['ausstellungsstaat'],
+ $interestedStudent['prestudent_id']);
+
+ $result = $this->db->query($updateQuery, $sqlParametersArray);
+ }
+
+ // Check DB transaction result
+ if($this->db->trans_status() === FALSE)
+ {
+ $this->db->trans_rollback();
+ $result = FALSE;
+ }
+ else
+ {
+ $this->db->trans_commit();
+ $result = TRUE;
+ }
+
+ return $result;
+ }
+
+ private function _validate($person = NULL)
+ {
+ if(!isset($person))
+ {
+ return false;
+ }
+
+ $person['nachname'] = trim($person['nachname']);
+ $person['vorname'] = trim($person['vorname']);
+ $person['vornamen'] = trim($person['vornamen']);
+ $person['anrede'] = trim($person['anrede']);
+ $person['titelpost'] = trim($person['titelpost']);
+ $person['titelpre'] = trim($person['titelpre']);
+
+ if(mb_strlen($person['sprache']) > 16)
+ {
+ //$this->errormsg = 'Sprache darf nicht laenger als 16 Zeichen sein';
+ return false;
+ }
+ if(mb_strlen($person['anrede']) > 16)
+ {
+ //$this->errormsg = 'Anrede darf nicht laenger als 16 Zeichen sein';
+ return false;
+ }
+ if(mb_strlen($person['titelpost']) > 32)
+ {
+ //$this->errormsg = 'Titelpost darf nicht laenger als 32 Zeichen sein';
+ return false;
+ }
+ if(mb_strlen($person['titelpre']) > 64)
+ {
+ //$this->errormsg = 'Titelpre darf nicht laenger als 64 Zeichen sein';
+ return false;
+ }
+ if(mb_strlen($person['nachname']) > 64)
+ {
+ //$this->errormsg = 'Nachname darf nicht laenger als 64 Zeichen sein';
+ return false;
+ }
+ if($person['nachname'] == '' || is_null($person['nachname']))
+ {
+ //$this->errormsg = 'Nachname muss eingegeben werden';
+ return false;
+ }
+
+ if(mb_strlen($person['vorname']) > 32)
+ {
+ //$this->errormsg = 'Vorname darf nicht laenger als 32 Zeichen sein';
+ return false;
+ }
+ if(mb_strlen($person['vornamen']) > 128)
+ {
+ //$this->errormsg = 'Vornamen darf nicht laenger als 128 Zeichen sein';
+ return false;
+ }
+ //ToDo Gebdatum pruefen -> laut bis muss student aelter als 10 Jahre sein
+ /* if (strlen($person['gebdatum) == 0 || is_null($person['gebdatum))
+ {
+ //$this->errormsg = "Geburtsdatum muss eingegeben werden\n";
+ return false;
+ } */
+ if(mb_strlen($person['gebort']) > 128)
+ {
+ //$this->errormsg = 'Geburtsort darf nicht laenger als 128 Zeichen sein';
+ return false;
+ }
+
+ if(mb_strlen($person['homepage']) > 256)
+ {
+ //$this->errormsg = 'Homepage darf nicht laenger als 256 Zeichen sein';
+ return false;
+ }
+ if(mb_strlen($person['svnr']) > 16)
+ {
+ //$this->errormsg = 'SVNR darf nicht laenger als 16 Zeichen sein';
+ return false;
+ }
+
+ if(mb_strlen($person['matr_nr']) > 32)
+ {
+ //$this->errormsg = 'Matrikelnummer darf nicht laenger als 32 Zeichen sein';
+ return false;
+ }
+
+ if($person['svnr'] != '' && mb_strlen($person['svnr']) != 16 && mb_strlen($person['svnr']) != 10)
+ {
+ //$this->errormsg = 'SVNR muss 10 oder 16 Zeichen lang sein';
+ return false;
+ }
+
+ if($person['svnr'] != '' && mb_strlen($person['svnr']) == 10)
+ {
+ //SVNR mit Pruefziffer pruefen
+ //Die 4. Stelle in der SVNR ist die Pruefziffer
+ //(Summe von (gewichtung[i]*svnr[i])) modulo 11 ergibt diese Pruefziffer
+ //Falls nicht, ist die SVNR ungueltig
+ $gewichtung = array(3, 7, 9, 0, 5, 8, 4, 2, 1, 6);
+ $erg = 0;
+ //Quersumme bilden
+ for($i = 0; $i < 10; $i++)
+ {
+ $erg += $gewichtung[$i] * $person['svnr']{$i};
+ }
+
+ if($person['svnr']{3} != ($erg % 11)) //Vergleichen der Pruefziffer mit Quersumme Modulo 11
+ {
+ //$this->errormsg = 'SVNR ist ungueltig';
+ return false;
+ }
+ }
+
+ if($person['svnr'] != '')
+ {
+ //Pruefen ob bereits ein Eintrag mit dieser SVNR vorhanden ist
+ $qry = "SELECT person_id FROM public.tbl_person WHERE svnr=" . $person['svnr'];
+ if(db_query($qry))
+ {
+ if($row = db_fetch_object())
+ {
+ if($row->person_id != $person['person_id'])
+ {
+ //$this->errormsg = 'Es existiert bereits eine Person mit dieser SVNR! Daten wurden NICHT gepeichert.';
+ return false;
+ }
+ }
+ }
+ }
+
+ if(mb_strlen($person['ersatzkennzeichen']) > 10)
+ {
+ //$this->errormsg = 'Ersatzkennzeichen darf nicht laenger als 10 Zeichen sein';
+ return false;
+ }
+ if(mb_strlen($person['familienstand']) > 1)
+ {
+ //$this->errormsg = 'Familienstand ist ungueltig';
+ return false;
+ }
+ if($person['anzahlkinder'] != '' && !is_numeric($person['anzahlkinder']))
+ {
+ //$this->errormsg = 'Anzahl der Kinder ist ungueltig';
+ return false;
+ }
+ if($person['aktiv'] != "t" && $person['aktiv'] != "f")
+ {
+ //$this->errormsg = 'Aktiv ist ungueltig';
+ return false;
+ }
+ if(!isset($person['person_id']) && mb_strlen($person['insertvon']) > 32)
+ {
+ //$this->errormsg = 'Insertvon darf nicht laenger als 32 Zeichen sein';
+ return false;
+ }
+ if(mb_strlen($person['updatevon']) > 32)
+ {
+ //$this->errormsg = 'Updatevon darf nicht laenger als 32 Zeichen sein';
+ return false;
+ }
+ /*if($person['ext_id'] != '' && !is_numeric($person['ext_id']))
+ {
+ //$this->errormsg = 'Ext_ID ist keine gueltige Zahl';
+ return false;
+ }*/
+ if(mb_strlen($person['geschlecht']) > 1)
+ {
+ //$this->errormsg = 'Geschlecht darf nicht laenger als 1 Zeichen sein';
+ return false;
+ }
+ if(mb_strlen($person['geburtsnation']) > 3)
+ {
+ //$this->errormsg = 'Geburtsnation darf nicht laenger als 3 Zeichen sein';
+ return false;
+ }
+ if(mb_strlen($person['staatsbuergerschaft']) > 3)
+ {
+ //$this->errormsg = 'Staatsbuergerschaft darf nicht laenger als 3 Zeichen sein';
+ return false;
+ }
+ if($person['geschlecht'] != 'm' && $person['geschlecht'] != 'w' && $person['geschlecht'] != 'u')
+ {
+ //$this->errormsg = 'Geschlecht muss w, m oder u sein!';
+ return false;
+ }
+
+ //Pruefen ob das Geburtsdatum mit der SVNR uebereinstimmt.
+ if($person['svnr'] != '' && $person['gebdatum'] != '')
+ {
+ if(mb_ereg("([0-9]{1,2}).([0-9]{1,2}).([0-9]{4})", $person['gebdatum'], $regs))
+ {
+ //$day = sprintf('%02s',$regs[1]);
+ //$month = sprintf('%02s',$regs[2]);
+ //$year = mb_substr($regs[3],2,2);
+ }
+ elseif(mb_ereg("([0-9]{4})-([0-9]{2})-([0-9]{2})", $person['gebdatum'], $regs))
+ {
+ //$day = sprintf('%02s',$regs[3]);
+ //$month = sprintf('%02s',$regs[2]);
+ //$year = mb_substr($regs[1],2,2);
+ }
+ else
+ {
+ //$this->errormsg = 'Format des Geburtsdatums ist ungueltig';
+ return false;
+ }
+
+ /* das muss nicht immer so sein
+ $day_svnr = mb_substr($person['svnr, 4, 2);
+ $month_svnr = mb_substr($person['svnr, 6, 2);
+ $year_svnr = mb_substr($person['svnr, 8, 2);
+
+ if ($day_svnr!=$day || $month_svnr!=$month || $year_svnr!=$year)
+ {
+ //$this->errormsg = 'SVNR und Geburtsdatum passen nicht zusammen';
+ return false;
+ }
+ */
+ }
+
+ return true;
+ }
+
+ /**
+ * Laedt Personendaten eine BenutzerUID
+ * @param string $uid DB-Attr: tbl_benutzer.uid .
+ * @return bool
+ */
+ public function getPersonFromBenutzerUID($uid)
+ {
+
+ if(!$this->fhc_db_acl->bb->isBerechtigt('person', 's'))
{
$this->db->select('tbl_person.*');
$this->db->from('public.tbl_person JOIN public.tbl_benutzer USING (person_id)');
$query = $this->db->get_where(null, array('uid' => $uid));
return $query->result_object();
}
- }
-
- public function savePerson($person)
- {
- //TODO check berechtigung
-// if($this->fhc_db_acl->bb->isBerechtigt('person', 'sui'))
-// {
- $data = array(
- "vorname"=>$person["vorname"],
- "nachname"=>$person["nachname"],
- "gebdatum"=>$person["gebdatum"],
- "aktiv" => true,
- "zugangscode"=>$person["zugangscode"],
- "zugangscode_timestamp"=>date('Y-m-d H:i:s'),
- "insertamum"=>date('Y-m-d H:i:s'),
- "insertvon"=>$person["insertvon"],
- );
- if($this->db->insert("public.tbl_person", $data)){
- return $this->db->insert_id();
- }
- else
- {
- return false;
- }
-// }
-// else
-// {
-// return "Nicht berechtigt";
-// }
- }
-
- public function checkBewerbung($email, $studiensemester_kurzbz=NULL)
- {
+ }
+
+ /**
+ *
+ */
+ public function checkBewerbung($email, $studiensemester_kurzbz = NULL)
+ {
$this->db->distinct();
if(is_null($studiensemester_kurzbz))
{
$this->db->select("p.person_id, p.zugangscode, p.insertamum")
- ->from("public.tbl_person p")
- ->join("public.tbl_kontakt k", "p.person_id=k.person_id")
- ->join("public.tbl_benutzer b", "p.person_id=b.person_id", "left")
- ->where("k.kontakttyp", 'email')
- ->where("(kontakt='".$email."'".
- " OR alias ||'@technikum-wien.at'='".$email."'".
- " OR uid ||'@technikum-wien.at'='".$email."')")
- ->order_by("p.insertamum", "DESC")
- ->limit(1)
+ ->from("public.tbl_person p")
+ ->join("public.tbl_kontakt k", "p.person_id=k.person_id")
+ ->join("public.tbl_benutzer b", "p.person_id=b.person_id", "left")
+ ->where("k.kontakttyp", 'email')
+ ->where("(kontakt='" . $email . "'" .
+ " OR alias ||'@technikum-wien.at'='" . $email . "'" .
+ " OR uid ||'@technikum-wien.at'='" . $email . "')")
+ ->order_by("p.insertamum", "DESC")
+ ->limit(1)
;
}
else
{
$this->db->select("p.person_id,p.zugangscode,p.insertamum")
- ->from("public.tbl_person p")
- ->join("public.tbl_kontakt k", "p.person_id=k.person_id")
- ->join("public.tbl_benutzer b", "p.person_id=b.person_id", "left")
- ->join("public.tbl_prestudent ps", "p.person_id=ps.person_id")
- ->join("public.tbl_prestudentstatus pst", "pst.prestudent_id=ps.prestudent_id")
- ->where("k.kontakttyp", 'email')
- ->where("(kontakt='".$email."'".
- " OR alias ||'@technikum-wien.at'='".$email."'".
- " OR uid ||'@technikum-wien.at'='".$email."')")
- ->where("studiensemester_kurzbz='".$studiensemester_kurzbz."'")
- ->order_by("p.insertamum", "DESC")
- ->limit(1)
+ ->from("public.tbl_person p")
+ ->join("public.tbl_kontakt k", "p.person_id=k.person_id")
+ ->join("public.tbl_benutzer b", "p.person_id=b.person_id", "left")
+ ->join("public.tbl_prestudent ps", "p.person_id=ps.person_id")
+ ->join("public.tbl_prestudentstatus pst", "pst.prestudent_id=ps.prestudent_id")
+ ->where("k.kontakttyp", 'email')
+ ->where("(kontakt='" . $email . "'" .
+ " OR alias ||'@technikum-wien.at'='" . $email . "'" .
+ " OR uid ||'@technikum-wien.at'='" . $email . "')")
+ ->where("studiensemester_kurzbz='" . $studiensemester_kurzbz . "'")
+ ->order_by("p.insertamum", "DESC")
+ ->limit(1)
;
}
return $this->db->get()->result_array();
- }
+ }
- public function checkZugangscodePerson($code)
- {
+ /**
+ *
+ */
+ public function checkZugangscodePerson($code)
+ {
$this->db->select("p.person_id")
- ->from("public.tbl_person p")
- ->where("p.zugangscode", $code);
+ ->from("public.tbl_person p")
+ ->where("p.zugangscode", $code);
return $this->db->get()->result_array();
- }
-
- public function updatePerson($person)
- {
- //TODO check berechtigung
-// if($this->fhc_db_acl->bb->isBerechtigt('person', 'sui'))
-// {
- //TODO set other columns to be updated
- $this->db->set("zugangscode", $person["zugangscode"]);
- $this->db->where("person_id", $person["person_id"]);
- if($this->db->update("public.tbl_person")){
- return true;
- }
- else
- {
- return false;
- }
-// }
-// else
-// {
-// return "Nicht berechtigt";
-// }
- }
-}
+ }
+}
\ No newline at end of file
diff --git a/application/models/person/Prestudent_model.php b/application/models/person/Prestudent_model.php
new file mode 100644
index 000000000..ac4ff8d3b
--- /dev/null
+++ b/application/models/person/Prestudent_model.php
@@ -0,0 +1,30 @@
+dbTable='public.tbl_prestudent';
+ $this->pk='prestudent_id';
+ }
+
+ /**
+ *
+ */
+ public function loadPrestudentPerson($prestudentID)
+ {
+ $this->db->select('*')
+ ->from('public.tbl_prestudent')
+ ->join('public.tbl_person', 'person_id')
+ ->where('prestudent_id', $prestudentID);
+ return $this->db->get()->result_array();
+ }
+
+
+}
diff --git a/ci_db_extra.php b/ci_db_extra.php
new file mode 100755
index 000000000..23f512a41
--- /dev/null
+++ b/ci_db_extra.php
@@ -0,0 +1,119 @@
+db_result=$this->db->simple_query($sql))
+ return $this->db_result;
+ else
+ {
+ $this->errormsg.='Abfrage in Datenbank fehlgeschlagen! '.$this->db_last_error();
+ return false;
+ }
+ }
+
+ public function db_fetch_object($result = null, $i=null)
+ {
+ if(is_null($result))
+ {
+ if(is_null($i))
+ return pg_fetch_object($this->db_result);
+ else
+ return pg_fetch_object($this->db_result, $i);
+ }
+ else
+ {
+ if(is_null($i))
+ return pg_fetch_object($result);
+ else
+ return pg_fetch_object($result, $i);
+ }
+ }
+
+ public function db_add_param($var, $type=FHC_STRING, $nullable=true)
+ {
+ if($var==='' && $type!=FHC_BOOLEAN)
+ {
+ if($nullable)
+ return 'null';
+ else
+ return "''";
+ }
+
+ switch($type)
+ {
+ case FHC_INTEGER:
+ $var = $this->db_escape($var);
+ if(!is_numeric($var) && $var!=='')
+ die('Invalid Integer Parameter detected:'.$var);
+ $var = $this->db_null_value($var, false);
+ break;
+
+ case FHC_BOOLEAN:
+ if($var===true)
+ $var='true';
+ elseif($var===false)
+ $var='false';
+ elseif($var=='' && $nullable)
+ $var = 'null';
+ else
+ die('Invalid Boolean Parameter detected');
+ break;
+
+ case FHC_STRING:
+ default:
+ $var = $this->db_escape($var);
+ $var = $this->db_null_value($var);
+ break;
+ }
+ return $var;
+ }
+
+ public function db_escape($var)
+ {
+ return pg_escape_string($var);
+ }
+
+ public function db_null_value($var, $qoute=true)
+ {
+ if($qoute)
+ return ($var!==''?$this->db_qoute($var):'null');
+ else
+ return ($var!==''?$var:'null');
+ }
+
+ public function db_qoute($var)
+ {
+ return "'".$var."'";
+ }
+
+ public function db_parse_bool($var)
+ {
+ if($var=='t')
+ return true;
+ elseif($var=='f')
+ return false;
+ elseif($var=='')
+ return '';
+ else
+ die('Invalid DB Boolean. Wrong DB-Engine?');
+ }
+
+ /**
+ * Bereitet ein Array von Elementen auf, damit es in der IN-Klausel eines
+ * Select Befehls verwendet werden kann.
+ */
+ public function db_implode4SQL($array)
+ {
+ $string = '';
+ foreach($array as $row)
+ {
+ if($string!='')
+ $string.=',';
+ $string.=$this->db_add_param($row);
+ }
+ return $string;
+ }
+}
diff --git a/ci_hack.php b/ci_hack.php
index 26bdc39c3..8bafa5f7b 100755
--- a/ci_hack.php
+++ b/ci_hack.php
@@ -347,6 +347,11 @@ if (isset($assign_to_config) && is_array($assign_to_config))
*/
$LANG =& load_class('Lang', 'core');
+define('FHC_INTEGER',1);
+define('FHC_STRING',2);
+define('FHC_BOOLEAN',3);
+define('FHC_LANG_ARRAY',4);
+
function &get_instance()
{
return CI_Controller::get_instance();
@@ -364,105 +369,5 @@ require_once(dirname(__FILE__).'/application/core/FHC_Model.php');
$model=new CI_Model();
// Traits
-trait db_extra
-{
- protected $db_result=null;
+require_once(dirname(__FILE__).'db_extra.php');
- public function db_query($sql)
- {
- if ($this->db_result=$this->db->simple_query($sql))
- return $this->db_result;
- else
- {
- $this->errormsg.='Abfrage in Datenbank fehlgeschlagen! '.$this->db_last_error();
- return false;
- }
- }
-
- public function db_fetch_object($result = null, $i=null)
- {
- if(is_null($result))
- {
- if(is_null($i))
- return pg_fetch_object($this->db_result);
- else
- return pg_fetch_object($this->db_result, $i);
- }
- else
- {
- if(is_null($i))
- return pg_fetch_object($result);
- else
- return pg_fetch_object($result, $i);
- }
- }
-
- public function db_add_param($var, $type=FHC_STRING, $nullable=true)
- {
- if($var==='' && $type!=FHC_BOOLEAN)
- {
- if($nullable)
- return 'null';
- else
- return "''";
- }
-
- switch($type)
- {
- case FHC_INTEGER:
- $var = $this->db_escape($var);
- if(!is_numeric($var) && $var!=='')
- die('Invalid Integer Parameter detected:'.$var);
- $var = $this->db_null_value($var, false);
- break;
-
- case FHC_BOOLEAN:
- if($var===true)
- $var='true';
- elseif($var===false)
- $var='false';
- elseif($var=='' && $nullable)
- $var = 'null';
- else
- die('Invalid Boolean Parameter detected');
- break;
-
- case FHC_STRING:
- default:
- $var = $this->db_escape($var);
- $var = $this->db_null_value($var);
- break;
- }
- return $var;
- }
-
- public function db_escape($var)
- {
- return pg_escape_string($var);
- }
-
- public function db_null_value($var, $qoute=true)
- {
- if($qoute)
- return ($var!==''?$this->db_qoute($var):'null');
- else
- return ($var!==''?$var:'null');
- }
-
- public function db_qoute($var)
- {
- return "'".$var."'";
- }
-
- public function db_parse_bool($var)
- {
- if($var=='t')
- return true;
- elseif($var=='f')
- return false;
- elseif($var=='')
- return '';
- else
- die('Invalid DB Boolean. Wrong DB-Engine?');
- }
-}
diff --git a/cis/private/bildupload.php b/cis/private/bildupload.php
index d27309a1b..cfc14f07e 100644
--- a/cis/private/bildupload.php
+++ b/cis/private/bildupload.php
@@ -24,7 +24,7 @@
// Oberflaeche zum Upload von Bildern
-session_cache_limiter('none'); //muss gesetzt werden damit der upload in chrome und das automatische updaten des profilbildes funktioniert
+//session_cache_limiter('none'); //muss gesetzt werden damit der upload in chrome und das automatische updaten des profilbildes funktioniert
require_once('../../config/cis.config.inc.php');
require_once('../../include/functions.inc.php');
require_once('../../include/person.class.php');
diff --git a/cis/private/jahresplan/jahresplan_detail.php b/cis/private/jahresplan/jahresplan_detail.php
index df8d62bdd..17ca31e67 100644
--- a/cis/private/jahresplan/jahresplan_detail.php
+++ b/cis/private/jahresplan/jahresplan_detail.php
@@ -119,4 +119,4 @@
}
?>