Merge branch 'master' into feature-3716/Messaging_inbox_outbox_user

This commit is contained in:
Paolo
2019-06-21 13:35:28 +02:00
25 changed files with 613 additions and 779 deletions
+193 -160
View File
@@ -65,13 +65,35 @@ class ReihungstestJob extends CLI_Controller
}
}
/**
* runZentraleReihungstestAnmeldefristAssistenzJob
*/
public function runZentraleReihungstestAnmeldefristAssistenzJob()
{
// Get placement tests where registration date was yesterday
$result = $this->ReihungstestModel->checkReachedRegistrationDate(11000);
/*
* Sends an email to all assistants of a placement test when an anmeldeschluss has been reached
*
* @param integer $degreeProgram. Kennzahl of Degree Program to check
* @param string $bcc. Optional. BCC-Mailadress to send the Mails to
* @param string $from. Optional. Sender-Mailadress shown to recipient
*/
public function runZentraleReihungstestAnmeldefristAssistenzJob($degreeProgram, $bcc = null, $from = null)
{
// Encode Params
if ($bcc != '')
{
// $bcc can be given as null-string, so check that too
if ($bcc == 'null')
{
$bcc = '';
}
else
{
$bcc = urldecode($bcc);
}
}
if ($from != '')
{
$from = urldecode($from);
}
// Get placement tests where registration date was yesterday
$result = $this->ReihungstestModel->checkReachedRegistrationDate($degreeProgram);
$reachedRegistration_rt_arr = array();
@@ -99,8 +121,9 @@ class ReihungstestJob extends CLI_Controller
show_error($applicants->error);
}
// Get all Bachelor-Degree-Programs with Mailadress
$bachelorStudiengeange = $this->StudiengangModel->loadStudiengaengeFromTyp('b');
// Get all Bachelor-Degree-Programs with Mailadress
$bachelorStudiengeange = $this->StudiengangModel->loadStudiengaengeFromTyp('b');
$bachelorStudiengeange_arr = array();
if (hasData($bachelorStudiengeange))
{
@@ -116,87 +139,80 @@ class ReihungstestJob extends CLI_Controller
foreach ($bachelorStudiengeange_arr as $bachelorStudiengang)
{
$studiengang_kuerzel = strtoupper($bachelorStudiengang->typ.$bachelorStudiengang->kurzbz);
$applicants_list = '';
$applicantCounter = 0;
$rowstyle = 'style="background-color: #EEEEEE; padding: 4px;"';
$mailReceipients = ''; // String with all mailadresses
$mailcontent_data_arr = array();
foreach ($applicants_arr as $applicant)
{
if ($bachelorStudiengang->studiengang_kz == $applicant->studiengang_kz)
{
$mailReceipients .= $applicant->email. ';';
$applicantCounter ++;
$applicants_list .= '
<tr '.$rowstyle.'>
<td>'. $applicant->orgform_kurzbz. '</td>
<td>'. $applicant->ausbildungssemester. '</td>
<td>'. $applicant->nachname. '</td>
<td>'. $applicant->vorname. '</td>
<td>'. $applicant->zgv_kurzbz. '</td>
<td>'. $applicant->prioritaet. '</td>
<td>'. $applicant->qualifikationskurs. '</td>
<td><a href="mailto:'. $applicant->email. '">'. $applicant->email. '</a></td>
</tr>
';
}
}
if ($applicantCounter == 0)
{
$mailcontent = '<p style="font-family: verdana, sans-serif;">Der Anmeldeschluss für den zentralen Reihungstest am ' . date_format(date_create($reihungstest->datum), 'd.m.Y') . ' um ' . $reihungstest->uhrzeit . ' Uhr wurde gestern erreicht.</p>';
$mailcontent .= '<p style="font-family: verdana, sans-serif;"><b>Für den Studiengang ' . $studiengang_kuerzel . ' nehmen keine InteressentInnen an diesem Reihungstest teil</b></p>';
}
else
{
$headerstyle = 'style="background: #DCE4EF; border: 1px solid #FFF; padding: 4px; text-align: left;"';
}
}
if ($applicantCounter == 0)
{
$mailcontent = '<p style="font-family: verdana, sans-serif;">Der Anmeldeschluss für den zentralen Reihungstest am ' . date_format(date_create($reihungstest->datum), 'd.m.Y') . ' um ' . $reihungstest->uhrzeit . ' Uhr wurde gestern erreicht.</p>';
$mailcontent .= '<p style="font-family: verdana, sans-serif;"><b>Für den Studiengang '.$studiengang_kuerzel.' nehmen keine InteressentInnen an diesem Reihungstest teil</b></p>';
}
else
{
$mailcontent = '<p style="font-family: verdana, sans-serif;">Der Anmeldeschluss für den zentralen Reihungstest am ' . date_format(date_create($reihungstest->datum), 'd.m.Y') . ' um ' . $reihungstest->uhrzeit . ' Uhr wurde gestern erreicht.</p>';
$mailcontent .= '
<p style="font-family: verdana, sans-serif;"><b>' . $applicantCounter . '</b> InteressentIn(nen) des Studiengangs ' . $studiengang_kuerzel . ' nehmen daran teil:</p>
<p style="font-family: verdana, sans-serif;">
<a href="'.APP_ROOT.'vilesci/stammdaten/auswertung_fhtw.php?reihungstest='.$reihungstest->reihungstest_id.'&studiengang='.$bachelorStudiengang->studiengang_kz.'" target="_blank">
Liste der Anmeldungen
</a>
</p>';
}
$mailcontent_data_arr['table'] = $mailcontent;
$mailcontent = '<p style="font-family: verdana, sans-serif;">Der Anmeldeschluss für den zentralen Reihungstest am ' . date_format(date_create($reihungstest->datum), 'd.m.Y') . ' um ' . $reihungstest->uhrzeit . ' Uhr wurde gestern erreicht.</p>';
$mailcontent .= '
<p style="font-family: verdana, sans-serif;">Folgende ' . $applicantCounter . ' InteressentInnen des Studiengangs ' . $studiengang_kuerzel . ' nehmen daran teil:</p>
<table width="100%" style="cellpadding: 3px; font-family: verdana, sans-serif; border: 1px solid #000000;">
<thead>
<th ' . $headerstyle . '>OrgForm</th>
<th ' . $headerstyle . '>Semester</th>
<th ' . $headerstyle . '>Nachname</th>
<th ' . $headerstyle . '>Vorname</th>
<th ' . $headerstyle . '>ZGV</th>
<th ' . $headerstyle . '>Priorität</th>
<th ' . $headerstyle . '>Qualikurs</th>
<th ' . $headerstyle . '>E-Mail</th>
</thead>
<tbody>
';
$mailcontent .= $applicants_list;
$mailcontent .= '
</tbody>
</table>
';
$mailcontent .= '<p style="font-family: verdana, sans-serif;"><a href="mailto:?bcc=' . $mailReceipients . '">Mail an alle schicken</a></p>';
}
$mailcontent_data_arr['table'] = $mailcontent;
// Send email in Sancho design
if (!isEmptyString($mailcontent))
{
sendSanchoMail(
'Sancho_ReihungstestteilnehmerJob',
$mailcontent_data_arr,
$bachelorStudiengang->email,
'Anmeldeschluss Reihungstest ' . date_format(date_create($reihungstest->datum), 'd.m.Y') . ' ' . $reihungstest->uhrzeit . ' Uhr',
'sancho_header_min_bw.jpg',
'sancho_footer_min_bw.jpg',
$from,
'',
$bcc);
}
}
}
}
// Send email in Sancho design
if (!isEmptyString($mailcontent))
{
sendSanchoMail(
'Sancho_ReihungstestteilnehmerJob',
$mailcontent_data_arr,
array($bachelorStudiengang->email, 'kindlm@technikum-wien.at'),
'Anmeldeschluss Reihungstest ' . date_format(date_create($reihungstest->datum), 'd.m.Y') . ' ' . $reihungstest->uhrzeit . ' Uhr',
'sancho_header_min_bw.jpg',
'sancho_footer_min_bw.jpg');
}
}
}
}
/*
* Checks, if an applicant was assigned to a test after Anmeldefrist and sends an email to all responsible assistants
*
* @param integer $degreeProgram. Kennzahl of Degree Program to check
* @param string $bcc. Optional. BCC-Mailadress to send the Mails to
* @param string $from. Optional. Sender-Mailadress shown to recipient
*/
public function runZentraleReihungstestNachtraeglichHinzugefuegtJob($degreeProgram, $bcc = null, $from = null)
{
// Encode Params
if ($bcc != '')
{
// $bcc can be given as null-string, so check that too
if ($bcc == 'null')
{
$bcc = '';
}
else
{
$bcc = urldecode($bcc);
}
}
if ($from != '')
{
$from = urldecode($from);
}
/**
* Checks, if an applicant was assigned to a test after Anmeldefrist
*/
public function runZentraleReihungstestNachtraeglichHinzugefuegtJob()
{
// Get applicants that have been added to a test after Anmeldefrist
$result = $this->ReihungstestModel->getApplicantAssignedAfterDate(11000);
// Get applicants that have been added to a test after Anmeldefrist
$result = $this->ReihungstestModel->getApplicantAssignedAfterDate($degreeProgram);
$applicants_after_anmeldefrist_arr = array();
@@ -217,32 +233,39 @@ class ReihungstestJob extends CLI_Controller
$mailcontent = '';
$applicants_list = '';
if (count($applicants_after_anmeldefrist_arr) > 0)
{
foreach ($applicants_after_anmeldefrist_arr as $applicant)
{
if ($studiengang != $applicant->studiengang_kz)
{
if ($studiengang != '' && $studiengang != $applicant->studiengang_kz)
{
$bachelorStudiengang = $this->StudiengangModel->load($studiengang);
$mailcontent .= $applicants_list;
$mailcontent .= '</tbody></table>';
$mailcontent .= '<p style="font-family: verdana, sans-serif;"><a href="mailto:?bcc=' . $mailReceipients . '">Mail an alle schicken</a></p>';
$mailcontent_data_arr['table'] = $mailcontent;
sendSanchoMail(
'Sancho_ReihungstestteilnehmerJob',
$mailcontent_data_arr,
array($bachelorStudiengang->retval[0]->email, 'kindlm@technikum-wien.at'),
'InteressentIn nach Reihungstest-Anmeldeschluss hinzugefügt',
'sancho_header_min_bw.jpg',
'sancho_footer_min_bw.jpg');
$applicants_list = '';
$mailcontent_data_arr = array();
}
if (count($applicants_after_anmeldefrist_arr) > 0)
{
foreach ($applicants_after_anmeldefrist_arr as $applicant)
{
if ($studiengang != $applicant->studiengang_kz)
{
if ($studiengang != '' && $studiengang != $applicant->studiengang_kz)
{
$bachelorStudiengang = $this->StudiengangModel->load($studiengang);
$mailcontent .= $applicants_list;
$mailcontent .= '</tbody></table>';
$mailcontent .= '<p style="font-family: verdana, sans-serif;">
<a href="'.APP_ROOT.'vilesci/stammdaten/auswertung_fhtw.php?reihungstest='.$applicant->reihungstest_id.'&studiengang='.$studiengang.'" target="_blank">
Liste der Anmeldungen
</a>
</p>';
$mailcontent_data_arr['table'] = $mailcontent;
sendSanchoMail(
'Sancho_ReihungstestteilnehmerJob',
$mailcontent_data_arr,
$bachelorStudiengang->retval[0]->email,
'InteressentIn nach Reihungstest-Anmeldeschluss hinzugefügt',
'sancho_header_min_bw.jpg',
'sancho_footer_min_bw.jpg',
$from,
'',
$bcc);
$applicants_list = '';
$mailcontent_data_arr = array();
}
$mailcontent = '<p style="font-family: verdana, sans-serif;">Folgende InteressentInnen wurden <b>nach</b> der Anmeldefrist zu einem Reihungstest hinzugefügt.</p>';
$mailcontent .= '
$mailcontent = '<p style="font-family: verdana, sans-serif;">Folgende InteressentInnen wurden <b>nach</b> der Anmeldefrist zu einem Reihungstest hinzugefügt.<br>Details siehe Link</p>';
$mailcontent .= '
<table width="100%" style="cellpadding: 3px; font-family: verdana, sans-serif; border: 1px solid #000000;">
<thead>
<th ' . $headerstyle . '>Datum des Tests</th>
@@ -251,10 +274,6 @@ class ReihungstestJob extends CLI_Controller
<th ' . $headerstyle . '>Semester</th>
<th ' . $headerstyle . '>Nachname</th>
<th ' . $headerstyle . '>Vorname</th>
<th ' . $headerstyle . '>ZGV</th>
<th ' . $headerstyle . '>Priorität</th>
<th ' . $headerstyle . '>Qualikurs</th>
<th ' . $headerstyle . '>E-Mail</th>
</thead>
<tbody>
';
@@ -270,50 +289,57 @@ class ReihungstestJob extends CLI_Controller
<td>' . $applicant->ausbildungssemester . '</td>
<td>' . $applicant->nachname . '</td>
<td>' . $applicant->vorname . '</td>
<td>' . $applicant->zgv_kurzbz . '</td>
<td>' . $applicant->prioritaet . '</td>
<td>' . $applicant->qualifikationskurs . '</td>
<td><a href="mailto:' . $applicant->email . '">' . $applicant->email . '</a></td>
</tr>
';
};
$bachelorStudiengang = $this->StudiengangModel->load($studiengang);
$mailcontent .= $applicants_list;
$mailcontent .= '</tbody></table>';
$mailcontent .= '<p style="font-family: verdana, sans-serif;"><a href="mailto:?bcc=' . $mailReceipients . '">Mail an alle schicken</a></p>';
$mailcontent_data_arr['table'] = $mailcontent;
sendSanchoMail(
'Sancho_ReihungstestteilnehmerJob',
$mailcontent_data_arr,
array($bachelorStudiengang->retval[0]->email, 'kindlm@technikum-wien.at'),
'InteressentIn nach Reihungstest-Anmeldeschluss hinzugefügt',
'sancho_header_min_bw.jpg',
'sancho_footer_min_bw.jpg');
}
}
};
$bachelorStudiengang = $this->StudiengangModel->load($studiengang);
$mailcontent .= $applicants_list;
$mailcontent .= '</tbody></table>';
$mailcontent .= '<p style="font-family: verdana, sans-serif;">
<a href="'.APP_ROOT.'vilesci/stammdaten/auswertung_fhtw.php?reihungstest='.$applicant->reihungstest_id.'&studiengang='.$studiengang.'" target="_blank">
Liste der Anmeldungen
</a>
</p>';
$mailcontent_data_arr['table'] = $mailcontent;
sendSanchoMail(
'Sancho_ReihungstestteilnehmerJob',
$mailcontent_data_arr,
$bachelorStudiengang->retval[0]->email,
'InteressentIn nach Reihungstest-Anmeldeschluss hinzugefügt',
'sancho_header_min_bw.jpg',
'sancho_footer_min_bw.jpg',
$from,
'',
$bcc);
}
}
/*
* Sends an email to all applicants of a placement test to remind them 3 working days before
*
* @param integer $degreeProgram. Kennzahl of Degree Program to check
* @param string $bcc. Optional. BCC-Mailadress to send the Mails to
* @param string $from. Optional. Sender-Mailadress shown to recipient
*/
public function remindApplicantsOfPlacementTest()
{
$degreeProgram = $this->input->get('degreeprogram');
$bcc = $this->input->get('bcc');
$from = $this->input->get('from');
// Encode Params
if ($bcc != '')
{
$bcc = urldecode($bcc);
}
if ($from != '')
{
$from = urldecode($from);
}
/*
* Sends an email to all applicants of a placement test to remind them 3 working days before
*
* @param integer $degreeProgram. Kennzahl of Degree Program to check
* @param string $bcc. Optional. BCC-Mailadress to send the Mails to
* @param string $from. Optional. Sender-Mailadress shown to recipient
*/
public function remindApplicantsOfPlacementTest($degreeProgram, $bcc = null, $from = null)
{
// Encode Params
if ($bcc != '')
{
// $bcc can be given as null-string, so check that too
if ($bcc == 'null')
{
$bcc = '';
}
else
{
$bcc = urldecode($bcc);
}
}
if ($from != '')
{
$from = urldecode($from);
}
// Get placement tests with testdate within the next 2 weeks
$resultNextTestDates = $this->ReihungstestModel->getNextPlacementtests($degreeProgram, 14);
@@ -376,16 +402,23 @@ class ReihungstestJob extends CLI_Controller
show_error($applicants->error);
}
foreach ($applicants_arr as $applicant)
{
$mailcontent_data_arr = array();
$mailcontent_data_arr['anrede'] = $applicant->anrede;
$mailcontent_data_arr['nachname'] = $applicant->nachname;
$mailcontent_data_arr['vorname'] = $applicant->vorname;
$mailcontent_data_arr['rt_datum'] = date_format(date_create($reihungstest->datum), 'd.m.Y');
$mailcontent_data_arr['rt_uhrzeit'] = date_format(date_create($reihungstest->uhrzeit), 'H:i');
$mailcontent_data_arr['rt_raum'] = $applicant->planbezeichnung;
$mailcontent_data_arr['wegbeschreibung'] = $applicant->lageplan;
foreach ($applicants_arr as $applicant)
{
$mailcontent_data_arr = array();
$mailcontent_data_arr['anrede'] = $applicant->anrede;
$mailcontent_data_arr['nachname'] = $applicant->nachname;
$mailcontent_data_arr['vorname'] = $applicant->vorname;
$mailcontent_data_arr['rt_datum'] = date_format(date_create($reihungstest->datum), 'd.m.Y');
$mailcontent_data_arr['rt_uhrzeit'] = date_format(date_create($reihungstest->uhrzeit), 'H:i');
$mailcontent_data_arr['rt_raum'] = $applicant->planbezeichnung;
if ($applicant->lageplan == '')
{
$mailcontent_data_arr['wegbeschreibung'] = 'Für diesen Raum liegt noch keine Wegbeschreibung vor.<br><br>No directions were found for this room';
}
else
{
$mailcontent_data_arr['wegbeschreibung'] = $applicant->lageplan;
}
sendSanchoMail(
'Sancho_RemindApplicantsOfTest',
-3
View File
@@ -14,9 +14,6 @@ class Auth_Controller extends FHC_Controller
// Loads authentication library and starts authentication
$this->load->library('AuthLib');
// Loads authentication helper
$this->load->helper('hlp_authentication');
// Checks if the caller is allowed to access to this content
$this->_isAllowed($requiredPermissions);
}
@@ -2,20 +2,35 @@
if (!defined('BASEPATH')) exit('No direct script access allowed');
// ------------------------------------------------------------------------
// -----------------------------------------------------------------------------------------------------
// Functions needed to manage the user authentication
// ------------------------------------------------------------------------
// NOTE: the following functions do NOT prompt a login page if the user is NOT logged in
// -----------------------------------------------------------------------------------------------------
/**
* It calls the AuthLib, if the user is NOT logged then the login page is shown
* If the user is NOT logged then a null value is returned.
* If the user is alredy logged, then it is possible to access to the authentication object
* that contains the person_id of the logged user
* NOTE: if a user is logged then a person_id is always present!
*/
function getAuthPersonId()
{
$ci =& get_instance(); // get CI instance
return isLogged() ? ($ci->authlib->getAuthObj())->{AuthLib::AO_PERSON_ID} : null;
}
/**
* If the user is NOT logged then a null value is returned.
* If the user is alredy logged, then it is possible to access to the authentication object
* that contains the username of the logged user
*
* @return string or null
* NOTE: if the user is logged with a "foreign" method (ex. Bewerbungstool),
* then it is possible that the username is null!
*/
function getAuthUID()
{
$ci =& get_instance(); // get CI instance
return ($ci->authlib->getAuthObj())->{AuthLib::AO_USERNAME};
return isLogged() ? ($ci->authlib->getAuthObj())->{AuthLib::AO_USERNAME} : null;
}
+16
View File
@@ -285,3 +285,19 @@ function terminateWithError($message = null)
exit(EXIT_ERROR);
}
/**
* Checks if the current user is logged by checking that the AuthLib is loaded and
* it is present the authentication object in session
* NOTE: it is placed here instead of being placed in the helper hlp_authentication_helper
* because hlp_authentication_helper is loaded after the authentication.
* It is very useful to use this function even in those parts of the code that are accessible
* even when a user is NOT authenticated!!!
* If and only if this function returns true, then all the functions present in hlp_authentication_helper can be used!
*/
function isLogged()
{
$ci =& get_instance(); // get CI instance
return isset($ci->authlib) && $ci->authlib->getAuthObj() != null;
}
+8 -2
View File
@@ -30,7 +30,6 @@ class AuthLib
/**
* Construct
*
*
* @param bool $authenticate If the authentication must be performed.
*/
public function __construct($authenticate = true)
@@ -483,6 +482,8 @@ class AuthLib
/**
* Stores the authentication object into the authentication session
* Everything was fine, the user at this point is authenticated, it is possible to store the authentication object
* in the user session
*/
private function _storeSessionAuthObj($authObj)
{
@@ -552,7 +553,12 @@ class AuthLib
$this->_showError(getData($auth)); // display a generic error message and logs the occurred error
}
}
// else the user is already logged, then continue with the execution
// else the user is already logged, then loads authentication helper and continue with the execution
// NOTE: it is needed only here because:
// - it is called when a user is already logged in
// - it is called after login the user
// - it is NOT called in case of fatal error or wrong authentication
$this->_ci->load->helper('hlp_authentication');
}
/**
+65 -82
View File
@@ -108,9 +108,6 @@ class FiltersLib
{
$this->_ci =& get_instance(); // get code igniter instance
// Loads authentication helper
$this->_ci->load->helper('hlp_authentication'); // NOTE: needed to load custom filters do not remove!
$this->_filterUniqueId = $this->_getFilterUniqueId($params); // sets the id for the related filter widget
}
@@ -185,11 +182,8 @@ class FiltersLib
{
// Loads the needed models
$this->_ci->load->model('system/Filters_model', 'FiltersModel');
$this->_ci->load->model('person/Benutzer_model', 'BenutzerModel'); // to get the default custom filter
$this->_ci->FiltersModel->resetQuery(); // reset any previous built query
$this->_ci->FiltersModel->addJoin('public.tbl_benutzer', 'person_id', 'LEFT'); // left join with benutzer table
$this->_ci->FiltersModel->addSelect('system.tbl_filters.*'); // select only from table filters
$this->_ci->FiltersModel->addOrder('sort', 'ASC'); // sort on column sort
$this->_ci->FiltersModel->addLimit(1); // if more than one filter is set as default only one will be retrieved
@@ -223,7 +217,7 @@ class FiltersLib
$whereParameters = array(
'app' => $app,
'dataset_name' => $datasetName,
'uid' => getAuthUID(),
'person_id' => getAuthPersonId(),
'default_filter' => true
);
@@ -260,10 +254,10 @@ class FiltersLib
$jsonEncodedFilter = null;
// If the definition contains data and they are valid
if (hasData($definition) && isset($definition->retval[0]->filter) && trim($definition->retval[0]->filter) != '')
if (hasData($definition) && isset(getData($definition)[0]->filter) && trim(getData($definition)[0]->filter) != '')
{
// Get the json definition of the filter
$tmpJsonEncodedFilter = json_decode($definition->retval[0]->filter);
$tmpJsonEncodedFilter = json_decode(getData($definition)[0]->filter);
// Checks required filter's properies
if (isset($tmpJsonEncodedFilter->name)
@@ -585,87 +579,76 @@ class FiltersLib
$saveCustomFilter = false; // by default returns a failure
// Checks parameter customFilterDescription if not valid stop the execution
if (isEmptyString($customFilterDescription))
{
return $saveCustomFilter;
}
if (isEmptyString($customFilterDescription)) return $saveCustomFilter;
$this->_ci->load->model('system/Filters_model', 'FiltersModel'); // to load the filter definitions
$this->_ci->load->model('person/Benutzer_model', 'BenutzerModel'); // to get the person_id of the authenticated user
$this->_ci->FiltersModel->resetQuery(); // reset any previous built query
$this->_ci->BenutzerModel->resetQuery(); // reset any previous built query
// Loads data for the authenticated user
$authBenutzer = $this->_ci->BenutzerModel->loadWhere(array('uid' => getAuthUID()));
if (hasData($authBenutzer)) // if data are found
// person_id of the authenticated user
$authPersonId = getAuthPersonId();
// Postgres array for the description
$descPGArray = str_replace('%desc%', $customFilterDescription, '{"%desc%", "%desc%", "%desc%", "%desc%"}');
// Loads the definition to check if is already present in the DB
$definition = $this->_ci->FiltersModel->loadWhere(array(
'app' => $this->getSessionElement(self::APP_PARAMETER),
'dataset_name' => $this->getSessionElement(self::DATASET_NAME_PARAMETER),
'description' => $descPGArray,
'person_id' => $authPersonId
));
// New definition to be json encoded
$jsonDeifinition = new stdClass();
$jsonDeifinition->name = $customFilterDescription; // name of the filter
// Generates the "column" property
$jsonDeifinition->columns = array();
$selectedFields = $this->getSessionElement(self::SESSION_SELECTED_FIELDS); // retrieved the selected fields
for ($i = 0; $i < count($selectedFields); $i++)
{
// person_id of the authenticated user
$authPersonId = $authBenutzer->retval[0]->person_id;
// Postgres array for the description
$descPGArray = str_replace('%desc%', $customFilterDescription, '{"%desc%", "%desc%", "%desc%", "%desc%"}');
// Each element is an object with a property called "name"
$jsonDeifinition->columns[$i] = new stdClass();
$jsonDeifinition->columns[$i]->name = $selectedFields[$i];
}
// Loads the definition to check if is already present in the DB
$definition = $this->_ci->FiltersModel->loadWhere(array(
'app' => $this->getSessionElement(self::APP_PARAMETER),
'dataset_name' => $this->getSessionElement(self::DATASET_NAME_PARAMETER),
'description' => $descPGArray,
'person_id' => $authPersonId
));
// List of applied filters
$jsonDeifinition->filters = $this->getSessionElement(self::SESSION_FILTERS);
// New definition to be json encoded
$jsonDeifinition = new stdClass();
$jsonDeifinition->name = $customFilterDescription; // name of the filter
// If it is already present
if (hasData($definition))
{
// update it
$this->_ci->FiltersModel->update(
array(
'app' => $this->getSessionElement(self::APP_PARAMETER),
'dataset_name' => $this->getSessionElement(self::DATASET_NAME_PARAMETER),
'description' => $descPGArray,
'person_id' => $authPersonId
),
array(
'filter' => json_encode($jsonDeifinition)
)
);
// Generates the "column" property
$jsonDeifinition->columns = array();
$selectedFields = $this->getSessionElement(self::SESSION_SELECTED_FIELDS); // retrieved the selected fields
for ($i = 0; $i < count($selectedFields); $i++)
{
// Each element is an object with a property called "name"
$jsonDeifinition->columns[$i] = new stdClass();
$jsonDeifinition->columns[$i]->name = $selectedFields[$i];
}
$saveCustomFilter = true;
}
else // otherwise insert a new one
{
$this->_ci->FiltersModel->insert(
array(
'app' => $this->getSessionElement(self::APP_PARAMETER),
'dataset_name' => $this->getSessionElement(self::DATASET_NAME_PARAMETER),
'filter_kurzbz' => uniqid($authPersonId, true),
'description' => $descPGArray,
'person_id' => $authPersonId,
'sort' => null,
'default_filter' => false,
'filter' => json_encode($jsonDeifinition),
'oe_kurzbz' => null
)
);
// List of applied filters
$jsonDeifinition->filters = $this->getSessionElement(self::SESSION_FILTERS);
// If it is already present
if (hasData($definition))
{
// update it
$this->_ci->FiltersModel->update(
array(
'app' => $this->getSessionElement(self::APP_PARAMETER),
'dataset_name' => $this->getSessionElement(self::DATASET_NAME_PARAMETER),
'description' => $descPGArray,
'person_id' => $authPersonId
),
array(
'filter' => json_encode($jsonDeifinition)
)
);
$saveCustomFilter = true;
}
else // otherwise insert a new one
{
$this->_ci->FiltersModel->insert(
array(
'app' => $this->getSessionElement(self::APP_PARAMETER),
'dataset_name' => $this->getSessionElement(self::DATASET_NAME_PARAMETER),
'filter_kurzbz' => uniqid($authPersonId, true),
'description' => $descPGArray,
'person_id' => $authPersonId,
'sort' => null,
'default_filter' => false,
'filter' => json_encode($jsonDeifinition),
'oe_kurzbz' => null
)
);
$saveCustomFilter = true;
}
$saveCustomFilter = true;
}
return $saveCustomFilter;
@@ -721,7 +704,7 @@ class FiltersLib
$childrenPersonalArray = array(); // contains all the children elements in menu enty for personal filters
// Loops through loaded filters
foreach ($filters->retval as $filter)
foreach (getData($filters) as $filter)
{
// Generate a menu entry
$menuEntry = $this->_ci->navigationlib->oneLevel(
@@ -349,6 +349,7 @@ class Reihungstest_model extends DB_Model
ps.prestudent_id,
rt.datum,
rt.uhrzeit,
rt.reihungstest_id,
tbl_studienplan.orgform_kurzbz,
tbl_prestudentstatus.studienplan_id,
tbl_prestudentstatus.ausbildungssemester,