Dashboard
-
diff --git a/application/controllers/api/frontend/v1/Lehre.php b/application/controllers/api/frontend/v1/Lehre.php new file mode 100644 index 000000000..95422142d --- /dev/null +++ b/application/controllers/api/frontend/v1/Lehre.php @@ -0,0 +1,67 @@ +. + */ + +if (! defined('BASEPATH')) exit('No direct script access allowed'); + + +class Lehre extends FHCAPI_Controller +{ + + /** + * Object initialization + */ + public function __construct() + { + parent::__construct([ + 'lvStudentenMail' => self::PERM_LOGGED, + ]); + + + + } + + //------------------------------------------------------------------------------------------------------------------ + // Public methods + + /** + * constructs the emails of the groups from a lehrveranstaltung + */ + public function lvStudentenMail() + { + $lehreinheit_id = $this->input->get("lehreinheit_id",TRUE); + + // return early if the required parameter is missing + if(!isset($lehreinheit_id)) + { + $this->terminateWithError('Missing required parameter', self::ERROR_TYPE_GENERAL); + } + + $this->load->model('education/Lehreinheit_model', 'LehreinheitModel'); + + $studentenMails = $this->LehreinheitModel->getStudentenMail($lehreinheit_id); + + $studentenMails = $this->getDataOrTerminateWithError($studentenMails); + + $this->terminateWithSuccess($studentenMails); + } + + + + +} + diff --git a/application/models/education/Lehreinheit_model.php b/application/models/education/Lehreinheit_model.php index 10c122b94..35281c8cc 100755 --- a/application/models/education/Lehreinheit_model.php +++ b/application/models/education/Lehreinheit_model.php @@ -113,4 +113,40 @@ class Lehreinheit_model extends DB_Model return $this->execQuery($query, array($lehreinheit_id)); } + + /** + * Gets emails of all Studierende in a lehrveranstaltung + * @param int $lehreinheit_id + * @return array + */ + public function getStudentenMail($lehreinheit_id) + { + + // logic used from cis_menu_lv.inc.php line 335 + return $this->execReadOnlyQuery(" + SELECT + CASE + WHEN gruppe_kurzbz !='' THEN LOWER(gruppe_kurzbz || '@' || ?) + ELSE LOWER(stg_typ || stg_kurzbz || semester || TRIM(verband) || TRIM(gruppe) || '@' || ?) + END AS mail + FROM + ( + SELECT + distinct vw_lehreinheit.studiensemester_kurzbz, vw_lehreinheit.stg_kurzbz, vw_lehreinheit.stg_typ, vw_lehreinheit.semester, + COALESCE(vw_lehreinheit.verband,'') as verband, COALESCE(vw_lehreinheit.gruppe,'') as gruppe, vw_lehreinheit.gruppe_kurzbz, tbl_gruppe.mailgrp + FROM campus.vw_lehreinheit + LEFT JOIN public.tbl_gruppe USING(gruppe_kurzbz) + WHERE + vw_lehreinheit.lehrveranstaltung_id= + (select distinct lehrveranstaltung_id from campus.vw_lehreinheit where lehreinheit_id=?) + AND + vw_lehreinheit.studiensemester_kurzbz = + (select distinct studiensemester_kurzbz from campus.vw_lehreinheit where lehreinheit_id=?) + AND (vw_lehreinheit.gruppe_kurzbz IS NULL OR + (vw_lehreinheit.gruppe_kurzbz IS NOT NULL AND tbl_gruppe.mailgrp = TRUE AND (SELECT COUNT(*) FROM public.tbl_benutzergruppe where gruppe_kurzbz = vw_lehreinheit.gruppe_kurzbz AND studiensemester_kurzbz = vw_lehreinheit.studiensemester_kurzbz) > 0)) + + + ) AS subquery + ",[DOMAIN,DOMAIN,$lehreinheit_id,$lehreinheit_id ]); + } } diff --git a/application/views/CisHtml/Dashboard.php b/application/views/CisHtml/Dashboard.php index 49db7ad7c..c2190620d 100755 --- a/application/views/CisHtml/Dashboard.php +++ b/application/views/CisHtml/Dashboard.php @@ -13,7 +13,8 @@ $this->load->view('templates/CISHTML-Header', $includesArray);
{{JSON.stringify(event,null,2)}}
+