Skip to content

Commit

Permalink
Merge branch '2024.11'
Browse files Browse the repository at this point in the history
  • Loading branch information
gitlabci committed Feb 28, 2025
2 parents ddb5f14 + f427de1 commit fd266ac
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 21 deletions.
1 change: 1 addition & 0 deletions tests/tine20/Tinebase/ApplicationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -552,6 +552,7 @@ public function testGetModelsOfAllApplications()
Tinebase_Model_Sms_AdapterConfig::class,
Tinebase_Model_Sms_AdapterConfigs::class,
Tinebase_Model_Sms_GenericHttpAdapter::class,
Tinebase_Model_Sms_MockAdapter::class,
Tinebase_Model_Sms_SendConfig::class,
Tinebase_Model_State::class,
Tinebase_Model_Tag::class,
Expand Down
19 changes: 3 additions & 16 deletions tine20/Admin/Controller/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -201,21 +201,8 @@ public function setAccountPassword(Tinebase_Model_FullUser $_account, $_password
return;
}

$smsAdapterConfig = $smsAdapterConfigs->getFirstRecord();
$smsAdapterConfig = $smsAdapterConfig->{Tinebase_Model_Sms_AdapterConfig::FLD_ADAPTER_CONFIG};

if (empty($smsAdapterConfig->getHttpClientConfig())) {
$smsAdapterConfig->setHttpClientConfig([
'adapter' => ($genericHttpAdapter = new Tinebase_ZendHttpClientAdapter())
]);

$genericHttpAdapter->writeBodyCallBack = function($body) {
$colorGreen = "\033[43m";
$colorReset = "\033[0m";
Tinebase_Core::getLogger()->warn($colorGreen . __METHOD__ . '::' . __LINE__ . ' sms request body: ' . $body . $colorReset . PHP_EOL);
};
$genericHttpAdapter->setResponse(new Zend_Http_Response(200, []));
}
$smsAdapterClass = $smsAdapterConfigs->getFirstRecord()->{Tinebase_Model_Sms_AdapterConfig::FLD_ADAPTER_CLASS};
$smsAdapterConfig = $smsAdapterConfigs->getFirstRecord()->{Tinebase_Model_Sms_AdapterConfig::FLD_ADAPTER_CONFIG};

$template = $customTemplate ? rawurldecode($customTemplate) : Tinebase_Config::getInstance()->{Tinebase_Config::SMS}
->{Tinebase_Config::SMS_MESSAGE_TEMPLATES}->get(Tinebase_Config::SMS_NEW_PASSWORD_TEMPLATE);
Expand All @@ -236,7 +223,7 @@ public function setAccountPassword(Tinebase_Model_FullUser $_account, $_password
$smsSendConfig = new Tinebase_Model_Sms_SendConfig([
Tinebase_Model_Sms_SendConfig::FLD_MESSAGE => $message,
Tinebase_Model_Sms_SendConfig::FLD_RECIPIENT_NUMBER => $mobilePhoneNumber,
Tinebase_Model_Sms_SendConfig::FLD_ADAPTER_CLASS => Tinebase_Model_Sms_GenericHttpAdapter::class,
Tinebase_Model_Sms_SendConfig::FLD_ADAPTER_CLASS => $smsAdapterClass,
Tinebase_Model_Sms_SendConfig::FLD_ADAPTER_CONFIG => $smsAdapterConfig,
]);

Expand Down
5 changes: 0 additions & 5 deletions tine20/Tinebase/Model/Sms/GenericHttpAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,6 @@ class Tinebase_Model_Sms_GenericHttpAdapter extends Tinebase_Record_NewAbstract

protected array $_httpClientConfig = [];

public function getHttpClientConfig()
{
return $this->_httpClientConfig;
}

public function setHttpClientConfig(array $_config): void
{
$this->_httpClientConfig = $_config;
Expand Down
38 changes: 38 additions & 0 deletions tine20/Tinebase/Model/Sms/MockAdapter.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?php declare(strict_types=1);
/**
* Tine 2.0
*
* @package Tinebase
* @subpackage Model
* @license http://www.gnu.org/licenses/agpl.html AGPL Version 3
* @copyright Copyright (c) 2024 Metaways Infosystems GmbH (http://www.metaways.de)
* @author Paul Mehrer <[email protected]>
*/

/**
* SMS Generic HTTP Adapter Model
*
* @package Tinebase
* @subpackage Model
*/
class Tinebase_Model_Sms_MockAdapter extends Tinebase_Model_Sms_GenericHttpAdapter
{
const MODEL_NAME_PART = 'Sms_MockAdapter';

public function send(Tinebase_Model_Sms_SendConfig $config): bool
{
// @TODO make me working
$this->setHttpClientConfig([
'adapter' => ($client = new Tinebase_ZendHttpClientAdapter())
]);

$client->writeBodyCallBack = function($body) {
$colorGreen = "\033[43m";
$colorReset = "\033[0m";
Tinebase_Core::getLogger()->warn($colorGreen . __METHOD__ . '::' . __LINE__ . ' sms request body: ' . $body . $colorReset . PHP_EOL);
};
$client->setResponse(new Zend_Http_Response(200, []));

return true;
}
}

0 comments on commit fd266ac

Please sign in to comment.