-
Notifications
You must be signed in to change notification settings - Fork 0
/
facebook.php
159 lines (135 loc) · 5.48 KB
/
facebook.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
<?php
require_once( "include/page_elements.php" );
require_once( "include/directory.php" );
/* Short and sweet */
define('WP_USE_THEMES', false);
require_once('wp-backend/wp-blog-header.php');
http_response_code(200); // override wp
// must be logged in
if ( ! is_user_logged_in() )
{
header('Location: /login.php?r=%2ffacebook.php');
die();
}
// TEMP?
//if ( isset( $_GET['clean'] ) ) {
// $message = cleanFacebook( $_GET['clean'] );
//} else
if ( isset( $_FILES['upload'] ) )
{
$message = facebookUpload( $_FILES['upload'] );
}
// Comparison function
function acct_type( $user ) {
$r = $user->get( 'team_role' );
if (gettype($r) !== 'array') return 4;
// careful of the comparison operator!
if ( array_search( 'Student', $r ) !== FALSE ) return 0;
if ( array_search( 'Coach', $r ) !== FALSE || array_search( 'Mentor', $r ) !== FALSE ) return 1;
if ( array_search( 'Alum', $r ) !== FALSE ) return 2;
return 3;
}
function user_cmp( $a, $b ) {
$aVal = acct_type( $a );
$bVal = acct_type( $b );
if ( $aVal != $bVal )
return ( $aVal < $bVal) ? -1 : 1;
$aVal = $a->last_name;
$bVal = $b->last_name;
if ( $aVal != $bVal )
return ( $aVal < $bVal) ? -1 : 1;
$aVal = $a->first_name;
$bVal = $b->first_name;
if ( $aVal != $bVal )
return ( $aVal < $bVal) ? -1 : 1;
return 0;
}
?>
<!DOCTYPE html>
<html>
<?php page_head( "LigerBots Facebook" ); ?>
<body>
<div id="header-ghost" ></div>
<div class="container-fluid no-side-padding">
<div class="col-xs-12 no-side-padding">
<?php
output_header();
output_navbar();
?>
<div class="row page-body">
<div class="col-md-12 col-md-offset-0 col-sm-10 col-sm-offset-1 col-xs-12">
<div class="row top-spacer"> </div>
<div class="row bottom-margin row-margins">
<div class="col-xs-12">
<?php
if ( ! empty( $message ) ) echo '<div class="alert">' . $message . '</div>' . "\n";
?>
<center>
<div class="notindex-title">LIGERBOTS FACEBOOK</div>
<br/><br/>
The information on this page is confidential - It is only available to registered and approved users.
<br/>
</center>
<?php
if ( current_user_can( 'edit_posts' ) ) {
echo '<br><form class="form-inline" action="' . $_SERVER['PHP_SELF'] . '" method="post" enctype="multipart/form-data">';
echo '<div class="form-group">';
echo '<label for="upload">Select multiple pictures to upload:</label>';
echo '<input class="form-control" type="file" id="upload" name="upload[]" multiple>';
echo "</div>\n";
echo '<button name="submit" type="submit" class="btn btn-default">Submit</button>';
echo "</form>\n";
}
$userlist = get_users();
// Sort the users: first by student/mentor/parent, then by name
uasort( $userlist, 'user_cmp' );
$prevType = -1;
foreach ( $userlist as $user ) {
// Don't list users who have not been approved
if ( ! $user->get( 'wp-approve-user' ) ) continue;
if ( $user->user_login === 'attendance-pi' ) continue;
$type = acct_type( $user );
if ( $type != $prevType ) {
if ( $prevType >= 0 ) echo '<div style="clear:left"></div>' . "\n";
if ( $type == 0 )
echo "<h2>Students</h2>\n";
else if ( $type == 1 )
echo "<h2>Coaches and Mentors</h2>\n";
else if ( $type == 2 )
echo "<h2>Alumni</h2>\n";
else
{
// Don't have any Parent pictures, so skip for now.
break;
// echo "<h2>Parents</h2>\n";
}
}
echo '<div class="facebook-entry">';
$fb_img = $user->get( 'facebook_image' );
if ( strlen($fb_img) == 0 ) $fb_img = "no_image.jpg";
echo '<img src="/images/facebook/' . $fb_img . '">';
echo "<br>\n";
echo '<div class="name';
if ( array_search( 'Exec', $user->get( 'team_role' ) ) !== FALSE ) echo ' exec';
echo '">' . $user->first_name . ' ' . $user->last_name . "</div>\n";
if ( $type == 0 ) {
// Student: add school name
if ( $user->get( 'school' ) == 'North' )
echo '<div class="north">North</div>';
else
echo '<div class="south">South</div>';
}
echo "</div>\n";
$prevType = $type;
}
?>
</div>
</div>
<?php output_footer(); ?>
</div>
</div>
</div>
</div>
<?php page_foot(); ?>
</body>
</html>