Scheduler Roles/Permissions

2 posts, 0 answers
  1. Amine
    Amine avatar
    1 posts
    Member since:
    Apr 2008

    Posted 10 Dec 2013 Link to this post

    Hello!

    Is it possible to setup some sort of roles/permissions around the creation and editing? The main concern is that we have two scenarios that need to be supported:

    1- Read Only Mode (Admin only can create).
    2- Shared Mode (Users can see all entries but only modify theirs).

    I haven't purchased this yet and this will help with the purchase decision.

    Thank you,
    Amine,

  2. Vikram
    Vikram avatar
    10 posts
    Member since:
    Oct 2010

    Posted 11 Dec 2013 Link to this post

    Hi,

    I was facing such issue while working on one of web application. There doesn't exist direct way (or modes). But indirect way exists.

    Steps to resolve - 

    (1) Declare CustomAttributeNames in RadScheduler as follow - 

    <telerik:RadScheduler runat="server" ID="EventScheduler" CustomAttributeNames="BookedBy,Role"/>

    CustomAttributeNames are way of adding extra piece of information with appointments.

    (2) Now you can use OnAppointmentInsertOnAppointmentUpdate, OnAppointmentDelete to check user's role. And to check if user created appointment is same as who is logged in.

    Code Snippet - 

    // APPOINTMENT INSERT
    protected void EventScheduler_AppointmentInsert(object sender, AppointmentInsertEventArgs e)
        {
            if (Session["User"] != null)
            {
                 e.Cancel = false;           
            }
            else
            {
                e.Cancel = true; // Cancel this event or appointment creation
                ShowErrorMessage("Only logged in user can create events.");
            }
        }
     
    // APPOINTMENT UPDATE
        protected void EventScheduler_AppointmentUpdate(object sender, AppointmentUpdateEventArgs e)
        {
            if (Session["User"] != null)
            {
                 switch (Utility.LoggedUserRole)
                {
                    case "Admin":
                         e.Cancel = false;
                        ShowErrorMessage("Updating events in blocked timeslot is not allowed.");
                        break;
     
     
                    case "User":
                        if (e.Appointment.Attributes["BookedBy"].Equals(Utility.LoggedUserEmp))
                        {
                             e.Cancel = false; // Let user update appointment
                        }
                        else
                        {
                            e.Cancel = true;
                            ShowErrorMessage("You cannot modify other user's created events.");
                        }
     
                        break;
                }
            }
            else
            {
                e.Cancel = true;
                ShowErrorMessage("Only logged in user can modify events.");
            }
        }
     
    // APPOINTMENT DELETE
        protected void EventScheduler_AppointmentDelete(object sender, AppointmentDeleteEventArgs e)
        {
            if (Session["User"] != null)
            {
                switch (Utility.LoggedUserRole)
                {
                    case "Admin":
                        e.Cancel = false;
                        break;
     
                    case "User":
                        if (!e.Appointment.Attributes["BookedBy"].Equals(Utility.LoggedUserEmp))
                        {
                            e.Cancel = true;
                            ShowErrorMessage("You cannot delete other user's created events.");
                        }
                        break;
                }
            }
            else
            {
                e.Cancel = true;
                ShowErrorMessage("Only logged in user can delete events.");
            }
        }
     
    // Error function
    private void ShowErrorMessage(string message)
        {
            Label1.Text = message;
            System.Web.UI.ScriptManager.RegisterClientScriptBlock(this, GetType(), "LabelUpdated","$telerik.$('.lblError').show().animate({ opacity: 0.9 }, 5000).fadeOut('slow');", true);
        }


  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top