diff --git a/application/helpers/hlp_header_helper.php b/application/helpers/hlp_header_helper.php index 53a5f5ba3..eb2cd9f85 100644 --- a/application/helpers/hlp_header_helper.php +++ b/application/helpers/hlp_header_helper.php @@ -111,7 +111,8 @@ function generateJSDataStorageObject($indexPage, $calledPath, $calledMethod) 'theme' => [ 'name'=>$ci->config->item('theme_name'), 'modes'=>$ci->config->item('theme_modes'), - ] + ], + 'domain' => DOMAIN ); $toPrint = "\n"; diff --git a/application/views/Studentenverwaltung.php b/application/views/Studentenverwaltung.php index 8dd2dd93d..c1a55c6bf 100644 --- a/application/views/Studentenverwaltung.php +++ b/application/views/Studentenverwaltung.php @@ -62,6 +62,7 @@ $configArray = [ logout-url="" :permissions="" :config="" + auth-uid="" > diff --git a/public/js/components/Stv/Studentenverwaltung.js b/public/js/components/Stv/Studentenverwaltung.js index a926bb858..f22aa2d45 100644 --- a/public/js/components/Stv/Studentenverwaltung.js +++ b/public/js/components/Stv/Studentenverwaltung.js @@ -54,7 +54,8 @@ export default { cisRoot: String, avatarUrl: String, logoutUrl: String, - activeAddons: String // semicolon separated list of active addons + activeAddons: String, // semicolon separated list of active addons + authUid: String }, provide() { return { @@ -88,6 +89,7 @@ export default { hasZGVMasterPermission: this.permissions['student/editMakkZgv'], hasZGVDoctorPermission: this.permissions['student/editDokZgv'], hasBismeldenPermission: this.permissions['student/editBismelden'], + authUid: this.authUid } }, diff --git a/public/js/components/Stv/Studentenverwaltung/Details/Kontaktieren.js b/public/js/components/Stv/Studentenverwaltung/Details/Kontaktieren.js index ef61ef1b9..6d89d6b12 100644 --- a/public/js/components/Stv/Studentenverwaltung/Details/Kontaktieren.js +++ b/public/js/components/Stv/Studentenverwaltung/Details/Kontaktieren.js @@ -1,6 +1,14 @@ -import { splitMailsHelper } from "../../../../helpers/EmailHelpers.js" +import { splitMailsHelper } from "../../../../helpers/EmailHelpers.js"; +import { splitMailLinks } from "../../../../helpers/EmailHelpers.js"; +import FormInput from "../../../Form/Input.js"; +import FormForm from "../../../Form/Form.js"; + export default { name: "Kontaktieren", + components: { + FormInput, + FormForm + }, computed: { internMails() { if (this.modelValue.mail_intern) @@ -21,38 +29,150 @@ export default { props: { modelValue: Object }, - + inject: { + authUid: { + from: 'authUid', + required: true + }, + }, + data(){ + return { + mailLinks: [], + mailLinksClicked: [], + showMailDialog: false, + showDivKomp: false, + showDivKompLocalStorageId: 'studvw-contact-showDivKomp' + } + }, + activated() { + const showDivCompLocalStorage = window.localStorage.getItem(this.showDivKompLocalStorageId); + this.showDivKomp = (showDivCompLocalStorage === 'true') ? true : false; + }, methods: { internMail(event) { if (this.internMails.length) { - splitMailsHelper(this.internMails, event, null, null, this.$fhcAlert, this.$p) + splitMailsHelper(this.internMails, event, null, null, this.$fhcAlert, this.$p, this.authUid) } }, privateMail(event) { if (this.privateMails.length) { - splitMailsHelper(this.privateMails, event, null,null, this.$fhcAlert, this.$p) + splitMailsHelper(this.privateMails, event, null, null, this.$fhcAlert, this.$p, this.authUid) } + }, + createMailLinks(event, mailGroup){ + let recipients = mailGroup == 'private' ? this.privateMails : this.internMails; + this.mailLinks = splitMailLinks( + recipients, + "", + event.ctrlKey || event.metaKey, + this.authUid + ); + this.mailLinksClicked = []; + + this.showMailDialog = true; + }, + handleMailLink(link, index){ + this.mailLinksClicked.push(index); + window.open(link, '_blank', 'noopener'); + }, + reset(){ + this.showMailDialog = false; + }, + onSwitchChange(){ + window.localStorage.setItem(this.showDivKompLocalStorageId, this.showDivKomp); } }, template: ` -
-
-
-
- +
+
+ + + +
+
+
+ +
+
+
+
+ +
- -
-
- + +
+ +
+
+ +
+
+
+ +
+
+ +
+
+

{{$p.t('stv', 'zuvieleEMails')}}

+ + +
+ +
+
-
` -}; \ No newline at end of file +
+ ` +}; diff --git a/public/js/helpers/EmailHelpers.js b/public/js/helpers/EmailHelpers.js index 4ffdc8122..d4be2dff1 100644 --- a/public/js/helpers/EmailHelpers.js +++ b/public/js/helpers/EmailHelpers.js @@ -1,5 +1,6 @@ -export async function splitMailsHelper(mails, event, subject, body, alertPluginRef, phrasenPluginRef) { +export async function splitMailsHelper(mails, event, subject, body, alertPluginRef, phrasenPluginRef, uidCC) { await phrasenPluginRef.loadCategory('ui'); + let splititem = ","; let maillist = mails.join(splititem); let useBcc = event?.ctrlKey || event?.metaKey; @@ -46,7 +47,10 @@ export async function splitMailsHelper(mails, event, subject, body, alertPluginR } // construct the clean mailLink - let mailLink = useBcc ? `mailto:?bcc=${mailto}` : `mailto:${mailto}`; + let mailadressUid = (uidCC && typeof uidCC === 'string') + ? uidCC + '@' + FHC_JS_DATA_STORAGE_OBJECT.domain + : 'noreply@' + FHC_JS_DATA_STORAGE_OBJECT.domain; + let mailLink = useBcc ? `mailto:${mailadressUid}?cc=${mailadressUid}&bcc=${mailto}` : `mailto:${mailto}`; if (queryString) { // If using BCC, the string already has a '?', so append with '&'. Otherwise, start with '?' mailLink += useBcc ? `&${queryString}` : `?${queryString}`; @@ -63,4 +67,79 @@ export async function splitMailsHelper(mails, event, subject, body, alertPluginR } } } -} \ No newline at end of file +} + + +/** + * just splits the list of mails + * + * @param mails emailadresses + * @param subject subject + * @param useBcc useBcc + * @returns array of links for splitted mails + */ +export function splitMailLinks(mails, subject = "", useBcc = false, uidCC= "", maxLength = 2024) { + if (!Array.isArray(mails) || mails.length === 0) { + return []; + } + + const separator = ","; + const encodedSubject = subject ? encodeURIComponent(subject) : ""; + + // reserve space for the subject parameter + const subjectLength = encodedSubject + ? `?subject=${encodedSubject}`.length + : 0; + + const limit = maxLength - subjectLength; + + const links = []; + let currentRecipients = []; + + for (const mail of mails) { + if (!mail) continue; + + const testRecipients = [...currentRecipients, mail]; + const recipientString = testRecipients.join(separator); + + if (recipientString.length > limit && currentRecipients.length > 0) { + + links.push(createMailto( + currentRecipients.join(separator), + encodedSubject, + useBcc, + uidCC + )); + + currentRecipients = [mail]; + } + else { + currentRecipients.push(mail); + } + } + + if (currentRecipients.length > 0) { + links.push(createMailto( + currentRecipients.join(separator), + encodedSubject, + useBcc, + uidCC + )); + } + + return links; +} + +function createMailto(recipients, encodedSubject, useBcc, uidCC) { + let mailadressUid = uidCC + '@technikum-wien.at'; + + let link = useBcc + ? `mailto:${encodeURIComponent(mailadressUid)}?cc=${encodeURIComponent(mailadressUid)}&bcc=${encodeURIComponent(recipients)}` + : `mailto:${encodeURIComponent(recipients)}`; + + if (encodedSubject) { + link += `${useBcc ? "&" : "?"}subject=${encodedSubject}`; + } + + return link; +} diff --git a/system/phrasesupdate.php b/system/phrasesupdate.php index b3b578e09..ca098e0f6 100644 --- a/system/phrasesupdate.php +++ b/system/phrasesupdate.php @@ -49804,7 +49804,7 @@ array( ), array( 'app' => 'core', - 'category' => 'stv', + 'category' => 'ui', 'phrase' => 'weitereEMail', 'insertvon' => 'system', 'phrases' => array( @@ -62123,6 +62123,66 @@ I have been informed that I am under no obligation to consent to the transmissio ) ), // tabulator presets section phrases END + array( + 'app' => 'core', + 'category' => 'ui', + 'phrase' => 'openInMailClient', + 'insertvon' => 'system', + 'phrases' => array( + array( + 'sprache' => 'German', + 'text' => 'In Mailanwendung öffnen', + 'description' => '', + 'insertvon' => 'system' + ), + array( + 'sprache' => 'English', + 'text' => 'Open in Mailclient', + 'description' => '', + 'insertvon' => 'system' + ) + ) + ), + array( + 'app' => 'core', + 'category' => 'ui', + 'phrase' => 'kompatibilityMode_WebmailClient', + 'insertvon' => 'system', + 'phrases' => array( + array( + 'sprache' => 'German', + 'text' => 'Kompatibilitätsmodus für Webmail', + 'description' => '', + 'insertvon' => 'system' + ), + array( + 'sprache' => 'English', + 'text' => 'Open in Compatibility mode (Webmail)', + 'description' => '', + 'insertvon' => 'system' + ) + ) + ), + array( + 'app' => 'core', + 'category' => 'ui', + 'phrase' => 'webmailclient', + 'insertvon' => 'system', + 'phrases' => array( + array( + 'sprache' => 'German', + 'text' => 'Webmail', + 'description' => '', + 'insertvon' => 'system' + ), + array( + 'sprache' => 'English', + 'text' => 'webmail', + 'description' => '', + 'insertvon' => 'system' + ) + ) + ), );