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