From 30be48f6e60d8eaf2d91edb5f4f7e2023ab123c2 Mon Sep 17 00:00:00 2001 From: Nathan Gray Date: Tue, 8 Dec 2009 23:18:51 +0000 Subject: [PATCH] Implement options so link_query() can be limited --- timesheet/inc/class.timesheet_bo.inc.php | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/timesheet/inc/class.timesheet_bo.inc.php b/timesheet/inc/class.timesheet_bo.inc.php index d919f6b77c..48d6b444bb 100644 --- a/timesheet/inc/class.timesheet_bo.inc.php +++ b/timesheet/inc/class.timesheet_bo.inc.php @@ -666,20 +666,28 @@ class timesheet_bo extends so_sql_cf * Is called as hook to participate in the linking * * @param string $pattern pattern to search + * @param array $options Array of options for the search * @return array with ts_id - title pairs of the matching entries */ - function link_query( $pattern ) + function link_query( $pattern, Array &$options = array() ) { $criteria = array(); + $limit = false; + $need_count = false; foreach(array('ts_project','ts_title','ts_description') as $col) { $criteria[$col] = $pattern; } + if($options['start'] || $options['num_rows']) { + $limit = array($options['start'], $options['num_rows']); + $need_count = true; + } $result = array(); - foreach((array) $this->search($criteria,false,'','','%',false,'OR') as $ts ) + foreach((array) $this->search($criteria,false,'','','%',false,'OR', $limit, null, '', $need_count) as $ts ) { if ($ts) $result[$ts['ts_id']] = $this->link_title($ts); } + $options['total'] = $need_count ? $this->total : count($result); return $result; } @@ -741,4 +749,4 @@ class timesheet_bo extends so_sql_cf } return array(); } -} \ No newline at end of file +}