Skip to content
Snippets Groups Projects
Commit 641afe65 authored by Andreas Schindlbeck's avatar Andreas Schindlbeck
Browse files

#1041362 AppointmentLinks jetzt auch gesperrt wenn User nicht ändern darf

parent 55a2eeb2
No related branches found
No related tags found
No related merge requests found
import("system.logging");
import("system.result");
import("system.tools");
import("system.neon");
import("system.vars");
import("system.calendars");
if(vars.get("$sys.recordstate") == neon.OPERATINGSTATE_VIEW)
result.object(neon.COMPONENTSTATE_DISABLED);
else if(vars.get("$sys.recordstate") == neon.OPERATINGSTATE_NEW && vars.get("$param.AppointmentId_param"))
{
var entry = calendars.getEntry(vars.get("$param.AppointmentId_param"), null, null);
doCalc(entry);
}
else if(vars.get("$sys.recordstate") == neon.OPERATINGSTATE_EDIT)
{
var entryy = calendars.getEntry(vars.get("$field.APPOINTMENT_ID"), null, null);
doCalc(entryy);
}
import("Appointment_lib");
import("system.result");
function doCalc(entry)
{
if(entry[calendars.ORGANIZER2]["paramvalue"] == "mailto:" + tools.getCurrentUser()["params"]["email"])
result.object(neon.COMPONENTSTATE_EDITABLE);
else
result.object(neon.COMPONENTSTATE_DISABLED);
}
\ No newline at end of file
result.object(AppointmentUtils.setAppointmentLinkComponentState(vars.get("$sys.recordstate"), vars.get("$param.AppointmentId_param"), vars.get("$field.APPOINTMENT_ID")));
\ No newline at end of file
import("system.logging");
import("Appointment_lib");
import("system.result");
import("system.tools");
import("system.neon");
import("system.vars");
import("system.calendars");
if(vars.get("$sys.recordstate") == neon.OPERATINGSTATE_VIEW)
result.object(neon.COMPONENTSTATE_DISABLED);
else if(vars.get("$sys.recordstate") == neon.OPERATINGSTATE_NEW && vars.get("$param.AppointmentId_param"))
{
var entry = calendars.getEntry(vars.get("$param.AppointmentId_param"), null, null);
doCalc(entry);
}
else if(vars.get("$sys.recordstate") == neon.OPERATINGSTATE_EDIT)
{
var entryy = calendars.getEntry(vars.get("$field.APPOINTMENT_ID"), null, null);
doCalc(entryy);
}
function doCalc(entry)
{
if(entry[calendars.ORGANIZER2]["paramvalue"] == "mailto:" + tools.getCurrentUser()["params"]["email"])
result.object(neon.COMPONENTSTATE_EDITABLE);
else
result.object(neon.COMPONENTSTATE_DISABLED);
}
\ No newline at end of file
result.object(AppointmentUtils.setAppointmentLinkComponentState(vars.get("$sys.recordstate"), vars.get("$param.AppointmentId_param"), vars.get("$field.APPOINTMENT_ID")));
\ No newline at end of file
import("system.logging");
import("system.vars");
import("system.tools");
import("Calendar_lib");
import("system.calendars");
import("system.neon");
import("system.text");
......@@ -94,4 +98,46 @@ AppointmentUtils.sendExchangedAction = function(event, newState)
jsonEvent["X-ADITO-STATUSACTION"] = newState; // "ACCEPT", "DECLINE", ""
jsonEvent[calendars.AFFECTEDUSERS] = "";
calendars.updateEntry(jsonEvent);
}
AppointmentUtils.setAppointmentLinkComponentState = function(pSysRecordstate, pAppointmentIdParam, pAppointmentIdFieldValue)
{
var entry;
if(pSysRecordstate == neon.OPERATINGSTATE_NEW && pAppointmentIdParam)
{
logging.log("NEW");
entry = calendars.getEntry(pAppointmentIdParam, null, null);
}
else if(pSysRecordstate == neon.OPERATINGSTATE_EDIT)
{
logging.log("EDIT");
entry = calendars.getEntry(pAppointmentIdFieldValue, null, null);
}
if(entry)
{
var currentUserId = CalendarUtil.getEffectiveCalendarIdFromUser(tools.getCurrentUser());
var organzierId = CalendarUtil.getEffectiveCalendarIdFromUser(tools.getUser(entry[calendars.ORGANIZER2]["cn"], tools.PROFILE_DEFAULT));
logging.log("current: " + currentUserId);
logging.log("organizer: " + organzierId);
if(currentUserId && currentUserId == organzierId)
{
logging.log("ENABELED: currentUser == organizer");
return neon.COMPONENTSTATE_EDITABLE;
}
else
{
logging.log("DISABLED: currentUser != organizer");
return neon.COMPONENTSTATE_DISABLED;
}
}
else
{
logging.log("DISABLED: entry == null");
return neon.COMPONENTSTATE_DISABLED;
}
}
\ No newline at end of file
This diff is collapsed.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment