Refactoring

This commit is contained in:
RainLoop Team 2014-07-15 16:20:08 +04:00
parent 310dbf9224
commit 958c814c86
35 changed files with 1402 additions and 158 deletions

View file

@ -424,6 +424,7 @@ Enums.Notification = {
'MailServerError': 901,
'ClientViewError': 902,
'InvalidInputArgument': 903,
'UnknownNotification': 999,
'UnknownError': 999
};

View file

@ -623,6 +623,7 @@ Utils.initNotificationLanguage = function ()
NotificationI18N[Enums.Notification.AccountAlreadyExists] = Utils.i18n('NOTIFICATIONS/ACCOUNT_ALREADY_EXISTS');
NotificationI18N[Enums.Notification.MailServerError] = Utils.i18n('NOTIFICATIONS/MAIL_SERVER_ERROR');
NotificationI18N[Enums.Notification.InvalidInputArgument] = Utils.i18n('NOTIFICATIONS/INVALID_INPUT_ARGUMENT');
NotificationI18N[Enums.Notification.UnknownNotification] = Utils.i18n('NOTIFICATIONS/UNKNOWN_ERROR');
NotificationI18N[Enums.Notification.UnknownError] = Utils.i18n('NOTIFICATIONS/UNKNOWN_ERROR');
};

View file

@ -2041,7 +2041,7 @@ class Utils
*/
public static function IdnToAscii($sStr, $bLowerIfAscii = false)
{
$sStr = $bLowerIfAscii ? \MailSo\Base\Utils::StrToLowerIfAscii($sStr) : $sStr;
$sStr = $bLowerIfAscii ? \MailSo\Base\Utils::StrToLowerIfAscii($sStr) : $sStr;
$sUser = '';
$sDomain = $sStr;

View file

@ -1007,6 +1007,7 @@ class Actions
$sAuthAccountHash = '';
}
$oAccount = null;
$oConfig = $this->Config();
$aResult = array(
@ -1114,6 +1115,8 @@ class Actions
}
else
{
$oAccount = null;
$aResult['DevEmail'] = $oConfig->Get('labs', 'dev_email', '');
$aResult['DevPassword'] = $oConfig->Get('labs', 'dev_password', '');
}
@ -1341,7 +1344,7 @@ class Actions
$aResult['MailToEmail'] = \MailSo\Base\Utils::IdnToUtf8($aResult['MailToEmail']);
$aResult['DevEmail'] = \MailSo\Base\Utils::IdnToUtf8($aResult['DevEmail']);
$this->Plugins()->InitAppData($bAdmin, $aResult);
$this->Plugins()->InitAppData($bAdmin, $aResult, $oAccount);
return $aResult;
}
@ -1431,19 +1434,27 @@ class Actions
* @param string $sPassword
* @param string $sSignMeToken = ''
* @param string $sAdditionalCode = ''
* @param string $bAdditionalCodeSignMeSignMe = false
* @param string $bAdditionalCodeSignMe = false
*
* @return \RainLoop\Account
* @throws \RainLoop\Exceptions\ClientException
*/
public function LoginProcess(&$sEmail, &$sPassword, $sSignMeToken = '',
$sAdditionalCode = '', $bAdditionalCodeSignMeSignMe = false)
$sAdditionalCode = '', $bAdditionalCodeSignMe = false)
{
$this->Plugins()->RunHook('filter.login-credentials-first', array(&$sEmail, &$sPassword));
$sEmail = \MailSo\Base\Utils::StrToLowerIfAscii($sEmail);
if (false === \strpos($sEmail, '@') && 0 < \strlen(\trim($this->Config()->Get('login', 'default_domain', ''))))
{
$sEmail = $sEmail.'@'.\trim(\trim($this->Config()->Get('login', 'default_domain', '')), ' @');
}
if (false === \strpos($sEmail, '@') || 0 === \strlen($sPassword))
{
throw new \RainLoop\Exceptions\ClientException(\RainLoop\Notifications::InvalidInputArgument);
}
$this->Logger()->AddSecret($sPassword);
$sLogin = $sEmail;
@ -1471,6 +1482,7 @@ class Actions
}
}
// Two factor auth
if ($oAccount && $this->TwoFactorAuthProvider()->IsActive())
{
$aData = $this->getTwoFactorInfo($oAccount->ParentEmailHelper());
@ -1503,7 +1515,7 @@ class Actions
}
}
if ($bAdditionalCodeSignMeSignMe)
if ($bAdditionalCodeSignMe)
{
\RainLoop\Utils::SetCookie(self::AUTH_TFA_SIGN_ME_TOKEN_KEY, $sSecretHash,
\time() + 60 * 60 * 24 * 14, '/', null, null, true);
@ -3230,7 +3242,7 @@ class Actions
if (!$bDisable)
{
$oPlugin = $this->Plugins()->CreatePluginByName($sName);
if ($oPlugin instanceof \RainLoop\Plugins\AbstractPlugin)
if ($oPlugin && ($oPlugin instanceof \RainLoop\Plugins\AbstractPlugin))
{
$sValue = $oPlugin->Supported();
if (0 < \strlen($sValue))
@ -3274,7 +3286,7 @@ class Actions
{
foreach ($aMap as $oItem)
{
if ($oItem && $oItem instanceof \RainLoop\Plugins\Property)
if ($oItem && ($oItem instanceof \RainLoop\Plugins\Property))
{
$aItem = $oItem->ToArray();
$aItem[0] = $oConfig->Get('plugin', $oItem->Name(), '');

View file

@ -63,6 +63,7 @@ class Notifications
const MailServerError = 901;
const ClientViewError = 902;
const InvalidInputArgument = 903;
const UnknownNotification = 998;
const UnknownError = 999;
@ -125,6 +126,7 @@ class Notifications
self::AccountAlreadyExists => 'AccountAlreadyExists',
self::MailServerError => 'MailServerError',
self::ClientViewError => 'ClientViewError',
self::InvalidInputArgument => 'InvalidInputArgument',
self::UnknownNotification => 'UnknownNotification',
self::UnknownError => 'UnknownError'
);

View file

@ -282,7 +282,7 @@ class Manager
*
* @return \RainLoop\Plugins\Manager
*/
public function InitAppData($bAdmin, &$aAppData)
public function InitAppData($bAdmin, &$aAppData, $oAccount = null)
{
if ($this->bIsEnabled && isset($aAppData['Plugins']) && is_array($aAppData['Plugins']))
{
@ -344,7 +344,7 @@ class Manager
}
/**
* @param string $sHookName
* @param string $sFile
* @param bool $bAdminScope = false
*
* @return \RainLoop\Plugins\Manager
@ -367,7 +367,7 @@ class Manager
}
/**
* @param string $sHookName
* @param string $sFile
* @param bool $bAdminScope = false
*
* @return \RainLoop\Plugins\Manager

View file

@ -0,0 +1,340 @@
<?php
namespace RainLoop\PluginsNext;
abstract class AbstractPlugin
{
/**
* @var \RainLoop\PluginsNext\Manager
*/
private $oPluginManager;
/**
* @var \RainLoop\Config\Plugin
*/
private $oPluginConfig;
/**
* @var bool
*/
private $bLangs;
/**
* @var string
*/
private $sName;
/**
* @var string
*/
private $sPath;
/**
* @var string
*/
private $sVersion;
/**
* @var array
*/
private $aConfigMap;
/**
* @var bool
*/
private $bPluginConfigLoaded;
public function __construct()
{
$this->sName = '';
$this->sPath = '';
$this->sVersion = '0.0';
$this->aConfigMap = null;
$this->oPluginManager = null;
$this->oPluginConfig = null;
$this->bPluginConfigLoaded = false;
$this->bLangs = false;
}
/**
* @return \RainLoop\Config\Plugin
*/
public function Config()
{
if (!$this->bPluginConfigLoaded && $this->oPluginConfig)
{
$this->bPluginConfigLoaded = true;
if ($this->oPluginConfig->IsInited())
{
if (!$this->oPluginConfig->Load())
{
$this->oPluginConfig->Save();
}
}
}
return $this->oPluginConfig;
}
/**
* @return \RainLoop\PluginsNext\Manager
*/
public function Manager()
{
return $this->oPluginManager;
}
/**
* @return string
*/
public function Path()
{
return $this->sPath;
}
/**
* @return string
*/
public function Name()
{
return $this->sName;
}
/**
* @return string
*/
public function Version()
{
return $this->sVersion;
}
/**
* @param bool|null $bLangs = null
* @return bool
*/
public function UseLangs($bLangs = null)
{
if (null !== $bLangs)
{
$this->bLangs = (bool) $bLangs;
}
return $this->bLangs;
}
/**
* @return array
*/
protected function configMapping()
{
return array();
}
/**
* @return string
*/
public function Hash()
{
return \md5($this->sVersion);
}
/**
* @return string
*/
public function Supported()
{
return '';
}
/**
* @final
* @return array
*/
final public function ConfigMap()
{
if (null === $this->aConfigMap)
{
$this->aConfigMap = $this->configMapping();
if (!\is_array($this->aConfigMap))
{
$this->aConfigMap = array();
}
}
return $this->aConfigMap;
}
/**
* @param string $sPath
* @param string $sName
* @param string $sVersion = ''
*
* @return self
*/
public function SetValues($sPath, $sName, $sVersion = '')
{
$this->sName = $sName;
$this->sPath = $sPath;
if (0 < \strlen($sVersion))
{
$this->sVersion = $sVersion;
}
return $this;
}
/**
* @param \RainLoop\PluginsNext\Manager $oPluginManager
*
* @return self
*/
public function SetPluginManager(\RainLoop\PluginsNext\Manager $oPluginManager)
{
$this->oPluginManager = $oPluginManager;
return $this;
}
/**
* @param \RainLoop\Config\Plugin $oPluginConfig
*
* @return self
*/
public function SetPluginConfig(\RainLoop\Config\Plugin $oPluginConfig)
{
$this->oPluginConfig = $oPluginConfig;
return $this;
}
/**
* @return self
*/
public function Init()
{
}
/**
* @param string $sStep
*
* @return self
*/
public function InitStep($sStep)
{
}
/**
* @param bool $bAdmin
* @param bool $bAuth
* @param array $aConfig
*
* @return void
*/
public function FilterAppDataPluginSection($bAdmin, $bAuth, &$aConfig)
{
}
/**
* @param string $sHookName
* @param string $sFunctionName
*
* @return self
*/
protected function addHook($sHookName, $sFunctionName)
{
if ($this->oPluginManager)
{
$this->oPluginManager->AddHook($sHookName, array(&$this, $sFunctionName));
}
return $this;
}
/**
* @param string $sFile
* @param bool $bAdminScope = false
*
* @return self
*/
protected function addJs($sFile, $bAdminScope = false)
{
if ($this->oPluginManager)
{
$this->oPluginManager->AddJs($this->sPath.'/'.$sFile, $bAdminScope);
}
return $this;
}
/**
* @param string $sFile
* @param bool $bAdminScope = false
*
* @return self
*/
protected function addTemplate($sFile, $bAdminScope = false)
{
if ($this->oPluginManager)
{
$this->oPluginManager->AddTemplate($this->sPath.'/'.$sFile, $bAdminScope);
}
return $this;
}
/**
* @param string $sActionName
* @param string $sFunctionName
*
* @return self
*/
protected function addPartHook($sActionName, $sFunctionName)
{
if ($this->oPluginManager)
{
$this->oPluginManager->AddAdditionalPartAction($sActionName, array(&$this, $sFunctionName));
}
return $this;
}
/**
* @param string $sActionName
* @param string $sFunctionName
*
* @return self
*/
protected function addAjaxHook($sActionName, $sFunctionName)
{
if ($this->oPluginManager)
{
$this->oPluginManager->AddAdditionalAjaxAction($sActionName, array(&$this, $sFunctionName));
}
return $this;
}
/**
* @param string $sName
* @param string $sPlace
* @param string $sLocalTemplateName
* @param bool $bPrepend = false
*
* @return self
*/
protected function addTemplateHook($sName, $sPlace, $sLocalTemplateName, $bPrepend = false)
{
if ($this->oPluginManager)
{
$this->oPluginManager->AddProcessTemplateAction($sName, $sPlace,
'<!-- ko template: \''.$sLocalTemplateName.'\' --><!-- /ko -->', $bPrepend);
}
return $this;
}
}

View file

@ -0,0 +1,685 @@
<?php
namespace RainLoop\PluginsNext;
class Manager
{
/**
* @var \RainLoop\Actions
*/
private $oActions;
/**
* @var array
*/
private $aHooks;
/**
* @var array
*/
private $aJs;
/**
* @var array
*/
private $aAdminJs;
/**
* @var array
*/
private $aTemplates;
/**
* @var array
*/
private $aAdminTemplates;
/**
* @var array
*/
private $aProcessTemplate;
/**
* @var array
*/
private $aAdditionalParts;
/**
* @var array
*/
private $aAdditionalAjax;
/**
* @var array
*/
private $aPlugins;
/**
* @var bool
*/
private $bIsEnabled;
/**
* @var \MailSo\Log\Logger
*/
private $oLogger;
/**
* @param \RainLoop\Actions $oActions
*/
public function __construct(\RainLoop\Actions $oActions)
{
$this->oLogger = null;
$this->oActions = $oActions;
$this->aPlugins = array();
$this->aHooks = array();
$this->aJs = array();
$this->aAdminJs = array();
$this->aTemplates = array();
$this->aAdminTemplates = array();
$this->aAjaxFilters = array();
$this->aAdditionalAjax = array();
$this->aProcessTemplate = array();
$this->bIsEnabled = (bool) $this->oActions->Config()->Get('plugins', 'enable', false);
if ($this->bIsEnabled)
{
$sList = \strtolower($this->oActions->Config()->Get('plugins', 'enabled_list', ''));
if (0 < \strlen($sList))
{
$aList = \explode(',', $sList);
$aList = \array_map('trim', $aList);
foreach ($aList as $sName)
{
if (0 < \strlen($sName))
{
$oPlugin = $this->CreatePluginByName($sName);
if ($oPlugin)
{
$oPlugin->InitStep('step1');
$oPlugin->Init();
$oPlugin->InitStep('step2');
$this->aPlugins[] = $oPlugin;
$oPlugin->InitStep('spep3');
}
}
}
}
$this->RunHook('api.bootstrap.plugins');
}
}
/**
* @param string $sName
*
* @return \RainLoop\Plugins\AbstractPlugin|null
*/
public function CreatePluginByName($sName)
{
$oPlugin = null;
if (\preg_match('/^[a-z0-9\-]+$/', $sName) &&
\file_exists(APP_PLUGINS_PATH.$sName.'/index.php'))
{
$sClassName = $this->convertPluginFolderNameToClassName($sName);
if (!\class_exists($sClassName))
{
include APP_PLUGINS_PATH.$sName.'/index.php';
}
if (\class_exists($sClassName))
{
$oPlugin = new $sClassName();
if ($oPlugin instanceof \RainLoop\PluginsNext\AbstractPlugin)
{
$oPlugin
->SetValues(APP_PLUGINS_PATH.$sName, $sName,
\file_exists(APP_PLUGINS_PATH.$sName.'/VERSION') ?
\file_get_contents(APP_PLUGINS_PATH.$sName.'/VERSION') : '')
->SetPluginManager($this)
->SetPluginConfig(new \RainLoop\Config\Plugin($sName, $oPlugin->ConfigMap()))
;
}
else
{
$oPlugin = null;
}
}
}
return $oPlugin;
}
/**
* @return array
*/
public function InstalledPlugins()
{
$aList = array();
$aGlob = @\glob(APP_PLUGINS_PATH.'*', GLOB_ONLYDIR|GLOB_NOSORT);
if (\is_array($aGlob))
{
foreach ($aGlob as $sPathName)
{
$sName = \basename($sPathName);
if (\preg_match('/^[a-z0-9\-]+$/', $sName) &&
\file_exists($sPathName.'/index.php'))
{
$aList[] = array(
$sName, @\file_get_contents($sPathName.'/VERSION')
);
}
}
}
else
{
$this->Actions()->Logger()->Write('Cannot get installed plugins from '.APP_PLUGINS_PATH,
\MailSo\Log\Enumerations\Type::ERROR);
}
return $aList;
}
/**
* @param string $sFolderName
*
* @return string
*/
private function convertPluginFolderNameToClassName($sFolderName)
{
$aParts = \array_map('ucfirst', \array_map('strtolower',
\explode(' ', \preg_replace('/[^a-z0-9]+/', ' ', $sFolderName))));
return \implode($aParts).'Plugin';
}
/**
* @return \RainLoop\Actions
*/
public function Actions()
{
return $this->oActions;
}
/**
* @return string
*/
public function Hash()
{
$sResult = \md5(APP_VERSION);
foreach ($this->aPlugins as $oPlugin)
{
$sResult = \md5($sResult.$oPlugin->Path().$oPlugin->Hash());
}
return $sResult;
}
/**
* @param bool $bAdminScope = false
*
* @return string
*/
public function CompileJs($bAdminScope = false)
{
$aResult = array();
if ($this->bIsEnabled)
{
$aJs = $bAdminScope ? $this->aAdminJs : $this->aJs;
foreach ($aJs as $sFile)
{
if (\file_exists($sFile))
{
$aResult[] = \file_get_contents($sFile);
}
}
}
return \implode("\n", $aResult);
}
/**
* @todo
* @param bool $bAdminScope = false
*
* @return string
*/
public function CompileCss($bAdminScope = false)
{
return '';
}
/**
* @param bool $bAdminScope = false
* @return string
*/
public function CompileTemplate($bAdminScope = false)
{
$sResult = '';
if ($this->bIsEnabled)
{
foreach ($bAdminScope ? $this->aAdminTemplates : $this->aTemplates as $sFile)
{
if (\file_exists($sFile))
{
$sTemplateName = \substr(\basename($sFile), 0, -5);
$sResult .= '<script id="'.\preg_replace('/[^a-zA-Z0-9]/', '', $sTemplateName).'" type="text/html" data-cfasync="false">'.
$this->Actions()->ProcessTemplate($sTemplateName, \file_get_contents($sFile)).'</script>';
}
}
}
return $sResult;
}
/**
* @param bool $bAdmin
* @param array $aAppData
* @param \RainLoop\Account|null $oAccount = null
*
* @return \RainLoop\PluginsNext\Manager
*/
public function InitAppData($bAdmin, &$aAppData, $oAccount = null)
{
if ($this->bIsEnabled && isset($aAppData['Plugins']) && \is_array($aAppData['Plugins']))
{
$bAuth = isset($aAppData['Auth']) && !!$aAppData['Auth'];
foreach ($this->aPlugins as $oPlugin)
{
if ($oPlugin)
{
$aConfig = array();
$aMap = $oPlugin->ConfigMap();
if (\is_array($aMap))
{
foreach ($aMap as /* @var $oPluginProperty \RainLoop\PluginsNext\Property */$oPluginProperty)
{
if ($oPluginProperty && $oPluginProperty->AllowedInJs())
{
$aConfig[$oPluginProperty->Name()] =
$oPlugin->Config()->Get('plugin',
$oPluginProperty->Name(),
$oPluginProperty->DefaultValue());
}
}
}
$oPlugin->FilterAppDataPluginSection($bAdmin, $bAuth, $aConfig);
if (0 < \count($aConfig))
{
$aAppData['Plugins'][$oPlugin->Name()] = $aConfig;
}
}
}
$this->RunHook('filter.app-data', array(
'IsAdmin' => $bAdmin,
'AppData' => &$aAppData
), $oAccount);
}
return $this;
}
/**
* @param string $sHookName
* @param mixed $mCallbak
*
* @return \RainLoop\PluginsNext\Manager
*/
public function AddHook($sHookName, $mCallbak)
{
if ($this->bIsEnabled && \is_callable($mCallbak))
{
if (!isset($this->aHooks[$sHookName]))
{
$this->aHooks[$sHookName] = array();
}
$this->aHooks[$sHookName][] = $mCallbak;
}
return $this;
}
/**
* @param string $sFile
* @param bool $bAdminScope = false
*
* @return \RainLoop\PluginsNext\Manager
*/
public function AddJs($sFile, $bAdminScope = false)
{
if ($this->bIsEnabled)
{
if ($bAdminScope)
{
$this->aAdminJs[$sFile] = $sFile;
}
else
{
$this->aJs[$sFile] = $sFile;
}
}
return $this;
}
/**
* @param string $sFile
* @param bool $bAdminScope = false
*
* @return \RainLoop\PluginsNext\Manager
*/
public function AddTemplate($sFile, $bAdminScope = false)
{
if ($this->bIsEnabled)
{
if ($bAdminScope)
{
$this->aAdminTemplates[$sFile] = $sFile;
}
else
{
$this->aTemplates[$sFile] = $sFile;
}
}
return $this;
}
/**
* @param string $sHookName
* @param array $aArg = array()
* @param \RainLoop\Account|null $oAccount = null
* @param bool $bLogHook = true
*
* @return \RainLoop\PluginsNext\Manager
*/
public function RunHook($sHookName, $aArg = array(), $oAccount = null, $bLogHook = true)
{
if ($this->bIsEnabled)
{
if (isset($this->aHooks[$sHookName]))
{
if ($bLogHook)
{
$this->WriteLog('Hook: '.$sHookName, \MailSo\Log\Enumerations\Type::NOTE);
}
$bArgArray = 0 < \count($aArg);
foreach ($this->aHooks[$sHookName] as $mCallbak)
{
if ($bArgArray)
{
\call_user_func_array($mCallbak, array($aArg));
}
else
{
\call_user_func($mCallbak);
}
}
}
}
return $this;
}
/**
* @param string $sActionName
* @param mixed $mCallbak
*
* @return \RainLoop\PluginsNext\Manager
*/
public function AddAdditionalPartAction($sActionName, $mCallbak)
{
if ($this->bIsEnabled && \is_callable($mCallbak))
{
$sActionName = \strtolower($sActionName);
if (!isset($this->aAdditionalParts[$sActionName]))
{
$this->aAdditionalParts[$sActionName] = array();
}
$this->aAdditionalParts[$sActionName][] = $mCallbak;
}
return $this;
}
/**
* @param string $sActionName
* @param array $aParts = array()
*
* @return \RainLoop\PluginsNext\Manager
*/
public function RunAdditionalPart($sActionName, $aParts = array())
{
$bResult = false;
if ($this->bIsEnabled)
{
$sActionName = \strtolower($sActionName);
if (isset($this->aAdditionalParts[$sActionName]))
{
foreach ($this->aAdditionalParts[$sActionName] as $mCallbak)
{
$bCallResult = \call_user_func_array($mCallbak, $aParts);
if ($bCallResult && !$bResult)
{
$bResult = true;
}
}
}
}
return $bResult;
}
/**
* @param string $sName
* @param string $sPlace
* @param string $sHtml
* @param bool $bPrepend = false
*
* @return \RainLoop\PluginsNext\Manager
*/
public function AddProcessTemplateAction($sName, $sPlace, $sHtml, $bPrepend = false)
{
if ($this->bIsEnabled)
{
if (!isset($this->aProcessTemplate[$sName]))
{
$this->aProcessTemplate[$sName] = array();
}
if (!isset($this->aProcessTemplate[$sName][$sPlace]))
{
$this->aProcessTemplate[$sName][$sPlace] = array();
}
if ($bPrepend)
{
\array_unshift($this->aProcessTemplate[$sName][$sPlace], $sHtml);
}
else
{
\array_push($this->aProcessTemplate[$sName][$sPlace], $sHtml);
}
}
return $this;
}
/**
* @param string $sActionName
* @param mixed $mCallbak
*
* @return \RainLoop\Plugins\Manager
*/
public function AddAdditionalAjaxAction($sActionName, $mCallbak)
{
if ($this->bIsEnabled && \is_callable($mCallbak) && 0 < \strlen($sActionName))
{
$sActionName = 'Do'.$sActionName;
if (!isset($this->aAdditionalAjax[$sActionName]))
{
$this->aAdditionalAjax[$sActionName] = $mCallbak;
}
}
return $this;
}
/**
* @param string $sActionName
*
* @return bool
*/
public function HasAdditionalAjax($sActionName)
{
return $this->bIsEnabled && isset($this->aAdditionalAjax[$sActionName]);
}
/**
* @param string $sActionName
*
* @return mixed
*/
public function RunAdditionalAjax($sActionName)
{
if ($this->bIsEnabled)
{
if (isset($this->aAdditionalAjax[$sActionName]))
{
return \call_user_func($this->aAdditionalAjax[$sActionName]);
}
}
return false;
}
/**
* @param string $sLang
* @param array $sActionName
*
* @return \RainLoop\PluginsNext\Manager
*/
public function ReadLang($sLang, &$aLang)
{
if ($this->bIsEnabled)
{
foreach ($this->aPlugins as $oPlugin)
{
if ($oPlugin->UseLangs())
{
$sPath = $oPlugin->Path();
\RainLoop\Utils::ReadAndAddLang($sPath.'/langs/en.ini', $aLang);
if ('en' !== $sLang)
{
\RainLoop\Utils::ReadAndAddLang($sPath.'/langs/'.$sLang.'.ini', $aLang);
}
}
}
}
return $this;
}
/**
* @param string $sName
* @param string $sHtml
*
* @return string
*/
public function ProcessTemplate($sName, $sHtml)
{
if (isset($this->aProcessTemplate[$sName]))
{
foreach ($this->aProcessTemplate[$sName] as $sPlace => $aAddHtml)
{
if (\is_array($aAddHtml) && 0 < \count($aAddHtml))
{
foreach ($aAddHtml as $sAddHtml)
{
$sHtml = \str_replace('{{INCLUDE/'.$sPlace.'/PLACE}}', $sAddHtml.'{{INCLUDE/'.$sPlace.'/PLACE}}', $sHtml);
}
}
}
}
return $sHtml;
}
/**
* @return bool
*/
public function bIsEnabled()
{
return $this->bIsEnabled;
}
/**
* @return int
*/
public function Count()
{
return $this->bIsEnabled ? \count($this->aPlugins) : 0;
}
/**
* @param \MailSo\Log\Logger $oLogger
*
* @return \RainLoop\PluginsNext\Manager
*
* @throws \MailSo\Base\Exceptions\InvalidArgumentException
*/
public function SetLogger($oLogger)
{
if (!($oLogger instanceof \MailSo\Log\Logger))
{
throw new \MailSo\Base\Exceptions\InvalidArgumentException();
}
$this->oLogger = $oLogger;
return $this;
}
/**
* @param string $sDesc
* @param int $iType = \MailSo\Log\Enumerations\Type::INFO
*
* @return void
*/
public function WriteLog($sDesc, $iType = \MailSo\Log\Enumerations\Type::INFO)
{
if ($this->oLogger)
{
$this->oLogger->Write($sDesc, $iType, 'PLUGIN');
}
}
/**
* @param string $sDesc
* @param int $iType = \MailSo\Log\Enumerations\Type::INFO
*
* @return void
*/
public function WriteException($sDesc, $iType = \MailSo\Log\Enumerations\Type::INFO)
{
if ($this->oLogger)
{
$this->oLogger->WriteException($sDesc, $iType, 'PLUGIN');
}
}
}

View file

@ -0,0 +1,179 @@
<?php
namespace RainLoop\PluginsNext;
class Property
{
/**
* @var string
*/
private $sName;
/**
* @var string
*/
private $sLabel;
/**
* @var string
*/
private $sDesc;
/**
* @var int
*/
private $iType;
/**
* @var bool
*/
private $bAllowedInJs;
/**
* @var mixed
*/
private $mDefaultValue;
private function __construct($sName)
{
$this->sName = $sName;
$this->iType = \RainLoop\Enumerations\PluginPropertyType::STRING;
$this->mDefaultValue = '';
$this->sLabel = '';
$this->sDesc = '';
$this->bAllowedInJs = false;
}
/**
* @param string $sName
*
* @return \RainLoop\PluginsNext\Property
*/
public static function NewInstance($sName)
{
return new self($sName);
}
/**
* @param int $iType
*
* @return \RainLoop\PluginsNext\Property
*/
public function SetType($iType)
{
$this->iType = (int) $iType;
return $this;
}
/**
* @param mixed $mDefaultValue
*
* @return \RainLoop\PluginsNext\Property
*/
public function SetDefaultValue($mDefaultValue)
{
$this->mDefaultValue = $mDefaultValue;
return $this;
}
/**
* @param string $sLabel
*
* @return \RainLoop\PluginsNext\Property
*/
public function SetLabel($sLabel)
{
$this->sLabel = $sLabel;
return $this;
}
/**
* @param string $sDesc
*
* @return \RainLoop\PluginsNext\Property
*/
public function SetDescription($sDesc)
{
$this->sDesc = $sDesc;
return $this;
}
/**
* @param bool $bValue = true
*
* @return \RainLoop\PluginsNext\Property
*/
public function SetAllowedInJs($bValue = true)
{
$this->bAllowedInJs = !!$bValue;
return $this;
}
/**
* @return string
*/
public function Name()
{
return $this->sName;
}
/**
* @return bool
*/
public function AllowedInJs()
{
return $this->bAllowedInJs;
}
/**
* @return string
*/
public function Description()
{
return $this->sDesc;
}
/**
* @return string
*/
public function Label()
{
return $this->sLabel;
}
/**
* @return int
*/
public function Type()
{
return $this->iType;
}
/**
* @return mixed
*/
public function DefaultValue()
{
return $this->mDefaultValue;
}
/**
* @return array
*/
public function ToArray()
{
return array(
'',
$this->sName,
$this->iType,
$this->sLabel,
$this->mDefaultValue,
$this->sDesc
);
}
}

View file

@ -583,6 +583,7 @@ LICENSING_DOMAIN_BANNED = "Das Abonnement dieser Domain ist gesperrt."
DEMO_SEND_MESSAGE_ERROR = "Dieser Demo-Account darf aus Sicherheitsgründen keine Nachrichten an externe E-Mail-Adressen versenden!"
ACCOUNT_ALREADY_EXISTS = "Dieses Konto gibt es schon."
MAIL_SERVER_ERROR = "Beim Zugriff auf den E-Mail-Server trat ein Fehler auf."
INVALID_INPUT_ARGUMENT = "Invalid input argument"
UNKNOWN_ERROR = "Unbekannter Fehler"
[STATIC]

View file

@ -591,6 +591,7 @@ LICENSING_DOMAIN_BANNED = "Subscription for this domain is banned."
DEMO_SEND_MESSAGE_ERROR = "For security purposes, this demo account is not allowed to send messages to external e-mail addresses!"
ACCOUNT_ALREADY_EXISTS = "Account already exists"
MAIL_SERVER_ERROR = "An error has occured while accessing mail server"
INVALID_INPUT_ARGUMENT = "Invalid input argument"
UNKNOWN_ERROR = "Unknown error"
[STATIC]

View file

@ -582,6 +582,7 @@ LICENSING_DOMAIN_BANNED = "La suscripción para este dominio se prohibió."
DEMO_SEND_MESSAGE_ERROR = "Por razones de seguridad, esta cuenta demo no permite enviar mensajes a direcciones de correo electrónico externas!"
ACCOUNT_ALREADY_EXISTS = "La cuenta ya existe"
MAIL_SERVER_ERROR = "Ocurrió un error mientras se accedía al servidor"
INVALID_INPUT_ARGUMENT = "Invalid input argument"
UNKNOWN_ERROR = "Error desconocido"
[STATIC]

View file

@ -582,6 +582,7 @@ LICENSING_DOMAIN_BANNED = "L'abonnement pour ce domaine est interdit."
DEMO_SEND_MESSAGE_ERROR = "Pour des raisons de sécurité, ce compte de démonstration n'est pas autorisé à envoyer des messages à des adresses e-mail externes!"
ACCOUNT_ALREADY_EXISTS = "Ce compte existe déjà"
MAIL_SERVER_ERROR = "Une erreur est survenue lors de l'accès au serveur mail"
INVALID_INPUT_ARGUMENT = "Invalid input argument"
UNKNOWN_ERROR = "Erreur inconnue"
[STATIC]

View file

@ -582,6 +582,7 @@ LICENSING_DOMAIN_BANNED = "Subscription for this domain is banned."
DEMO_SEND_MESSAGE_ERROR = "For security purposes, this demo account is not allowed to send messages to external e-mail addresses!"
ACCOUNT_ALREADY_EXISTS = "Account already exists"
MAIL_SERVER_ERROR = "An error has occured while accessing mail server"
INVALID_INPUT_ARGUMENT = "Invalid input argument"
UNKNOWN_ERROR = "Ismeretlen hiba"
[STATIC]

View file

@ -582,6 +582,7 @@ LICENSING_DOMAIN_BANNED = "Áskrift fyrir þetta lén er bönnuð."
DEMO_SEND_MESSAGE_ERROR = "Vegna öryggissjónarmiða, þá hefur þessi sýni aðgangur ekki leyfi til að senda bréf á utanaðkomandi netföng!"
ACCOUNT_ALREADY_EXISTS = "Aðgangur er til núþegar"
MAIL_SERVER_ERROR = "Villa kom upp við tilraun til að tengjast netþjóni"
INVALID_INPUT_ARGUMENT = "Invalid input argument"
UNKNOWN_ERROR = "Óþekkt villa"
[STATIC]

View file

@ -583,6 +583,7 @@ LICENSING_DOMAIN_BANNED = "Questo dominio è stato bannato"
DEMO_SEND_MESSAGE_ERROR = "Per ragioni di sicurezza, questa demo non è abilitata ad inviare email ad inidirizzi esterni"
ACCOUNT_ALREADY_EXISTS = "L'account esiste già"
MAIL_SERVER_ERROR = "È successo un errore nel server mail"
INVALID_INPUT_ARGUMENT = "Invalid input argument"
UNKNOWN_ERROR = "Errore sconosciuto"
[STATIC]

View file

@ -582,6 +582,7 @@ LICENSING_DOMAIN_BANNED = "Subscription for this domain is banned."
DEMO_SEND_MESSAGE_ERROR = "For security purposes, this demo account is not allowed to send messages to external e-mail addresses!"
ACCOUNT_ALREADY_EXISTS = "Account already exists"
MAIL_SERVER_ERROR = "An error has occured while accessing mail server"
INVALID_INPUT_ARGUMENT = "Invalid input argument"
UNKNOWN_ERROR = "Unknown error"
[STATIC]

View file

@ -579,6 +579,7 @@ LICENSING_DOMAIN_BANNED = "사용 금지된 도메인입니다."
DEMO_SEND_MESSAGE_ERROR = "이 테스트 계정은 외부 메일 발송이 금지되어있습니다."
ACCOUNT_ALREADY_EXISTS = "이미 존재하는 계정입니다."
MAIL_SERVER_ERROR = "메일 서버에 연결하는 중 오류가 발생했습니다."
INVALID_INPUT_ARGUMENT = "Invalid input argument"
UNKNOWN_ERROR = "알 수 없는 오류"
[STATIC]

View file

@ -582,6 +582,7 @@ LICENSING_DOMAIN_BANNED = "Abonēšana šim domēnam ir bloķēta."
DEMO_SEND_MESSAGE_ERROR = "Drošīnas iemeslu dēļ, demo konts nedrīks sūtīt e-pastu uz ārējiem e-pastiem!"
ACCOUNT_ALREADY_EXISTS = "Konts jau eksistē"
MAIL_SERVER_ERROR = "Radās kļūda savienojoties ar serveri"
INVALID_INPUT_ARGUMENT = "Invalid input argument"
UNKNOWN_ERROR = "Nezināma kļūda"
[STATIC]

View file

@ -582,6 +582,7 @@ LICENSING_DOMAIN_BANNED = "Subscription for this domain is banned."
DEMO_SEND_MESSAGE_ERROR = "For security purposes, this demo account is not allowed to send messages to external e-mail addresses!"
ACCOUNT_ALREADY_EXISTS = "Account bestaat al"
MAIL_SERVER_ERROR = "Fout bij toegang tot de mail server"
INVALID_INPUT_ARGUMENT = "Invalid input argument"
UNKNOWN_ERROR = "Onbekende fout"
[STATIC]

View file

@ -582,6 +582,7 @@ LICENSING_DOMAIN_BANNED = "Abonnement for dette domenet er forbudt ."
DEMO_SEND_MESSAGE_ERROR = "For sikkerhets skyld , denne demo-konto er ikke lov til å sende meldinger til eksterne e - postadresser !"
ACCOUNT_ALREADY_EXISTS = "Kontoen finnes allerede"
MAIL_SERVER_ERROR = "Det har oppstått en feil under tilgang til e-postserver"
INVALID_INPUT_ARGUMENT = "Invalid input argument"
UNKNOWN_ERROR = "Ukjent feil"
[STATIC]

View file

@ -581,6 +581,7 @@ LICENSING_DOMAIN_BANNED = "Subskrypcja dla tej domeny została zablokowana"
DEMO_SEND_MESSAGE_ERROR = "Ze względów bezpieczeństwa, to konto testowe nie ma możliwości przesyłania, wiadomości na zewnętrzne adresy e-mail."
ACCOUNT_ALREADY_EXISTS = "Konto o takiej nazwie już istnieje"
MAIL_SERVER_ERROR = "Wystąpił błąd w trakcie połączenia z serwerem poczty"
INVALID_INPUT_ARGUMENT = "Invalid input argument"
UNKNOWN_ERROR = "Nieznany błąd"
[STATIC]

View file

@ -585,6 +585,7 @@ LICENSING_DOMAIN_BANNED = "A assinatura para este domínio é proibida."
DEMO_SEND_MESSAGE_ERROR = "Por motivos de segurança, esta conta demo não tem permissão para enviar mensagens para endereços de e-mail externo!"
ACCOUNT_ALREADY_EXISTS = "Esta conta já existe"
MAIL_SERVER_ERROR = "Ocorreu um erro ao acessar o servidor de email"
INVALID_INPUT_ARGUMENT = "Invalid input argument"
UNKNOWN_ERROR = "Erro desconhecido"
[STATIC]

View file

@ -582,6 +582,7 @@ LICENSING_DOMAIN_BANNED = "A assinatura para este domínio é proibida."
DEMO_SEND_MESSAGE_ERROR = "Por motivos de segurança, esta conta demo não tem permissão para enviar mensagens para endereços de e-mail externo!"
ACCOUNT_ALREADY_EXISTS = "Esta conta já existe"
MAIL_SERVER_ERROR = "Ocorreu um erro ao acessar o servidor de email"
INVALID_INPUT_ARGUMENT = "Invalid input argument"
UNKNOWN_ERROR = "Erro desconhecido"
[STATIC]

View file

@ -581,6 +581,7 @@ LICENSING_BANNED = "Licență restricționată."
DEMO_SEND_MESSAGE_ERROR = "Cont demo trimite e-mail la adresele de e-mail externe este interzisă!"
ACCOUNT_ALREADY_EXISTS = "Contul deja există"
MAIL_SERVER_ERROR = "Nu am reușit să accesez serverul de e-mail"
INVALID_INPUT_ARGUMENT = "Invalid input argument"
UNKNOWN_ERROR = "Eroare necunoscută"
[STATIC]

View file

@ -583,6 +583,7 @@ LICENSING_BANNED = "Подписка на данный домен заблоки
DEMO_SEND_MESSAGE_ERROR = "Демо аккаунту отправка писем на внешние почтовые адреса запрещена!"
ACCOUNT_ALREADY_EXISTS = "Аккаунт уже добавлен"
MAIL_SERVER_ERROR = "Ошибка доступа к почтовому серверу"
INVALID_INPUT_ARGUMENT = "Invalid input argument"
UNKNOWN_ERROR = "Неизвестная ошибка"
[STATIC]

View file

@ -582,6 +582,7 @@ LICENSING_DOMAIN_BANNED = "Subscription for this domain is banned."
DEMO_SEND_MESSAGE_ERROR = "For security purposes, this demo account is not allowed to send messages to external e-mail addresses!"
ACCOUNT_ALREADY_EXISTS = "účet už existuje"
MAIL_SERVER_ERROR = "Nastala chyba počas prístupu na poštový server"
INVALID_INPUT_ARGUMENT = "Invalid input argument"
UNKNOWN_ERROR = "Neznáma chyba"
[STATIC]

View file

@ -583,6 +583,7 @@ LICENSING_BANNED = "Підписка на цей домен заблокован
DEMO_SEND_MESSAGE_ERROR = "Демо акаунту надсилання листів на зовнішні поштові адреси заборонена!"
ACCOUNT_ALREADY_EXISTS = "акаунт вже додано"
MAIL_SERVER_ERROR = "Помилка доступу до поштового серверу"
INVALID_INPUT_ARGUMENT = "Invalid input argument"
UNKNOWN_ERROR = "Невідома помилка"
[STATIC]

View file

@ -582,6 +582,7 @@ LICENSING_DOMAIN_BANNED = "此域订阅服务已禁止。"
DEMO_SEND_MESSAGE_ERROR = "出于安全考虑,测试账号无法发送外部邮件。"
ACCOUNT_ALREADY_EXISTS = "账户已存在"
MAIL_SERVER_ERROR = "访问邮件服务器遇到错误。"
INVALID_INPUT_ARGUMENT = "Invalid input argument"
UNKNOWN_ERROR = "未知错误"
[STATIC]

View file

@ -791,6 +791,7 @@ Enums.Notification = {
'MailServerError': 901,
'ClientViewError': 902,
'InvalidInputArgument': 903,
'UnknownNotification': 999,
'UnknownError': 999
};
@ -1420,6 +1421,7 @@ Utils.initNotificationLanguage = function ()
NotificationI18N[Enums.Notification.AccountAlreadyExists] = Utils.i18n('NOTIFICATIONS/ACCOUNT_ALREADY_EXISTS');
NotificationI18N[Enums.Notification.MailServerError] = Utils.i18n('NOTIFICATIONS/MAIL_SERVER_ERROR');
NotificationI18N[Enums.Notification.InvalidInputArgument] = Utils.i18n('NOTIFICATIONS/INVALID_INPUT_ARGUMENT');
NotificationI18N[Enums.Notification.UnknownNotification] = Utils.i18n('NOTIFICATIONS/UNKNOWN_ERROR');
NotificationI18N[Enums.Notification.UnknownError] = Utils.i18n('NOTIFICATIONS/UNKNOWN_ERROR');
};

File diff suppressed because one or more lines are too long

View file

@ -794,6 +794,7 @@ Enums.Notification = {
'MailServerError': 901,
'ClientViewError': 902,
'InvalidInputArgument': 903,
'UnknownNotification': 999,
'UnknownError': 999
};
@ -1423,6 +1424,7 @@ Utils.initNotificationLanguage = function ()
NotificationI18N[Enums.Notification.AccountAlreadyExists] = Utils.i18n('NOTIFICATIONS/ACCOUNT_ALREADY_EXISTS');
NotificationI18N[Enums.Notification.MailServerError] = Utils.i18n('NOTIFICATIONS/MAIL_SERVER_ERROR');
NotificationI18N[Enums.Notification.InvalidInputArgument] = Utils.i18n('NOTIFICATIONS/INVALID_INPUT_ARGUMENT');
NotificationI18N[Enums.Notification.UnknownNotification] = Utils.i18n('NOTIFICATIONS/UNKNOWN_ERROR');
NotificationI18N[Enums.Notification.UnknownError] = Utils.i18n('NOTIFICATIONS/UNKNOWN_ERROR');
};

File diff suppressed because one or more lines are too long