$actual_price = $unit_price * $registrants; } $paid = hasUserPaid($user["user_id"], $event["event_id"]); if ($_SERVER["REQUEST_METHOD"] == "POST") { if (isset($_POST["stripeToken"])) { $token = $_POST['stripeToken']; } $stripe_charge_id = getStripeChargeId($event["event_id"], $user["user_id"]); if ($_POST["action"] == "cancel") { // if the event has been paid for, refund the original charge if ($paid) { $refund = \Stripe\Refund::create(array("charge" => $stripe_charge_id)); $_SESSION["refund"] = $refund["amount"] / 100; } // delete the user's event registration $unregister = unregisterUser($event["event_id"], $user['user_id']); $_SESSION["cancel"] = true; } if ($_POST["action"] == "cc-on-file" || $_POST["action"] == "new-card" || $_POST["action"] == "modify") { // determine the new price of the event $price_in_cents = intval($actual_price * 100); // if this is a new card, either create a new customer or update existing customer if ($_POST["action"] == "new-card") { if (empty($user["stripe_cust_id"])) { // create a new customer $stripe_cust_id = createStripeCustomer($token, $user); $user["stripe_cust_id"] = $stripe_cust_id; } else { // update a customer's source $cu = \Stripe\Customer::retrieve($user["stripe_cust_id"]); $cu->source = $token;
function submitRegistrationForm($moduleCompId, $userId, $silent = false, $disableCaptcha = false) { ///-------------------------Get anonymous unique negative user id--------------- if ($userId == 0) { $useridQuery = "SELECT MIN(`user_id`) - 1 AS MIN FROM `form_regdata` WHERE 1"; $useridResult = mysql_query($useridQuery); if (mysql_num_rows($useridResult) > 0) { $useridRow = mysql_fetch_assoc($useridResult); $userId = $useridRow['MIN']; } else { $userId = -1; } } ///-----------------------------Anonymous user id ends------------------------------- ///---------------------------- CAPTCHA Validation ---------------------------------- if (!$disableCaptcha) { $captchaQuery = 'SELECT `form_usecaptcha` FROM `form_desc` WHERE `page_modulecomponentid` = \'' . $moduleCompId . "'"; $captchaResult = mysql_query($captchaQuery); $captchaRow = mysql_fetch_row($captchaResult); if ($captchaRow[0] == 1) { if (!submitCaptcha()) { return false; } } } ///------------------------ CAPTCHA Validation Ends Here ---------------------------- $query = "SELECT `form_elementid`,`form_elementtype` FROM `form_elementdesc` WHERE `page_modulecomponentid`='{$moduleCompId}'"; $result = mysql_query($query); $allFieldsUpdated = true; while ($elementRow = mysql_fetch_assoc($result)) { $type = $elementRow['form_elementtype']; $elementId = $elementRow['form_elementid']; $postVarName = "form_" . $moduleCompId . "_element_" . $elementRow['form_elementid']; $functionName = "submitRegistrationForm" . ucfirst(strtolower($type)); $elementDescQuery = "SELECT `form_elementname`,`form_elementsize`,`form_elementtypeoptions`,`form_elementmorethan`," . "`form_elementlessthan`,`form_elementcheckint`,`form_elementisrequired` FROM `form_elementdesc` " . "WHERE `page_modulecomponentid`='{$moduleCompId}' AND `form_elementid` ='{$elementId}'"; $elementDescResult = mysql_query($elementDescQuery); if (!$elementDescResult) { displayerror('E69 : Invalid query: ' . mysql_error()); return false; } $elementDescRow = mysql_fetch_assoc($elementDescResult); $elementName = $elementDescRow['form_elementname']; $elementSize = $elementDescRow['form_elementsize']; $elementTypeOptions = $elementDescRow['form_elementtypeoptions']; $elementMoreThan = $elementDescRow['form_elementmorethan']; $elementLessThan = $elementDescRow['form_elementlessthan']; $elementCheckInt = $elementDescRow['form_elementcheckint'] == 1 ? true : false; $elementIsRequired = $elementDescRow['form_elementisrequired'] == 1 ? true : false; if ($functionName($moduleCompId, $elementId, $userId, $postVarName, $elementName, $elementSize, $elementTypeOptions, $elementMoreThan, $elementLessThan, $elementCheckInt, $elementIsRequired) == false) { // displayerror("Error in inputting data in function $functionName."); $allFieldsUpdated = false; break; } } if (!$allFieldsUpdated) { if ($userId < 0) { unregisterUser($moduleCompId, $userId); } else { if (!verifyUserRegistered($moduleCompId, $userId)) { $deleteelementdata_query = "DELETE FROM `form_elementdata` WHERE `user_id` = '{$userId}' AND `page_modulecomponentid` ='{$moduleCompId}' "; $deleteelementdata_result = mysql_query($deleteelementdata_query); } return false; } } else { if (!verifyUserRegistered($moduleCompId, $userId)) { registerUser($moduleCompId, $userId); } else { updateUser($moduleCompId, $userId); } if (!$silent) { $footerQuery = "SELECT `form_footertext`, `form_sendconfirmation` FROM `form_desc` WHERE `page_modulecomponentid` = '{$moduleCompId}'"; $footerResult = mysql_query($footerQuery); $footerRow = mysql_fetch_row($footerResult); $footerText = $footerRow[0]; $footerTextLength = strlen($footerText); if ($footerTextLength > 7) { if (substr($footerText, 0, 4) == '<!--' && substr($footerText, $footerTextLength - 3) == '-->') { $footerText = substr($footerText, 4, $footerTextLength - 7); } else { $footerText = ''; } } else { $footerText = ''; } displayinfo($footerText == '' ? "User successfully registered!" : $footerText); // send mail code starts here - see common.lib.php for more if ($footerRow[1]) { $from = ''; // Default CMS email will be added automatically if this is left blank $to = getUserEmail($userId); $pageId = getPageIdFromModuleComponentId('form', $moduleCompId); $parentPage = getParentPage($pageId); $formname = getPageTitle($parentPage); $keyid = $finalName = str_pad($userId, 5, '0', STR_PAD_LEFT); $key = ''; $mailtype = "form_registration_mail"; $messenger = new messenger(false); global $onlineSiteUrl; $messenger->assign_vars(array('FORMNAME' => "{$formname}", 'KEY' => "{$key}", 'WEBSITE' => CMS_TITLE, 'DOMAIN' => $onlineSiteUrl, 'NAME' => getUserFullName($userId))); if ($messenger->mailer($to, $mailtype, $key, $from)) { displayinfo("You have been succesfully registered to {$formname} and a registration confirmation mail has been sent. Kindly check your e-mail."); } else { displayerror("Registration confirmation mail sending failure. Kindly contact webadmin@pragyan.org"); } } // send mail code ends here } } return true; }
public function actionEditregistrants() { /** * After view registrants completes, generateFormDataRow() will be used here also * then manually prepend the "delete" button and "edit" button columns * * After generateFormDataTable() completes, move the code to generate the top header row (with the sort * by this column images) to a new function and call it here also and manually prepened two <th>s of * delete and edit * * The delete button should point to a subaction through get vars * * Clicking edit button, should do something like edit in 2nd form in "editform" does with a twist : * to generate the edit form simply call generateRegistrationForm($moduleCompId,$userId,$action=) * with action ./+editregistrants&subaction=editregistrant&useremail=<useremail> * * and when submitted call submitRegistrationForm() */ global $sourceFolder, $moduleFolder; if (isset($_GET['subaction']) && isset($_GET['useremail'])) { if ($_GET['subaction'] == 'edit') { if (isset($_POST['submitreg_form_' . $this->moduleComponentId])) { submitRegistrationForm($this->moduleComponentId, getUserIdFromEmail(escape($_GET['useremail'])), true, true); } return '<a href="./+editregistrants">« Back</a><br />' . generateRegistrationForm($this->moduleComponentId, $this->userId, './+editregistrants&subaction=edit&useremail=' . escape($_GET['useremail']), true) . '<br /><a href="./+editregistrants">« Back</a><br />'; } elseif ($_GET['subaction'] == 'delete') { if ($_GET['useremail'] == "Anonymous") { $userIdTemp = escape($_GET['registrantid']); } else { $userIdTemp = getUserIdFromEmail(escape($_GET['useremail'])); } if (!unregisterUser($this->moduleComponentId, $userIdTemp)) { displayerror('Error! User with the given e-mail ' . escape($_GET['useremail']) . ' was not found.'); } } } elseif (isset($_GET['subaction']) && $_GET['subaction'] == 'getsuggestions' && isset($_GET['forwhat'])) { echo $this->getUnregisteredUsersFromPattern(escape($_GET['forwhat'])); disconnect(); exit; } elseif (isset($_POST['btnAddUserToForm']) && isset($_POST['useremail'])) { $hyphenPos = strpos($_POST['useremail'], '-'); if ($hyphenPos >= 0) { $userEmail = escape(trim(substr($_POST['useremail'], 0, $hyphenPos - 1))); } else { $userEmail = escape($_POST['useremail']); } $targetUserId = getUserIdFromEmail($userEmail); if ($targetUserId > 0) { if (verifyUserRegistered($this->moduleComponentId, $targetUserId)) { displayerror('The given user is already registered to this form.'); } else { registerUser($this->moduleComponentId, $targetUserId); } } else { displayerror('A user registered with the e-mail ID you entered was not found.'); } } elseif (isset($_POST['btnEmptyRegistrants'])) { $registeredUsers = form::getRegisteredUserArray($this->moduleComponentId); $registeredUserCount = count($registeredUsers); for ($i = 0; $i < $registeredUserCount; $i++) { unregisterUser($this->moduleComponentId, $registeredUsers[$i], true); } displayinfo('All registrations to this form have been deleted.'); } $sortField = 'registrationdate'; /// Default Values $sortOrder = 'asc'; if (isset($_GET['sortfield'])) { $sortField = escape($_GET['sortfield']); } if (isset($_GET['sortorder']) && ($_GET['sortorder'] == 'asc' || $_GET['sortorder'] == 'desc')) { $sortOrder = escape($_GET['sortorder']); } global $ICONS; $html = generateFormDataTable($this->moduleComponentId, $sortField, $sortOrder, 'editregistrants'); return "<fieldset><legend>{$ICONS['Form Registrants']['small']}Edit Form Registrants</legend>{$html}</fieldset>"; }
$max = ""; } else { $max = $event["max_attendees"]; } if ($_SERVER["REQUEST_METHOD"] == "POST") { // process the event change if (password_verify($_POST["admin-password"], $admin["password"])) { if ($_POST["action"] == "delete") { $registrations = deleteEvent($event["event_id"]); foreach ($registrations as $registration) { // refund the charge if (!empty($registration["stripe_charge_id"])) { $refund = \Stripe\Refund::create(array("charge" => $registration["stripe_charge_id"])); } // unregister the user unregisterUser($registration["event_id"], $registration["user_id"]); } deleteEvent($event["event_id"], true); $_SESSION["deleted"] = $event["name"]; header("Location:/admin/events/"); } elseif ($_POST["action"] == "edit") { $edit = editEvent($event["event_id"], $_POST["name"], str_replace(array("\r\n", "\r", "\n"), "<br>", $_POST["description"]), $_POST["date"], $_POST["start-time"], $_POST["end-time"], $_POST["member-price"], $_POST["nonmember-price"], $_POST["max"]); var_dump($edit); $_SESSION["event-edited"] = true; header("Location:/admin/events/edit/" . $event["event_id"] . "/"); } } else { $_SESSION["incorrect-password"] = true; header("Location:/admin/events/edit/" . $event["event_id"] . "/"); } } else {
function submitRegistrationForm($moduleCompId, $userId, $silent = false, $disableCaptcha = false) { ///-------------------------Get anonymous unique negative user id--------------- if ($userId == 0) { $useridQuery = "SELECT MIN(`user_id`) - 1 AS MIN FROM `form_regdata` WHERE 1"; $useridResult = mysql_query($useridQuery); if (mysql_num_rows($useridResult) > 0) { $useridRow = mysql_fetch_assoc($useridResult); $userId = $useridRow['MIN']; } else { $userId = -1; } } ///-----------------------------Anonymous user id ends------------------------------- ///---------------------------- CAPTCHA Validation ---------------------------------- if (!$disableCaptcha) { $captchaQuery = 'SELECT `form_usecaptcha` FROM `form_desc` WHERE `page_modulecomponentid` = ' . $moduleCompId; $captchaResult = mysql_query($captchaQuery); $captchaRow = mysql_fetch_row($captchaResult); if ($captchaRow[0] == 1) { if (!submitCaptcha()) { return false; } } } ///------------------------ CAPTCHA Validation Ends Here ---------------------------- $query = "SELECT `form_elementid`,`form_elementtype` FROM `form_elementdesc` WHERE `page_modulecomponentid`={$moduleCompId}"; $result = mysql_query($query); $allFieldsUpdated = true; while ($elementRow = mysql_fetch_assoc($result)) { $type = $elementRow['form_elementtype']; $elementId = $elementRow['form_elementid']; $postVarName = "form_" . $moduleCompId . "_element_" . $elementRow['form_elementid']; $functionName = "submitRegistrationForm" . ucfirst(strtolower($type)); $elementDescQuery = "SELECT `form_elementname`,`form_elementsize`,`form_elementtypeoptions`,`form_elementmorethan`," . "`form_elementlessthan`,`form_elementcheckint`,`form_elementisrequired` FROM `form_elementdesc` " . "WHERE `page_modulecomponentid`={$moduleCompId} AND `form_elementid` ={$elementId}"; $elementDescResult = mysql_query($elementDescQuery); if (!$elementDescResult) { displayerror('E69 : Invalid query: ' . mysql_error()); return false; } $elementDescRow = mysql_fetch_assoc($elementDescResult); $elementName = $elementDescRow['form_elementname']; $elementSize = $elementDescRow['form_elementsize']; $elementTypeOptions = $elementDescRow['form_elementtypeoptions']; $elementMoreThan = $elementDescRow['form_elementmorethan']; $elementLessThan = $elementDescRow['form_elementlessthan']; $elementCheckInt = $elementDescRow['form_elementcheckint'] == 1 ? true : false; $elementIsRequired = $elementDescRow['form_elementisrequired'] == 1 ? true : false; if ($functionName($moduleCompId, $elementId, $userId, $postVarName, $elementName, $elementSize, $elementTypeOptions, $elementMoreThan, $elementLessThan, $elementCheckInt, $elementIsRequired) == false) { // displayerror("Error in inputting data in function $functionName."); $allFieldsUpdated = false; break; } } if (!$allFieldsUpdated) { if ($userId < 0) { unregisterUser($moduleCompId, $userId); } else { if (!verifyUserRegistered($moduleCompId, $userId)) { $deleteelementdata_query = "DELETE FROM `form_elementdata` WHERE `user_id` = {$userId} AND `page_modulecomponentid` = {$moduleCompId} "; $deleteelementdata_result = mysql_query($deleteelementdata_query); } return false; } } else { if (!verifyUserRegistered($moduleCompId, $userId)) { registerUser($moduleCompId, $userId); } else { updateUser($moduleCompId, $userId); } if (!$silent) { displayinfo("User successfully registered!"); // send mail code starts here - see common.lib.php for more /* $from = CMS_EMAIL; $to = getUserEmail($userId); $pageId = getPageIdFromModuleComponentId('form',$moduleCompId); $parentPage = getParentPage($pageId); $event = getPageTitle($parentPage); $keyid = $finalName = str_pad($userId, 5,'0', STR_PAD_LEFT); $key = ''; if($event=='Hospitality'){ $mailtype = "hospitality_mail"; $key = 'P09'.$keyid; }elseif($event=='Crossfire'){ $mailtype = "crossfire_mail"; } elseif($event=='Home'){ $mailtype = "suggestions_mail"; } else { $mailtype = "registration_mail"; } $messenger = new messenger(false); if($event=='Akriti') { $key=<<<MSG Your Akriti registration no. is P09AR$keyid. Please ensure that your drawing sheets and/or reports only bear the registration number. Name of the institute, participants name are strictly prohibited from appearing in any form. MSG; } $messenger->assign_vars(array('EVENT'=>"$event",'KEY'=>"$key", 'NAME'=>getUserFullName($userId))); if($event == 'onlinefinals') ; else if ($messenger->mailer($to,$mailtype,$key,$from)) displayinfo("You have been succesfully registered to $event and a registration confirmation mail has been sent. Kindly check your e-mail."); else displayerror("Registration confirmation mail sending failure. Kindly contact webadmin@pragyan.org"); */ // send mail code ends here } } return true; }