diff --git a/htdocs/admin/eventorganization.php b/htdocs/admin/eventorganization.php index 9338aa3a6dd..b6a964d8617 100644 --- a/htdocs/admin/eventorganization.php +++ b/htdocs/admin/eventorganization.php @@ -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; diff --git a/htdocs/eventorganization/conferenceorbooth_card.php b/htdocs/eventorganization/conferenceorbooth_card.php index 4f0720d11e3..15b52eda038 100644 --- a/htdocs/eventorganization/conferenceorbooth_card.php +++ b/htdocs/eventorganization/conferenceorbooth_card.php @@ -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'; diff --git a/htdocs/langs/en_US/eventorganization.lang b/htdocs/langs/en_US/eventorganization.lang index 03fb460d6b9..a9d31c1dbaf 100644 --- a/htdocs/langs/en_US/eventorganization.lang +++ b/htdocs/langs/en_US/eventorganization.lang @@ -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 diff --git a/htdocs/public/eventorganization/attendee_subscription.php b/htdocs/public/eventorganization/attendee_subscription.php index 800c6dc469d..3d1ee6272cc 100644 --- a/htdocs/public/eventorganization/attendee_subscription.php +++ b/htdocs/public/eventorganization/attendee_subscription.php @@ -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"))."
\n"; } - if (!GETPOST("societe")) { + /*if (!GETPOST("societe")) { $error++; $errmsg .= $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Societe"))."
\n"; - } + }*/ if (GETPOST("email") && !isValidEmail(GETPOST("email"))) { $error++; $langs->load("errors"); $errmsg .= $langs->trans("ErrorBadEMail", GETPOST("email"))."
\n"; } + if (!GETPOST("country_id")) { + $error++; + $errmsg .= $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Country"))."
\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 '
'. print ''; print ''; print ''; -print ''; -print ''; +print ''; +print ''; print '
'; @@ -331,8 +347,10 @@ jQuery(document).ready(function () { print ''."\n"; +// Email +print ''."\n"; // Company -print ''."\n"; +print ''."\n"; // Address print ''."\n"; @@ -343,7 +361,7 @@ print ' / '; print $formcompany->select_ziptown(GETPOST('town'), 'town', array('zipcode', 'selectcountry_id', 'state_id'), 0, 1); print ''; // Country -print ''; } -// Email -print ''."\n"; print "
'.$langs->trans("Email").' *
'.$langs->trans("Company").' *
'.$langs->trans("Company").'
'.$langs->trans("Address").''."\n"; print '
'.$langs->trans('Country').''; +print '
'.$langs->trans('Country').'*'; $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 '
'.$langs->trans("Email").' *
\n";