This is a migrated thread and some comments may be shown as answers.

Scheduler Roles/Permissions

1 Answer 101 Views
Scheduler
This is a migrated thread and some comments may be shown as answers.
Amine
Top achievements
Rank 1
Amine asked on 11 Dec 2013, 02:21 AM
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,

1 Answer, 1 is accepted

Sort by
0
Vic
Top achievements
Rank 2
answered on 11 Dec 2013, 02:01 PM
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);
    }


Tags
Scheduler
Asked by
Amine
Top achievements
Rank 1
Answers by
Vic
Top achievements
Rank 2
Share this question
or