';
print '

executeHooks('doActions', $parameters, $object, $action);
if ($reshook < 0) {
@@ -170,74 +165,60 @@ if (empty($reshook) && $action == 'add') {
$db->begin();
// test if login already exists
- if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED))
- {
- if (!GETPOST('login'))
- {
+ if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED)) {
+ if (!GETPOST('login')) {
$error++;
$errmsg .= $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Login"))."
\n";
}
$sql = "SELECT login FROM ".MAIN_DB_PREFIX."adherent WHERE login='".$db->escape(GETPOST('login'))."'";
$result = $db->query($sql);
- if ($result)
- {
+ if ($result) {
$num = $db->num_rows($result);
}
- if ($num != 0)
- {
+ if ($num != 0) {
$error++;
$langs->load("errors");
$errmsg .= $langs->trans("ErrorLoginAlreadyExists")."
\n";
}
- if (!isset($_POST["pass1"]) || !isset($_POST["pass2"]) || $_POST["pass1"] == '' || $_POST["pass2"] == '' || $_POST["pass1"] != $_POST["pass2"])
- {
+ if (!isset($_POST["pass1"]) || !isset($_POST["pass2"]) || $_POST["pass1"] == '' || $_POST["pass2"] == '' || $_POST["pass1"] != $_POST["pass2"]) {
$error++;
$langs->load("errors");
$errmsg .= $langs->trans("ErrorPasswordsMustMatch")."
\n";
}
- if (!GETPOST("email"))
- {
+ if (!GETPOST("email")) {
$error++;
$errmsg .= $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("EMail"))."
\n";
}
}
- if (GETPOST('type') <= 0)
- {
+ if (GETPOST('type') <= 0) {
$error++;
$errmsg .= $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Type"))."
\n";
}
- if (!in_array(GETPOST('morphy'), array('mor', 'phy')))
- {
+ if (!in_array(GETPOST('morphy'), array('mor', 'phy'))) {
$error++;
$errmsg .= $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv('Nature'))."
\n";
}
- if (empty($_POST["lastname"]))
- {
+ if (empty($_POST["lastname"])) {
$error++;
$errmsg .= $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Lastname"))."
\n";
}
- if (empty($_POST["firstname"]))
- {
+ if (empty($_POST["firstname"])) {
$error++;
$errmsg .= $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Firstname"))."
\n";
}
- if (GETPOST("email") && !isValidEmail(GETPOST("email")))
- {
+ if (GETPOST("email") && !isValidEmail(GETPOST("email"))) {
$error++;
$langs->load("errors");
$errmsg .= $langs->trans("ErrorBadEMail", GETPOST("email"))."
\n";
}
$birthday = dol_mktime($_POST["birthhour"], $_POST["birthmin"], $_POST["birthsec"], $_POST["birthmonth"], $_POST["birthday"], $_POST["birthyear"]);
- if ($_POST["birthmonth"] && empty($birthday))
- {
+ if ($_POST["birthmonth"] && empty($birthday)) {
$error++;
$langs->load("errors");
$errmsg .= $langs->trans("ErrorBadDateFormat")."
\n";
}
- if (!empty($conf->global->MEMBER_NEWFORM_DOLIBARRTURNOVER))
- {
- if (GETPOST("morphy") == 'mor' && GETPOST('budget') <= 0)
- {
+ if (!empty($conf->global->MEMBER_NEWFORM_DOLIBARRTURNOVER)) {
+ if (GETPOST("morphy") == 'mor' && GETPOST('budget') <= 0) {
$error++;
$errmsg .= $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("TurnoverOrBudget"))."
\n";
}
@@ -246,8 +227,7 @@ if (empty($reshook) && $action == 'add') {
if (isset($public)) $public = 1;
else $public = 0;
- if (!$error)
- {
+ if (!$error) {
// email a peu pres correct et le login n'existe pas
$adh = new Adherent($db);
$adh->statut = -1;
@@ -261,8 +241,7 @@ if (empty($reshook) && $action == 'add') {
$adh->zip = $_POST["zipcode"];
$adh->town = $_POST["town"];
$adh->email = $_POST["email"];
- if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED))
- {
+ if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED)) {
$adh->login = $_POST["login"];
$adh->pass = $_POST["pass1"];
}
@@ -281,16 +260,14 @@ if (empty($reshook) && $action == 'add') {
if ($ret < 0) $error++;
$result = $adh->create($user);
- if ($result > 0)
- {
+ if ($result > 0) {
require_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php';
$object = $adh;
$adht = new AdherentType($db);
$adht->fetch($object->typeid);
- if ($object->email)
- {
+ if ($object->email) {
$subject = '';
$msg = '';
@@ -308,8 +285,7 @@ if (empty($reshook) && $action == 'add') {
if (!empty($labeltouse)) $arraydefaultmessage = $formmail->getEMailTemplate($db, 'member', $user, $outputlangs, 0, 1, $labeltouse);
- if (!empty($labeltouse) && is_object($arraydefaultmessage) && $arraydefaultmessage->id > 0)
- {
+ if (!empty($labeltouse) && is_object($arraydefaultmessage) && $arraydefaultmessage->id > 0) {
$subject = $arraydefaultmessage->topic;
$msg = $arraydefaultmessage->content;
}
@@ -319,14 +295,12 @@ if (empty($reshook) && $action == 'add') {
$subjecttosend = make_substitutions($subject, $substitutionarray, $outputlangs);
$texttosend = make_substitutions(dol_concatdesc($msg, $adht->getMailOnValid()), $substitutionarray, $outputlangs);
- if ($subjecttosend && $texttosend)
- {
+ if ($subjecttosend && $texttosend) {
$moreinheader = 'X-Dolibarr-Info: send_an_email by public/members/new.php'."\r\n";
$result = $object->send_an_email($texttosend, $subjecttosend, array(), array(), array(), "", "", 0, -1, '', $moreinheader);
}
- /*if ($result < 0)
- {
+ /*if ($result < 0) {
$error++;
setEventMessages($object->error, $object->errors, 'errors');
}*/
@@ -334,18 +308,17 @@ if (empty($reshook) && $action == 'add') {
// Send email to the foundation to say a new member subscribed with autosubscribe form
if (!empty($conf->global->MAIN_INFO_SOCIETE_MAIL) && !empty($conf->global->ADHERENT_AUTOREGISTER_NOTIF_MAIL_SUBJECT) &&
- !empty($conf->global->ADHERENT_AUTOREGISTER_NOTIF_MAIL))
- {
+ !empty($conf->global->ADHERENT_AUTOREGISTER_NOTIF_MAIL)) {
// Define link to login card
$appli = constant('DOL_APPLICATION_TITLE');
- if (!empty($conf->global->MAIN_APPLICATION_TITLE))
- {
+ if (!empty($conf->global->MAIN_APPLICATION_TITLE)) {
$appli = $conf->global->MAIN_APPLICATION_TITLE;
- if (preg_match('/\d\.\d/', $appli))
- {
+ if (preg_match('/\d\.\d/', $appli)) {
if (!preg_match('/'.preg_quote(DOL_VERSION).'/', $appli)) $appli .= " (".DOL_VERSION.")"; // If new title contains a version that is different than core
} else $appli .= " ".DOL_VERSION;
- } else $appli .= " ".DOL_VERSION;
+ } else {
+ $appli .= " ".DOL_VERSION;
+ }
$to = $adh->makeSubstitution($conf->global->MAIN_INFO_SOCIETE_MAIL);
$from = $conf->global->ADHERENT_MAIL_FROM;
@@ -363,72 +336,60 @@ if (empty($reshook) && $action == 'add') {
-1
);
- if (!$mailfile->sendfile())
- {
+ if (!$mailfile->sendfile()) {
dol_syslog($langs->trans("ErrorFailedToSendMail", $from, $to), LOG_ERR);
}
}
- if (!empty($backtopage)) $urlback = $backtopage;
- elseif (!empty($conf->global->MEMBER_URL_REDIRECT_SUBSCRIPTION))
- {
+ if (!empty($backtopage)) {
+ $urlback = $backtopage;
+ } elseif (!empty($conf->global->MEMBER_URL_REDIRECT_SUBSCRIPTION)) {
$urlback = $conf->global->MEMBER_URL_REDIRECT_SUBSCRIPTION;
// TODO Make replacement of __AMOUNT__, etc...
- } else $urlback = $_SERVER["PHP_SELF"]."?action=added";
+ } else {
+ $urlback = $_SERVER["PHP_SELF"]."?action=added";
+ }
- if (!empty($conf->global->MEMBER_NEWFORM_PAYONLINE) && $conf->global->MEMBER_NEWFORM_PAYONLINE != '-1')
- {
- if ($conf->global->MEMBER_NEWFORM_PAYONLINE == 'all')
- {
+ if (!empty($conf->global->MEMBER_NEWFORM_PAYONLINE) && $conf->global->MEMBER_NEWFORM_PAYONLINE != '-1') {
+ if ($conf->global->MEMBER_NEWFORM_PAYONLINE == 'all') {
$urlback = DOL_MAIN_URL_ROOT.'/public/payment/newpayment.php?from=membernewform&source=membersubscription&ref='.urlencode($adh->ref);
if (price2num(GETPOST('amount', 'alpha'))) $urlback .= '&amount='.price2num(GETPOST('amount', 'alpha'));
if (GETPOST('email')) $urlback .= '&email='.urlencode(GETPOST('email'));
- if (!empty($conf->global->PAYMENT_SECURITY_TOKEN))
- {
- if (!empty($conf->global->PAYMENT_SECURITY_TOKEN_UNIQUE))
- {
+ if (!empty($conf->global->PAYMENT_SECURITY_TOKEN)) {
+ if (!empty($conf->global->PAYMENT_SECURITY_TOKEN_UNIQUE)) {
$urlback .= '&securekey='.urlencode(dol_hash($conf->global->PAYMENT_SECURITY_TOKEN.'membersubscription'.$adh->ref, 2));
} else {
$urlback .= '&securekey='.urlencode($conf->global->PAYMENT_SECURITY_TOKEN);
}
}
- } elseif ($conf->global->MEMBER_NEWFORM_PAYONLINE == 'paybox')
- {
+ } elseif ($conf->global->MEMBER_NEWFORM_PAYONLINE == 'paybox') {
$urlback = DOL_MAIN_URL_ROOT.'/public/paybox/newpayment.php?from=membernewform&source=membersubscription&ref='.urlencode($adh->ref);
if (price2num(GETPOST('amount', 'alpha'))) $urlback .= '&amount='.price2num(GETPOST('amount', 'alpha'));
if (GETPOST('email')) $urlback .= '&email='.urlencode(GETPOST('email'));
- if (!empty($conf->global->PAYMENT_SECURITY_TOKEN))
- {
- if (!empty($conf->global->PAYMENT_SECURITY_TOKEN_UNIQUE))
- {
+ if (!empty($conf->global->PAYMENT_SECURITY_TOKEN)) {
+ if (!empty($conf->global->PAYMENT_SECURITY_TOKEN_UNIQUE)) {
$urlback .= '&securekey='.urlencode(dol_hash($conf->global->PAYMENT_SECURITY_TOKEN.'membersubscription'.$adh->ref, 2));
} else {
$urlback .= '&securekey='.urlencode($conf->global->PAYMENT_SECURITY_TOKEN);
}
}
- } elseif ($conf->global->MEMBER_NEWFORM_PAYONLINE == 'paypal')
- {
+ } elseif ($conf->global->MEMBER_NEWFORM_PAYONLINE == 'paypal') {
$urlback = DOL_MAIN_URL_ROOT.'/public/paypal/newpayment.php?from=membernewform&source=membersubscription&ref='.urlencode($adh->ref);
if (price2num(GETPOST('amount', 'alpha'))) $urlback .= '&amount='.price2num(GETPOST('amount', 'alpha'));
if (GETPOST('email')) $urlback .= '&email='.urlencode(GETPOST('email'));
- if (!empty($conf->global->PAYMENT_SECURITY_TOKEN))
- {
- if (!empty($conf->global->PAYMENT_SECURITY_TOKEN_UNIQUE))
- {
+ if (!empty($conf->global->PAYMENT_SECURITY_TOKEN)) {
+ if (!empty($conf->global->PAYMENT_SECURITY_TOKEN_UNIQUE)) {
$urlback .= '&securekey='.urlencode(dol_hash($conf->global->PAYMENT_SECURITY_TOKEN.'membersubscription'.$adh->ref, 2));
} else {
$urlback .= '&securekey='.urlencode($conf->global->PAYMENT_SECURITY_TOKEN);
}
}
- } elseif ($conf->global->MEMBER_NEWFORM_PAYONLINE == 'stripe')
- {
+ } elseif ($conf->global->MEMBER_NEWFORM_PAYONLINE == 'stripe') {
$urlback = DOL_MAIN_URL_ROOT.'/public/stripe/newpayment.php?from=membernewform&source=membersubscription&ref='.$adh->ref;
if (price2num(GETPOST('amount', 'alpha'))) $urlback .= '&amount='.price2num(GETPOST('amount', 'alpha'));
if (GETPOST('email')) $urlback .= '&email='.urlencode(GETPOST('email'));
- if (!empty($conf->global->PAYMENT_SECURITY_TOKEN))
- {
- if (!empty($conf->global->PAYMENT_SECURITY_TOKEN_UNIQUE))
- {
+ if (!empty($conf->global->PAYMENT_SECURITY_TOKEN)) {
+ if (!empty($conf->global->PAYMENT_SECURITY_TOKEN_UNIQUE)) {
$urlback .= '&securekey='.urlencode(dol_hash($conf->global->PAYMENT_SECURITY_TOKEN.'membersubscription'.$adh->ref, 2));
} else {
$urlback .= '&securekey='.urlencode($conf->global->PAYMENT_SECURITY_TOKEN);
@@ -448,8 +409,7 @@ if (empty($reshook) && $action == 'add') {
}
}
- if (!$error)
- {
+ if (!$error) {
$db->commit();
Header("Location: ".$urlback);
@@ -497,8 +457,11 @@ print '
';
print '
';
print '
';
-if (!empty($conf->global->MEMBER_NEWFORM_TEXT)) print $langs->trans($conf->global->MEMBER_NEWFORM_TEXT)."
\n";
-else print $langs->trans("NewSubscriptionDesc", $conf->global->MAIN_INFO_SOCIETE_MAIL)."
\n";
+if (!empty($conf->global->MEMBER_NEWFORM_TEXT)) {
+ print $langs->trans($conf->global->MEMBER_NEWFORM_TEXT)."
\n";
+} else {
+ print $langs->trans("NewSubscriptionDesc", $conf->global->MAIN_INFO_SOCIETE_MAIL)."
\n";
+}
print '
';
dol_htmloutput_errors($errmsg);
@@ -544,13 +507,15 @@ jQuery(document).ready(function () {
print '
'."\n";
// Type
-if (empty($conf->global->MEMBER_NEWFORM_FORCETYPE))
-{
+if (empty($conf->global->MEMBER_NEWFORM_FORCETYPE)) {
$listoftype = $adht->liste_array();
$tmp = array_keys($listoftype);
$defaulttype = '';
$isempty = 1;
- if (count($listoftype) == 1) { $defaulttype = $tmp[0]; $isempty = 0; }
+ if (count($listoftype) == 1) {
+ $defaulttype = $tmp[0];
+ $isempty = 0;
+ }
print '| '.$langs->trans("Type").' * | ';
print $form->selectarray("type", $adht->liste_array(), GETPOST('type') ?GETPOST('type') : $defaulttype, $isempty);
print ' |
'."\n";
@@ -561,8 +526,7 @@ if (empty($conf->global->MEMBER_NEWFORM_FORCETYPE))
// Moral/Physic attribute
$morphys["phy"] = $langs->trans("Physical");
$morphys["mor"] = $langs->trans("Moral");
-if (empty($conf->global->MEMBER_NEWFORM_FORCEMORPHY))
-{
+if (empty($conf->global->MEMBER_NEWFORM_FORCEMORPHY)) {
print '| '.$langs->trans('MemberNature').' * | '."\n";
print $form->selectarray("morphy", $morphys, GETPOST('morphy'), 1);
print ' |
'."\n";
@@ -597,13 +561,13 @@ print '';
// 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);
-if (!$country_id && !empty($conf->geoipmaxmind->enabled))
-{
+if (!$country_id && !empty($conf->global->MEMBER_NEWFORM_FORCECOUNTRYCODE)) {
+ $country_id = getCountry($conf->global->MEMBER_NEWFORM_FORCECOUNTRYCODE, 2, $db, $langs);
+}
+if (!$country_id && !empty($conf->geoipmaxmind->enabled)) {
$country_code = dol_user_country();
//print $country_code;
- if ($country_code)
- {
+ if ($country_code) {
$new_country_id = getCountry($country_code, 3, $db, $langs);
//print 'xxx'.$country_code.' - '.$new_country_id;
if ($new_country_id) $country_id = $new_country_id;
@@ -613,8 +577,7 @@ $country_code = getCountry($country_id, 2, $db, $langs);
print $form->select_country($country_id, 'country_id');
print ' |
';
// State
-if (empty($conf->global->SOCIETE_DISABLE_STATE))
-{
+if (empty($conf->global->SOCIETE_DISABLE_STATE)) {
print '| '.$langs->trans('State').' | ';
if ($country_code) print $formcompany->select_state(GETPOST("state_id"), $country_code);
else print '';
@@ -623,8 +586,7 @@ if (empty($conf->global->SOCIETE_DISABLE_STATE))
// EMail
print ' |
| '.$langs->trans("Email").' * | |
'."\n";
// Login
-if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED))
-{
+if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED)) {
print '| '.$langs->trans("Login").' * | |
'."\n";
print '| '.$langs->trans("Password").' * | |
'."\n";
print '| '.$langs->trans("PasswordAgain").' * | |
'."\n";
@@ -647,8 +609,7 @@ print ' |