/
Detail.inc.php
235 lines (223 loc) · 6.48 KB
/
Detail.inc.php
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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
<?php
namespace PhoenixSNS\Modules\Community;
use WebFX\System;
use WebFX\Controls\ButtonGroup;
use WebFX\Controls\ButtonGroupButton;
use WebFX\Controls\BreadcrumbItem;
use WebFX\Controls\Panel;
use PhoenixSNS\Objects\Group;
use PhoenixSNS\Objects\User;
use PhoenixSNS\Pages\ErrorPage;
$thisgroup = Group::GetByIDOrName($path[1]);
if ($thisgroup == null)
{
$page = new ErrorPage("Group not found");
$page->Message = "That group does not exist in the system. It may have been deleted, or you may have typed the name incorrectly.";
$page->ReturnButtonURL = "~/community/groups";
$page->ReturnButtonText = "Return to Group List";
$page->Render();
return;
}
class GroupDetailPage extends CommunityPage
{
public $Group;
public $Path;
public function __construct($group)
{
parent::__construct();
$this->Title = $group->Title;
$this->Group = $group;
}
protected function Initialize()
{
parent::Initialize();
$this->BreadcrumbItems = array
(
new BreadcrumbItem("~/community", "Community"),
new BreadcrumbItem("~/community/groups", "Groups"),
new BreadcrumbItem("~/community/groups/" . $this->Group->Name, $this->Group->Title)
);
}
protected function RenderContent()
{
$CurrentUser = User::GetCurrent();
?>
<div class="Card">
<div class="Title">
<i class="fa fa-users"></i> <span class="Text"><?php echo($this->Group->Title); ?></span>
</div>
<div class="Content">
<table style="width: 100%">
<tr>
<td style="width: 128px;"><img src="<?php echo(System::ExpandRelativePath("~/community/groups/" . $this->Group->Name . "/images/avatar/thumbnail.png")); ?>" style="width: 112px; height: 112px;" /></td>
<td><?php echo($this->Group->Description); ?></td>
</tr>
</table>
<table style="width: 100%">
<tr>
<td style="width: 25%">Created on:</td>
<td><?php echo($this->Group->DateCreated); ?></td>
</tr>
</table>
</div>
<div class="Actions Horizontal">
<?php
if ($CurrentUser != null)
{
if ($this->Group->HasMember($CurrentUser))
{
?>
<a title="Invite Friends" href="<?php echo(System::ExpandRelativePath("~/community/groups/" . $this->Group->Name . "/invite")); ?>" onclick="InviteFriendsDialog.Show(<?php echo($this->Group->ID); ?>); return false;"><i class="fa fa-share-square-o"></i> <span class="Text">Invite Friends</span></a>
<a title="Leave Group" href="<?php echo(System::ExpandRelativePath("~/community/groups/" . $this->Group->Name . "/disconnect")); ?>"><i class="fa fa-sign-out"></i> <span class="Text">Leave Group</span></a>
<?php
}
else if ($this->Group->HasPermission($CurrentUser, 2) || $this->Group->HasPermission($CurrentUser, 3))
{
?>
<a title="Join Group" href="<?php echo(System::ExpandRelativePath("~/community/groups/" . $this->Group->Name . "/connect")); ?>"><i class="fa fa-sign-in"></i> <span class="Text">Join Group</span></a>
<?php
}
if ($this->Group->HasPermission($CurrentUser, 4))
{
?>
<a title="Change Group Settings" href="<?php echo(System::ExpandRelativePath("~/community/groups/" . $this->Group->Name . "/settings")); ?>"><i class="fa fa-cog"></i> <span class="Text">Change Group Settings</span></a>
<?php
}
if ($this->Group->Creator->ID == $CurrentUser->ID)
{
?>
<a title="Delete Group" href="<?php echo(System::ExpandRelativePath("~/community/groups/" . $this->Group->Name . "/delete.phnx")); ?>"><i class="fa fa-trash-o"></i> <span class="Text">Delete Group</span></a>
<?php
}
}
else
{
?><i class="fa fa-warning"></i> Please log in to join this group.<?php
}
?>
</div>
</div>
<div class="Card">
<div class="Title">
<i class="fa fa-comments"></i> <span class="Text">Discussions (<?php echo($this->Group->CountTopics()); ?>)</span>
</div>
<div class="Content">
<div class="ListBox">
<?php
$topics = $this->Group->GetTopics(5);
foreach ($topics as $topic)
{
?>
<a href="<?php echo(System::ExpandRelativePath("~/community/groups/" . $this->Group->Name . "/topics/" . $topic->Name)); ?>">
<div class="ListItemTitle"><?php echo($topic->Title); ?></div>
</a>
<?php
}
?>
</div>
</div>
<div class="Actions Horizontal">
<?php
if ($this->Group->HasMember($CurrentUser))
{
?>
<a href="<?php echo(System::ExpandRelativePath("~/community/groups/" . $this->Group->Name . "/topics/create.mmo")); ?>" title="Start a discussion"><i class="fa fa-pencil-square-o"></i> <span class="Text">Start a discussion</span></a>
<?php
}
?>
</div>
</div>
<div class="Card">
<div class="Title">
<i class="fa fa-shield"></i> <span class="Text">Members (<?php echo($this->Group->CountMembers()); ?>)</span>
</div>
<div class="Content">
<div class="ButtonGroup ButtonGroupHorizontal">
<?php
$members = $this->Group->GetMembers();
foreach ($members as $member)
{
?>
<a class="ButtonGroupButton" href="<?php echo(System::ExpandRelativePath("~/community/members/" . $member->ShortName)); ?>" onclick="DisplayMemberInformation(<?php echo($member->ID); ?>); return false;">
<img class="ButtonGroupButtonImage" src="<?php echo(System::ExpandRelativePath("~/community/members/" . $member->ShortName . "/images/avatar/thumbnail.png")); ?>" />
<span class="ButtonGroupButtonText"><?php echo($member->ToString()); ?></span>
</a>
<?php
}
?>
</div>
</div>
</div>
<?php
}
}
switch ($path[2])
{
case "images":
{
switch ($path[3])
{
case "avatar":
{
switch ($path[4])
{
case "thumbnail.png":
{
// paths are relative to the path of the including file
header("Content-Type: image");
$fileName = "images/icons/group.png";
// header("Content-Type: " . mime_content_type("images/icons/group.png"));
readfile($fileName);
return;
}
}
break;
}
}
break;
}
case "delete.phnx":
{
require("delete.inc.php");
return;
}
case "connect":
{
$this->Group->AddMember($CurrentUser);
System::Redirect("~/community/groups/" . $this->Group->Name);
return;
}
case "disconnect":
{
$this->Group->RemoveMember($CurrentUser);
System::Redirect("~/community/groups/" . $this->Group->Name);
return;
}
default:
{
if (count($path) > 3 && $path[3] != "")
{
switch($path[3])
{
case "create.mmo":
{ // BEGIN create.mmo
require("Topics/Create.inc.php");
return;
} // END create.mmo
default:
{
require("Topics/Detail.inc.php");
return;
}
}
}
else
{
$page = new GroupDetailPage($thisgroup);
$page->Path = $path[2];
$page->Render();
return;
}
}
}
?>