diff --git a/htdocs/admin/events.php b/htdocs/admin/events.php
index 85accd21fd7..13186d2988c 100644
--- a/htdocs/admin/events.php
+++ b/htdocs/admin/events.php
@@ -20,16 +20,17 @@
* \file htdocs/admin/events.php
* \ingroup core
* \brief Log event setup page
- * \version $Id$
+ * \version $Id: events.php,v 1.20 2011/07/18 23:30:56 eldy Exp $
*/
require("../main.inc.php");
require_once(DOL_DOCUMENT_ROOT."/lib/admin.lib.php");
require_once(DOL_DOCUMENT_ROOT."/lib/agenda.lib.php");
+require_once(DOL_DOCUMENT_ROOT."/core/class/events.class.php");
if (!$user->admin)
- accessforbidden();
+accessforbidden();
$langs->load("users");
$langs->load("admin");
@@ -38,52 +39,19 @@ $langs->load("other");
$action=GETPOST("action");
-// List of all events supported by triggers
-$eventstolog=array(
- array('id'=>'USER_LOGIN', 'test'=>1),
- array('id'=>'USER_LOGIN_FAILED', 'test'=>1),
- array('id'=>'USER_LOGOUT', 'test'=>1),
- array('id'=>'USER_CREATE', 'test'=>1),
- array('id'=>'USER_MODIFY', 'test'=>1),
- array('id'=>'USER_NEW_PASSWORD', 'test'=>1),
- array('id'=>'USER_ENABLEDISABLE', 'test'=>1),
- array('id'=>'USER_DELETE', 'test'=>1),
- array('id'=>'GROUP_CREATE', 'test'=>1),
- array('id'=>'GROUP_MODIFY', 'test'=>1),
- array('id'=>'GROUP_DELETE', 'test'=>1),
-/* array('id'=>'ACTION_CREATE', 'test'=>$conf->societe->enabled),
- array('id'=>'COMPANY_CREATE', 'test'=>$conf->societe->enabled),
- array('id'=>'CONTRACT_VALIDATE', 'test'=>$conf->contrat->enabled),
- array('id'=>'PROPAL_VALIDATE', 'test'=>$conf->propal->enabled),
- array('id'=>'PROPAL_CLOSE_SIGNED', 'test'=>$conf->propal->enabled),
- array('id'=>'PROPAL_CLOSE_REFUSED', 'test'=>$conf->propal->enabled),
- array('id'=>'PROPAL_SENTBYMAIL', 'test'=>$conf->propal->enabled),
- array('id'=>'ORDER_VALIDATE', 'test'=>$conf->commande->enabled),
- array('id'=>'ORDER_SENTBYMAIL', 'test'=>$conf->commande->enabled),
- array('id'=>'BILL_VALIDATE', 'test'=>$conf->facture->enabled),
- array('id'=>'BILL_PAYED', 'test'=>$conf->facture->enabled),
- array('id'=>'BILL_CANCEL', 'test'=>$conf->facture->enabled),
- array('id'=>'BILL_SENTBYMAIL', 'test'=>$conf->facture->enabled),
- array('id'=>'PAYMENT_CUSTOMER_CREATE','test'=>$conf->facture->enabled),
- array('id'=>'PAYMENT_SUPPLIER_CREATE','test'=>$conf->fournisseur->enabled),
- array('id'=>'MEMBER_CREATE', 'test'=>$conf->adherent->enabled),
- array('id'=>'MEMBER_VALIDATE', 'test'=>$conf->adherent->enabled),
- array('id'=>'MEMBER_SUBSCRIPTION', 'test'=>$conf->adherent->enabled),
- array('id'=>'MEMBER_MODIFY', 'test'=>$conf->adherent->enabled),
- array('id'=>'MEMBER_RESILIATE', 'test'=>$conf->adherent->enabled),
- array('id'=>'MEMBER_DELETE', 'test'=>$conf->adherent->enabled),
-*/
-);
+$securityevent=new Events($db);
+$eventstolog=$securityevent->eventstolog;
+
/*
-* Actions
-*/
+ * Actions
+ */
if ($action == "save")
{
- $i=0;
+ $i=0;
- $db->begin();
+ $db->begin();
foreach ($eventstolog as $key => $arr)
{
@@ -93,8 +61,8 @@ if ($action == "save")
else dolibarr_del_const($db,$param,$conf->entity);
}
- $db->commit();
- $mesg = "".$langs->trans("SetupSaved")."";
+ $db->commit();
+ $mesg = "".$langs->trans("SetupSaved")."";
}
@@ -130,14 +98,14 @@ foreach ($eventstolog as $key => $arr)
{
if ($arr['id'])
{
- $var=!$var;
- print '
';
- print '| '.$arr['id'].' | ';
- print '';
- $key='MAIN_LOGEVENTS_'.$arr['id'];
+ $var=!$var;
+ print ' |
';
+ print '| '.$arr['id'].' | ';
+ print '';
+ $key='MAIN_LOGEVENTS_'.$arr['id'];
$value=$conf->global->$key;
print '';
- print ' |
'."\n";
+ print ''."\n";
}
}
print '';
@@ -151,12 +119,10 @@ print "\n";
print '';
-
-if ($mesg) print "
$mesg
";
-print "
";
+dol_htmloutput_mesg($mesg);
$db->close();
-llxFooter('$Date$ - $Revision$');
+llxFooter('$Date: 2011/07/18 23:30:56 $ - $Revision: 1.20 $');
?>
diff --git a/htdocs/admin/tools/listevents.php b/htdocs/admin/tools/listevents.php
index f0ad5511ddf..f2ad75a748d 100644
--- a/htdocs/admin/tools/listevents.php
+++ b/htdocs/admin/tools/listevents.php
@@ -21,19 +21,19 @@
* \file htdocs/admin/tools/listevents.php
* \ingroup core
* \brief List of security events
- * \version $Id$
+ * \version $Id: listevents.php,v 1.31 2011/07/18 23:28:30 eldy Exp $
*/
require("../../main.inc.php");
-
+require_once(DOL_DOCUMENT_ROOT.'/core/class/events.class.php');
if (! $user->admin)
- accessforbidden();
+accessforbidden();
// Security check
if ($user->societe_id > 0)
{
- $action = '';
- $socid = $user->societe_id;
+ $action = '';
+ $socid = $user->societe_id;
}
$langs->load("admin");
@@ -61,23 +61,48 @@ $search_ua = GETPOST("search_ua");
* Actions
*/
+$now=dol_now();
+
// Purge audit events
if ($_REQUEST['action'] == 'confirm_purge' && $_REQUEST['confirm'] == 'yes' && $user->admin)
{
+ $error=0;
+
+ $db->begin();
+ $securityevents=new Events($db);
+
+ // Delete events
$sql = "DELETE FROM ".MAIN_DB_PREFIX."events";
$sql.= " WHERE entity = ".$conf->entity;
$resql = $db->query($sql);
if (! $resql)
{
+ $error++;
$mesg=''.$db->lasterror().'
';
}
+ // Add event purge
+ $text=$langs->trans("SecurityEventsPurged");
+ $securityevent=new Events($db);
+ $securityevent->type='SECURITY_EVENTS_PURGE';
+ $securityevent->dateevent=$now;
+ $securityevent->description=$text;
+ $result=$securityevent->create($user);
+ if ($result > 0)
+ {
+ dol_syslog($text, LOG_WARNING);
+ }
+ else
+ {
+ $error++;
+ dol_syslog($securityevent->error, LOG_ERROR);
+ $db->rolback();
+ }
}
-
/*
-* View
-*/
+ * View
+ */
llxHeader();
@@ -215,21 +240,21 @@ if ($result)
else print '| '.$langs->trans("NoEventOrNoAuditSetup").' |
';
}
print "";
- $db->free();
+ $db->free($result);
if ($num)
{
- print '';
+ print '';
}
}
else
{
- dol_print_error($db);
+ dol_print_error($db);
}
$db->close();
-llxFooter('$Date$ - $Revision$');
+llxFooter('$Date: 2011/07/18 23:28:30 $ - $Revision: 1.31 $');
?>
\ No newline at end of file
diff --git a/htdocs/core/class/events.class.php b/htdocs/core/class/events.class.php
index 8e541732348..918b93de6ad 100644
--- a/htdocs/core/class/events.class.php
+++ b/htdocs/core/class/events.class.php
@@ -21,7 +21,7 @@
* \file htdocs/core/class/events.class.php
* \ingroup core
* \brief File of class to manage security events.
- * \version $Id$
+ * \version $Id: events.class.php,v 1.7 2011/07/18 23:32:00 eldy Exp $
* \author Laurent Destailleur
*/
@@ -52,6 +52,42 @@ class Events // extends CommonObject
var $dateevent;
var $description;
+ // List of all events supported by triggers
+ var $eventstolog=array(
+ array('id'=>'USER_LOGIN', 'test'=>1),
+ array('id'=>'USER_LOGIN_FAILED', 'test'=>1),
+ array('id'=>'USER_LOGOUT', 'test'=>1),
+ array('id'=>'USER_CREATE', 'test'=>1),
+ array('id'=>'USER_MODIFY', 'test'=>1),
+ array('id'=>'USER_NEW_PASSWORD', 'test'=>1),
+ array('id'=>'USER_ENABLEDISABLE', 'test'=>1),
+ array('id'=>'USER_DELETE', 'test'=>1),
+ array('id'=>'GROUP_CREATE', 'test'=>1),
+ array('id'=>'GROUP_MODIFY', 'test'=>1),
+ array('id'=>'GROUP_DELETE', 'test'=>1),
+ /* array('id'=>'ACTION_CREATE', 'test'=>$conf->societe->enabled),
+ array('id'=>'COMPANY_CREATE', 'test'=>$conf->societe->enabled),
+ array('id'=>'CONTRACT_VALIDATE', 'test'=>$conf->contrat->enabled),
+ array('id'=>'PROPAL_VALIDATE', 'test'=>$conf->propal->enabled),
+ array('id'=>'PROPAL_CLOSE_SIGNED', 'test'=>$conf->propal->enabled),
+ array('id'=>'PROPAL_CLOSE_REFUSED', 'test'=>$conf->propal->enabled),
+ array('id'=>'PROPAL_SENTBYMAIL', 'test'=>$conf->propal->enabled),
+ array('id'=>'ORDER_VALIDATE', 'test'=>$conf->commande->enabled),
+ array('id'=>'ORDER_SENTBYMAIL', 'test'=>$conf->commande->enabled),
+ array('id'=>'BILL_VALIDATE', 'test'=>$conf->facture->enabled),
+ array('id'=>'BILL_PAYED', 'test'=>$conf->facture->enabled),
+ array('id'=>'BILL_CANCEL', 'test'=>$conf->facture->enabled),
+ array('id'=>'BILL_SENTBYMAIL', 'test'=>$conf->facture->enabled),
+ array('id'=>'PAYMENT_CUSTOMER_CREATE','test'=>$conf->facture->enabled),
+ array('id'=>'PAYMENT_SUPPLIER_CREATE','test'=>$conf->fournisseur->enabled),
+ array('id'=>'MEMBER_CREATE', 'test'=>$conf->adherent->enabled),
+ array('id'=>'MEMBER_VALIDATE', 'test'=>$conf->adherent->enabled),
+ array('id'=>'MEMBER_SUBSCRIPTION', 'test'=>$conf->adherent->enabled),
+ array('id'=>'MEMBER_MODIFY', 'test'=>$conf->adherent->enabled),
+ array('id'=>'MEMBER_RESILIATE', 'test'=>$conf->adherent->enabled),
+ array('id'=>'MEMBER_DELETE', 'test'=>$conf->adherent->enabled),
+ */
+ );
/**
@@ -75,7 +111,6 @@ class Events // extends CommonObject
global $conf, $langs;
// Clean parameters
- $this->id=trim($this->id);
$this->description=trim($this->description);
// Check parameters
diff --git a/htdocs/lib/usergroups.lib.php b/htdocs/lib/usergroups.lib.php
index 3f27a017ac5..1521cc75921 100644
--- a/htdocs/lib/usergroups.lib.php
+++ b/htdocs/lib/usergroups.lib.php
@@ -22,7 +22,7 @@
/**
* \file htdocs/lib/usergroups.lib.php
* \brief Ensemble de fonctions de base pour la gestion des utilisaterus et groupes
- * \version $Id: usergroups.lib.php,v 1.28 2011/07/04 09:01:38 eldy Exp $
+ * \version $Id: usergroups.lib.php,v 1.29 2011/07/18 23:35:06 eldy Exp $
*/
function user_prepare_head($object)
{
@@ -152,10 +152,10 @@ function show_theme($fuser,$edit=0,$foruserprofile=false)
{
global $conf,$langs,$bc;
-
+
$dirtheme=dol_buildpath($conf->global->MAIN_FORCETHEMEDIR.'/theme',0);
$urltheme=dol_buildpath($conf->global->MAIN_FORCETHEMEDIR.'/theme',1);
-
+
$selected_theme=$conf->global->MAIN_THEME;
if (! empty($fuser)) $selected_theme=$fuser->conf->MAIN_THEME;
@@ -178,6 +178,7 @@ function show_theme($fuser,$edit=0,$foruserprofile=false)
print '';
$url='http://www.dolistore.com/lang-en/4-skins';
if (preg_match('/fr/i',$langs->defaultlang)) $url='http://www.dolistore.com/lang-fr/4-themes';
+ //if (preg_match('/es/i',$langs->defaultlang)) $url='http://www.dolistore.com/lang-es/4-themes';
print '';
print $langs->trans('DownloadMoreSkins');
print '';
@@ -203,7 +204,7 @@ function show_theme($fuser,$edit=0,$foruserprofile=false)
print ' | '.$dirtheme.' | ';
print '';
}
-
+
if ($edit)
{
if ($subdir == $conf->global->MAIN_THEME) $title=$langs->trans("ThemeCurrentlyActive");