Esempio n. 1
0
        private void SetLogoutUrl(Boolean isEditPage, String currentUrl, Boolean setBackUrl, String backUrl)
        {
            if (!setBackUrl)
            {
                backUrl = "";
            }

            View.DefaultLogoutUrl = (isEditPage ?
                                     RootObject.EditItem(View.PreloadIdItem, View.PreloadIdFolder, View.PreloadIdentifierPath, ItemAction.edit, setBackUrl, backUrl)
                                :
                                     RootObject.Details(View.PreloadIdItem, View.PreloadIdFolder, View.PreloadIdentifierPath, ItemAction.details, setBackUrl, backUrl)
                                     );
        }
Esempio n. 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);
        }