diff --git a/application/config/Events.php b/application/config/Events.php index 191a1eb98..14eb30d3e 100644 --- a/application/config/Events.php +++ b/application/config/Events.php @@ -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) { diff --git a/application/controllers/api/frontend/v1/LvMenu.php b/application/controllers/api/frontend/v1/LvMenu.php new file mode 100644 index 000000000..d9a4550eb --- /dev/null +++ b/application/controllers/api/frontend/v1/LvMenu.php @@ -0,0 +1,87 @@ +. + */ + +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); + + } +} + diff --git a/application/core/CI3_Events.php b/application/core/CI3_Events.php index 33a96b89e..7e7e471b1 100644 --- a/application/core/CI3_Events.php +++ b/application/core/CI3_Events.php @@ -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'; diff --git a/public/js/api/addons.js b/public/js/api/addons.js index b40ea65cb..249457ac5 100644 --- a/public/js/api/addons.js +++ b/public/js/api/addons.js @@ -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}`, + {} + ); + }, + + } \ No newline at end of file diff --git a/public/js/components/Cis/Mylv/LvUebersicht.js b/public/js/components/Cis/Mylv/LvUebersicht.js index 7c16b8fb9..0762208af 100644 --- a/public/js/components/Cis/Mylv/LvUebersicht.js +++ b/public/js/components/Cis/Mylv/LvUebersicht.js @@ -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)