creating lvMenu with Event hooks WIP

This commit is contained in:
SimonGschnell
2024-07-04 15:37:50 +02:00
parent 2a7735bca5
commit 79ffc1c077
5 changed files with 109 additions and 0 deletions
+2
View File
@@ -3,6 +3,8 @@ if (! defined('BASEPATH')) exit('No direct script access allowed');
use CI3_Events as Events;
// build the menu for fhc
/**
* NOTE(chris): example:
Events::on('stv_conf_student', function (&$res) {
@@ -0,0 +1,87 @@
<?php
/**
* Copyright (C) 2024 fhcomplete.org
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
if (! defined('BASEPATH')) exit('No direct script access allowed');
use CI3_Events as Events;
/**
* This controller operates between (interface) the JS (GUI) and the SearchBarLib (back-end)
* Provides data to the ajax get calls about the searchbar component
* This controller works with JSON calls on the HTTP GET and the output is always JSON
*/
class LvMenu extends FHCAPI_Controller
{
/**
* Object initialization
*/
public function __construct()
{
// NOTE(chris): additional permission checks will be done in SearchBarLib
parent::__construct([
'getLvMenu' => self::PERM_LOGGED
]);
}
//------------------------------------------------------------------------------------------------------------------
// Public methods
/**
* Gets a JSON body via HTTP POST and provides the parameters
*/
public function getLvMenu($lvid, $studiensemester_kurzbz)
{
if(!isset($lvid) || !isset($studiensemester_kurzbz))
$this->terminateWithError('Missing parameters', self::ERROR_TYPE_GENERAL);
$menu = array();
// get the menu of the fhc core, look menu_lv.class.php
//todo
require_once(FHCPATH.'config/cis.config.inc.php');
require_once(FHCPATH.'include/lehrveranstaltung.class.php');
require_once(FHCPATH.'include/studiensemester.class.php');
require_once(FHCPATH.'include/lehreinheit.class.php');
require_once(FHCPATH.'include/vertrag.class.php');
require_once(FHCPATH.'include/functions.inc.php');
require_once(FHCPATH.'include/benutzerberechtigung.class.php');
require_once(FHCPATH.'include/studiengang.class.php');
require_once(FHCPATH.'include/phrasen.class.php');
Events::trigger('lvMenuBuild',
// callback function for the onEvents to add newValues to the $menu
function ($newValue) use (&$menu) {
$menu[]= $newValue;
},
$lvid,
$studiensemester_kurzbz
);
$this->terminateWithSuccess($menu);
}
}
+5
View File
@@ -46,6 +46,11 @@ class CI3_Events
* NOTE(chris): Autoload Events config
*/
require_once(APPPATH.'config/Events.php');
foreach (scandir(APPPATH.'config/extensions') as $dir)
if ($dir[0] != '.' && file_exists(APPPATH.'config/extensions/'.$dir.'/Events.php'))
require_once APPPATH.'config/extensions/'.$dir.'/Events.php';
foreach (scandir(FHCPATH.'addons') as $dir)
if ($dir[0] != '.' && file_exists(FHCPATH.'addons/'.$dir.'/Events.php'))
require_once FHCPATH.'addons/'.$dir.'/Events.php';
+11
View File
@@ -7,4 +7,15 @@ export default {
studiensemester_kurzbz: studiensemester_kurzbz }
);
},
getLvMenu(lvid, studiensemester_kurzbz) {
return this.$fhcApi.get(
FHC_JS_DATA_STORAGE_OBJECT.app_root +
FHC_JS_DATA_STORAGE_OBJECT.ci_router +
`/api/frontend/v1/LvMenu/getLvMenu/${lvid}/${studiensemester_kurzbz}`,
{}
);
},
}
@@ -27,6 +27,9 @@ export default {
},
methods:{
showModal: function(){
this.$fhcApi.factory.addons.getLvMenu(this.event.lehrveranstaltung_id, this.event.studiensemester_kurzbz).then(res =>{
console.log("this is the addon endpoint res",res);
});
this.$fhcApi.factory.lehre.getStudentenMail(this.event.lehreinheit_id).then(res =>
{
// prepare the mailto link with all the emails from the students of the lv
@@ -41,6 +44,7 @@ export default {
mounted(){
// make axios call to the active addons
/* $addon_obj->loadAddons();
foreach($addon_obj->result as $addon)