test for existence of selected checkboxes in post data because if none are selected, the array won't exist

This commit is contained in:
Isaac Connor 2020-01-02 10:17:07 -05:00
parent a7b23f5c39
commit 60d45d967f
1 changed files with 13 additions and 10 deletions

View File

@ -110,8 +110,6 @@ foreach ( array_map('basename', glob('skins/'.$skin.'/css/*',GLOB_ONLYDIR)) as $
<button value="Save" type="submit"><?php echo translate('Save') ?></button>
</div>
</form>
<?php
} else if ( $tab == 'users' ) {
?>
@ -319,23 +317,28 @@ foreach ( array_map('basename', glob('skins/'.$skin.'/css/*',GLOB_ONLYDIR)) as $
}
function updateSelected() {
# Turn them all off, then selectively turn the checked ones back on
dbQuery('UPDATE `Users` SET `APIEnabled`=0');
foreach ( $_REQUEST["tokenUids"] as $markUid ) {
$minTime = time();
dbQuery('UPDATE `Users` SET `TokenMinExpiry`=? WHERE `Id`=?', array($minTime, $markUid));
if ( isset($_REQUEST['tokenUids']) ) {
foreach ( $_REQUEST['tokenUids'] as $markUid ) {
$minTime = time();
dbQuery('UPDATE `Users` SET `TokenMinExpiry`=? WHERE `Id`=?', array($minTime, $markUid));
}
}
foreach ( $_REQUEST["apiUids"] as $markUid ) {
dbQuery('UPDATE `Users` SET `APIEnabled`=1 WHERE `Id`=?', array($markUid));
if ( isset($_REQUEST['apiUids']) ) {
foreach ( $_REQUEST['apiUids'] as $markUid ) {
dbQuery('UPDATE `Users` SET `APIEnabled`=1 WHERE `Id`=?', array($markUid));
}
}
echo '<span class="timedSuccessBox">'.translate('Updated').'</span>';
}
if ( array_key_exists('revokeAllTokens',$_POST) ) {
if ( array_key_exists('revokeAllTokens', $_POST) ) {
revokeAllTokens();
}
if ( array_key_exists('updateSelected',$_POST) ) {
if ( array_key_exists('updateSelected', $_POST) ) {
updateSelected();
}
?>