-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.php
More file actions
192 lines (155 loc) · 4.07 KB
/
index.php
File metadata and controls
192 lines (155 loc) · 4.07 KB
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
<?php
/* NAME
*
* index.php
*
* CONCEPT
*
* Top-level index file for the pattern selection projects.
*/
header("Cache-Control: no-store, no-cache, must-revalidate, max-age=0");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
function isactive($p) {
return($p['id'] && $p['active']);
} /* end isactive() */
function aintactive($p) {
return($p['id'] && !$p['active']);
} /* end aintactive() */
set_include_path(get_include_path() . PATH_SEPARATOR . 'project');
require 'lib/ps.php';
DataStoreConnect();
Initialize();
$projects = GetProjects();
if($isLogged = $auth->isLogged()) {
$userinfo = $auth->getCurrentSessionUserInfo();
$timestamp = strtotime($userinfo['expiredate']);
$expire = "<script>\n let exptime = $timestamp\n</script>\n";
} else {
$expire = '';
}
print "<!doctype html>
<html lang=\"en\">
<head>
<title>Pattern Sphere</title>
<link rel=\"stylesheet\" href=\"project/lib/ps.css\">
<script src=\"project/lib/ps.js\"></script>
$expire
</head>
<body>
<header>
<h1>Pattern Sphere</h1>
</header>
<div id=\"poutine\">
<img src=\"images/pattern-sphere-band.png\" id=\"gravy\">
";
$intro = GetAppConfig('appintro');
print $intro;
print "<h2>Projects</h2>
";
$super = $omanager = $tmanager = '';
if($isLogged) {
// This user has a login.
$user = $auth->getCurrentUser(true);
$actual = $user;
$action = array(' <li><a href="log.php">Log out</a></li>',
' <li><a href="profile.php">Edit profile</a></li>');
if($user['role'] == 'super') {
# this user is a super; offer the super menu
$super = '<div id="super">
<div class="banner">Super actions</div>
<ul>
<li><a href="config.php">Edit config</a></li>
<li><a href="users.php">Manage users</a></li>
<li><a href="patterneditor.php">Manage patterns</a></li>
<li><a href="projecteditor.php">Manage projects</a></li>
<li><a href="orgeditor.php">Manage organizations</a></li>
<li><a href="teameditor.php">Manage teams</a></li>
</ul>
</div>
';
} else {
$teams = ManagedTeams($user['id']);
if(count($teams)) {
// this user manages one or more teams
$tmanager = '<div id="mange">
<div class="banner">Team management</div>
<ul>
<li><a href="teameditor.php">Manage teams</a></li>
</ul>
</div>
';
}
$orgs = ManagedOrgs($user['id']);
if(count($orgs)) {
// this user manages one or more organizations
$omanager = '<div id="omange">
<div class="banner">Organization management</div>
<ul>
<li><a href="orgeditor.php">Manage organizations</a></li>
</ul>
</div>
';
}
}
} else {
// is not authenticated
$action = [
'<li><a href="register.php">Register</a></li>',
'<li><a href="log.php">Log in</a></li>',
'<li><a href="reset.php">Reset password</a></li>'
];
?>
<?php
}
$actions = join('', $action);
?>
<div id="actions">
<div id="authactions">
<div class="banner">User actions</div>
<ul>
<?=$actions?>
</ul>
</div>
<?=$omanager?>
<?=$tmanager?>
<?=$super?>
</div>
<?php
# Present a menu of active projects to all comers.
if(count($projects))
$aprojects = array_filter($projects, 'isactive');
else
$aprojects = [];
if(count($aprojects)) {
print "<ul>\n";
foreach($aprojects as $aproject) {
$purl = "project/index.php/{$aproject['tag']}";
print "<li><a href=\"$purl\">{$aproject['title']}</a></li>\n";
}
print "</ul>\n";
} else {
print "<p class=\"alert\" style=\"margin-left: 1em\">No active projects.</p>\n";
}
# Present a menu of inactive projects to admins.
if(isset($user) && $user['role'] == 'super') {
if(count($projects)) {
$iprojects = array_filter($projects, 'aintactive');
if(DEBUG) error_log('Found ' . count($iprojects) . ' inactive projects');
} else
$iprojects = [];
print "<h3>Inactive Projects</h3>\n";
if(count($iprojects)) {
print "<ul>\n";
foreach($iprojects as $iproject)
print " <li><a href=\"{$iproject['tag']}/\">{$iproject['title']}</a></li>\n";
print "</ul>\n";
} else
print "<p class=\"alert\" style=\"margin-left: 1em\">No inactive projects.</p>\n";
}
?>
</ul>
</div>
<?=FOOT?>
</body>
</html>