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 302790f91f0..fbee3de4e3d 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 0adf783ee05..ba52057b796 100644
--- a/htdocs/public/eventorganization/attendee_subscription.php
+++ b/htdocs/public/eventorganization/attendee_subscription.php
@@ -77,8 +77,25 @@ $error = 0;
$backtopage = GETPOST('backtopage', 'alpha');
$action = GETPOST('action', 'aZ09');
-$key = 'DV3PH';
-$id = dol_decode(GETPOST('id'), $key);
+$email = GETPOST("email");
+
+// 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;
+}
$conference = new ConferenceOrBooth($db);
$resultconf = $conference->fetch($id);
@@ -86,13 +103,6 @@ if ($resultconf < 0) {
setEventMessages(null, $object->errors, "errors");
}
-// Securekey check
-$securekey = GETPOST('securekey', 'alpha');
-if ($securekey != $conf->global->EVENTORGANIZATION_SECUREKEY) {
- print $langs->trans('MissingOrBadSecureKey');
- exit;
-}
-
// Load translation files
$langs->loadLangs(array("main", "companies", "install", "other", "eventorganization"));
@@ -183,32 +193,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++;
@@ -216,7 +226,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");
@@ -224,6 +239,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');
@@ -266,6 +282,7 @@ if (empty($reshook) && $action == 'add') {
}
}
}
+
if (!$error) {
$db->commit();
$project = new Project($db);
@@ -317,6 +334,12 @@ if (empty($reshook) && $action == 'add') {
$form = new Form($db);
$formcompany = new FormCompany($db);
+$conference = new ConferenceOrBooth($db);
+$resultconf = $conference->fetch($id);
+if ($resultconf < 0) {
+ setEventMessages(null, $object->errors, "errors");
+}
+
llxHeaderVierge($langs->trans("NewSubscription"));
@@ -343,8 +366,8 @@ print '