protected void Page_Load(object sender, EventArgs e)
{
try
{
//link for the Chat Archives
//hlArchive.NavigateUrl = EditUrl("Archive",);
StartMessage = Settings.Contains("StartMessage") ? Settings["StartMessage"].ToString() : Localization.GetString("DefaultStartMessage", LocalResourceFile);
DefaultAvatarUrl = Settings.Contains("DefaultAvatarUrl") ? Settings["DefaultAvatarUrl"].ToString() : Localization.GetString("DefaultAvatarUrl", LocalResourceFile);
var directRoom = string.Empty;
var qs = Request.QueryString["rmid"];
if (qs != null)
{
directRoom = qs.ToString();}
if (Settings.Contains("DefaultRoomId") && directRoom == string.Empty)
{
DefaultRoomId = Settings["DefaultRoomId"].ToString();
}
else if (directRoom != string.Empty)
{ //if a guid came in, let's put the user in that room.
DefaultRoomId = directRoom;
}
else
{
//if we don't have a setting. go get the default room from the database.
var rc = new RoomController();
var r = rc.GetRoom("Lobby");
if (r == null || (r.ModuleId > 0 && r.ModuleId != ModuleId))
{
//todo: if there isn't a room we need display a message about creating one
}
else
{
//if the default room doesn't have a moduleid on it, set the module id
if (r.ModuleId < 0)
{
r.ModuleId = ModuleId;
}
rc.UpdateRoom(r);
}
if (r != null) DefaultRoomId = r.RoomId.ToString();
}
//encrypt the user's roles so we can ensure security
var curRoles = UserInfo.Roles;
var section = (MachineKeySection)ConfigurationManager.GetSection("system.web/machineKey");
var pc = new PortalSecurity();
foreach (var c in curRoles)
{
EncryptedRoles += pc.Encrypt(section.ValidationKey, c) + ",";
}
if (UserInfo.IsSuperUser)
{
EncryptedRoles += pc.Encrypt(section.ValidationKey, "SuperUser");
}
}
catch (Exception exc) //Module failed to load
{
Exceptions.ProcessModuleLoadException(this, exc);
}
}