socialnetworks.php 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. <?php
  2. /* Copyright (C) 2018 Laurent Destailleur <eldy@users.sourceforge.net>
  3. *
  4. * This program is free software; you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License as published by
  6. * the Free Software Foundation; either version 3 of the License, or
  7. * (at your option) any later version.
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  16. */
  17. /**
  18. * \file htdocs/admin/socialnetworks.php
  19. * \ingroup socialnetworks
  20. * \brief Page to setup the module Social Networks
  21. */
  22. require '../main.inc.php';
  23. require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
  24. require_once DOL_DOCUMENT_ROOT.'/core/lib/mailmanspip.lib.php';
  25. require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
  26. // Load translation files required by the page
  27. $langs->loadLangs(array("admin", "errors"));
  28. if (! $user->admin) accessforbidden();
  29. $type=array('yesno','texte','chaine');
  30. $action = GETPOST('action','aZ09');
  31. /*
  32. * Actions
  33. */
  34. // Action activation d'un sous module du module adherent
  35. if ($action == 'set')
  36. {
  37. $result=dolibarr_set_const($db, $_GET["name"], $_GET["value"], '', 0, '', $conf->entity);
  38. if ($result < 0)
  39. {
  40. dol_print_error($db);
  41. }
  42. }
  43. // Action desactivation d'un sous module du module adherent
  44. if ($action == 'unset')
  45. {
  46. $result=dolibarr_del_const($db, $_GET["name"], $conf->entity);
  47. if ($result < 0)
  48. {
  49. dol_print_error($db);
  50. }
  51. }
  52. /*
  53. * View
  54. */
  55. $help_url='';
  56. llxHeader('',$langs->trans("SocialNetworkSetup"),$help_url);
  57. $linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>';
  58. print load_fiche_titre($langs->trans("SocialNetworkSetup"),$linkback,'title_setup');
  59. //$head = socialnetworks_admin_prepare_head();
  60. $h=0;
  61. $head = array();
  62. $head[$h][0] = DOL_URL_ROOT.'/admin/socialnetworks.php';
  63. $head[$h][1] = $langs->trans("Setup");
  64. $head[$h][2] = 'setup';
  65. $h++;
  66. print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
  67. dol_fiche_head($head, 'setup', '', 0, 'user');
  68. print '<br>';
  69. $arrayofsocialnetworks=array('skype'=>'Skype', 'twitter'=>'Twitter', 'facebook'=>'Facebook');
  70. foreach($arrayofsocialnetworks as $snkey => $snlabel)
  71. {
  72. $consttocheck = 'SOCIALNETWORKS_'.strtoupper($snkey);
  73. if (! empty($conf->global->$consttocheck))
  74. {
  75. //$link=img_picto($langs->trans("Active"),'tick').' ';
  76. $link='<a href="'.$_SERVER["PHP_SELF"].'?action=unset&value=0&name='.$consttocheck.'">';
  77. //$link.=$langs->trans("Disable");
  78. $link.=img_picto($langs->trans("Activated"),'switch_on');
  79. $link.='</a>';
  80. }
  81. else
  82. {
  83. $link='<a href="'.$_SERVER["PHP_SELF"].'?action=set&value=1&name='.$consttocheck.'">';
  84. //$link.=img_$langs->trans("Activate")
  85. $link.=img_picto($langs->trans("Disabled"),'switch_off');
  86. $link.='</a>';
  87. }
  88. print $langs->trans('EnableFeatureFor', $snlabel).' '.$link.'<br><br>';
  89. }
  90. dol_fiche_end();
  91. print '</form>';
  92. // End of page
  93. llxFooter();
  94. $db->close();