Drop unused user mail templates system

This commit is contained in:
djmaze 2021-09-17 10:32:58 +02:00
parent fd28e65ed6
commit 134deb8d73
37 changed files with 0 additions and 797 deletions

View file

@ -1932,10 +1932,6 @@ class Actions
$aResult[] = Enumerations\Capa::IDENTITIES;
}
if ($oConfig->Get('capa', 'x-templates', true)) {
$aResult[] = Enumerations\Capa::TEMPLATES;
}
if ($oConfig->Get('webmail', 'allow_themes', false)) {
$aResult[] = Enumerations\Capa::THEMES;
}

View file

@ -83,9 +83,6 @@ trait Admin
case Capa::IDENTITIES:
$this->setConfigFromParams($oConfig, $sParamName, 'webmail', 'allow_additional_identities', 'bool');
break;
case Capa::TEMPLATES:
$this->setConfigFromParams($oConfig, $sParamName, 'capa', 'x-templates', 'bool');
break;
case Capa::ATTACHMENT_THUMBNAILS:
$this->setConfigFromParams($oConfig, $sParamName, 'interface', 'show_attachment_thumbnail', 'bool');
break;
@ -150,7 +147,6 @@ trait Admin
$this->setCapaFromParams($oConfig, 'CapaAdditionalAccounts', Capa::ADDITIONAL_ACCOUNTS);
$this->setCapaFromParams($oConfig, 'CapaIdentities', Capa::IDENTITIES);
$this->setCapaFromParams($oConfig, 'CapaTemplates', Capa::TEMPLATES);
$this->setCapaFromParams($oConfig, 'CapaOpenPGP', Capa::OPEN_PGP);
$this->setCapaFromParams($oConfig, 'CapaThemes', Capa::THEMES);
$this->setCapaFromParams($oConfig, 'CapaUserBackground', Capa::USER_BACKGROUND);

View file

@ -1,215 +0,0 @@
<?php
namespace RainLoop\Actions;
use \RainLoop\Enumerations\Capa;
use \RainLoop\Exceptions\ClientException;
use \RainLoop\Model\Account;
use \RainLoop\Model\Template;
use \RainLoop\Notifications;
trait Templates
{
/**
* @throws \MailSo\Base\Exceptions\Exception
*/
public function DoTemplateSetup() : array
{
$oAccount = $this->getAccountFromToken();
if (!$this->GetCapa(false, Capa::TEMPLATES, $oAccount))
{
return $this->FalseResponse(__FUNCTION__);
}
$oTemplate = new Template();
if (!$oTemplate->FromJSON($this->GetActionParams(), true))
{
throw new ClientException(Notifications::InvalidInputArgument);
}
if ('' === $oTemplate->Id())
{
$oTemplate->GenerateID();
}
$aTemplatesForSave = array();
$aTemplates = $this->GetTemplates($oAccount);
foreach ($aTemplates as $oItem)
{
if ($oItem && $oItem->Id() !== $oTemplate->Id())
{
$aTemplatesForSave[] = $oItem;
}
}
$aTemplatesForSave[] = $oTemplate;
return $this->DefaultResponse(__FUNCTION__, $this->SetTemplates($oAccount, $aTemplatesForSave));
}
/**
* @throws \MailSo\Base\Exceptions\Exception
*/
public function DoTemplateDelete() : array
{
$oAccount = $this->getAccountFromToken();
if (!$this->GetCapa(false, Capa::TEMPLATES, $oAccount))
{
return $this->FalseResponse(__FUNCTION__);
}
$sId = \trim($this->GetActionParam('IdToDelete', ''));
if (empty($sId))
{
throw new ClientException(Notifications::UnknownError);
}
$aNew = array();
$aTemplates = $this->GetTemplates($oAccount);
foreach ($aTemplates as $oItem)
{
if ($oItem && $sId !== $oItem->Id())
{
$aNew[] = $oItem;
}
}
return $this->DefaultResponse(__FUNCTION__, $this->SetTemplates($oAccount, $aNew));
}
/**
* @throws \MailSo\Base\Exceptions\Exception
*/
public function DoTemplateGetByID() : array
{
$oAccount = $this->getAccountFromToken();
if (!$this->GetCapa(false, Capa::TEMPLATES, $oAccount))
{
return $this->FalseResponse(__FUNCTION__);
}
$sId = \trim($this->GetActionParam('ID', ''));
if (empty($sId))
{
throw new ClientException(Notifications::UnknownError);
}
$oTemplate = false;
$aTemplates = $this->GetTemplates($oAccount);
foreach ($aTemplates as $oItem)
{
if ($oItem && $sId === $oItem->Id())
{
$oTemplate = $oItem;
break;
}
}
$oTemplate->SetPopulateAlways(true);
return $this->DefaultResponse(__FUNCTION__, $oTemplate);
}
/**
* @throws \MailSo\Base\Exceptions\Exception
*/
public function DoTemplates() : array
{
$oAccount = $this->getAccountFromToken();
if (!$this->GetCapa(false, Capa::TEMPLATES, $oAccount))
{
return $this->FalseResponse(__FUNCTION__);
}
return $this->DefaultResponse(__FUNCTION__, array(
'Templates' => $this->GetTemplates($oAccount)
));
}
private function GetTemplates(?Account $oAccount) : array
{
$aTemplates = array();
if ($oAccount)
{
$aData = array();
$sData = $this->StorageProvider(true)->Get($oAccount,
\RainLoop\Providers\Storage\Enumerations\StorageType::CONFIG,
'templates'
);
if ('' !== $sData && '[' === \substr($sData, 0, 1))
{
$aData = \json_decode($sData, true);
}
if (\is_array($aData) && 0 < \count($aData))
{
foreach ($aData as $aItem)
{
$oItem = new Template();
$oItem->FromJSON($aItem);
if ($oItem && $oItem->Validate())
{
\array_push($aTemplates, $oItem);
}
}
}
if (1 < \count($aTemplates))
{
$sOrder = $this->StorageProvider()->Get($oAccount,
\RainLoop\Providers\Storage\Enumerations\StorageType::CONFIG,
'templates_order'
);
$aOrder = empty($sOrder) ? array() : \json_decode($sOrder, true);
if (\is_array($aOrder) && 1 < \count($aOrder))
{
\usort($aTemplates, function ($a, $b) use ($aOrder) {
return \array_search($a->Id(), $aOrder) < \array_search($b->Id(), $aOrder) ? -1 : 1;
});
}
}
}
return $aTemplates;
}
private function GetTemplateByID(Account $oAccount, string $sID) : ?\RainLoop\Model\Identity
{
$aTemplates = $this->GetTemplates($oAccount);
foreach ($aTemplates as $oIdentity)
{
if ($oIdentity && $sID === $oIdentity->Id())
{
return $oIdentity;
}
}
return isset($aTemplates[0]) ? $aTemplates[0] : null;
}
private function SetTemplates(Account $oAccount, array $aTemplates = array()) : array
{
$aResult = array();
foreach ($aTemplates as $oItem)
{
$aResult[] = $oItem->ToSimpleJSON();
}
return $this->StorageProvider(true)->Put($oAccount,
\RainLoop\Providers\Storage\Enumerations\StorageType::CONFIG,
'templates',
\json_encode($aResult)
);
}
}

View file

@ -14,7 +14,6 @@ trait User
use Filters;
use Folders;
use Messages;
use Templates;
/**
* @throws \MailSo\Base\Exceptions\Exception

View file

@ -194,7 +194,6 @@ class Application extends \RainLoop\Config\AbstractConfig
'reload' => array(true),
'search' => array(true),
'search_adv' => array(true),
'x-templates' => array(false),
'dangerous_actions' => array(true),
'message_actions' => array(true),
'messagelist_actions' => array(true),

View file

@ -1,106 +0,0 @@
<?php
namespace RainLoop\Model;
class Template implements \JsonSerializable
{
/**
* @var string
*/
private $sId;
/**
* @var string
*/
private $sName;
/**
* @var string
*/
private $sBody;
/**
* @var bool
*/
private $bPopulateAlways;
function __construct(string $sId = '', string $sName = '', string $sBody = '')
{
$this->sId = $sId;
$this->sName = $sName;
$this->sBody = $sBody;
$this->bPopulateAlways = false;
}
public function Id() : string
{
return $this->sId;
}
public function Name() : string
{
return $this->sName;
}
public function Body() : string
{
return $this->sBody;
}
public function SetPopulateAlways(bool $bPopulateAlways)
{
$this->bPopulateAlways = $bPopulateAlways;
}
public function FromJSON(array $aData, bool $bJson = false) : bool
{
if (isset($aData['ID'], $aData['Name'], $aData['Body']))
{
$this->sId = $aData['ID'];
$this->sName = $aData['Name'];
$this->sBody = $aData['Body'];
return true;
}
return false;
}
public function ToSimpleJSON() : array
{
return array(
'ID' => $this->Id(),
'Name' => $this->Name(),
'Body' => $this->Body()
);
}
public function jsonSerialize()
{
$sBody = $this->Body();
$bPopulated = true;
if ($bPopulated && !$this->bPopulateAlways) {
if (1024 * 5 < \strlen($sBody) || true) {
$bPopulated = false;
$sBody = '';
}
}
return array(
'@Object' => 'Object/Template',
'id' => $this->Id(),
'name' => $this->Name(),
'body' => $sBody,
'populated' => $bPopulated
);
}
public function GenerateID() : bool
{
return $this->sId = \MailSo\Base\Utils::Md5Rand();
}
public function Validate() : bool
{
return 0 < \strlen($this->sBody);
}
}

View file

@ -32,7 +32,6 @@
"LABEL_ATTACHMENT_SIZE_LIMIT": "Größenlimit für Anhänge",
"LABEL_ALLOW_ADDITIONAL_ACCOUNTS": "Zusätzliche Konten erlauben",
"LABEL_ALLOW_IDENTITIES": "Mehrere Identitäten erlauben",
"LABEL_ALLOW_TEMPLATES": "Vorlagen erlauben",
"ALERT_DATA_ACCESS": "Data folder is accessible. Please configure your web server to hide the data folder from external access. Read more here:",
"ALERT_WARNING": "Warnung!",
"HTML_ALERT_WEAK_PASSWORD": "Sie verwenden das Standard-Admin-Passwort.\n<br \/>\nBitte <strong><a href=\"#\/security\">ändern<\/a><\/strong> Sie\naus Sicherheitsgründen das Passwort jetzt.\n"

View file

@ -355,7 +355,6 @@
"LABEL_ACCOUNTS_NAME": "Konten",
"LABEL_IDENTITIES_NAME": "Identitäten",
"LABEL_FILTERS_NAME": "Filter",
"LABEL_TEMPLATES_NAME": "Vorlagen",
"LABEL_SECURITY_NAME": "Sicherheit",
"LABEL_THEMES_NAME": "Themen"
},

View file

@ -32,7 +32,6 @@
"LABEL_ATTACHMENT_SIZE_LIMIT": "Attachment size limit",
"LABEL_ALLOW_ADDITIONAL_ACCOUNTS": "Allow additional accounts",
"LABEL_ALLOW_IDENTITIES": "Allow multiple identities",
"LABEL_ALLOW_TEMPLATES": "Allow templates",
"ALERT_DATA_ACCESS": "Data folder is accessible. Please configure your web server to hide the data folder from external access. Read more here:",
"ALERT_WARNING": "Warning!",
"HTML_ALERT_WEAK_PASSWORD": "You are using the default admin password.\n<br \/>\nFor security reasons please\n<strong><a href=\"#\/security\">change<\/a><\/strong>\npassword to something else now.\n"

View file

@ -355,7 +355,6 @@
"LABEL_ACCOUNTS_NAME": "Accounts",
"LABEL_IDENTITIES_NAME": "Identities",
"LABEL_FILTERS_NAME": "Filters",
"LABEL_TEMPLATES_NAME": "Templates",
"LABEL_SECURITY_NAME": "Security",
"LABEL_THEMES_NAME": "Themes"
},

View file

@ -32,7 +32,6 @@
"LABEL_ATTACHMENT_SIZE_LIMIT": "Tamaño máximo para adjuntos",
"LABEL_ALLOW_ADDITIONAL_ACCOUNTS": "Permitir cuentas adicionales",
"LABEL_ALLOW_IDENTITIES": "Permitir múltiples identidades",
"LABEL_ALLOW_TEMPLATES": "Permitir plantillas",
"ALERT_DATA_ACCESS": "Data folder is accessible. Please configure your web server to hide the data folder from external access. Read more here:",
"ALERT_WARNING": "¡Atención!",
"HTML_ALERT_WEAK_PASSWORD": "Estas utilizando la contraseña por defecto.\n<br \/>\nDebido a razones de seguridad, debes\n<strong><a href=\"#\/security\">cambiar<\/a><\/strong>\ntu contraseña inmediatamente.\n"

View file

@ -355,7 +355,6 @@
"LABEL_ACCOUNTS_NAME": "Cuentas",
"LABEL_IDENTITIES_NAME": "Identidades",
"LABEL_FILTERS_NAME": "Filtros",
"LABEL_TEMPLATES_NAME": "Plantillas",
"LABEL_SECURITY_NAME": "Seguridad",
"LABEL_THEMES_NAME": "Temas"
},

View file

@ -32,7 +32,6 @@
"LABEL_ATTACHMENT_SIZE_LIMIT": "Taille limite des pièces jointes",
"LABEL_ALLOW_ADDITIONAL_ACCOUNTS": "Autoriser les comptes supplémentaires",
"LABEL_ALLOW_IDENTITIES": "Autoriser les identités multiples",
"LABEL_ALLOW_TEMPLATES": "Autoriser les modèles",
"ALERT_DATA_ACCESS": "Data folder is accessible. Please configure your web server to hide the data folder from external access. Read more here:",
"ALERT_WARNING": "ATTENTION !",
"HTML_ALERT_WEAK_PASSWORD": "Vous utilisez le mot de passe administrateur par défaut.\n<br \/>\nPour des raisons de sécurité, veuillez\n<strong><a href=\"#\/security\">changer le mot de passe <\/a><\/strong>\ndès maintenant.\n"

View file

@ -355,7 +355,6 @@
"LABEL_ACCOUNTS_NAME": "Comptes",
"LABEL_IDENTITIES_NAME": "Identités",
"LABEL_FILTERS_NAME": "Filtres",
"LABEL_TEMPLATES_NAME": "Modèles",
"LABEL_SECURITY_NAME": "Sécurité",
"LABEL_THEMES_NAME": "Thèmes"
},

View file

@ -32,7 +32,6 @@
"LABEL_ATTACHMENT_SIZE_LIMIT": "Melléklet méret korlát",
"LABEL_ALLOW_ADDITIONAL_ACCOUNTS": "További fiókok engedélyezése",
"LABEL_ALLOW_IDENTITIES": "Több identitás engedélyezése",
"LABEL_ALLOW_TEMPLATES": "Sablonok engedélyezése",
"ALERT_DATA_ACCESS": "A RainLoop adatmappája hozzáférhető. Kérlek állítsd be úgy a webszervert, hogy az adatmappát rejtse el a külső hozzáférés elől. További tudnivalók itt:",
"ALERT_WARNING": "Figyelmeztetés!",
"HTML_ALERT_WEAK_PASSWORD": "Az alapértelmezett admin jelszót használod\n<br \/>\nBiztonsági okokból kérlek\n<strong><a href=\"#\/security\">változtasd meg<\/a><\/strong>\na jelszót valami másra!\n"

View file

@ -355,7 +355,6 @@
"LABEL_ACCOUNTS_NAME": "Fiókok",
"LABEL_IDENTITIES_NAME": "Identitások",
"LABEL_FILTERS_NAME": "Szűrők",
"LABEL_TEMPLATES_NAME": "Sablonok",
"LABEL_SECURITY_NAME": "Biztonság",
"LABEL_THEMES_NAME": "Témák"
},

View file

@ -32,7 +32,6 @@
"LABEL_ATTACHMENT_SIZE_LIMIT": "Maximale bijlage grootte",
"LABEL_ALLOW_ADDITIONAL_ACCOUNTS": "Sta extra accounts toe",
"LABEL_ALLOW_IDENTITIES": "Meerdere identiteiten toestaan",
"LABEL_ALLOW_TEMPLATES": "Sta templates toe",
"ALERT_DATA_ACCESS": "Data folder is accessible. Please configure your web server to hide the data folder from external access. Read more here:",
"ALERT_WARNING": "Waarschuwing!",
"HTML_ALERT_WEAK_PASSWORD": "U gebruikt het standaard beheer wachtwoord.\n<br \/>\n<strong><a href=\"#\/security\">Wijzig<\/a><\/strong>\na.u.b. voor uw veiligheid direct het wachtwoord.\n"

View file

@ -355,7 +355,6 @@
"LABEL_ACCOUNTS_NAME": "Accounts",
"LABEL_IDENTITIES_NAME": "Identiteiten",
"LABEL_FILTERS_NAME": "Filters",
"LABEL_TEMPLATES_NAME": "Templates",
"LABEL_SECURITY_NAME": "Beveiliging",
"LABEL_THEMES_NAME": "Thema's"
},

View file

@ -32,7 +32,6 @@
"LABEL_ATTACHMENT_SIZE_LIMIT": "Bilagor storlek",
"LABEL_ALLOW_ADDITIONAL_ACCOUNTS": "Tillåt ytterligare konton",
"LABEL_ALLOW_IDENTITIES": "Tillåt multiidentiteter",
"LABEL_ALLOW_TEMPLATES": "Tillåt mallar",
"ALERT_DATA_ACCESS": "RainLoops datamapp är åtkomstbar. Var vänlig konfigurera din webb-server för att förhindra extern åtkomst och synlighet. Läs mer här: ",
"ALERT_WARNING": "Varning!",
"HTML_ALERT_WEAK_PASSWORD": "Du använder standardlösenord.\n<br \/>\nFör säkerhetsskäl\n<strong><a href=\"#\/security\">ändra<\/a><\/strong>\nlösenord till något annat\n"

View file

@ -355,7 +355,6 @@
"LABEL_ACCOUNTS_NAME": "Konton",
"LABEL_IDENTITIES_NAME": "Identiteter",
"LABEL_FILTERS_NAME": "Filter",
"LABEL_TEMPLATES_NAME": "Templates",
"LABEL_SECURITY_NAME": "Säkerhet",
"LABEL_THEMES_NAME": "Teman"
},

View file

@ -32,7 +32,6 @@
"LABEL_ATTACHMENT_SIZE_LIMIT": "附件大小限制",
"LABEL_ALLOW_ADDITIONAL_ACCOUNTS": "允许额外的账户",
"LABEL_ALLOW_IDENTITIES": "允许多重身份",
"LABEL_ALLOW_TEMPLATES": "允许使用模板",
"ALERT_DATA_ACCESS": "数据文件夹可被访问。请配置您的 Web 服务器以阻止从外部访问数据文件夹。获取更多帮助:",
"ALERT_WARNING": "警告!",
"HTML_ALERT_WEAK_PASSWORD": "您正在使用默认的管理员密码\n<br \/>\n安全起见请立即将密码\n<strong><a href=\"#\/security\">更改<\/a><\/strong>\n为其他的字符串。\n"

View file

@ -355,7 +355,6 @@
"LABEL_ACCOUNTS_NAME": "账户",
"LABEL_IDENTITIES_NAME": "身份",
"LABEL_FILTERS_NAME": "筛选条件",
"LABEL_TEMPLATES_NAME": "模版",
"LABEL_SECURITY_NAME": "安全",
"LABEL_THEMES_NAME": "主题"
},

View file

@ -128,18 +128,5 @@
}"></div>
</div>
</div>
<!--
<div class="control-group">
<div class="controls">
<div data-bind="component: {
name: 'Checkbox',
params: {
label: 'TAB_GENERAL/LABEL_ALLOW_TEMPLATES',
value: capaTemplates
}
}"></div>
</div>
</div>
-->
</div>
</div>

View file

@ -1,40 +0,0 @@
<div class="modal fade b-template-add-content" data-bind="modal: modalVisibility">
<div class="modal-header g-ui-user-select-none">
<button type="button" class="close" data-bind="command: cancelCommand">×</button>
<h3>
<span data-bind="visible: '' === id()" data-i18n="POPUPS_ADD_TEMPLATE/TITLE_ADD_TEMPLATE"></span>
<span data-bind="visible: '' !== id()" data-i18n="POPUPS_ADD_TEMPLATE/TITLE_UPDATE_TEMPLATE"></span>
</h3>
</div>
<div class="modal-body">
<div class="form-horizontal g-ui-user-select-none">
<div class="alert" data-bind="visible: '' !== submitError()">
<button type="button" class="close" data-bind="click: function () { submitError('') }">×</button>
<span data-bind="text: submitError"></span>
</div>
<br />
<div class="control-group" data-bind="css: {'error': nameError}">
<label class="control-label" data-i18n="GLOBAL/NAME"></label>
<div class="controls">
<input type="text" class="inputName input-xlarge"
autofocus="" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"
data-bind="textInput: name, onEnter: addTemplateCommand" />
</div>
</div>
</div>
<hr />
<div class="form-horizontal">
<div class="control-group" data-bind="css: {'error': bodyError}">
<div class="e-template-place" data-bind="initDom: signatureDom"></div>
</div>
</div>
</div>
<div class="modal-footer">
<a class="btn buttonAddAccount" data-bind="command: addTemplateCommand">
<i data-bind="visible: '' == id(), css: {'icon-user-add': !submitRequest(), 'icon-spinner': submitRequest()}"></i>
<span data-bind="visible: '' == id()" data-i18n="POPUPS_ADD_TEMPLATE/BUTTON_ADD_TEMPLATE"></span>
<i data-bind="visible: '' !== id(), css: {'icon-ok': !submitRequest(), 'icon-spinner': submitRequest()}"></i>
<span data-bind="visible: '' !== id()" data-i18n="POPUPS_ADD_TEMPLATE/BUTTON_UPDATE_TEMPLATE"></span>
</a>
</div>
</div>

View file

@ -1,28 +0,0 @@
<div class="b-settings-templates g-ui-user-select-none">
<div class="legend">
<span data-i18n="SETTINGS_TEMPLATES/LEGEND_TEMPLATES"></span>
&nbsp;&nbsp;&nbsp;
<i class="icon-spinner" style="margin-top: 5px" data-bind="visible: templates.loading"></i>
</div>
<a class="btn" data-bind="click: addNewTemplate">
<i class="icon-user-add"></i>
<span data-i18n="SETTINGS_TEMPLATES/BUTTON_ADD_TEMPLATE"></span>
</a>
<table class="table table-hover list-table templates-list" data-bind="i18nUpdate: templates">
<tbody data-bind="foreach: templates">
<tr draggable="true" data-bind="sortableItem: { list: $root.templates }">
<td class="e-action">
<i class="fontastic drag-handle"></i>
<span class="template-name" data-bind="text: name"></span>
</td>
<td>
<a class="btn btn-small btn-small-small btn-danger pull-right button-confirm-delete button-delete-transitions" data-bind="css: {'delete-access': deleteAccess}, click: function(oTemplate) { $root.deleteTemplate(oTemplate); }"
data-i18n="GLOBAL/ARE_YOU_SURE"></a>
</td>
<td>
<span class="delete-template fontastic" data-bind="visible: !deleteAccess(), click: function (oTemplate) { $root.templateForDeletion(oTemplate); }">🗑</span>
</td>
</tr>
</tbody>
</table>
</div>