diff --git a/application/controllers/system/Messages.php b/application/controllers/system/Messages.php index 390d75d33..2fa2619f1 100644 --- a/application/controllers/system/Messages.php +++ b/application/controllers/system/Messages.php @@ -4,6 +4,8 @@ if (! defined('BASEPATH')) exit('No direct script access allowed'); class Messages extends VileSci_Controller { + private $uid; // contains the UID of the logged user + /** * */ @@ -17,7 +19,12 @@ class Messages extends VileSci_Controller // Loads the widget library $this->load->library('WidgetLib'); + // Loads the person log library + $this->load->library('PersonLogLib'); + $this->load->model('person/Person_model', 'PersonModel'); + + $this->_setAuthUID(); // sets property uid } /** @@ -76,7 +83,7 @@ class Messages extends VileSci_Controller $data = array ( 'sender_id' => $sender_id, - 'receivers' => $msgVarsData->retval, + 'receivers' => isset($msgVarsData->retval) ? $msgVarsData->retval : $msgVarsData, 'message' => $msg, 'variables' => $variablesArray, 'oe_kurzbz' => $oe_kurzbz, // used to get the templates @@ -200,6 +207,21 @@ class Messages extends VileSci_Controller $error = true; break; } + + //write log entry + $this->personloglib->log( + $dataArray['person_id'], + 'Action', + array( + 'name' => 'Message sent', + 'message' => 'Message sent from person '.$sender_id.' to '.$dataArray['person_id'].', messageid '.$msg->retval, + 'success' => 'true' + ), + 'kommunikation', + 'core', + null, + $this->uid + ); } } @@ -233,6 +255,16 @@ class Messages extends VileSci_Controller return $person_id; } + /** + * Retrieve the UID of the logged user and checks if it is valid + */ + private function _setAuthUID() + { + $this->uid = getAuthUID(); + + if (!$this->uid) show_error('User authentification failed'); + } + /** * getVorlage */ diff --git a/application/models/person/Benutzer_model.php b/application/models/person/Benutzer_model.php index 339c7ea11..221688c21 100644 --- a/application/models/person/Benutzer_model.php +++ b/application/models/person/Benutzer_model.php @@ -11,4 +11,11 @@ class Benutzer_model extends DB_Model $this->dbTable = 'public.tbl_benutzer'; $this->pk = 'uid'; } + + public function getFromPersonId($person_id) + { + /*$this->addSelect('uid, aktiv, alias');*/ + $this->loadWhere(array('person_id' => $person_id)); + } + } diff --git a/system/dbupdate_3.3.php b/system/dbupdate_3.3.php index dbd40a3d2..56cd0b648 100644 --- a/system/dbupdate_3.3.php +++ b/system/dbupdate_3.3.php @@ -1151,6 +1151,8 @@ if (!$result = @$db->db_query("SELECT 1 FROM system.tbl_verarbeitungstaetigkeit" VALUES('lehrauftraege','Lehraufträge','{\'Lehraufträge\',\'Lehraufträge\'}', true); INSERT INTO system.tbl_verarbeitungstaetigkeit(taetigkeit_kurzbz, bezeichnung, bezeichnung_mehrsprachig, aktiv) VALUES('datenwartung','Datenwartung','{\'Datenwartung\',\'Datenwartung\'}', true); + INSERT INTO system.tbl_verarbeitungstaetigkeit(taetigkeit_kurzbz, bezeichnung, bezeichnung_mehrsprachig, aktiv) + VALUES('kommunikation','Kommunikation','{\'Kommunikation\',\'Kommunikation\'}', true); GRANT SELECT, UPDATE, INSERT, DELETE ON system.tbl_verarbeitungstaetigkeit TO vilesci; GRANT SELECT ON system.tbl_verarbeitungstaetigkeit TO web;