Merge pull request #17251 from DorianVabre/dev_EventOrganizer

Dev event organizer: public registration page to a conference
This commit is contained in:
Laurent Destailleur 2021-04-13 15:31:40 +02:00 committed by GitHub
commit 3f159fa39f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 47 additions and 27 deletions

View File

@ -60,7 +60,7 @@ $arrayofparameters = array(
'EVENTORGANIZATION_TEMPLATE_EMAIL_AFT_SUBS_EVENT'=>array('type'=>'emailtemplate:eventorganization_send', 'enabled'=>1),
'EVENTORGANIZATION_TEMPLATE_EMAIL_BULK_SPEAKER'=>array('type'=>'emailtemplate:eventorganization_send', 'enabled'=>1),
'EVENTORGANIZATION_TEMPLATE_EMAIL_BULK_ATTENDES'=>array('type'=>'emailtemplate:eventorganization_send', 'enabled'=>1),
'EVENTORGANIZATION_SECUREKEY'=>array('type'=>'securekey', 'enabled'=>1),
'EVENTORGANIZATION_SECUREKEY'=>array('type'=>'securekey', 'enabled'=>1),
);
$error = 0;

View File

@ -494,11 +494,14 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
//unset($object->fields['fk_project']); // Hide field already shown in banner
//unset($object->fields['fk_soc']); // Hide field already shown in banner
global $dolibarr_main_url_root;
$link_subscription = $dolibarr_main_url_root.'/public/eventorganization/attendee_subscription.php?id=';
$key = 'DV3PH';
$link_subscription .= dol_encode($id, $key);
$link_subscription .= '&securekey='.urlencode($conf->global->EVENTORGANIZATION_SECUREKEY);
$object->fields['pubregister'] = array('type'=>'url', 'label'=>'Lien public d\'enregistrement à une conférence', 'enabled'=>'1', 'position'=>72, 'notnull'=>0, 'visible'=>1);
$encodedid = dol_encode($id, $dolibarr_main_instance_unique_id);
$link_subscription = $dolibarr_main_url_root.'/public/eventorganization/attendee_subscription.php?id='.$encodedid;
$encodedsecurekey = dol_encode($conf->global->EVENTORGANIZATION_SECUREKEY.$encodedid, $dolibarr_main_instance_unique_id);
$link_subscription .= '&securekey='.urlencode($encodedsecurekey);
$object->fields['pubregister'] = array('type'=>'url', 'label'=>$langs->trans("PublicAttendeeSubscriptionPage"), 'enabled'=>'1', 'position'=>72, 'notnull'=>0, 'visible'=>1);
$object->pubregister = $link_subscription;
$keyforbreak='pubregister';

View File

@ -19,7 +19,6 @@
ModuleEventOrganizationName = Event Organization
EventOrganizationDescription = Event Organization through Module Project
EventOrganizationDescriptionLong= Manage Event organization for conference, attendees, speaker, and attendees, with public subcription page
#
# Menu
#
@ -82,6 +81,7 @@ PriceOfBoothHelp=Subscription price to stand a booth
EventOrganizationICSLink=Link ICS for events
ConferenceOrBoothInformation=Conference Or Booth informations
Attendees = Attendees
EVENTORGANIZATION_SECUREKEY = Secure Key of the public registration link to a conference
#
# Status
#
@ -94,6 +94,7 @@ EvntOrgCancelled = Cancelled
#
# Public page
#
PublicAttendeeSubscriptionPage = Public link of registration to a conference
MissingOrBadSecureKey = The security key is invalid or missing
EvntOrgWelcomeMessage = This form allows you to register as a new participant to the conference
EvntOrgStartDuration = This conference starts on

View File

@ -75,12 +75,22 @@ $error = 0;
$backtopage = GETPOST('backtopage', 'alpha');
$action = GETPOST('action', 'aZ09');
$key = 'DV3PH';
$id = dol_decode(GETPOST('id'), $key);
$email = GETPOST("email");
// Securekey check
$securekey = GETPOST('securekey', 'alpha');
if ($securekey != $conf->global->EVENTORGANIZATION_SECUREKEY) {
// Getting id from Post and decoding it
$encodedid = GETPOST('id');
$id = dol_decode($encodedid, $dolibarr_main_instance_unique_id);
// Getting 'securekey'.'id' from Post and decoding it
$encodedsecurekeyandid = GETPOST('securekey', 'alpha');
$securekeyandid = dol_decode($encodedsecurekeyandid, $dolibarr_main_instance_unique_id);
// Securekey decomposition into pure securekey and id added at the end
$securekey = substr($securekeyandid, 0, strlen($securekeyandid)-strlen($encodedid));
$idgotfromsecurekey = dol_decode(substr($securekeyandid, -strlen($encodedid), strlen($encodedid)), $dolibarr_main_instance_unique_id);
// We check if the securekey collected is OK and if the id collected is the same than the id in the securekey
if ($securekey != $conf->global->EVENTORGANIZATION_SECUREKEY || $idgotfromsecurekey != $id) {
print $langs->trans('MissingOrBadSecureKey');
exit;
}
@ -175,32 +185,32 @@ if ($reshook < 0) {
if (empty($reshook) && $action == 'add') {
$error = 0;
$urlback = '';
$db->begin();
if (!GETPOST("email")) {
$error++;
$errmsg .= $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Email"))."<br>\n";
}
if (!GETPOST("societe")) {
/*if (!GETPOST("societe")) {
$error++;
$errmsg .= $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Societe"))."<br>\n";
}
}*/
if (GETPOST("email") && !isValidEmail(GETPOST("email"))) {
$error++;
$langs->load("errors");
$errmsg .= $langs->trans("ErrorBadEMail", GETPOST("email"))."<br>\n";
}
if (!GETPOST("country_id")) {
$error++;
$errmsg .= $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Country"))."<br>\n";
}
if (!$error) {
// Vérifier si client existe
// Vérifier si client existe par l'email
$thirdparty = new Societe($db);
$nomsociete = GETPOST("societe");
$resultfetchthirdparty = $thirdparty->fetch('', $nomsociete);
$resultfetchthirdparty = $thirdparty->fetch('', '', '', '', '', '', '', '', '', '', $email);
if ($resultfetchthirdparty<0) {
$error++;
@ -208,7 +218,12 @@ if (empty($reshook) && $action == 'add') {
$readythirdparty = -1;
} elseif ($resultfetchthirdparty==0) {
// creation of a new thirdparty
$thirdparty->name = $nomsociete;
if (!empty(GETPOST("societe"))) {
$thirdparty->name = GETPOST("societe");
} else {
$thirdparty->name = $email;
}
$thirdparty->address = GETPOST("address");
$thirdparty->zip = GETPOST("zipcode");
$thirdparty->town = GETPOST("town");
@ -216,6 +231,7 @@ if (empty($reshook) && $action == 'add') {
$thirdparty->fournisseur = 0;
$thirdparty->country_id = GETPOST("country_id", 'int');
$thirdparty->state_id = GETPOST("state_id", 'int');
$thirdparty->email = $email;
// Load object modCodeTiers
$module = (!empty($conf->global->SOCIETE_CODECLIENT_ADDON) ? $conf->global->SOCIETE_CODECLIENT_ADDON : 'mod_codeclient_leopard');
@ -308,8 +324,8 @@ print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST" name="newmember">'.
print '<input type="hidden" name="token" value="'.newToken().'" / >';
print '<input type="hidden" name="entity" value="'.$entity.'" />';
print '<input type="hidden" name="action" value="add" />';
print '<input type="hidden" name="id" value="'.dol_encode($id, $key).'" />';
print '<input type="hidden" name="securekey" value="'.$securekey.'" />';
print '<input type="hidden" name="id" value="'.$encodedid.'" />';
print '<input type="hidden" name="securekey" value="'.$encodedsecurekeyandid.'" />';
print '<br>';
@ -331,8 +347,10 @@ jQuery(document).ready(function () {
print '<table class="border" summary="form to subscribe" id="tablesubscribe">'."\n";
// Email
print '<tr><td>'.$langs->trans("Email").' <FONT COLOR="red">*</FONT></td><td><input type="text" name="email" maxlength="255" class="minwidth150" value="'.dol_escape_htmltag(GETPOST('email')).'"></td></tr>'."\n";
// Company
print '<tr id="trcompany" class="trcompany"><td>'.$langs->trans("Company").' <FONT COLOR="red">*</FONT></td><td><input type="text" name="societe" class="minwidth150" value="'.dol_escape_htmltag(GETPOST('societe')).'"></td></tr>'."\n";
print '<tr id="trcompany" class="trcompany"><td>'.$langs->trans("Company").' </td><td><input type="text" name="societe" class="minwidth150" value="'.dol_escape_htmltag(GETPOST('societe')).'"></td></tr>'."\n";
// Address
print '<tr><td>'.$langs->trans("Address").'</td><td>'."\n";
print '<textarea name="address" id="address" wrap="soft" class="quatrevingtpercent" rows="'.ROWS_3.'">'.dol_escape_htmltag(GETPOST('address', 'restricthtml'), 0, 1).'</textarea></td></tr>'."\n";
@ -343,7 +361,7 @@ print ' / ';
print $formcompany->select_ziptown(GETPOST('town'), 'town', array('zipcode', 'selectcountry_id', 'state_id'), 0, 1);
print '</td></tr>';
// Country
print '<tr><td>'.$langs->trans('Country').'</td><td>';
print '<tr><td>'.$langs->trans('Country').'<FONT COLOR="red">*</FONT></td><td>';
$country_id = GETPOST('country_id');
if (!$country_id && !empty($conf->global->MEMBER_NEWFORM_FORCECOUNTRYCODE)) {
$country_id = getCountry($conf->global->MEMBER_NEWFORM_FORCECOUNTRYCODE, 2, $db, $langs);
@ -372,8 +390,6 @@ if (empty($conf->global->SOCIETE_DISABLE_STATE)) {
}
print '</td></tr>';
}
// Email
print '<tr><td>'.$langs->trans("Email").' <FONT COLOR="red">*</FONT></td><td><input type="text" name="email" maxlength="255" class="minwidth150" value="'.dol_escape_htmltag(GETPOST('email')).'"></td></tr>'."\n";
print "</table>\n";