diff --git a/application/controllers/system/Messages.php b/application/controllers/system/Messages.php index d11eed4e1..4be3a0e78 100755 --- a/application/controllers/system/Messages.php +++ b/application/controllers/system/Messages.php @@ -16,105 +16,32 @@ class Messages extends VileSci_Controller $this->load->model('person/Person_model', 'PersonModel'); } - - public function index() - { - $this->load->view('system/messages.php', array('person_id' => $this->getPersonId())); - } - - public function inbox($person_id) - { - $msg = $this->messagelib->getMessagesByPerson($person_id); - if ($msg->error) - { - show_error($msg->retval); - } - - $person = $this->PersonModel->load($person_id); - if ($person->error) - { - show_error($person->retval); - } - - $data = array ( - 'messages' => $msg->retval, - 'person' => $person->retval[0] - ); - - $this->load->view('system/messagesInbox.php', $data); - } - - public function outbox($person_id) - { - $msg = $this->messagelib->getSentMessagesByPerson($person_id); - if ($msg->error) - { - show_error($msg->retval); - } - - $person = $this->PersonModel->load($person_id); - if ($person->error) - { - show_error($person->retval); - } - - $data = array ( - 'messages' => $msg->retval, - 'person' => $person->retval[0] - ); - - $this->load->view('system/messagesOutbox.php', $data); - } - public function view($msg_id, $person_id) - { - $msg = $this->messagelib->getMessage($msg_id, $person_id); - if ($msg->error) - { - show_error($msg->retval); - } - - $v = $this->load->view('system/messageView', array('message' => $msg->retval[0])); - } - - public function reply($msg_id, $person_id) - { - $msg = $this->messagelib->getMessage($msg_id, $person_id); - if ($msg->error) - { - show_error($msg->retval); - } - - $v = $this->load->view('system/messageReply', array('message' => $msg->retval[0])); - } - - public function sendReply($msg_id, $person_id) - { - $subject = $this->input->post('subject'); - $body = $this->input->post('body'); - - $this->load->model('system/Message_model', 'MessageModel'); - $originMsg = $this->MessageModel->load($msg_id); - if ($originMsg->error) - { - show_error($originMsg->retval); - } - - $msg = $this->messagelib->sendMessage($person_id, $originMsg->retval[0]->person_id, $subject, $body, PRIORITY_NORMAL, $msg_id); - if ($msg->error) - { - show_error($msg->retval); - } - - redirect('/system/Messages/view/' . $msg->retval . '/' . $originMsg->retval[0]->person_id); - } - - public function write($sender_id) + /** + * + */ + 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)) + { + $msg = $this->messagelib->getMessage($msg_id, $receiver_id); + if ($msg->error) + { + show_error($msg->retval); + } + else + { + $msg = $msg->retval[0]; + } + } + + // Get variables $this->load->model('crm/Prestudent_model', 'PrestudentModel'); - $prestudent = $this->MessageModel->getMsgVarsData($prestudent_id); + $prestudent = $this->MessageModel->getMsgVarsDataByPrestudentId($prestudent_id); if ($prestudent->error) { show_error($prestudent->retval); @@ -141,12 +68,16 @@ class Messages extends VileSci_Controller $data = array ( 'sender_id' => $sender_id, 'receivers' => $prestudent->retval, + 'message' => $msg, 'variables' => $variablesArray ); $v = $this->load->view('system/messageWrite', $data); } + /** + * + */ public function send($sender_id) { $error = false; @@ -154,7 +85,14 @@ class Messages extends VileSci_Controller $subject = $this->input->post('subject'); $body = $this->input->post('body'); $prestudents = $this->input->post('prestudents'); - $data = $this->MessageModel->getMsgVarsData($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)) { for ($i = 0; $i < count($data->retval); $i++) @@ -169,7 +107,7 @@ class Messages extends VileSci_Controller $parsedText = $this->messagelib->parseMessageText($body, $dataArray); - $msg = $this->messagelib->sendMessage($sender_id, $dataArray['person_id'], $subject, $parsedText, PRIORITY_NORMAL); + $msg = $this->messagelib->sendMessage($sender_id, $dataArray['person_id'], $subject, $parsedText, PRIORITY_NORMAL, $relationmessage_id); if ($msg->error) { show_error($msg->retval); @@ -185,6 +123,9 @@ class Messages extends VileSci_Controller } } + /** + * + */ private function getPersonId() { $person_id = null; @@ -206,6 +147,9 @@ class Messages extends VileSci_Controller return $person_id; } + /** + * + */ public function getVorlage() { $vorlage_kurzbz = $this->input->get('vorlage_kurzbz'); @@ -221,6 +165,9 @@ class Messages extends VileSci_Controller } } + /** + * + */ public function parseMessageText() { $prestudent_id = $this->input->get('prestudent_id'); @@ -228,7 +175,7 @@ class Messages extends VileSci_Controller if (isset($prestudent_id)) { - $data = $this->MessageModel->getMsgVarsData($prestudent_id); + $data = $this->MessageModel->getMsgVarsDataByPrestudentId($prestudent_id); $parsedText = ""; if (hasData($data)) diff --git a/application/helpers/fhc_helper.php b/application/helpers/fhc_helper.php index b76e2041d..c2832d55d 100644 --- a/application/helpers/fhc_helper.php +++ b/application/helpers/fhc_helper.php @@ -62,3 +62,17 @@ function generateToken($length = 64) $token .= $characters[mt_rand(0, $charactersLength)]; return $token; } + +/** + * var_dump_to_error_log() + * Gets the output of the var_dump function and print it out + * via the error log. It also removes the end line characters + */ +function var_dump_to_error_log($parameter) +{ + ob_start(); + var_dump($parameter); + $ob_get_contents = ob_get_contents(); + ob_end_clean(); + error_log(str_replace("\n", '', $ob_get_contents)); +} \ No newline at end of file diff --git a/application/libraries/PermissionLib.php b/application/libraries/PermissionLib.php index dd0b2242a..662130c42 100644 --- a/application/libraries/PermissionLib.php +++ b/application/libraries/PermissionLib.php @@ -29,34 +29,34 @@ class PermissionLib const INSERT_RIGHT = 'i'; const DELETE_RIGHT = 'd'; const REPLACE_RIGHT = 'ui'; - + private $bb; // benutzerberechtigung private $acl; // conversion array from a source to a permission - + /** - * + * */ function __construct() { // Loads CI instance $this->ci =& get_instance(); - + // Loads the library to manage the rights system //$this->ci->load->library('FHC_DB_ACL'); - + // Loads the auth helper $this->ci->load->helper('fhcauth'); - + // Loads the array of resources $this->acl = $this->ci->config->item('fhc_acl'); - - // + + // $this->bb = new benutzerberechtigung(); } - + /** * Check if the user is entitled to get access to a source with the given access type - * + * * @return bool true if a user has the right to access to the specified * resource with a specified permission type, false otherwise */ @@ -74,7 +74,7 @@ class PermissionLib return false; } } - + /** * Get a permission by a given source */ @@ -89,16 +89,25 @@ class PermissionLib return null; } } - + /** - * + * */ private function isBerechtigt($berechtigung_kurzbz, $art = null, $oe_kurzbz = null, $kostenstelle_id = null) { if (!is_null($berechtigung_kurzbz)) { $this->bb->getBerechtigungen(getAuthUID()); - return $this->bb->isBerechtigt($berechtigung_kurzbz, $oe_kurzbz, $art, $kostenstelle_id); + if($this->bb->isBerechtigt($berechtigung_kurzbz, $oe_kurzbz, $art, $kostenstelle_id)) + { + log_message('debug','Permission '.$berechtigung_kurzbz.' granted'); + return true; + } + else + { + log_message('debug','Permission '.$berechtigung_kurzbz.' failed'); + return false; + } } else { diff --git a/application/libraries/ReihungstestLib.php b/application/libraries/ReihungstestLib.php index 6d6960240..4030e50c3 100644 --- a/application/libraries/ReihungstestLib.php +++ b/application/libraries/ReihungstestLib.php @@ -23,7 +23,14 @@ class ReihungstestLib */ public function insertPersonReihungstest($ddReihungstest) { - return $this->ci->RtPersonModel->insert($ddReihungstest); + if (isset($ddReihungstest['rt_id']) && $this->checkAvailability($ddReihungstest['rt_id'])) + { + return $this->ci->RtPersonModel->insert($ddReihungstest); + } + else + { + return error('This test is not more available'); + } } /** @@ -62,4 +69,19 @@ class ReihungstestLib return $this->ci->ReihungstestModel->loadWhere($parametersArray); } + + /** + * It checks if the test is available + */ + public function checkAvailability($reihungstest_id) + { + $result = $this->ci->ReihungstestModel->checkAvailability($reihungstest_id); + + if (hasData($result)) + { + return true; + } + + return false; + } } \ No newline at end of file diff --git a/application/models/crm/Reihungstest_model.php b/application/models/crm/Reihungstest_model.php index 46e8702cc..a8d048463 100644 --- a/application/models/crm/Reihungstest_model.php +++ b/application/models/crm/Reihungstest_model.php @@ -11,4 +11,31 @@ class Reihungstest_model extends DB_Model $this->dbTable = 'public.tbl_reihungstest'; $this->pk = 'reihungstest_id'; } + + /** + * Gets a test from a test id only if it is available + */ + public function checkAvailability($reihungstest_id) + { + $query = 'SELECT public.tbl_reihungstest.* + FROM public.tbl_reihungstest LEFT JOIN public.tbl_rt_studienplan USING(reihungstest_id) + WHERE tbl_reihungstest.oeffentlich = TRUE + AND tbl_reihungstest.datum > NOW() + AND tbl_reihungstest.anmeldefrist >= NOW() + AND COALESCE ( + tbl_reihungstest.max_teilnehmer, + ( + SELECT SUM(arbeitsplaetze) + FROM public.tbl_ort JOIN public.tbl_rt_ort USING(ort_kurzbz) + WHERE rt_id = tbl_reihungstest.reihungstest_id + ) + ) - ( + SELECT COUNT(*) + FROM public.tbl_rt_person + WHERE rt_id = tbl_reihungstest.reihungstest_id + ) > 0 + AND reihungstest_id = ?'; + + return $this->execQuery($query, array($reihungstest_id)); + } } \ No newline at end of file diff --git a/application/models/system/Message_model.php b/application/models/system/Message_model.php index bc59bb24a..0cb3162c2 100644 --- a/application/models/system/Message_model.php +++ b/application/models/system/Message_model.php @@ -87,7 +87,7 @@ class Message_model extends DB_Model /** * */ - public function getMsgVarsData($prestudent_id) + public function getMsgVarsDataByPrestudentId($prestudent_id) { $query = 'SELECT * FROM public.vw_msg_vars WHERE prestudent_id %s ?'; diff --git a/application/views/system/messageReply.php b/application/views/system/messageReply.php deleted file mode 100644 index ea98f56fd..000000000 --- a/application/views/system/messageReply.php +++ /dev/null @@ -1,65 +0,0 @@ -load->view("templates/header", array("title" => "MessageReply", "jquery" => true, "tinymce" => true)); ?> - - - -
- -
-
- To: uid . " " . $message->vorname . " " . $message->nachname . " " . $message->kontakt; ?>
- Subject:
- -
-
- -
-
- -            - widgetlib->widget( - 'Vorlage_widget', - null, - array('name' => 'vorlage', 'id' => 'vorlageDnD') - ); - ?> -
-
- -
- - - - diff --git a/application/views/system/messageView.php b/application/views/system/messageView.php deleted file mode 100644 index ea5411a20..000000000 --- a/application/views/system/messageView.php +++ /dev/null @@ -1,34 +0,0 @@ -load->view('templates/header'); ?> - - - - -
-
-

- From: uid . " " . $message->vorname . " " . $message->nachname . " " . $message->kontakt; ?>
- Subject: subject; ?>
-

- -
-
- -
-
- -
-
- - - - diff --git a/application/views/system/messageWrite.php b/application/views/system/messageWrite.php index 193403e88..84757b5cc 100644 --- a/application/views/system/messageWrite.php +++ b/application/views/system/messageWrite.php @@ -1,10 +1,13 @@ load->view("templates/header", array("title" => "MessageReply", "jquery" => true, "tinymce" => true)); ?> + +
+
@@ -33,15 +36,30 @@ Subject:  - + subject; + } + ?> +
+
Message:
- + body; + } + ?> +
  @@ -142,8 +160,16 @@ } ?> + + + + - - \ No newline at end of file + + + +load->view("templates/footer"); ?> \ No newline at end of file diff --git a/application/views/system/messages.php b/application/views/system/messages.php deleted file mode 100644 index 1ba29c04a..000000000 --- a/application/views/system/messages.php +++ /dev/null @@ -1,20 +0,0 @@ - - - - - VileSci - Messages - - - - - - - - <body bgcolor="#FFFFFF"> - This application works only with a frames-enabled browser.<br /> - <a href="MessagesList">Use without frames</a> - </body> - - - - diff --git a/application/views/system/messagesInbox.php b/application/views/system/messagesInbox.php deleted file mode 100644 index 88a1b595d..000000000 --- a/application/views/system/messagesInbox.php +++ /dev/null @@ -1,57 +0,0 @@ -load->view('templates/header', array('title' => 'MessagesList', 'tablesort' => true, 'tableid' => 't1', 'headers' => '4:{sorter:false}')); ?> - -
-
-

- Inbox vorname . " " . $person->nachname; ?> -
-
- -
-
-

-
- Person - -
- - - - - - - - - - - - - - - - - message_id . "/" . $person->person_id; - ?> - - - - - - - - - - - - - -
MessageIDSenderErstelltPrioritätStatusStatusInfoOERelation
message_id; ?>titelpost.' '.$m->vorname.' '.$m->nachname.' '.$m->titelpre; ?>insertamum; ?>priority; ?>status; ?>statusinfo; ?>oe_kurzbz; ?>relationmessage_id; ?>View
-
-
- - diff --git a/application/views/system/messagesOutbox.php b/application/views/system/messagesOutbox.php deleted file mode 100644 index a4bcad7dc..000000000 --- a/application/views/system/messagesOutbox.php +++ /dev/null @@ -1,57 +0,0 @@ -load->view('templates/header', array('title' => 'MessagesList', 'tablesort' => true, 'tableid' => 't1', 'headers' => '4:{sorter:false}')); ?> - -
-
-

- Outbox vorname . " " . $person->nachname; ?> -
-
- -
-
-

-
- Person - -
- - - - - - - - - - - - - - - - - message_id . "/" . $person->person_id; - ?> - - - - - - - - - - - - - -
MessageIDSenderErstelltPrioritätStatusStatusInfoOERelation
message_id; ?>titelpost.' '.$m->vorname.' '.$m->nachname.' '.$m->titelpre; ?>insertamum; ?>priority; ?>status; ?>statusinfo; ?>oe_kurzbz; ?>relationmessage_id; ?>View
-
-
- - diff --git a/cis/private/lehre/moodle_choice.php b/cis/private/lehre/moodle_choice.php index 75d717105..3ff9ce425 100644 --- a/cis/private/lehre/moodle_choice.php +++ b/cis/private/lehre/moodle_choice.php @@ -27,6 +27,7 @@ require_once('../../../include/moodle.class.php'); require_once('../../../include/moodle19_course.class.php'); require_once('../../../include/moodle24_course.class.php'); require_once('../../../include/phrasen.class.php'); +require_once('../../../include/lehreinheit.class.php'); if (!$db = new basis_db()) die('Fehler beim Herstellen der Datenbankverbindung'); @@ -37,15 +38,15 @@ $p = new phrasen(getSprache()); if(isset($_GET['lvid'])) $lvid=$_GET['lvid']; -else +else die('lvid muss uebergeben werden'); - + if(isset($_GET['stsem'])) $stsem = $_GET['stsem']; -else +else die('Es wurde kein Studiensemester uebergeben'); - -echo ' + +echo ' @@ -53,39 +54,74 @@ echo '

'.$p->t('moodle/kursUebersicht').'

- - - - - -
'; +'; $moodle = new moodle(); $moodle->getAll($lvid, $stsem); +$meinekurse = ''; +$allgemeinekurse = ''; + foreach ($moodle->result as $row) { + $kurs = ''; switch($row->moodle_version) { case '1.9': $mdlcourse19=new moodle19_course(); $mdlcourse19->load($row->mdl_course_id); - echo "$mdlcourse19->mdl_fullname
"; + $bezeichnung = $mdlcourse19->mdl_fullname; + if($bezeichnung=='') + $bezeichnung = 'Course '.$row->mdl_course_id; + $kurs = "$bezeichnung
"; break; case '2.4': $mdlcourse24=new moodle24_course(); $mdlcourse24->load($row->mdl_course_id); - echo "$mdlcourse24->mdl_fullname
"; + $bezeichnung = $mdlcourse24->mdl_fullname; + if($bezeichnung=='') + $bezeichnung = 'Course '.$row->mdl_course_id; + $kurs = "$bezeichnung
"; break; default: - echo $p->t('moodle/ungueltigeVersion',array($row->moodle_version)).'
'; + $kurs = $p->t('moodle/ungueltigeVersion',array($row->moodle_version)).'
'; break; } + if($row->lehreinheit_id!='') + { + $le = new lehreinheit(); + $stud = $le->getStudenten($row->lehreinheit_id); + $zugeordnet = false; + + foreach($stud as $row_stud) + { + if($row_stud->uid == $user) + { + $zugeordnet = true; + break; + } + } + + if($zugeordnet) + { + $meinekurse .= $kurs; + } + } + $allgemeinekurse .= $kurs; } -echo '
- +if($meinekurse!='') +{ + echo '

'.$p->t('moodle/meineKurse').'

'; + echo $meinekurse; +} + +echo '

'.$p->t('moodle/vorhandeneKurse').'

'; + +echo $allgemeinekurse; + +echo ' '; ?> diff --git a/content/messages.js.php b/content/messages.js.php index be39d3a73..e61108eb6 100644 --- a/content/messages.js.php +++ b/content/messages.js.php @@ -24,6 +24,7 @@ var MessagePersonID=null; var MessagesTreeDatasource=''; // Datasource des Adressen Trees var MessagesSelectID=''; var MessageSenderPersonID=''; +var MessageIFrameIsInitialized=false; var MessagesTreeSinkObserver = { @@ -102,9 +103,9 @@ function MessagesNewMessage() else { var prestudentIdArray = getMultipleTreeCellText(tree, 'student-treecol-prestudent_id'); - + var action = 'index.ci.php/system/Messages/write/' + MessageSenderPersonID; - + openWindowPostArray(action, 'prestudent_id', prestudentIdArray); } } @@ -114,16 +115,22 @@ function MessagesNewMessage() */ function MessagesSendAnswer() { - var tree=document.getElementById('messages-tree'); - if(tree.currentIndex==-1) + var messagesTree = document.getElementById('messages-tree'); + var studentsTree = parent.document.getElementById('student-tree'); + + if (messagesTree.currentIndex == -1) { alert("Bitte markieren Sie zuerst eine Nachricht"); } else { - var MessageId = getTreeCellText(tree, 'messages-tree-message_id', tree.currentIndex); - var RecipientID = getTreeCellText(tree, 'messages-tree-recipient_id', tree.currentIndex); - window.open('index.ci.php/system/Messages/reply/'+MessageId+'/'+RecipientID,'Reply',''); + var MessageId = getTreeCellText(messagesTree, 'messages-tree-message_id', messagesTree.currentIndex); + var RecipientID = getTreeCellText(messagesTree, 'messages-tree-recipient_id', messagesTree.currentIndex); + var prestudentIdArray = new Array(getTreeCellText(studentsTree, 'student-treecol-prestudent_id', studentsTree.currentIndex)); + + var action = 'index.ci.php/system/Messages/write/' + MessageSenderPersonID + '/' + MessageId + '/' + RecipientID; + + openWindowPostArray(action, 'prestudent_id', prestudentIdArray); } } @@ -150,5 +157,35 @@ function MessageAuswahl() document.getElementById('messages-button-answer').disabled=false; } } - document.getElementById('message-wysiwyg').value=text; + + MessagesIFrameSetHTML(text); } + +function MessagesIFrameSetHTML(val) +{ + MessageIFrameInit(); + netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); + editor = document.getElementById('message-wysiwyg'); + + if(editor.contentWindow.document.body.innerHTML!='') + { + //Inhalt leeren + editor.contentDocument.execCommand("selectall", false, null); + editor.contentDocument.execCommand("delete", false, null); + } + //Value setzen + if(val!='') + editor.contentDocument.execCommand("inserthtml", false, val); +} + +function MessageIFrameInit() +{ + if(!MessageIFrameIsInitialized) + { + netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); + editor = document.getElementById('message-wysiwyg'); + editor.contentDocument.designMode = 'on'; + editor.style.backgroundColor="#FFFFFF"; + MessageIFrameIsInitialized=true; + } +} \ No newline at end of file diff --git a/content/messages.xul.php b/content/messages.xul.php index 106fb7104..35e279c1d 100644 --- a/content/messages.xul.php +++ b/content/messages.xul.php @@ -73,7 +73,7 @@ echo ']>