Added "Attachment size limit" setting (Admin panel) (#114)

This commit is contained in:
RainLoop Team 2014-06-24 01:32:09 +04:00
parent 40a0f8b821
commit 0b5e4f534d
14 changed files with 387 additions and 224 deletions

View file

@ -19,6 +19,15 @@ function AdminGeneral()
this.capaAdditionalAccounts = oData.capaAdditionalAccounts;
this.capaAdditionalIdentities = oData.capaAdditionalIdentities;
this.mainAttachmentLimit = ko.observable(Utils.pInt(RL.settingsGet('AttachmentLimit')) / (1024 * 1024)).extend({'posInterer': 25});
this.uploadData = RL.settingsGet('PhpUploadSizes');
this.uploadDataDesc = this.uploadData && (this.uploadData['upload_max_filesize'] || this.uploadData['post_max_size']) ?
[
this.uploadData['upload_max_filesize'] ? 'upload_max_filesize = ' + this.uploadData['upload_max_filesize'] + '; ' : '',
this.uploadData['post_max_size'] ? 'post_max_size = ' + this.uploadData['post_max_size'] : ''
].join('')
: '';
this.themesOptions = ko.computed(function () {
return _.map(oData.themes(), function (sTheme) {
return {
@ -34,6 +43,7 @@ function AdminGeneral()
this.weakPassword = !!RL.settingsGet('WeakPassword');
this.attachmentLimitTrigger = ko.observable(Enums.SaveSettingsStep.Idle);
this.languageTrigger = ko.observable(Enums.SaveSettingsStep.Idle);
this.themeTrigger = ko.observable(Enums.SaveSettingsStep.Idle);
}
@ -46,10 +56,17 @@ AdminGeneral.prototype.onBuild = function ()
_.delay(function () {
var
f1 = Utils.settingsSaveHelperSimpleFunction(self.attachmentLimitTrigger, self),
f2 = Utils.settingsSaveHelperSimpleFunction(self.languageTrigger, self),
f3 = Utils.settingsSaveHelperSimpleFunction(self.themeTrigger, self)
;
self.mainAttachmentLimit.subscribe(function (sValue) {
RL.remote().saveAdminConfig(f1, {
'AttachmentLimit': Utils.pInt(sValue)
});
});
self.language.subscribe(function (sValue) {
RL.remote().saveAdminConfig(f2, {
'Language': Utils.trim(sValue)
@ -99,3 +116,12 @@ AdminGeneral.prototype.selectLanguage = function ()
{
kn.showScreenPopup(PopupsLanguagesViewModel);
};
/**
* @return {string}
*/
AdminGeneral.prototype.phpInfoLink = function ()
{
return RL.link().phpInfo();
};

View file

@ -722,6 +722,30 @@ ko.extenders.trimmer = function (oTarget)
return oResult;
};
ko.extenders.posInterer = function (oTarget, iDefault)
{
var oResult = ko.computed({
'read': oTarget,
'write': function (sNewValue) {
var iNew = Utils.pInt(sNewValue.toString(), iDefault);
if (0 >= iNew)
{
iNew = iDefault;
}
if (iNew === oTarget() && '' + iNew !== '' + sNewValue)
{
oTarget(iNew + 1);
}
oTarget(iNew);
}
});
oResult(oTarget());
return oResult;
};
ko.extenders.reversible = function (oTarget)
{
var mValue = oTarget();

View file

@ -46,11 +46,13 @@ Utils.isPosNumeric = function (mValue, bIncludeZero)
/**
* @param {*} iValue
* @param {number=} iDefault = 0
* @return {number}
*/
Utils.pInt = function (iValue)
Utils.pInt = function (iValue, iDefault)
{
return Utils.isNormal(iValue) && '' !== iValue ? window.parseInt(iValue, 10) : 0;
var iResult = Utils.isNormal(iValue) && '' !== iValue ? window.parseInt(iValue, 10) : (iDefault || 0);
return window.isNaN(iResult) ? (iDefault || 0) : iResult;
};
/**

View file

@ -44,11 +44,11 @@ function PopupsDomainViewModel()
this.name.focused = ko.observable(false);
this.imapServer = ko.observable('');
this.imapPort = ko.observable(Consts.Values.ImapDefaulPort);
this.imapPort = ko.observable('' + Consts.Values.ImapDefaulPort);
this.imapSecure = ko.observable(Enums.ServerSecure.None);
this.imapShortLogin = ko.observable(false);
this.smtpServer = ko.observable('');
this.smtpPort = ko.observable(Consts.Values.SmtpDefaulPort);
this.smtpPort = ko.observable('' + Consts.Values.SmtpDefaulPort);
this.smtpSecure = ko.observable(Enums.ServerSecure.None);
this.smtpShortLogin = ko.observable(false);
this.smtpAuth = ko.observable(true);
@ -83,11 +83,11 @@ function PopupsDomainViewModel()
!this.edit(),
this.name(),
this.imapServer(),
this.imapPort(),
Utils.pInt(this.imapPort()),
this.imapSecure(),
this.imapShortLogin(),
this.smtpServer(),
this.smtpPort(),
Utils.pInt(this.smtpPort()),
this.smtpSecure(),
this.smtpShortLogin(),
this.smtpAuth(),
@ -105,10 +105,10 @@ function PopupsDomainViewModel()
_.bind(this.onTestConnectionResponse, this),
this.name(),
this.imapServer(),
this.imapPort(),
Utils.pInt(this.imapPort()),
this.imapSecure(),
this.smtpServer(),
this.smtpPort(),
Utils.pInt(this.smtpPort()),
this.smtpSecure(),
this.smtpAuth()
);
@ -141,13 +141,13 @@ function PopupsDomainViewModel()
case '0':
if (993 === iPort)
{
this.imapPort(143);
this.imapPort('143');
}
break;
case '1':
if (143 === iPort)
{
this.imapPort(993);
this.imapPort('993');
}
break;
}
@ -161,19 +161,19 @@ function PopupsDomainViewModel()
case '0':
if (465 === iPort || 587 === iPort)
{
this.smtpPort(25);
this.smtpPort('25');
}
break;
case '1':
if (25 === iPort || 587 === iPort)
{
this.smtpPort(465);
this.smtpPort('465');
}
break;
case '2':
if (25 === iPort || 465 === iPort)
{
this.smtpPort(587);
this.smtpPort('587');
}
break;
}
@ -253,11 +253,11 @@ PopupsDomainViewModel.prototype.onShow = function (oDomain)
this.name(Utils.trim(oDomain.Name));
this.imapServer(Utils.trim(oDomain.IncHost));
this.imapPort(Utils.pInt(oDomain.IncPort));
this.imapPort('' + Utils.pInt(oDomain.IncPort));
this.imapSecure(Utils.trim(oDomain.IncSecure));
this.imapShortLogin(!!oDomain.IncShortLogin);
this.smtpServer(Utils.trim(oDomain.OutHost));
this.smtpPort(Utils.pInt(oDomain.OutPort));
this.smtpPort('' + Utils.pInt(oDomain.OutPort));
this.smtpSecure(Utils.trim(oDomain.OutSecure));
this.smtpShortLogin(!!oDomain.OutShortLogin);
this.smtpAuth(!!oDomain.OutAuth);
@ -284,11 +284,11 @@ PopupsDomainViewModel.prototype.clearForm = function ()
this.name.focused(false);
this.imapServer('');
this.imapPort(Consts.Values.ImapDefaulPort);
this.imapPort('' + Consts.Values.ImapDefaulPort);
this.imapSecure(Enums.ServerSecure.None);
this.imapShortLogin(false);
this.smtpServer('');
this.smtpPort(Consts.Values.SmtpDefaulPort);
this.smtpPort('' + Consts.Values.SmtpDefaulPort);
this.smtpSecure(Enums.ServerSecure.None);
this.smtpShortLogin(false);
this.smtpAuth(true);

View file

@ -476,6 +476,7 @@ gulp.task('rainloop:setup', ['rainloop:copy'], function() {
dist = cfg.releasesPath + '/webmail/' + versionFull + '/src/'
;
fs.writeFileSync(dist + 'data/VERSION', versionFull);
fs.writeFileSync(dist + 'data/EMPTY', versionFull);
fs.writeFileSync(dist + 'index.php',

View file

@ -1197,6 +1197,11 @@ class Actions
$aResult['WeakPassword'] = $oConfig->ValidatePassword('12345');
$aResult['CoreAccess'] = $this->rainLoopCoreAccess();
$aResult['PhpUploadSizes'] = array(
'upload_max_filesize' => \ini_get('upload_max_filesize'),
'post_max_size' => \ini_get('post_max_size')
);
}
$aResult['Capa'] = $this->Capa(true);
@ -2180,6 +2185,8 @@ class Actions
$this->setConfigFromParams($oConfig, 'AllowLanguagesOnSettings', 'webmail', 'allow_languages_on_settings', 'bool');
$this->setConfigFromParams($oConfig, 'AllowLanguagesOnLogin', 'login', 'allow_languages_on_login', 'bool');
$this->setConfigFromParams($oConfig, 'AllowCustomLogin', 'login', 'allow_custom_login', 'bool');
$this->setConfigFromParams($oConfig, 'AttachmentLimit', 'webmail', 'attachment_size_limit', 'int');
$this->setConfigFromParams($oConfig, 'LoginDefaultDomain', 'login', 'default_domain', 'string');
$this->setConfigFromParams($oConfig, 'ContactsEnable', 'contacts', 'enable', 'bool');

View file

@ -48,6 +48,40 @@
</label>
</div>
</div>
<div class="control-group">
<div class="controls">
<label class="inline" data-bind="click: function () { capaGravatar(!capaGravatar()); }">
<i data-bind="css: capaGravatar() ? 'icon-checkbox-checked' : 'icon-checkbox-unchecked'"></i>
Allow Gravatar
</label>
(<a class="g-ui-link" href="http://en.gravatar.com/" target="_blank">http://en.gravatar.com/</a>)
</div>
</div>
<div class="legend">
Main
</div>
<div class="control-group">
<label class="control-label">
Attachment
size limit
</label>
<div class="controls">
<input class="span1" type="text" maxlength="3" data-bind="value: mainAttachmentLimit, saveTrigger: attachmentLimitTrigger" /> MB
<div data-bind="saveTrigger: attachmentLimitTrigger"></div>
<br />
<br />
<span class="well well-small" data-bind="visible: '' !== uploadDataDesc">
<b>PHP:</b>
&nbsp;
<span data-bind="text: uploadDataDesc"></span>
</span>
&nbsp;&nbsp;&nbsp;
<a href="#" target="_blank" class="btn btn-small" data-bind="link: phpInfoLink()">
<i class="icon-info"></i>
</a>
</div>
</div>
<br />
<div class="control-group">
<div class="controls">
<label data-bind="click: function () { capaAdditionalAccounts(!capaAdditionalAccounts()); }">
@ -60,14 +94,5 @@
</label>
</div>
</div>
<div class="control-group">
<div class="controls">
<label class="inline" data-bind="click: function () { capaGravatar(!capaGravatar()); }">
<i data-bind="css: capaGravatar() ? 'icon-checkbox-checked' : 'icon-checkbox-unchecked'"></i>
Allow Gravatar
</label>
(<a class="g-ui-link" href="http://en.gravatar.com/" target="_blank">http://en.gravatar.com/</a>)
</div>
</div>
</div>
</div>

View file

@ -843,11 +843,13 @@ Utils.isPosNumeric = function (mValue, bIncludeZero)
/**
* @param {*} iValue
* @param {number=} iDefault = 0
* @return {number}
*/
Utils.pInt = function (iValue)
Utils.pInt = function (iValue, iDefault)
{
return Utils.isNormal(iValue) && '' !== iValue ? window.parseInt(iValue, 10) : 0;
var iResult = Utils.isNormal(iValue) && '' !== iValue ? window.parseInt(iValue, 10) : (iDefault || 0);
return window.isNaN(iResult) ? (iDefault || 0) : iResult;
};
/**
@ -3435,6 +3437,30 @@ ko.extenders.trimmer = function (oTarget)
return oResult;
};
ko.extenders.posInterer = function (oTarget, iDefault)
{
var oResult = ko.computed({
'read': oTarget,
'write': function (sNewValue) {
var iNew = Utils.pInt(sNewValue.toString(), iDefault);
if (0 >= iNew)
{
iNew = iDefault;
}
if (iNew === oTarget() && '' + iNew !== '' + sNewValue)
{
oTarget(iNew + 1);
}
oTarget(iNew);
}
});
oResult(oTarget());
return oResult;
};
ko.extenders.reversible = function (oTarget)
{
var mValue = oTarget();
@ -5197,11 +5223,11 @@ function PopupsDomainViewModel()
this.name.focused = ko.observable(false);
this.imapServer = ko.observable('');
this.imapPort = ko.observable(Consts.Values.ImapDefaulPort);
this.imapPort = ko.observable('' + Consts.Values.ImapDefaulPort);
this.imapSecure = ko.observable(Enums.ServerSecure.None);
this.imapShortLogin = ko.observable(false);
this.smtpServer = ko.observable('');
this.smtpPort = ko.observable(Consts.Values.SmtpDefaulPort);
this.smtpPort = ko.observable('' + Consts.Values.SmtpDefaulPort);
this.smtpSecure = ko.observable(Enums.ServerSecure.None);
this.smtpShortLogin = ko.observable(false);
this.smtpAuth = ko.observable(true);
@ -5236,11 +5262,11 @@ function PopupsDomainViewModel()
!this.edit(),
this.name(),
this.imapServer(),
this.imapPort(),
Utils.pInt(this.imapPort()),
this.imapSecure(),
this.imapShortLogin(),
this.smtpServer(),
this.smtpPort(),
Utils.pInt(this.smtpPort()),
this.smtpSecure(),
this.smtpShortLogin(),
this.smtpAuth(),
@ -5258,10 +5284,10 @@ function PopupsDomainViewModel()
_.bind(this.onTestConnectionResponse, this),
this.name(),
this.imapServer(),
this.imapPort(),
Utils.pInt(this.imapPort()),
this.imapSecure(),
this.smtpServer(),
this.smtpPort(),
Utils.pInt(this.smtpPort()),
this.smtpSecure(),
this.smtpAuth()
);
@ -5294,13 +5320,13 @@ function PopupsDomainViewModel()
case '0':
if (993 === iPort)
{
this.imapPort(143);
this.imapPort('143');
}
break;
case '1':
if (143 === iPort)
{
this.imapPort(993);
this.imapPort('993');
}
break;
}
@ -5314,19 +5340,19 @@ function PopupsDomainViewModel()
case '0':
if (465 === iPort || 587 === iPort)
{
this.smtpPort(25);
this.smtpPort('25');
}
break;
case '1':
if (25 === iPort || 587 === iPort)
{
this.smtpPort(465);
this.smtpPort('465');
}
break;
case '2':
if (25 === iPort || 465 === iPort)
{
this.smtpPort(587);
this.smtpPort('587');
}
break;
}
@ -5406,11 +5432,11 @@ PopupsDomainViewModel.prototype.onShow = function (oDomain)
this.name(Utils.trim(oDomain.Name));
this.imapServer(Utils.trim(oDomain.IncHost));
this.imapPort(Utils.pInt(oDomain.IncPort));
this.imapPort('' + Utils.pInt(oDomain.IncPort));
this.imapSecure(Utils.trim(oDomain.IncSecure));
this.imapShortLogin(!!oDomain.IncShortLogin);
this.smtpServer(Utils.trim(oDomain.OutHost));
this.smtpPort(Utils.pInt(oDomain.OutPort));
this.smtpPort('' + Utils.pInt(oDomain.OutPort));
this.smtpSecure(Utils.trim(oDomain.OutSecure));
this.smtpShortLogin(!!oDomain.OutShortLogin);
this.smtpAuth(!!oDomain.OutAuth);
@ -5437,11 +5463,11 @@ PopupsDomainViewModel.prototype.clearForm = function ()
this.name.focused(false);
this.imapServer('');
this.imapPort(Consts.Values.ImapDefaulPort);
this.imapPort('' + Consts.Values.ImapDefaulPort);
this.imapSecure(Enums.ServerSecure.None);
this.imapShortLogin(false);
this.smtpServer('');
this.smtpPort(Consts.Values.SmtpDefaulPort);
this.smtpPort('' + Consts.Values.SmtpDefaulPort);
this.smtpSecure(Enums.ServerSecure.None);
this.smtpShortLogin(false);
this.smtpAuth(true);
@ -6037,6 +6063,15 @@ function AdminGeneral()
this.capaAdditionalAccounts = oData.capaAdditionalAccounts;
this.capaAdditionalIdentities = oData.capaAdditionalIdentities;
this.mainAttachmentLimit = ko.observable(Utils.pInt(RL.settingsGet('AttachmentLimit')) / (1024 * 1024)).extend({'posInterer': 25});
this.uploadData = RL.settingsGet('PhpUploadSizes');
this.uploadDataDesc = this.uploadData && (this.uploadData['upload_max_filesize'] || this.uploadData['post_max_size']) ?
[
this.uploadData['upload_max_filesize'] ? 'upload_max_filesize = ' + this.uploadData['upload_max_filesize'] + '; ' : '',
this.uploadData['post_max_size'] ? 'post_max_size = ' + this.uploadData['post_max_size'] : ''
].join('')
: '';
this.themesOptions = ko.computed(function () {
return _.map(oData.themes(), function (sTheme) {
return {
@ -6052,6 +6087,7 @@ function AdminGeneral()
this.weakPassword = !!RL.settingsGet('WeakPassword');
this.attachmentLimitTrigger = ko.observable(Enums.SaveSettingsStep.Idle);
this.languageTrigger = ko.observable(Enums.SaveSettingsStep.Idle);
this.themeTrigger = ko.observable(Enums.SaveSettingsStep.Idle);
}
@ -6064,10 +6100,17 @@ AdminGeneral.prototype.onBuild = function ()
_.delay(function () {
var
f1 = Utils.settingsSaveHelperSimpleFunction(self.attachmentLimitTrigger, self),
f2 = Utils.settingsSaveHelperSimpleFunction(self.languageTrigger, self),
f3 = Utils.settingsSaveHelperSimpleFunction(self.themeTrigger, self)
;
self.mainAttachmentLimit.subscribe(function (sValue) {
RL.remote().saveAdminConfig(f1, {
'AttachmentLimit': Utils.pInt(sValue)
});
});
self.language.subscribe(function (sValue) {
RL.remote().saveAdminConfig(f2, {
'Language': Utils.trim(sValue)
@ -6118,6 +6161,15 @@ AdminGeneral.prototype.selectLanguage = function ()
kn.showScreenPopup(PopupsLanguagesViewModel);
};
/**
* @return {string}
*/
AdminGeneral.prototype.phpInfoLink = function ()
{
return RL.link().phpInfo();
};
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
/**

File diff suppressed because one or more lines are too long

View file

@ -846,11 +846,13 @@ Utils.isPosNumeric = function (mValue, bIncludeZero)
/**
* @param {*} iValue
* @param {number=} iDefault = 0
* @return {number}
*/
Utils.pInt = function (iValue)
Utils.pInt = function (iValue, iDefault)
{
return Utils.isNormal(iValue) && '' !== iValue ? window.parseInt(iValue, 10) : 0;
var iResult = Utils.isNormal(iValue) && '' !== iValue ? window.parseInt(iValue, 10) : (iDefault || 0);
return window.isNaN(iResult) ? (iDefault || 0) : iResult;
};
/**
@ -3438,6 +3440,30 @@ ko.extenders.trimmer = function (oTarget)
return oResult;
};
ko.extenders.posInterer = function (oTarget, iDefault)
{
var oResult = ko.computed({
'read': oTarget,
'write': function (sNewValue) {
var iNew = Utils.pInt(sNewValue.toString(), iDefault);
if (0 >= iNew)
{
iNew = iDefault;
}
if (iNew === oTarget() && '' + iNew !== '' + sNewValue)
{
oTarget(iNew + 1);
}
oTarget(iNew);
}
});
oResult(oTarget());
return oResult;
};
ko.extenders.reversible = function (oTarget)
{
var mValue = oTarget();

File diff suppressed because one or more lines are too long