2
0
forked from Wavyzz/dolibarr

Update change select to button on/off (#31443)

* change select to button on/off

* fix error and update view to show social network enabled

* remove var_dump'

* add function getSocialNetworks

* fix errors params in function

* fix errors travis

* fix errors

* update type of params

* fix type of params in function getSocialNetwork

* remove ve_dump

* remove function getSocialNetwork
This commit is contained in:
lamrani abdelwadoud
2024-10-29 23:09:56 +01:00
committed by GitHub
parent 1006edf1a7
commit fc8c299b3e
5 changed files with 83 additions and 46 deletions

View File

@@ -12494,21 +12494,21 @@ function dolGetStatus($statusLabel = '', $statusLabelShort = '', $html = '', $st
* @param int|boolean $userRight User action right * @param int|boolean $userRight User action right
* // phpcs:disable * // phpcs:disable
* @param array{confirm?:array{url?:string,title?:string,content?:string,action-btn-label?:string,cancel-btn-label?:string,modal?:bool},attr?:array<string,mixed>,areDropdownButtons?:bool,backtopage?:string,lang?:string,enabled?:bool,perm?:int<0,1>,label?:string,url?:string,isDropdown?:int<0,1>,isDropDown?:int<0,1>} $params = [ // Various params for future : recommended rather than adding more function arguments * @param array{confirm?:array{url?:string,title?:string,content?:string,action-btn-label?:string,cancel-btn-label?:string,modal?:bool},attr?:array<string,mixed>,areDropdownButtons?:bool,backtopage?:string,lang?:string,enabled?:bool,perm?:int<0,1>,label?:string,url?:string,isDropdown?:int<0,1>,isDropDown?:int<0,1>} $params = [ // Various params for future : recommended rather than adding more function arguments
* 'attr' => [ // to add or override button attributes * 'attr' => [ // to add or override button attributes
* 'xxxxx' => '', // your xxxxx attribute you want * 'xxxxx' => '', // your xxxxx attribute you want
* 'class' => 'reposition', // to add more css class to the button class attribute * 'class' => 'reposition', // to add more css class to the button class attribute
* 'classOverride' => '' // to replace class attribute of the button * 'classOverride' => '' // to replace class attribute of the button
* ], * ],
* 'confirm' => [ * 'confirm' => [
* 'url' => 'http://', // Override Url to go when user click on action btn, if empty default url is $url.?confirm=yes, for no js compatibility use $url for fallback confirm. * 'url' => 'http://', // Override Url to go when user click on action btn, if empty default url is $url.?confirm=yes, for no js compatibility use $url for fallback confirm.
* 'title' => '', // Override title of modal, if empty default title use "ConfirmBtnCommonTitle" lang key * 'title' => '', // Override title of modal, if empty default title use "ConfirmBtnCommonTitle" lang key
* 'action-btn-label' => '', // Override label of action button, if empty default label use "Confirm" lang key * 'action-btn-label' => '', // Override label of action button, if empty default label use "Confirm" lang key
* 'cancel-btn-label' => '', // Override label of cancel button, if empty default label use "CloseDialog" lang key * 'cancel-btn-label' => '', // Override label of cancel button, if empty default label use "CloseDialog" lang key
* 'content' => '', // Override text of content, if empty default content use "ConfirmBtnCommonContent" lang key * 'content' => '', // Override text of content, if empty default content use "ConfirmBtnCommonContent" lang key
* 'modal' => true, // true|false to display dialog as a modal (with dark background) * 'modal' => true, // true|false to display dialog as a modal (with dark background)
* 'isDropDown' => false, // true|false to display dialog as a dropdown list (css dropdown-item with dark background) * 'isDropDown' => false, // true|false to display dialog as a dropdown list (css dropdown-item with dark background)
* ], * ],
* ] * ]
* // phpcs:enable * // phpcs:enable
* Example: array('attr' => array('class' => 'reposition')) * Example: array('attr' => array('class' => 'reposition'))
* @return string html button * @return string html button

View File

@@ -462,4 +462,5 @@ IDOfPaymentInAnExternalSystem=ID of the payment mode into an external system (li
AADEWebserviceCredentials=AADE Webservice Credentials AADEWebserviceCredentials=AADE Webservice Credentials
ThirdPartyMustBeACustomerToCreateBANOnStripe=The third-party must be a customer to allow the creation of its bank info on Stripe side ThirdPartyMustBeACustomerToCreateBANOnStripe=The third-party must be a customer to allow the creation of its bank info on Stripe side
NewSocNameForClone=New company name NewSocNameForClone=New company name
ConfirmCloneThirdparties=Are you sure that you want to clone <b>%s</b> company ? ConfirmCloneThirdparties=Are you sure that you want to clone <b>%s</b> company ?
SocialNetworksBusiness=Social networks for company

View File

@@ -137,3 +137,4 @@ ExcludedByFilter=Non qualified by filters but shown to see its hierarchy
UserEnabledDisabled=User status changed: %s UserEnabledDisabled=User status changed: %s
AlternativeEmailForOAuth2=Alternative Email for OAuth2 login AlternativeEmailForOAuth2=Alternative Email for OAuth2 login
ErrorUpdateCanceledDueToDuplicatedUniqueValue=Error, The update was canceled because one of the pieces of data, that should be unique, already exists ErrorUpdateCanceledDueToDuplicatedUniqueValue=Error, The update was canceled because one of the pieces of data, that should be unique, already exists
SocialNetworksUser=Social networks for user

View File

@@ -342,11 +342,12 @@ if (getDolUserInt('USER_PUBLIC_SHOW_ADDRESS', 0, $object) && $object->address) {
} }
// Social networks // Social networks
if (!empty($object->socialnetworks) && is_array($object->socialnetworks) && count($object->socialnetworks) > 0) { if (!empty($object->socialnetworks) && is_array($object->socialnetworks)) {
if (!getDolUserInt('USER_PUBLIC_HIDE_SOCIALNETWORKS', 0, $object)) { if (!getDolGlobalInt('USER_PUBLIC_HIDE_SOCIALNETWORKS')) {
foreach ($object->socialnetworks as $key => $value) { $listOfSocialNetworks = $object->socialnetworks;
if ($value) { foreach ($listOfSocialNetworks as $key => $value) {
$usersection .= '<div class="flexitemsmall">'.dol_print_socialnetworks($value, 0, $mysoc->id, $key, $socialnetworksdict).'</div>'; if (getDolGlobalString('USER_SOCIALNETWORK_'.strtoupper($key))) {
$usersection .= '<div class="flexitemsmall">'.dol_print_socialnetworks($key, 0, $object->id, strtolower($key), $socialnetworksdict).'</div>';
} }
} }
} }
@@ -413,9 +414,9 @@ if (!getDolUserInt('USER_PUBLIC_HIDE_COMPANY', 0, $object)) {
// Social networks // Social networks
if (!empty($mysoc->socialnetworks) && is_array($mysoc->socialnetworks) && count($mysoc->socialnetworks) > 0) { if (!empty($mysoc->socialnetworks) && is_array($mysoc->socialnetworks) && count($mysoc->socialnetworks) > 0) {
if (!getDolUserInt('USER_PUBLIC_HIDE_SOCIALNETWORKS_BUSINESS', 0, $object)) { if (!getDolGlobalInt('USER_PUBLIC_HIDE_SOCIALNETWORKS_BUSINESS', 0)) {
foreach ($mysoc->socialnetworks as $key => $value) { foreach ($mysoc->socialnetworks as $key => $value) {
if ($value) { if (getDolGlobalString('SOCIETE_PUBLIC_SOCIALNETWORKS_'.strtoupper($key))) {
$companysection .= '<div class="flexitemsmall wordbreak">'.dol_print_socialnetworks($value, 0, $mysoc->id, $key, $socialnetworksdict).'</div>'; $companysection .= '<div class="flexitemsmall wordbreak">'.dol_print_socialnetworks($value, 0, $mysoc->id, $key, $socialnetworksdict).'</div>';
} }
} }

View File

@@ -24,6 +24,7 @@
// Load Dolibarr environment // Load Dolibarr environment
require '../main.inc.php'; require '../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/usergroups.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/usergroups.lib.php';
require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php'; require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php';
@@ -70,20 +71,9 @@ $permissiontoedit = ((($object->id == $user->id) && $user->hasRight('user', 'sel
if ($action == 'update' && $permissiontoedit) { if ($action == 'update' && $permissiontoedit) {
$tmparray = array(); $tmparray = array();
$tmparray['USER_PUBLIC_HIDE_PHOTO'] = (GETPOST('USER_PUBLIC_HIDE_PHOTO') ? 1 : 0);
$tmparray['USER_PUBLIC_HIDE_EMAIL'] = (GETPOST('USER_PUBLIC_HIDE_EMAIL') ? 1 : 0);
$tmparray['USER_PUBLIC_HIDE_SOCIALNETWORKS'] = (GETPOST('USER_PUBLIC_HIDE_SOCIALNETWORKS') ? 1 : 0);
$tmparray['USER_PUBLIC_SHOW_BIRTH'] = (GETPOST('USER_PUBLIC_SHOW_BIRTH') ? 1 : 0);
$tmparray['USER_PUBLIC_SHOW_ADDRESS'] = (GETPOST('USER_PUBLIC_SHOW_ADDRESS') ? 1 : 0);
$tmparray['USER_PUBLIC_HIDE_COMPANY'] = (GETPOST('USER_PUBLIC_HIDE_COMPANY') ? 1 : 0);
$tmparray['USER_PUBLIC_HIDE_JOBPOSITION'] = (GETPOST('USER_PUBLIC_HIDE_JOBPOSITION') ? 1 : 0);
$tmparray['USER_PUBLIC_HIDE_OFFICE_PHONE'] = (GETPOST('USER_PUBLIC_HIDE_OFFICE_PHONE') ? 1 : 0);
$tmparray['USER_PUBLIC_HIDE_OFFICE_FAX'] = (GETPOST('USER_PUBLIC_HIDE_OFFICE_FAX') ? 1 : 0);
$tmparray['USER_PUBLIC_HIDE_USER_MOBILE'] = (GETPOST('USER_PUBLIC_HIDE_USER_MOBILE') ? 1 : 0);
$tmparray['USER_PUBLIC_HIDE_SOCIALNETWORKS_BUSINESS'] = (GETPOST('USER_PUBLIC_HIDE_SOCIALNETWORKS_BUSINESS') ? 1 : 0);
$tmparray['USER_PUBLIC_MORE'] = (GETPOST('USER_PUBLIC_MORE') ? GETPOST('USER_PUBLIC_MORE') : ''); $tmparray['USER_PUBLIC_MORE'] = (GETPOST('USER_PUBLIC_MORE') ? GETPOST('USER_PUBLIC_MORE') : '');
dol_set_user_param($db, $conf, $object, $tmparray); dolibarr_set_const($db, 'USER_PUBLIC_MORE', $tmparray['USER_PUBLIC_MORE'], 'chaine', 0, '', $conf->entity);
} }
if ($action == 'setUSER_ENABLE_PUBLIC' && $permissiontoedit) { if ($action == 'setUSER_ENABLE_PUBLIC' && $permissiontoedit) {
@@ -153,6 +143,9 @@ if (getDolUserInt('USER_ENABLE_PUBLIC', 0, $object)) {
$fullexternaleurltovirtualcard = $object->getOnlineVirtualCardUrl('', 'external'); $fullexternaleurltovirtualcard = $object->getOnlineVirtualCardUrl('', 'external');
$fullinternalurltovirtualcard = $object->getOnlineVirtualCardUrl('', 'internal'); $fullinternalurltovirtualcard = $object->getOnlineVirtualCardUrl('', 'internal');
$showUserSocialNetworks = getDolGlobalString('USER_PUBLIC_HIDE_SOCIALNETWORKS');
$showSocieteSocialNetworks = getDolGlobalString('USER_PUBLIC_HIDE_SOCIALNETWORKS_BUSINESS');
print '<div class="urllink">'; print '<div class="urllink">';
print '<input type="text" id="publicurluser" class="quatrevingtpercentminusx" value="'.$fullexternaleurltovirtualcard.'">'; print '<input type="text" id="publicurluser" class="quatrevingtpercentminusx" value="'.$fullexternaleurltovirtualcard.'">';
print '<a target="_blank" rel="noopener noreferrer" href="'.$fullexternaleurltovirtualcard.'">'.img_picto('', 'globe', 'class="paddingleft marginrightonly paddingright"').$langs->trans("GoTo").'...</a>'; print '<a target="_blank" rel="noopener noreferrer" href="'.$fullexternaleurltovirtualcard.'">'.img_picto('', 'globe', 'class="paddingleft marginrightonly paddingright"').$langs->trans("GoTo").'...</a>';
@@ -204,63 +197,85 @@ if (getDolUserInt('USER_ENABLE_PUBLIC', 0, $object)) {
print '<tr class="oddeven" id="tredit"><td>'; print '<tr class="oddeven" id="tredit"><td>';
print $langs->trans("HideOnVCard", $langs->transnoentitiesnoconv("Photo")); print $langs->trans("HideOnVCard", $langs->transnoentitiesnoconv("Photo"));
print '</td><td>'; print '</td><td>';
print $form->selectyesno("USER_PUBLIC_HIDE_PHOTO", (getDolUserInt('USER_PUBLIC_HIDE_PHOTO', 0, $object) ? getDolUserInt('USER_PUBLIC_HIDE_PHOTO', 0, $object) : 0), 1); print ajax_constantonoff("USER_PUBLIC_HIDE_PHOTO", array(), null, 0, 0, 0);
print "</td></tr>\n"; print "</td></tr>\n";
// Job position // Job position
print '<tr class="oddeven" id="tredit"><td>'; print '<tr class="oddeven" id="tredit"><td>';
print $langs->trans("HideOnVCard", $langs->transnoentitiesnoconv("PostOrFunction")); print $langs->trans("HideOnVCard", $langs->transnoentitiesnoconv("PostOrFunction"));
print '</td><td>'; print '</td><td>';
print $form->selectyesno("USER_PUBLIC_HIDE_JOBPOSITION", (getDolUserInt('USER_PUBLIC_HIDE_JOBPOSITION', 0, $object) ? getDolUserInt('USER_PUBLIC_HIDE_JOBPOSITION', 0, $object) : 0), 1); print ajax_constantonoff("USER_PUBLIC_HIDE_JOBPOSITION");
print "</td></tr>\n"; print "</td></tr>\n";
// Email // Email
print '<tr class="oddeven" id="tredit"><td>'; print '<tr class="oddeven" id="tredit"><td>';
print $langs->trans("HideOnVCard", $langs->transnoentitiesnoconv("Email")); print $langs->trans("HideOnVCard", $langs->transnoentitiesnoconv("Email"));
print '</td><td>'; print '</td><td>';
print $form->selectyesno("USER_PUBLIC_HIDE_EMAIL", (getDolUserInt('USER_PUBLIC_HIDE_EMAIL', 0, $object) ? getDolUserInt('USER_PUBLIC_HIDE_EMAIL', 0, $object) : 0), 1); print ajax_constantonoff("USER_PUBLIC_HIDE_EMAIL");
print "</td></tr>\n"; print "</td></tr>\n";
// Office phone // Office phone
print '<tr class="oddeven" id="tredit"><td>'; print '<tr class="oddeven" id="tredit"><td>';
print $langs->trans("HideOnVCard", $langs->transnoentitiesnoconv("PhonePro")); print $langs->trans("HideOnVCard", $langs->transnoentitiesnoconv("PhonePro"));
print '</td><td>'; print '</td><td>';
print $form->selectyesno("USER_PUBLIC_HIDE_OFFICE_PHONE", (getDolUserInt('USER_PUBLIC_HIDE_OFFICE_PHONE', 0, $object) ? getDolUserInt('USER_PUBLIC_HIDE_OFFICE_PHONE', 0, $object) : 0), 1); print ajax_constantonoff("USER_PUBLIC_HIDE_OFFICE_PHONE");
print "</td></tr>\n"; print "</td></tr>\n";
// Office fax // Office fax
print '<tr class="oddeven" id="tredit"><td>'; print '<tr class="oddeven" id="tredit"><td>';
print $langs->trans("HideOnVCard", $langs->transnoentitiesnoconv("Fax")); print $langs->trans("HideOnVCard", $langs->transnoentitiesnoconv("Fax"));
print '</td><td>'; print '</td><td>';
print $form->selectyesno("USER_PUBLIC_HIDE_OFFICE_FAX", (getDolUserInt('USER_PUBLIC_HIDE_OFFICE_FAX', 0, $object) ? getDolUserInt('USER_PUBLIC_HIDE_OFFICE_FAX', 0, $object) : 0), 1); print ajax_constantonoff("USER_PUBLIC_HIDE_OFFICE_FAX");
print "</td></tr>\n"; print "</td></tr>\n";
// User mobile // User mobile
print '<tr class="oddeven" id="tredit"><td>'; print '<tr class="oddeven" id="tredit"><td>';
print $langs->trans("HideOnVCard", $langs->transnoentitiesnoconv("PhoneMobile")); print $langs->trans("HideOnVCard", $langs->transnoentitiesnoconv("PhoneMobile"));
print '</td><td>'; print '</td><td>';
print $form->selectyesno("USER_PUBLIC_HIDE_USER_MOBILE", (getDolUserInt('USER_PUBLIC_HIDE_USER_MOBILE', 0, $object) ? getDolUserInt('USER_PUBLIC_HIDE_USER_MOBILE', 0, $object) : 0), 1); print ajax_constantonoff("USER_PUBLIC_HIDE_USER_MOBILE");
print "</td></tr>\n"; print "</td></tr>\n";
// Social networks // Social networks
print '<tr class="oddeven" id="tredit"><td>'; print '<tr class="oddeven" id="tredit"><td>';
print $langs->trans("HideOnVCard", $langs->transnoentitiesnoconv("SocialNetworksInformation")); print $langs->trans("HideOnVCard", $langs->transnoentitiesnoconv("SocialNetworksInformation"));
print '</td><td>'; print '</td><td>';
print $form->selectyesno("USER_PUBLIC_HIDE_SOCIALNETWORKS", (getDolUserInt('USER_PUBLIC_HIDE_SOCIALNETWORKS', 0, $object) ? getDolUserInt('USER_PUBLIC_HIDE_SOCIALNETWORKS', 0, $object) : 0), 1); print ajax_constantonoff("USER_PUBLIC_HIDE_SOCIALNETWORKS", array(), null, 0, 0, 1);
print "</td></tr>\n"; print "</td></tr>\n";
//Show list of socialnetworks for user
if (empty($showUserSocialNetworks)) {
print '<tr class="liste_titre" id="tramount">';
print '<td>'.$langs->trans("SocialNetworksUser").'</td>';
print '<td></td>';
print "</tr>\n";
$socialnetworks = $object->socialnetworks;
if (!empty($socialnetworks)) {
foreach ($socialnetworks as $key => $networkVal) {
print '<tr class="oddeven">';
print '<td>'.dol_escape_htmltag($key).'</td><td>';
print ajax_constantonoff('USER_SOCIALNETWORK_'.strtoupper($key));
print '</td>';
print "</tr>";
}
}
print '<tr class="liste_titre" id="tramount">';
print '<td></td>';
print '<td></td>';
print "</tr>\n";
}
// Birth date // Birth date
print '<tr class="oddeven" id="tredit"><td>'; print '<tr class="oddeven" id="tredit"><td>';
print $langs->trans("ShowOnVCard", $langs->transnoentitiesnoconv("Birthdate")); print $langs->trans("ShowOnVCard", $langs->transnoentitiesnoconv("Birthdate"));
print '</td><td>'; print '</td><td>';
print $form->selectyesno("USER_PUBLIC_SHOW_BIRTH", (getDolUserInt('USER_PUBLIC_SHOW_BIRTH', 0, $object) ? getDolUserInt('USER_PUBLIC_SHOW_BIRTH', 0, $object) : 0), 1); print ajax_constantonoff("USER_PUBLIC_SHOW_BIRTH");
print "</td></tr>\n"; print "</td></tr>\n";
// Address // Address
print '<tr class="oddeven" id="tredit"><td>'; print '<tr class="oddeven" id="tredit"><td>';
print $langs->trans("ShowOnVCard", $langs->transnoentitiesnoconv("Address")); print $langs->trans("ShowOnVCard", $langs->transnoentitiesnoconv("Address"));
print '</td><td>'; print '</td><td>';
print $form->selectyesno("USER_PUBLIC_SHOW_ADDRESS", (getDolUserInt('USER_PUBLIC_SHOW_ADDRESS', 0, $object) ? getDolUserInt('USER_PUBLIC_SHOW_ADDRESS', 0, $object) : 0), 1); print ajax_constantonoff("USER_PUBLIC_SHOW_ADDRESS");
print "</td></tr>\n"; print "</td></tr>\n";
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
@@ -272,16 +287,35 @@ if (getDolUserInt('USER_ENABLE_PUBLIC', 0, $object)) {
print '<tr class="oddeven" id="tramount"><td>'; print '<tr class="oddeven" id="tramount"><td>';
print $langs->trans("HideOnVCard", $langs->transnoentitiesnoconv("CompanySection")); print $langs->trans("HideOnVCard", $langs->transnoentitiesnoconv("CompanySection"));
print '</td><td>'; print '</td><td>';
print $form->selectyesno("USER_PUBLIC_HIDE_COMPANY", (getDolUserInt('USER_PUBLIC_HIDE_COMPANY', 0, $object) ? getDolUserInt('USER_PUBLIC_HIDE_COMPANY', 0, $object) : 0), 1); print ajax_constantonoff("USER_PUBLIC_HIDE_COMPANY");
print "</td></tr>\n"; print "</td></tr>\n";
// Social networks // Social networks
print '<tr class="oddeven" id="tredit"><td>'; print '<tr class="oddeven" id="tredit"><td>';
print $langs->trans("HideOnVCard", $langs->transnoentitiesnoconv("SocialNetworksInformation")); print $langs->trans("HideOnVCard", $langs->transnoentitiesnoconv("SocialNetworksInformation"));
print '</td><td>'; print '</td><td>';
print $form->selectyesno("USER_PUBLIC_HIDE_SOCIALNETWORKS_BUSINESS", (getDolUserInt('USER_PUBLIC_HIDE_SOCIALNETWORKS_BUSINESS', 0, $object) ? getDolUserInt('USER_PUBLIC_HIDE_SOCIALNETWORKS_BUSINESS', 0, $object) : 0), 1); print ajax_constantonoff("USER_PUBLIC_HIDE_SOCIALNETWORKS_BUSINESS", array(), null, 0, 0, 1);
print "</td></tr>\n"; print "</td></tr>\n";
// show list of social networks for company
if (empty($showSocieteSocialNetworks)) {
print '<tr class="liste_titre" id="tramount">';
print '<td>'.$langs->trans("SocialNetworksBusiness").'</td>';
print '<td></td>';
print "</tr>\n";
$listofnetworks = $mysoc->socialnetworks;
if (!empty($listofnetworks)) {
foreach ($listofnetworks as $key => $networkVal) {
print '<tr class="oddeven">';
print '<td>'.dol_escape_htmltag($key).'</td><td>';
print ajax_constantonoff('SOCIETE_PUBLIC_SOCIALNETWORKS_'.strtoupper($key));
print '</td>';
print "</tr>";
}
}
}
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
print '<td>'.$langs->trans("Other").'</td>'; print '<td>'.$langs->trans("Other").'</td>';