From 10f71b84f0eb839ce00d138adb4edd47708b9995 Mon Sep 17 00:00:00 2001 From: Julian Egelstaff Date: Sat, 15 Jun 2024 17:56:48 -0400 Subject: [PATCH] No longer treat anon passcodes as forcehidden elements (which are deprecated) --- modules/formulize/admin/formindex.php | 2 +- modules/formulize/class/passcode.php | 34 +++++++++++++-------------- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/modules/formulize/admin/formindex.php b/modules/formulize/admin/formindex.php index a01c40343..1723a63e7 100644 --- a/modules/formulize/admin/formindex.php +++ b/modules/formulize/admin/formindex.php @@ -1249,7 +1249,7 @@ function patch40() { } // check for ele_forcehidden elements, and flag them to the user - $sql = "SELECT f.desc_form, e.ele_caption, e.ele_colhead FROM ".$xoopsDB->prefix("formulize")." AS e LEFT JOIN ".$xoopsDB->prefix("formulize_id")." AS f ON f.id_form = e.id_form WHERE e.ele_forcehidden = 1 ORDER BY f.desc_form, e.ele_colhead, e.ele_caption"; + $sql = "SELECT f.desc_form, e.ele_caption, e.ele_colhead FROM ".$xoopsDB->prefix("formulize")." AS e LEFT JOIN ".$xoopsDB->prefix("formulize_id")." AS f ON f.id_form = e.id_form WHERE e.ele_forcehidden = 1 AND e.ele_type != 'anonPasscode' ORDER BY f.desc_form, e.ele_colhead, e.ele_caption"; $res = $xoopsDB->query($sql); $forceHiddenElements = ""; $formTitle = ""; diff --git a/modules/formulize/class/passcode.php b/modules/formulize/class/passcode.php index a1b172030..4983be250 100644 --- a/modules/formulize/class/passcode.php +++ b/modules/formulize/class/passcode.php @@ -71,11 +71,11 @@ function &create($passCode='',$screen=0,$expiry='') { } function generatePasscode() { - + if(!function_exists('bcadd')) { return ''; } - + require XOOPS_ROOT_PATH.'/modules/formulize/libraries/GenPhrase/Loader.php'; $loader = new GenPhrase\Loader(); $loader->register(); @@ -83,7 +83,7 @@ function generatePasscode() { // Generate a passphrase using english words and (at least) 50 bits of entropy. return $gen->generate(); } - + function validatePasscode($code, $sid) { global $xoopsDB; $code = formulize_db_escape($code); @@ -100,27 +100,27 @@ function validatePasscode($code, $sid) { return false; } } - + function cleanupExpiredPasscodes() { global $xoopsDB; $date = date('Y-m-d'); $sql = 'DELETE FROM '.$xoopsDB->prefix('formulize_passcodes').' WHERE expiry <= "'.$date.'" AND expiry IS NOT NULL'; $xoopsDB->queryF($sql); } - + function getOtherScreenPasscodes($sid) { return self::getPasscodes($sid, '!='); } - + function getThisScreenPasscodes($sid) { return self::getPasscodes($sid, '='); } - + // returns an array of passcodes matching what is passed. In each array/passcode, the fields are keyed as - passcode, notes, expiry, id function getPasscode($passcode) { return self::getPasscodes(0,"",$passcode); } - + function getPasscodes($sid=0, $op="",$passcode="") { global $xoopsDB; $screenWhere = ''; @@ -145,17 +145,17 @@ function getPasscodes($sid=0, $op="",$passcode="") { } return $passcodes; } - + function copyPasscodeToScreen($id, $sid) { global $xoopsDB; $id = intval($id); $sid = intval($sid); - $sql = 'SELECT passcode, notes, expiry FROM '.$xoopsDB->prefix('formulize_passcodes').' WHERE passcode_id = '.$id; + $sql = 'SELECT passcode, notes, expiry FROM '.$xoopsDB->prefix('formulize_passcodes').' WHERE passcode_id = '.$id; $res = $xoopsDB->query($sql); $data = $xoopsDB->fetchArray($res); return self::insert($data['passcode'], $data['notes'], $sid, $data['expiry']); } - + function insert($code, $notes, $sid, $expiry='') { global $xoopsDB; $sid = intval($sid); @@ -170,7 +170,7 @@ function insert($code, $notes, $sid, $expiry='') { self::createPasscodeElement($sid); return true; } - + function updatePasscode($oldCode, $newCode, $sid) { global $xoopsDB; $sid = intval($sid); @@ -183,7 +183,7 @@ function updatePasscode($oldCode, $newCode, $sid) { } return true; } - + // add a system level passcode element to the form visible to registered users, if one does not exist already function createPasscodeElement($sid) { @@ -209,14 +209,14 @@ function createPasscodeElement($sid) { $element->setVar('ele_encrypt', 0); $element->setVar('ele_handle', 'anon_passcode_'.$fid); $element->setVar('ele_caption', 'Anonymous User Passcode'); - $element->setVar('ele_forcehidden', 1); + $element->setVar('ele_forcehidden', 0); $elementId = $element_handler->insert($element); // pass id so element object gets recreated inside other method, and then it will pick up all the properties from the custom class if(!$insertResult = $form_handler->insertElementField($elementId, $element->overrideDataType)) { exit("Error: could not add the new element to the data table in the database."); } } - + function updateExpiry($id, $expiry) { global $xoopsDB; $id = intval($id); @@ -228,7 +228,7 @@ function updateExpiry($id, $expiry) { } return true; } - + function delete($id) { global $xoopsDB; $id = intval($id); @@ -239,5 +239,5 @@ function delete($id) { } return true; } - + }