From edb60ef17b321b22264318bde9dde5f5dd781b29 Mon Sep 17 00:00:00 2001 From: oesi Date: Fri, 19 Aug 2016 11:31:30 +0200 Subject: [PATCH] - Fixed Fallback if Vorlage doesnt exist - Added Additional Parameters to Message --- application/libraries/VorlageLib.php | 42 ++++++++++++++-------------- content/student/studentDBDML.php | 37 ++++++++++++++++++------ 2 files changed, 50 insertions(+), 29 deletions(-) diff --git a/application/libraries/VorlageLib.php b/application/libraries/VorlageLib.php index 7cf586dff..c121134fd 100644 --- a/application/libraries/VorlageLib.php +++ b/application/libraries/VorlageLib.php @@ -1,4 +1,4 @@ -ci =& get_instance(); - + $this->ci->load->library('parser'); $this->ci->load->library('OrganisationseinheitLib'); - + $this->ci->load->model('system/Vorlage_model', 'VorlageModel'); $this->ci->load->model('system/Vorlagestudiengang_model', 'VorlageStudiengangModel'); - + $this->ci->load->helper('language'); //$this->ci->lang->load('fhcomplete'); } @@ -37,7 +37,7 @@ class VorlageLib { if (empty($vorlage_kurzbz)) return $this->_error(MSG_ERR_INVALID_MSG_ID); - + $vorlage = $this->ci->VorlageModel->load($vorlage_kurzbz); return $vorlage; } @@ -53,7 +53,7 @@ class VorlageLib $vorlage = $this->ci->VorlageModel->loadWhere(array('mimetype' => $mimetype)); return $vorlage; } - + /** * saveVorlage() - will save a spezific Template. @@ -65,7 +65,7 @@ class VorlageLib { if (empty($data)) return $this->_error(MSG_ERR_INVALID_MSG_ID); - + $vorlage = $this->ci->VorlageModel->update($vorlage_kurzbz, $data); return $vorlage; } @@ -81,7 +81,7 @@ class VorlageLib { if (empty($vorlage_kurzbz)) return $this->_error($this->ci->lang->line('fhc_'.FHC_INVALIDID, false)); - + $vorlage = $this->ci->VorlageStudiengangModel->loadWhere(array('vorlage_kurzbz' =>$vorlage_kurzbz)); return $vorlage; } @@ -99,20 +99,20 @@ class VorlageLib { if (empty($vorlage_kurzbz)) return $this->_error($this->ci->lang->line('fhc_'.FHC_INVALIDID, false)); - + // Builds where clause - $where = ""; + $where = "vorlage_kurzbz=".$this->ci->VorlageModel->escape($vorlage_kurzbz); if (is_null($orgform_kurzbz)) { - $where .= "orgform_kurzbz IS NULL"; + $where .= "AND orgform_kurzbz IS NULL"; } else { - $where .= "orgform_kurzbz = " . $this->ci->VorlageModel->escape($orgform_kurzbz); + $where .= "AND orgform_kurzbz = " . $this->ci->VorlageModel->escape($orgform_kurzbz); } - + $where .= " AND "; - + if (is_null($sprache)) { $where .= "sprache IS NULL"; @@ -121,7 +121,7 @@ class VorlageLib { $where .= "sprache = " . $this->ci->VorlageModel->escape($sprache); } - + // Try to search the template with the given vorlage_kurzbz and other parameters if present $queryParameters = array("vorlage_kurzbz" => $vorlage_kurzbz); @@ -137,7 +137,7 @@ class VorlageLib { $queryParameters["sprache"] = $sprache; } - + $vorlage = $this->ci->VorlageStudiengangModel->loadWhere($queryParameters); // If the searched template was not found if (is_object($vorlage) && $vorlage->error == EXIT_SUCCESS && is_array($vorlage->retval) && count($vorlage->retval) == 0) @@ -146,14 +146,14 @@ class VorlageLib 'public', 'tbl_vorlagestudiengang', array("vorlage_kurzbz", "studiengang_kz", "version", "text", "oe_kurzbz", - "vorlagestudiengang_id", "style", "berechtigung", "anmerkung_vorlagestudiengang", + "vorlagestudiengang_id", "style", "berechtigung", "anmerkung_vorlagestudiengang", "aktiv", "sprache", "subject", "orgform_kurzbz"), $where, "version DESC", $oe_kurzbz ); } - + return $vorlage; } @@ -207,7 +207,7 @@ class VorlageLib $text = $this->ci->parser->parse_string($text, $data, TRUE); return $text; } - + /** --------------------------------------------------------------- * Success * @@ -223,7 +223,7 @@ class VorlageLib $return->retval = $retval; return $return; } - + /** --------------------------------------------------------------- * General Error * diff --git a/content/student/studentDBDML.php b/content/student/studentDBDML.php index 16fd12d86..5718ac02b 100644 --- a/content/student/studentDBDML.php +++ b/content/student/studentDBDML.php @@ -71,6 +71,7 @@ require_once('../../include/note.class.php'); require_once('../../include/standort.class.php'); require_once('../../include/adresse.class.php'); require_once('../../include/reihungstest.class.php'); +require_once('../../include/studienplan.class.php'); $user = get_uid(); $db = new basis_db(); @@ -1025,10 +1026,10 @@ if(!$error) $prestudent = new prestudent(); $prestudent->load($_POST['prestudent_id']); - $url =APP_ROOT.'/index.ci.php/api/v1/system/Message/MessageVorlage'; + $url =APP_ROOT.'index.ci.php/api/v1/system/Message/MessageVorlage'; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL,$url); - curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST"); + curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST"); $header=array(); $auth = base64_encode(FHC_REST_USER.':'.FHC_REST_PASSWORD); @@ -1041,17 +1042,28 @@ if(!$error) $studiengang->load($prestudent->studiengang_kz); $studiengang->getAllTypes(); + $orgform=''; + if($rolle->studienplan_id!='') + { + $studienplan = new studienplan(); + $studienplan->loadStudienplan($rolle->studienplan_id); + $orgform = $studienplan->orgform_kurzbz; + } + else + $orgform = $rolle->orgform_kurzbz; $curl_post_data = array( "sender_id" => 1, // TODO "receiver_id" => $prestudent->person_id, "oe_kurzbz" => $studiengang->oe_kurzbz, - "vorlage_kurzbz" => 'MailApplicationConfirmationInteressent', + "vorlage_kurzbz" => 'MailStatConfirm'.$_POST['status_kurzbz'], "data" => array( - 'typ'=>$studiengang->studiengang_typ_arr[$studiengang->typ], - 'studiengang'=>$studiengang->bezeichnung, + 'anrede'=>$prestudent->anrede, 'vorname'=>$prestudent->vorname, 'nachname'=>$prestudent->nachname, - 'anrede'=>$prestudent->anrede + 'typ'=>$studiengang->studiengang_typ_arr[$studiengang->typ], + 'studiengang'=>$studiengang->bezeichnung, + 'orgform'=>$orgform, + 'stgMail'=>$studiengang->email ) ); @@ -1061,8 +1073,17 @@ if(!$error) $result = curl_exec($ch); $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE); curl_close($ch); - - $return = true; + + $jsonresult = json_decode($result); + if(isset($jsonresult->error) && $jsonresult->error==1) + { + $return = false; + $errormsg = $jsonresult->retval; + } + else + { + $return = true; + } } else {