2006-11-10 16:30:01 +01:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* eGroupWare
|
|
|
|
*
|
|
|
|
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
|
|
|
|
* @package importexport
|
|
|
|
* @link http://www.egroupware.org
|
|
|
|
* @author Cornelius Weiss <nelius@cwtech.de>
|
|
|
|
* @copyright Cornelius Weiss <nelius@cwtech.de>
|
2006-11-10 16:38:31 +01:00
|
|
|
* @version $Id$
|
2006-11-10 16:30:01 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
2010-03-29 19:38:54 +02:00
|
|
|
* class importexport_helper_functions (only static methods)
|
|
|
|
* use importexport_helper_functions::method
|
2006-11-10 16:30:01 +01:00
|
|
|
*/
|
2010-03-22 16:09:26 +01:00
|
|
|
class importexport_helper_functions {
|
2010-04-03 12:31:57 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Plugins are scanned and cached for all instances using this source path for given time (in seconds)
|
|
|
|
*/
|
|
|
|
const CACHE_EXPIRATION = 3600;
|
2010-03-29 19:38:54 +02:00
|
|
|
|
2012-10-18 18:38:30 +02:00
|
|
|
/**
|
|
|
|
* Make no changes (automatic category creation)
|
|
|
|
*/
|
|
|
|
public static $dry_run = false;
|
|
|
|
|
2012-12-31 21:36:28 +01:00
|
|
|
/**
|
|
|
|
* Relative date ranges for filtering
|
|
|
|
*/
|
|
|
|
public static $relative_dates = array( // Start: year,month,day,week, End: year,month,day,week
|
|
|
|
'Today' => array(0,0,0,0, 0,0,1,0),
|
|
|
|
'Yesterday' => array(0,0,-1,0, 0,0,0,0),
|
|
|
|
'This week' => array(0,0,0,0, 0,0,0,1),
|
|
|
|
'Last week' => array(0,0,0,-1, 0,0,0,0),
|
|
|
|
'This month' => array(0,0,0,0, 0,1,0,0),
|
|
|
|
'Last month' => array(0,-1,0,0, 0,0,0,0),
|
2013-01-03 17:58:38 +01:00
|
|
|
'Last 3 months' => array(0,-3,0,0, 0,0,0,0),
|
2012-12-31 21:36:28 +01:00
|
|
|
'This quarter'=> array(0,0,0,0, 0,0,0,0), // Just a marker, needs special handling
|
|
|
|
'Last quarter'=> array(0,-4,0,0, 0,-4,0,0), // Just a marker
|
|
|
|
'This year' => array(0,0,0,0, 1,0,0,0),
|
|
|
|
'Last year' => array(-1,0,0,0, 0,0,0,0),
|
|
|
|
'2 years ago' => array(-2,0,0,0, -1,0,0,0),
|
|
|
|
'3 years ago' => array(-3,0,0,0, -2,0,0,0),
|
|
|
|
);
|
|
|
|
|
2010-03-29 19:38:54 +02:00
|
|
|
/**
|
|
|
|
* Files known to cause problems, and will be skipped in a plugin scan
|
|
|
|
* If you put appname => true, the whole app will be skipped.
|
|
|
|
*/
|
|
|
|
protected static $blacklist_files = array(
|
|
|
|
'news_admin' => array(
|
|
|
|
'class.news_admin_import.inc.php',
|
|
|
|
),
|
|
|
|
);
|
2010-10-07 00:33:52 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Class used to provide extra conversion functions
|
|
|
|
*
|
|
|
|
* Passed in as a param to conversion()
|
|
|
|
*/
|
|
|
|
protected static $cclass = null;
|
|
|
|
|
2006-11-10 16:30:01 +01:00
|
|
|
/**
|
|
|
|
* nothing to construct here, only static functions!
|
|
|
|
*/
|
2010-04-03 12:31:57 +02:00
|
|
|
|
2007-06-23 14:07:18 +02:00
|
|
|
/**
|
|
|
|
* Converts a custom time string to to unix timestamp
|
2010-04-03 12:31:57 +02:00
|
|
|
* The format of the time string is given by the argument $_format
|
2007-06-23 14:07:18 +02:00
|
|
|
* which takes the same parameters as the php date() function.
|
|
|
|
*
|
2007-07-06 11:42:23 +02:00
|
|
|
* @abstract supportet formatstrings: d,m,y,Y,H,h,i,s,O,a,A
|
2007-06-23 14:07:18 +02:00
|
|
|
* If timestring is empty, php strtotime is used.
|
|
|
|
* @param string $_string time string to convert
|
|
|
|
* @param string $_format format of time string e.g.: d.m.Y H:i
|
2007-08-24 14:52:50 +02:00
|
|
|
* @param int $_is_dst is day light saving time? 0 = no, 1 = yes, -1 = system default
|
2007-06-23 14:07:18 +02:00
|
|
|
*/
|
2007-08-24 14:52:50 +02:00
|
|
|
public static function custom_strtotime( $_string, $_format='', $_is_dst = -1) {
|
2007-06-23 14:07:18 +02:00
|
|
|
if ( empty( $_format ) ) return strtotime( $_string );
|
|
|
|
$fparams = explode( ',', chunk_split( $_format, 1, ',' ) );
|
|
|
|
$spos = 0;
|
|
|
|
foreach ( $fparams as $fparam ) {
|
2010-04-03 12:31:57 +02:00
|
|
|
|
2007-06-23 14:07:18 +02:00
|
|
|
switch ( $fparam ) {
|
|
|
|
case 'd': (int)$day = substr( $_string, $spos, 2 ); $spos += 2; break;
|
|
|
|
case 'm': (int)$mon = substr( $_string, $spos, 2 ); $spos += 2; break;
|
|
|
|
case 'y': (int)$year = substr( $_string, $spos, 2 ); $spos += 2; break;
|
|
|
|
case 'Y': (int)$year = substr( $_string, $spos, 4 ); $spos += 4; break;
|
|
|
|
case 'H': (int)$hour = substr( $_string, $spos, 2 ); $spos += 2; break;
|
|
|
|
case 'h': (int)$hour = substr( $_string, $spos, 2 ); $spos += 2; break;
|
|
|
|
case 'i': (int)$min = substr( $_string, $spos, 2 ); $spos += 2; break;
|
2007-07-06 11:42:23 +02:00
|
|
|
case 's': (int)$sec = substr( $_string, $spos, 2 ); $spos += 2; break;
|
2007-06-23 14:07:18 +02:00
|
|
|
case 'O': (int)$offset = $year = substr( $_string, $spos, 5 ); $spos += 5; break;
|
|
|
|
case 'a': (int)$hour = $fparam == 'am' ? $hour : $hour + 12; break;
|
|
|
|
case 'A': (int)$hour = $fparam == 'AM' ? $hour : $hour + 12; break;
|
|
|
|
default: $spos++; // seperator
|
|
|
|
}
|
|
|
|
}
|
2010-04-03 12:31:57 +02:00
|
|
|
|
2007-06-23 14:07:18 +02:00
|
|
|
print_debug("hour:$hour; min:$min; sec:$sec; mon:$mon; day:$day; year:$year;\n");
|
2007-08-24 14:52:50 +02:00
|
|
|
$timestamp = mktime($hour, $min, $sec, $mon, $day, $year, $_is_dst);
|
2010-04-03 12:31:57 +02:00
|
|
|
|
2007-06-23 14:07:18 +02:00
|
|
|
// offset given?
|
|
|
|
if ( isset( $offset ) && strlen( $offset == 5 ) ) {
|
|
|
|
$operator = $offset{0};
|
|
|
|
$ohour = 60 * 60 * (int)substr( $offset, 1, 2 );
|
|
|
|
$omin = 60 * (int)substr( $offset, 3, 2 );
|
|
|
|
if ( $operator == '+' ) $timestamp += $ohour + $omin;
|
|
|
|
else $timestamp -= $ohour + $omin;
|
|
|
|
}
|
|
|
|
return $timestamp;
|
|
|
|
}
|
2006-11-10 16:30:01 +01:00
|
|
|
/**
|
|
|
|
* converts accound_lid to account_id
|
|
|
|
*
|
2007-06-09 17:36:30 +02:00
|
|
|
* @param mixed $_account_lid comma seperated list or array with lids
|
|
|
|
* @return mixed comma seperated list or array with ids
|
2006-11-10 16:30:01 +01:00
|
|
|
*/
|
2012-01-25 19:13:57 +01:00
|
|
|
public static function account_name2id( &$_account_lids ) {
|
2007-06-09 17:36:30 +02:00
|
|
|
$account_lids = is_array( $_account_lids ) ? $_account_lids : explode( ',', $_account_lids );
|
2011-03-16 17:50:28 +01:00
|
|
|
$skip = false;
|
|
|
|
foreach ( $account_lids as $key => $account_lid ) {
|
|
|
|
if($skip) {
|
2012-01-25 19:13:57 +01:00
|
|
|
unset($account_lids[$key]);
|
2011-03-16 17:50:28 +01:00
|
|
|
$skip = false;
|
|
|
|
continue;
|
|
|
|
}
|
2011-04-18 17:09:03 +02:00
|
|
|
$account_lid = trim($account_lid);
|
|
|
|
|
2011-03-15 00:42:24 +01:00
|
|
|
// Handle any IDs that slip in
|
|
|
|
if(is_numeric($account_lid) && $GLOBALS['egw']->accounts->id2name($account_lid)) {
|
2012-01-25 19:13:57 +01:00
|
|
|
unset($account_lids[$key]);
|
2011-03-15 00:42:24 +01:00
|
|
|
$account_ids[] = (int)$account_lid;
|
|
|
|
continue;
|
|
|
|
}
|
2011-03-16 17:50:28 +01:00
|
|
|
// Handle users listed as Lastname, Firstname instead of login ID
|
|
|
|
// Do this first, in case their first name matches a username
|
|
|
|
if ( $account_lids[$key+1][0] == ' ' && $account_id = $GLOBALS['egw']->accounts->name2id( trim($account_lids[$key+1]).' ' .$account_lid, 'account_fullname')) {
|
|
|
|
$account_ids[] = $account_id;
|
2012-01-25 19:13:57 +01:00
|
|
|
unset($account_lids[$key]);
|
2011-03-16 17:50:28 +01:00
|
|
|
$skip = true; // Skip the next one, it's the first name
|
|
|
|
continue ;
|
|
|
|
}
|
2006-11-10 16:30:01 +01:00
|
|
|
if ( $account_id = $GLOBALS['egw']->accounts->name2id( $account_lid )) {
|
|
|
|
$account_ids[] = $account_id;
|
2012-01-25 19:13:57 +01:00
|
|
|
unset($account_lids[$key]);
|
2011-03-15 01:01:23 +01:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if ( $account_id = $GLOBALS['egw']->accounts->name2id( $account_lid, 'account_fullname' )) {
|
|
|
|
$account_ids[] = $account_id;
|
2012-01-25 19:13:57 +01:00
|
|
|
unset($account_lids[$key]);
|
2011-03-15 01:01:23 +01:00
|
|
|
continue;
|
|
|
|
}
|
2011-11-21 10:50:02 +01:00
|
|
|
|
2011-03-15 01:01:23 +01:00
|
|
|
// Handle groups listed as Group, <name>
|
2013-01-08 17:14:37 +01:00
|
|
|
if ( $account_lids[$key][0] == ' ' && $account_id = $GLOBALS['egw']->accounts->name2id( $account_lid)) {
|
2011-03-15 01:01:23 +01:00
|
|
|
$account_ids[] = $account_id;
|
2012-01-25 19:13:57 +01:00
|
|
|
unset($account_lids[$key-1]);
|
|
|
|
unset($account_lids[$key]);
|
2013-01-08 17:14:37 +01:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
// Group, <name> - remove the Group part
|
|
|
|
if($account_lid == 'Group')
|
|
|
|
{
|
|
|
|
unset($account_lids[$key]);
|
|
|
|
continue;
|
2006-11-10 16:30:01 +01:00
|
|
|
}
|
|
|
|
}
|
2012-01-25 19:13:57 +01:00
|
|
|
$_account_lids = (is_array($_account_lids) ? $account_lids : implode(',',$account_lids));
|
2007-06-21 17:09:51 +02:00
|
|
|
return is_array( $_account_lids ) ? $account_ids : implode( ',', (array)$account_ids );
|
2010-04-03 12:31:57 +02:00
|
|
|
|
2006-11-10 16:30:01 +01:00
|
|
|
} // end of member function account_lid2id
|
|
|
|
|
|
|
|
/**
|
|
|
|
* converts account_ids to account_lids
|
|
|
|
*
|
2007-06-09 17:36:30 +02:00
|
|
|
* @param mixed $_account_ids comma seperated list or array with ids
|
|
|
|
* @return mixed comma seperated list or array with lids
|
2006-11-10 16:30:01 +01:00
|
|
|
*/
|
2007-06-09 17:36:30 +02:00
|
|
|
public static function account_id2name( $_account_id ) {
|
|
|
|
$account_ids = is_array( $_account_id ) ? $_account_id : explode( ',', $_account_id );
|
2006-11-10 16:30:01 +01:00
|
|
|
foreach ( $account_ids as $account_id ) {
|
|
|
|
if ( $account_lid = $GLOBALS['egw']->accounts->id2name( $account_id )) {
|
|
|
|
$account_lids[] = $account_lid;
|
|
|
|
}
|
|
|
|
}
|
2007-06-21 17:09:51 +02:00
|
|
|
return is_array( $_account_id ) ? $account_lids : implode( ',', (array)$account_lids );
|
2006-11-10 16:30:01 +01:00
|
|
|
} // end of member function account_id2lid
|
2010-04-03 12:31:57 +02:00
|
|
|
|
2006-11-10 16:30:01 +01:00
|
|
|
/**
|
|
|
|
* converts cat_id to a cat_name
|
|
|
|
*
|
2007-06-09 17:36:30 +02:00
|
|
|
* @param mixed _cat_ids comma seperated list or array
|
2010-04-03 12:31:57 +02:00
|
|
|
* @return mixed comma seperated list or array with cat_names
|
2006-11-10 16:30:01 +01:00
|
|
|
*/
|
|
|
|
public static function cat_id2name( $_cat_ids ) {
|
2007-06-09 17:36:30 +02:00
|
|
|
$cat_ids = is_array( $_cat_ids ) ? $_cat_ids : explode( ',', $_cat_ids );
|
2006-11-10 16:30:01 +01:00
|
|
|
foreach ( $cat_ids as $cat_id ) {
|
2010-04-03 12:31:57 +02:00
|
|
|
$cat_names[] = categories::id2name( (int)$cat_id );
|
2006-11-10 16:30:01 +01:00
|
|
|
}
|
2007-06-21 17:09:51 +02:00
|
|
|
return is_array( $_cat_ids ) ? $cat_names : implode(',',(array)$cat_names);
|
2006-11-10 16:30:01 +01:00
|
|
|
} // end of member function category_id2name
|
|
|
|
|
|
|
|
/**
|
|
|
|
* converts cat_name to a cat_id.
|
|
|
|
* If a cat isn't found, it will be created.
|
|
|
|
*
|
2007-06-09 17:36:30 +02:00
|
|
|
* @param mixed $_cat_names comma seperated list or array.
|
2011-03-17 00:29:42 +01:00
|
|
|
* @param int $parent Optional parent ID to use for new categories
|
2007-06-09 17:36:30 +02:00
|
|
|
* @return mixed comma seperated list or array with cat_ids
|
2006-11-10 16:30:01 +01:00
|
|
|
*/
|
2011-03-17 00:29:42 +01:00
|
|
|
public static function cat_name2id( $_cat_names, $parent = 0 ) {
|
2010-04-03 12:31:57 +02:00
|
|
|
$cats = new categories(); // uses current user and app (egw_info[flags][currentapp])
|
|
|
|
|
2007-06-09 17:36:30 +02:00
|
|
|
$cat_names = is_array( $_cat_names ) ? $_cat_names : explode( ',', $_cat_names );
|
2006-11-10 16:30:01 +01:00
|
|
|
foreach ( $cat_names as $cat_name ) {
|
2011-03-16 16:53:11 +01:00
|
|
|
$cat_name = trim($cat_name);
|
2007-08-30 17:46:31 +02:00
|
|
|
if ( $cat_name == '' ) continue;
|
2012-10-18 18:38:30 +02:00
|
|
|
if ( ( $cat_id = $cats->name2id( $cat_name ) ) == 0 && !self::$dry_run) {
|
2010-04-03 12:31:57 +02:00
|
|
|
$cat_id = $cats->add( array(
|
|
|
|
'name' => $cat_name,
|
2011-03-17 00:29:42 +01:00
|
|
|
'parent' => $parent,
|
2010-04-03 12:31:57 +02:00
|
|
|
'access' => 'public',
|
2007-06-21 16:02:03 +02:00
|
|
|
'descr' => $cat_name. ' ('. lang('Automatically created by importexport'). ')'
|
|
|
|
));
|
|
|
|
}
|
2006-11-10 16:30:01 +01:00
|
|
|
$cat_ids[] = $cat_id;
|
|
|
|
}
|
2007-06-21 17:09:51 +02:00
|
|
|
return is_array( $_cat_names ) ? $cat_ids : implode( ',', (array)$cat_ids );
|
2010-04-03 12:31:57 +02:00
|
|
|
|
2006-11-10 16:30:01 +01:00
|
|
|
} // end of member function category_name2id
|
|
|
|
|
|
|
|
/**
|
|
|
|
* conversion
|
2010-04-03 12:31:57 +02:00
|
|
|
*
|
|
|
|
* Conversions enable you to change / adapt the content of each _record field for your needs.
|
2006-11-10 16:30:01 +01:00
|
|
|
* General syntax is: pattern1 |> replacement1 || ... || patternN |> replacementN
|
2010-04-03 12:31:57 +02:00
|
|
|
* If the pattern-part of a pair is ommited it will match everything ('^.*$'), which
|
2006-11-10 16:30:01 +01:00
|
|
|
* is only usefull for the last pair, as they are worked from left to right.
|
|
|
|
* Example: 1|>private||public
|
|
|
|
* This will translate a '1' in the _record field to 'privat' and everything else to 'public'.
|
2010-04-03 12:31:57 +02:00
|
|
|
*
|
|
|
|
* In addintion to the fields assign by the pattern of the reg.exp.
|
2007-06-09 17:36:30 +02:00
|
|
|
* you can use all other _record fields, with the syntax |[FIELDINDEX].
|
2010-04-03 12:31:57 +02:00
|
|
|
* Example:
|
|
|
|
* Your record is:
|
2007-06-09 17:36:30 +02:00
|
|
|
* array( 0 => Company, 1 => NFamily, 2 => NGiven
|
2010-04-03 12:31:57 +02:00
|
|
|
* Your conversion string for field 0 (Company):
|
2007-06-09 17:36:30 +02:00
|
|
|
* .+|>|[0]: |[1], |[2]|||[1], |[2]
|
2010-04-03 12:31:57 +02:00
|
|
|
* This constructs something like
|
2007-06-09 17:36:30 +02:00
|
|
|
* Company: FamilyName, GivenName or FamilyName, GivenName if 'Company' is empty.
|
2010-04-03 12:31:57 +02:00
|
|
|
*
|
2011-08-06 00:04:05 +02:00
|
|
|
* Moreover the following helper functions can be used:
|
2010-04-03 12:31:57 +02:00
|
|
|
* cat(Cat1,...,CatN) returns a (','-separated) list with the cat_id's. If a
|
2006-11-10 16:30:01 +01:00
|
|
|
* category isn't found, it will be automaticaly added.
|
|
|
|
*
|
2011-08-06 00:04:05 +02:00
|
|
|
* account(name) returns an account ID, if found in the system
|
|
|
|
* list(sep, data, index) lets you explode a field on sep, then select just one part (index)
|
|
|
|
*
|
2010-04-03 12:31:57 +02:00
|
|
|
* Patterns as well as the replacement can be regular expressions (the replacement is done
|
2011-03-09 19:18:26 +01:00
|
|
|
* via str_replace).
|
2010-04-03 12:31:57 +02:00
|
|
|
*
|
2006-11-10 16:30:01 +01:00
|
|
|
* @param array _record reference with record to do the conversion with
|
|
|
|
* @param array _conversion array with conversion description
|
2010-10-07 00:33:52 +02:00
|
|
|
* @param object &$cclass calling class to process the '@ evals'
|
2006-11-10 16:30:01 +01:00
|
|
|
* @return bool
|
|
|
|
*/
|
2010-10-07 00:33:52 +02:00
|
|
|
public static function conversion( &$_record, $_conversion, &$_cclass = null ) {
|
2007-04-06 10:03:04 +02:00
|
|
|
if (empty( $_conversion ) ) return $_record;
|
2010-04-03 12:31:57 +02:00
|
|
|
|
2010-10-07 00:33:52 +02:00
|
|
|
self::$cclass =& $_cclass;
|
|
|
|
|
2006-11-10 16:30:01 +01:00
|
|
|
$PSep = '||'; // Pattern-Separator, separats the pattern-replacement-pairs in conversion
|
|
|
|
$ASep = '|>'; // Assignment-Separator, separats pattern and replacesment
|
2007-08-30 17:46:31 +02:00
|
|
|
$CPre = '|['; $CPos = ']'; // |[_record-idx] is expanded to the corespondig value
|
2007-06-25 22:47:38 +02:00
|
|
|
$TPre = '|T{'; $TPos = '}'; // |{_record-idx} is trimmed
|
2007-08-30 17:46:31 +02:00
|
|
|
$CntlPre = '|TC{'; // Filter all cntl-chars \x01-\x1f and trim
|
2007-06-25 22:47:38 +02:00
|
|
|
$CntlnCLPre = '|TCnCL{'; // Like |C{ but allowes CR and LF
|
2007-08-30 17:46:31 +02:00
|
|
|
$INE = '|INE{'; // Only insert if stuff in ^^ is not empty
|
2010-02-26 00:13:18 +01:00
|
|
|
|
2007-06-09 17:36:30 +02:00
|
|
|
foreach ( $_conversion as $idx => $conversion_string ) {
|
|
|
|
if ( empty( $conversion_string ) ) continue;
|
2010-04-03 12:31:57 +02:00
|
|
|
|
2007-06-09 17:36:30 +02:00
|
|
|
// fetch patterns ($rvalues)
|
|
|
|
$pat_reps = explode( $PSep, stripslashes( $conversion_string ) );
|
|
|
|
foreach( $pat_reps as $k => $pat_rep ) {
|
|
|
|
list( $pattern, $replace ) = explode( $ASep, $pat_rep, 2 );
|
|
|
|
if( $replace == '' ) {
|
|
|
|
$replace = $pattern; $pattern = '^.*$';
|
2006-11-10 16:30:01 +01:00
|
|
|
}
|
2007-06-09 17:36:30 +02:00
|
|
|
$rvalues[$pattern] = $replace; // replace two with only one, added by the form
|
2006-11-10 16:30:01 +01:00
|
|
|
}
|
2010-04-03 12:31:57 +02:00
|
|
|
|
2007-06-25 22:47:38 +02:00
|
|
|
// conversion list may be longer than $_record aka (no_csv)
|
2007-06-09 17:36:30 +02:00
|
|
|
$val = array_key_exists( $idx, $_record ) ? $_record[$idx] : '';
|
2006-11-10 16:30:01 +01:00
|
|
|
|
2011-08-06 00:04:05 +02:00
|
|
|
$c_functions = array('cat', 'account', 'strtotime', 'list');
|
2010-10-07 00:33:52 +02:00
|
|
|
if($_cclass) {
|
|
|
|
// Add in additional methods
|
|
|
|
$reflection = new ReflectionClass(get_class($_cclass));
|
|
|
|
$methods = $reflection->getMethods(ReflectionMethod::IS_STATIC);
|
|
|
|
foreach($methods as $method) {
|
|
|
|
$c_functions[] = $method->name;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$c_functions = implode('|', $c_functions);
|
2007-06-09 17:36:30 +02:00
|
|
|
foreach ( $rvalues as $pattern => $replace ) {
|
2011-03-09 19:18:26 +01:00
|
|
|
if( preg_match('/'. (string)$pattern.'/', $val) ) {
|
2010-04-03 12:31:57 +02:00
|
|
|
|
2011-03-09 19:18:26 +01:00
|
|
|
$val = preg_replace( '/'.(string)$pattern.'/', $replace, (string)$val );
|
2010-04-03 12:31:57 +02:00
|
|
|
|
2011-03-09 19:18:26 +01:00
|
|
|
$reg = '/\|\[([a-zA-Z_0-9]+)\]/';
|
|
|
|
while( preg_match( $reg, $val, $vars ) ) {
|
2007-06-09 17:36:30 +02:00
|
|
|
// expand all _record fields
|
|
|
|
$val = str_replace(
|
2010-04-03 12:31:57 +02:00
|
|
|
$CPre . $vars[1] . $CPos,
|
|
|
|
$_record[array_search($vars[1], array_keys($_record))],
|
2007-06-09 17:36:30 +02:00
|
|
|
$val
|
|
|
|
);
|
2006-11-10 16:30:01 +01:00
|
|
|
}
|
2010-10-07 00:33:52 +02:00
|
|
|
$val = preg_replace_callback( "/($c_functions)\(([^)]*)\)/i", array( self, 'c2_dispatcher') , $val );
|
2011-03-04 18:42:53 +01:00
|
|
|
break;
|
2006-11-10 16:30:01 +01:00
|
|
|
}
|
|
|
|
}
|
2007-06-25 22:47:38 +02:00
|
|
|
// clean each field
|
2007-08-30 17:46:31 +02:00
|
|
|
$val = preg_replace_callback("/(\|T\{|\|TC\{|\|TCnCL\{|\|INE\{)(.*)\}/", array( self, 'strclean'), $val );
|
2010-02-26 00:13:18 +01:00
|
|
|
|
2007-06-25 22:47:38 +02:00
|
|
|
$_record[$idx] = $val;
|
2006-11-10 16:30:01 +01:00
|
|
|
}
|
2007-06-25 22:47:38 +02:00
|
|
|
return $_record;
|
2006-11-10 16:30:01 +01:00
|
|
|
} // end of member function conversion
|
2010-04-03 12:31:57 +02:00
|
|
|
|
2007-06-09 17:36:30 +02:00
|
|
|
/**
|
|
|
|
* callback for preg_replace_callback from self::conversion.
|
2010-04-03 12:31:57 +02:00
|
|
|
* This function gets called when 2nd level conversions are made,
|
2007-06-09 17:36:30 +02:00
|
|
|
* like the cat() and account() statements in the conversions.
|
|
|
|
*
|
|
|
|
* @param array $_matches
|
|
|
|
*/
|
|
|
|
private static function c2_dispatcher( $_matches ) {
|
|
|
|
$action = &$_matches[1]; // cat or account ...
|
|
|
|
$data = &$_matches[2]; // datas for action
|
2010-04-03 12:31:57 +02:00
|
|
|
|
2007-06-23 14:07:18 +02:00
|
|
|
switch ( $action ) {
|
|
|
|
case 'strtotime' :
|
|
|
|
list( $string, $format ) = explode( ',', $data );
|
|
|
|
return self::custom_strtotime( trim( $string ), trim( $format ) );
|
2011-08-06 00:04:05 +02:00
|
|
|
case 'list':
|
|
|
|
list( $split, $data, $index) = explode(',',$data);
|
|
|
|
$exploded = explode($split, $data);
|
|
|
|
// 1 based indexing for user ease
|
|
|
|
return $exploded[$index - 1];
|
2007-06-23 14:07:18 +02:00
|
|
|
default :
|
2010-10-07 00:33:52 +02:00
|
|
|
if(self::$cclass && method_exists(self::$cclass, $action)) {
|
|
|
|
$class = get_class(self::$cclass);
|
|
|
|
return call_user_func("$class::$action", $data);
|
|
|
|
}
|
2007-06-23 14:07:18 +02:00
|
|
|
$method = (string)$action. ( is_int( $data ) ? '_id2name' : '_name2id' );
|
2010-10-07 00:33:52 +02:00
|
|
|
if(self::$cclass && method_exists(self::$cclass, $method)) {
|
|
|
|
$class = get_class(self::$cclass);
|
|
|
|
return call_user_func("$class::$action", $data);
|
|
|
|
} else {
|
|
|
|
return self::$method( $data );
|
|
|
|
}
|
2007-06-23 14:07:18 +02:00
|
|
|
}
|
2007-06-09 17:36:30 +02:00
|
|
|
}
|
2010-04-03 12:31:57 +02:00
|
|
|
|
2007-06-25 22:47:38 +02:00
|
|
|
private static function strclean( $_matches ) {
|
|
|
|
switch( $_matches[1] ) {
|
|
|
|
case '|T{' : return trim( $_matches[2] );
|
|
|
|
case '|TC{' : return trim( preg_replace( '/[\x01-\x1F]+/', '', $_matches[2] ) );
|
2007-08-30 17:46:31 +02:00
|
|
|
case '|TCnCL{' : return trim( preg_replace( '/[\x01-\x09\x11\x12\x14-\x1F]+/', '', $_matches[2] ) );
|
2010-04-03 12:31:57 +02:00
|
|
|
case '|INE{' : return preg_match( '/\^.+\^/', $_matches[2] ) ? $_matches[2] : '';
|
2007-06-25 22:47:38 +02:00
|
|
|
default:
|
|
|
|
throw new Exception('Error in conversion string! "'. substr( $_matches[1], 0, -1 ). '" is not valid!');
|
|
|
|
}
|
|
|
|
}
|
2010-04-03 12:31:57 +02:00
|
|
|
|
2006-11-10 16:30:01 +01:00
|
|
|
/**
|
2010-04-03 12:31:57 +02:00
|
|
|
* returns a list of importexport plugins
|
2006-11-10 16:30:01 +01:00
|
|
|
*
|
|
|
|
* @param string $_tpye {import | export | all}
|
|
|
|
* @param string $_appname {<appname> | all}
|
|
|
|
* @return array(<appname> => array( <type> => array(<plugin> => <title>)))
|
|
|
|
*/
|
2007-06-08 00:08:38 +02:00
|
|
|
public static function get_plugins( $_appname = 'all', $_type = 'all' ) {
|
2010-03-29 19:38:54 +02:00
|
|
|
$plugins = egw_cache::getTree(
|
2010-04-03 12:31:57 +02:00
|
|
|
__CLASS__,
|
|
|
|
'plugins',
|
|
|
|
array('importexport_helper_functions','_get_plugins'),
|
2010-03-29 19:38:54 +02:00
|
|
|
array(array_keys($GLOBALS['egw_info']['apps']), array('import', 'export')),
|
|
|
|
self::CACHE_EXPIRATION
|
|
|
|
);
|
2006-11-10 16:30:01 +01:00
|
|
|
$appnames = $_appname == 'all' ? array_keys($GLOBALS['egw_info']['apps']) : (array)$_appname;
|
2007-06-08 00:08:38 +02:00
|
|
|
$types = $_type == 'all' ? array('import','export') : (array)$_type;
|
2010-04-03 12:31:57 +02:00
|
|
|
|
2011-02-03 19:09:39 +01:00
|
|
|
// Testing: comment out egw_cache call, use this
|
|
|
|
//$plugins = self::_get_plugins($appnames, $types);
|
2011-01-28 20:44:24 +01:00
|
|
|
foreach($plugins as $appname => $_types) {
|
|
|
|
if(!in_array($appname, $appnames)) unset($plugins[$appname]);
|
2010-03-29 19:38:54 +02:00
|
|
|
}
|
|
|
|
foreach($plugins as $appname => $types) {
|
|
|
|
$plugins[$appname] = array_intersect_key($plugins[$appname], $types);
|
|
|
|
}
|
|
|
|
return $plugins;
|
|
|
|
}
|
|
|
|
|
2010-04-03 12:31:57 +02:00
|
|
|
public static function _get_plugins(Array $appnames, Array $types) {
|
2006-11-10 16:30:01 +01:00
|
|
|
$plugins = array();
|
|
|
|
foreach ($appnames as $appname) {
|
2010-03-29 19:38:54 +02:00
|
|
|
if(array_key_exists($appname, self::$blacklist_files) && self::$blacklist_files[$appname] === true) continue;
|
|
|
|
|
2010-03-22 16:09:26 +01:00
|
|
|
$appdir = EGW_INCLUDE_ROOT. "/$appname/inc";
|
2010-03-29 19:38:54 +02:00
|
|
|
if(!is_dir($appdir)) continue;
|
2006-11-10 16:30:01 +01:00
|
|
|
$d = dir($appdir);
|
2010-04-03 12:31:57 +02:00
|
|
|
|
2006-11-10 16:30:01 +01:00
|
|
|
// step through each file in appdir
|
|
|
|
while (false !== ($entry = $d->read())) {
|
2010-03-29 19:38:54 +02:00
|
|
|
// Blacklisted?
|
|
|
|
if(is_array(self::$blacklist_files[$appname]) && in_array($entry, self::$blacklist_files[$appname])) continue;
|
2011-11-21 10:50:02 +01:00
|
|
|
if (!preg_match('/^class\.([^.]+)\.inc\.php$/', $entry, $matches)) continue;
|
|
|
|
$classname = $matches[1];
|
2006-11-10 16:30:01 +01:00
|
|
|
$file = $appdir. '/'. $entry;
|
2010-04-03 12:31:57 +02:00
|
|
|
|
2006-11-10 16:30:01 +01:00
|
|
|
foreach ($types as $type) {
|
2012-09-18 21:04:31 +02:00
|
|
|
if( !is_file($file) || strpos($entry, $type) === false || strpos($entry,'wizard') !== false) continue;
|
2006-11-10 16:30:01 +01:00
|
|
|
require_once($file);
|
2010-03-22 16:09:26 +01:00
|
|
|
$reflectionClass = new ReflectionClass($classname);
|
2010-04-03 12:31:57 +02:00
|
|
|
if($reflectionClass->IsInstantiable() &&
|
2010-03-22 16:09:26 +01:00
|
|
|
$reflectionClass->implementsInterface('importexport_iface_'.$type.'_plugin')) {
|
|
|
|
try {
|
|
|
|
$plugin_object = new $classname;
|
|
|
|
}
|
|
|
|
catch (Exception $exception) {
|
|
|
|
continue;
|
|
|
|
}
|
2006-11-10 16:30:01 +01:00
|
|
|
$plugins[$appname][$type][$classname] = $plugin_object->get_name();
|
2010-03-22 16:09:26 +01:00
|
|
|
unset ($plugin_object);
|
2006-11-10 16:30:01 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$d->close();
|
2011-02-03 19:09:39 +01:00
|
|
|
|
2011-05-24 18:13:51 +02:00
|
|
|
$config = config::read('importexport');
|
|
|
|
if($config['update'] == 'auto') {
|
|
|
|
self::load_defaults($appname);
|
2011-02-03 19:09:39 +01:00
|
|
|
}
|
2006-11-10 16:30:01 +01:00
|
|
|
}
|
2007-06-08 00:08:38 +02:00
|
|
|
//error_log(__CLASS__.__FUNCTION__.print_r($plugins,true));
|
2010-04-03 12:31:57 +02:00
|
|
|
return $plugins;
|
2006-11-10 16:30:01 +01:00
|
|
|
}
|
2010-04-03 12:31:57 +02:00
|
|
|
|
2006-11-10 16:30:01 +01:00
|
|
|
/**
|
|
|
|
* returns list of apps which have plugins of given type.
|
|
|
|
*
|
|
|
|
* @param string $_type
|
|
|
|
* @return array $num => $appname
|
|
|
|
*/
|
2011-02-03 17:49:49 +01:00
|
|
|
public static function get_apps($_type, $ignore_acl = false) {
|
|
|
|
$apps = array_keys(self::get_plugins('all',$_type));
|
|
|
|
if($ignore_acl) return $apps;
|
|
|
|
|
|
|
|
foreach($apps as $key => $app) {
|
|
|
|
if(!self::has_definitions($app, $_type)) unset($apps[$key]);
|
|
|
|
}
|
|
|
|
return $apps;
|
2006-11-10 16:30:01 +01:00
|
|
|
}
|
|
|
|
|
2011-05-24 18:13:51 +02:00
|
|
|
public static function load_defaults($appname) {
|
|
|
|
// Check for new definitions to import from $appname/setup/*.xml
|
|
|
|
$appdir = EGW_INCLUDE_ROOT. "/$appname/setup";
|
|
|
|
if(!is_dir($appdir)) continue;
|
|
|
|
$d = dir($appdir);
|
|
|
|
|
|
|
|
// step through each file in app's setup
|
|
|
|
while (false !== ($entry = $d->read())) {
|
|
|
|
$file = $appdir. '/'. $entry;
|
|
|
|
list( $filename, $extension) = explode('.',$entry);
|
|
|
|
if ( $extension != 'xml' ) continue;
|
|
|
|
try {
|
|
|
|
// import will skip invalid files
|
|
|
|
importexport_definitions_bo::import( $file );
|
|
|
|
} catch (Exception $e) {
|
|
|
|
error_log(__CLASS__.__FUNCTION__. " import $appname definitions: " . $e->getMessage());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$d->close();
|
|
|
|
}
|
|
|
|
|
2007-06-08 00:08:38 +02:00
|
|
|
public static function guess_filetype( $_file ) {
|
2010-04-03 12:31:57 +02:00
|
|
|
|
2007-06-08 00:08:38 +02:00
|
|
|
}
|
2011-01-28 20:44:24 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* returns if the given app has importexport definitions for the current user
|
|
|
|
*
|
|
|
|
* @param string $_appname {<appname> | all}
|
|
|
|
* @param string $_type {import | export | all}
|
|
|
|
* @return boolean
|
|
|
|
*/
|
|
|
|
public static function has_definitions( $_appname = 'all', $_type = 'all' ) {
|
|
|
|
$definitions = egw_cache::getSession(
|
|
|
|
__CLASS__,
|
|
|
|
'has_definitions',
|
|
|
|
array('importexport_helper_functions','_has_definitions'),
|
|
|
|
array(array_keys($GLOBALS['egw_info']['apps']), array('import', 'export')),
|
|
|
|
self::CACHE_EXPIRATION
|
|
|
|
);
|
|
|
|
$appnames = $_appname == 'all' ? array_keys($GLOBALS['egw_info']['apps']) : (array)$_appname;
|
|
|
|
$types = $_type == 'all' ? array('import','export') : (array)$_type;
|
|
|
|
|
2011-04-11 17:21:10 +02:00
|
|
|
// Testing: Comment out cache call above, use this
|
|
|
|
//$definitions = self::_has_definitions($appnames, $types);
|
|
|
|
|
2011-01-28 20:44:24 +01:00
|
|
|
foreach($definitions as $appname => $_types) {
|
|
|
|
if(!in_array($appname, $appnames)) unset($definitions[$appname]);
|
|
|
|
}
|
|
|
|
foreach($definitions as $appname => $_types) {
|
|
|
|
$definitions[$appname] = array_intersect_key($definitions[$appname], array_flip($types));
|
|
|
|
}
|
|
|
|
return count($definitions[$appname]) > 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
// egw_cache needs this public
|
|
|
|
public static function _has_definitions(Array $appnames, Array $types) {
|
|
|
|
$def = new importexport_definitions_bo(array('application'=>$appnames, 'type' => $types));
|
|
|
|
$list = array();
|
2011-02-08 17:01:55 +01:00
|
|
|
foreach((array)$def->get_definitions() as $id) {
|
2011-02-10 21:45:32 +01:00
|
|
|
// Need to instanciate it to check, but if the user doesn't have permission, it throws an exception
|
|
|
|
try {
|
|
|
|
$definition = new importexport_definition($id);
|
|
|
|
if($def->is_permitted($definition->get_record_array())) {
|
2011-02-11 19:03:44 +01:00
|
|
|
$list[$definition->application][$definition->type][] = $id;
|
2011-02-10 21:45:32 +01:00
|
|
|
}
|
|
|
|
} catch (Exception $e) {
|
|
|
|
// That one doesn't work, keep going
|
2011-01-28 20:44:24 +01:00
|
|
|
}
|
|
|
|
$definition = null;
|
|
|
|
}
|
|
|
|
return $list;
|
|
|
|
}
|
2012-12-31 21:36:28 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Get a list of filterable fields, and options for those fields
|
|
|
|
*
|
|
|
|
* It tries to automatically pull filterable fields from the list of fields in the wizard,
|
|
|
|
* and sets widget properties. The plugin can edit / set the fields by implementing
|
|
|
|
* get_filter_fields(Array &$fields).
|
|
|
|
*
|
|
|
|
* Currently only supports select,select-cat,select-account,date,date-time
|
|
|
|
*
|
|
|
|
* @param $app_name String name of app
|
|
|
|
* @param $plugin_name Name of the plugin
|
|
|
|
*
|
|
|
|
* @return Array ([fieldname] => array(widget settings), ...)
|
|
|
|
*/
|
|
|
|
public static function get_filter_fields($app_name, $plugin_name, $wizard_plugin = null, $record_classname = null)
|
|
|
|
{
|
|
|
|
$fields = array();
|
|
|
|
try {
|
|
|
|
if($record_classname == null) $record_classname = $app_name . '_egw_record';
|
|
|
|
if(!class_exists($record_classname)) throw new Exception('Bad class name ' . $record_classname);
|
|
|
|
|
|
|
|
$plugin = is_object($plugin_name) ? $plugin_name : new $plugin_name();
|
|
|
|
$plugin_name = get_class($plugin);
|
|
|
|
|
|
|
|
if(!$wizard_plugin)
|
|
|
|
{
|
|
|
|
$wizard_name = $app_name . '_wizard_' . str_replace($app_name . '_', '', $plugin_name);
|
|
|
|
if(!class_exists($wizard_name)) throw new Exception('Bad wizard name ' . $wizard_name);
|
|
|
|
$wizard_plugin = new $wizard_name;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch (Exception $e)
|
|
|
|
{
|
|
|
|
error_log($e->getMessage());
|
|
|
|
return array();
|
|
|
|
}
|
|
|
|
|
|
|
|
// Get field -> label map and initialize fields using wizard field order
|
2013-01-23 18:44:03 +01:00
|
|
|
$fields = $export_fields = array();
|
|
|
|
if(method_exists($wizard_plugin, 'get_export_fields'))
|
|
|
|
{
|
|
|
|
$fields = $export_fields = $wizard_plugin->get_export_fields();
|
|
|
|
}
|
2012-12-31 21:36:28 +01:00
|
|
|
|
|
|
|
foreach($record_classname::$types as $type => $type_fields)
|
|
|
|
{
|
|
|
|
// Only these for now, until filter methods for others are figured out
|
|
|
|
if(!in_array($type, array('select','select-cat','select-account','date','date-time'))) continue;
|
|
|
|
foreach($type_fields as $field_name)
|
|
|
|
{
|
|
|
|
$fields[$field_name] = array(
|
|
|
|
'name' => $field_name,
|
|
|
|
'label' => $export_fields[$field_name] ? $export_fields[$field_name] : $field_name,
|
|
|
|
'type' => $type
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// Add custom fields
|
|
|
|
$custom = config::get_customfields($app_name);
|
|
|
|
foreach($custom as $field_name => $settings)
|
|
|
|
{
|
|
|
|
$settings['name'] = '#'.$field_name;
|
|
|
|
$fields['#'.$field_name] = $settings;
|
|
|
|
}
|
|
|
|
|
|
|
|
foreach($fields as $field_name => &$settings) {
|
|
|
|
// Can't really filter on these (or at least no generic, sane way figured out yet)
|
|
|
|
if(!is_array($settings) || in_array($settings['type'], array('text','button', 'label','url','url-email','url-phone','htmlarea')))
|
|
|
|
{
|
|
|
|
unset($fields[$field_name]);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if($settings['type'] == 'radio') $settings['type'] = 'select';
|
|
|
|
switch($settings['type'])
|
|
|
|
{
|
|
|
|
case 'checkbox':
|
|
|
|
// This isn't quite right - there's only 2 options and you can select both
|
|
|
|
$settings['type'] = 'select-bool';
|
|
|
|
$settings['rows'] = 1;
|
|
|
|
$settings['enhance'] = true;
|
|
|
|
break;
|
|
|
|
case 'select-cat':
|
|
|
|
$settings['rows'] = "5,,,$app_name";
|
|
|
|
$settings['enhance'] = true;
|
|
|
|
break;
|
|
|
|
case 'select-account':
|
|
|
|
$settings['rows'] = '5,both';
|
|
|
|
$settings['enhance'] = true;
|
|
|
|
break;
|
|
|
|
case 'select':
|
|
|
|
$settings['rows'] = 5;
|
|
|
|
$settings['enhance'] = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if(method_exists($plugin, 'get_filter_fields'))
|
|
|
|
{
|
|
|
|
$plugin->get_filter_fields($fields);
|
|
|
|
}
|
|
|
|
return $fields;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Parse a relative date (Yesterday) into absolute (2012-12-31) date
|
|
|
|
*
|
|
|
|
* @param $value String description of date matching $relative_dates
|
|
|
|
*
|
|
|
|
* @return Array([from] => timestamp, [to]=> timestamp), inclusive
|
|
|
|
*/
|
|
|
|
public static function date_rel2abs($value)
|
|
|
|
{
|
|
|
|
if(is_array($value))
|
|
|
|
{
|
|
|
|
$abs = array();
|
|
|
|
foreach($value as $key => $val)
|
|
|
|
{
|
|
|
|
$abs[$key] = self::date_rel2abs($val);
|
|
|
|
}
|
|
|
|
return $abs;
|
|
|
|
}
|
|
|
|
if($date = self::$relative_dates[$value])
|
|
|
|
{
|
|
|
|
$year = (int) date('Y');
|
|
|
|
$month = (int) date('m');
|
|
|
|
$day = (int) date('d');
|
|
|
|
$today = mktime(0,0,0,date('m'),date('d'),date('Y'));
|
|
|
|
|
|
|
|
list($syear,$smonth,$sday,$sweek,$eyear,$emonth,$eday,$eweek) = $date;
|
|
|
|
|
|
|
|
if(stripos($value, 'quarter') !== false)
|
|
|
|
{
|
|
|
|
// Handle quarters
|
|
|
|
$start = mktime(0,0,0,((int)floor(($smonth+$month) / 3.1)) * 3 + 1, 1, $year);
|
|
|
|
$end = mktime(0,0,0,((int)floor(($emonth+$month) / 3.1)+1) * 3 + 1, 1, $year);
|
|
|
|
}
|
|
|
|
elseif ($syear || $eyear)
|
|
|
|
{
|
|
|
|
$start = mktime(0,0,0,1,1,$syear+$year);
|
|
|
|
$end = mktime(0,0,0,1,1,$eyear+$year);
|
|
|
|
}
|
|
|
|
elseif ($smonth || $emonth)
|
|
|
|
{
|
|
|
|
$start = mktime(0,0,0,$smonth+$month,1,$year);
|
|
|
|
$end = mktime(0,0,0,$emonth+$month,1,$year);
|
|
|
|
}
|
|
|
|
elseif ($sday || $eday)
|
|
|
|
{
|
|
|
|
$start = mktime(0,0,0,$month,$sday+$day,$year);
|
|
|
|
$end = mktime(0,0,0,$month,$eday+$day,$year);
|
|
|
|
}
|
|
|
|
elseif ($sweek || $eweek)
|
|
|
|
{
|
|
|
|
$wday = (int) date('w'); // 0=sun, ..., 6=sat
|
|
|
|
switch($GLOBALS['egw_info']['user']['preferences']['calendar']['weekdaystarts'])
|
|
|
|
{
|
|
|
|
case 'Sunday':
|
|
|
|
$weekstart = $today - $wday * 24*60*60;
|
|
|
|
break;
|
|
|
|
case 'Saturday':
|
|
|
|
$weekstart = $today - (6-$wday) * 24*60*60;
|
|
|
|
break;
|
|
|
|
case 'Moday':
|
|
|
|
default:
|
|
|
|
$weekstart = $today - ($wday ? $wday-1 : 6) * 24*60*60;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
$start = $weekstart + $sweek*7*24*60*60;
|
|
|
|
$end = $weekstart + $eweek*7*24*60*60;
|
|
|
|
}
|
|
|
|
$end_param = $end - 24*60*60;
|
|
|
|
|
|
|
|
// Take 1 second off end to provide an inclusive range.for filtering
|
|
|
|
$end -= 1;
|
|
|
|
|
|
|
|
//echo __METHOD__."($value,$start,$end) today=".date('l, Y-m-d H:i',$today)." ==> <br />".date('l, Y-m-d H:i:s',$start)." <= date <= ".date('l, Y-m-d H:i:s',$end)."</p>\n";
|
|
|
|
return array('from' => $start, 'to' => $end);
|
|
|
|
}
|
|
|
|
return null;
|
|
|
|
}
|
2010-03-29 19:38:54 +02:00
|
|
|
} // end of importexport_helper_functions
|