mirror of
https://github.com/FH-Complete/FHC-Core.git
synced 2026-07-20 00:12:15 +00:00
- Changed config entry addons_aufnahme_url in fhcomplete.php. Now it's an array having an entry for each organisation unit root
- Changed redirectByToken method in controllers/Redirect, now: - Loads the root of the organisation unit tree using the oe_kurzbz present in the message, loaded using a token - Redirect to the related aufnahme using the organisation unit previously found - Changed method send in system/Messages, now retrives the oe_kurzbz of the recipients/prestudents to store these oe_kurzbz in the table tbl_msg_message (used by FAS) - Added method getRoot to library OrganisationseinheitLib to retrive the root of an organisation unit by the given oe_kurzbz - Added method getOrganisationunits to model crm/Prestudent_model, retrives the oe_kurzbz using the given prestudent/s id/s - Added some comments here and there
This commit is contained in:
@@ -243,4 +243,6 @@ $config['fhc_acl'] = array
|
||||
'PhrasesLib.getPhrase' => 'system/PhrasesLib'
|
||||
);
|
||||
|
||||
$config['addons_aufnahme_url'] = 'http://debian.dev/build/addons/aufnahme/cis/index.php';
|
||||
//
|
||||
$config['addons_aufnahme_url'] = array();
|
||||
$config['addons_aufnahme_url']['OE_ROOT'] = 'http://debian.dev/addons/aufnahme/OE_ROOT/cis/index.php';
|
||||
|
||||
@@ -25,13 +25,52 @@ class Redirect extends FHC_Controller
|
||||
|
||||
// Loads config file fhcomplete
|
||||
$this->config->load('fhcomplete');
|
||||
|
||||
// Loads message helper
|
||||
$this->load->helper('message');
|
||||
|
||||
// Loads model MessageTokenModel
|
||||
$this->load->model('system/MessageToken_model', 'MessageTokenModel');
|
||||
|
||||
// Loads library OrganisationseinheitLib
|
||||
$this->load->library('OrganisationseinheitLib');
|
||||
}
|
||||
|
||||
/**
|
||||
* redirectByToken
|
||||
*
|
||||
* - Loads the message using a token
|
||||
* - Loads the root of the organisation unit tree using the oe_kurzbz present in the message
|
||||
* - Redirect to the aufnahme related to the found organisation unit
|
||||
*/
|
||||
public function redirectByToken($token)
|
||||
{
|
||||
if (isset($token))
|
||||
$msg = $this->MessageTokenModel->getMessageByToken($token);
|
||||
if ($msg->error)
|
||||
{
|
||||
redirect($this->config->item('addons_aufnahme_url') . '?token=' . $token);
|
||||
show_error($msg->retval);
|
||||
}
|
||||
|
||||
$oe_kurzbz = $msg->retval[0]->oe_kurzbz;
|
||||
|
||||
if ($oe_kurzbz != null && $oe_kurzbz != '')
|
||||
{
|
||||
$rootOE = $this->organisationseinheitlib->getRoot($oe_kurzbz);
|
||||
if ($rootOE->error)
|
||||
{
|
||||
show_error($rootOE->retval);
|
||||
}
|
||||
|
||||
$addonAufnahmeUrls = $this->config->item('addons_aufnahme_url');
|
||||
|
||||
if (isset($token)
|
||||
&& hasData($msg)
|
||||
&& is_array($addonAufnahmeUrls)
|
||||
&& hasData($rootOE)
|
||||
&& isset($addonAufnahmeUrls[$rootOE->retval[0]->oe_kurzbz]))
|
||||
{
|
||||
redirect($addonAufnahmeUrls[$rootOE->retval[0]->oe_kurzbz] . '?token=' . $token);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,17 +27,17 @@ class Message extends APIv1_Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
* getMessagesByPersonID
|
||||
*/
|
||||
public function getMessagesByPersonID()
|
||||
{
|
||||
$person_id = $this->get('person_id');
|
||||
$all = $this->get('all');
|
||||
|
||||
|
||||
if (isset($person_id))
|
||||
{
|
||||
$result = $this->messagelib->getMessagesByPerson($person_id, $all);
|
||||
|
||||
|
||||
$this->response($result, REST_Controller::HTTP_OK);
|
||||
}
|
||||
else
|
||||
@@ -45,19 +45,19 @@ class Message extends APIv1_Controller
|
||||
$this->response();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return void
|
||||
* getMessagesByUID
|
||||
*/
|
||||
public function getMessagesByUID()
|
||||
{
|
||||
$uid = $this->get('uid');
|
||||
$all = $this->get('all');
|
||||
|
||||
|
||||
if (isset($uid))
|
||||
{
|
||||
$result = $this->messagelib->getMessagesByUID($uid, $all);
|
||||
|
||||
|
||||
$this->response($result, REST_Controller::HTTP_OK);
|
||||
}
|
||||
else
|
||||
@@ -65,18 +65,18 @@ class Message extends APIv1_Controller
|
||||
$this->response();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return void
|
||||
* getMessagesByToken
|
||||
*/
|
||||
public function getMessagesByToken()
|
||||
{
|
||||
$token = $this->get('token');
|
||||
|
||||
|
||||
if (isset($token))
|
||||
{
|
||||
$result = $this->messagelib->getMessageByToken($token);
|
||||
|
||||
|
||||
$this->response($result, REST_Controller::HTTP_OK);
|
||||
}
|
||||
else
|
||||
@@ -84,19 +84,19 @@ class Message extends APIv1_Controller
|
||||
$this->response();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return void
|
||||
* getSentMessagesByPerson
|
||||
*/
|
||||
public function getSentMessagesByPerson()
|
||||
{
|
||||
$person_id = $this->get('person_id');
|
||||
$all = $this->get('all');
|
||||
|
||||
|
||||
if (isset($person_id))
|
||||
{
|
||||
$result = $this->messagelib->getSentMessagesByPerson($person_id, $all);
|
||||
|
||||
|
||||
$this->response($result, REST_Controller::HTTP_OK);
|
||||
}
|
||||
else
|
||||
@@ -104,18 +104,18 @@ class Message extends APIv1_Controller
|
||||
$this->response();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return void
|
||||
* getCountUnreadMessages
|
||||
*/
|
||||
public function getCountUnreadMessages()
|
||||
{
|
||||
$person_id = $this->get('person_id');
|
||||
|
||||
|
||||
if (isset($person_id))
|
||||
{
|
||||
$result = $this->messagelib->getCountUnreadMessages($person_id);
|
||||
|
||||
|
||||
$this->response($result, REST_Controller::HTTP_OK);
|
||||
}
|
||||
else
|
||||
@@ -123,14 +123,14 @@ class Message extends APIv1_Controller
|
||||
$this->response();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return void
|
||||
* postMessage
|
||||
*/
|
||||
public function postMessage()
|
||||
{
|
||||
$validation = $this->_validatePostMessage($this->post());
|
||||
|
||||
|
||||
if (isSuccess($validation))
|
||||
{
|
||||
$result = $this->messagelib->sendMessage(
|
||||
@@ -140,10 +140,10 @@ class Message extends APIv1_Controller
|
||||
$this->post()['body'],
|
||||
PRIORITY_NORMAL,
|
||||
isset($this->post()['relationmessage_id']) ? $this->post()['relationmessage_id'] : null,
|
||||
isset($this->post()['oe_kurzbz']) ? $this->post()['oe_kurzbz'] : null,
|
||||
isset($this->post()['oe_kurzbz']) ? $this->post()['oe_kurzbz'] : null, // Sender organisation unit
|
||||
isset($this->post()['multiPartMime']) ? $this->post()['multiPartMime'] : true
|
||||
);
|
||||
|
||||
|
||||
$this->response($result, REST_Controller::HTTP_OK);
|
||||
}
|
||||
else
|
||||
@@ -151,27 +151,27 @@ class Message extends APIv1_Controller
|
||||
$this->response($validation, REST_Controller::HTTP_OK);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return void
|
||||
* postMessageVorlage
|
||||
*/
|
||||
public function postMessageVorlage()
|
||||
{
|
||||
$validation = $this->_validatePostMessageVorlage($this->post());
|
||||
|
||||
|
||||
if (isSuccess($validation))
|
||||
{
|
||||
$result = $this->messagelib->sendMessageVorlage(
|
||||
isset($this->post()['sender_id']) ? $this->post()['sender_id'] : null,
|
||||
isset($this->post()['receiver_id']) ? $this->post()['receiver_id'] : null,
|
||||
$this->post()['vorlage_kurzbz'],
|
||||
isset($this->post()['oe_kurzbz']) ? $this->post()['oe_kurzbz'] : null,
|
||||
isset($this->post()['oe_kurzbz']) ? $this->post()['oe_kurzbz'] : null, // Sender organisation unit
|
||||
$this->post()['data'],
|
||||
isset($this->post()['relationmessage_id']) ? $this->post()['relationmessage_id'] : null,
|
||||
isset($this->post()['orgform_kurzbz']) ? $this->post()['orgform_kurzbz'] : null,
|
||||
isset($this->post()['multiPartMime']) ? $this->post()['multiPartMime'] : true
|
||||
);
|
||||
|
||||
|
||||
$this->response($result, REST_Controller::HTTP_OK);
|
||||
}
|
||||
else
|
||||
@@ -179,16 +179,16 @@ class Message extends APIv1_Controller
|
||||
$this->response($validation, REST_Controller::HTTP_OK);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return void
|
||||
* postChangeStatus
|
||||
*/
|
||||
public function postChangeStatus()
|
||||
{
|
||||
$person_id = $this->post()['person_id'];
|
||||
$message_id = $this->post()['message_id'];
|
||||
$status = $this->post()['status'];
|
||||
|
||||
|
||||
if (isset($person_id) && isset($message_id) && isset($status) &&
|
||||
in_array($status, array(MSG_STATUS_UNREAD, MSG_STATUS_READ, MSG_STATUS_ARCHIVED, MSG_STATUS_DELETED)))
|
||||
{
|
||||
@@ -201,7 +201,10 @@ class Message extends APIv1_Controller
|
||||
$this->response();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* _validatePostMessage
|
||||
*/
|
||||
private function _validatePostMessage($message = null)
|
||||
{
|
||||
if (!isset($message))
|
||||
@@ -220,10 +223,13 @@ class Message extends APIv1_Controller
|
||||
{
|
||||
return error('If a receiver_id is not given a oe_kurzbz must be specified');
|
||||
}
|
||||
|
||||
|
||||
return success('Input data are valid');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* _validatePostMessageVorlage
|
||||
*/
|
||||
private function _validatePostMessageVorlage($message = null)
|
||||
{
|
||||
if (!isset($message))
|
||||
@@ -242,7 +248,7 @@ class Message extends APIv1_Controller
|
||||
{
|
||||
return error('If a receiver_id is not given a oe_kurzbz must be specified');
|
||||
}
|
||||
|
||||
|
||||
return success('Input data are valid');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,29 +2,32 @@
|
||||
|
||||
if (! defined('BASEPATH')) exit('No direct script access allowed');
|
||||
|
||||
class Messages extends VileSci_Controller
|
||||
class Messages extends VileSci_Controller
|
||||
{
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
|
||||
// Loads the message library
|
||||
$this->load->library('MessageLib');
|
||||
|
||||
|
||||
// Loads the widget library
|
||||
$this->load->library('WidgetLib');
|
||||
|
||||
|
||||
$this->load->model('person/Person_model', 'PersonModel');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* write
|
||||
*/
|
||||
public function write($sender_id, $msg_id = null, $receiver_id = null)
|
||||
{
|
||||
$prestudent_id = $this->input->post('prestudent_id');
|
||||
$msg = null;
|
||||
|
||||
|
||||
// Get message data if possible
|
||||
if (is_numeric($msg_id) && is_numeric($receiver_id))
|
||||
{
|
||||
@@ -38,7 +41,7 @@ class Messages extends VileSci_Controller
|
||||
$msg = $msg->retval[0];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Get variables
|
||||
$this->load->model('system/Message_model', 'MessageModel');
|
||||
$msgVarsDataByPrestudentId = $this->MessageModel->getMsgVarsDataByPrestudentId($prestudent_id);
|
||||
@@ -46,7 +49,7 @@ class Messages extends VileSci_Controller
|
||||
{
|
||||
show_error($msgVarsDataByPrestudentId->retval);
|
||||
}
|
||||
|
||||
|
||||
if (!hasData($variables = $this->MessageModel->getMessageVars()))
|
||||
{
|
||||
unset($variables);
|
||||
@@ -60,11 +63,11 @@ class Messages extends VileSci_Controller
|
||||
$variablesArray['{'.str_replace(" ", "_", strtolower($variables->retval[$i])).'}'] = $variables->retval[$i];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
array_shift($variables->retval); // Remove person_id
|
||||
array_shift($variables->retval); // Remove prestudent_id
|
||||
|
||||
// Organisation units
|
||||
|
||||
// Organisation units used to get the templates
|
||||
$oe_kurzbz = array(); // A person can have more organisation units
|
||||
$this->load->model('person/Benutzerfunktion_model', 'BenutzerfunktionModel');
|
||||
$benutzerResult = $this->BenutzerfunktionModel->getByPersonId($sender_id);
|
||||
@@ -75,7 +78,7 @@ class Messages extends VileSci_Controller
|
||||
$oe_kurzbz[] = $val->oe_kurzbz;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Admin or commoner?
|
||||
$this->load->model('system/Benutzerrolle_model', 'BenutzerrolleModel');
|
||||
$isAdmin = $this->BenutzerrolleModel->isAdminByPersonId($sender_id);
|
||||
@@ -83,38 +86,45 @@ class Messages extends VileSci_Controller
|
||||
{
|
||||
show_error($isAdmin->retval);
|
||||
}
|
||||
|
||||
|
||||
$data = array (
|
||||
'sender_id' => $sender_id,
|
||||
'receivers' => $msgVarsDataByPrestudentId->retval,
|
||||
'message' => $msg,
|
||||
'variables' => $variablesArray,
|
||||
'oe_kurzbz' => $oe_kurzbz,
|
||||
'oe_kurzbz' => $oe_kurzbz, // used to get the templates
|
||||
'isAdmin' => $isAdmin->retval
|
||||
);
|
||||
|
||||
|
||||
$v = $this->load->view('system/messageWrite', $data);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* send
|
||||
*/
|
||||
public function send($sender_id)
|
||||
{
|
||||
$error = false;
|
||||
|
||||
|
||||
$subject = $this->input->post('subject');
|
||||
$body = $this->input->post('body');
|
||||
$prestudents = $this->input->post('prestudents');
|
||||
$relationmessage_id = $this->input->post('relationmessage_id');
|
||||
|
||||
|
||||
if (!isset($relationmessage_id) || $relationmessage_id == '')
|
||||
{
|
||||
$relationmessage_id = null;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
$data = $this->MessageModel->getMsgVarsDataByPrestudentId($prestudents);
|
||||
if (hasData($data))
|
||||
|
||||
//
|
||||
$this->load->model('crm/Prestudent_model', 'PrestudentModel');
|
||||
$prestudentsData = $this->PrestudentModel->getOrganisationunits($prestudents);
|
||||
|
||||
//
|
||||
if (hasData($data) && hasData($prestudentsData))
|
||||
{
|
||||
for ($i = 0; $i < count($data->retval); $i++)
|
||||
{
|
||||
@@ -125,10 +135,19 @@ class Messages extends VileSci_Controller
|
||||
$newKey = str_replace(" ", "_", strtolower($key));
|
||||
$dataArray[$newKey] = $dataArray[$key];
|
||||
}
|
||||
|
||||
|
||||
$parsedText = $this->messagelib->parseMessageText($body, $dataArray);
|
||||
|
||||
$msg = $this->messagelib->sendMessage($sender_id, $dataArray['person_id'], $subject, $parsedText, PRIORITY_NORMAL, $relationmessage_id);
|
||||
|
||||
$oe_kurzbz = '';
|
||||
for ($p = 0; $p < count($prestudentsData->retval); $p++)
|
||||
{
|
||||
if ($prestudentsData->retval[$p]->prestudent_id == $data->retval[$i]->prestudent_id)
|
||||
{
|
||||
$oe_kurzbz = $prestudentsData->retval[$p]->oe_kurzbz;
|
||||
}
|
||||
}
|
||||
|
||||
$msg = $this->messagelib->sendMessage($sender_id, $dataArray['person_id'], $subject, $parsedText, PRIORITY_NORMAL, $relationmessage_id, $oe_kurzbz);
|
||||
if ($msg->error)
|
||||
{
|
||||
show_error($msg->retval);
|
||||
@@ -137,20 +156,20 @@ class Messages extends VileSci_Controller
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (!$error)
|
||||
{
|
||||
echo "Messages sent successfully";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* getPersonId
|
||||
*/
|
||||
private function getPersonId()
|
||||
{
|
||||
$person_id = null;
|
||||
|
||||
|
||||
if ($this->input->get('person_id') !== null)
|
||||
{
|
||||
$person_id = $this->input->get('person_id');
|
||||
@@ -159,45 +178,45 @@ class Messages extends VileSci_Controller
|
||||
{
|
||||
$person_id = $this->input->get('person_id');
|
||||
}
|
||||
|
||||
|
||||
if (!is_numeric($person_id))
|
||||
{
|
||||
show_error('Person_id is not numeric');
|
||||
}
|
||||
|
||||
|
||||
return $person_id;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* getVorlage
|
||||
*/
|
||||
public function getVorlage()
|
||||
{
|
||||
$vorlage_kurzbz = $this->input->get('vorlage_kurzbz');
|
||||
|
||||
|
||||
if (isset($vorlage_kurzbz))
|
||||
{
|
||||
$this->load->model('system/Vorlagestudiengang_model', 'VorlagestudiengangModel');
|
||||
$result = $this->VorlagestudiengangModel->loadWhere(array('vorlage_kurzbz' => $vorlage_kurzbz));
|
||||
|
||||
|
||||
$this->output
|
||||
->set_content_type('application/json')
|
||||
->set_output(json_encode($result));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* parseMessageText
|
||||
*/
|
||||
public function parseMessageText()
|
||||
{
|
||||
$prestudent_id = $this->input->get('prestudent_id');
|
||||
$text = $this->input->get('text');
|
||||
|
||||
|
||||
if (isset($prestudent_id))
|
||||
{
|
||||
$data = $this->MessageModel->getMsgVarsDataByPrestudentId($prestudent_id);
|
||||
|
||||
|
||||
$parsedText = "";
|
||||
if (hasData($data))
|
||||
{
|
||||
@@ -207,13 +226,13 @@ class Messages extends VileSci_Controller
|
||||
$newKey = str_replace(" ", "_", strtolower($key));
|
||||
$dataArray[$newKey] = $dataArray[$key];
|
||||
}
|
||||
|
||||
|
||||
$parsedText = $this->messagelib->parseMessageText($text, $dataArray);
|
||||
}
|
||||
|
||||
|
||||
$this->output
|
||||
->set_content_type('application/json')
|
||||
->set_output(json_encode($parsedText));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,14 +10,14 @@ class OrganisationseinheitLib
|
||||
public function __construct()
|
||||
{
|
||||
$this->ci =& get_instance();
|
||||
|
||||
|
||||
// Loads model Organisationseinheit_model
|
||||
$this->ci->load->model('organisation/Organisationseinheit_model', 'OrganisationseinheitModel');
|
||||
|
||||
|
||||
// Loads helper message to manage returning messages
|
||||
$this->ci->load->helper('Message');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* treeSearch
|
||||
*
|
||||
@@ -54,7 +54,7 @@ class OrganisationseinheitLib
|
||||
}
|
||||
|
||||
$result = $this->ci->OrganisationseinheitModel->getOneLevel($schema, $table, $select, $where, $orderby, $oe_kurzbz);
|
||||
|
||||
|
||||
if (hasData($result))
|
||||
{
|
||||
if ($result->retval[0]->_ppk != null && $result->retval[0]->oe_kurzbz == null)
|
||||
@@ -62,12 +62,14 @@ class OrganisationseinheitLib
|
||||
return $this->treeSearch($schema, $table, $select, $where, $orderby, $result->retval[0]->_ppk);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* treeSearchEntire
|
||||
*
|
||||
* Like tree search, but it returns all the results found while travelling through the tree structure
|
||||
*/
|
||||
public function treeSearchEntire($table, $alias, $fields, $where, $orderby, $oe_kurzbz)
|
||||
{
|
||||
@@ -89,13 +91,13 @@ class OrganisationseinheitLib
|
||||
}
|
||||
|
||||
$result = $this->ci->OrganisationseinheitModel->getOneLevelAlias($table, $alias, $select, $where, $orderby, $oe_kurzbz);
|
||||
|
||||
|
||||
if (hasData($result))
|
||||
{
|
||||
if ($result->retval[0]->_pk != null && $result->retval[0]->_ppk != null && $result->retval[0]->_jtpk != null)
|
||||
{
|
||||
$tmpResult = $this->treeSearchEntire($table, $alias, $select, $where, $orderby, $result->retval[0]->_ppk);
|
||||
|
||||
|
||||
if (hasData($tmpResult)
|
||||
&& $tmpResult->retval[0]->_pk != null
|
||||
&& $tmpResult->retval[0]->_ppk != null
|
||||
@@ -109,7 +111,25 @@ class OrganisationseinheitLib
|
||||
$result = $this->treeSearchEntire($table, $alias, $select, $where, $orderby, $result->retval[0]->_ppk);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* getRoot - Get the root of the organisation unit tree which belongs the given organisation unit parameter
|
||||
*/
|
||||
public function getRoot($oe_kurzbz)
|
||||
{
|
||||
$result = $this->ci->OrganisationseinheitModel->load($oe_kurzbz);
|
||||
|
||||
if (hasData($result))
|
||||
{
|
||||
if ($result->retval[0]->oe_parent_kurzbz != null)
|
||||
{
|
||||
$result = $this->getRoot($result->retval[0]->oe_parent_kurzbz);
|
||||
}
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -88,7 +88,7 @@ class Prestudent_model extends DB_Model
|
||||
)
|
||||
{
|
||||
if (isError($ent = $this->isEntitled($this->dbTable, PermissionLib::SELECT_RIGHT, FHC_NORIGHT, FHC_MODEL_ERROR))) return $ent;
|
||||
|
||||
|
||||
$this->addSelect(
|
||||
'p.person_id,
|
||||
prestudent_id,
|
||||
@@ -179,4 +179,17 @@ class Prestudent_model extends DB_Model
|
||||
|
||||
return $this->loadWhere($parametersArray);
|
||||
}
|
||||
|
||||
/**
|
||||
* getOrganisationunits
|
||||
*/
|
||||
public function getOrganisationunits($prestudent_id)
|
||||
{
|
||||
$query = 'SELECT p.prestudent_id, s.oe_kurzbz
|
||||
FROM public.tbl_prestudent p
|
||||
INNER JOIN public.tbl_studiengang s USING(studiengang_kz)
|
||||
WHERE prestudent_id %s ?';
|
||||
|
||||
return $this->execQuery(sprintf($query, is_array($prestudent_id) ? 'IN' : '='), array($prestudent_id));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
class Organisationseinheit_model extends DB_Model
|
||||
{
|
||||
/**
|
||||
@@ -11,6 +12,9 @@ class Organisationseinheit_model extends DB_Model
|
||||
$this->pk = 'oe_kurzbz';
|
||||
}
|
||||
|
||||
/**
|
||||
* getRecursiveList
|
||||
*/
|
||||
public function getRecursiveList($typ = null)
|
||||
{
|
||||
$qry = "WITH RECURSIVE tree (oe_kurzbz, bezeichnung, path, organisationseinheittyp_kurzbz) AS (
|
||||
@@ -31,17 +35,17 @@ class Organisationseinheit_model extends DB_Model
|
||||
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);
|
||||
}
|
||||
|
||||
@@ -78,12 +82,15 @@ class Organisationseinheit_model extends DB_Model
|
||||
) _joined_table ON (orgs._pk = _joined_table._pk)
|
||||
WHERE orgs._pk = ?
|
||||
ORDER BY %s";
|
||||
|
||||
|
||||
$query = sprintf($query, $table, $fields, $schema, $table, $where, $orderby);
|
||||
|
||||
|
||||
return $this->execQuery($query, array($oe_kurzbz));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* getOneLevelAlias
|
||||
*/
|
||||
public function getOneLevelAlias($table, $alias, $fields, $where, $orderby, $oe_kurzbz)
|
||||
{
|
||||
$query = "WITH RECURSIVE organizations(_pk, _ppk) AS
|
||||
@@ -103,9 +110,9 @@ class Organisationseinheit_model extends DB_Model
|
||||
) _joined_table ON (orgs._pk = _joined_table._jtpk)
|
||||
WHERE orgs._pk = ?
|
||||
ORDER BY %s";
|
||||
|
||||
|
||||
$query = sprintf($query, $alias, $fields, $table, $where, $orderby);
|
||||
|
||||
|
||||
return $this->execQuery($query, array($oe_kurzbz));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user