diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index bba94b3f1bb..2dfa39b3165 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -15648,8 +15648,10 @@ function readfileLowMemory($fullpath_original_file_osencoded, $method = -1) } // Be sure we don't have output buffering enabled to have readfile working correctly - while (ob_get_level()) { - ob_end_flush(); + $level = ob_get_level(); + ob_start(); + while (ob_get_level() > $level) { + ob_end_clean(); } // Solution 0 diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index bba715cd45d..62d084c93e1 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -1035,7 +1035,7 @@ Permission2515=Setup documents directories Permission2610=Generate/modify users API key Permission2801=Use FTP client in read mode (browse and download only) Permission2802=Use FTP client in write mode (delete or upload files) -Permission3201=Read Unalterable Logs and signature +Permission3201=Read, Export and Control Immutable Logs and signature Permission3301=Generate new modules Permission4001=Read skill/job/position Permission4002=Create/modify skill/job/position diff --git a/htdocs/projet/class/api_tasks.class.php b/htdocs/projet/class/api_tasks.class.php index 914148ffeeb..614a661da33 100644 --- a/htdocs/projet/class/api_tasks.class.php +++ b/htdocs/projet/class/api_tasks.class.php @@ -5,6 +5,7 @@ * Copyright (C) 2025 MDW * Copyright (C) 2025 Jessica Kowal * Copyright (C) 2025 Charlene Benke + * Copyright (C) 2026 William Mead * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -106,17 +107,18 @@ class Tasks extends DolibarrApi * * @since 5.0.0 Initial implementation * - * @param string $sortfield Sort field - * @param string $sortorder Sort order - * @param int $limit Limit for list - * @param int $page Page number - * @param string $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.ref:like:'SO-%') and (t.date_creation:<:'20160101')" - * @param string $properties Restrict the data returned to these properties. Ignored if empty. Comma separated list of properties names - * @return array Array of project objects + * @param string $sortfield Sort field + * @param string $sortorder Sort order + * @param int $limit Limit for list + * @param int $page Page number + * @param string $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.ref:like:'SO-%') and (t.date_creation:<:'20160101')" + * @param string $properties Restrict the data returned to these properties. Ignored if empty. Comma separated list of properties names + * @param bool $pagination_data If this parameter is set to true the response will include pagination data. Default value is false. Page starts from 0 + * @return array Array of project objects * @phan-return Task[] * @phpstan-return Task[] */ - public function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $sqlfilters = '', $properties = '') + public function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $sqlfilters = '', $properties = '', $pagination_data = false) { global $db, $conf; @@ -160,6 +162,9 @@ class Tasks extends DolibarrApi } } + //this query will return total tasks with the filters given + $sqlTotals = str_replace('SELECT t.rowid', 'SELECT count(t.rowid) as total', $sql); + $sql .= $this->db->order($sortfield, $sortorder); if ($limit) { if ($page < 0) { @@ -189,6 +194,23 @@ class Tasks extends DolibarrApi throw new RestException(503, 'Error when retrieve task list : ' . $this->db->lasterror()); } + //if $pagination_data is true the response will contain element data with all values and element pagination with pagination data(total,page,limit) + if ($pagination_data) { + $totalsResult = $this->db->query($sqlTotals); + $total = $this->db->fetch_object($totalsResult)->total; + + $tmp = $obj_ret; + $obj_ret = []; + + $obj_ret['data'] = $tmp; + $obj_ret['pagination'] = [ + 'total' => (int) $total, + 'page' => $page, //count starts from 0 + 'page_count' => ceil((int) $total / $limit), + 'limit' => $limit + ]; + } + return $obj_ret; } diff --git a/htdocs/public/stripe/ipn.php b/htdocs/public/stripe/ipn.php index d8a88530bbd..839a67edc22 100644 --- a/htdocs/public/stripe/ipn.php +++ b/htdocs/public/stripe/ipn.php @@ -191,6 +191,18 @@ dol_syslog("***** Stripe IPN was called with event->type=".$event->type." servic sleep(2); +// Hook to allow external modules to handle Stripe webhook events +$hookmanager = new HookManager($db); +$hookmanager->initHooks(array('stripeipn')); +$parameters = array('event' => $event, 'servicestatus' => $servicestatus, 'service' => $service); +$reshook = $hookmanager->executeHooks('stripeWebhookEvent', $parameters, $event->data->object, $event->type); +if ($reshook > 0) { + // A hook handled the event entirely, stop processing + http_response_code(200); + return; +} + + if ($event->type == 'payout.created' && getDolGlobalString('STRIPE_AUTO_RECORD_PAYOUT')) { // When a payout is created by Stripe to transfer money to your account dol_syslog("object = ".formatLogObject($event->data));