Skip to content
GitLab
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
93819d7f
Commit
93819d7f
authored
Jan 26, 2019
by
Stephane Crozat
Browse files
Modification de l'index pour gérer le cas resp et le cas admin
parent
0a3dc27c
Changes
3
Hide whitespace changes
Inline
Side-by-side
castest.php
deleted
100644 → 0
View file @
0a3dc27c
<?php
session_start
();
if
(
!
isset
(
$_SESSION
[
'login'
]))
{
/* If session is already open for current PHP file, user is already logged in, do nothing
If session is not open on current PHP file, check if it is open on CAS server
If it is open on CAS server retrieve session informations
If it is not on open on CAS server, ask for login to CAS server
*/
include
$_SERVER
[
'DOCUMENT_ROOT'
]
.
'/apisub/lib/cas.php'
;
$info
=
CAS
::
authenticate
();
if
(
$info
!=
-
1
)
{
$_SESSION
[
'ticket'
]
=
$_GET
[
'ticket'
];
$_SESSION
[
'utclogin'
]
=
$info
[
'cas:user'
];
$_SESSION
[
'mail'
]
=
$info
[
'cas:attributes'
][
'cas:mail'
];
$_SESSION
[
'surname'
]
=
strtoupper
(
$info
[
'cas:attributes'
][
'cas:sn'
]);
$_SESSION
[
'firstname'
]
=
$info
[
'cas:attributes'
][
'cas:givenName'
];
}
else
CAS
::
login
();
}
echo
$_SESSION
[
'ticket'
]
.
" "
.
$_SESSION
[
'utclogin'
]
?>
index.php
View file @
93819d7f
...
...
@@ -38,7 +38,15 @@ $view = new Views($admin, $_SESSION['utclogin'], $_SESSION['surname'], $_SESSION
$view
->
printHtmlBegin
();
$view
->
printUser
(
$db
->
isResp
(
$_SESSION
[
'utclogin'
]),
$db
->
isAdmin
(
$_SESSION
[
'utclogin'
]));
$view
->
printInstructions
(
$db
->
config
());
if
(
isset
(
$_GET
[
'mode'
]))
{
if
(
$_GET
[
'mode'
]
==
'resp'
)
{
$view
->
respValidation
(
$_SESSION
[
'utclogin'
]);
}
if
(
$_GET
[
'mode'
]
==
'admin'
)
{
$view
->
adminFunction
(
$_SESSION
[
'utclogin'
]);
}
}
/** Subscription and unsubscription management **/
if
(
isset
(
$_GET
[
'api'
])
&&
$admin
->
isActive
())
{
...
...
@@ -52,6 +60,7 @@ if (isset($_GET['api']) && $admin->isActive()) {
}
}
$view
->
printInstructions
(
$db
->
config
());
$view
->
printSubList
(
$db
->
subList
(
$_SESSION
[
'utclogin'
]));
$view
->
printApiList
(
$db
->
apiList
(
'E'
,
2019
),
$_SESSION
[
'utclogin'
]);
...
...
lib/views.php
View file @
93819d7f
...
...
@@ -39,10 +39,10 @@ class Views {
public
function
printUser
(
$isResp
,
$isAdmin
)
{
echo
"<p><i>
$this->firstname
$this->surname
</i> (<b>
$this->utclogin
</b>)</p>"
;
if
(
$isResp
)
{
echo
'<a href="
resp.ph
p">[Gérer ses Api]</a> '
;
echo
'<a href="
index.php?mode=res
p">[Gérer ses Api]</a> '
;
}
if
(
$isAdmin
)
{
echo
'<a href="admin
.php
">[Super-pouvoirs]</a>'
;
echo
'<a href="
index.php?mode=
admin">[Super-pouvoirs]</a>'
;
}
}
...
...
@@ -100,4 +100,11 @@ class Views {
}
}
public
function
respValidation
(
$utclogin
)
{
echo
"<p>Je dois vérifier que
$utclogin
est un responsable d'Api</p>"
;
}
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
.
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