Work on module social network

This commit is contained in:
Laurent Destailleur 2018-09-19 01:45:56 +02:00
parent 2ec02afa8b
commit d35687c8b3
4 changed files with 173 additions and 11 deletions

View File

@ -8,6 +8,7 @@ For Users:
NEW: Stable module: Website NEW: Stable module: Website
NEW: Stable module: WebDAV NEW: Stable module: WebDAV
NEW: Stable module: Module Builder NEW: Stable module: Module Builder
NEW: Stable module "Skype" has been replaced with module "Social Networks" to support more tools.
NEW: Dolibarr can provide information in page title when multicompany is enabled of not, making NEW: Dolibarr can provide information in page title when multicompany is enabled of not, making
Android application like DoliDroid able to provide native features for multicompany module. Android application like DoliDroid able to provide native features for multicompany module.

View File

@ -0,0 +1,123 @@
<?php
/* Copyright (C) 2018 Laurent Destailleur <eldy@users.sourceforge.net>
*
* 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 <http://www.gnu.org/licenses/>.
*/
/**
* \file htdocs/admin/socialnetworks.php
* \ingroup socialnetworks
* \brief Page to setup the module Social Networks
*/
require '../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/mailmanspip.lib.php';
require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
// Load translation files required by the page
$langs->loadLangs(array("admin", "errors"));
if (! $user->admin) accessforbidden();
$type=array('yesno','texte','chaine');
$action = GETPOST('action','aZ09');
/*
* Actions
*/
// Action activation d'un sous module du module adherent
if ($action == 'set')
{
$result=dolibarr_set_const($db, $_GET["name"], $_GET["value"], '', 0, '', $conf->entity);
if ($result < 0)
{
dol_print_error($db);
}
}
// Action desactivation d'un sous module du module adherent
if ($action == 'unset')
{
$result=dolibarr_del_const($db, $_GET["name"], $conf->entity);
if ($result < 0)
{
dol_print_error($db);
}
}
/*
* View
*/
$help_url='';
llxHeader('',$langs->trans("SocialNetworkSetup"),$help_url);
$linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>';
print load_fiche_titre($langs->trans("SocialNetworkSetup"),$linkback,'title_setup');
//$head = socialnetworks_admin_prepare_head();
$h=0;
$head = array();
$head[$h][0] = DOL_URL_ROOT.'/admin/socialnetworks.php';
$head[$h][1] = $langs->trans("Setup");
$head[$h][2] = 'setup';
$h++;
print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
dol_fiche_head($head, 'setup', '', 0, 'user');
print '<br>';
$arrayofsocialnetworks=array('skype'=>'Skype', 'twitter'=>'Twitter', 'facebook'=>'Facebook');
foreach($arrayofsocialnetworks as $snkey => $snlabel)
{
$consttocheck = 'SOCIALNETWORKS_'.strtoupper($snkey);
if (! empty($conf->global->$consttocheck))
{
//$link=img_picto($langs->trans("Active"),'tick').' ';
$link='<a href="'.$_SERVER["PHP_SELF"].'?action=unset&value=0&name='.$consttocheck.'">';
//$link.=$langs->trans("Disable");
$link.=img_picto($langs->trans("Activated"),'switch_on');
$link.='</a>';
}
else
{
$link='<a href="'.$_SERVER["PHP_SELF"].'?action=set&value=1&name='.$consttocheck.'">';
//$link.=img_$langs->trans("Activate")
$link.=img_picto($langs->trans("Disabled"),'switch_off');
$link.='</a>';
}
print $langs->trans('EnableFeatureFor', $snlabel).' '.$link.'<br><br>';
}
dol_fiche_end();
print '</form>';
// End of page
llxFooter();
$db->close();

View File

@ -1804,6 +1804,8 @@ HelpOnTooltip=Help text to show on tooltip
HelpOnTooltipDesc=Put here a text or a translation key for a text to show on a tooltip when this field appears into a form HelpOnTooltipDesc=Put here a text or a translation key for a text to show on a tooltip when this field appears into a form
YouCanDeleteFileOnServerWith=You can delete this file on server with Command Line:<br>%s YouCanDeleteFileOnServerWith=You can delete this file on server with Command Line:<br>%s
ChartLoaded=Chart of account loaded ChartLoaded=Chart of account loaded
SocialNetworkSetup=Setup of module Social Networks
EnableFeatureFor=Enable features for <strong>%s</strong>
##### Resource #### ##### Resource ####
ResourceSetup=Configuration du module Resource ResourceSetup=Configuration du module Resource
UseSearchToSelectResource=Use a search form to choose a resource (rather than a drop-down list). UseSearchToSelectResource=Use a search form to choose a resource (rather than a drop-down list).

View File

@ -145,7 +145,7 @@ if (empty($reshook))
$object->client = $object->client | $soc_origin->client; $object->client = $object->client | $soc_origin->client;
$object->fournisseur = $object->fournisseur | $soc_origin->fournisseur; $object->fournisseur = $object->fournisseur | $soc_origin->fournisseur;
$listofproperties=array( $listofproperties=array(
'address', 'zip', 'town', 'state_id', 'country_id', 'phone', 'phone_pro', 'fax', 'email', 'skype', 'url', 'barcode', 'address', 'zip', 'town', 'state_id', 'country_id', 'phone', 'phone_pro', 'fax', 'email', 'skype', 'twitter', 'facebook', 'url', 'barcode',
'idprof1', 'idprof2', 'idprof3', 'idprof4', 'idprof5', 'idprof6', 'idprof1', 'idprof2', 'idprof3', 'idprof4', 'idprof5', 'idprof6',
'tva_intra', 'effectif_id', 'forme_juridique', 'remise_percent', 'remise_supplier_percent', 'mode_reglement_supplier_id', 'cond_reglement_supplier_id', 'name_bis', 'tva_intra', 'effectif_id', 'forme_juridique', 'remise_percent', 'remise_supplier_percent', 'mode_reglement_supplier_id', 'cond_reglement_supplier_id', 'name_bis',
'stcomm_id', 'outstanding_limit', 'price_level', 'parent', 'default_lang', 'ref', 'ref_ext', 'import_key', 'fk_incoterms', 'fk_multicurrency', 'stcomm_id', 'outstanding_limit', 'price_level', 'parent', 'default_lang', 'ref', 'ref_ext', 'import_key', 'fk_incoterms', 'fk_multicurrency',
@ -405,6 +405,8 @@ if (empty($reshook))
$object->country_id = GETPOST('country_id', 'int'); $object->country_id = GETPOST('country_id', 'int');
$object->state_id = GETPOST('state_id', 'int'); $object->state_id = GETPOST('state_id', 'int');
$object->skype = GETPOST('skype', 'alpha'); $object->skype = GETPOST('skype', 'alpha');
$object->twitter = GETPOST('twitter', 'alpha');
$object->facebook = GETPOST('facebook', 'alpha');
$object->phone = GETPOST('phone', 'alpha'); $object->phone = GETPOST('phone', 'alpha');
$object->fax = GETPOST('fax','alpha'); $object->fax = GETPOST('fax','alpha');
$object->email = trim(GETPOST('email', 'custom', 0, FILTER_SANITIZE_EMAIL)); $object->email = trim(GETPOST('email', 'custom', 0, FILTER_SANITIZE_EMAIL));
@ -959,6 +961,8 @@ else
$object->town = GETPOST('town', 'alpha'); $object->town = GETPOST('town', 'alpha');
$object->state_id = GETPOST('state_id', 'int'); $object->state_id = GETPOST('state_id', 'int');
$object->skype = GETPOST('skype', 'alpha'); $object->skype = GETPOST('skype', 'alpha');
$object->twitter = GETPOST('twitter', 'alpha');
$object->facebook = GETPOST('facebook', 'alpha');
$object->phone = GETPOST('phone', 'alpha'); $object->phone = GETPOST('phone', 'alpha');
$object->fax = GETPOST('fax', 'alpha'); $object->fax = GETPOST('fax', 'alpha');
$object->email = GETPOST('email', 'custom', 0, FILTER_SANITIZE_EMAIL); $object->email = GETPOST('email', 'custom', 0, FILTER_SANITIZE_EMAIL);
@ -1246,11 +1250,26 @@ else
print '<tr><td>'.fieldLabel('Web','url').'</td>'; print '<tr><td>'.fieldLabel('Web','url').'</td>';
print '<td colspan="3"><input type="text" name="url" id="url" value="'.$object->url.'"></td></tr>'; print '<td colspan="3"><input type="text" name="url" id="url" value="'.$object->url.'"></td></tr>';
// Skype if (! empty($conf->socialnetworks->enabled))
if (! empty($conf->skype->enabled))
{ {
print '<tr><td>'.fieldLabel('Skype','skype').'</td>'; // Skype
print '<td colspan="3"><input type="text" name="skype" id="skype" value="'.$object->skype.'"></td></tr>'; if (! empty($conf->global->SOCIALNETWORKS_SKYPE))
{
print '<tr><td>'.fieldLabel('Skype','skype').'</td>';
print '<td colspan="3"><input type="text" name="skype" id="skype" value="'.$object->skype.'"></td></tr>';
}
// Twitter
if (! empty($conf->global->SOCIALNETWORKS_TWITTER))
{
print '<tr><td>'.fieldLabel('Twitter','twitter').'</td>';
print '<td colspan="3"><input type="text" name="twitter" id="twitter" value="'.$object->twitter.'"></td></tr>';
}
// Facebook
if (! empty($conf->global->SOCIALNETWORKS_FACEBOOK))
{
print '<tr><td>'.fieldLabel('Facebook','facebook').'</td>';
print '<td colspan="3"><input type="text" name="facebook" id="facebook" value="'.$object->facebook.'"></td></tr>';
}
} }
// Phone / Fax // Phone / Fax
@ -1538,6 +1557,8 @@ else
$object->country_id = GETPOST('country_id')?GETPOST('country_id', 'int'):$mysoc->country_id; $object->country_id = GETPOST('country_id')?GETPOST('country_id', 'int'):$mysoc->country_id;
$object->state_id = GETPOST('state_id', 'int'); $object->state_id = GETPOST('state_id', 'int');
$object->skype = GETPOST('skype', 'alpha'); $object->skype = GETPOST('skype', 'alpha');
$object->twitter = GETPOST('twitter', 'alpha');
$object->facebook = GETPOST('facebook', 'alpha');
$object->phone = GETPOST('phone', 'alpha'); $object->phone = GETPOST('phone', 'alpha');
$object->fax = GETPOST('fax', 'alpha'); $object->fax = GETPOST('fax', 'alpha');
$object->email = GETPOST('email', 'custom', 0, FILTER_SANITIZE_EMAIL); $object->email = GETPOST('email', 'custom', 0, FILTER_SANITIZE_EMAIL);
@ -1819,12 +1840,27 @@ else
print '<tr><td>'.fieldLabel('Web','url').'</td>'; print '<tr><td>'.fieldLabel('Web','url').'</td>';
print '<td colspan="3"><input type="text" name="url" id="url" size="32" value="'.$object->url.'"></td></tr>'; print '<td colspan="3"><input type="text" name="url" id="url" size="32" value="'.$object->url.'"></td></tr>';
// Skype if (! empty($conf->socialnetworks->enabled))
if (! empty($conf->skype->enabled)) {
{ // Skype
print '<tr><td>'.fieldLabel('Skype','skype').'</td>'; if (! empty($conf->global->SOCIALNETWORKS_SKYPE))
print '<td colspan="3"><input type="text" name="skype" id="skype" size="32" value="'.$object->skype.'"></td></tr>'; {
} print '<tr><td>'.fieldLabel('Skype','skype').'</td>';
print '<td colspan="3"><input type="text" name="skype" id="skype" value="'.$object->skype.'"></td></tr>';
}
// Twitter
if (! empty($conf->global->SOCIALNETWORKS_TWITTER))
{
print '<tr><td>'.fieldLabel('Twitter','twitter').'</td>';
print '<td colspan="3"><input type="text" name="twitter" id="twitter" value="'.$object->twitter.'"></td></tr>';
}
// Facebook
if (! empty($conf->global->SOCIALNETWORKS_FACEBOOK))
{
print '<tr><td>'.fieldLabel('Facebook','facebook').'</td>';
print '<td colspan="3"><input type="text" name="facebook" id="facebook" value="'.$object->facebook.'"></td></tr>';
}
}
// Phone / Fax // Phone / Fax
print '<tr><td>'.fieldLabel('Phone','phone').'</td>'; print '<tr><td>'.fieldLabel('Phone','phone').'</td>';