Esempio n. 1
0
 /// <summary> Constructor for a new instance of the Private_Items_AggregationViewer class </summary>
 /// <param name="Current_Mode"> Mode / navigation information for the current request</param>
 /// <param name="Current_Aggregation"> Current item aggregation object to display </param>
 /// <param name="Tracer">Trace object keeps a list of each method executed and important milestones in rendering</param>
 public Private_Items_AggregationViewer(SobekCM_Navigation_Object Current_Mode, Item_Aggregation Current_Aggregation, Custom_Tracer Tracer) : base(Current_Aggregation, Current_Mode)
 {
     privateItems = SobekCM_Database.Tracking_Get_Aggregation_Private_Items(currentCollection.Code, (int)RESULTS_PER_PAGE, currentMode.Page, currentMode.Sort, Tracer);
 }
        /// <summary> Constructor for a new instance of the Private_Items_AggregationViewer class </summary>
        /// <param name="RequestSpecificValues"> All the necessary, non-global data specific to the current request </param>
        public Private_Items_AggregationViewer(RequestCache RequestSpecificValues)
            : base(RequestSpecificValues)
        {
            // Ensure user has some permissions on this aggregation, or is a power/internal user or admin before showing
            // them this list
            if ((RequestSpecificValues.Current_User == null) || (!RequestSpecificValues.Current_User.LoggedOn))
            {
                RequestSpecificValues.Current_Mode.Aggregation_Type = Aggregation_Type_Enum.Home;
                UrlWriterHelper.Redirect(RequestSpecificValues.Current_Mode);
                return;
            }

            // Does this user have permissions on this itgem
            if (RequestSpecificValues.Current_User.PermissionedAggregations != null)
            {
                // Do they have some special permissions against this aggregation?
                bool special_permissions_found = false;
                foreach (User_Permissioned_Aggregation permissions in RequestSpecificValues.Current_User.PermissionedAggregations)
                {
                    if (String.Compare(permissions.Code, RequestSpecificValues.Hierarchy_Object.Code, StringComparison.OrdinalIgnoreCase) == 0)
                    {
                        if ((permissions.CanChangeVisibility) || (permissions.CanDelete) || (permissions.CanEditBehaviors) || (permissions.CanEditItems) ||
                            (permissions.CanEditMetadata) || (permissions.CanPerformQc) || (permissions.CanUploadFiles) || (permissions.IsAdmin) || (permissions.IsCurator))
                        {
                            special_permissions_found = true;
                            break;
                        }
                    }
                }

                // Are they a portal/system admin or power user?
                if ((!special_permissions_found) && ((RequestSpecificValues.Current_User.Is_Internal_User) || (RequestSpecificValues.Current_User.Is_Portal_Admin) || (RequestSpecificValues.Current_User.Is_System_Admin)))
                    special_permissions_found = true;

                // If no permissions, forward them back
                if (!special_permissions_found)
                {
                    RequestSpecificValues.Current_Mode.Aggregation_Type = Aggregation_Type_Enum.Home;
                    UrlWriterHelper.Redirect(RequestSpecificValues.Current_Mode);
                    return;
                }
            }
            else
            {
                // Are they a portal/system admin or power user?
                if ((!RequestSpecificValues.Current_User.Is_Internal_User) && (!RequestSpecificValues.Current_User.Is_Portal_Admin) && (!RequestSpecificValues.Current_User.Is_System_Admin))
                {
                    RequestSpecificValues.Current_Mode.Aggregation_Type = Aggregation_Type_Enum.Home;
                    UrlWriterHelper.Redirect(RequestSpecificValues.Current_Mode);
                    return;
                }
            }

            // Get the list of private items
            int current_sort = RequestSpecificValues.Current_Mode.Sort.HasValue ? RequestSpecificValues.Current_Mode.Sort.Value : 0;
            int current_page = RequestSpecificValues.Current_Mode.Page.HasValue ? RequestSpecificValues.Current_Mode.Page.Value : 1;
            privateItems = SobekCM_Database.Tracking_Get_Aggregation_Private_Items(RequestSpecificValues.Hierarchy_Object.Code, (int)RESULTS_PER_PAGE, current_page, current_sort, RequestSpecificValues.Tracer);
        }
        /// <summary> Constructor for a new instance of the Private_Items_AggregationViewer class </summary>
        /// <param name="RequestSpecificValues"> All the necessary, non-global data specific to the current request </param>
        /// <param name="ViewBag"> Aggregation-specific request information, such as aggregation object and any browse object requested </param>
        public Private_Items_AggregationViewer(RequestCache RequestSpecificValues, AggregationViewBag ViewBag)
            : base(RequestSpecificValues, ViewBag)
        {
            // Ensure user has some permissions on this aggregation, or is a power/internal user or admin before showing
            // them this list
            if ((RequestSpecificValues.Current_User == null) || (!RequestSpecificValues.Current_User.LoggedOn))
            {
                RequestSpecificValues.Current_Mode.Aggregation_Type = Aggregation_Type_Enum.Home;
                UrlWriterHelper.Redirect(RequestSpecificValues.Current_Mode);
                return;
            }

            // Does this user have permissions on this itgem
            if (RequestSpecificValues.Current_User.PermissionedAggregations != null)
            {
                // Do they have some special permissions against this aggregation?
                bool special_permissions_found = false;
                foreach (User_Permissioned_Aggregation permissions in RequestSpecificValues.Current_User.PermissionedAggregations)
                {
                    if (String.Compare(permissions.Code, ViewBag.Hierarchy_Object.Code, StringComparison.OrdinalIgnoreCase) == 0)
                    {
                        if ((permissions.CanChangeVisibility) || (permissions.CanDelete) || (permissions.CanEditBehaviors) || (permissions.CanEditItems) ||
                            (permissions.CanEditMetadata) || (permissions.CanPerformQc) || (permissions.CanUploadFiles) || (permissions.IsAdmin) || (permissions.IsCurator))
                        {
                            special_permissions_found = true;
                            break;
                        }
                    }
                }

                // Are they a portal/system admin or power user?
                if ((!special_permissions_found) && ((RequestSpecificValues.Current_User.Is_Internal_User) || (RequestSpecificValues.Current_User.Is_Portal_Admin) || (RequestSpecificValues.Current_User.Is_System_Admin)))
                {
                    special_permissions_found = true;
                }

                // If no permissions, forward them back
                if (!special_permissions_found)
                {
                    RequestSpecificValues.Current_Mode.Aggregation_Type = Aggregation_Type_Enum.Home;
                    UrlWriterHelper.Redirect(RequestSpecificValues.Current_Mode);
                    return;
                }
            }
            else
            {
                // Are they a portal/system admin or power user?
                if ((!RequestSpecificValues.Current_User.Is_Internal_User) && (!RequestSpecificValues.Current_User.Is_Portal_Admin) && (!RequestSpecificValues.Current_User.Is_System_Admin))
                {
                    RequestSpecificValues.Current_Mode.Aggregation_Type = Aggregation_Type_Enum.Home;
                    UrlWriterHelper.Redirect(RequestSpecificValues.Current_Mode);
                    return;
                }
            }

            // Get the list of private items
            int current_sort = RequestSpecificValues.Current_Mode.Sort.HasValue ? RequestSpecificValues.Current_Mode.Sort.Value : 0;
            int current_page = RequestSpecificValues.Current_Mode.Page.HasValue ? RequestSpecificValues.Current_Mode.Page.Value : 1;

            privateItems = Engine_Database.Tracking_Get_Aggregation_Private_Items(ViewBag.Hierarchy_Object.Code, (int)RESULTS_PER_PAGE, current_page, current_sort, RequestSpecificValues.Tracer);
        }
        /// <summary> Gets the list of all private and dark items linked to an item aggregation  </summary>
        /// <param name="AggregationCode"> Code for the item aggregation of interest </param>
        /// <param name="ResultsPerPage"> Number of results to return per "page" of results </param>
        /// <param name="ResultsPage"> Which page of results to return ( one-based, so the first page is page number of one )</param>
        /// <param name="Sort"> Current sort to use ( 0 = default by search or browse, 1 = title, 10 = date asc, 11 = date desc )</param>
        /// <param name="Tracer"> Tracer object keeps track of all executions that take place while meeting a user's request </param>
        /// <returns> Table with all of the item and item group information </returns>
        /// <remarks> This calls the 'Tracking_Get_Aggregation_Privates' stored procedure.</remarks>
        public static Private_Items_List Tracking_Get_Aggregation_Private_Items(string AggregationCode, int ResultsPerPage, int ResultsPage, int Sort, Custom_Tracer Tracer)
        {
            if (Tracer != null)
                Tracer.Add_Trace("Engine_Database.Tracking_Get_Aggregation_Private_Items", "Pulling list of private items for this aggregation");

            // Build the parameters list
            List<EalDbParameter> parameters = new List<EalDbParameter>
            {
                new EalDbParameter("@code", AggregationCode),
                new EalDbParameter("@pagesize", ResultsPerPage),
                new EalDbParameter("@pagenumber", ResultsPage),
                new EalDbParameter("@sort", Sort),
                new EalDbParameter("@minpagelookahead", 1),
                new EalDbParameter("@maxpagelookahead", 1),
                new EalDbParameter("@lookahead_factor", LOOKAHEAD_FACTOR)
            };

            // Add parameters for total items and total titles
            EalDbParameter totalItemsParameter = new EalDbParameter("@total_items", 0) { Direction = ParameterDirection.InputOutput };
            parameters.Add(totalItemsParameter);

            EalDbParameter totalTitlesParameter = new EalDbParameter("@total_titles", 0) { Direction = ParameterDirection.InputOutput };
            parameters.Add(totalTitlesParameter);

            // Create the database agnostic reader
            EalDbReaderWrapper readerWrapper = EalDbAccess.ExecuteDataReader(DatabaseType, Connection_String + "Connection Timeout=45", CommandType.StoredProcedure, "Tracking_Get_Aggregation_Privates", parameters);

            // Pull out the database reader
            DbDataReader reader = readerWrapper.Reader;

            // Create the return argument object
            Private_Items_List returnArgs = new Private_Items_List { TitleResults = DataReader_To_Private_Items_List(reader) };

            // Close the reader (which also closes the connection)
            readerWrapper.Close();

            // Store the total items/titles
            returnArgs.TotalItems = Convert.ToInt32(totalItemsParameter.Value);
            returnArgs.TotalTitles = Convert.ToInt32(totalTitlesParameter.Value);

            if (Tracer != null)
                Tracer.Add_Trace("Engine_Database.Tracking_Get_Aggregation_Private_Items", "Done pulling list of private items");

            return returnArgs;
        }