Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Stephane Crozat
apisub
Commits
66ecbcc8
Commit
66ecbcc8
authored
Feb 07, 2019
by
Stephane Crozat
Browse files
Ajout trombinoscope
parent
86ea0c64
Changes
3
Hide whitespace changes
Inline
Side-by-side
api.php
0 → 100644
View file @
66ecbcc8
<?php
if
(
!
isset
(
$_GET
[
'api'
]))
{
header
(
'Location:index.php'
);
}
else
{
session_start
();
include
'lib/cas_connect.php'
;
include
'lib/db.php'
;
include
'lib/views.php'
;
include
'lib/admin.php'
;
$db
=
new
DB
();
$admin
=
new
Admin
(
$db
);
$view
=
new
Views
(
$admin
,
$_SESSION
[
'utclogin'
],
$_SESSION
[
'surname'
],
$_SESSION
[
'firstname'
]);
$view
->
printHtmlBegin
(
$admin
);
$view
->
printUser
(
$db
->
isResp
(
$_SESSION
[
'utclogin'
]),
$db
->
isAdmin
(
$_SESSION
[
'utclogin'
]));
$view
->
apiStudents
(
$db
->
apiStudents
(
$_SESSION
[
'utclogin'
],
$_GET
[
'api'
]));
}
?>
lib/db.php
View file @
66ecbcc8
...
...
@@ -203,5 +203,26 @@ class DB {
}
}
public
function
apiStudents
(
$utclogin
,
$api
)
{
if
(
$this
->
isAdmin
(
$utclogin
))
{
$sql
=
'SELECT *
FROM vsubscription
WHERE id=:api AND resplogin=:utclogin AND validation
ORDER BY surname, firstname'
;
//TODO donner accès aux admins même si ne sont pas les resp
}
else
{
$sql
=
'SELECT *
FROM vsubscription
WHERE id=:api AND resplogin=:utclogin AND validation
ORDER BY surname, firstname'
;
}
$st
=
$this
->
conn
->
prepare
(
$sql
);
$st
->
bindValue
(
':api'
,
$api
,
PDO
::
PARAM_STR
);
$st
->
bindValue
(
':utclogin'
,
$utclogin
,
PDO
::
PARAM_STR
);
$st
->
execute
();
$res
=
$st
->
fetchAll
(
PDO
::
FETCH_ASSOC
);
return
$res
;
}
}
lib/views.php
View file @
66ecbcc8
...
...
@@ -151,6 +151,7 @@ class Views {
$api
=
$sub
[
'id'
];
echo
'<hr/>'
;
echo
'<h2>'
.
$this
->
printApi
(
$sub
)
.
'</h2>'
;
echo
"<div><a href='api.php?api=
$api
'>> Trombinoscope</a></div>"
;
}
if
(
$sub
[
'utclogin'
])
{
if
(
$sub
[
'validation'
])
{
...
...
@@ -176,6 +177,32 @@ class Views {
}
}
public
function
apiStudents
(
$students
)
{
echo
"<hr/>"
;
if
(
isset
(
$students
[
0
]))
{
echo
'<h2>'
.
$this
->
printApi
(
$students
[
0
])
.
'</h2>'
;
}
else
{
echo
'<h2>Aucun inscrit</h2>'
;
}
foreach
(
$students
as
$s
)
{
echo
"<div class='student'>
<img src='https://demeter.utc.fr/portal/pls/portal30/portal30.get_photo_utilisateur?username=
$s[utclogin]
'
height='100px'
width='100px'/>
<span class='name'>
$s[surname]
$s[firstname]
|
$s[level]
| <a href='mailto:
$s[email]'>$s[email]
</a> (
$s[utclogin]
)</span>
</div>"
;
}
}
public
function
apiStudentsCsv
(
$students
)
{
//TODO
foreach
(
$students
as
$s
)
{
echo
"
$s[surname];$s[firstname];$s[level];$s[email];$s[utclogin]
\n
"
;
}
}
public
function
adminFunction
(
$utclogin
)
{
echo
"<p>Je dois vérifier que
$utclogin
a vraiment des super-pouvoirs...</p>"
;
}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment