mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-09-09 17:37:02 +03:00
Rename 'ajax' to 'json' because we don't use XML
We use json as response
This commit is contained in:
parent
76cf24f426
commit
950579c7f5
18 changed files with 83 additions and 91 deletions
|
|
@ -141,7 +141,7 @@ class Actions
|
|||
|
||||
$this->sSpecAuthToken = '';
|
||||
$this->sUpdateAuthToken = '';
|
||||
$this->bIsAjax = false;
|
||||
$this->bIsJson = false;
|
||||
|
||||
$oConfig = $this->Config();
|
||||
$this->Plugins()->RunHook('filter.application-config', array($oConfig));
|
||||
|
|
@ -163,9 +163,9 @@ class Actions
|
|||
return $this;
|
||||
}
|
||||
|
||||
public function SetIsAjax(bool $bIsAjax): self
|
||||
public function SetIsJson(bool $bIsJson): self
|
||||
{
|
||||
$this->bIsAjax = $bIsAjax;
|
||||
$this->bIsJson = $bIsJson;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
|
@ -180,9 +180,9 @@ class Actions
|
|||
return $this->sUpdateAuthToken;
|
||||
}
|
||||
|
||||
public function GetIsAjax(): bool
|
||||
public function GetIsJson(): bool
|
||||
{
|
||||
return $this->bIsAjax;
|
||||
return $this->bIsJson;
|
||||
}
|
||||
|
||||
public function GetShortLifeSpecAuthToken(int $iLife = 60): string
|
||||
|
|
|
|||
|
|
@ -387,7 +387,7 @@ trait User
|
|||
|
||||
$aResult = array();
|
||||
|
||||
$this->Plugins()->RunHook('ajax.suggestions-input-parameters', array(&$sQuery, &$iLimit, $oAccount));
|
||||
$this->Plugins()->RunHook('json.suggestions-input-parameters', array(&$sQuery, &$iLimit, $oAccount));
|
||||
|
||||
$iLimit = (int) $iLimit;
|
||||
if (5 > $iLimit)
|
||||
|
|
@ -395,7 +395,7 @@ trait User
|
|||
$iLimit = 5;
|
||||
}
|
||||
|
||||
$this->Plugins()->RunHook('ajax.suggestions-pre', array(&$aResult, $sQuery, $oAccount, $iLimit));
|
||||
$this->Plugins()->RunHook('json.suggestions-pre', array(&$aResult, $sQuery, $oAccount, $iLimit));
|
||||
|
||||
if ($iLimit > \count($aResult) && 0 < \strlen($sQuery))
|
||||
{
|
||||
|
|
@ -442,7 +442,7 @@ trait User
|
|||
$aResult = \array_slice($aResult, 0, $iLimit);
|
||||
}
|
||||
|
||||
$this->Plugins()->RunHook('ajax.suggestions-post', array(&$aResult, $sQuery, $oAccount, $iLimit));
|
||||
$this->Plugins()->RunHook('json.suggestions-post', array(&$aResult, $sQuery, $oAccount, $iLimit));
|
||||
|
||||
$aResult = Utils::RemoveSuggestionDuplicates($aResult);
|
||||
if ($iLimit < \count($aResult))
|
||||
|
|
|
|||
|
|
@ -131,17 +131,17 @@ class Identity implements JsonSerializable
|
|||
return $this;
|
||||
}
|
||||
|
||||
public function FromJSON(array $aData, bool $bAjax = false): bool
|
||||
public function FromJSON(array $aData, bool $bJson = false): bool
|
||||
{
|
||||
if (!empty($aData['Email'])) {
|
||||
$this->sId = !empty($aData['Id']) ? $aData['Id'] : '';
|
||||
$this->sEmail = $bAjax ? Utils::IdnToAscii($aData['Email'], true) : $aData['Email'];
|
||||
$this->sEmail = $bJson ? Utils::IdnToAscii($aData['Email'], true) : $aData['Email'];
|
||||
$this->sName = isset($aData['Name']) ? $aData['Name'] : '';
|
||||
$this->sReplyTo = !empty($aData['ReplyTo']) ? $aData['ReplyTo'] : '';
|
||||
$this->sBcc = !empty($aData['Bcc']) ? $aData['Bcc'] : '';
|
||||
$this->sSignature = !empty($aData['Signature']) ? $aData['Signature'] : '';
|
||||
$this->bSignatureInsertBefore = isset($aData['SignatureInsertBefore']) ?
|
||||
($bAjax ? '1' === $aData['SignatureInsertBefore'] : !!$aData['SignatureInsertBefore']) : true;
|
||||
($bJson ? '1' === $aData['SignatureInsertBefore'] : !!$aData['SignatureInsertBefore']) : true;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -52,7 +52,7 @@ class Template implements \JsonSerializable
|
|||
$this->bPopulateAlways = $bPopulateAlways;
|
||||
}
|
||||
|
||||
public function FromJSON(array $aData, bool $bAjax = false) : bool
|
||||
public function FromJSON(array $aData, bool $bJson = false) : bool
|
||||
{
|
||||
if (isset($aData['ID'], $aData['Name'], $aData['Body']))
|
||||
{
|
||||
|
|
|
|||
|
|
@ -232,11 +232,11 @@ abstract class AbstractPlugin
|
|||
return $this;
|
||||
}
|
||||
|
||||
protected function addAjaxHook(string $sActionName, string $sFunctionName) : self
|
||||
protected function addJsonHook(string $sActionName, string $sFunctionName) : self
|
||||
{
|
||||
if ($this->oPluginManager)
|
||||
{
|
||||
$this->oPluginManager->AddAdditionalAjaxAction($sActionName, array(&$this, $sFunctionName));
|
||||
$this->oPluginManager->AddAdditionalJsonAction($sActionName, array(&$this, $sFunctionName));
|
||||
}
|
||||
|
||||
return $this;
|
||||
|
|
@ -253,11 +253,11 @@ abstract class AbstractPlugin
|
|||
return $this;
|
||||
}
|
||||
|
||||
protected function ajaxResponse(string $sFunctionName, array $aData) : self
|
||||
protected function jsonResponse(string $sFunctionName, array $aData) : self
|
||||
{
|
||||
if ($this->oPluginManager)
|
||||
{
|
||||
return $this->oPluginManager->AjaxResponseHelper(
|
||||
return $this->oPluginManager->JsonResponseHelper(
|
||||
$this->oPluginManager->convertPluginFolderNameToClassName($this->Name()).'::'.$sFunctionName, $aData);
|
||||
}
|
||||
|
||||
|
|
@ -269,7 +269,7 @@ abstract class AbstractPlugin
|
|||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function ajaxParam(string $sKey, $mDefault = null)
|
||||
public function jsonParam(string $sKey, $mDefault = null)
|
||||
{
|
||||
if ($this->oPluginManager)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@ class Manager
|
|||
/**
|
||||
* @var array
|
||||
*/
|
||||
private $aAdditionalAjax;
|
||||
private $aAdditionalJson;
|
||||
|
||||
/**
|
||||
* @var array
|
||||
|
|
@ -76,8 +76,8 @@ class Manager
|
|||
$this->aTemplates = array();
|
||||
$this->aAdminTemplates = array();
|
||||
|
||||
$this->aAjaxFilters = array();
|
||||
$this->aAdditionalAjax = array();
|
||||
$this->aJsonFilters = array();
|
||||
$this->aAdditionalJson = array();
|
||||
$this->aProcessTemplate = array();
|
||||
|
||||
$this->bIsEnabled = (bool) $this->oActions->Config()->Get('plugins', 'enable', false);
|
||||
|
|
@ -438,36 +438,36 @@ class Manager
|
|||
/**
|
||||
* @param mixed $mCallback
|
||||
*/
|
||||
public function AddAdditionalAjaxAction(string $sActionName, $mCallback) : self
|
||||
public function AddAdditionalJsonAction(string $sActionName, $mCallback) : self
|
||||
{
|
||||
if ($this->bIsEnabled && \is_callable($mCallback) && 0 < \strlen($sActionName))
|
||||
{
|
||||
$sActionName = 'DoPlugin'.$sActionName;
|
||||
|
||||
if (!isset($this->aAdditionalAjax[$sActionName]))
|
||||
if (!isset($this->aAdditionalJson[$sActionName]))
|
||||
{
|
||||
$this->aAdditionalAjax[$sActionName] = $mCallback;
|
||||
$this->aAdditionalJson[$sActionName] = $mCallback;
|
||||
}
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function HasAdditionalAjax(string $sActionName) : bool
|
||||
public function HasAdditionalJson(string $sActionName) : bool
|
||||
{
|
||||
return $this->bIsEnabled && isset($this->aAdditionalAjax[$sActionName]);
|
||||
return $this->bIsEnabled && isset($this->aAdditionalJson[$sActionName]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function RunAdditionalAjax(string $sActionName)
|
||||
public function RunAdditionalJson(string $sActionName)
|
||||
{
|
||||
if ($this->bIsEnabled)
|
||||
{
|
||||
if (isset($this->aAdditionalAjax[$sActionName]))
|
||||
if (isset($this->aAdditionalJson[$sActionName]))
|
||||
{
|
||||
return \call_user_func($this->aAdditionalAjax[$sActionName]);
|
||||
return \call_user_func($this->aAdditionalJson[$sActionName]);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -479,7 +479,7 @@ class Manager
|
|||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function AjaxResponseHelper(string $sFunctionName, $mData)
|
||||
public function JsonResponseHelper(string $sFunctionName, $mData)
|
||||
{
|
||||
return $this->oActions->DefaultResponse($sFunctionName, $mData);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -74,7 +74,7 @@ class ServiceActions
|
|||
return $this;
|
||||
}
|
||||
|
||||
public function ServiceAjax() : string
|
||||
public function ServiceJson() : string
|
||||
{
|
||||
\ob_start();
|
||||
|
||||
|
|
@ -87,7 +87,7 @@ class ServiceActions
|
|||
$sAction = $this->aPaths[2];
|
||||
}
|
||||
|
||||
$this->oActions->SetIsAjax(true);
|
||||
$this->oActions->SetIsJson(true);
|
||||
|
||||
try
|
||||
{
|
||||
|
|
@ -105,7 +105,7 @@ class ServiceActions
|
|||
|
||||
$sMethodName = 'Do'.$sAction;
|
||||
|
||||
$this->Logger()->Write('Action: '.$sMethodName, \MailSo\Log\Enumerations\Type::NOTE, 'AJAX');
|
||||
$this->Logger()->Write('Action: '.$sMethodName, \MailSo\Log\Enumerations\Type::NOTE, 'JSON');
|
||||
|
||||
$aPost = $this->oHttp->GetPostAsArray();
|
||||
if ($aPost)
|
||||
|
|
@ -133,15 +133,15 @@ class ServiceActions
|
|||
if (\method_exists($this->oActions, $sMethodName) &&
|
||||
\is_callable(array($this->oActions, $sMethodName)))
|
||||
{
|
||||
$this->Plugins()->RunHook('ajax.action-pre-call', array($sAction));
|
||||
$this->Plugins()->RunHook('json.action-pre-call', array($sAction));
|
||||
$aResponseItem = \call_user_func(array($this->oActions, $sMethodName));
|
||||
$this->Plugins()->RunHook('ajax.action-post-call', array($sAction, &$aResponseItem));
|
||||
$this->Plugins()->RunHook('json.action-post-call', array($sAction, &$aResponseItem));
|
||||
}
|
||||
else if ($this->Plugins()->HasAdditionalAjax($sMethodName))
|
||||
else if ($this->Plugins()->HasAdditionalJson($sMethodName))
|
||||
{
|
||||
$this->Plugins()->RunHook('ajax.action-pre-call', array($sAction));
|
||||
$aResponseItem = $this->Plugins()->RunAdditionalAjax($sMethodName);
|
||||
$this->Plugins()->RunHook('ajax.action-post-call', array($sAction, &$aResponseItem));
|
||||
$this->Plugins()->RunHook('json.action-pre-call', array($sAction));
|
||||
$aResponseItem = $this->Plugins()->RunAdditionalJson($sMethodName);
|
||||
$this->Plugins()->RunHook('json.action-post-call', array($sAction, &$aResponseItem));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -189,7 +189,7 @@ class ServiceActions
|
|||
}
|
||||
}
|
||||
|
||||
$this->Plugins()->RunHook('filter.ajax-response', array($sAction, &$aResponseItem));
|
||||
$this->Plugins()->RunHook('filter.json-response', array($sAction, &$aResponseItem));
|
||||
|
||||
\header('Content-Type: application/json; charset=utf-8');
|
||||
|
||||
|
|
@ -211,7 +211,7 @@ class ServiceActions
|
|||
|
||||
$iLimit = (int) $this->Config()->Get('labs', 'log_ajax_response_write_limit', 0);
|
||||
$this->Logger()->Write(0 < $iLimit && $iLimit < \strlen($sResult)
|
||||
? \substr($sResult, 0, $iLimit).'...' : $sResult, \MailSo\Log\Enumerations\Type::INFO, 'AJAX');
|
||||
? \substr($sResult, 0, $iLimit).'...' : $sResult, \MailSo\Log\Enumerations\Type::INFO, 'JSON');
|
||||
}
|
||||
|
||||
return $sResult;
|
||||
|
|
@ -316,14 +316,7 @@ class ServiceActions
|
|||
$aResponseItem = $this->oActions->ExceptionResponse($sAction, $oException);
|
||||
}
|
||||
|
||||
if ('iframe' === $this->oHttp->GetPost('jua-post-type', ''))
|
||||
{
|
||||
\header('Content-Type: text/html; charset=utf-8');
|
||||
}
|
||||
else
|
||||
{
|
||||
\header('Content-Type: application/json; charset=utf-8');
|
||||
}
|
||||
\header('Content-Type: application/json; charset=utf-8');
|
||||
|
||||
$this->Plugins()->RunHook('filter.upload-response', array(&$aResponseItem));
|
||||
$sResult = \MailSo\Base\Utils::Php2js($aResponseItem, $this->Logger());
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue