public void InitView(long idLink, long idItem, long idVersion, long idFolder, String path, Boolean setBackUrl, String backUrl)
        {
            RepositoryIdentifier rIdentifier = Service.ItemGetRepositoryIdentifier(idItem);
            Int32 idCommunity = UserContext.CurrentCommunityID;

            View.IdItem                      = idItem;
            View.IdVersion                   = idVersion;
            View.IdLink                      = idLink;
            View.IdCurrentFolder             = idFolder;
            View.CurrentFolderIdentifierPath = path;
            if (setBackUrl && String.IsNullOrEmpty(backUrl))
            {
                backUrl = View.GetPreviousRelativeUrl();
                if (!IsValidPreviousUrl(backUrl))
                {
                    backUrl    = "";
                    setBackUrl = false;
                }
                if (backUrl.StartsWith(RootObject.BaseRepositoryUrl(), StringComparison.InvariantCultureIgnoreCase) && rIdentifier != null)
                {
                    cookieRepository cookie = View.GetRepositoryCookie(rIdentifier);
                    if (cookie != null)
                    {
                        backUrl = RootObject.RepositoryItems(rIdentifier.Type, rIdentifier.IdCommunity, 0, cookie.IdFolder, cookie.Type, cookie.ItemsOrderBy, cookie.Ascending, cookie.IdentifierPath);
                    }
                }
                SetLogoutUrl(View.GetCurrentUrl(), setBackUrl, backUrl);
            }
            else
            {
                View.DefaultLogoutUrl = View.GetCurrentUrl();
            }
            View.BackUrl = (setBackUrl ? backUrl : "");
            View.SetPageBackUrl(backUrl);
            View.PageIdentifier = Guid.NewGuid();
            if (SessionTimeout())
            {
                return;
            }

            View.IsInitialized = true;
            ModuleRepository.ActionType uAction = ModuleRepository.ActionType.None;

            if (rIdentifier == null)
            {
                uAction = ModuleRepository.ActionType.MultimedaSettingsTryToLoad;
                View.DisplayUnknownItem();
            }
            else
            {
                Int32 idCurrentUser               = UserContext.CurrentUserID;
                liteRepositoryItem        item    = Service.ItemGet(idItem);
                liteRepositoryItemVersion version = Service.ItemGetVersion(idItem, idVersion);
                if (version == null)
                {
                    uAction = ModuleRepository.ActionType.MultimedaSettingsTryToLoad;
                    View.DisplayUnknownItem();
                }
                else if (version.Type != ItemType.Multimedia)
                {
                    idCommunity = version.IdCommunity;
                    View.DisplayMessage(version.DisplayName, version.Extension, version.Type, Domain.UserMessageType.multimediaSettingsInvalidType);
                    uAction = ModuleRepository.ActionType.MultimedaSettingsInvalidType;
                }
                else
                {
                    idVersion      = version.Id;
                    View.IdVersion = idVersion;
                    idCommunity    = version.IdCommunity;
                    if (version.Availability == ItemAvailability.available || version.Availability == ItemAvailability.waitingsettings)
                    {
                        ItemPermission permissions = null;

                        if (idLink == 0)
                        {
                            dtoDisplayRepositoryItem dto = Service.GetItemWithPermissions(idItem, idCurrentUser, item.Repository, View.GetUnknownUserName());
                            if (dto != null)
                            {
                                permissions = dto.Permissions;
                            }
                        }
                        else
                        {
                            liteModuleLink link = CurrentManager.Get <liteModuleLink>(idLink);
                            if (link == null)
                            {
                                View.DisplayMessage(version.DisplayName, version.Extension, version.Type, Domain.UserMessageType.multimediaSettingsNoPermission);
                            }
                            else
                            {
                                permissions = View.GetLinkPermissions(link, idCurrentUser);
                                idCommunity = link.SourceItem.CommunityID;
                            }
                        }
                        if (permissions != null)
                        {
                            if (permissions.EditSettings)
                            {
                                if (version.Availability == ItemAvailability.waitingsettings)
                                {
                                    View.DisplayMessage(version.DisplayName, version.Extension, version.Type, Domain.UserMessageType.multimediaSettingsNoDefaultDocument);
                                }
                                List <dtoMultimediaFileObject> items = Service.MultimediaGetItems(idItem, idVersion);
                                View.AllowSave = (items != null && items.Any());
                                View.LoadItems(item.UniqueIdVersion.ToString(), item.DisplayName, items, (items == null ? null : items.Where(i => i.IsDefaultDocument).FirstOrDefault()));
                            }
                            else
                            {
                                uAction = ModuleRepository.ActionType.MultimedaSettingsNoPermissions;
                                View.DisplayMessage(version.DisplayName, version.Extension, version.Type, Domain.UserMessageType.multimediaSettingsNoPermission);
                            }
                        }
                        else
                        {
                            uAction = ModuleRepository.ActionType.MultimedaSettingsStatusError;
                            View.DisplayMessage(version.DisplayName, version.Extension, version.Type, Domain.UserMessageType.multimediaSettingsInvalidStatus, version.Availability);
                        }
                    }
                    else
                    {
                        uAction = ModuleRepository.ActionType.MultimedaSettingsStatusError;
                        View.DisplayMessage(version.DisplayName, version.Extension, version.Type, Domain.UserMessageType.multimediaSettingsInvalidStatus, version.Availability);
                    }
                }
                View.RepositoryIdentifier  = CacheKeys.RepositoryIdentifierKey(rIdentifier.Type, rIdentifier.IdCommunity);
                View.RepositoryIdCommunity = rIdentifier.IdCommunity;
                View.RepositoryType        = rIdentifier.Type;
                View.IsInitialized         = true;
            }
            View.SendUserAction(idCommunity, Service.GetIdModule(), uAction);
        }
예제 #2
0
        public void InitView(Boolean isEditPage, long idItem, long idFolder, String path, Boolean setBackUrl, String backUrl)
        {
            RepositoryIdentifier rIdentifier = Service.ItemGetRepositoryIdentifier(idItem);
            Int32 idCommunity = UserContext.CurrentCommunityID;

            View.IdItem                      = idItem;
            View.IdCurrentFolder             = idFolder;
            View.CurrentFolderIdentifierPath = path;
            if (setBackUrl && String.IsNullOrEmpty(backUrl))
            {
                backUrl = View.GetPreviousRelativeUrl();
                if (!IsValidPreviousUrl(backUrl))
                {
                    backUrl    = "";
                    setBackUrl = false;
                }
                if (backUrl.StartsWith(RootObject.BaseRepositoryUrl(), StringComparison.InvariantCultureIgnoreCase) && rIdentifier != null)
                {
                    cookieRepository cookie = View.GetRepositoryCookie(rIdentifier);
                    if (cookie != null)
                    {
                        backUrl = RootObject.RepositoryItems(rIdentifier.Type, rIdentifier.IdCommunity, 0, cookie.IdFolder, cookie.Type, cookie.ItemsOrderBy, cookie.Ascending, cookie.IdentifierPath);
                    }
                }
                SetLogoutUrl(isEditPage, View.GetCurrentUrl(), setBackUrl, backUrl);
            }
            else
            {
                View.DefaultLogoutUrl = View.GetCurrentUrl();
            }
            View.BackUrl = (setBackUrl ? backUrl : "");
            View.SetPageBackUrl(backUrl);
            View.PageIdentifier = Guid.NewGuid();
            if (SessionTimeout())
            {
                return;
            }

            View.IsInitialized = true;
            ModuleRepository.ActionType uAction = ModuleRepository.ActionType.None;

            if (rIdentifier == null)
            {
                View.InitializeHeader();
                uAction = (isEditPage) ? ModuleRepository.ActionType.EditDetailsTryToLoad : ModuleRepository.ActionType.ViewDetailsTryToLoad;
                View.DisplayUnknownItem();
            }
            else
            {
                Int32 idCurrentUser             = UserContext.CurrentUserID;
                liteRepositorySettings settings = Service.SettingsGetByRepositoryIdentifier(rIdentifier);

                ModuleRepository module = Service.GetPermissions(rIdentifier, idCurrentUser);

                View.RepositoryIdentifier  = CacheKeys.RepositoryIdentifierKey(rIdentifier.Type, rIdentifier.IdCommunity);
                View.RepositoryIdCommunity = rIdentifier.IdCommunity;
                idCommunity         = rIdentifier.IdCommunity;
                View.RepositoryType = rIdentifier.Type;

                View.SetTitle(Service.ItemGetType(idItem));
                View.IsInitialized = true;
                if (settings != null)
                {
                    Boolean admin = module.ManageItems || module.Administration;
                    dtoDisplayRepositoryItem dto = Service.GetItemWithPermissionsAndStatistics(idItem, Service.GetAvailableRepositoryItems(settings, UserContext.CurrentUserID, rIdentifier.Type, rIdentifier.IdCommunity, View.GetUnknownUserName(), View.GetFolderTypeTranslation(), View.GetTypesTranslations(), module, admin, admin), UserContext.CurrentUserID);
                    if (dto != null)
                    {
                        if (!isEditPage && dto.Permissions.Edit)
                        {
                            View.SetUrlForEdit(RootObject.EditItem(idItem, idFolder, path, ItemAction.edit, (!String.IsNullOrWhiteSpace(backUrl)), backUrl));
                        }
                        else if (isEditPage)
                        {
                            View.SetUrlForView(RootObject.Details(idItem, idFolder, path, ItemAction.edit, (!String.IsNullOrWhiteSpace(backUrl)), backUrl));
                        }
                        if (!isEditPage || (isEditPage && dto.Permissions.Edit))
                        {
                            View.AllowSave = dto.Permissions.Edit && isEditPage;

                            View.AllowHideItem = dto.Permissions.Hide && isEditPage;
                            View.AllowShowItem = dto.Permissions.Show && isEditPage;
                            View.DisplayItemDetails(isEditPage, dto, settings.AutoThumbnailWidth, settings.AutoThumbnailHeight, settings.AutoThumbnailForExtension);
                            if (dto.Permissions.ViewPermission || dto.Permissions.EditPermission)
                            {
                                View.DisplayItemPermissions(isEditPage, dto);
                            }
                            if (isEditPage)
                            {
                                View.InitializeDefaultTags(ServiceTags.GetAvailableTags(rIdentifier.IdPerson, idCommunity, CurrentIdModule, ModuleRepository.UniqueCode));
                            }
                            else
                            {
                                View.InitializeHeader();
                            }
                            uAction = (isEditPage) ? ModuleRepository.ActionType.EditDetailsLoaded : ModuleRepository.ActionType.ViewDetailsLoaded;
                        }
                        else if (isEditPage)
                        {
                            View.SendUserAction(idCommunity, Service.GetIdModule(), ModuleRepository.ActionType.EditDetailsTryToLoad);
                            View.GoToUrl(RootObject.Details(idItem, idFolder, path, ItemAction.details, setBackUrl, backUrl));
                        }
                    }
                    else
                    {
                        if (isEditPage)
                        {
                            View.SetUrlForView(RootObject.Details(idItem, idFolder, path, ItemAction.edit, (!String.IsNullOrWhiteSpace(backUrl)), backUrl));
                        }

                        View.InitializeHeader();
                        View.DisplayNoPermission(idCommunity, Service.GetIdModule());
                        uAction = (isEditPage) ? ModuleRepository.ActionType.EditDetailsNoPermissions : ModuleRepository.ActionType.ViewDetailsNoPermissions;
                    }
                }
                else
                {
                    View.InitializeHeader();
                    uAction = (isEditPage) ? ModuleRepository.ActionType.EditDetailsTryToLoad : ModuleRepository.ActionType.ViewDetailsTryToLoad;
                    View.DisplayUnknownItem();
                }
            }
            View.SendUserAction(idCommunity, Service.GetIdModule(), uAction);
        }