From ccc859ec8069ce78dfeef31c1599ae0b2baf2782 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Thu, 21 May 2020 09:12:18 +0200 Subject: [PATCH] add new rule --- htdocs/adherents/admin/adherent.php | 45 +- htdocs/adherents/admin/adherent_emails.php | 24 +- .../adherents/admin/adherent_extrafields.php | 9 +- .../admin/adherent_type_extrafields.php | 9 +- htdocs/adherents/admin/website.php | 21 +- htdocs/adherents/agenda.php | 26 +- .../actions_adherentcard_common.class.php | 39 +- .../actions_adherentcard_default.class.php | 9 +- .../default/tpl/adherentcard_create.tpl.php | 3 +- .../default/tpl/adherentcard_edit.tpl.php | 3 +- .../default/tpl/adherentcard_view.tpl.php | 3 +- htdocs/adherents/card.php | 408 ++++++------------ htdocs/adherents/cartes/carte.php | 66 +-- htdocs/adherents/class/adherent.class.php | 18 +- .../adherents/class/adherent_type.class.php | 98 ++--- .../adherents/class/adherentstats.class.php | 3 +- htdocs/adherents/class/api_members.class.php | 21 +- .../class/api_memberstypes.class.php | 18 +- .../class/api_subscriptions.class.php | 18 +- htdocs/adherents/class/subscription.class.php | 47 +- htdocs/adherents/document.php | 15 +- htdocs/adherents/htpasswd.php | 15 +- htdocs/adherents/index.php | 68 +-- htdocs/adherents/ldap.php | 30 +- htdocs/adherents/list.php | 219 ++++------ htdocs/adherents/note.php | 9 +- htdocs/adherents/stats/byproperties.php | 12 +- htdocs/adherents/stats/geo.php | 55 +-- htdocs/adherents/stats/index.php | 21 +- htdocs/adherents/subscription.php | 277 ++++-------- htdocs/adherents/subscription/card.php | 69 +-- htdocs/adherents/subscription/list.php | 124 ++---- .../adherents/tpl/linkedobjectblock.tpl.php | 6 +- htdocs/adherents/type.php | 133 ++---- htdocs/adherents/type_ldap.php | 21 +- htdocs/adherents/type_translation.php | 66 +-- htdocs/zapier/class/hook.class.php | 3 +- htdocs/zapier/hook_agenda.php | 29 +- htdocs/zapier/hook_card.php | 36 +- htdocs/zapier/hook_document.php | 6 +- htdocs/zapier/hook_list.php | 3 +- htdocs/zapier/hook_note.php | 3 +- htdocs/zapier/lib/zapier_hook.lib.php | 3 +- htdocs/zapier/zapierindex.php | 3 +- 44 files changed, 711 insertions(+), 1403 deletions(-) diff --git a/htdocs/adherents/admin/adherent.php b/htdocs/adherents/admin/adherent.php index ca5011849b1..ca1d1cc2a33 100644 --- a/htdocs/adherents/admin/adherent.php +++ b/htdocs/adherents/admin/adherent.php @@ -49,8 +49,7 @@ $action = GETPOST('action', 'alpha'); */ // -if ($action == 'updateall') -{ +if ($action == 'updateall') { $db->begin(); $res1 = $res2 = $res3 = $res4 = $res5 = $res6 = 0; $res1 = dolibarr_set_const($db, 'ADHERENT_LOGIN_NOT_REQUIRED', GETPOST('ADHERENT_LOGIN_NOT_REQUIRED', 'alpha') ? 0 : 1, 'chaine', 0, '', $conf->entity); @@ -58,17 +57,14 @@ if ($action == 'updateall') $res3 = dolibarr_set_const($db, 'ADHERENT_DEFAULT_SENDINFOBYMAIL', GETPOST('ADHERENT_DEFAULT_SENDINFOBYMAIL', 'alpha'), 'chaine', 0, '', $conf->entity); $res4 = dolibarr_set_const($db, 'ADHERENT_BANK_USE', GETPOST('ADHERENT_BANK_USE', 'alpha'), 'chaine', 0, '', $conf->entity); // Use vat for invoice creation - if ($conf->facture->enabled) - { + if ($conf->facture->enabled) { $res4 = dolibarr_set_const($db, 'ADHERENT_VAT_FOR_SUBSCRIPTIONS', GETPOST('ADHERENT_VAT_FOR_SUBSCRIPTIONS', 'alpha'), 'chaine', 0, '', $conf->entity); $res5 = dolibarr_set_const($db, 'ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS', GETPOST('ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS', 'alpha'), 'chaine', 0, '', $conf->entity); - if (!empty($conf->product->enabled) || !empty($conf->service->enabled)) - { + if (!empty($conf->product->enabled) || !empty($conf->service->enabled)) { $res6 = dolibarr_set_const($db, 'ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS', GETPOST('ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS', 'alpha'), 'chaine', 0, '', $conf->entity); } } - if ($res1 < 0 || $res2 < 0 || $res3 < 0 || $res4 < 0 || $res5 < 0 || $res6 < 0) - { + if ($res1 < 0 || $res2 < 0 || $res3 < 0 || $res4 < 0 || $res5 < 0 || $res6 < 0) { setEventMessages('ErrorFailedToSaveDate', null, 'errors'); $db->rollback(); } else { @@ -78,14 +74,12 @@ if ($action == 'updateall') } // Action to update or add a constant -if ($action == 'update' || $action == 'add') -{ +if ($action == 'update' || $action == 'add') { $constname = GETPOST('constname', 'alpha'); $constvalue = (GETPOST('constvalue_'.$constname) ? GETPOST('constvalue_'.$constname) : GETPOST('constvalue')); if (($constname == 'ADHERENT_CARD_TYPE' || $constname == 'ADHERENT_ETIQUETTE_TYPE' || $constname == 'ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS') && $constvalue == -1) $constvalue = ''; - if ($constname == 'ADHERENT_LOGIN_NOT_REQUIRED') // Invert choice - { + if ($constname == 'ADHERENT_LOGIN_NOT_REQUIRED') { // Invert choice if ($constvalue) $constvalue = 0; else $constvalue = 1; } @@ -96,8 +90,7 @@ if ($action == 'update' || $action == 'add') if (!$res > 0) $error++; - if (!$error) - { + if (!$error) { setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); } else { setEventMessages($langs->trans("Error"), null, 'errors'); @@ -105,21 +98,17 @@ if ($action == 'update' || $action == 'add') } // Action to enable of a submodule of the adherent module -if ($action == 'set') -{ +if ($action == 'set') { $result = dolibarr_set_const($db, GETPOST('name', 'alpha'), GETPOST('value'), '', 0, '', $conf->entity); - if ($result < 0) - { + if ($result < 0) { print $db->error(); } } // Action to disable a submodule of the adherent module -if ($action == 'unset') -{ +if ($action == 'unset') { $result = dolibarr_del_const($db, GETPOST('name', 'alpha'), $conf->entity); - if ($result < 0) - { + if ($result < 0) { print $db->error(); } } @@ -179,19 +168,16 @@ if (!empty($conf->banque->enabled) && !empty($conf->societe->enabled) && !empty( if (!empty($conf->banque->enabled) && !empty($conf->societe->enabled) && !empty($conf->facture->enabled)) $arraychoices['bankviainvoice'] = $langs->trans("MoreActionBankViaInvoice"); print ''; print $form->selectarray('ADHERENT_BANK_USE', $arraychoices, $conf->global->ADHERENT_BANK_USE, 0); -if ($conf->global->ADHERENT_BANK_USE == 'bankdirect' || $conf->global->ADHERENT_BANK_USE == 'bankviainvoice') -{ +if ($conf->global->ADHERENT_BANK_USE == 'bankdirect' || $conf->global->ADHERENT_BANK_USE == 'bankviainvoice') { print '
'.$langs->trans("ABankAccountMustBeDefinedOnPaymentModeSetup").'
'; } print ''; print "\n"; // Use vat for invoice creation -if ($conf->facture->enabled) -{ +if ($conf->facture->enabled) { print ''.$langs->trans("VATToUseForSubscriptions").''; - if (!empty($conf->banque->enabled)) - { + if (!empty($conf->banque->enabled)) { print ''; print $form->selectarray('ADHERENT_VAT_FOR_SUBSCRIPTIONS', array('0'=>$langs->trans("NoVatOnSubscription"), 'defaultforfoundationcountry'=>$langs->trans("Default")), (empty($conf->global->ADHERENT_VAT_FOR_SUBSCRIPTIONS) ? '0' : $conf->global->ADHERENT_VAT_FOR_SUBSCRIPTIONS), 0); print ''; @@ -202,8 +188,7 @@ if ($conf->facture->enabled) } print "\n"; - if (!empty($conf->product->enabled) || !empty($conf->service->enabled)) - { + if (!empty($conf->product->enabled) || !empty($conf->service->enabled)) { print ''.$langs->trans("ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS").''; print ''; $form->select_produits($conf->global->ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS, 'ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS', '', 0); diff --git a/htdocs/adherents/admin/adherent_emails.php b/htdocs/adherents/admin/adherent_emails.php index f59a27c170b..22519c55ab0 100644 --- a/htdocs/adherents/admin/adherent_emails.php +++ b/htdocs/adherents/admin/adherent_emails.php @@ -65,13 +65,11 @@ $constantes = array( */ // -if ($action == 'updateall') -{ +if ($action == 'updateall') { $db->begin(); $res1 = $res2 = $res3 = $res4 = $res5 = $res6 = 0; $res1 = dolibarr_set_const($db, 'XXXX', GETPOST('ADHERENT_LOGIN_NOT_REQUIRED', 'alpha'), 'chaine', 0, '', $conf->entity); - if ($res1 < 0 || $res2 < 0 || $res3 < 0 || $res4 < 0 || $res5 < 0 || $res6 < 0) - { + if ($res1 < 0 || $res2 < 0 || $res3 < 0 || $res4 < 0 || $res5 < 0 || $res6 < 0) { setEventMessages('ErrorFailedToSaveDate', null, 'errors'); $db->rollback(); } else { @@ -81,8 +79,7 @@ if ($action == 'updateall') } // Action to update or add a constant -if ($action == 'update' || $action == 'add') -{ +if ($action == 'update' || $action == 'add') { $constlineid = GETPOST('rowid', 'int'); $constname = GETPOST('constname', 'alpha'); @@ -96,8 +93,7 @@ if ($action == 'update' || $action == 'add') if (!$res > 0) $error++; - if (!$error) - { + if (!$error) { setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); } else { @@ -106,21 +102,17 @@ if ($action == 'update' || $action == 'add') } // Action to enable a submodule of the adherent module -if ($action == 'set') -{ +if ($action == 'set') { $result = dolibarr_set_const($db, GETPOST('name', 'alpha'), GETPOST('value'), '', 0, '', $conf->entity); - if ($result < 0) - { + if ($result < 0) { print $db->error(); } } // Action to disable a submodule of the adherent module -if ($action == 'unset') -{ +if ($action == 'unset') { $result = dolibarr_del_const($db, GETPOST('name', 'alpha'), $conf->entity); - if ($result < 0) - { + if ($result < 0) { print $db->error(); } } diff --git a/htdocs/adherents/admin/adherent_extrafields.php b/htdocs/adherents/admin/adherent_extrafields.php index 73e1a519c59..d3d91ecba09 100644 --- a/htdocs/adherents/admin/adherent_extrafields.php +++ b/htdocs/adherents/admin/adherent_extrafields.php @@ -78,8 +78,7 @@ dol_fiche_end(); // Buttons -if ($action != 'create' && $action != 'edit') -{ +if ($action != 'create' && $action != 'edit') { print '
'; print ''; print "
"; @@ -92,8 +91,7 @@ if ($action != 'create' && $action != 'edit') /* */ /* ************************************************************************** */ -if ($action == 'create') -{ +if ($action == 'create') { print '

'; print load_fiche_titre($langs->trans('NewAttribute')); @@ -105,8 +103,7 @@ if ($action == 'create') /* Edition of an optional field */ /* */ /* ************************************************************************** */ -if ($action == 'edit' && !empty($attrname)) -{ +if ($action == 'edit' && !empty($attrname)) { print '

'; print load_fiche_titre($langs->trans("FieldEdition", $attrname)); diff --git a/htdocs/adherents/admin/adherent_type_extrafields.php b/htdocs/adherents/admin/adherent_type_extrafields.php index 7864505f2e1..fe7989a70b9 100644 --- a/htdocs/adherents/admin/adherent_type_extrafields.php +++ b/htdocs/adherents/admin/adherent_type_extrafields.php @@ -81,8 +81,7 @@ dol_fiche_end(); // Buttons -if ($action != 'create' && $action != 'edit') -{ +if ($action != 'create' && $action != 'edit') { print '
'; print ''; print "
"; @@ -95,8 +94,7 @@ if ($action != 'create' && $action != 'edit') /* */ /* ************************************************************************** */ -if ($action == 'create') -{ +if ($action == 'create') { print "
"; print load_fiche_titre($langs->trans('NewAttribute')); @@ -108,8 +106,7 @@ if ($action == 'create') /* Edition of an optional field */ /* */ /* ************************************************************************** */ -if ($action == 'edit' && !empty($attrname)) -{ +if ($action == 'edit' && !empty($attrname)) { print "
"; print load_fiche_titre($langs->trans("FieldEdition", $attrname)); diff --git a/htdocs/adherents/admin/website.php b/htdocs/adherents/admin/website.php index 50a7f58e8c5..0dbb998f764 100644 --- a/htdocs/adherents/admin/website.php +++ b/htdocs/adherents/admin/website.php @@ -42,14 +42,12 @@ if (!$user->admin) accessforbidden(); * Actions */ -if ($action == 'setMEMBER_ENABLE_PUBLIC') -{ +if ($action == 'setMEMBER_ENABLE_PUBLIC') { if (GETPOST('value')) dolibarr_set_const($db, 'MEMBER_ENABLE_PUBLIC', 1, 'chaine', 0, '', $conf->entity); else dolibarr_set_const($db, 'MEMBER_ENABLE_PUBLIC', 0, 'chaine', 0, '', $conf->entity); } -if ($action == 'update') -{ +if ($action == 'update') { $public = GETPOST('MEMBER_ENABLE_PUBLIC'); $amount = GETPOST('MEMBER_NEWFORM_AMOUNT'); $editamount = GETPOST('MEMBER_NEWFORM_EDITAMOUNT'); @@ -67,8 +65,7 @@ if ($action == 'update') if (!$res > 0) $error++; - if (!$error) - { + if (!$error) { setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); } else { setEventMessages($langs->trans("Error"), null, 'errors'); @@ -99,8 +96,7 @@ print ''; dol_fiche_head($head, 'website', $langs->trans("Members"), -1, 'user'); -if ($conf->use_javascript_ajax) -{ +if ($conf->use_javascript_ajax) { print "\n".''."\n"; } - if (is_object($objsoc) && $objsoc->id > 0) - { + if (is_object($objsoc) && $objsoc->id > 0) { $this->tpl['company'] = $objsoc->getNomUrl(1); $this->tpl['company_id'] = $objsoc->id; } else { @@ -126,8 +122,7 @@ abstract class ActionsAdherentCardCommon $this->tpl['select_civility'] = $formcompany->select_civility($this->object->civility_id); // Predefined with third party - if ((isset($objsoc->typent_code) && $objsoc->typent_code == 'TE_PRIVATE')) - { + if ((isset($objsoc->typent_code) && $objsoc->typent_code == 'TE_PRIVATE')) { if (dol_strlen(trim($this->object->address)) == 0) $this->tpl['address'] = $objsoc->address; if (dol_strlen(trim($this->object->zip)) == 0) $this->object->zip = $objsoc->zip; if (dol_strlen(trim($this->object->town)) == 0) $this->object->town = $objsoc->town; @@ -159,18 +154,15 @@ abstract class ActionsAdherentCardCommon $this->tpl['select_morphy'] = $form->selectarray('morphy', $selectarray, $this->object->morphy, 0); } - if ($action == 'view' || $action == 'edit' || $action == 'delete') - { + if ($action == 'view' || $action == 'edit' || $action == 'delete') { // Emailing - if (!empty($conf->mailing->enabled)) - { + if (!empty($conf->mailing->enabled)) { $langs->load("mails"); $this->tpl['nb_emailing'] = $this->object->getNbOfEMailings(); } // Dolibarr user - if ($this->object->user_id) - { + if ($this->object->user_id) { $dolibarr_user = new User($this->db); $result = $dolibarr_user->fetch($this->object->user_id); $this->tpl['dolibarr_user'] = $dolibarr_user->getLoginUrl(1); @@ -178,12 +170,10 @@ abstract class ActionsAdherentCardCommon else $this->tpl['dolibarr_user'] = $langs->trans("NoDolibarrAccess"); } - if ($action == 'view' || $action == 'delete') - { + if ($action == 'view' || $action == 'delete') { $this->tpl['showrefnav'] = $form->showrefnav($this->object, 'id'); - if ($this->object->socid > 0) - { + if ($this->object->socid > 0) { $objsoc = new Societe($this->db); $objsoc->fetch($this->object->socid); @@ -210,8 +200,7 @@ abstract class ActionsAdherentCardCommon $this->tpl['note'] = nl2br($this->object->note); } - if ($action == 'create_user') - { + if ($action == 'create_user') { // Full firstname and lastname separated with a dot : firstname.lastname include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/security2.lib.php'; @@ -259,12 +248,10 @@ abstract class ActionsAdherentCardCommon $this->object->canvas = $_POST["canvas"]; // We set country_id, and country_code label of the chosen country - if ($this->object->country_id) - { + if ($this->object->country_id) { $sql = "SELECT code, label FROM ".MAIN_DB_PREFIX."c_country WHERE rowid = ".$this->object->country_id; $resql = $this->db->query($sql); - if ($resql) - { + if ($resql) { $obj = $this->db->fetch_object($resql); $this->object->country_code = $obj->code; diff --git a/htdocs/adherents/canvas/default/actions_adherentcard_default.class.php b/htdocs/adherents/canvas/default/actions_adherentcard_default.class.php index f248256a547..db2473c55d9 100644 --- a/htdocs/adherents/canvas/default/actions_adherentcard_default.class.php +++ b/htdocs/adherents/canvas/default/actions_adherentcard_default.class.php @@ -90,8 +90,7 @@ class ActionsAdherentCardDefault extends ActionsAdherentCardCommon $this->tpl['error'] = $this->error; $this->tpl['errors'] = $this->errors; - if ($action == 'view') - { + if ($action == 'view') { // Card header $head = member_prepare_head($this->object); $title = $this->getTitle($action); @@ -107,14 +106,12 @@ class ActionsAdherentCardDefault extends ActionsAdherentCardCommon $this->tpl['actionsdone'] = show_actions_done($conf, $langs, $db, $objsoc, $this->object, 1); } else { // Confirm delete contact - if ($action == 'delete' && $user->rights->adherent->supprimer) - { + if ($action == 'delete' && $user->rights->adherent->supprimer) { $this->tpl['action_delete'] = $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$this->object->id, $langs->trans("DeleteAdherent"), $langs->trans("ConfirmDeleteAdherent"), "confirm_delete", '', 0, 1); } } - if ($action == 'list') - { + if ($action == 'list') { $this->LoadListDatas($limit, $offset, $sortfield, $sortorder); } } diff --git a/htdocs/adherents/canvas/default/tpl/adherentcard_create.tpl.php b/htdocs/adherents/canvas/default/tpl/adherentcard_create.tpl.php index 92f1e11d7a2..b6c0b542d27 100644 --- a/htdocs/adherents/canvas/default/tpl/adherentcard_create.tpl.php +++ b/htdocs/adherents/canvas/default/tpl/adherentcard_create.tpl.php @@ -17,8 +17,7 @@ */ // Protection to avoid direct call of template -if (empty($conf) || !is_object($conf)) -{ +if (empty($conf) || !is_object($conf)) { print "Error, template page can't be called as URL"; exit; } diff --git a/htdocs/adherents/canvas/default/tpl/adherentcard_edit.tpl.php b/htdocs/adherents/canvas/default/tpl/adherentcard_edit.tpl.php index 36e2deab14c..92a4fbddd38 100644 --- a/htdocs/adherents/canvas/default/tpl/adherentcard_edit.tpl.php +++ b/htdocs/adherents/canvas/default/tpl/adherentcard_edit.tpl.php @@ -17,8 +17,7 @@ */ // Protection to avoid direct call of template -if (empty($conf) || !is_object($conf)) -{ +if (empty($conf) || !is_object($conf)) { print "Error, template page can't be called as URL"; exit; } diff --git a/htdocs/adherents/canvas/default/tpl/adherentcard_view.tpl.php b/htdocs/adherents/canvas/default/tpl/adherentcard_view.tpl.php index b738f549247..8789b2fcb34 100644 --- a/htdocs/adherents/canvas/default/tpl/adherentcard_view.tpl.php +++ b/htdocs/adherents/canvas/default/tpl/adherentcard_view.tpl.php @@ -17,8 +17,7 @@ */ // Protection to avoid direct call of template -if (empty($conf) || !is_object($conf)) -{ +if (empty($conf) || !is_object($conf)) { print "Error, template page can't be called as URL"; exit; } diff --git a/htdocs/adherents/card.php b/htdocs/adherents/card.php index 7a5880fc317..cf5253e3bf8 100644 --- a/htdocs/adherents/card.php +++ b/htdocs/adherents/card.php @@ -55,8 +55,7 @@ $typeid = GETPOST('typeid', 'int'); $userid = GETPOST('userid', 'int'); $socid = GETPOST('socid', 'int'); -if (!empty($conf->mailmanspip->enabled)) -{ +if (!empty($conf->mailmanspip->enabled)) { include_once DOL_DOCUMENT_ROOT.'/mailmanspip/class/mailmanspip.class.php'; $langs->load('mailmanspip'); @@ -76,8 +75,7 @@ $socialnetworks = getArrayOfSocialNetworks(); $object->getCanvas($id); $canvas = $object->canvas ? $object->canvas : GETPOST("canvas"); $objcanvas = null; -if (!empty($canvas)) -{ +if (!empty($canvas)) { require_once DOL_DOCUMENT_ROOT.'/core/class/canvas.class.php'; $objcanvas = new Canvas($db, $action); $objcanvas->getCanvas('adherent', 'membercard', $canvas); @@ -86,16 +84,14 @@ if (!empty($canvas)) // Security check $result = restrictedArea($user, 'adherent', $id, '', '', 'socid', 'rowid', $objcanvas); -if ($id > 0) -{ +if ($id > 0) { // Load member $result = $object->fetch($id); // Define variables to know what current user can do on users $canadduser = ($user->admin || $user->rights->user->user->creer); // Define variables to know what current user can do on properties of user linked to edited member - if ($object->user_id) - { + if ($object->user_id) { // $User is the user who edits, $object->user_id is the id of the related user in the edited member $caneditfielduser = ((($user->id == $object->user_id) && $user->rights->user->self->creer) || (($user->id != $object->user_id) && $user->rights->user->user->creer)); @@ -107,8 +103,7 @@ if ($id > 0) // Define variables to determine what the current user can do on the members $canaddmember = $user->rights->adherent->creer; // Define variables to determine what the current user can do on the properties of a member -if ($id) -{ +if ($id) { $caneditfieldmember = $user->rights->adherent->creer; } @@ -125,34 +120,26 @@ $parameters = array('id'=>$id, 'rowid'=>$id, 'objcanvas'=>$objcanvas, 'confirm'= $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); -if (empty($reshook)) -{ - if ($cancel) - { - if (!empty($backtopage)) - { +if (empty($reshook)) { + if ($cancel) { + if (!empty($backtopage)) { header("Location: ".$backtopage); exit; } $action = ''; } - if ($action == 'setuserid' && ($user->rights->user->self->creer || $user->rights->user->user->creer)) - { + if ($action == 'setuserid' && ($user->rights->user->self->creer || $user->rights->user->user->creer)) { $error = 0; - if (empty($user->rights->user->user->creer)) // If can edit only itself user, we can link to itself only - { - if ($userid != $user->id && $userid != $object->user_id) - { + if (empty($user->rights->user->user->creer)) { // If can edit only itself user, we can link to itself only + if ($userid != $user->id && $userid != $object->user_id) { $error++; setEventMessages($langs->trans("ErrorUserPermissionAllowsToLinksToItselfOnly"), null, 'errors'); } } - if (!$error) - { - if ($userid != $object->user_id) // If link differs from currently in database - { + if (!$error) { + if ($userid != $object->user_id) { // If link differs from currently in database $result = $object->setUserId($userid); if ($result < 0) dol_print_error($object->db, $object->error); $action = ''; @@ -160,22 +147,17 @@ if (empty($reshook)) } } - if ($action == 'setsocid') - { + if ($action == 'setsocid') { $error = 0; - if (!$error) - { - if ($socid != $object->socid) // If link differs from currently in database - { + if (!$error) { + if ($socid != $object->socid) { // If link differs from currently in database $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."adherent"; $sql .= " WHERE socid = '".$socid."'"; $sql .= " AND entity = ".$conf->entity; $resql = $db->query($sql); - if ($resql) - { + if ($resql) { $obj = $db->fetch_object($resql); - if ($obj && $obj->rowid > 0) - { + if ($obj && $obj->rowid > 0) { $othermember = new Adherent($db); $othermember->fetch($obj->rowid); $thirdparty = new Societe($db); @@ -185,8 +167,7 @@ if (empty($reshook)) } } - if (!$error) - { + if (!$error) { $result = $object->setThirdPartyId($socid); if ($result < 0) dol_print_error($object->db, $object->error); $action = ''; @@ -196,16 +177,13 @@ if (empty($reshook)) } // Create user from a member - if ($action == 'confirm_create_user' && $confirm == 'yes' && $user->rights->user->user->creer) - { - if ($result > 0) - { + if ($action == 'confirm_create_user' && $confirm == 'yes' && $user->rights->user->user->creer) { + if ($result > 0) { // Creation user $nuser = new User($db); $result = $nuser->create_from_member($object, GETPOST('login', 'alphanohtml')); - if ($result < 0) - { + if ($result < 0) { $langs->load("errors"); setEventMessages($langs->trans($nuser->error), null, 'errors'); } @@ -215,16 +193,13 @@ if (empty($reshook)) } // Create third party from a member - if ($action == 'confirm_create_thirdparty' && $confirm == 'yes' && $user->rights->societe->creer) - { - if ($result > 0) - { + if ($action == 'confirm_create_thirdparty' && $confirm == 'yes' && $user->rights->societe->creer) { + if ($result > 0) { // User creation $company = new Societe($db); $result = $company->create_from_member($object, GETPOST('companyname', 'alpha'), GETPOST('companyalias', 'alpha')); - if ($result < 0) - { + if ($result < 0) { $langs->load("errors"); setEventMessages($langs->trans($company->error), null, 'errors'); setEventMessages($company->error, $company->errors, 'errors'); @@ -234,15 +209,13 @@ if (empty($reshook)) } } - if ($action == 'update' && !$cancel && $user->rights->adherent->creer) - { + if ($action == 'update' && !$cancel && $user->rights->adherent->creer) { require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; $birthdate = ''; if (isset($_POST["birthday"]) && $_POST["birthday"] && isset($_POST["birthmonth"]) && $_POST["birthmonth"] - && isset($_POST["birthyear"]) && $_POST["birthyear"]) - { + && isset($_POST["birthyear"]) && $_POST["birthyear"]) { $birthdate = dol_mktime(12, 0, 0, $_POST["birthmonth"], $_POST["birthday"], $_POST["birthyear"]); } $lastname = $_POST["lastname"]; @@ -267,16 +240,14 @@ if (empty($reshook)) setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Company")), null, 'errors'); } // Check if the login already exists - if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED)) - { + if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED)) { if (empty($login)) { $error++; setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Login")), null, 'errors'); } } // Create new object - if ($result > 0 && !$error) - { + if ($result > 0 && !$error) { $object->oldcopy = clone $object; // Change values @@ -329,32 +300,27 @@ if (empty($reshook)) // Check if we need to also synchronize user information $nosyncuser = 0; - if ($object->user_id) // If linked to a user - { + if ($object->user_id) { // If linked to a user if ($user->id != $object->user_id && empty($user->rights->user->user->creer)) $nosyncuser = 1; // Disable synchronizing } // Check if we need to also synchronize password information $nosyncuserpass = 0; - if ($object->user_id) // If linked to a user - { + if ($object->user_id) { // If linked to a user if ($user->id != $object->user_id && empty($user->rights->user->user->password)) $nosyncuserpass = 1; // Disable synchronizing } $result = $object->update($user, 0, $nosyncuser, $nosyncuserpass); - if ($result >= 0 && !count($object->errors)) - { + if ($result >= 0 && !count($object->errors)) { $categories = GETPOST('memcats', 'array'); $object->setCategories($categories); // Logo/Photo save $dir = $conf->adherent->dir_output.'/'.get_exdir(0, 0, 0, 1, $object, 'member').'/photos'; $file_OK = is_uploaded_file($_FILES['photo']['tmp_name']); - if ($file_OK) - { - if (GETPOST('deletephoto')) - { + if ($file_OK) { + if (GETPOST('deletephoto')) { require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; $fileimg = $conf->adherent->dir_output.'/'.get_exdir(0, 0, 0, 1, $object, 'member').'/photos/'.$object->photo; $dirthumbs = $conf->adherent->dir_output.'/'.get_exdir(0, 0, 0, 1, $object, 'member').'/photos/thumbs'; @@ -362,15 +328,12 @@ if (empty($reshook)) dol_delete_dir_recursive($dirthumbs); } - if (image_format_supported($_FILES['photo']['name']) > 0) - { + if (image_format_supported($_FILES['photo']['name']) > 0) { dol_mkdir($dir); - if (@is_dir($dir)) - { + if (@is_dir($dir)) { $newfile = $dir.'/'.dol_sanitizeFileName($_FILES['photo']['name']); - if (!dol_move_uploaded_file($_FILES['photo']['tmp_name'], $newfile, 1, 0, $_FILES['photo']['error']) > 0) - { + if (!dol_move_uploaded_file($_FILES['photo']['tmp_name'], $newfile, 1, 0, $_FILES['photo']['error']) > 0) { setEventMessages($langs->trans("ErrorFailedToSaveFile"), null, 'errors'); } else { // Create thumbs @@ -381,8 +344,7 @@ if (empty($reshook)) setEventMessages("ErrorBadImageFormat", null, 'errors'); } } else { - switch ($_FILES['photo']['error']) - { + switch ($_FILES['photo']['error']) { case 1: //uploaded file exceeds the upload_max_filesize directive in php.ini case 2: //uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the html form $errors[] = "ErrorFileSizeTooLarge"; @@ -397,8 +359,7 @@ if (empty($reshook)) $id = $object->id; $action = ''; - if (!empty($backtopage)) - { + if (!empty($backtopage)) { header("Location: ".$backtopage); exit; } @@ -411,19 +372,16 @@ if (empty($reshook)) } } - if ($action == 'add' && $user->rights->adherent->creer) - { + if ($action == 'add' && $user->rights->adherent->creer) { if ($canvas) $object->canvas = $canvas; $birthdate = ''; if (isset($_POST["birthday"]) && $_POST["birthday"] && isset($_POST["birthmonth"]) && $_POST["birthmonth"] - && isset($_POST["birthyear"]) && $_POST["birthyear"]) - { + && isset($_POST["birthyear"]) && $_POST["birthyear"]) { $birthdate = dol_mktime(12, 0, 0, $_POST["birthmonth"], $_POST["birthday"], $_POST["birthyear"]); } $datesubscription = ''; - if (isset($_POST["reday"]) && isset($_POST["remonth"]) && isset($_POST["reyear"])) - { + if (isset($_POST["reday"]) && isset($_POST["remonth"]) && isset($_POST["reyear"])) { $datesubscription = dol_mktime(12, 0, 0, $_POST["remonth"], $_POST["reday"], $_POST["reyear"]); } @@ -508,8 +466,7 @@ if (empty($reshook)) setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("MemberNature")), null, 'errors'); } // Tests if the login already exists - if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED)) - { + if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED)) { if (empty($login)) { $error++; setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Login")), null, 'errors'); @@ -557,14 +514,12 @@ if (empty($reshook)) $public = 0; if (isset($public)) $public = 1; - if (!$error) - { + if (!$error) { $db->begin(); // Email about right and login does not exist $result = $object->create($user); - if ($result > 0) - { + if ($result > 0) { // Foundation categories $memcats = GETPOST('memcats', 'array'); $object->setCategories($memcats); @@ -590,13 +545,10 @@ if (empty($reshook)) } } - if ($user->rights->adherent->supprimer && $action == 'confirm_delete' && $confirm == 'yes') - { + if ($user->rights->adherent->supprimer && $action == 'confirm_delete' && $confirm == 'yes') { $result = $object->delete($id, $user); - if ($result > 0) - { - if (!empty($backtopage)) - { + if ($result > 0) { + if (!empty($backtopage)) { header("Location: ".$backtopage); exit; } else { @@ -608,8 +560,7 @@ if (empty($reshook)) } } - if ($user->rights->adherent->creer && $action == 'confirm_valid' && $confirm == 'yes') - { + if ($user->rights->adherent->creer && $action == 'confirm_valid' && $confirm == 'yes') { $error = 0; $db->begin(); @@ -619,11 +570,9 @@ if (empty($reshook)) $result = $object->validate($user); - if ($result >= 0 && !count($object->errors)) - { + if ($result >= 0 && !count($object->errors)) { // Send confirmation email (according to parameters of member type. Otherwise generic) - if ($object->email && GETPOST("send_mail")) - { + if ($object->email && GETPOST("send_mail")) { $subject = ''; $msg = ''; @@ -641,8 +590,7 @@ if (empty($reshook)) 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; } @@ -661,8 +609,7 @@ if (empty($reshook)) $moreinheader = 'X-Dolibarr-Info: send_an_email by adherents/card.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'); } @@ -677,8 +624,7 @@ if (empty($reshook)) } } - if (!$error) - { + if (!$error) { $db->commit(); } else { $db->rollback(); @@ -686,21 +632,17 @@ if (empty($reshook)) $action = ''; } - if ($user->rights->adherent->supprimer && $action == 'confirm_resign') - { + if ($user->rights->adherent->supprimer && $action == 'confirm_resign') { $error = 0; - if ($confirm == 'yes') - { + if ($confirm == 'yes') { $adht = new AdherentType($db); $adht->fetch($object->typeid); $result = $object->resiliate($user); - if ($result >= 0 && !count($object->errors)) - { - if ($object->email && GETPOST("send_mail")) - { + if ($result >= 0 && !count($object->errors)) { + if ($object->email && GETPOST("send_mail")) { $subject = ''; $msg = ''; @@ -718,8 +660,7 @@ if (empty($reshook)) 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; } @@ -738,8 +679,7 @@ if (empty($reshook)) $moreinheader = 'X-Dolibarr-Info: send_an_email by adherents/card.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'); } @@ -756,31 +696,24 @@ if (empty($reshook)) $action = ''; } } - if (!empty($backtopage) && !$error) - { + if (!empty($backtopage) && !$error) { header("Location: ".$backtopage); exit; } } // SPIP Management - if ($user->rights->adherent->supprimer && $action == 'confirm_del_spip' && $confirm == 'yes') - { - if (!count($object->errors)) - { - if (!$mailmanspip->del_to_spip($object)) - { + if ($user->rights->adherent->supprimer && $action == 'confirm_del_spip' && $confirm == 'yes') { + if (!count($object->errors)) { + if (!$mailmanspip->del_to_spip($object)) { setEventMessages($langs->trans('DeleteIntoSpipError').': '.$mailmanspip->error, null, 'errors'); } } } - if ($user->rights->adherent->creer && $action == 'confirm_add_spip' && $confirm == 'yes') - { - if (!count($object->errors)) - { - if (!$mailmanspip->add_to_spip($object)) - { + if ($user->rights->adherent->creer && $action == 'confirm_add_spip' && $confirm == 'yes') { + if (!count($object->errors)) { + if (!$mailmanspip->add_to_spip($object)) { setEventMessages($langs->trans('AddIntoSpipError').': '.$mailmanspip->error, null, 'errors'); } } @@ -817,13 +750,11 @@ llxHeader('', $title, $help_url); $countrynotdefined = $langs->trans("ErrorSetACountryFirst").' ('.$langs->trans("SeeAbove").')'; -if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) -{ +if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { // ----------------------------------------- // When used with CANVAS // ----------------------------------------- - if (empty($object->error) && $id) - { + if (empty($object->error) && $id) { $object = new Adherent($db); $result = $object->fetch($id); if ($result <= 0) dol_print_error('', $object->error); @@ -835,8 +766,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) // When used in standard mode // ----------------------------------------- - if ($action == 'create') - { + if ($action == 'create') { /* ************************************************************************** */ /* */ /* Creation mode */ @@ -847,8 +777,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) // We set country_id, country_code and country for the selected country $object->country_id = GETPOST('country_id', 'int') ?GETPOST('country_id', 'int') : $mysoc->country_id; - if ($object->country_id) - { + if ($object->country_id) { $tmparray = getCountry($object->country_id, 'all'); $object->country_code = $tmparray['code']; $object->country = $tmparray['label']; @@ -858,8 +787,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) $object = new Societe($db); if ($socid > 0) $object->fetch($socid); - if (!($object->id > 0)) - { + if (!($object->id > 0)) { $langs->load("errors"); print($langs->trans('ErrorRecordNotFound')); exit; @@ -870,8 +798,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) print load_fiche_titre($langs->trans("NewMember"), '', 'members'); - if ($conf->use_javascript_ajax) - { + if ($conf->use_javascript_ajax) { print "\n".'