/
ShowUser.aspx.cs
73 lines (69 loc) · 3.29 KB
/
ShowUser.aspx.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
using System;
using AspNetDating.Classes;
namespace AspNetDating
{
public partial class ShowUserPage : PageBase
{
public ShowUserPage()
{
RequiresAuthorization = false;
}
protected void Page_Load(object sender, EventArgs e)
{
}
protected override void OnPreRender(EventArgs e)
{
ViewProfileCtrl.User = ((ShowUser) Master).ViewedUser;
Classes.User ViewedUser = ((ShowUser)Master).ViewedUser;
if (CurrentUserSession != null && ViewedUser != null && ViewedUser.Username == CurrentUserSession.Username)
Response.Redirect("~/ManageProfile.aspx");
if (!IsPostBack)
{
if (CurrentUserSession == null)
{
if (!ViewedUser.IsOptionEnabled(eUserOptions.VisitorsCanViewProfile))
{
if (ViewedUser.IsOptionEnabled(eUserOptions.UsersCanViewProfile))
Response.Redirect(String.Format("~/ShowUserError.aspx?uid={0}&error=ro", Request.Params["uid"]));
else if (ViewedUser.IsOptionEnabled(eUserOptions.FriendsOfFriendsCanViewProfile))
Response.Redirect(String.Format("~/ShowUserError.aspx?uid={0}&error=fof", Request.Params["uid"]));
else Response.Redirect(String.Format("~/ShowUserError.aspx?uid={0}&error=fo", Request.Params["uid"]));
}
}
else
{
if (ViewedUser.Username != CurrentUserSession.Username
&& !ViewedUser.IsOptionEnabled(eUserOptions.VisitorsCanViewProfile)
&& !ViewedUser.IsOptionEnabled(eUserOptions.UsersCanViewProfile))
{
if (ViewedUser.IsOptionEnabled(eUserOptions.FriendsOfFriendsCanViewProfile))
{
if (!ViewedUser.IsUserInFriendList(CurrentUserSession.Username))
{
bool areFriends = false;
string[] friends = Classes.User.FetchMutuallyFriends(ViewedUser.Username);
foreach (string friend in friends)
{
if (Classes.User.IsUserInFriendList(friend, CurrentUserSession.Username))
{
areFriends = true;
break;
}
}
if (!areFriends)
{
Response.Redirect(String.Format("~/ShowUserError.aspx?uid={0}&error=fof", Request.Params["uid"]));
}
}
}
else if (!ViewedUser.IsUserInFriendList(CurrentUserSession.Username))
{
Response.Redirect(String.Format("~/ShowUserError.aspx?uid={0}&error=fo", Request.Params["uid"]));
}
}
}
}
base.OnPreRender(e);
}
}
}