From 621f246d589c0fedaa3eac3c24e19e234e7b934d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sat, 12 Dec 2020 18:26:54 +0100 Subject: [PATCH 1/3] my company social networks in a separate tab --- htdocs/admin/company.php | 26 ----- htdocs/admin/company_socialnetworks.php | 142 ++++++++++++++++++++++++ htdocs/core/lib/admin.lib.php | 5 + 3 files changed, 147 insertions(+), 26 deletions(-) create mode 100644 htdocs/admin/company_socialnetworks.php diff --git a/htdocs/admin/company.php b/htdocs/admin/company.php index da955a67ea4..d5892bc35ab 100644 --- a/htdocs/admin/company.php +++ b/htdocs/admin/company.php @@ -178,13 +178,6 @@ if (($action == 'update' && !GETPOST("cancel", 'alpha')) } } - dolibarr_set_const($db, "MAIN_INFO_SOCIETE_FACEBOOK_URL", GETPOST("facebookurl", 'alpha'), 'chaine', 0, '', $conf->entity); - dolibarr_set_const($db, "MAIN_INFO_SOCIETE_TWITTER_URL", GETPOST("twitterurl", 'alpha'), 'chaine', 0, '', $conf->entity); - dolibarr_set_const($db, "MAIN_INFO_SOCIETE_LINKEDIN_URL", GETPOST("linkedinurl", 'alpha'), 'chaine', 0, '', $conf->entity); - dolibarr_set_const($db, "MAIN_INFO_SOCIETE_INSTAGRAM_URL", GETPOST("instagramurl", 'alpha'), 'chaine', 0, '', $conf->entity); - dolibarr_set_const($db, "MAIN_INFO_SOCIETE_YOUTUBE_URL", GETPOST("youtubeurl", 'alpha'), 'chaine', 0, '', $conf->entity); - dolibarr_set_const($db, "MAIN_INFO_SOCIETE_GITHUB_URL", GETPOST("githuburl", 'alpha'), 'chaine', 0, '', $conf->entity); - dolibarr_set_const($db, "MAIN_INFO_SOCIETE_MANAGERS", GETPOST("MAIN_INFO_SOCIETE_MANAGERS", 'nohtml'), 'chaine', 0, '', $conf->entity); dolibarr_set_const($db, "MAIN_INFO_GDPR", GETPOST("MAIN_INFO_GDPR", 'nohtml'), 'chaine', 0, '', $conf->entity); dolibarr_set_const($db, "MAIN_INFO_CAPITAL", GETPOST("capital", 'nohtml'), 'chaine', 0, '', $conf->entity); @@ -546,25 +539,6 @@ print ''; print ''; -// Social networks -print '
'; -print ''; -print ''; -print ''; -print "\n"; - -$listofnetworks = array('facebook'=>'facebook', 'twitter'=>'twitter', 'linkedin'=>'linkedin', 'instagram'=>'instagram', 'youtube'=>'youtube', 'github'=>'github'); -foreach ($listofnetworks as $networkkey => $networkicon) { - print ''; - print ''."\n"; -} - -print "
'.$langs->trans("SocialNetworksInformation").''.$langs->trans("Value").'
'; - print ''; - $networkconst = 'MAIN_INFO_SOCIETE_'.strtoupper($networkkey).'_URL'; - print ''; - print '
"; - print '
'; // IDs of the company (country-specific) diff --git a/htdocs/admin/company_socialnetworks.php b/htdocs/admin/company_socialnetworks.php new file mode 100644 index 00000000000..ec244d77ffd --- /dev/null +++ b/htdocs/admin/company_socialnetworks.php @@ -0,0 +1,142 @@ + + * Copyright (C) 2004-2019 Laurent Destailleur + * Copyright (C) 2005-2017 Regis Houssin + * Copyright (C) 2010-2014 Juanjo Menent + * Copyright (C) 2011-2017 Philippe Grand + * Copyright (C) 2015 Alexandre Spangaro + * Copyright (C) 2017 Rui Strecht + * Copyright (C) 2020 Frédéric France + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/** + * \file htdocs/admin/company_socialnetworks.php + * \ingroup company + * \brief Setup page to configure company social networks + */ + +require '../main.inc.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/images.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; + +$action = GETPOST('action', 'aZ09'); +$contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'admincompany'; // To manage different context of search + +// Load translation files required by the page +$langs->loadLangs(array('admin', 'companies', 'bills')); + +if (!$user->admin) accessforbidden(); + +// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context +$hookmanager->initHooks(array('adminsocialnetworkscompany', 'globaladmin')); + +/* + * Actions + */ + +$parameters = array(); +$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 (($action == 'update' && !GETPOST("cancel", 'alpha')) || ($action == 'updateedit')) { + dolibarr_set_const($db, "MAIN_INFO_SOCIETE_FACEBOOK_URL", GETPOST("facebookurl", 'alpha'), 'chaine', 0, '', $conf->entity); + dolibarr_set_const($db, "MAIN_INFO_SOCIETE_TWITTER_URL", GETPOST("twitterurl", 'alpha'), 'chaine', 0, '', $conf->entity); + dolibarr_set_const($db, "MAIN_INFO_SOCIETE_LINKEDIN_URL", GETPOST("linkedinurl", 'alpha'), 'chaine', 0, '', $conf->entity); + dolibarr_set_const($db, "MAIN_INFO_SOCIETE_INSTAGRAM_URL", GETPOST("instagramurl", 'alpha'), 'chaine', 0, '', $conf->entity); + dolibarr_set_const($db, "MAIN_INFO_SOCIETE_YOUTUBE_URL", GETPOST("youtubeurl", 'alpha'), 'chaine', 0, '', $conf->entity); + dolibarr_set_const($db, "MAIN_INFO_SOCIETE_GITHUB_URL", GETPOST("githuburl", 'alpha'), 'chaine', 0, '', $conf->entity); + + if ($action != 'updateedit' && !$error) { + header("Location: ".$_SERVER["PHP_SELF"]); + exit; + } +} + + +/* + * View + */ + +$wikihelp = 'EN:First_setup|FR:Premiers_paramétrages|ES:Primeras_configuraciones'; +llxHeader('', $langs->trans("Setup"), $wikihelp); + +$form = new Form($db); +$formother = new FormOther($db); +$formcompany = new FormCompany($db); + +print load_fiche_titre($langs->trans("CompanyFoundation"), '', 'title_setup'); + +$head = company_admin_prepare_head(); + +print dol_get_fiche_head($head, 'socialnetworks', $langs->trans("SocialNetworksInformation"), -1, 'company'); + +print ''.$langs->trans("CompanyFundationDesc", $langs->transnoentities("Save"))."
\n"; +print "
\n"; + + +/** + * Edit parameters + */ + +print '
'; +print ''; +print ''; + +// Social networks +print '
'; +print ''; +print ''; +print ''; +print "\n"; + +$listofnetworks = array( + 'facebook'=>'facebook', + 'twitter'=>'twitter', + 'linkedin'=>'linkedin', + 'instagram'=>'instagram', + 'youtube'=>'youtube', + 'github'=>'github' +); + +foreach ($listofnetworks as $networkkey => $networkicon) { + print ''; + print ''."\n"; +} + +print "
'.$langs->trans("SocialNetworksInformation").''.$langs->trans("Value").'
'; + print ''; + $networkconst = 'MAIN_INFO_SOCIETE_'.strtoupper($networkkey).'_URL'; + print ''; + print '
"; + +print '
'; + +print '
'; +print ''; +print '
'; + +print '
'; + + +// End of page +llxFooter(); +$db->close(); diff --git a/htdocs/core/lib/admin.lib.php b/htdocs/core/lib/admin.lib.php index 704a4496d03..13f59c45ba8 100644 --- a/htdocs/core/lib/admin.lib.php +++ b/htdocs/core/lib/admin.lib.php @@ -1819,6 +1819,11 @@ function company_admin_prepare_head() $head[$h][2] = 'accountant'; $h++; + $head[$h][0] = DOL_URL_ROOT."/admin/company_socialnetworks.php"; + $head[$h][1] = $langs->trans("SocialNetworksInformation"); + $head[$h][2] = 'socialnetworks'; + $h++; + complete_head_from_modules($conf, $langs, null, $head, $h, 'mycompany_admin', 'add'); complete_head_from_modules($conf, $langs, null, $head, $h, 'mycompany_admin', 'remove'); From b8a01b4d2d46bdcdf90c55fcb854eedeb5ed8e0b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sat, 12 Dec 2020 18:31:26 +0100 Subject: [PATCH 2/3] my company social networks in a separate tab --- htdocs/admin/company.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/htdocs/admin/company.php b/htdocs/admin/company.php index d5892bc35ab..b82f0fcd765 100644 --- a/htdocs/admin/company.php +++ b/htdocs/admin/company.php @@ -685,7 +685,7 @@ print ' '; print "\n"; // Main tax -print ""; +print '"; print ''; $tooltiphelp = ''; if ($mysoc->country_code == 'FR') $tooltiphelp = ''.$langs->trans("Example").': '.$langs->trans("VATIsUsedExampleFR").""; @@ -693,7 +693,7 @@ print "