This commit is contained in:
Paminger
2016-06-22 08:11:59 +02:00
18 changed files with 552 additions and 47 deletions
@@ -23,45 +23,20 @@ class Message extends APIv1_Controller
{
parent::__construct();
// Load model MessageModel
$this->load->model('system/message_model', 'MessageModel');
// Load set the uid of the model to let to check the permissions
$this->MessageModel->setUID($this->_getUID());
$this->load->library('MessageLib', array('uid' => $this->_getUID()));
}
/**
* @return void
*/
public function getMessage()
public function getMessagesByPersonID()
{
$messageID = $this->get('message_id');
$person_id = $this->get('person_id');
$all = $this->get('all');
if (isset($messageID))
if (isset($person_id))
{
$result = $this->MessageModel->load($messageID);
$this->response($result, REST_Controller::HTTP_OK);
}
else
{
$this->response();
}
}
/**
* @return void
*/
public function postMessage()
{
if ($this->_validate($this->post()))
{
if (isset($this->post()['message_id']))
{
$result = $this->MessageModel->update($this->post()['message_id'], $this->post());
}
else
{
$result = $this->MessageModel->insert($this->post());
}
$result = $this->messagelib->getMessagesByPerson($person_id, $all);
$this->response($result, REST_Controller::HTTP_OK);
}
@@ -71,8 +46,39 @@ class Message extends APIv1_Controller
}
}
private function _validate($message = NULL)
/**
* @return void
*/
public function postMessage()
{
if ($this->_validate($this->post()))
{
$this->messagelib->addRecipient($this->post()['person_id']);
$result = $this->messagelib->sendMessage(
$this->post()['person_id'],
$this->post()['subject'],
$this->post()['body'],
PRIORITY_NORMAL,
NULL,
$this->post()['oe_kurzbz']
);
$this->response($result, REST_Controller::HTTP_OK);
}
else
{
$this->response();
}
}
private function _validate($message = null)
{
if (!isset($message['person_id']) || !isset($message['subject']) ||
!isset($message['body']) || !isset($message['oe_kurzbz']))
{
return false;
}
return true;
}
}
+147
View File
@@ -0,0 +1,147 @@
<?php
if (! defined('BASEPATH')) exit('No direct script access allowed');
class Phrases extends FHC_Controller
{
public function __construct()
{
parent::__construct();
$this->load->library('PhrasesLib');
}
public function index()
{
$this->load->view('system/phrases.php');
}
public function table()
{
$phrases = $this->phraseslib->getPhraseByApp('aufnahme');
if ($phrases->error)
show_error($phrases->retval);
//var_dump($vorlage);
$data = array
(
'app' => 'aufnahme',
'phrases' => $phrases->retval
);
$v = $this->load->view('system/phrasesList.php', $data);
}
public function view($phrase_id = null)
{
if (empty($phrase_id))
exit;
$phrase_inhalt = $this->phraseslib->getPhraseInhalt($phrase_id);
if ($phrase_inhalt->error)
show_error($phrase_inhalt->retval);
//var_dump($vorlage);
$data = array
(
'phrase_id' => $phrase_id,
'phrase_inhalt' => $phrase_inhalt->retval
);
$v = $this->load->view('system/phrasesinhaltList.php', $data);
}
public function edit($phrase_id = null)
{
if (empty($phrase_id))
exit;
$phrase = $this->phraseslib->getPhrase($phrase_id);
//var_dump($vorlage);
if ($phrase->error)
show_error($phrase->retval);
if (count($phrase->retval) != 1)
show_error('Phrase nicht vorhanden! ID: '.$phrase_id);
$data = array
(
'phrase' => $phrase->retval[0]
);
//var_dump($data['message']);
$v = $this->load->view('system/phrasesEdit', $data);
}
public function write($vorlage_kurzbz = null)
{
$data = array
(
'subject' => 'TestSubject',
'body' => 'TestDevelopmentBodyText'
);
$v = $this->load->view('system/messageWrite', $data);
}
public function save()
{
$phrase_id = $this->input->post('phrase_id', TRUE);
$data['phrase'] = $this->input->post('phrase', TRUE);
$phrase = $this->phraseslib->savePhrase($phrase_id, $data);
if ($phrase->error)
show_error($phrase->retval);
$phrase_id = $phrase->retval;
redirect('/system/Phrases/edit/'.$phrase_id);
}
public function newText()
{
$vorlage_kurzbz = $this->input->post('vorlage_kurzbz', TRUE);
$data = array
(
'vorlage_kurzbz' => $vorlage_kurzbz,
'studiengang_kz' => 0,
'version' => 1,
'oe_kurzbz' => 'etw'
);
$vorlagetext = $this->vorlagelib->insertVorlagetext($data);
if ($vorlagetext->error)
show_error($vorlagetext->retval);
$vorlagestudiengang_id = $vorlagetext->retval;
redirect('/system/Templates/editText/'.$vorlagestudiengang_id);
}
public function editText($phrase_inhalt_id)
{
$phrase_inhalt = $this->phraseslib->getPhraseInhaltById($phrase_inhalt_id);
if ($phrase_inhalt->error)
show_error($phrase_inhalt->retval);
$data = $phrase_inhalt->retval[0];
$this->load->view('system/phraseinhaltEdit', $data);
}
public function saveText()
{
$phrase_inhalt_id = $this->input->post('phrase_inhalt_id', TRUE);
$data['orgeinheit_kurzbz'] = $this->input->post('oe_kurzbz', TRUE);
$data['text'] = $this->input->post('text', TRUE);
$data['description'] = $this->input->post('description', TRUE);
$data['sprache'] = $this->input->post('sprache', TRUE);
$phrase_inhalt = $this->phraseslib->updatePhraseInhalt($phrase_inhalt_id, $data);
if ($phrase_inhalt->error)
show_error($phrase_inhalt->retval);
$data['phrase_inhalt_id'] = $phrase_inhalt_id;
redirect('/system/Phrases/editText/'.$phrase_inhalt_id);
//$this->load->view('system/templatetextEdit', $data);
}
public function preview($vorlagestudiengang_id)
{
$formdata = $this->input->post('formdata', FALSE);
$daten = json_decode($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)
);
$this->load->view('system/templatetextPreview', $data);
}
}