From 4df87611ace067f6c2696b437de626e38a441ff5 Mon Sep 17 00:00:00 2001 From: DaPikk Date: Tue, 1 Jul 2025 09:54:32 +0000 Subject: [PATCH 1/7] Event type Ack and POll support for Toolkit --- opensrs/RequestFactory.php | 5 +++- opensrs/event/PollAck.php | 52 +++++++++++++++++++++++++++++++++++++ opensrs/event/PollEvent.php | 50 +++++++++++++++++++++++++++++++++++ 3 files changed, 106 insertions(+), 1 deletion(-) create mode 100644 opensrs/event/PollAck.php create mode 100644 opensrs/event/PollEvent.php diff --git a/opensrs/RequestFactory.php b/opensrs/RequestFactory.php index f4984eb8..13dd49b7 100644 --- a/opensrs/RequestFactory.php +++ b/opensrs/RequestFactory.php @@ -131,7 +131,10 @@ class RequestFactory 'mailsetdomainblocklist' => 'mail\SetDomainBlockList', 'mailsetdomaindisabledstatus' => 'mail\SetDomainDisabledStatus', 'mailsetdomainmailboxlimits' => 'mail\SetDomainMailboxLimits', - 'accountgetbalance' => 'account\GetBalance' + 'accountgetbalance' => 'account\GetBalance', + // EVENT polling commands + 'eventpoll' => 'event\PollEvent', + 'eventack' => 'event\PollAck', ); public static function build($func, $type, $dataObject) diff --git a/opensrs/event/PollAck.php b/opensrs/event/PollAck.php new file mode 100644 index 00000000..e08c25f4 --- /dev/null +++ b/opensrs/event/PollAck.php @@ -0,0 +1,52 @@ +_formatHolder = $formatString; + $this->_validateObject($dataObject); + + $cookie = null; + if (isset($dataObject->data->cookie)) { + $cookie = $dataObject->data->cookie; + } elseif (isset($dataObject->cookie)) { + $cookie = $dataObject->cookie; + } + + if (empty($cookie)) { + throw new \Exception("PollAck requires 'cookie' parameter"); + } + + $cmd = array( + 'protocol' => 'XCP', + 'action' => $this->action, + 'object' => $this->object, + 'attributes' => array( + 'cookie' => $cookie + ) + ); + + $this->send($cmd, $returnFullResponse); + } + + public function __destruct() + { + parent::__destruct(); + } +} diff --git a/opensrs/event/PollEvent.php b/opensrs/event/PollEvent.php new file mode 100644 index 00000000..3b995cc8 --- /dev/null +++ b/opensrs/event/PollEvent.php @@ -0,0 +1,50 @@ +_formatHolder = $formatString; + $this->_validateObject($dataObject); + + $limit = null; + if (isset($dataObject->data->poll_limit)) { + $limit = (int)$dataObject->data->poll_limit; + } elseif (isset($dataObject->poll_limit)) { + $limit = (int)$dataObject->poll_limit; + } + + $cmd = array( + 'protocol' => 'XCP', + 'action' => $this->action, + 'object' => $this->object, + 'attributes' => array() + ); + + if (!is_null($limit)) { + $cmd['attributes']['limit'] = $limit; + } + + $this->send($cmd, $returnFullResponse); + } + + public function __destruct() + { + parent::__destruct(); + } +} From 184da5db945da0fb02221ef571f6c301513a4f77 Mon Sep 17 00:00:00 2001 From: DaPikk Date: Tue, 1 Jul 2025 17:09:15 +0300 Subject: [PATCH 2/7] Update PollAck.php --- opensrs/event/PollAck.php | 32 +++++++++----------------------- 1 file changed, 9 insertions(+), 23 deletions(-) diff --git a/opensrs/event/PollAck.php b/opensrs/event/PollAck.php index e08c25f4..1e55baf9 100644 --- a/opensrs/event/PollAck.php +++ b/opensrs/event/PollAck.php @@ -6,14 +6,20 @@ class PollAck extends Base { - public $action = 'poll'; - public $object = 'ack'; + public $action = 'ack'; + public $object = 'event'; public $_formatHolder = ''; public $resultFullRaw; public $resultRaw; public $resultFullFormatted; public $resultFormatted; + + public $requiredFields = array( + 'attributes' => array( + 'event_id' + ) + ); public function __construct($formatString, $dataObject, $returnFullResponse = true) { @@ -22,27 +28,7 @@ public function __construct($formatString, $dataObject, $returnFullResponse = tr $this->_formatHolder = $formatString; $this->_validateObject($dataObject); - $cookie = null; - if (isset($dataObject->data->cookie)) { - $cookie = $dataObject->data->cookie; - } elseif (isset($dataObject->cookie)) { - $cookie = $dataObject->cookie; - } - - if (empty($cookie)) { - throw new \Exception("PollAck requires 'cookie' parameter"); - } - - $cmd = array( - 'protocol' => 'XCP', - 'action' => $this->action, - 'object' => $this->object, - 'attributes' => array( - 'cookie' => $cookie - ) - ); - - $this->send($cmd, $returnFullResponse); + $this->send($dataObject, $returnFullResponse); } public function __destruct() From b1358449dd9be3368036f2c16c870f3f63bd6740 Mon Sep 17 00:00:00 2001 From: DaPikk Date: Tue, 1 Jul 2025 17:09:41 +0300 Subject: [PATCH 3/7] Update PollEvent.php --- opensrs/event/PollEvent.php | 20 +------------------- 1 file changed, 1 insertion(+), 19 deletions(-) diff --git a/opensrs/event/PollEvent.php b/opensrs/event/PollEvent.php index 3b995cc8..3600d114 100644 --- a/opensrs/event/PollEvent.php +++ b/opensrs/event/PollEvent.php @@ -22,25 +22,7 @@ public function __construct($formatString, $dataObject, $returnFullResponse = tr $this->_formatHolder = $formatString; $this->_validateObject($dataObject); - $limit = null; - if (isset($dataObject->data->poll_limit)) { - $limit = (int)$dataObject->data->poll_limit; - } elseif (isset($dataObject->poll_limit)) { - $limit = (int)$dataObject->poll_limit; - } - - $cmd = array( - 'protocol' => 'XCP', - 'action' => $this->action, - 'object' => $this->object, - 'attributes' => array() - ); - - if (!is_null($limit)) { - $cmd['attributes']['limit'] = $limit; - } - - $this->send($cmd, $returnFullResponse); + $this->send($dataObject, $returnFullResponse); } public function __destruct() From 97797e0debfaa0aad41b0ec836ca0aecf3315810 Mon Sep 17 00:00:00 2001 From: DaPikk Date: Tue, 1 Jul 2025 17:10:23 +0300 Subject: [PATCH 4/7] Create PollAck.php --- .../dataconversion/event/PollAck.php | 44 +++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 opensrs/backwardcompatibility/dataconversion/event/PollAck.php diff --git a/opensrs/backwardcompatibility/dataconversion/event/PollAck.php b/opensrs/backwardcompatibility/dataconversion/event/PollAck.php new file mode 100644 index 00000000..412a5f64 --- /dev/null +++ b/opensrs/backwardcompatibility/dataconversion/event/PollAck.php @@ -0,0 +1,44 @@ + 'data->cookie' + // this will map ->data->cookie in the + // original object to ->cookie in the + // new format + // + // example 2: + // ['attributes']['domain'] = 'data->domain' + // this will map ->data->domain in the original + // to ->attributes->domain in the new format + protected $newStructure = array( + 'attributes' => array( + 'event_id' => 'data->event_id', + ), + ); + + public function convertDataObject($dataObject, $newStructure = null) + { + $p = new parent(); + + if (is_null($newStructure)) { + $newStructure = $this->newStructure; + } + + $newDataObject = $p->convertDataObject($dataObject, $newStructure); + + return $newDataObject; + } +} From e5d9f94b591fd78c99575c25cbbd00d5d289ec79 Mon Sep 17 00:00:00 2001 From: DaPikk Date: Tue, 1 Jul 2025 17:10:57 +0300 Subject: [PATCH 5/7] Create PollEvent.php --- .../dataconversion/event/PollEvent.php | 44 +++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 opensrs/backwardcompatibility/dataconversion/event/PollEvent.php diff --git a/opensrs/backwardcompatibility/dataconversion/event/PollEvent.php b/opensrs/backwardcompatibility/dataconversion/event/PollEvent.php new file mode 100644 index 00000000..7a0055f4 --- /dev/null +++ b/opensrs/backwardcompatibility/dataconversion/event/PollEvent.php @@ -0,0 +1,44 @@ + 'data->cookie' + // this will map ->data->cookie in the + // original object to ->cookie in the + // new format + // + // example 2: + // ['attributes']['domain'] = 'data->domain' + // this will map ->data->domain in the original + // to ->attributes->domain in the new format + protected $newStructure = array( + 'attributes' => array( + 'limit' => 'data->poll_limit', + ), + ); + + public function convertDataObject($dataObject, $newStructure = null) + { + $p = new parent(); + + if (is_null($newStructure)) { + $newStructure = $this->newStructure; + } + + $newDataObject = $p->convertDataObject($dataObject, $newStructure); + + return $newDataObject; + } +} From e2677e5237b23b315bd891436905713a2b01e1c7 Mon Sep 17 00:00:00 2001 From: DaPikk Date: Tue, 15 Jul 2025 20:12:59 +0300 Subject: [PATCH 6/7] Update Ops.php MSG ID Fix --- opensrs/Ops.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/opensrs/Ops.php b/opensrs/Ops.php index 09625c19..56598afc 100644 --- a/opensrs/Ops.php +++ b/opensrs/Ops.php @@ -193,7 +193,7 @@ public function XML2PHP($msg) public function encode($array) { ++$this->_MSGCNT; - $msg_id = ltrim($this->_SESSID.$this->_MSGCNT, '0'); + $msg_id = $this->_SESSID + $this->_MSGCNT; /* addition removes the leading zero */ $msg_type = $this->_MSGTYPE_STD; if ($array['protocol']) { From 709e6652de0027ae2d9868b5b18fd94f80463ef9 Mon Sep 17 00:00:00 2001 From: DaPikk Date: Tue, 15 Jul 2025 20:17:48 +0300 Subject: [PATCH 7/7] Update Ops.php min --- opensrs/Ops.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/opensrs/Ops.php b/opensrs/Ops.php index 56598afc..6fd10ef8 100644 --- a/opensrs/Ops.php +++ b/opensrs/Ops.php @@ -193,7 +193,8 @@ public function XML2PHP($msg) public function encode($array) { ++$this->_MSGCNT; - $msg_id = $this->_SESSID + $this->_MSGCNT; /* addition removes the leading zero */ + //$msg_id = $this->_SESSID + $this->_MSGCNT; /* addition removes the leading zero */ + $msg_id = ltrim($this->_SESSID.$this->_MSGCNT, '0'); $msg_type = $this->_MSGTYPE_STD; if ($array['protocol']) {