2020-02-13 09:18:13 +00:00
|
|
|
/*
|
|
|
|
*
|
|
|
|
* (c) Copyright Ascensio System Limited 2010-2018
|
|
|
|
*
|
|
|
|
* This program is freeware. You can redistribute it and/or modify it under the terms of the GNU
|
|
|
|
* General Public License (GPL) version 3 as published by the Free Software Foundation (https://www.gnu.org/copyleft/gpl.html).
|
|
|
|
* In accordance with Section 7(a) of the GNU GPL its Section 15 shall be amended to the effect that
|
|
|
|
* Ascensio System SIA expressly excludes the warranty of non-infringement of any third-party rights.
|
|
|
|
*
|
|
|
|
* THIS PROGRAM IS DISTRIBUTED WITHOUT ANY WARRANTY; WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE. For more details, see GNU GPL at https://www.gnu.org/copyleft/gpl.html
|
|
|
|
*
|
|
|
|
* You can contact Ascensio System SIA by email at sales@onlyoffice.com
|
|
|
|
*
|
|
|
|
* The interactive user interfaces in modified source and object code versions of ONLYOFFICE must display
|
|
|
|
* Appropriate Legal Notices, as required under Section 5 of the GNU GPL version 3.
|
|
|
|
*
|
|
|
|
* Pursuant to Section 7 § 3(b) of the GNU GPL you must retain the original ONLYOFFICE logo which contains
|
|
|
|
* relevant author attributions when distributing the software. If the display of the logo in its graphic
|
|
|
|
* form is not reasonably feasible for technical reasons, you must include the words "Powered by ONLYOFFICE"
|
|
|
|
* in every copy of the program you distribute.
|
|
|
|
* Pursuant to Section 7 § 3(e) we decline to grant you any rights under trademark law for use of our trademarks.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using System.Runtime.Serialization;
|
|
|
|
using ASC.Core;
|
|
|
|
using ASC.Web.Core.Calendars;
|
2020-02-27 14:15:25 +00:00
|
|
|
using ASC.Common;
|
2021-07-01 09:15:59 +00:00
|
|
|
using System.Text.Json.Serialization;
|
2020-02-13 09:18:13 +00:00
|
|
|
|
|
|
|
namespace ASC.Calendar.Models
|
|
|
|
{
|
2020-02-21 12:33:51 +00:00
|
|
|
[DataContract(Name = "sharing", Namespace = "")]
|
2021-04-13 08:40:31 +00:00
|
|
|
[Scope]
|
2020-02-21 12:33:51 +00:00
|
|
|
public class PublicItemCollection
|
|
|
|
{
|
2021-07-01 09:15:59 +00:00
|
|
|
[JsonPropertyName("actions")]
|
2020-02-21 12:33:51 +00:00
|
|
|
public List<AccessOption> AvailableOptions { get; set; }
|
|
|
|
|
|
|
|
[DataMember(Name = "items", Order = 20)]
|
|
|
|
public List<PublicItemWrapper> Items { get; set; }
|
|
|
|
|
|
|
|
|
|
|
|
public static PublicItemCollection GetSample()
|
|
|
|
{
|
|
|
|
return new PublicItemCollection { AvailableOptions = new List<AccessOption>() { AccessOption.GetSample() }, Items = new List<PublicItemWrapper>() { PublicItemWrapper.GetSample() } };
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
2021-05-17 18:35:23 +00:00
|
|
|
|
|
|
|
[Scope]
|
2020-02-21 12:33:51 +00:00
|
|
|
public class PublicItemCollectionHelper
|
|
|
|
{
|
|
|
|
public AuthContext AuthContext { get; }
|
2020-02-25 13:36:20 +00:00
|
|
|
public PublicItemWrapperHelper PublicItemWrapperHelper { get; }
|
|
|
|
|
|
|
|
public PublicItemCollectionHelper(
|
|
|
|
AuthContext authContext,
|
|
|
|
PublicItemWrapperHelper publicItemWrapperHelper)
|
2020-02-21 12:33:51 +00:00
|
|
|
{
|
|
|
|
AuthContext = authContext;
|
2020-02-25 13:36:20 +00:00
|
|
|
PublicItemWrapperHelper = publicItemWrapperHelper;
|
2020-02-21 12:33:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public PublicItemCollection GetDefault()
|
|
|
|
{
|
2020-02-25 13:36:20 +00:00
|
|
|
var sharingOptions = GetPublicItemCollection();
|
|
|
|
sharingOptions.Items.Add(PublicItemWrapperHelper.Get(
|
2020-02-21 12:33:51 +00:00
|
|
|
new ASC.Web.Core.Calendars.SharingOptions.PublicItem()
|
|
|
|
{
|
|
|
|
Id = AuthContext.CurrentAccount.ID,
|
|
|
|
IsGroup = false
|
|
|
|
},
|
|
|
|
"0", AuthContext.CurrentAccount.ID));
|
|
|
|
return sharingOptions;
|
|
|
|
}
|
|
|
|
|
|
|
|
public PublicItemCollection GetForCalendar(ICalendar calendar)
|
|
|
|
{
|
2020-02-25 13:36:20 +00:00
|
|
|
var sharingOptions = GetPublicItemCollection();
|
|
|
|
sharingOptions.Items.Add(PublicItemWrapperHelper.Get(new ASC.Web.Core.Calendars.SharingOptions.PublicItem()
|
2020-02-21 12:33:51 +00:00
|
|
|
{
|
|
|
|
Id = calendar.OwnerId,
|
|
|
|
IsGroup = false
|
|
|
|
},
|
2022-01-11 15:37:10 +00:00
|
|
|
calendar.Id, calendar.OwnerId));
|
2020-02-25 13:36:20 +00:00
|
|
|
|
2020-02-21 12:33:51 +00:00
|
|
|
foreach (var item in calendar.SharingOptions.PublicItems)
|
2022-01-11 15:37:10 +00:00
|
|
|
sharingOptions.Items.Add(PublicItemWrapperHelper.Get(item, calendar.Id, calendar.OwnerId));
|
2020-02-21 12:33:51 +00:00
|
|
|
|
|
|
|
return sharingOptions;
|
|
|
|
}
|
2020-02-25 13:36:20 +00:00
|
|
|
public PublicItemCollection GetForEvent(IEvent calendarEvent)
|
2020-02-21 12:33:51 +00:00
|
|
|
{
|
2020-02-25 13:36:20 +00:00
|
|
|
var sharingOptions = GetPublicItemCollection();
|
|
|
|
sharingOptions.Items.Add(PublicItemWrapperHelper.Get(new ASC.Web.Core.Calendars.SharingOptions.PublicItem()
|
2020-02-21 12:33:51 +00:00
|
|
|
{
|
|
|
|
Id = calendarEvent.OwnerId,
|
|
|
|
IsGroup = false
|
|
|
|
},
|
|
|
|
|
|
|
|
calendarEvent.CalendarId, calendarEvent.Id, calendarEvent.OwnerId));
|
|
|
|
|
|
|
|
foreach (var item in calendarEvent.SharingOptions.PublicItems)
|
2020-02-25 13:36:20 +00:00
|
|
|
sharingOptions.Items.Add(PublicItemWrapperHelper.Get(item, calendarEvent.CalendarId, calendarEvent.Id, calendarEvent.OwnerId));
|
2020-02-21 12:33:51 +00:00
|
|
|
|
|
|
|
return sharingOptions;
|
|
|
|
}
|
2020-02-25 13:36:20 +00:00
|
|
|
|
|
|
|
public PublicItemCollection GetPublicItemCollection()
|
|
|
|
{
|
|
|
|
var publicItemCollection = new PublicItemCollection();
|
|
|
|
|
|
|
|
publicItemCollection.Items = new List<PublicItemWrapper>();
|
|
|
|
|
|
|
|
publicItemCollection.AvailableOptions = AccessOption.CalendarStandartOptions;
|
|
|
|
|
|
|
|
return publicItemCollection;
|
|
|
|
}
|
2020-02-21 12:33:51 +00:00
|
|
|
}
|
|
|
|
|
2020-02-13 09:18:13 +00:00
|
|
|
}
|