Author: benj
Date: Tue May 10 11:45:29 2016
New Revision: 1675
URL: http://svn.gna.org/viewcvs/gdtc?rev=1675&view=rev
Log:
Cosmetic change + add possibility to add comment to modifications
Modified:
trunk/gdtc/include/utils.php
Modified: trunk/gdtc/include/utils.php
URL:
http://svn.gna.org/viewcvs/gdtc/trunk/gdtc/include/utils.php?rev=1675&r1=1674&r2=1675&view=diff
==============================================================================
--- trunk/gdtc/include/utils.php (original)
+++ trunk/gdtc/include/utils.php Tue May 10 11:45:29 2016
@@ -131,11 +131,12 @@
$smarty -> assign ( 'recur_tpe_url', RECUR_TPE_URL );
$smarty -> assign ( 'dtc_admin_host_name', DTC_ADMIN_HOST_NAME );
$smarty -> assign ( 'dtc_my_host_name', DTC_MY_HOST_NAME );
+ $smarty -> assign ( 'dtc_domain', DTC_DOMAIN );
+
$smarty -> assign ( 'dtc_base_url', DTC_BASE_URL );
$smarty -> assign ( 'dtc_public_base_url', DTC_PUBLIC_BASE_URL );
$smarty -> assign ( 'dtc_admin_base_url', DTC_ADMIN_BASE_URL );
$smarty -> assign ( 'dtc_my_base_url', DTC_MY_BASE_URL );
- $smarty -> assign ( 'dtc_domain', DTC_DOMAIN );
$smarty -> assign ( 'url', DTC_HOST_NAME . $_SERVER [ 'REQUEST_URI' ] );
if ( array_key_exists ( 'HTTP_REFERER', $_SERVER ) )
$smarty -> assign ( 'url_referer', $_SERVER [ 'HTTP_REFERER' ] );
@@ -385,7 +386,7 @@
}
-function commit ( $table, $id_field, $id, $args )
+function commit ( $table, $id_field, $id, $args, $comment = '' )
{
$additional = array();
$result = do_query ( "SELECT * FROM $table WHERE $id_field=$id;" );
@@ -411,7 +412,7 @@
$type = find_column_type ( $table, $key );
record_change ( 'changed', $table, $id_field, $id, $key,
- addslashes ( $line[$key] ), $value );
+ addslashes ( $line[$key] ), $value, $comment );
if ( preg_match ( '/varchar/', $type ) || $type == 'text')
{
@@ -468,7 +469,7 @@
fatal_sql_error ( null, $query );
}
- $additional [ 'message' ] [ 'notice' ] = 'Modification effectuée';
+ $additional [ 'message' ] [ 'notice' ] = 'Modification
effectuée';
}
else
{
@@ -624,9 +625,17 @@
function sql2date ( $arg )
{
- if ( preg_match ( '/([0-9]*)-([0-9]*)-([0-9]*)/', $arg, $matches ) )
- {
- return $matches[3] . '/' . $matches[2] . '/' . $matches[1];
+ if ( preg_match ( '/([0-9]*)-([0-9]*)-([0-9]*)( (\d\d):(\d\d):(\d\d))?/',
$arg, $matches ) )
+ {
+ if ( count($matches) >= 5 )
+ {
+ return sprintf ( '%02d/%02d/%04d %02d:%02d:%02d', $matches[3],
$matches[2], $matches[1],
+ $matches[5], $matches[6], $matches[7] );
+ }
+ else
+ {
+ return $matches[3] . '/' . $matches[2] . '/' . $matches[1];
+ }
}
// Puzzled, safer to return initial value
@@ -717,7 +726,7 @@
-function record_change ( $type, $table, $id_field, $id, $field, $oldval,
$newval )
+function record_change ( $type, $table, $id_field, $id, $field, $oldval,
$newval, $comment = '' )
{
global $log_user;
$user = '';
@@ -739,8 +748,8 @@
}
}
- do_query ( 'insert into modification
(user,type_modification,table_name,id_table,id_field,field_name,old_value,new_value)
values ('.
- "'$user', '$type', '$table', '$id_field', '$id', '$field',
'$oldval', '$newval' )");
+ do_query ( 'insert into modification
(user,type_modification,table_name,id_table,id_field,field_name,old_value,new_value,comment)
values ('.
+ "'$user', '$type', '$table', '$id_field', '$id', '$field',
'$oldval', '$newval', '$comment' )");
}
_______________________________________________
Gdtc-commits mailing list
[email protected]
https://mail.gna.org/listinfo/gdtc-commits