Beginning cleanup stage
This commit is contained in:
parent
b19f2f8ac4
commit
aee930ecff
@ -130,8 +130,8 @@
|
||||
//on login see if user name fields are set and if not copy from saml when using saml, and then reload
|
||||
if (Registry::AUTHMETHOD == 'SAML') {
|
||||
if ($StaticFunctions->getUserSessionStatus() == true) {
|
||||
if (empty($Users->getUserInitials($uid)[0]["users_lastname"])) {
|
||||
$Users->updateSAMLName($uid, $attributes['http://schemas.xmlsoap.org/ws/2005/05/identity/claims/givenname'][0], $attributes['http://schemas.xmlsoap.org/ws/2005/05/identity/claims/surname'][0]);
|
||||
if (empty($Users->readUserFirstAndLast($uid)[0]["users_lastname"])) {
|
||||
$Users->updateSamlFirstAndLast($uid, $attributes['http://schemas.xmlsoap.org/ws/2005/05/identity/claims/givenname'][0], $attributes['http://schemas.xmlsoap.org/ws/2005/05/identity/claims/surname'][0]);
|
||||
?>
|
||||
|
||||
<div class="jumbotron">
|
||||
@ -340,7 +340,7 @@ $(document).on("click", ".open-voidModal", function (e) {
|
||||
<span class="badge badge-light"><?php echo $transLang['BADGE']; ?></span> <?php echo $row['visits_badge']; ?>
|
||||
</div>
|
||||
<div>
|
||||
<span class="badge badge-light"><?php echo $transLang['SIGNINBY']; ?></span> <?php echo $Users->getUserInitials($row['visits_initials'])[0]["users_firstname"] . " " . $Users->getUserInitials($row['visits_initials'])[0]["users_lastname"]; ?>
|
||||
<span class="badge badge-light"><?php echo $transLang['SIGNINBY']; ?></span> <?php echo $Users->readUserFirstAndLast($row['visits_initials'])[0]["users_firstname"] . " " . $Users->readUserFirstAndLast($row['visits_initials'])[0]["users_lastname"]; ?>
|
||||
</div>
|
||||
|
||||
|
||||
|
@ -186,7 +186,7 @@
|
||||
<td><?php echo $row['visits_lastname'] . ", " . $row['visits_firstname']; ?><br /><img src="<?php echo $row['visits_signature']; ?>" width="200" height="50" alt="Signature" /></td>
|
||||
<td><?php if (!empty($row['visits_escort'])) {echo $row['visits_escort'] . '<br /><img src="' . $row['visits_escort_signature'] . '" width="200" height="50" alt="Escort Signature" />'; } ?></td>
|
||||
<td><?php echo $row['visits_badge']; ?></td>
|
||||
<td><?php echo $Users->getUserInitials($row['visits_initials'])[0]["users_firstname"] . " " . $Users->getUserInitials($row['visits_initials'])[0]["users_lastname"]; ?></td>
|
||||
<td><?php echo $Users->readUserFirstAndLast($row['visits_initials'])[0]["users_firstname"] . " " . $Users->readUserFirstAndLast($row['visits_initials'])[0]["users_lastname"]; ?></td>
|
||||
<?php if($SiteInfo->getSite($siteid, $uid, "0", "0")[0]["sites_region"] == "EMEA") { ?>
|
||||
<td><?php echo $carnum; ?></td>
|
||||
<td><?php echo $ssanum; ?></td>
|
||||
|
@ -66,7 +66,7 @@ class SiteInfo {
|
||||
}
|
||||
|
||||
// Return Site Information array. 0 eliminates argument
|
||||
public function getSitePerms ($sites_id, $users_id) {
|
||||
public function readSitePermissionBySiteAndUser ($sites_id, $users_id) {
|
||||
$query = "
|
||||
SELECT DISTINCT
|
||||
" . Registry::DB_PRFX . "users_sites.sites_id as users_sites_sites_id,
|
||||
@ -80,7 +80,7 @@ class SiteInfo {
|
||||
}
|
||||
|
||||
// Update site perms. For now we delete all uid matches and then insert.
|
||||
public function delSitePerms ($users_id) {
|
||||
public function deleteSitePermissionByUser ($users_id) {
|
||||
$query = "
|
||||
DELETE
|
||||
FROM " . Registry::DB_PRFX . "users_sites
|
||||
@ -90,7 +90,7 @@ class SiteInfo {
|
||||
if(empty($rows)) {
|
||||
return "0";} else { return "1";};
|
||||
}
|
||||
public function delSiteAdminPerms ($users_id, $sites_id) {
|
||||
public function deleteSitePermissionByUserAndSite ($users_id, $sites_id) {
|
||||
$query = "
|
||||
DELETE
|
||||
FROM " . Registry::DB_PRFX . "users_sites
|
||||
@ -100,7 +100,7 @@ class SiteInfo {
|
||||
if(empty($rows)) {
|
||||
return "0";} else { return "1";};
|
||||
}
|
||||
public function setSitePerms ($sites_id, $users_id) {
|
||||
public function grantSitePermissionBySiteAndUser ($sites_id, $users_id) {
|
||||
$query = "
|
||||
INSERT
|
||||
INTO " . Registry::DB_PRFX . "users_sites
|
||||
|
@ -74,7 +74,7 @@ class Users {
|
||||
return $rows;
|
||||
}
|
||||
|
||||
public function getUserInitials($userid) {
|
||||
public function readUserFirstAndLast($userid) {
|
||||
$query = "
|
||||
SELECT
|
||||
" . Registry::DB_PRFX . "users.id as users_id,
|
||||
@ -116,7 +116,7 @@ class Users {
|
||||
return $rows;
|
||||
}
|
||||
|
||||
public function checkSAMLUser ($email) {
|
||||
public function lookupSamlUserByEmail ($email) {
|
||||
$query = "
|
||||
SELECT
|
||||
" . Registry::DB_PRFX . "users.email as users_email
|
||||
@ -182,7 +182,7 @@ class Users {
|
||||
return $count;
|
||||
}
|
||||
|
||||
public function updateSAMLName($uid, $firstname, $lastname) {
|
||||
public function updateSamlFirstAndLast($uid, $firstname, $lastname) {
|
||||
$query = "
|
||||
UPDATE
|
||||
" . Registry::DB_PRFX . "users
|
||||
@ -196,18 +196,6 @@ class Users {
|
||||
return $count;
|
||||
}
|
||||
|
||||
public function getUserType ($usertypeid){
|
||||
$query = "
|
||||
SELECT
|
||||
" . Registry::DB_PRFX . "usertypes.id as usertypes_id,
|
||||
" . Registry::DB_PRFX . "usertypes.name as usertypes_name
|
||||
FROM " . Registry::DB_PRFX . "usertypes
|
||||
WHERE " . Registry::DB_PRFX . "usertypes.id LIKE \"$usertypeid\"";
|
||||
$database = new \App\LobbySIO\Database\Connect();
|
||||
$rows = $database->getQuery($query);
|
||||
return $rows;
|
||||
}
|
||||
|
||||
public function deleteUser ($userid) {
|
||||
$query = "
|
||||
DELETE FROM " . Registry::DB_PRFX . "users WHERE " . Registry::DB_PRFX . "users.id=\"$userid\"
|
||||
@ -217,7 +205,7 @@ class Users {
|
||||
return $count;
|
||||
}
|
||||
|
||||
public function getUserTypeInfo ($usertypeid) {
|
||||
public function readUserTypeByUserTypeID ($usertypeid) {
|
||||
$query = "
|
||||
SELECT
|
||||
" . Registry::DB_PRFX . "usertypes.id as usertypes_id,
|
||||
|
22
users.php
22
users.php
@ -130,7 +130,7 @@
|
||||
<span class="input-group-text" id="username"><?php echo $transLang['ACCESS_LEVEL']; ?></span>
|
||||
</div>
|
||||
<select class="custom-select" id="usertype" aria-label="<?php echo $transLang['ACCESS_LEVEL']; ?>" name="usertype" required>
|
||||
<?php foreach($Users->getUserTypeInfo("%") as $row): ?>
|
||||
<?php foreach($Users->readUserTypeByUserTypeID("%") as $row): ?>
|
||||
<option value="<?php echo $row['usertypes_id']; ?>"<?php if ($row['usertypes_id']==$edituser["0"]["users_usertypeid"]) { echo " selected"; } ?>><?php echo $transLang[$row['usertypes_name']]; ?></option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
@ -143,7 +143,7 @@
|
||||
</div>
|
||||
<select id="sitepermissions" name="sitepermissions[]" class="custom-select" multiple size="5">
|
||||
<?php foreach($SiteInfo->listSite("0", "0") as $row): ?>
|
||||
<option value="<?php echo $row['sites_id']; ?>"<?php if ($SiteInfo->getSitePerms($row['sites_id'], $edituser["0"]["users_id"])=="1") { echo " selected"; } ?>><?php echo $row['sites_name']; ?></option>
|
||||
<option value="<?php echo $row['sites_id']; ?>"<?php if ($SiteInfo->readSitePermissionBySiteAndUser($row['sites_id'], $edituser["0"]["users_id"])=="1") { echo " selected"; } ?>><?php echo $row['sites_name']; ?></option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
</div>
|
||||
@ -173,8 +173,8 @@
|
||||
if (!empty($_POST['newsite'])): // NEW SITE
|
||||
$SiteInfo->addSite($_POST['sitename'], $_POST['timezone'], $_POST['region']);
|
||||
$newsiteid = $SiteInfo->getSiteByID($_POST['sitename']);
|
||||
$SiteInfo->setSitePerms($newsiteid["0"]["id"], "1");
|
||||
$SiteInfo->setSitePerms($newsiteid["0"]["id"], "2");
|
||||
$SiteInfo->grantSitePermissionBySiteAndUser($newsiteid["0"]["id"], "1");
|
||||
$SiteInfo->grantSitePermissionBySiteAndUser($newsiteid["0"]["id"], "2");
|
||||
header('Location: ' . $_SERVER['PHP_SELF']);
|
||||
endif;
|
||||
|
||||
@ -208,7 +208,7 @@ if (Registry::AUTHMETHOD == 'INTERNAL') {
|
||||
if (!empty($_POST['newuser'])): // NEW USER SAML
|
||||
$email = filter_var($_POST['email'], FILTER_VALIDATE_EMAIL);
|
||||
if (!$email): $errors['email'] = $transLang['EMAIL_NOTVALID']; endif;
|
||||
$existing = $Users->checkSAMLUser($email);
|
||||
$existing = $Users->lookupSamlUserByEmail($email);
|
||||
if ($existing):
|
||||
if ($existing[0]["users_email"] == $email): $errors['email'] = $transLang['PASSWORD_USED']; endif;
|
||||
endif;
|
||||
@ -247,9 +247,9 @@ if (Registry::AUTHMETHOD == 'INTERNAL') {
|
||||
}
|
||||
$Users->editUserInfo($_POST['edituserid'], $_POST['firstname'], $_POST['lastname'], $editedusername, $_POST['email'], $_POST['usertype']);
|
||||
//foreach loop to check if exists, if new, delete or add as needed
|
||||
$SiteInfo->delSitePerms($_POST['edituserid']);
|
||||
$SiteInfo->deleteSitePermissionByUser($_POST['edituserid']);
|
||||
foreach($_POST['sitepermissions'] as $editsitepermission) {
|
||||
$SiteInfo->setSitePerms($editsitepermission, $_POST['edituserid']);
|
||||
$SiteInfo->grantSitePermissionBySiteAndUser($editsitepermission, $_POST['edituserid']);
|
||||
}
|
||||
header('Location: ' . $_SERVER['PHP_SELF']);
|
||||
endif;
|
||||
@ -386,7 +386,7 @@ if (0 === $row_count): else: $page_count = (int)ceil($row_count / $StaticFunctio
|
||||
<div class="row">
|
||||
<div class="col-sm">
|
||||
<select class="custom-select" id="usertype" aria-label="<?php echo $transLang['ACCESS_LEVEL']; ?>" name="usertype" required>
|
||||
<option value="" selected><?php echo $transLang['CHOOSE']; ?> <?php echo $transLang['ACCESS_LEVEL']; ?></option><?php foreach($Users->getUserTypeInfo("%") as $row): ?>
|
||||
<option value="" selected><?php echo $transLang['CHOOSE']; ?> <?php echo $transLang['ACCESS_LEVEL']; ?></option><?php foreach($Users->readUserTypeByUserTypeID("%") as $row): ?>
|
||||
<option value="<?php echo $row['usertypes_id']; ?>"><?php echo $transLang[$row['usertypes_name']]; ?></option><?php endforeach; ?>
|
||||
</select>
|
||||
</div>
|
||||
@ -411,9 +411,9 @@ if (0 === $row_count): else: $page_count = (int)ceil($row_count / $StaticFunctio
|
||||
if (!empty($_POST['delsite'])) {
|
||||
if ($_SERVER['REQUEST_METHOD'] == 'DELETE' || ($_SERVER['REQUEST_METHOD'] == 'POST' && $_POST['_METHOD'] == 'DELETE')) {
|
||||
$deleteid = (int) $_POST['deleteid'];
|
||||
$SiteInfo->delSiteAdminPerms ('0', $deleteid);
|
||||
$SiteInfo->delSiteAdminPerms ('1', $deleteid);
|
||||
$SiteInfo->delSiteAdminPerms ('2', $deleteid);
|
||||
$SiteInfo->deleteSitePermissionByUserAndSite ('0', $deleteid);
|
||||
$SiteInfo->deleteSitePermissionByUserAndSite ('1', $deleteid);
|
||||
$SiteInfo->deleteSitePermissionByUserAndSite ('2', $deleteid);
|
||||
echo $SiteInfo->deleteSite($deleteid);
|
||||
echo "site deleted!";
|
||||
header('Location: ' . $_SERVER['PHP_SELF']);
|
||||
|
Loading…
Reference in New Issue
Block a user