- two new parameters to search(): cols and append

- docu update
This commit is contained in:
Ralf Becker 2009-05-05 12:49:15 +00:00
parent 7bc380fab9
commit 065e1dde5a

View File

@ -97,7 +97,7 @@ class infolog_so
/**
* checks if user has the $required_rights to access $info_id (private access is handled too)
*
* @param array/int $info data or info_id of InfoLog entry
* @param array|int $info data or info_id of InfoLog entry
* @param int $required_rights EGW_ACL_xyz anded together
* @param boolean $implicit_edit=false responsible has only implicit read and add rigths, unless this is set to true
* @return boolean True if access is granted else False
@ -339,8 +339,8 @@ class infolog_so
*
* some cacheing is done to prevent multiple reads of the same entry
*
* @param $info_id id or uid of entry
* @return array/boolean the entry as array or False on error (eg. entry not found)
* @param int|string $info_id id or uid of entry
* @return array|boolean the entry as array or False on error (eg. entry not found)
*/
function read($info_id) // did _not_ ensure ACL
{
@ -399,7 +399,7 @@ class infolog_so
* delete InfoLog entry $info_id AND the links to it
*
* @param int $info_id id of log-entry
* @param bool $delete_children delete the children, if not set there parent-id to $new_parent
* @param boolean $delete_children delete the children, if not set there parent-id to $new_parent
* @param int $new_parent new parent-id to set for subs
*/
function delete($info_id,$delete_children=True,$new_parent=0) // did _not_ ensure ACL
@ -495,7 +495,7 @@ class infolog_so
*
* @param array $values with the data of the log-entry
* @param int $check_modified=0 old modification date to check before update (include in WHERE)
* @return int/boolean info_id, false on error or 0 if the entry has been updated in the meantime
* @return int|boolean info_id, false on error or 0 if the entry has been updated in the meantime
*/
function write($values,$check_modified=0) // did _not_ ensure ACL
{
@ -616,17 +616,19 @@ class infolog_so
/**
* searches InfoLog for a certain pattern in $query
*
* @param $query[order] column-name to sort after
* @param $query[sort] sort-order DESC or ASC
* @param $query[filter] string with combination of acl-, date- and status-filters, eg. 'own-open-today' or ''
* @param $query[cat_id] category to use or 0 or unset
* @param $query[search] pattern to search, search is done in info_from, info_subject and info_des
* @param $query[action] / $query[action_id] if only entries linked to a specified app/entry show be used
* @param &$query[start], &$query[total] nextmatch-parameters will be used and set if query returns less entries
* @param $query[col_filter] array with column-name - data pairs, data == '' means no filter (!)
* @param $query[subs] boolean return subs or not, if unset the user preference is used
* @param $query[num_rows] number of rows to return if $query[start] is set, default is to use the value from the general prefs
* @return array with id's as key of the matching log-entries
* @param string $query[order] column-name to sort after
* @param string $query[sort] sort-order DESC or ASC
* @param string $query[filter] string with combination of acl-, date- and status-filters, eg. 'own-open-today' or ''
* @param int $query[cat_id] category to use or 0 or unset
* @param string $query[search] pattern to search, search is done in info_from, info_subject and info_des
* @param string $query[action] / $query[action_id] if only entries linked to a specified app/entry show be used
* @param int &$query[start], &$query[total] nextmatch-parameters will be used and set if query returns less entries
* @param array $query[col_filter] array with column-name - data pairs, data == '' means no filter (!)
* @param boolean $query[subs] return subs or not, if unset the user preference is used
* @param int $query[num_rows] number of rows to return if $query[start] is set, default is to use the value from the general prefs
* @param string|array $query[cols]=null what to query, if set the recordset / iterator get's returned
* @param string $query[append]=null get's appended to sql query, eg. for GROUP BY
* @return array|iterator with id's as key of the matching log-entries or recordset/iterator if cols is set
*/
function search(&$query)
{
@ -661,7 +663,9 @@ class infolog_so
}
else
{
$val = (substr($val,0,5) != 'info_' ? 'info_' : '').$val;
static $table_def;
if (is_null($table_def)) $table_def = $this->db->get_table_definitions('infolog',$this->info_table);
if (substr($val,0,5) != 'info_' && isset($table_def['fd']['info_'.$val])) $val = 'info_'.$val;
if ($val == 'info_des' && $this->db->capabilities['order_on_text'] !== true)
{
if (!$this->db->capabilities['order_on_text']) continue;
@ -685,6 +689,11 @@ class infolog_so
{
foreach($query['col_filter'] as $col => $data)
{
if (is_int($col))
{
$filtermethod .= ' AND '.$data;
continue;
}
if (substr($col,0,5) != 'info_' && substr($col,0,1)!='#') $col = 'info_'.$col;
if (!empty($data) && preg_match('/^[a-z_0-9]+$/i',$col))
{
@ -788,7 +797,9 @@ class infolog_so
{
$query['start'] = 0;
}
$rs = $this->db->query($sql="SELECT $mysql_calc_rows $distinct main.* $info_customfield $sql_query $ordermethod",__LINE__,__FILE__,
$cols = isset($query['cols']) ? $query['cols'] : 'main.*';
if (is_array($cols)) $cols = implode(',',$cols);
$rs = $this->db->query($sql='SELECT '.$mysql_calc_rows.' '.$distinct.' '.$cols.' '.$info_customfield.' '.$sql_query.$query['append'].' '.$ordermethod,__LINE__,__FILE__,
(int) $query['start'],isset($query['start']) ? (int) $query['num_rows'] : -1,false,egw_db::FETCH_ASSOC);
//echo "<p>db::query('$sql',,,".(int)$query['start'].','.(isset($query['start']) ? (int) $query['num_rows'] : -1).")</p>\n";
@ -800,6 +811,10 @@ class infolog_so
// check if start is behind total --> loop to set start=0
while (isset($query['start']) && $query['start'] > $query['total']);
if (isset($query['cols']))
{
return $rs;
}
foreach($rs as $info)
{
$info['info_responsible'] = $info['info_responsible'] ? explode(',',$info['info_responsible']) : array();