- Fixed Fallback if Vorlage doesnt exist

- Added Additional Parameters to Message
This commit is contained in:
oesi
2016-08-19 11:31:30 +02:00
parent b46692913c
commit edb60ef17b
2 changed files with 50 additions and 29 deletions
+21 -21
View File
@@ -1,4 +1,4 @@
<?php
<?php
if (! defined('BASEPATH')) exit('No direct script access allowed');
/**
@@ -10,19 +10,19 @@ if (! defined('BASEPATH')) exit('No direct script access allowed');
class VorlageLib
{
private $recipients = array();
public function __construct()
{
require_once APPPATH.'config/message.php';
$this->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
*
+29 -8
View File
@@ -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
{