Beispiel #1
0
        /// <summary> Add the HTML to be displayed </summary>
        /// <param name="Output"> Textwriter to write the HTML for this viewer </param>
        /// <param name="Tracer">Trace object keeps a list of each method executed and important milestones in rendering</param>
        public override void Add_HTML(TextWriter Output, Custom_Tracer Tracer)
        {
            if (Tracer != null)
            {
                Tracer.Add_Trace("User_Permissions_WebContentViewer.Add_HTML", "No html added");
            }

            Output.WriteLine("<div class=\"Wchs_Text\">");
            Output.WriteLine("  <p>Below are the users that have permissions to edit this page. This includes system and portal administrators, as well as users and user groups that are individually permissioned to this web content page.</p>");
            Output.WriteLine("</div>");


            // Try to get the global permissions table
            DataTable globalPermissions = HttpContext.Current.Cache["GlobalPermissionsReport"] as DataTable;

            if (globalPermissions == null)
            {
                globalPermissions = SobekCM_Database.Get_Global_User_Permissions(RequestSpecificValues.Tracer);
                if (globalPermissions == null)
                {
                    Output.WriteLine("  <br />");
                    Output.WriteLine("  <div id=\"sbkAdm_ActionMessageError\">Error pulling user permissions!</div>");
                }
                else
                {
                    HttpContext.Current.Cache.Insert("GlobalPermissionsReport", globalPermissions, null, DateTime.Now.AddSeconds(60d), Cache.NoSlidingExpiration);
                }
            }

            if (globalPermissions != null)
            {
                List <string> hostAdmins   = new List <string>();
                List <string> sysAdmins    = new List <string>();
                List <string> portalAdmins = new List <string>();

                foreach (DataRow thisUser in globalPermissions.Rows)
                {
                    string name = thisUser["LastName"] + ", " + thisUser["FirstName"];
                    if ((thisUser["Nickname"] != DBNull.Value) && (!String.IsNullOrEmpty(thisUser["Nickname"].ToString())))
                    {
                        name = name + " (\"" + thisUser["Nickname"] + "\")";
                    }

                    // Check for host admins
                    if (Convert.ToBoolean(thisUser["IsHostAdmin"]))
                    {
                        if (!hostAdmins.Contains(name))
                        {
                            hostAdmins.Add(name);
                        }
                    }
                    else if (Convert.ToBoolean(thisUser["IsSystemAdmin"]))
                    {
                        if (!sysAdmins.Contains(name))
                        {
                            sysAdmins.Add(name);
                        }
                    }
                    else if (Convert.ToBoolean(thisUser["IsPortalAdmin"]))
                    {
                        if (!portalAdmins.Contains(name))
                        {
                            portalAdmins.Add(name);
                        }
                    }
                }

                Output.WriteLine("  <table id=\"sbkUpav_ListTable\">");
                Output.WriteLine("    <tr>");


                // A bunch of code here just to write the admins in up to three columns and
                // start the table
                int column = 1;
                if (hostAdmins.Count > 0)
                {
                    Output.WriteLine("      <td style=\"width:33%\">");
                    add_user_list(Output, hostAdmins, "Host Administrators", false);
                    Output.WriteLine("      </td>");
                    column++;
                }

                if (sysAdmins.Count > 0)
                {
                    Output.WriteLine("      <td style=\"width:33%\">");
                    add_user_list(Output, sysAdmins, "System Administrators", false);
                    Output.WriteLine("      </td>");
                    column++;
                }

                if (portalAdmins.Count > 0)
                {
                    Output.WriteLine("      <td style=\"width:33%\">");
                    add_user_list(Output, portalAdmins, "Portal Administrators", false);
                    Output.WriteLine("      </td>");
                    column++;
                }

                while (column <= 3)
                {
                    Output.WriteLine("      <td style=\"width:33%\">&nbsp;</td>");
                    column++;
                }

                Output.WriteLine("    </tr>");

                Output.WriteLine("  </table>");
            }
        }