Clean code

This commit is contained in:
Laurent Destailleur 2024-08-13 13:05:38 +02:00
parent d92e50fc66
commit eef5cea575
5 changed files with 23 additions and 25 deletions

View file

@ -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 '<td>'.$langs->trans("Example").'</td>';
print '</tr>';
print '<tr class="oddeven">';
print '<td width="100">'.$langs->trans("Title").'</td>';
print '<td>'.$langs->trans("Title").'</td>';
print '<td><input type="text" class="flat minwidth300" name="socialnetwork_name"></td>';
print '<td>'.$langs->trans('Example').'</td>';
print '<td>Mastodon</td>';
print '</tr>';
print '<tr class="oddeven">';
print '<td>'.$langs->trans('SocialNetworkUrl').'</td>';
print '<td><input type="text" class="flat minwidth300" name="socialnetwork_url"></td>';
print '<td>https://twitter.social<br>http://www.dolibarr.org/</td>';
print '<td>https://mastodon.social/api/v1/accounts/id_user</td>';
print '</tr>';
print '</table>';
@ -226,33 +231,29 @@ if ($resql) {
print "<br>";
print '<form action="'.$_SERVER["PHP_SELF"].'" method="post">'."\n";
print '<input type="hidden" name="token" value="'.newToken().'">'."\n";
print '<table class="noborder centpercent">'."\n";
print '<input type="hidden" name="token" value="'.newToken().'">'."\n";
print '<tr class="liste_titre">';
print "<td>".$langs->trans("SocialNetworks")." ".($i+1)."</td>";
print '<td class="right">';
print '<a class="viewfielda reposition marginleftonly marginrighttonly showInputBtn" href="'.$_SERVER["PHP_SELF"].'?action=editsocialnetwork&token='.newToken().'&key='.urlencode($key).'">'.img_edit().'</a>';
print '<a class="deletefielda reposition marginleftonly right" href="'.$_SERVER["PHP_SELF"].'?action=deletesocialnetwork&token='.newToken().'&key='.urlencode($key).'">'.img_delete().'</a>';
print '<input type="hidden" name="id" value="'.$key.'">';
print '</td>';
print '</tr>'."\n";
print '<tr class="oddeven">';
print '<td class="titlefield">'.$langs->trans("Title")."</td>";
print '<td>'.$langs->trans("Title")."</td>";
print '<td><input type="text" class="flat minwidth300" name="socialnetwork_name" value="'.dol_escape_htmltag($socialNetworkTitle).'" '.($action != "editsocialnetwork" ? 'disabled' : '').'></td>';
print '</tr>'."\n";
print '<tr class="oddeven">';
print "<td>".$langs->trans("URL")."</td>";
print '<td><input type="text" class="flat minwidth300" name="socialnetwork_url" value="'.dol_escape_htmltag($socialNetworkUrl).'" '.($action != "editsocialnetwork" ? 'disabled' : '').'></td>';
print '</tr>'."\n";
print '<tr class="oddeven">';
print "<td>".$langs->trans("Status")."</td>";
print "<td>";

View file

@ -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;

View file

@ -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

View file

@ -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);

View file

@ -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
MenuDict=Dictionary