diff --git a/htdocs/asterisk/wrapper.php b/htdocs/asterisk/wrapper.php index f37707a5d2f..12f3062f02f 100644 --- a/htdocs/asterisk/wrapper.php +++ b/htdocs/asterisk/wrapper.php @@ -30,15 +30,23 @@ * write = system,call,log,verbose,command,agent,user */ -//if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER','1'); // Not disabled cause need to load personalized language -//if (! defined('NOREQUIREDB')) define('NOREQUIREDB','1'); // Not disabled cause need to load personalized language +//if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER','1'); +//if (! defined('NOREQUIREDB')) define('NOREQUIREDB','1'); if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1'); -if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1'); +if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1'); if (! defined('NOCSRFCHECK')) define('NOCSRFCHECK','1'); if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL','1'); -if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1'); -if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1'); -if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1'); +if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1'); +if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1'); +if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1'); + +// C'est un wrapper, donc header vierge +function llxHeader() { + print ''."\n"; + print ''."\n"; + print 'Asterisk redirection from Dolibarr...'."\n"; + print ''."\n"; +} require_once("../main.inc.php"); require_once(DOL_DOCUMENT_ROOT."/lib/functions.lib.php"); @@ -46,13 +54,20 @@ require_once(DOL_DOCUMENT_ROOT."/lib/functions2.lib.php"); // Security check -// TODO Enable and test if module Asterisk is enabled +if (! $conf->clicktodial->enabled) +{ + accessforbidden(); + exit; +} -$conf->global->ASTERISK_HOST="127.0.0.1"; -$conf->global->ASTERISK_TYPE="SIP/"; -$conf->global->ASTERISK_INDICATIF="0"; -$conf->global->ASTERISK_PORT=5038; +// Define Asterisk setup +if (! isset($conf->global->ASTERISK_HOST)) $conf->global->ASTERISK_HOST="127.0.0.1"; +if (! isset($conf->global->ASTERISK_TYPE)) $conf->global->ASTERISK_TYPE="SIP/"; +if (! isset($conf->global->ASTERISK_INDICATIF)) $conf->global->ASTERISK_INDICATIF="0"; +if (! isset($conf->global->ASTERISK_HOST)) $conf->global->ASTERISK_PORT=5038; +if ($conf->global->ASTERISK_INDICATIF=='NONE') $conf->global->ASTERISK_INDICATIF=''; + $login = $_GET['login']; $password = $_GET['password']; @@ -61,41 +76,29 @@ $called = $_GET['called']; # Adresse IP du serveur Asterisk $strHost = $conf->global->ASTERISK_HOST; - -#Context ( generalement from-internal ) -$strContext = "from-internal"; - #Spécifiez le type d'extension par laquelle vous poste est connecte. #ex: SIP/, IAX2/, ZAP/, etc $channel = $conf->global->ASTERISK_TYPE; - +#Indicatif de la ligne sortante +$prefix = $conf->global->ASTERISK_INDICATIF; +#Port +$port = $conf->global->ASTERISK_PORT; +#Context ( generalement from-internal ) +$strContext = "from-internal"; #Delai d'attente avant de raccrocher $strWaitTime = "30"; - #Priority $strPriority = "1"; - #Nomber of try $strMaxRetry = "2"; -#Indicatif de la ligne sortante -$prefix = $conf->global->ASTERISK_INDICATIF; - -#Port -$port = $conf->global->ASTERISK_PORT; - - /* * View */ -print ''."\n"; -print ''."\n"; -print 'Asterisk redirection from Dolibarr...'."\n"; -print ''."\n"; - +llxHeader(); $number=strtolower($called) ; $pos=strpos ($number,"local"); @@ -141,5 +144,8 @@ if (! empty($number)) } endif ; } +else { + print 'Bad parameters in URL. Must be http://MYDOLIBARR/asterisk/wrapper.php?caller=99999&called=99999&login=xxxxx&password=xxxxx'; +} print ''."\n"; diff --git a/htdocs/includes/modules/modClickToDial.class.php b/htdocs/includes/modules/modClickToDial.class.php index 42c9ae8f8cd..f0e340a36ec 100644 --- a/htdocs/includes/modules/modClickToDial.class.php +++ b/htdocs/includes/modules/modClickToDial.class.php @@ -81,10 +81,12 @@ class modClickToDial extends DolibarrModules $this->rights_class = 'clicktodial'; } - /** - * \brief Fonction appel�e lors de l'activation du module. Ins�re en base les constantes, boites, permissions du module. - * D�finit �galement les r�pertoires de donn�es � cr�er pour ce module. - */ + /** + * \brief Function called when module is enabled. + * The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database. + * It also creates data directories. + * \return int 1 if OK, 0 if KO + */ function init() { global $conf; @@ -94,10 +96,12 @@ class modClickToDial extends DolibarrModules return $this->_init($sql); } - /** - * \brief Fonction appel�e lors de la d�sactivation d'un module. - * Supprime de la base les constantes, boites et permissions du module. - */ + /** + * \brief Function called when module is disabled. + * Remove from database constants, boxes and permissions from Dolibarr database. + * Data directories are not deleted. + * \return int 1 if OK, 0 if KO + */ function remove() { $sql = array(); diff --git a/htdocs/lib/security.lib.php b/htdocs/lib/security.lib.php index d08b93a31ca..1f5cffa02a7 100644 --- a/htdocs/lib/security.lib.php +++ b/htdocs/lib/security.lib.php @@ -27,7 +27,7 @@ /** * \brief Show Dolibarr default login page - * \param langs Lang object + * \param langs Lang object (must be initialized by a new). * \param conf Conf object * \param mysoc Company object */ @@ -76,7 +76,7 @@ function dol_loginfunction($langs,$conf,$mysoc) } } - $conf->css = "/theme/".$conf->theme."/style.css.php?lang=".$langs->defaultlang; + $conf->css = "/theme/".$conf->theme."/style.css.php?lang=".$langs->defaultlang; $conf_css = DOL_URL_ROOT.$conf->css; // Set cookie for timeout management diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index 0d75e1cc11d..a62894a6e2e 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -395,6 +395,11 @@ if (! defined('NOLOGIN')) { // We show login page include_once(DOL_DOCUMENT_ROOT."/lib/security.lib.php"); + if (! is_object($langs)) // This can occurs when calling page with NOREQUIRETRAN defined + { + include_once(DOL_DOCUMENT_ROOT."/core/class/translate.class.php"); + $langs=new Translate("",$conf); + } dol_loginfunction($langs,$conf,$mysoc); exit; }