search envelope-o feed check
Home Unanswered Active Tags New Question
user comment-o

DayPilot Month Calendar

Asked by Ferdie Wehrmann
9 years ago.

How could I validate an event before editing the event that the event is owned by the particular logged in user.In short I don't want user's to be able to edit other user's events in the calendar.

Answer posted by Dan Letecky [DayPilot]
9 years ago.

If you are using the DayPilot modal dialog:

1. You need to secure the "edit" page itself - this is required because DayPilot settings can be circumvented (they are client-side only).

2. Depending on the permissions and event properties, you can disable EventClick using BeforeEventRender:

protected void DayPilotMonth1_BeforeEventRender(object sender, BeforeEventRenderEventArgs e)
{
  if ((string)e.DataItem["owner"] == User.Identity.Name)  // "owner" field must be available in the DataSource
  {
    e.ClickEnabled = false;
  }
}

3. Another option is to display a different page for non-owners:

<DayPilot:DayPilotMonth
...
DataTagFields="owner"
EventClickHandling="JavaScript"
EventClickJavaScript="onClick(e)"
/>

<script>
function onClick(e) {
  if (e.tag("owner") === loggedInUser) {
    // open edit dialog
  }
  else {
    // show warning...
  }
}
</script>

Make sure the owner field is available (DataTagFields) and check the value in the event click handler (EventClickJavaScript).

Comment posted by Dan Letecky [DayPilot]
9 years ago.
This question is more than 1 months old and has been closed. Please create a new question if you have anything to add.