Merge branch 'develop' of ssh://git@github.com/Dolibarr/dolibarr.git into develop

This commit is contained in:
Laurent Destailleur 2012-01-31 23:23:02 +01:00
commit c1243db086
18 changed files with 158 additions and 156 deletions

View File

@ -54,6 +54,7 @@ For developers:
- New: Log module outputs can be setup with "or" rule (not only "xor").
- New: Add FirePHP output for logging module.
- New: Add trigger ACTION_DELETE and ACTION_MODIFY.
- New: Trigger now have a priority to define sort execution order.
- New: Can define different requests according to database type into migration files.
- New: Add "canvas" feature to overwrite page of thirdparty, contact, product with yours.
- New: Removed artichow deprecated libraries.

View File

@ -107,7 +107,7 @@ Source: "C:\Program Files\Wamp\bin\mysql\mysql5.0.45\*.*"; DestDir: "{app}\bin\m
; Mysql data files (does not overwrite if exists)
Source: "build\exe\doliwamp\mysql\*.*"; DestDir: "{app}\bin\mysql\data\mysql"; Flags: onlyifdoesntexist ignoreversion recursesubdirs; Excludes: ".cvsignore,.project,CVS\*,Thumbs.db"
; Dolibarr
Source: "htdocs\*.*"; DestDir: "{app}\www\dolibarr\htdocs"; Flags: ignoreversion recursesubdirs; Excludes: ".cvsignore,.project,CVS\*,Thumbs.db,custom\*,custom2\*,telephonie\*,*\conf.php,*\conf.php.mysql,*\conf.php.old,*\conf.php.postgres,*\install.forced.php,*\modBookmark4u.class.php,*\modDocument.class.php,*\modDroitPret.class.php,*\modEditeur.class.php,*\modPostnuke.class.php,*\modTelephonie.class.php,*\interface_modEditeur_Editeur.class.php*,*\bureau2crea,*\rodolphe"
Source: "htdocs\*.*"; DestDir: "{app}\www\dolibarr\htdocs"; Flags: ignoreversion recursesubdirs; Excludes: ".cvsignore,.project,CVS\*,Thumbs.db,custom\*,custom2\*,telephonie\*,*\conf.php,*\conf.php.mysql,*\conf.php.old,*\conf.php.postgres,*\install.forced.php"
Source: "dev\*.*"; DestDir: "{app}\www\dolibarr\dev"; Flags: ignoreversion recursesubdirs; Excludes: ".cvsignore,.project,CVS\*,Thumbs.db,dbmodel\*,fpdf\*,initdata\*,iso-normes\*,licence\*,phpcheckstyle\*,phpunit\*,samples\*,test\*,uml\*,xdebug\*"
Source: "doc\*.*"; DestDir: "{app}\www\dolibarr\doc"; Flags: ignoreversion recursesubdirs; Excludes: ".cvsignore,.project,CVS\*,Thumbs.db,wiki\*,plaquette\*,dev\*,images\dolibarr_screenshot2.png,images\dolibarr_screenshot3.png,images\dolibarr_screenshot4.png,images\dolibarr_screenshot5.png,images\dolibarr_screenshot6.png,images\dolibarr_screenshot7.png,images\dolibarr_screenshot8.png,images\dolibarr_screenshot9.png,images\dolibarr_screenshot10.png,images\dolibarr_screenshot11.png,images\dolibarr_screenshot12.png"
Source: "scripts\*.*"; DestDir: "{app}\www\dolibarr\scripts"; Flags: ignoreversion recursesubdirs; Excludes: ".cvsignore,.project,CVS\*,Thumbs.db,product\materiel.net.php,product\import-product.php"

View File

@ -3,13 +3,13 @@
# Goal: Goal of module
# Version: 1.0
# Author: Copyright 2008 - Author name here
# Licence: Not yet defined
# Licence: GPL
# Install: Just unpack content of module package in Dolibarr directory.
# Setup: Go on Dolibarr setup - modules page to enable module.
# Setup: Go on Dolibarr setup - modules to enable module.
#
# Files in module
htdocs/core/modules/modMyModule.class.php
htdocs/core/triggers/interface_mymodule.class.php
htdocs/mymodule/core/modules/modMyModule.class.php
htdocs/mymodule/core/triggers/interface_mymodule.class.php
htdocs/mymodule/page1.php
htdocs/mymodule/page2.php
htdocs/mymodule/sql/script1.sql

View File

@ -31,15 +31,6 @@ htdocs/conf/conf.php.mysql
htdocs/conf/conf.php.old
htdocs/conf/conf.php.postgres
htdocs/avoir
htdocs/core/modules/modBookmark4u.class.php
htdocs/core/modules/modDocument.class.php
htdocs/core/modules/modDroitPret.class.php
htdocs/core/modules/modEditeur.class.php
htdocs/core/modules/modPostnuke.class.php
htdocs/core/modules/modTelephonie.class.php
htdocs/core/triggers/interface_user.class.php
htdocs/core/triggers/interface_contractfrombill.class.php-NORUN
htdocs/core/triggers/interface_modEditeur_Editeur.class.php-NORUN
htdocs/custom
htdocs/custom2
htdocs/customleave

View File

@ -27,15 +27,6 @@
*/htdocs/conf/conf.php.mysql
*/htdocs/conf/conf.php.old
*/htdocs/conf/conf.php.postgres
*/htdocs/core/modules/modBookmark4u.class.php
*/htdocs/core/modules/modClickToDial.class.php
*/htdocs/core/modules/modDocument.class.php
*/htdocs/core/modules/modDomain.class.php
*/htdocs/core/modules/modDroitPret.class.php
*/htdocs/core/modules/modEditeur.class.php
*/htdocs/core/modules/modPostnuke.class.php
*/htdocs/core/triggers/interface_user.class.php
*/htdocs/core/triggers/interface_contractfrombill.class.php-NORUN
*/htdocs/custom/*
*/htdocs/custom2/*
*/htdocs/document/*

View File

@ -24,7 +24,7 @@
require("../main.inc.php");
require_once(DOL_DOCUMENT_ROOT."/core/lib/admin.lib.php");
require_once(DOL_DOCUMENT_ROOT."/core/triggers/interface_modNotification_Notification.class.php");
require_once(DOL_DOCUMENT_ROOT."/core/triggers/interface_50_modNotification_Notification.class.php");
$langs->load("admin");
$langs->load("other");

View File

@ -1,5 +1,5 @@
<?php
/* Copyright (C) 2005-2007 Laurent Destailleur <eldy@users.sourceforge.net>
/* Copyright (C) 2005-2012 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
@ -17,7 +17,7 @@
/**
* \file htdocs/admin/triggers.php
* \brief Page de configuration et activation des triggers
* \brief Page to view triggers
*/
require("../main.inc.php");
@ -25,13 +25,13 @@ require_once(DOL_DOCUMENT_ROOT."/core/class/interfaces.class.php");
$langs->load("admin");
if (!$user->admin)
accessforbidden();
if (!$user->admin) accessforbidden();
/*
* Action
*/
// None
/*
@ -50,9 +50,11 @@ print "<br>\n";
$template_dir = DOL_DOCUMENT_ROOT.'/core/tpl/';
$interfaces = new Interfaces($db);
$triggers = $interfaces->getTriggersList(0);
$triggers = $interfaces->getTriggersList(0,'priority');
include($template_dir.'triggers.tpl.php');
llxFooter();
$db->close();
?>

View File

@ -67,6 +67,13 @@ class Interfaces
dol_syslog(get_class($this).'::run_triggers was called with wrong parameters action='.$action.' object='.is_object($object).' user='.is_object($user).' langs='.is_object($langs).' conf='.is_object($conf), LOG_WARNING);
}
$nbfile = $nbtotal = $nbok = $nbko = 0;
$files = array();
$modules = array();
$orders = array();
$i=0;
foreach($conf->triggers_modules as $reldir)
{
$dir=dol_buildpath($reldir,0);
@ -76,111 +83,116 @@ class Interfaces
if (!is_dir($dir)) continue;
$handle=opendir($dir);
$modules = array();
$nbfile = $nbtotal = $nbok = $nbko = 0;
if (is_resource($handle))
{
while (($file = readdir($handle))!==false)
{
if (is_readable($dir."/".$file) && preg_match('/^interface_([^_]+)_(.+)\.class\.php$/i',$file,$reg))
if (is_readable($dir."/".$file) && preg_match('/^interface_([0-9]+)_([^_]+)_(.+)\.class\.php$/i',$file,$reg))
{
$part1=$reg[1];
$part2=$reg[2];
$part3=$reg[3];
$nbfile++;
$modName = "Interface".ucfirst($reg[2]);
$modName = "Interface".ucfirst($reg[3]);
//print "file=$file"; print "modName=$modName"; exit;
if (in_array($modName,$modules))
{
$langs->load("errors");
dol_syslog("Interface::run_triggers action=".$action." ".$langs->trans("ErrorDuplicateTrigger",$modName,"/htdocs/core/triggers/"),LOG_ERR);
dol_syslog(get_class($this)."::run_triggers action=".$action." ".$langs->trans("ErrorDuplicateTrigger",$modName,"/htdocs/core/triggers/"),LOG_ERR);
continue;
}
else
{
include_once($dir.'/'.$file);
}
// Check if trigger file is disabled by name
if (preg_match('/NORUN$/i',$file))
{
continue;
}
if (preg_match('/NORUN$/i',$file)) continue;
// Check if trigger file is for a particular module
$qualified=true;
if (strtolower($reg[1]) != 'all')
if (strtolower($reg[2]) != 'all')
{
$module=preg_replace('/^mod/i','',$reg[1]);
$module=preg_replace('/^mod/i','',$reg[2]);
$constparam='MAIN_MODULE_'.strtoupper($module);
if (empty($conf->global->$constparam)) $qualified=false;
}
if (! $qualified)
{
dol_syslog("Interfaces::run_triggers action=".$action." Triggers for file '".$file."' need module to be enabled",LOG_INFO);
dol_syslog(get_class($this)."::run_triggers action=".$action." Triggers for file '".$file."' need module to be enabled",LOG_INFO);
continue;
}
include_once($dir."/".$file);
$objMod = new $modName($this->db);
$i=0;
if ($objMod)
{
// Bypass if workflow module is enabled and if the trigger asked to be disable in such case
if (! empty($conf->workflow->enabled) && ! empty($objMod->disabled_if_workflow))
{
dol_syslog("Interfaces::run_triggers action=".$action." Bypass triggers for file '".$file."'",LOG_INFO);
continue;
}
dol_syslog("Interfaces::run_triggers action=".$action." Launch triggers for file '".$file."'",LOG_INFO);
$modules[$i] = $modName;
//dol_syslog("Interfaces::run_triggers Launch triggers for file '".$file."'",LOG_INFO);
$result=$objMod->run_trigger($action,$object,$user,$langs,$conf);
if ($result > 0)
{
// Action OK
$nbtotal++;
$nbok++;
}
if ($result == 0)
{
// Aucune action faite
$nbtotal++;
}
if ($result < 0)
{
// Action KO
$nbtotal++;
$nbko++;
$this->errors[]=$objMod->error;
}
$i++;
}
else
{
dol_syslog("Interfaces::run_triggers action=".$action." Failed to instantiate trigger for file '".$file."'",LOG_ERR);
}
$modules[$i] = $modName;
$files[$i] = $file;
$orders[$i] = $part1.'_'.$part2.'_'.$part3; // Set sort criteria value
$i++;
}
}
closedir($handle);
}
}
asort($orders);
// Loop on each trigger
foreach ($orders as $key => $value)
{
$modName = $modules[$key];
if (empty($modName)) continue;
$objMod = new $modName($this->db);
if ($objMod)
{
dol_syslog(get_class($this)."::run_triggers action=".$action." Launch triggers for file '".$files[$key]."'",LOG_INFO);
$result=$objMod->run_trigger($action,$object,$user,$langs,$conf);
if ($result > 0)
{
// Action OK
$nbtotal++;
$nbok++;
}
if ($result == 0)
{
// Aucune action faite
$nbtotal++;
}
if ($result < 0)
{
// Action KO
$nbtotal++;
$nbko++;
$this->errors[]=$objMod->error;
}
}
else
{
dol_syslog(get_class($this)."::run_triggers action=".$action." Failed to instantiate trigger for file '".$files[$key]."'",LOG_ERR);
}
}
if ($nbko)
{
dol_syslog("Interfaces::run_triggers action=".$action." Files found: ".$nbfile.", Files launched: ".$nbtotal.", Done: ".$nbok.", Failed: ".$nbko, LOG_ERR);
dol_syslog(get_class($this)."::run_triggers action=".$action." Files found: ".$nbfile.", Files launched: ".$nbtotal.", Done: ".$nbok.", Failed: ".$nbko, LOG_ERR);
return -$nbko;
}
else
{
//dol_syslog("Interfaces::run_triggers Files found: ".$nbfile.", Files launched: ".$nbtotal.", Done: ".$nbok.", Failed: ".$nbko, LOG_DEBUG);
//dol_syslog(get_class($this)."::run_triggers Files found: ".$nbfile.", Files launched: ".$nbtotal.", Done: ".$nbok.", Failed: ".$nbko, LOG_DEBUG);
return $nbok;
}
}
/**
* Return list of triggers. Function used by admin page htdoc/admin/triggers
* Return list of triggers. Function used by admin page htdoc/admin/triggers.
* List is sorted by trigger filename so by priority to run.
*
* @param int $workflow 0=Return all triggers, 1=Return only triggers not disabled if workflow module activated
* @return array Array list of triggers
*/
function getTriggersList($workflow=0)
function getTriggersList()
{
global $conf, $langs;
@ -204,31 +216,29 @@ class Interfaces
{
while (($file = readdir($handle))!==false)
{
if (is_readable($dir.'/'.$file) && preg_match('/^interface_([^_]+)_(.+)\.class\.php/',$file,$reg))
if (is_readable($dir.'/'.$file) && preg_match('/^interface_([0-9]+)_([^_]+)_(.+)\.class\.php/',$file,$reg))
{
$modName = 'Interface'.ucfirst($reg[2]);
$part1=$reg[1];
$part2=$reg[2];
$part3=$reg[3];
$modName = 'Interface'.ucfirst($reg[3]);
//print "file=$file"; print "modName=$modName"; exit;
if (in_array($modName,$modules))
{
$langs->load("errors");
print '<div class="error">'.$langs->trans("Error").' : '.$langs->trans("ErrorDuplicateTrigger",$modName,"/htdocs/core/triggers/").'</div>';
$objMod = new $modName($this->db);
$modules[$i] = $modName;
$files[$i] = $file;
$orders[$i] = $objMod->family; // Tri par famille
$i++;
}
else
{
include_once($dir.'/'.$file);
$objMod = new $modName($this->db);
$modules[$i] = $modName;
$files[$i] = $file;
$orders[$i] = $objMod->family; // Tri par famille
$i++;
}
$files[$i] = $file;
$modules[$i] = $modName;
$orders[$i] = $part1.'_'.$part2.'_'.$part3; // Set sort criteria value
$i++;
}
}
closedir($handle);
@ -244,27 +254,27 @@ class Interfaces
foreach ($orders as $key => $value)
{
$modName = $modules[$key];
if ($modName)
{
$objMod = new $modName($this->db);
// Bypass if workflow module is enabled and if the trigger is compatible
if ($workflow && ! empty($objMod->disabled_if_workflow)) continue;
}
if (empty($modName)) continue;
$objMod = new $modName($this->db);
// Define disabledbyname and disabledbymodule
$disabledbyname=0;
$disabledbymodule=1;
$module='';
// Check if trigger file is disabled by name
if (preg_match('/NORUN$/i',$files[$key])) $disabledbyname=1;
if (preg_match('/^interface_([^_]+)_(.+)\.class\.php/i',$files[$key],$reg))
// Check if trigger file is for a particular module
if (preg_match('/^interface_([0-9]+)_([^_]+)_(.+)\.class\.php/i',$files[$key],$reg))
{
// Check if trigger file is for a particular module
$module=preg_replace('/^mod/i','',$reg[1]);
$module=preg_replace('/^mod/i','',$reg[2]);
$constparam='MAIN_MODULE_'.strtoupper($module);
if (strtolower($reg[1]) == 'all') $disabledbymodule=0;
if (strtolower($reg[2]) == 'all') $disabledbymodule=0;
else if (empty($conf->global->$constparam)) $disabledbymodule=2;
}
// We set info of modules
$triggers[$j]['picto'] = $objMod->picto?img_object('',$objMod->picto):img_object('','generic');
$triggers[$j]['file'] = $files[$key];
$triggers[$j]['version'] = $objMod->getVersion();

View File

@ -17,7 +17,7 @@
*/
/**
* \file htdocs/core/triggers/interface_all_Logevents.class.php
* \file htdocs/core/triggers/interface_20_all_Logevents.class.php
* \ingroup core
* \brief Trigger file for
*/
@ -38,12 +38,13 @@ class InterfaceLogevents
var $desc;
/**
* Constructor.
* @param DB Database handler
* Constructor
*
* @param DoliDB $db Database handler
*/
function InterfaceLogevents($DB)
function InterfaceLogevents($db)
{
$this->db = $DB ;
$this->db = $db;
$this->name = preg_replace('/^Interface/i','',get_class($this));
$this->family = "core";
@ -243,7 +244,7 @@ class InterfaceLogevents
$error ="Failed to insert security event: ".$event->error;
$this->error=$error;
dol_syslog("interface_all_Logevents.class.php: ".$this->error, LOG_ERR);
dol_syslog(get_class($this).": ".$this->error, LOG_ERR);
return -1;
}
}

View File

@ -16,7 +16,7 @@
*/
/**
* \file /htdocs/core/triggers/interface_modPaypal_PaypalWorkflow.class.php
* \file /htdocs/core/triggers/interface_20_modPaypal_PaypalWorkflow.class.php
* \ingroup paypal
* \brief Trigger file for paypal workflow
*/
@ -32,11 +32,12 @@ class InterfacePaypalWorkflow
/**
* Constructor
* @param DB Database handler
*
* @param DoliDB $db Database handler
*/
function InterfacePaypalWorkflow($DB)
function InterfacePaypalWorkflow($db)
{
$this->db = $DB ;
$this->db = $db;
$this->name = preg_replace('/^Interface/i','',get_class($this));
$this->family = "paypal";

View File

@ -17,7 +17,7 @@
*/
/**
* \file htdocs/core/triggers/interface_modWorkflow_WorkflowManager.class.php
* \file htdocs/core/triggers/interface_20_modWorkflow_WorkflowManager.class.php
* \ingroup core
* \brief Trigger file for workflows
*/
@ -33,12 +33,13 @@ class InterfaceWorkflowManager
var $db;
/**
* Constructor.
* @param DB Database handler
* Constructor
*
* @param DoliDB $db Database handler
*/
function InterfaceWorkflowManager($DB)
function InterfaceWorkflowManager($db)
{
$this->db = $DB ;
$this->db = $db;
$this->name = preg_replace('/^Interface/i','',get_class($this));
$this->family = "core";

View File

@ -18,7 +18,7 @@
*/
/**
* \file htdocs/core/triggers/interface_modAgenda_ActionsAuto.class.php
* \file htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php
* \ingroup agenda
* \brief Trigger file for agenda module
*/
@ -39,12 +39,13 @@ class InterfaceActionsAuto
var $desc;
/**
* Constructor.
* @param DB Database handler
* Constructor
*
* @param DoliDB $db Database handler
*/
function InterfaceActionsAuto($DB)
function InterfaceActionsAuto($db)
{
$this->db = $DB ;
$this->db = $db;
$this->name = preg_replace('/^Interface/i','',get_class($this));
$this->family = "agenda";

View File

@ -16,7 +16,7 @@
*/
/**
* \file htdocs/core/triggers/interface_modLdap_Ldapsynchro.class.php
* \file htdocs/core/triggers/interface_50_modLdap_Ldapsynchro.class.php
* \ingroup core
* \brief Fichier de gestion des triggers LDAP
*/
@ -34,12 +34,13 @@ class InterfaceLdapsynchro
/**
* Constructor.
* @param DB Database handler
* Constructor
*
* @param DoliDB $db Database handler
*/
function InterfaceLdapsynchro($DB)
function InterfaceLdapsynchro($db)
{
$this->db = $DB ;
$this->db = $db;
$this->name = preg_replace('/^Interface/i','',get_class($this));
$this->family = "ldap";

View File

@ -17,7 +17,7 @@
*/
/**
* \file htdocs/core/triggers/interface_modNotification_Notification.class.php
* \file htdocs/core/triggers/interface_50_modNotification_Notification.class.php
* \ingroup notification
* \brief File of class of triggers for notification module
*/
@ -34,12 +34,13 @@ class InterfaceNotification
'FICHEINTER_VALIDATE','ORDER_SUPPLIER_APPROVE','ORDER_SUPPLIER_REFUSE');
/**
* Constructor.
* @param DB Database handler
* Constructor
*
* @param DoliDB $db Database handler
*/
function InterfaceNotification($DB)
function InterfaceNotification($db)
{
$this->db = $DB ;
$this->db = $db;
$this->name = preg_replace('/^Interface/i','',get_class($this));
$this->family = "notification";

View File

@ -17,12 +17,12 @@
*/
/**
* \file htdocs/core/triggers/interface_all_Demo.class.php
* \file htdocs/core/triggers/interface_90_all_Demo.class.php
* \ingroup core
* \brief Fichier de demo de personalisation des actions du workflow
* \remarks Son propre fichier d'actions peut etre cree par recopie de celui-ci:
* - Le nom du fichier doit etre: interface_modMymodule_Mytrigger.class.php
* ou: interface_all_Mytrigger.class.php
* - Le nom du fichier doit etre: interface_99_modMymodule_Mytrigger.class.php
* ou: interface_99_all_Mytrigger.class.php
* - Le fichier doit rester stocke dans core/triggers
* - Le nom de la classe doit etre InterfaceMytrigger
* - Le nom de la methode constructeur doit etre InterfaceMytrigger
@ -39,12 +39,13 @@ class InterfaceDemo
var $db;
/**
* Constructor.
* @param DB Database handler
* Constructor
*
* @param DoliDB $db Database handler
*/
function InterfaceDemo($DB)
function InterfaceDemo($db)
{
$this->db = $DB ;
$this->db = $db;
$this->name = preg_replace('/^Interface/i','',get_class($this));
$this->family = "demo";

View File

@ -18,7 +18,7 @@
-- ========================================================================
-- This table logs all dolibarr security events
-- Content of this table is not managed by users but by Dolibarr
-- trigger interface_all_LogEvent.
-- trigger interface_20_all_Logevents.
-- ========================================================================
create table llx_events

View File

@ -26,7 +26,7 @@
require("../../main.inc.php");
require_once(DOL_DOCUMENT_ROOT."/core/lib/company.lib.php");
require_once(DOL_DOCUMENT_ROOT."/contact/class/contact.class.php");
require_once(DOL_DOCUMENT_ROOT."/core/triggers/interface_modNotification_Notification.class.php");
require_once(DOL_DOCUMENT_ROOT."/core/triggers/interface_50_modNotification_Notification.class.php");
$langs->load("companies");
$langs->load("mails");

View File

@ -383,7 +383,7 @@ a.tmenu:link, a.tmenu:visited, a.tmenu:hover, a.tmenu:active {
padding: 0px 5px 0px 5px;
margin: 0px 1px 2px 1px;
white-space: nowrap;
text-shadow: 1px 2px 3px #AFAFAF;
text-shadow: 1px 2px 4px #BFBFBF;
}
a.tmenu:hover, a.tmenu:active {
margin: 0px 0px 0px 0px;
@ -394,7 +394,7 @@ a.tmenu:hover, a.tmenu:active {
}
a.tmenu:hover, a.tmenu:active {
background: #F4F4F4;
text-shadow: 1px 2px 3px #AFAFAF;
text-shadow: 1px 2px 4px #BFBFBF;
}
a.tmenusel:link, a.tmenusel:visited, a.tmenusel:hover, a.tmenusel:active {
@ -408,7 +408,7 @@ a.tmenusel:link, a.tmenusel:visited, a.tmenusel:hover, a.tmenusel:active {
border-<?php print $left; ?>: 1px solid #D8D8D8;
border-bottom: 2px solid #F4F4F4;
white-space: nowrap;
text-shadow: 1px 2px 3px #AFAFAF;
text-shadow: 1px 2px 4px #BFBFBF;
}
@ -1693,7 +1693,7 @@ div.titre {
font-weight: bold;
color: rgb(<?php print $colortext; ?>);
text-decoration: none;
text-shadow: 1px 2px 3px #AFAFAF;
text-shadow: 2px 2px 4px #BFBFBF;
}