From eef5cea5750f69af880e6182c6fb3e96785fcecd Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 13 Aug 2024 13:05:38 +0200 Subject: [PATCH] Clean code --- htdocs/admin/fediverse.php | 21 ++++++++++--------- htdocs/core/lib/socialnetwork.lib.php | 10 ++++----- .../core/modules/modSocialNetworks.class.php | 4 +--- .../mysql/data/llx_c_socialnetworks.sql | 3 +-- htdocs/langs/en_US/admin.lang | 10 ++++----- 5 files changed, 23 insertions(+), 25 deletions(-) diff --git a/htdocs/admin/fediverse.php b/htdocs/admin/fediverse.php index 7285701d94e..e69b5833f23 100644 --- a/htdocs/admin/fediverse.php +++ b/htdocs/admin/fediverse.php @@ -46,15 +46,19 @@ $langs->loadLangs(array('admin', 'users', 'dict')); $action = GETPOST('action', 'aZ09'); -//Security check +// Security check if (!$user->admin) { accessforbidden(); } +if (!isModEnabled('socialnetworks')) { + accessforbidden('Module Social Networks is not enabled'); +} /* * Actions */ + if ($action == 'add') { $error = 0; @@ -134,6 +138,7 @@ if ($action == 'confirm_delete' && GETPOST('confirm') == 'yes') { /* * View */ + $form = new Form($db); llxHeader('', $langs->trans("FediverseSetup"), '', '', 0, 0, '', '', '', 'mod-admin page-dict'); @@ -160,15 +165,15 @@ print ''.$langs->trans("Example").''; print ''; print ''; -print ''.$langs->trans("Title").''; +print ''.$langs->trans("Title").''; print ''; -print ''.$langs->trans('Example').''; +print 'Mastodon'; print ''; print ''; print ''.$langs->trans('SocialNetworkUrl').''; print ''; -print 'https://twitter.social
http://www.dolibarr.org/'; +print 'https://mastodon.social/api/v1/accounts/id_user'; print ''; print ''; @@ -226,33 +231,29 @@ if ($resql) { print "
"; print '
'."\n"; + print ''."\n"; print ''."\n"; - print ''."\n"; print ''; print ""; print ''; print ''."\n"; - print ''; - print '"; + print '"; print ''; print ''."\n"; - print ''; print ""; print ''; print ''."\n"; - print ''; print ""; print "
".$langs->trans("SocialNetworks")." ".($i+1)."'; print ''.img_edit().''; print ''.img_delete().''; - print ''; print '
'.$langs->trans("Title")."'.$langs->trans("Title")."
".$langs->trans("URL")."
".$langs->trans("Status").""; diff --git a/htdocs/core/lib/socialnetwork.lib.php b/htdocs/core/lib/socialnetwork.lib.php index 20d5cada6fa..ac1a28d0538 100644 --- a/htdocs/core/lib/socialnetwork.lib.php +++ b/htdocs/core/lib/socialnetwork.lib.php @@ -31,16 +31,16 @@ function socialnetwork_prepare_head() $h = 0; $head = array(); - $head[$h][0] = DOL_URL_ROOT.'/admin/fediverse.php'; - $head[$h][1] = $langs->trans("Fediverse"); - $head[$h][2] = 'divers'; - $h++; - $head[$h][0] = DOL_URL_ROOT.'/admin/dict.php?id=38'; $head[$h][1] = $langs->trans("Dictionary").' - '.$langs->trans("SocialNetworks"); $head[$h][2] = 'dict'; $h++; + $head[$h][0] = DOL_URL_ROOT.'/admin/fediverse.php'; + $head[$h][1] = $langs->trans("Fediverse"); + $head[$h][2] = 'divers'; + $h++; + complete_head_from_modules($conf, $langs, null, $head, $h, 'socialnetwork', 'add', 'external'); complete_head_from_modules($conf, $langs, null, $head, $h, 'socialnetwork', 'remove'); return $head; diff --git a/htdocs/core/modules/modSocialNetworks.class.php b/htdocs/core/modules/modSocialNetworks.class.php index 0ad95e9113a..ff6e42f1bb4 100644 --- a/htdocs/core/modules/modSocialNetworks.class.php +++ b/htdocs/core/modules/modSocialNetworks.class.php @@ -37,8 +37,6 @@ class modSocialNetworks extends DolibarrModules */ public function __construct($db) { - global $langs, $conf; - $this->db = $db; $this->numero = 3400; @@ -61,7 +59,7 @@ class modSocialNetworks extends DolibarrModules $this->dirs = array(); // Config pages - $this->config_page_url = array(DOL_URL_ROOT.'/admin/fediverse.php'); + $this->config_page_url = array(DOL_URL_ROOT.'/admin/dict.php?id=38'); // Dependencies $this->hidden = getDolGlobalInt('MODULE_SOCIALNETWORKS_DISABLED'); // A condition to hide module diff --git a/htdocs/install/mysql/data/llx_c_socialnetworks.sql b/htdocs/install/mysql/data/llx_c_socialnetworks.sql index a7eae8b3996..f581eb6322c 100644 --- a/htdocs/install/mysql/data/llx_c_socialnetworks.sql +++ b/htdocs/install/mysql/data/llx_c_socialnetworks.sql @@ -37,7 +37,6 @@ INSERT INTO llx_c_socialnetworks (entity, code, label, url, icon, active) VALUES INSERT INTO llx_c_socialnetworks (entity, code, label, url, icon, active) VALUES ( 1, 'gifycat', 'Gificat', '{socialid}', '', 0); INSERT INTO llx_c_socialnetworks (entity, code, label, url, icon, active) VALUES ( 1, 'giphy', 'Giphy', '{socialid}', '', 0); INSERT INTO llx_c_socialnetworks (entity, code, label, url, icon, active) VALUES ( 1, 'github', 'GitHub', 'https://www.github.com/{socialid}', '', 0); -INSERT INTO llx_c_socialnetworks (entity, code, label, url, icon, active) VALUES ( 1, 'googleplus', 'GooglePlus', 'https://www.googleplus.com/{socialid}', 'fa-google-plus', 0); INSERT INTO llx_c_socialnetworks (entity, code, label, url, icon, active) VALUES ( 1, 'instagram', 'Instagram', 'https://www.instagram.com/{socialid}', 'fa-instagram', 1); INSERT INTO llx_c_socialnetworks (entity, code, label, url, icon, active) VALUES ( 1, 'linkedin', 'LinkedIn', 'https://www.linkedin.com/in/{socialid}', 'fa-linkedin', 1); INSERT INTO llx_c_socialnetworks (entity, code, label, url, icon, active) VALUES ( 1, 'mastodon', 'Mastodon', '{socialid}', '', 0); @@ -52,7 +51,7 @@ INSERT INTO llx_c_socialnetworks (entity, code, label, url, icon, active) VALUES INSERT INTO llx_c_socialnetworks (entity, code, label, url, icon, active) VALUES ( 1, 'tripadvisor', 'Tripadvisor', '{socialid}', '', 0); INSERT INTO llx_c_socialnetworks (entity, code, label, url, icon, active) VALUES ( 1, 'tumblr', 'Tumblr', 'https://www.tumblr.com/{socialid}', 'fa-tumblr', 0); INSERT INTO llx_c_socialnetworks (entity, code, label, url, icon, active) VALUES ( 1, 'twitch', 'Twitch', '{socialid}', '', 0); -INSERT INTO llx_c_socialnetworks (entity, code, label, url, icon, active) VALUES ( 1, 'twitter', 'Twitter', 'https://www.twitter.com/{socialid}', 'fa-twitter', 1); +INSERT INTO llx_c_socialnetworks (entity, code, label, url, icon, active) VALUES ( 1, 'twitter', 'X-Twitter', 'https://www.x.com/{socialid}', 'fa-twitter', 1); INSERT INTO llx_c_socialnetworks (entity, code, label, url, icon, active) VALUES ( 1, 'vero', 'Vero', 'https://vero.co/{socialid}', '', 0); INSERT INTO llx_c_socialnetworks (entity, code, label, url, icon, active) VALUES ( 1, 'viadeo', 'Viadeo', 'https://fr.viadeo.com/fr/{socialid}', 'fa-viadeo', 0); INSERT INTO llx_c_socialnetworks (entity, code, label, url, icon, active) VALUES ( 1, 'viber', 'Viber', '{socialid}', '', 0); diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index 9a9b1f79099..dbbf3e18d04 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -2126,7 +2126,7 @@ MAIN_DOCUMENTS_WITH_PICTURE_WIDTH=Width of the column if a picture is added on l MAIN_GENERATE_DOCUMENTS_SUPPLIER_PROPOSAL_WITHOUT_UNIT_PRICE=Hide the unit price column on quotation requests MAIN_GENERATE_DOCUMENTS_SUPPLIER_PROPOSAL_WITHOUT_TOTAL_COLUMN=Hide the total price column on quotation requests MAIN_GENERATE_DOCUMENTS_PURCHASE_ORDER_WITHOUT_UNIT_PRICE=Hide the unit price column on purchase orders -MAIN_GENERATE_DOCUMENTS_PURCHASE_ORDER_WITHOUT_TOTAL_COLUMN=Hide the total price column on puchase orders +MAIN_GENERATE_DOCUMENTS_PURCHASE_ORDER_WITHOUT_TOTAL_COLUMN=Hide the total price column on purchase orders MAIN_PDF_NO_SENDER_FRAME=Hide borders on sender address frame MAIN_PDF_NO_RECIPENT_FRAME=Hide borders on recipient address frame MAIN_PDF_HIDE_CUSTOMER_CODE=Hide customer code @@ -2540,12 +2540,12 @@ MainAuthenticationOidcLoginClaimDesc=OpenID Connect claim matching the Dolibarr BlackListWords=Black list of words AddBlackList=Add to black list FediverseSetup=Configuration of fediverse section -ConfigImportSocialNetwork=Configuration import social networks +ConfigImportSocialNetwork=Configuration of social networks compatible with Fediverse Fediverse=Fediverse -NewSocialNetwork=New social network -SocialNetworkUrl= URL +NewSocialNetwork=New Fediverse social network +SocialNetworkUrl=Fediverse API URL SocialNetworksNote=Each social network definition provides a widget that you must enable to have it available in dashboard ConfirmDeleteSocialNetwork= Are you sure want to delete this record ? AnOwnerMustBeSetIfEmailTemplateIsPrivate=An owner must be set if the email template is set as private ContactsDefaultRoles=For third parties of the "individual" type, a contact can be created simultaneously. Define here the roles that will be systematically assigned to this contact. -MenuDict=Dictionary \ No newline at end of file +MenuDict=Dictionary