Skip to content

Commit

Permalink
No longer treat anon passcodes as forcehidden elements (which are dep…
Browse files Browse the repository at this point in the history
…recated)
  • Loading branch information
jegelstaff committed Jun 15, 2024
1 parent e537ace commit 10f71b8
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 18 deletions.
2 changes: 1 addition & 1 deletion modules/formulize/admin/formindex.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 = "";
Expand Down
34 changes: 17 additions & 17 deletions modules/formulize/class/passcode.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,19 +71,19 @@ 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();
$gen = new GenPhrase\Password();
// 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);
Expand All @@ -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 = '';
Expand All @@ -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);
Expand All @@ -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);
Expand All @@ -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) {
Expand All @@ -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);
Expand All @@ -228,7 +228,7 @@ function updateExpiry($id, $expiry) {
}
return true;
}

function delete($id) {
global $xoopsDB;
$id = intval($id);
Expand All @@ -239,5 +239,5 @@ function delete($id) {
}
return true;
}

}

0 comments on commit 10f71b8

Please sign in to comment.