Error occurred while saving data, please contact the administrator.
";
- }
- }
-
- private function _getUsers($studiengang, $studiensemester, $gruppe, $reihungstest, $stufe)
- {
- // Load model prestudentm_model
- $this->load->model('crm/Prestudent_model', 'PrestudentModel');
-
- $this->PrestudentModel->addSelect(
- 'DISTINCT ON(p.person_id, prestudent_id) p.person_id,
- prestudent_id,
- p.nachname,
- p.vorname,
- p.geschlecht,
- p.gebdatum,
- k.kontakt AS email,
- sg.kurzbzlang,
- sg.bezeichnung,
- sg.orgform_kurzbz,
- sgt.bezeichnung AS typ,
- s.bezeichnung AS studienplan,
- ps.rt_stufe,
- aufnahmegruppe_kurzbz,
- rtp.punkte'
- );
-
- $this->PrestudentModel->addJoin('public.tbl_rt_person rtp', 'person_id');
- $this->PrestudentModel->addJoin('public.tbl_person p', 'person_id', 'LEFT');
- $this->PrestudentModel->addJoin(
- '(
- SELECT person_id,
- kontakt
- FROM public.tbl_kontakt
- WHERE zustellung = TRUE
- AND kontakttyp = \'email\'
- ORDER BY kontakt_id DESC
- ) k',
- 'person_id',
- 'LEFT'
- );
- $this->PrestudentModel->addJoin('public.tbl_prestudentstatus ps', 'prestudent_id');
- $this->PrestudentModel->addJoin('lehre.tbl_studienplan s', 's.studienplan_id = ps.studienplan_id');
- $this->PrestudentModel->addJoin('lehre.tbl_studienordnung so', 'studienordnung_id');
- $this->PrestudentModel->addJoin('public.tbl_studiengang sg', 'sg.studiengang_kz = so.studiengang_kz');
- $this->PrestudentModel->addJoin('public.tbl_studiengangstyp sgt', 'typ');
-
- $this->PrestudentModel->addOrder('p.person_id', 'ASC');
- $this->PrestudentModel->addOrder('prestudent_id', 'ASC');
-
- $parametersArray = array('p.aktiv' => true, 'ps.status_kurzbz' => 'Interessent');
-
- if ($studiengang != null && $studiengang != '-1')
- {
- $parametersArray['sg.studiengang_kz'] = $studiengang;
- }
-
- if ($studiensemester != null && $studiensemester != '-1')
- {
- $parametersArray['ps.studiensemester_kurzbz'] = $studiensemester;
- }
-
- if ($gruppe != null && $gruppe != '-1')
- {
- $parametersArray['aufnahmegruppe_kurzbz'] = $gruppe;
- }
-
- if ($reihungstest != null && $reihungstest != '-1')
- {
- $parametersArray['rtp.rt_id'] = $reihungstest;
- }
-
- if ($stufe != null && $stufe != '-1')
- {
- $parametersArray['ps.rt_stufe'] = $stufe;
- }
-
- return $this->PrestudentModel->loadWhere($parametersArray);
- }
-}
\ No newline at end of file
diff --git a/application/controllers/system/Templates.php b/application/controllers/system/Vorlage.php
similarity index 56%
rename from application/controllers/system/Templates.php
rename to application/controllers/system/Vorlage.php
index e33eed087..0cf821488 100755
--- a/application/controllers/system/Templates.php
+++ b/application/controllers/system/Vorlage.php
@@ -1,108 +1,122 @@
load->library('VorlageLib');
+
+ // Loads the widget library
+ $this->load->library('WidgetLib');
}
-
+
public function index()
{
- $this->load->view('system/templates.php');
+ $this->load->view('system/vorlage/templates.php');
}
-
+
public function table()
{
- $mimetype = $this->input->post('mimetype', TRUE);
+ $mimetype = $this->input->post('mimetype');
+
if (is_null($mimetype))
$mimetype = 'text/html';
if ($mimetype == '')
$mimetype = null;
+
$vorlage = $this->vorlagelib->getVorlageByMimetype($mimetype);
+
if ($vorlage->error)
show_error($vorlage->retval);
- //var_dump($vorlage);
- $data = array
- (
+ $data = array (
'mimetype' => $mimetype,
'vorlage' => $vorlage->retval
);
- $v = $this->load->view('system/templatesList.php', $data);
+
+ $v = $this->load->view('system/vorlage/templatesList.php', $data);
}
-
+
public function view($vorlage_kurzbz = null)
{
- if (empty($vorlage_kurzbz))
- exit;
+ if (empty($vorlage_kurzbz)) exit;
+
$vorlagentext = $this->vorlagelib->getVorlagetextByVorlage($vorlage_kurzbz);
+
if ($vorlagentext->error)
show_error($vorlagentext->retval);
- //var_dump($vorlagentext);
- $data = array
- (
+ $data = array (
'vorlage_kurzbz' => $vorlage_kurzbz,
'vorlagentext' => $vorlagentext->retval
);
- $v = $this->load->view('system/templatetextList.php', $data);
+
+ $v = $this->load->view('system/vorlage/templatetextList.php', $data);
}
-
+
public function edit($vorlage_kurzbz = null)
{
- if (empty($vorlage_kurzbz))
- exit;
+ if (empty($vorlage_kurzbz)) exit;
+
$vorlage = $this->vorlagelib->getVorlage($vorlage_kurzbz);
- //var_dump($vorlage);
+
if ($vorlage->error)
show_error($vorlage->retval);
+
if (count($vorlage->retval) != 1)
show_error('Nachricht nicht vorhanden! ID: '.$vorlage_kurzbz);
-
- $data = array
- (
+
+ $data = array (
'vorlage' => $vorlage->retval[0]
);
- //var_dump($data['message']);
- $v = $this->load->view('system/templatesEdit', $data);
+
+ $v = $this->load->view('system/vorlage/templatesEdit', $data);
}
public function write($vorlage_kurzbz = null)
{
- $data = array
- (
+ $data = array (
'subject' => 'TestSubject',
'body' => 'TestDevelopmentBodyText'
- );
- $v = $this->load->view('system/messageWrite', $data);
+ );
+
+ $v = $this->load->view('system/vorlage/messageWrite', $data);
}
public function save()
{
- $vorlage_kurzbz = $this->input->post('vorlage_kurzbz', TRUE);
- $data['bezeichnung'] = $this->input->post('bezeichnung', TRUE);
- $data['anmerkung'] = $this->input->post('anmerkung', TRUE);
- $data['mimetype'] = $this->input->post('mimetype', TRUE);
- $data['attribute'] = $this->input->post('attribute', TRUE);
+ $vorlage_kurzbz = $this->input->post('vorlage_kurzbz');
+
+ $data = array(
+ 'bezeichnung' => $this->input->post('bezeichnung'),
+ 'anmerkung' => $this->input->post('anmerkung'),
+ 'mimetype' => $this->input->post('mimetype'),
+ 'attribute' => $this->input->post('attribute')
+ );
+
$vorlage = $this->vorlagelib->saveVorlage($vorlage_kurzbz, $data);
+
if ($vorlage->error)
show_error($vorlage->retval);
+
$vorlage_kurzbz = $vorlage->retval;
-
- redirect('/system/Templates/edit/'.$vorlage_kurzbz);
+
+ redirect('/system/vorlage/edit/'.$vorlage_kurzbz);
}
-
+
public function newText()
{
- $vorlage_kurzbz = $this->input->post('vorlage_kurzbz', true);
+ $vorlage_kurzbz = $this->input->post('vorlage_kurzbz');
$this->load->model('organisation/Organisationseinheit_model', 'OrganisationseinheitModel');
$this->OrganisationseinheitModel->addLimit(1);
$this->OrganisationseinheitModel->addOrder('oe_kurzbz');
+
$resultOE = $this->OrganisationseinheitModel->loadWhere(array('aktiv' => true, 'oe_parent_kurzbz' => null));
if ($resultOE->error)
@@ -120,105 +134,127 @@ class Templates extends FHC_Controller
);
$vorlagetext = $this->vorlagelib->insertVorlagetext($data);
+
if ($vorlagetext->error)
show_error($vorlagetext->retval);
$vorlagestudiengang_id = $vorlagetext->retval;
- redirect('/system/Templates/editText/'.$vorlagestudiengang_id);
+ redirect('/system/vorlage/editText/'.$vorlagestudiengang_id);
}
else
{
show_error('No valid organisation unit found');
}
}
-
+
public function editText($vorlagestudiengang_id)
{
$vorlagetext = $this->vorlagelib->getVorlagetextById($vorlagestudiengang_id);
+
if ($vorlagetext->error)
show_error($vorlagetext->retval);
+
$data = $vorlagetext->retval[0];
-
+
// Preview-Data
$schema = $this->vorlagelib->getVorlage($data->vorlage_kurzbz);
+
$data->schema = $schema->retval[0]->attribute;
-
- $this->load->view('system/templatetextEdit', $data);
+
+ $this->load->view('system/vorlage/templatetextEdit', $data);
}
-
+
public function linkDocuments($vorlagestudiengang_id)
{
- $this->load->model('system/vorlagedokument_model');
- $return = $this->vorlagedokument_model->loadDokumenteFromVorlagestudiengang($vorlagestudiengang_id);
+ $data = array();
+
+ $this->load->model('system/Vorlagedokument_model', 'VorlagedokumentModel');
+
+ $return = $this->VorlagedokumentModel->loadDokumenteFromVorlagestudiengang($vorlagestudiengang_id);
+
$data['documents'] = $return->retval;
-
- $this->load->model('system/dokument_model');
- $this->dokument_model->addOrder("bezeichnung");
- $return = $this->dokument_model->load();
+
+ $this->load->model('system/Dokument_model', 'DokumentModel');
+ $this->DokumentModel->addOrder('bezeichnung');
+
+ $return = $this->DokumentModel->load();
+
$data['allDocuments'] = $return->retval;
-
$data['vorlagestudiengang_id'] = $vorlagestudiengang_id;
-
- $this->load->view('system/templateLinkDocuments', $data);
+
+ $this->load->view('system/vorlage/templateLinkDocuments', $data);
}
-
+
public function saveDocuments($vorlagestudiengang_id, $dokument_kurzbz, $sort)
{
- $this->load->model('system/vorlagedokument_model');
+ $insert = array();
+
$insert['vorlagestudiengang_id'] = $vorlagestudiengang_id;
$insert['dokument_kurzbz'] = $dokument_kurzbz;
- $insert['sort'] = $sort;
- $this->vorlagedokument_model->insert($insert);
+ $insert['sort'] = $sort;
+
+ $this->load->model('system/Vorlagedokument_model', 'VorlagedokumentModel');
+
+ $this->VorlagedokumentModel->insert($insert);
}
-
+
public function deleteDocumentLink($vorlagestudiengang_id)
{
- $this->load->model('system/vorlagedokument_model');
- $this->vorlagedokument_model->delete($vorlagestudiengang_id);
+ $this->load->model('system/Vorlagedokument_model', 'VorlagedokumentModel');
+
+ $this->VorlagedokumentModel->delete($vorlagestudiengang_id);
}
-
+
public function changeSort($vorlagestudiengang_id, $sort)
{
- $this->load->model('system/vorlagedokument_model');
- $this->vorlagedokument_model->update($vorlagestudiengang_id, array("sort"=>$sort));
+ $this->load->model('system/Vorlagedokument_model', 'VorlagedokumentModel');
+
+ $this->VorlagedokumentModel->update($vorlagestudiengang_id, array('sort' => $sort));
}
-
+
public function saveText()
{
- $vorlagestudiengang_id = $this->input->post('vorlagestudiengang_id', TRUE);
- $data['studiengang_kz'] = $this->input->post('studiengang_kz', TRUE);
- $data['version'] = $this->input->post('version', TRUE);
- $data['oe_kurzbz'] = $this->input->post('oe_kurzbz', TRUE);
+ $data = array(
+ 'studiengang_kz' => $this->input->post('studiengang_kz'),
+ 'version' => $this->input->post('version'),
+ 'oe_kurzbz' => $this->input->post('oe_kurzbz'),
+ 'aktiv' => $this->input->post('aktiv'),
+ 'text' => $this->input->post('text'),
+ 'vorlagestudiengang_id' => $this->input->post('vorlagestudiengang_id')
+ );
+
if ($this->input->post('sprache') == '')
$data['sprache'] = null;
else
- $data['sprache'] = $this->input->post('sprache', TRUE);
+ $data['sprache'] = $this->input->post('sprache');
+
if ($this->input->post('orgform_kurzbz') == '')
$data['orgform_kurzbz'] = null;
else
- $data['orgform_kurzbz'] = $this->input->post('orgform_kurzbz', TRUE);
- $data['text'] = $this->input->post('text', TRUE);
- $data['aktiv'] = $this->input->post('aktiv', TRUE);
- $vorlagetext = $this->vorlagelib->updateVorlagetext($vorlagestudiengang_id, $data);
+ $data['orgform_kurzbz'] = $this->input->post('orgform_kurzbz');
+
+ $vorlagetext = $this->vorlagelib->updateVorlagetext($data['vorlagestudiengang_id'], $data);
+
if ($vorlagetext->error)
show_error($vorlagetext->retval);
- $data['vorlagestudiengang_id'] = $vorlagestudiengang_id;
- redirect('/system/Templates/editText/'.$vorlagestudiengang_id);
- //$this->load->view('system/templatetextEdit', $data);
+
+ redirect('/system/vorlage/editText/'.$data['vorlagestudiengang_id']);
}
-
+
public function preview($vorlagestudiengang_id)
{
- $formdata = $this->input->post('formdata', FALSE);
- $daten = json_decode($formdata, TRUE);
+ $jsonDecodedForm = json_decode($this->input->post('formdata'), true);
+
$vorlagetext = $this->vorlagelib->getVorlagetextById($vorlagestudiengang_id);
+
if ($vorlagetext->error)
show_error($vorlagetext->retval);
- $data = array
- (
- 'text' => $this->vorlagelib->parseVorlagetext($vorlagetext->retval[0]->text, $daten)
+
+ $data = array(
+ 'text' => $this->vorlagelib->parseVorlagetext($vorlagetext->retval[0]->text, $jsonDecodedForm)
);
- $this->load->view('system/templatetextPreview', $data);
+
+ $this->load->view('system/vorlage/templatetextPreview', $data);
}
-}
+}
\ No newline at end of file
diff --git a/application/controllers/system/aufnahme/PrestudentMultiAssign.php b/application/controllers/system/aufnahme/PrestudentMultiAssign.php
new file mode 100644
index 000000000..b171f432e
--- /dev/null
+++ b/application/controllers/system/aufnahme/PrestudentMultiAssign.php
@@ -0,0 +1,157 @@
+load->helper('message');
+
+ // Loads the widget library
+ $this->load->library('WidgetLib');
+ }
+
+ public function index()
+ {
+ $studiengang = $this->input->post('studiengang');
+ $studiensemester = $this->input->post('studiensemester');
+ $aufnahmegruppe = $this->input->post('aufnahmegruppe');
+ $reihungstest = $this->input->post('reihungstest');
+ $stufe = $this->input->post('stufe');
+
+ $returnUsers = null;
+ if ($studiengang != null || $studiensemester != null || $aufnahmegruppe!= null
+ || $reihungstest != null || $stufe != null)
+ {
+ $returnUsers = $this->_getPrestudents($studiengang, $studiensemester, $aufnahmegruppe, $reihungstest, $stufe);
+ }
+
+ $users = null;
+ if (hasData($returnUsers))
+ {
+ $users = $returnUsers->retval;
+ }
+
+ if ($returnUsers == null || isSuccess($returnUsers))
+ {
+ $viewData = array(
+ 'studiengang' => $studiengang,
+ 'studiensemester' => $studiensemester,
+ 'aufnahmegruppe' => $aufnahmegruppe,
+ 'reihungstest' => $reihungstest,
+ 'stufe' => $stufe,
+ 'users' => $users
+ );
+
+ $this->load->view('system/aufnahme/prestudentMultiAssign', $viewData);
+ }
+ else if (isError($returnUsers))
+ {
+ show_error($returnUsers->retval);
+ }
+ }
+
+ /**
+ * To assign a stufe to one or more prestudents
+ */
+ public function linkToStufe()
+ {
+ $prestudentIdArray = $this->input->post('prestudent_id');
+ $stufe = $this->input->post('stufe');
+
+ // Load model PrestudentstatusModel
+ $this->load->model('crm/Prestudentstatus_model', 'PrestudentstatusModel');
+
+ $result = error("No valid parameters");
+ if (isset($stufe) && isset($prestudentIdArray) && is_array($prestudentIdArray) && count($prestudentIdArray) >0)
+ {
+ $result = $this->PrestudentstatusModel->updateStufe($prestudentIdArray, $stufe);
+ }
+
+ $this->output->set_header('Content-Type: application/json; charset=utf-8');
+
+ if (isSuccess($result))
+ {
+ echo '{"msg": "Data correctly saved"}';
+ }
+ else
+ {
+ echo '{"msg": "Error occurred while saving data, please contact the administrator"}';
+ }
+ }
+
+ /**
+ * To assign one or more prestudents to a gruppe
+ */
+ public function linkToAufnahmegruppe()
+ {
+ $prestudentIdArray = $this->input->post('prestudent_id');
+ $aufnahmegruppe = $this->input->post('aufnahmegruppe');
+
+ // Load model PrestudentstatusModel
+ $this->load->model('crm/Prestudent_model', 'PrestudentModel');
+
+ $result = error("No valid parameters");
+ if (isset($aufnahmegruppe) && isset($prestudentIdArray) && is_array($prestudentIdArray) && count($prestudentIdArray) >0)
+ {
+ $result = $this->PrestudentModel->updateAufnahmegruppe($prestudentIdArray, $aufnahmegruppe);
+ }
+
+ $this->output->set_header('Content-Type: application/json; charset=utf-8');
+
+ if (isSuccess($result))
+ {
+ echo '{"msg": "Data correctly saved"}';
+ }
+ else
+ {
+ echo '{"msg": "Error occurred while saving data, please contact the administrator"}';
+ }
+ }
+
+ /**
+ * Get the prestudents using search parameters
+ */
+ private function _getPrestudents($studiengang, $studiensemester, $aufnahmegruppe, $reihungstest, $stufe)
+ {
+ // Load model prestudentm_model
+ $this->load->model('crm/Prestudent_model', 'PrestudentModel');
+
+ if ($studiengang == '' || empty($studiengang))
+ {
+ $studiengang = null;
+ }
+
+ if ($studiensemester == '' || empty($studiensemester))
+ {
+ $studiensemester = null;
+ }
+
+ if ($aufnahmegruppe == '' || empty($aufnahmegruppe))
+ {
+ $aufnahmegruppe = null;
+ }
+
+ if ($reihungstest == '' || empty($reihungstest))
+ {
+ $reihungstest = null;
+ }
+
+ if ($stufe == '' || empty($stufe))
+ {
+ $stufe = null;
+ }
+
+ return $this->PrestudentModel->getPrestudentMultiAssign(
+ $studiengang,
+ $studiensemester,
+ $aufnahmegruppe,
+ $reihungstest,
+ $stufe
+ );
+ }
+}
\ No newline at end of file
diff --git a/application/core/APIv1_Controller.php b/application/core/APIv1_Controller.php
index 5c529a4b4..26fbeddac 100644
--- a/application/core/APIv1_Controller.php
+++ b/application/core/APIv1_Controller.php
@@ -9,6 +9,6 @@ class APIv1_Controller extends REST_Controller
parent::__construct();
// Loads return messages
- $this->load->helper('Message');
+ $this->load->helper('message');
}
}
\ No newline at end of file
diff --git a/application/core/DB_Model.php b/application/core/DB_Model.php
index f34d6fe1c..369d8bb46 100644
--- a/application/core/DB_Model.php
+++ b/application/core/DB_Model.php
@@ -8,6 +8,7 @@ class DB_Model extends FHC_Model
const PGSQL_BOOLEAN_TRUE = 't';
const PGSQL_BOOLEAN_FALSE = 'f';
const MODEL_POSTFIX = '_model';
+ const DEFAULT_SCHEMA = 'public';
protected $dbTable; // Name of the DB-Table for CI-Insert, -Update, ...
protected $pk; // Name of the PrimaryKey for DB-Update, Load, ...
@@ -226,6 +227,8 @@ class DB_Model extends FHC_Model
* - Adding support for composed primary key
* - Adding support for cascading side tables (useful?)
*
+ * NOTE: sub queries are not supported in the from clause
+ *
* @return array
*/
public function loadTree($mainTable, $sideTables, $where = null, $sideTablesAliases = null)
@@ -246,13 +249,26 @@ class DB_Model extends FHC_Model
$select = '';
for ($t = 0; $t < count($tables); $t++)
{
- $fields = $this->db->list_fields($tables[$t]); // list of the columns of the current table
+ // Get the schema if it is specified
+ $schemaAndTable = $this->getSchemaAndTable($tables[$t]);
+ // Discard the schema, not needed in the next steps
+ $tables[$t] = $schemaAndTable->table;
+
+ // List of the columns of the current table
+ // NOTE: $this->db->list_fields($tables[$t]) doesn't work if there are two tables with
+ // the same name in two different schemas, use this workaround
+ $fields = array();
+ if (isSuccess($lstColumns = $this->_list_columns($schemaAndTable->schema, $schemaAndTable->table)))
+ {
+ $fields = $lstColumns->retval;
+ }
+
for ($f = 0; $f < count($fields); $f++)
{
// To avoid overwriting of the properties within the object returned by CI
// will be given an alias to every column, that will be composed with the following schema
//
. AS _
- $select .= $tables[$t] . '.' . $fields[$f] . ' AS ' . $tables[$t] . '_' . $fields[$f];
+ $select .= $tables[$t] . '.' . $fields[$f]->column_name . ' AS ' . $tables[$t] . '_' . $fields[$f]->column_name;
if ($f < count($fields) - 1) $select .= ', ';
}
@@ -452,6 +468,26 @@ class DB_Model extends FHC_Model
return success(true);
}
+ /** ---------------------------------------------------------------
+ * Add one or more fields in the group by clause
+ *
+ * @return void
+ */
+ public function addGroupBy($fields)
+ {
+ if (!isset($fields)
+ || (!is_array($fields) && !is_string($fields))
+ || (is_array($fields) && count($fields) == 0)
+ || (is_string($fields) && $fields == ''))
+ {
+ return error(FHC_MODEL_ERROR, FHC_MODEL_ERROR);
+ }
+
+ $this->db->group_by($fields);
+
+ return success(true);
+ }
+
/** ---------------------------------------------------------------
* Reset the query builder state
*
@@ -640,6 +676,32 @@ class DB_Model extends FHC_Model
return $result;
}
+ /**
+ * Get schema and table name from the parameter
+ * If no schema are specified it will returns the parameter as table name,
+ * and the default schema as schema
+ * Ex:
+ * If the parameters is 'lehre.tbl_studienplan' it will returns the following object:
+ * obj
+ * |--->schema: lehre
+ * |--->table: tbl_studienplan
+ */
+ protected function getSchemaAndTable($schemaAndTable)
+ {
+ $result = new stdClass();
+ $result->schema = DB_Model::DEFAULT_SCHEMA;
+ $result->table = $schemaAndTable;
+
+ // If a schema is specified
+ if (($pos = strpos($schemaAndTable, '.')) !== false)
+ {
+ $result->schema = substr($schemaAndTable, 0, $pos);
+ $result->table = substr($schemaAndTable, $pos + 1);
+ }
+
+ return $result;
+ }
+
/**
* Checks if the caller is entitled to perform this operation with this right
*/
@@ -651,9 +713,13 @@ class DB_Model extends FHC_Model
substr(get_called_class(), -6) == DB_Model::MODEL_POSTFIX) ||
$permission != PermissionLib::SELECT_RIGHT)
{
+ // If true is not returned, then an error has occurred
if (($isEntitled = $this->isEntitled($this->dbTable, $permission, FHC_NORIGHT, FHC_MODEL_ERROR)) !== true)
{
- // TODO: resetQuery
+ // Before returning the object containing the error, reset the build query
+ // This is for preventing that other parts of the query will be built before of the next execution
+ $this->resetQuery();
+
return $isEntitled;
}
}
@@ -751,4 +817,19 @@ class DB_Model extends FHC_Model
return false;
}
+
+ /**
+ * Workaround of CI_DB_driver->_list_columns
+ * CI_DB_driver->list_fields($tableName), that calls CI_DB_postgre_driver->_list_columns,
+ * doesn't work if there are two tables with the same name in two different schemas
+ */
+ private function _list_columns($schema, $table)
+ {
+ $query = 'SELECT column_name
+ FROM information_schema.columns
+ WHERE LOWER(table_schema) = ?
+ AND LOWER(table_name) = ?';
+
+ return $this->execQuery($query, array(strtolower($schema), strtolower($table)));
+ }
}
\ No newline at end of file
diff --git a/application/core/FHC_Controller.php b/application/core/FHC_Controller.php
index 497f996a9..fcffd7a82 100644
--- a/application/core/FHC_Controller.php
+++ b/application/core/FHC_Controller.php
@@ -7,7 +7,7 @@ class FHC_Controller extends CI_Controller
public function __construct()
{
parent::__construct();
- $this->load->library('session');
+
$this->load->helper('fhcauth');
}
}
\ No newline at end of file
diff --git a/application/libraries/MailLib.php b/application/libraries/MailLib.php
old mode 100644
new mode 100755
index 53ecffad2..ee2fa9419
--- a/application/libraries/MailLib.php
+++ b/application/libraries/MailLib.php
@@ -8,13 +8,13 @@ if (! defined("BASEPATH")) exit("No direct script access allowed");
class MailLib
{
private $sended; // Sended email counter
-
+
// Properties for storing the configuration
private $email_number_to_sent;
private $email_number_per_time_range;
private $email_time_range;
private $email_from_system;
-
+
/**
* Class constructor
*/
@@ -22,26 +22,27 @@ class MailLib
{
// Set the counter to 0
$this->sended = 0;
-
+
// Get CI instance
$this->ci =& get_instance();
-
+
// The second parameter is used to avoiding name collisions in the config array
$this->ci->config->load("mail", true);
-
+
// CI Email library
$this->ci->load->library("email");
-
+
// Initializing email library with the loaded configurations
$this->ci->email->initialize($this->ci->config->config["mail"]);
-
+
// Set the configuration properties with the standard configuration values
$this->email_number_to_sent = $this->getEmailCfgItem("email_number_to_sent");
$this->email_number_per_time_range = $this->getEmailCfgItem("email_number_per_time_range");
$this->email_time_range = $this->getEmailCfgItem("email_time_range");
$this->email_from_system = $this->getEmailCfgItem("email_from_system");
+ $this->alias_from_system = $this->getEmailCfgItem("alias_from_system");
}
-
+
/**
* Sends a single email
*/
@@ -51,10 +52,15 @@ class MailLib
if (is_null($from) || $from == "")
{
$from = $this->email_from_system;
+ // If alias is not specified then use the standard one
+ if (is_null($alias) || $alias == "")
+ {
+ $alias = $this->alias_from_system;
+ }
}
-
+
$this->ci->email->from($from, $alias);
-
+
// Check if the email address of the debug recipient is a valid one
$recipient = $to;
$recipientCC = $cc;
@@ -66,17 +72,17 @@ class MailLib
$recipientCC = MAIL_DEBUG;
$recipientBCC = MAIL_DEBUG;
}
-
+
$this->ci->email->to($recipient);
if (!is_null($recipientCC)) $this->ci->email->cc($recipientCC);
if (!is_null($recipientBCC)) $this->ci->email->bcc($recipientBCC);
$this->ci->email->subject($subject);
$this->ci->email->message($message);
if (!empty($altMessage)) $this->ci->email->set_alt_message($altMessage);
-
+
// Avoid printing on standard output ugly error messages
$result = @$this->ci->email->send();
-
+
// If the email was succesfully sended then increment the counter
// and checks if it has to wait until the sending of the next
if ($result)
@@ -84,10 +90,10 @@ class MailLib
$this->sended++;
$this->wait();
}
-
+
return $result;
}
-
+
/**
* To ovveride the configurations
*/
@@ -113,7 +119,7 @@ class MailLib
}
}
}
-
+
/**
* Returns the current configuration
*/
@@ -124,25 +130,25 @@ class MailLib
$cfg->email_number_per_time_range = $this->email_number_per_time_range;
$cfg->email_time_range = $this->email_time_range;
$cfg->email_from_system = $this->email_from_system;
-
+
return $cfg;
}
-
+
/**
* Validates an email address
*/
public function validateEmailAddress($emailAddress)
{
$valid = false;
-
+
if (!empty($emailAddress))
{
$valid = filter_var($emailAddress, FILTER_VALIDATE_EMAIL);
}
-
+
return $valid;
}
-
+
/**
* Checks if it has to wait until the sending of the next
*/
@@ -153,7 +159,7 @@ class MailLib
sleep($this->email_time_range); // Wait!!!
}
}
-
+
/**
* Gets an item from the email configuration array
*/
@@ -161,4 +167,4 @@ class MailLib
{
return $this->ci->config->item($itemName, EMAIL_CONFIG_INDEX);
}
-}
\ No newline at end of file
+}
diff --git a/application/libraries/MessageLib.php b/application/libraries/MessageLib.php
old mode 100644
new mode 100755
index fa302abc1..88c18e8ab
--- a/application/libraries/MessageLib.php
+++ b/application/libraries/MessageLib.php
@@ -8,15 +8,15 @@ if (! defined('BASEPATH')) exit('No direct script access allowed');
class MessageLib
{
const MSG_INDX_PREFIX = 'message_';
-
+
public function __construct()
{
// Get code igniter instance
$this->ci =& get_instance();
-
+
// Loads message configuration
$this->ci->config->load('message');
-
+
// CI Parser library
$this->ci->load->library('parser');
// Loads LogLib
@@ -25,22 +25,22 @@ class MessageLib
$this->ci->load->library('VorlageLib');
// Loads Mail library
$this->ci->load->library('MailLib');
-
+
// Loading models
$this->ci->load->model('system/Message_model', 'MessageModel');
$this->ci->load->model('system/MsgStatus_model', 'MsgStatusModel');
$this->ci->load->model('system/Recipient_model', 'RecipientModel');
$this->ci->load->model('system/Attachment_model', 'AttachmentModel');
-
+
// Loads fhc helper
$this->ci->load->helper('fhc');
// Loads helper message to manage returning messages
$this->ci->load->helper('message');
-
+
// Loads phrases
$this->ci->lang->load('message');
}
-
+
/**
* getMessage() - returns the spicified received message for a specified person
*
@@ -54,12 +54,12 @@ class MessageLib
return $this->_error('', MSG_ERR_INVALID_MSG_ID);
if (empty($person_id))
return $this->_error('', MSG_ERR_INVALID_RECIPIENTS);
-
+
$msg = $this->ci->RecipientModel->getMessage($msg_id, $person_id);
-
+
return $msg;
}
-
+
/**
* getMessagesByUID() - will return all messages, including the latest status for specified user. It don´t returns Attachments.
*
@@ -70,12 +70,12 @@ class MessageLib
{
if (empty($uid))
return $this->_error('', MSG_ERR_INVALID_MSG_ID);
-
+
$msg = $this->ci->RecipientModel->getMessagesByUID($uid, $all);
return $msg;
}
-
+
/**
* getMessagesByPerson() - will return all messages, including the latest status for specified user. It don´t returns Attachments.
*
@@ -86,12 +86,12 @@ class MessageLib
{
if (empty($person_id))
return $this->_error('', MSG_ERR_INVALID_MSG_ID);
-
+
$msg = $this->ci->RecipientModel->getMessagesByPerson($person_id, $all);
-
+
return $msg;
}
-
+
/**
* getSentMessagesByPerson() - Get all sent messages from a person identified by person_id
*
@@ -102,12 +102,12 @@ class MessageLib
{
if (empty($person_id))
return $this->_error('', MSG_ERR_INVALID_MSG_ID);
-
+
$msg = $this->ci->MessageModel->getMessagesByPerson($person_id, $all);
-
+
return $msg;
}
-
+
/**
* getMessageByToken
*
@@ -118,7 +118,7 @@ class MessageLib
{
if (empty($token))
return $this->_error('', MSG_ERR_INVALID_TOKEN);
-
+
$result = $this->ci->RecipientModel->getMessageByToken($token);
if (hasData($result))
{
@@ -132,7 +132,7 @@ class MessageLib
break;
}
}
-
+
// If not found then insert the read status
if ($found == -1)
{
@@ -141,7 +141,7 @@ class MessageLib
'person_id' => $result->retval[0]->receiver_id,
'status' => MSG_STATUS_READ
);
-
+
$resultIns = $this->ci->MsgStatusModel->insert($statusKey);
// If an error occured while writing on data base, then return it
if (isError($resultIns))
@@ -150,10 +150,10 @@ class MessageLib
}
}
}
-
+
return $result;
}
-
+
/**
* getCountUnreadMessages
*
@@ -164,12 +164,12 @@ class MessageLib
{
if (!is_numeric($person_id))
return $this->_error('', MSG_ERR_INVALID_RECIPIENTS);
-
+
$msg = $this->ci->RecipientModel->getCountUnreadMessages($person_id);
-
+
return $msg;
}
-
+
/**
* updateMessageStatus() - will change status on message for particular user
*
@@ -184,18 +184,18 @@ class MessageLib
{
return $this->_error('', MSG_ERR_INVALID_MSG_ID);
}
-
+
if (empty($person_id))
{
return $this->_error('', MSG_ERR_INVALID_USER_ID);
}
-
+
// Not use empty otherwise if status is 0 it returns an error
if (!isset($status))
{
return $this->_error('', MSG_ERR_INVALID_STATUS_ID);
}
-
+
// Searches if the status is already present
$result = $this->ci->MsgStatusModel->load(array($message_id, $person_id, $status));
if (hasData($result))
@@ -210,13 +210,13 @@ class MessageLib
'person_id' => $person_id,
'status' => $status
);
-
+
$result = $this->ci->MsgStatusModel->insert($statusKey);
}
-
+
return $result;
}
-
+
/**
* sendMessage() - sends new internal message. This function will create a new thread
*
@@ -227,9 +227,9 @@ class MessageLib
{
$sender_id = $this->ci->config->item('system_person_id');
}
-
+
$receivers = $this->_getReceivers($receiver_id, $oe_kurzbz);
-
+
// If everything went ok
if (isSuccess($receivers) && is_array($receivers->retval))
{
@@ -238,12 +238,12 @@ class MessageLib
{
$result = $this->_error($receivers->retval, MSG_ERR_OU_CONTACTS_NOT_FOUND);
}
-
+
// Looping on receivers
for ($i = 0; $i < count($receivers->retval); $i++)
{
$receiver_id = $receivers->retval[$i]->person_id;
-
+
// Checks if the receiver exists
if ($this->_checkReceiverId($receiver_id))
{
@@ -289,10 +289,10 @@ class MessageLib
{
$result = $receivers;
}
-
+
return $result;
}
-
+
/**
* sendMessageVorlage() - sends new internal message using a template
*
@@ -309,9 +309,9 @@ class MessageLib
{
$sender_id = $this->ci->config->item('system_person_id');
}
-
+
$receivers = $this->_getReceivers($receiver_id, $oe_kurzbz);
-
+
// If everything went ok
if (isSuccess($receivers) && is_array($receivers->retval))
{
@@ -325,12 +325,12 @@ class MessageLib
// Load reveiver data to get its relative language
$this->ci->load->model('person/Person_model', 'PersonModel');
}
-
+
// Looping on receivers
for ($i = 0; $i < count($receivers->retval); $i++)
{
$receiver_id = $receivers->retval[$i]->person_id;
-
+
$result = $this->ci->PersonModel->load($receiver_id);
if (hasData($result))
{
@@ -341,7 +341,7 @@ class MessageLib
{
$sprache = $result->retval[0]->sprache;
}
-
+
// Loads template data
$result = $this->ci->vorlagelib->loadVorlagetext($vorlage_kurzbz, $oe_kurzbz, $orgform_kurzbz, $sprache);
if (isSuccess($result))
@@ -353,7 +353,7 @@ class MessageLib
// Parses template text
$parsedText = $this->ci->vorlagelib->parseVorlagetext($result->retval[0]->text, $data);
$subject = $result->retval[0]->subject;
-
+
// Save message
$result = $this->_saveMessage($sender_id, $receiver_id, $subject, $parsedText, $relationmessage_id, $oe_kurzbz);
// If no errors were occurred
@@ -413,27 +413,27 @@ class MessageLib
{
$result = $receivers;
}
-
+
return $result;
}
-
+
/**
* Gets all the messages from DB and sends them via email
*/
public function sendAll($numberToSent = null, $numberPerTimeRange = null, $email_time_range = null, $email_from_system = null)
{
$sent = true; // optimistic expectation
-
+
// Gets standard configs
$cfg = $this->ci->maillib->getConfigs();
$cfg->email_number_to_sent = $numberToSent;
$cfg->email_number_per_time_range = $numberPerTimeRange;
$cfg->email_time_range = $email_time_range;
$cfg->email_from_system = $email_from_system;
-
+
// Overrides configs with the parameters
$this->ci->maillib->overrideConfigs($cfg);
-
+
// Gets a number ($this->ci->maillib->getMaxEmailToSent()) of unsent messages from DB
// having EMAIL_KONTAKT_TYPE as relative contact type
$result = $this->ci->RecipientModel->getMessages(
@@ -468,7 +468,7 @@ class MessageLib
{
$this->ci->loglib->logError('Error while parsing the mail template');
}
-
+
// Using a template for the plain text email body
$altBody = $this->ci->parser->parse(
'templates/mailTXT',
@@ -483,9 +483,9 @@ class MessageLib
{
$this->ci->loglib->logError('Error while parsing the mail template');
}
-
- // If the sender kontakt does not exist, then use system
- $sender = $this->ci->maillib->getConfigs()->email_from_system;
+
+ // If the sender kontakt does not exist, then system-sender is used if empty
+ $sender = '';
if (!is_null($result->retval[0]->sender) && $result->retval[0]->sender != '')
{
$sender = $result->retval[0]->sender;
@@ -505,7 +505,7 @@ class MessageLib
if (!$sent)
{
$this->ci->loglib->logError('Error while sending an email');
- // Writing errors in tbl_message_status
+ // Writing errors in tbl_message_recipient
$sme = $this->setMessageError(
$result->retval[$i]->message_id,
$result->retval[$i]->receiver_id,
@@ -531,7 +531,7 @@ class MessageLib
else
{
$this->ci->loglib->logError('This person does not have an email account');
- // Writing errors in tbl_message_status
+ // Writing errors in tbl_message_recipient
$sme = $this->setMessageError(
$result->retval[$i]->message_id,
$result->retval[$i]->receiver_id,
@@ -557,17 +557,17 @@ class MessageLib
$this->ci->loglib->logError('Something went wrong while getting data from DB');
$sent = false;
}
-
+
return $sent;
}
-
+
/**
* Gets one message from DB and sends it via email
*/
public function sendOne($message_id, $subject = null, $body = null, $multiPartMime = true)
{
$sent = true; // optimistic expectation
-
+
// Get a specific message from DB having EMAIL_KONTAKT_TYPE as relative contact type
$result = $this->ci->RecipientModel->getMessages(
EMAIL_KONTAKT_TYPE,
@@ -603,7 +603,7 @@ class MessageLib
// $body = $result->retval[0]->body;
$this->ci->loglib->logError('Error while parsing the html mail template');
}
-
+
// Using a template for the plain text email body
$altBody = $this->ci->parser->parse(
'templates/mailTXT',
@@ -623,14 +623,14 @@ class MessageLib
{
$bodyMsg = $altBody = $body;
}
-
- // If the sender kontakt does not exist, then use system
- $sender = $this->ci->maillib->getConfigs()->email_from_system;
+
+ // If the sender kontakt does not exist, then system-sender is used if empty
+ $sender = '';
if (!is_null($result->retval[0]->sender) && $result->retval[0]->sender != '')
{
$sender = $result->retval[0]->sender;
}
-
+
// Sending email
$sent = $this->ci->maillib->send(
$sender,
@@ -697,21 +697,21 @@ class MessageLib
$this->ci->loglib->logError('Something went wrong while getting data from DB');
$sent = false;
}
-
+
return $sent;
}
-
+
// ------------------------------------------------------------------------
// Private Functions from here out!
// ------------------------------------------------------------------------
-
+
/**
* Update the table tbl_message_recipient
*/
private function _updateMessageRecipient($message_id, $receiver_id, $parameters)
{
$updated = false;
-
+
// Changes the status of the message from unread to read
$resultUpdate = $this->ci->RecipientModel->update(array($receiver_id, $message_id), $parameters);
// Checks if errors were occurred
@@ -719,20 +719,20 @@ class MessageLib
{
$updated = true;
}
-
+
return $updated;
}
-
+
/**
* Changes the status of the message from unsent to sent
*/
private function setMessageSent($message_id, $receiver_id)
{
$parameters = array('sent' => 'NOW()', 'sentinfo' => null);
-
+
return $this->_updateMessageRecipient($message_id, $receiver_id, $parameters);
}
-
+
/**
* Sets the sentInfo with the error
*/
@@ -742,12 +742,12 @@ class MessageLib
{
$sentInfo = $prevSentInfo . SENT_INFO_NEWLINE . $sentInfo;
}
-
+
$parameters = array('sent' => null, 'sentinfo' => $sentInfo);
-
+
return $this->_updateMessageRecipient($message_id, $receiver_id, $parameters);
}
-
+
/**
* Gets the receivers id that are enabled to read messages for that oe_kurzbz
*/
@@ -763,17 +763,17 @@ class MessageLib
' AND funktion_kurzbz = \'' . $this->ci->config->item('assistent_function') . '\'' .
' AND (NOW() BETWEEN COALESCE(datum_von, NOW()) AND COALESCE(datum_bis, NOW()))'
);
-
+
return $receivers;
}
-
+
/**
* Gets the receivers id
*/
private function _getReceivers($receiver_id, $oe_kurzbz = null)
{
$receivers = null;
-
+
// If no receiver_id is given...
if (is_null($receiver_id))
{
@@ -793,10 +793,10 @@ class MessageLib
$receivers = $this->_success(array(new stdClass()));
$receivers->retval[0]->person_id = $receiver_id;
}
-
+
return $receivers;
}
-
+
/**
* Checks if the given receiver id is a valid person
*/
@@ -809,10 +809,10 @@ class MessageLib
{
return true;
}
-
+
return false;
}
-
+
/**
* Save a message in DB
**/
@@ -820,7 +820,7 @@ class MessageLib
{
// Starts db transaction
$this->ci->db->trans_start(false);
-
+
// Save Message
$msgData = array(
'person_id' => $sender_id,
@@ -852,9 +852,9 @@ class MessageLib
$result = $this->ci->MsgStatusModel->insert($statusData);
}
}
-
+
$this->ci->db->trans_complete();
-
+
if ($this->ci->db->trans_status() === false || isError($result))
{
$this->ci->db->trans_rollback();
@@ -865,10 +865,10 @@ class MessageLib
$this->ci->db->trans_commit();
$result = $this->_success($msg_id);
}
-
+
return $result;
}
-
+
/**
* Wrapper for function error
*/
@@ -876,7 +876,7 @@ class MessageLib
{
return error($retval, $code, MessageLib::MSG_INDX_PREFIX);
}
-
+
/**
* Wrapper for function success
*/
@@ -884,12 +884,12 @@ class MessageLib
{
return success($retval, $code, MessageLib::MSG_INDX_PREFIX);
}
-
+
/**
- *
+ *
*/
public function parseMessageText($text, $data = array())
{
return $this->ci->parser->parse_string($text, $data, true);
}
-}
\ No newline at end of file
+}
diff --git a/application/libraries/PhrasesLib.php b/application/libraries/PhrasesLib.php
index b7b004fbc..0ae5c72c0 100644
--- a/application/libraries/PhrasesLib.php
+++ b/application/libraries/PhrasesLib.php
@@ -126,12 +126,24 @@ class PhrasesLib
for ($i = 0; $i < count($result->retval); $i++)
{
// If no
tags required
- if ($blockTags == "no")
+ if ($blockTags == 'no')
{
- // Removes tags
and
from the beginning and from the end of the string
- $tmpText = $parser->textileThis($result->retval[$i]->text);
- $tmpText = substr($tmpText, 3, strlen($tmpText));
- $tmpText = substr($tmpText, 0, strlen($tmpText) - 4);
+ $tmpText = $parser->textileThis($result->retval[$i]->text); // Parse
+
+ // Removes tags
and
from the beginning and from the end of the string if they are present
+ // NOTE: Those tags are usually, but not always, added by the textile parser
+ if (strlen($tmpText) >= 7)
+ {
+ if (substr($tmpText, 0, 3) == '
')
+ {
+ $tmpText = substr($tmpText, 0, strlen($tmpText) - 4);
+ }
+ }
+
$result->retval[$i]->text = $tmpText;
}
else
diff --git a/application/libraries/TemplateLib.php b/application/libraries/WidgetLib.php
similarity index 72%
rename from application/libraries/TemplateLib.php
rename to application/libraries/WidgetLib.php
index 6cc001f1f..52fbd0071 100644
--- a/application/libraries/TemplateLib.php
+++ b/application/libraries/WidgetLib.php
@@ -24,12 +24,10 @@
* THE SOFTWARE.
*/
-if (!defined("BASEPATH"))
- exit("No direct script access allowed");
+if (!defined("BASEPATH")) exit("No direct script access allowed");
-class TemplateLib
+class WidgetLib
{
-
/* default values */
private $_template = 'template';
private $_parser = FALSE;
@@ -181,9 +179,11 @@ class TemplateLib
* Can be usefull to use straight from the template file
* @param string $name
* @param array $data
+ * @param array $htmlArgs
* @return Widget
*/
- public function widget($name, $data = array()) {
+ public function widget($name, $data = array(), $htmlArgs = array())
+ {
$class = str_replace('.php', '', trim($name, '/'));
// determine path and widget class name
@@ -210,7 +210,7 @@ class TemplateLib
show_error("Widget '" . $class . "' was not found.");
}
- return new $class($class, $data);
+ return new $class($class, $data, $htmlArgs);
}
/**
@@ -335,7 +335,6 @@ class TemplateLib
class Partial
{
-
protected $_ci, $_content, $_name, $_cache_ttl = 0, $_cached = false, $_identifier, $_trigger;
protected $_args = array();
@@ -343,7 +342,8 @@ class Partial
* Construct with optional parameters
* @param array $args
*/
- public function __construct($name, $args = array()) {
+ public function __construct($name, $args = array())
+ {
$this->_ci = &get_instance();
$this->_args = $args;
$this->_name = $name;
@@ -602,28 +602,196 @@ class Partial
}
}
+/**
+ * The mother of all widgets
+ * it represent a generic HTML element
+ */
class Widget extends Partial
{
+ // The name of the array present in the data array given to the view that will render this widget
+ const HTML_ARG_NAME = 'HTML';
+ const HTML_DEFAULT_VALUE = ''; // Default value of the html element
+ const HTML_NAME = 'name'; // HTML name attribute
+ const HTML_ID = 'id'; // HTML id attribute
- /* (non-PHPdoc)
- * @see Partial::content()
+ /**
+ * It gets also the htmlArgs array as parameter, it will be used to set the HTML properties
*/
- 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);
- }
- }
- }
+ public function __construct($name, $args, $htmlArgs = array())
+ {
+ parent::__construct($name, $args);
+
+ // Initialising HTML properties
+ $this->_setHtmlProperties($htmlArgs);
- return parent::content();
+ // Loads helper message to manage returning messages
+ $this->load->helper('message');
+ }
+
+ /**
+ * (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();
+ }
+
+ /**
+ * Initialising html properties, such as the id and name attributes of the HTML element
+ */
+ private function _setHtmlProperties($htmlArgs)
+ {
+ if (isset($htmlArgs) && is_array($htmlArgs))
+ {
+ $this->_args[Widget::HTML_ARG_NAME] = array();
+
+ // Avoids that the elements of a same HTML page have the same name or id
+ $randomIdentifier = uniqid(rand(0, 1000));
+
+ if (isset($htmlArgs[Widget::HTML_ID]) && trim($htmlArgs[Widget::HTML_ID]) != '')
+ {
+ $this->_args[Widget::HTML_ARG_NAME][Widget::HTML_ID] = $htmlArgs[Widget::HTML_ID];
+ }
+ else
+ {
+ $this->_args[Widget::HTML_ARG_NAME][Widget::HTML_ID] = $randomIdentifier;
+ }
+
+ if (isset($htmlArgs[Widget::HTML_NAME]) && trim($htmlArgs[Widget::HTML_NAME]) != '')
+ {
+ $this->_args[Widget::HTML_ARG_NAME][Widget::HTML_NAME] = $htmlArgs[Widget::HTML_NAME];
+ }
+ else
+ {
+ $this->_args[Widget::HTML_ARG_NAME][Widget::HTML_NAME] = $randomIdentifier;
+ }
+ }
}
}
+
+/**
+ * It exends the Widget class to represent an HTML dropdown
+ */
+class DropdownWidget extends Widget
+{
+ // The name of the element of the data array given to the view
+ // this element is an array of elements to be place inside the dropdown
+ const WIDGET_DATA_ELEMENTS_ARRAY_NAME = 'ELEMENTS_ARRAY';
+ // Name of the property that will be used to store the value attribute of the option tag
+ const ID_FIELD = 'id';
+ // Name of the property that will be used to store the value between the option tags
+ const DESCRIPTION_FIELD = 'description'; //
+ // The name of the element of the data array given to the view
+ // this element is used to tell what element of the dropdown is selected
+ const SELECTED_ELEMENT = 'selectedElement'; //
+
+ private $elementsArray; // Array of elements to be place inside the dropdown
+
+ /**
+ * Loads the dropdown view with all the elements to be displayed
+ */
+ protected function loadDropDownView($widgetData)
+ {
+ $widgetData[DropdownWidget::WIDGET_DATA_ELEMENTS_ARRAY_NAME] = $this->elementsArray->retval;
+
+ if (!isset($widgetData[DropdownWidget::SELECTED_ELEMENT]))
+ {
+ $widgetData[DropdownWidget::SELECTED_ELEMENT] = Widget::HTML_DEFAULT_VALUE;
+ }
+
+ $this->view('widgets/dropdown', $widgetData);
+ }
+
+ /**
+ * Add the correct select to the model used to load a list of elemets for this dropdown
+ * @param model $model the model used to load elements
+ * @param string $idName the name of the field that will used to be the value of the option tag
+ * @param string $descriptionName the name of the field that will used to be displayed in the dropdown
+ */
+ protected function addSelectToModel($model, $idName, $descriptionName)
+ {
+ $model->addSelect(
+ sprintf(
+ '%s AS %s, %s AS %s',
+ $idName,
+ DropdownWidget::ID_FIELD,
+ $descriptionName,
+ DropdownWidget::DESCRIPTION_FIELD
+ )
+ );
+ }
+
+ /**
+ * Set the array used to populate the dropdown
+ * @param array $elements list used to populate this dropdown
+ * @param boolean $emptyElement if an empty element must be added at the beginning of the dropdown
+ * @param string $stdDescription description of the empty element
+ * @param string $noDataDescription description if no data are found
+ * @param string $id value of the attribute value of the empty element
+ */
+ protected function setElementsArray(
+ $elements, $emptyElement = false, $stdDescription = '' , $noDataDescription = '' , $id = Widget::HTML_DEFAULT_VALUE
+ )
+ {
+ if (isError($elements))
+ {
+ if (is_object($elements) && isset($elements->retval))
+ {
+ show_error($elements->retval);
+ }
+ else if (is_string($elements))
+ {
+ show_error($elements);
+ }
+ else
+ {
+ show_error('Generic error occurred');
+ }
+ }
+ else
+ {
+ $this->elementsArray = $elements;
+
+ if ($emptyElement === true)
+ {
+ $this->addElementAtBeginning($stdDescription, $noDataDescription, $id);
+ }
+ }
+ }
+
+ /**
+ * Adds an element to the beginning of the array
+ */
+ protected function addElementAtBeginning($stdDescription, $noDataDescription, $id)
+ {
+ $element = new stdClass();
+ $element->id = $id;
+ $element->description = $stdDescription;
+
+ if (!hasData($this->elementsArray))
+ {
+ $element->description = $noDataDescription;
+ }
+
+ array_unshift($this->elementsArray->retval, $element);
+ }
+}
\ No newline at end of file
diff --git a/application/models/crm/Prestudent_model.php b/application/models/crm/Prestudent_model.php
index a638f04fa..ee21dec11 100644
--- a/application/models/crm/Prestudent_model.php
+++ b/application/models/crm/Prestudent_model.php
@@ -74,4 +74,107 @@ class Prestudent_model extends DB_Model
)
);
}
+
+ /**
+ * Returns a list of prestudent with additional information:
+ * - person_id
+ * - name, surname, gender and birthday
+ * - email
+ * - studiengang and orgform
+ * - studienplan
+ * - stufe and aufnahmegruppe
+ * - reihungstest score
+ */
+ public function getPrestudentMultiAssign($studiengang = null, $studiensemester = null, $gruppe = null, $reihungstest = null, $stufe = null)
+ {
+ $this->addSelect(
+ 'p.person_id,
+ prestudent_id,
+ p.nachname,
+ p.vorname,
+ p.geschlecht,
+ p.gebdatum,
+ k.kontakt AS email,
+ sg.kurzbzlang,
+ sg.bezeichnung,
+ sg.orgform_kurzbz,
+ sgt.bezeichnung AS typ,
+ s.bezeichnung AS studienplan,
+ ps.rt_stufe,
+ aufnahmegruppe_kurzbz,
+ SUM(rtp.punkte) AS punkte'
+ );
+
+ $this->addJoin('public.tbl_person p', 'person_id', 'LEFT');
+ $this->addJoin(
+ '(
+ SELECT DISTINCT ON(person_id) person_id,
+ kontakt
+ FROM public.tbl_kontakt
+ WHERE zustellung = TRUE
+ AND kontakttyp = \'email\'
+ ORDER BY person_id, kontakt_id DESC
+ ) k',
+ 'person_id',
+ 'LEFT'
+ );
+ $this->addJoin('public.tbl_prestudentstatus ps', 'prestudent_id');
+ $this->addJoin('lehre.tbl_studienplan s', 's.studienplan_id = ps.studienplan_id');
+ $this->addJoin('lehre.tbl_studienordnung so', 'studienordnung_id');
+ $this->addJoin('public.tbl_studiengang sg', 'sg.studiengang_kz = so.studiengang_kz');
+ $this->addJoin('public.tbl_studiengangstyp sgt', 'typ');
+
+ $this->addJoin('public.tbl_rt_person rtp', 'rtp.person_id = p.person_id AND rtp.studienplan_id = s.studienplan_id', 'LEFT');
+
+ $this->addOrder('p.person_id', 'ASC');
+ $this->addOrder('prestudent_id', 'ASC');
+
+ $parametersArray = array('p.aktiv' => true, 'ps.status_kurzbz' => 'Interessent');
+
+ if ($studiengang != null)
+ {
+ $parametersArray['public.tbl_prestudent.studiengang_kz'] = $studiengang;
+ }
+
+ if ($studiensemester != null)
+ {
+ $parametersArray['ps.studiensemester_kurzbz'] = $studiensemester;
+ }
+
+ if ($gruppe != null)
+ {
+ $parametersArray['aufnahmegruppe_kurzbz'] = $gruppe;
+ }
+
+ if ($reihungstest != null)
+ {
+ $parametersArray['rtp.rt_id'] = $reihungstest;
+ }
+
+ if ($stufe != null)
+ {
+ $parametersArray['ps.rt_stufe'] = $stufe;
+ }
+
+ $this->addGroupBy(
+ array(
+ 'p.person_id',
+ 'prestudent_id',
+ 'p.nachname',
+ 'p.vorname',
+ 'p.geschlecht',
+ 'p.gebdatum',
+ 'k.kontakt',
+ 'sg.kurzbzlang',
+ 'sg.bezeichnung',
+ 'sg.orgform_kurzbz',
+ 'sgt.bezeichnung',
+ 's.bezeichnung',
+ 'ps.rt_stufe',
+ 'aufnahmegruppe_kurzbz'
+ )
+ );
+
+ return $this->loadWhere($parametersArray);
+ }
}
\ No newline at end of file
diff --git a/application/models/organisation/Organisationseinheit_model.php b/application/models/organisation/Organisationseinheit_model.php
index aca1451da..ccab383cd 100755
--- a/application/models/organisation/Organisationseinheit_model.php
+++ b/application/models/organisation/Organisationseinheit_model.php
@@ -11,32 +11,38 @@ class Organisationseinheit_model extends DB_Model
$this->pk = 'oe_kurzbz';
}
- public function getRecursiveList($typ)
+ public function getRecursiveList($typ = null)
{
- $qry = "WITH RECURSIVE tree (oe_kurzbz, bezeichnung, path, organisationseinheittyp_kurzbz) AS
- (
- SELECT
- oe_kurzbz,
- bezeichnung||' ('||organisationseinheittyp_kurzbz||')' AS bezeichnung,
- oe_kurzbz||'|' AS path,
- organisationseinheittyp_kurzbz
- FROM tbl_organisationseinheit
- WHERE oe_parent_kurzbz IS NULL AND aktiv
- UNION ALL
- SELECT
- oe.oe_kurzbz,
- oe.bezeichnung||' ('||oe.organisationseinheittyp_kurzbz||')' AS bezeichnung,
- tree.path ||oe.oe_kurzbz||'|' AS path,
- oe.organisationseinheittyp_kurzbz
- FROM tree
- JOIN tbl_organisationseinheit oe ON (tree.oe_kurzbz=oe.oe_parent_kurzbz)
+ $qry = "WITH RECURSIVE tree (oe_kurzbz, bezeichnung, path, organisationseinheittyp_kurzbz) AS (
+ SELECT oe_kurzbz,
+ bezeichnung || ' (' || organisationseinheittyp_kurzbz || ')' AS bezeichnung,
+ oe_kurzbz || '|' AS path,
+ organisationseinheittyp_kurzbz
+ FROM tbl_organisationseinheit
+ WHERE oe_parent_kurzbz IS NULL
+ AND aktiv = true
+ UNION ALL
+ SELECT oe.oe_kurzbz,
+ oe.bezeichnung || ' (' || oe.organisationseinheittyp_kurzbz || ')' AS bezeichnung,
+ tree.path || oe.oe_kurzbz || '|' AS path,
+ oe.organisationseinheittyp_kurzbz
+ FROM tree JOIN tbl_organisationseinheit oe ON (tree.oe_kurzbz = oe.oe_parent_kurzbz)
)
- SELECT oe_kurzbz AS value, substring(regexp_replace(path, '[A-z]+\|', '-','g')||bezeichnung,2) AS name, path FROM tree ";
- if (!empty($typ))
- $qry .= 'WHERE organisationseinheittyp_kurzbz IN ('.$typ.') ';
- $qry .= 'ORDER BY path;';
-
- return $this->execQuery($qry);
+ SELECT oe_kurzbz AS id,
+ SUBSTRING(REGEXP_REPLACE(path, '[A-z]+\|', '-', 'g') || bezeichnung, 2) AS description
+ FROM tree";
+
+ $parametersArray = array();
+
+ if (is_array($typ) && count($typ) > 0)
+ {
+ $parametersArray[] = $typ;
+ $qry .= ' WHERE organisationseinheittyp_kurzbz IN ?';
+ }
+
+ $qry .= ' ORDER BY path';
+
+ return $this->execQuery($qry, $parametersArray);
}
/**
diff --git a/application/models/organisation/Studiengang_model.php b/application/models/organisation/Studiengang_model.php
index 54dcaf242..385c874a2 100644
--- a/application/models/organisation/Studiengang_model.php
+++ b/application/models/organisation/Studiengang_model.php
@@ -116,9 +116,9 @@ class Studiengang_model extends DB_Model
$this->addOrder('lehre.tbl_studienplan.studienplan_id');
$result = $this->loadTree(
- 'tbl_studiengang',
+ 'public.tbl_studiengang',
array(
- 'tbl_studienplan'
+ 'lehre.tbl_studienplan'
),
array(
'lehre.tbl_studienplan_semester.studiensemester_kurzbz' => $studiensemester_kurzbz,
@@ -158,10 +158,10 @@ class Studiengang_model extends DB_Model
$this->addOrder('lehre.tbl_studienplan.studienplan_id');
$result = $this->loadTree(
- 'tbl_studiengang',
+ 'public.tbl_studiengang',
array(
- 'tbl_studienplan',
- 'tbl_akadgrad'
+ 'lehre.tbl_studienplan',
+ 'lehre.tbl_akadgrad'
),
'public.tbl_studiengang.aktiv = TRUE
AND public.tbl_studiengang.onlinebewerbung = TRUE
@@ -180,22 +180,23 @@ class Studiengang_model extends DB_Model
}
/**
- * TODO
+ *
*/
- public function getAppliedStudiengang($person_id, $studiensemester_kurzbz, $titel, $status_kurzbz)
+ public function getAppliedStudiengang($person_id, $studiensemester_kurzbz, $titel)
{
- // Then join with table
+ // Then join with table public.tbl_prestudent
$this->addJoin('public.tbl_prestudent', 'studiengang_kz');
- // Join table
+ // Join table public.tbl_prestudentstatus
$this->addJoin('public.tbl_prestudentstatus', 'prestudent_id');
- // Then join with table
+ // Then join with table lehre.tbl_studienplan
$this->addJoin('lehre.tbl_studienplan', 'studienplan_id');
- // Then join with table
+ // Then join with table public.tbl_notizzuordnung + public.tbl_notiz
$this->addJoin(
'(
- SELECT *
- FROM public.tbl_notizzuordnung INNER JOIN public.tbl_notiz n USING(notiz_id)
- WHERE n.titel = \''.$titel.'\') tbl_nn',
+ SELECT public.tbl_notiz.*, public.tbl_notizzuordnung.prestudent_id
+ FROM public.tbl_notiz JOIN public.tbl_notizzuordnung USING(notiz_id)
+ WHERE titel = '.$this->escape($titel).
+ ') tbl_notiz',
'prestudent_id',
'LEFT'
);
@@ -204,17 +205,16 @@ class Studiengang_model extends DB_Model
$this->addOrder('public.tbl_studiengang.bezeichnung');
$result = $this->loadTree(
- 'tbl_studiengang',
+ 'public.tbl_studiengang',
array(
- 'tbl_prestudent',
- 'tbl_prestudentstatus',
- 'tbl_studienplan',
- 'tbl_nn'
+ 'public.tbl_prestudent',
+ 'public.tbl_prestudentstatus',
+ 'lehre.tbl_studienplan',
+ 'public.tbl_notiz'
),
- 'public.tbl_prestudent.person_id = '.$person_id.
- ' AND public.tbl_prestudentstatus.studiensemester_kurzbz = \''.$studiensemester_kurzbz.'\''.
- ' AND (public.tbl_prestudentstatus.status_kurzbz = \'Interessent\' OR public.tbl_prestudentstatus.status_kurzbz = \'Bewerber\')'
- ,
+ 'public.tbl_prestudent.person_id = '.$this->escape($person_id).
+ ' AND public.tbl_prestudentstatus.studiensemester_kurzbz = '.$this->escape($studiensemester_kurzbz).
+ ' AND (public.tbl_prestudentstatus.status_kurzbz = \'Interessent\' OR public.tbl_prestudentstatus.status_kurzbz = \'Bewerber\')',
array(
'prestudenten',
'prestudentstatus',
@@ -235,8 +235,6 @@ class Studiengang_model extends DB_Model
return $isEntitled;
if (($isEntitled = $this->isEntitled('lehre.tbl_studienplan', PermissionLib::SELECT_RIGHT, FHC_NORIGHT, FHC_MODEL_ERROR)) !== true)
return $isEntitled;
- /*if (($isEntitled = $this->isEntitled('public.tbl_rt_studienplan', PermissionLib::SELECT_RIGHT, FHC_NORIGHT, FHC_MODEL_ERROR)) !== true)
- return $isEntitled;*/
if (($isEntitled = $this->isEntitled('public.tbl_reihungstest', PermissionLib::SELECT_RIGHT, FHC_NORIGHT, FHC_MODEL_ERROR)) !== true)
return $isEntitled;
if (($isEntitled = $this->isEntitled('public.tbl_prestudentstatus', PermissionLib::SELECT_RIGHT, FHC_NORIGHT, FHC_MODEL_ERROR)) !== true)
@@ -244,11 +242,6 @@ class Studiengang_model extends DB_Model
if (($isEntitled = $this->isEntitled('public.tbl_prestudent', PermissionLib::SELECT_RIGHT, FHC_NORIGHT, FHC_MODEL_ERROR)) !== true)
return $isEntitled;
- $this->addFrom(
- '(SELECT * FROM public.tbl_reihungstest LEFT JOIN public.tbl_rt_studienplan USING(reihungstest_id))',
- 'tbl_reihungstest'
- );
-
$this->addJoin('lehre.tbl_studienordnung', 'studiengang_kz');
$this->addJoin('lehre.tbl_studienplan', 'studienordnung_id');
@@ -257,11 +250,16 @@ class Studiengang_model extends DB_Model
$this->addJoin('public.tbl_prestudent', 'prestudent_id');
+ $this->addFrom(
+ '(SELECT * FROM public.tbl_reihungstest LEFT JOIN public.tbl_rt_studienplan USING(reihungstest_id))',
+ 'tbl_reihungstest'
+ );
+
$this->addOrder('tbl_studiengang.bezeichnung, tbl_reihungstest.stufe, tbl_reihungstest.datum');
return $this->loadTree(
- 'tbl_studiengang',
- array('tbl_reihungstest'),
+ 'public.tbl_studiengang',
+ array('public.tbl_reihungstest'),
'tbl_prestudentstatus.status_kurzbz = \'Interessent\'
AND (tbl_prestudentstatus.rt_stufe >= tbl_reihungstest.stufe OR tbl_reihungstest.stufe IS NULL)
AND (tbl_prestudent.aufnahmegruppe_kurzbz = tbl_reihungstest.aufnahmegruppe_kurzbz OR tbl_reihungstest.aufnahmegruppe_kurzbz IS NULL)
@@ -273,15 +271,15 @@ class Studiengang_model extends DB_Model
tbl_reihungstest.max_teilnehmer,
(
SELECT SUM(arbeitsplaetze)
- FROM public.tbl_ort JOIN public.tbl_rt_ort USING(ort_kurzbz)
- WHERE rt_id = tbl_reihungstest.reihungstest_id
+ FROM public.tbl_ort JOIN public.tbl_rt_ort USING(ort_kurzbz)
+ WHERE rt_id = tbl_reihungstest.reihungstest_id
)
) - (
SELECT COUNT(*)
- FROM public.tbl_rt_person
- WHERE rt_id = tbl_reihungstest.reihungstest_id
+ FROM public.tbl_rt_person
+ WHERE rt_id = tbl_reihungstest.reihungstest_id
) > 0
- AND person_id = ' . $person_id,
+ AND person_id = ' . $this->escape($person_id),
array('reihungstest')
);
}
diff --git a/application/models/system/MessageToken_model.php b/application/models/system/MessageToken_model.php
old mode 100644
new mode 100755
index c724478bf..331039a7b
--- a/application/models/system/MessageToken_model.php
+++ b/application/models/system/MessageToken_model.php
@@ -1,5 +1,9 @@
config->load('message');
-
+
// Load return message helper
$this->load->helper('message');
-
+
// Loads the database object
$this->load->database();
}
-
+
/**
* Get a received message identified by token
*/
@@ -41,9 +45,168 @@ class MessageToken_model extends CI_Model
) s ON (r.message_id = s.message_id AND r.person_id = s.person_id)
WHERE r.token = ?
LIMIT 1';
-
+
$result = $this->db->query($sql, array(MSG_STATUS_DELETED, $token));
+ // If no errors occurred
+ if ($result)
+ {
+ return success($result->result());
+ }
+ else
+ {
+ return error($this->db->error());
+ }
+ }
+
+ /**
+ * Set the status of a message to read. If the status of the message
+ * is already read, than update updateamum
+ */
+ public function setReadMessageStatusByToken($token)
+ {
+ $sql = 'SELECT r.message_id,
+ m.person_id as sender_id,
+ r.person_id as receiver_id,
+ m.subject,
+ m.body,
+ m.insertamum,
+ m.relationmessage_id,
+ m.oe_kurzbz,
+ s.status,
+ s.statusinfo,
+ s.insertamum as statusamum
+ FROM public.tbl_msg_recipient r JOIN public.tbl_msg_message m USING (message_id)
+ JOIN (
+ SELECT * FROM public.tbl_msg_status WHERE status < ? ORDER BY insertamum DESC, status DESC
+ ) s ON (r.message_id = s.message_id AND r.person_id = s.person_id)
+ WHERE r.token = ?
+ LIMIT 1';
+
+ $msgs = $this->db->query($sql, array(MSG_STATUS_ARCHIVED, $token));
+
+ // If no errors occurred
+ if ($msgs)
+ {
+ // If at least a record is present
+ if (count($msgs->result()) > 0)
+ {
+ $msg = $msgs->result()[0];
+
+ $msgStatusResult = false; // pessimistic expectation
+
+ // If the status of the message is unread
+ if ($msg->status == MSG_STATUS_UNREAD)
+ {
+ // Insert the read status
+ $msgStatusResult = $this->db->insert(
+ 'public.tbl_msg_status',
+ array(
+ 'message_id' => $msg->message_id,
+ 'person_id' => $msg->receiver_id,
+ 'status' => MSG_STATUS_READ,
+ 'statusinfo' => $msg->statusinfo,
+ 'insertamum' => 'NOW()',
+ 'insertvon' => null,
+ 'updateamum' => 'NOW()',
+ 'updatevon' => null
+ )
+ );
+ }
+ // If the status of the message is read
+ else if ($msg->status == MSG_STATUS_READ)
+ {
+ // Update updateamum to current date
+ $this->db->set('updateamum', 'NOW()');
+
+ $this->db->where('message_id', $msg->message_id);
+ $this->db->where('person_id', $msg->receiver_id);
+ $this->db->where('status', MSG_STATUS_READ);
+
+ $msgStatusResult = $this->db->update('public.tbl_msg_status');
+ }
+
+ // If some of the previous DB manipulation (update or insert) has failed
+ if (!$msgStatusResult)
+ {
+ return error($this->db->error());
+ }
+ }
+
+ return success($msgs->result());
+ }
+ else
+ {
+ return error($this->db->error());
+ }
+
return success($result->result());
}
+
+ /**
+ * Get data of the message sender
+ */
+ public function getSenderData($person_id)
+ {
+ $sql = 'SELECT p.vorname,
+ p.nachname,
+ p.anrede,
+ p.titelpost,
+ p.titelpre,
+ p.vornamen,
+ m.mitarbeiter_uid
+ FROM public.tbl_person p
+ LEFT JOIN public.tbl_benutzer b USING(person_id)
+ LEFT JOIN public.tbl_mitarbeiter m ON(b.uid = m.mitarbeiter_uid)
+ WHERE p.person_id = ?';
+
+ $result = $this->db->query($sql, array($person_id));
+
+ // If no errors occurred
+ if ($result)
+ {
+ return success($result->result());
+ }
+ else
+ {
+ return error($this->db->error());
+ }
+ }
+
+ /**
+ *
+ */
+ public function isEmployee($person_id)
+ {
+ $sql = 'SELECT m.mitarbeiter_uid
+ FROM public.tbl_person p
+ LEFT JOIN public.tbl_benutzer b USING(person_id)
+ LEFT JOIN public.tbl_mitarbeiter m ON(b.uid = m.mitarbeiter_uid)
+ WHERE p.person_id = ?
+ AND b.aktiv = TRUE';
+
+ $result = $this->db->query($sql, array($person_id));
+
+ // If no errors occurred
+ if ($result)
+ {
+ // If data are present
+ if (is_array($result->result()) && count($result->result()) > 0)
+ {
+ $person = $result->result()[0];
+
+ // If it is an employee
+ if ($person->mitarbeiter_uid != null)
+ {
+ return true;
+ }
+ }
+
+ return false;
+ }
+ else
+ {
+ return error($this->db->error());
+ }
+ }
}
\ No newline at end of file
diff --git a/application/views/system/aufnahme/prestudentMultiAssign.php b/application/views/system/aufnahme/prestudentMultiAssign.php
new file mode 100644
index 000000000..f90ea208c
--- /dev/null
+++ b/application/views/system/aufnahme/prestudentMultiAssign.php
@@ -0,0 +1,323 @@
+load->view("templates/header", array("title" => "Users manager", "jquery" => true, "tablesort" => true, "jquery_checkboxes" => true, "jquery_custom" => true)); ?>
+
+
+
+
+
+
+
+
+
+
+
+
+
+load->view("templates/footer"); ?>
\ No newline at end of file
diff --git a/application/views/system/messageHTML.php b/application/views/system/messageHTML.php
old mode 100644
new mode 100755
index a98995e7f..4a2eb2f07
--- a/application/views/system/messageHTML.php
+++ b/application/views/system/messageHTML.php
@@ -1,9 +1,57 @@
-