public static PublicItemCollection GetSample()
 {
     return(new PublicItemCollection {
         AvailableOptions = new List <AccessOption>()
         {
             AccessOption.GetSample()
         }, Items = new List <PublicItemWrapper>()
         {
             PublicItemWrapper.GetSample()
         }
     });
 }
示例#2
0
        public PublicItemWrapper Get(ASC.Web.Core.Calendars.SharingOptions.PublicItem publicItem, string calendartId, Guid owner)
        {
            var result = new PublicItemWrapper();

            result.Id      = publicItem.Id;
            result.IsGroup = publicItem.IsGroup;

            _owner      = owner;
            _calendarId = calendartId;
            _isCalendar = true;

            Init(publicItem, ref result);

            return(result);
        }
示例#3
0
        protected void Init(ASC.Web.Core.Calendars.SharingOptions.PublicItem publicItem, ref PublicItemWrapper result)
        {
            result.ItemId = publicItem.Id.ToString();

            //---ItemName
            if (result.IsGroup)
            {
                result.ItemName = UserManager.GetGroupInfo(publicItem.Id).Name;
            }
            else
            {
                result.ItemName = UserManager.GetUsers(publicItem.Id).DisplayUserName(DisplayUserSettingsHelper);
            }

            //---CanEdit
            result.CanEdit = !publicItem.Id.Equals(_owner);

            //---SharingOption
            if (publicItem.Id.Equals(_owner))
            {
                result.SharingOption = AccessOption.OwnerOption;
            }
            else
            {
                var subject = publicItem.IsGroup ? (ISubject)UserManager.GetGroupInfo(publicItem.Id) : (ISubject)Authentication.GetAccountByID(TenantManager.GetCurrentTenant().TenantId, publicItem.Id);
                int calId;
                if (_isCalendar && int.TryParse(_calendarId, out calId))
                {
                    var icalendar = new iCalendar(AuthContext, TimeZoneConverter, TenantManager);
                    var obj       = new BusinessObjects.Calendar(AuthContext, TimeZoneConverter, icalendar, DataProvider)
                    {
                        Id = _calendarId
                    };
                    if (PermissionContext.PermissionResolver.Check(subject, obj, null, CalendarAccessRights.FullAccessAction))
                    {
                        result.SharingOption = AccessOption.FullAccessOption;
                    }
                    else
                    {
                        result.SharingOption = AccessOption.ReadOption;
                    }
                }
                else if (!_isCalendar)
                {
                    var icalendar = new iCalendar(AuthContext, TimeZoneConverter, TenantManager);
                    var obj       = new BusinessObjects.Event(AuthContext, TimeZoneConverter, icalendar, DataProvider)
                    {
                        Id = _eventId, CalendarId = _calendarId
                    };
                    if (PermissionContext.PermissionResolver.Check(subject, obj, null, CalendarAccessRights.FullAccessAction))
                    {
                        result.SharingOption = AccessOption.FullAccessOption;
                    }
                    else
                    {
                        result.SharingOption = AccessOption.ReadOption;
                    }
                }
                else
                {
                    result.SharingOption = AccessOption.ReadOption;
                }
            }
        }