mirror of
https://codeberg.org/artfulrobot/contactcats.git
synced 2025-06-26 14:47:17 +02:00
Support updating a single contact
This commit is contained in:
parent
8d0a9d0926
commit
016ca2a735
2 changed files with 37 additions and 9 deletions
|
@ -13,6 +13,15 @@ use Civi\ContactCats\Processor;
|
|||
*/
|
||||
class Sync extends \Civi\Api4\Generic\AbstractAction {
|
||||
|
||||
/**
|
||||
* Contact ID
|
||||
*
|
||||
* Force sync for given contact only.
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
protected $contact_id;
|
||||
|
||||
/**
|
||||
* Usually this will not act unless the time is right.
|
||||
*
|
||||
|
@ -24,7 +33,8 @@ class Sync extends \Civi\Api4\Generic\AbstractAction {
|
|||
public function _run(Result $result) {
|
||||
ini_set('memory_limit', '256M');
|
||||
Civi::log()->debug('Begin', ['=start' => 'ContactCatSync', '=timed' => 1]);
|
||||
if (!$this->force) {
|
||||
|
||||
if (!$this->force && !$this->contact_id) {
|
||||
$nextRun = Civi::settings()->get('contactcats_next_run') ?? 0;
|
||||
if (time() < $nextRun) {
|
||||
// not needed yet.
|
||||
|
@ -33,7 +43,7 @@ class Sync extends \Civi\Api4\Generic\AbstractAction {
|
|||
}
|
||||
}
|
||||
|
||||
$processor = new Processor();
|
||||
$processor = new Processor($this->contact_id);
|
||||
$result->exchangeArray($processor->run());
|
||||
|
||||
// Limit to running every 24 hours; we actually want it to be stable within one day.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue