Initial commit: Security packages

This commit is contained in:
Ernad Husremovic 2025-08-29 15:20:51 +02:00
commit bb469e4763
1399 changed files with 278378 additions and 0 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 450 B

View file

@ -0,0 +1,25 @@
.o_calendar_sidebar {
.bg-primary {
background-color: $o-enterprise-primary-color;
}
.o_microsoft_sync_button {
padding: 0;
cursor: pointer;
font-size: 0.9em;
}
.o_microsoft_sync_button_configured {
color: white;
height: 2em;
&:hover {
#microsoft_check {
display: none;
}
}
&:not(:hover) {
#microsoft_stop {
display: none;
}
}
}
}

View file

@ -0,0 +1,10 @@
/** @odoo-module **/
import { AttendeeCalendarCommonPopover } from "@calendar/views/attendee_calendar/common/attendee_calendar_common_popover";
import { patch } from "@web/core/utils/patch";
patch(AttendeeCalendarCommonPopover.prototype, "microsoft_calendar_microsoft_calendar_common_popover", {
get isEventArchivable() {
return this._super() || (this.isCurrentUserOrganizer && this.props.record.rawRecord.microsoft_id);
},
});

View file

@ -0,0 +1,62 @@
/** @odoo-module **/
import { AttendeeCalendarController } from "@calendar/views/attendee_calendar/attendee_calendar_controller";
import { patch } from "@web/core/utils/patch";
import { useService } from "@web/core/utils/hooks";
import { ConfirmationDialog, AlertDialog } from "@web/core/confirmation_dialog/confirmation_dialog";
patch(AttendeeCalendarController.prototype, "microsoft_calendar_microsoft_calendar_controller", {
setup() {
this._super(...arguments);
this.dialog = useService("dialog");
this.notification = useService("notification");
},
async onMicrosoftSyncCalendar() {
await this.orm.call(
"res.users",
"restart_microsoft_synchronization",
[[this.user.userId]],
);
const syncResult = await this.model.syncMicrosoftCalendar();
if (syncResult.status === "need_auth") {
window.location.assign(syncResult.url);
} else if (syncResult.status === "need_config_from_admin") {
if (this.isSystemUser) {
this.dialog.add(ConfirmationDialog, {
title: this.env._t("Configuration"),
body: this.env._t("The Outlook Synchronization needs to be configured before you can use it, do you want to do it now?"),
confirm: this.actionService.doAction.bind(this.actionService, syncResult.action),
});
} else {
this.dialog.add(AlertDialog, {
title: this.env._t("Configuration"),
body: this.env._t("An administrator needs to configure Outlook Synchronization before you can use it!"),
});
}
} else if (syncResult.status === "need_refresh") {
await this.model.load();
}
},
async onStopMicrosoftSynchronization() {
this.dialog.add(ConfirmationDialog, {
body: this.env._t("You are about to stop the synchronization of your calendar with Outlook. Are you sure you want to continue?"),
confirm: async () => {
await this.orm.call(
"res.users",
"stop_microsoft_synchronization",
[[this.user.userId]],
);
this.notification.add(
this.env._t("The synchronization with Outlook calendar was successfully stopped."),
{
title: this.env._t("Success"),
type: "success",
},
);
await this.model.load();
},
});
}
});

View file

@ -0,0 +1,25 @@
<?xml version="1.0" encoding="UTF-8"?>
<templates>
<t t-name="microsoft_calendar.MicrosoftCalendarController" t-inherit="calendar.AttendeeCalendarController" t-inherit-mode="extension" owl="1">
<xpath expr="//div[@id='calendar_sync_wrapper']" position="attributes">
<attribute name="t-if">true</attribute>
</xpath>
<xpath expr="//div[@id='microsoft_calendar_sync']" position="replace">
<div id="microsoft_calendar_sync" class="o_calendar_sync">
<button t-if="!model.microsoftIsSync" type="button" id="microsoft_sync_pending" class="o_microsoft_sync_button o_microsoft_sync_pending btn btn-secondary btn" t-on-click="onMicrosoftSyncCalendar">
<b><i class='fa fa-refresh'/> Outlook</b>
</button>
<!-- class change on hover -->
<button t-else="" type="button" id="microsoft_sync_configured" class="me-1 o_microsoft_sync_button o_microsoft_sync_button_configured btn text-bg-primary" t-on-click="onStopMicrosoftSynchronization"
t-on-mouseenter="(ev) => {ev.target.classList.remove('text-bg-primary');ev.target.classList.add('text-bg-danger');}"
t-on-mouseleave="(ev) => {ev.target.classList.remove('text-bg-danger');ev.target.classList.add('text-bg-primary');}">
<b>
<i id="microsoft_check" class='fa fa-check'/>
<i id="microsoft_stop" class='fa fa-times'/>
<span class="mx-1">Outlook</span>
</b>
</button>
</div>
</xpath>
</t>
</templates>

View file

@ -0,0 +1,64 @@
/** @odoo-module **/
import { AttendeeCalendarModel } from "@calendar/views/attendee_calendar/attendee_calendar_model";
import { patch } from "@web/core/utils/patch";
patch(AttendeeCalendarModel, "microsoft_calendar_microsoft_calendar_model", {
services: [...AttendeeCalendarModel.services, "rpc"],
});
patch(AttendeeCalendarModel.prototype, "microsoft_calendar_microsoft_calendar_model_functions", {
setup(params, { rpc }) {
this._super(...arguments);
this.rpc = rpc;
this.isAlive = params.isAlive;
this.microsoftIsSync = true;
this.microsoftPendingSync = false;
},
/**
* @override
*/
async updateData() {
const _super = this._super.bind(this);
if (this.microsoftPendingSync) {
return _super(...arguments);
}
try {
await Promise.race([
new Promise(resolve => setTimeout(resolve, 1000)),
this.syncMicrosoftCalendar(true)
]);
} catch (error) {
if (error.event) {
error.event.preventDefault();
}
console.error("Could not synchronize microsoft events now.", error);
this.microsoftPendingSync = false;
}
if (this.isAlive()) {
return _super(...arguments);
}
},
async syncMicrosoftCalendar(silent = false) {
this.microsoftPendingSync = true;
const result = await this.rpc(
"/microsoft_calendar/sync_data",
{
model: this.resModel,
fromurl: window.location.href
},
{
silent,
},
);
if (["need_config_from_admin", "need_auth", "sync_stopped"].includes(result.status)) {
this.microsoftIsSync = false;
} else if (result.status === "no_new_event_from_microsoft" || result.status === "need_refresh") {
this.microsoftIsSync = true;
}
this.microsoftPendingSync = false;
return result;
},
});