From baa28076064227a26a29e31e60b1073665d4b50d Mon Sep 17 00:00:00 2001 From: Ralf Becker Date: Tue, 12 Jun 2018 19:04:02 +0200 Subject: [PATCH] some hooks needed for new policy app --- api/src/Contacts/Storage.php | 11 +++++++++ api/src/Etemplate/Widget/Nextmatch.php | 31 ++++++++++++++++++-------- api/src/Storage/History.php | 18 ++++++++------- 3 files changed, 43 insertions(+), 17 deletions(-) diff --git a/api/src/Contacts/Storage.php b/api/src/Contacts/Storage.php index 78c7ba8a32..3d8ce9ab2c 100755 --- a/api/src/Contacts/Storage.php +++ b/api/src/Contacts/Storage.php @@ -748,6 +748,17 @@ class Storage { $rows[$n] = $this->db2data($row); } + + // allow other apps to hook into search + Api\Hooks::process(array( + 'hook_location' => 'contacts_search', + 'criteria' => $criteria, + 'filter' => $filter, + 'ignore_acl' => $ignore_acl, + 'obj' => $this, + 'rows' => &$rows, + 'total' => &$this->total, + ), array(), true); // true = no permission check } return $rows; } diff --git a/api/src/Etemplate/Widget/Nextmatch.php b/api/src/Etemplate/Widget/Nextmatch.php index ae25e21121..7688be956b 100644 --- a/api/src/Etemplate/Widget/Nextmatch.php +++ b/api/src/Etemplate/Widget/Nextmatch.php @@ -7,8 +7,7 @@ * @subpackage etemplate * @link http://www.egroupware.org * @author Ralf Becker - * @copyright 2002-16 by RalfBecker@outdoor-training.de - * @version $Id$ + * @copyright 2002-18 by RalfBecker@outdoor-training.de */ namespace EGroupware\Api\Etemplate\Widget; @@ -608,6 +607,17 @@ class Nextmatch extends Etemplate\Widget { $total = false; // method not callable } + + // allow to hook into get_rows of other apps + Api\Hooks::process(array( + 'hook_location' => 'etemplate2_after_get_rows', + 'get_rows' => $method, + 'value' => &$value, + 'rows' => &$rows, + 'readonlys' => &$readonlys, + 'total' => &$total, + ), array(), true); // true = no permission check + // if we have a nextmatch widget, find the repeating row if ($widget && $widget->attrs['template']) { @@ -848,17 +858,20 @@ class Nextmatch extends Etemplate\Widget //echo "*** Inserting id=$prefix$id"; _debug_array($action); // we break at end of foreach loop, as rest of actions is already dealt with // by putting them as children - - // sets the default attributes to every children dataset - if (is_array($action['children'])) { - foreach ($action['children'] as $key => $children) { + + // sets the default attributes to every children dataset + if (is_array($action['children'])) + { + foreach ($action['children'] as $key => $children) + { // checks if children is a valid array and if the "$default_attrs" variable exists - if (is_array($action['children'][$key]) && $default_attrs) { + if (is_array($children) && $default_attrs) + { $action['children'][$key] += $default_attrs; } } - } - } + } + } // add all first level popup actions plus ones with enabled = 'javaScript:...' to action_links if ((!isset($action['type']) || in_array($action['type'],array('popup','drag','drop'))) && // popup is the default diff --git a/api/src/Storage/History.php b/api/src/Storage/History.php index 1291bd8ae6..f3be3807d1 100644 --- a/api/src/Storage/History.php +++ b/api/src/Storage/History.php @@ -195,14 +195,7 @@ class History $filter[$column] = $value; } } - if ($GLOBALS['egw']->db->Type == 'mysql' && $GLOBALS['egw']->db->ServerInfo['version'] >= 4.0) - { - $mysql_calc_rows = 'SQL_CALC_FOUND_ROWS '; - } - else - { - $total = $GLOBALS['egw']->db->select(self::TABLE,'COUNT(*)',$filter,__LINE__,__FILE__,false,'','phpgwapi',0)->fetchColumn(); - } + // filter out private (or no longer defined) custom fields if ($filter['history_appname']) { @@ -293,6 +286,15 @@ class History } $total = $GLOBALS['egw']->db->union($_query,__LINE__,__FILE__)->NumRows(); + // allow to hook into get_rows of other apps + Api\Hooks::process(array( + 'hook_location' => 'etemplate2_history_get_rows', + 'get_rows' => __METHOD__, + 'value' => &$query, + 'rows' => &$rows, + 'total' => &$total, + ), array(), true); // true = no permission check + return $total; } }