Skip to content

Commit

Permalink
Support regex extension (SIEVE) (#1043)
Browse files Browse the repository at this point in the history
+ Update jquery
  • Loading branch information
RainLoop committed May 26, 2016
1 parent 2fefad4 commit c0ab236
Show file tree
Hide file tree
Showing 8 changed files with 31 additions and 12 deletions.
1 change: 1 addition & 0 deletions dev/Common/Enums.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,7 @@ export const FilterConditionType = {
'NotContains': 'NotContains',
'EqualTo': 'EqualTo',
'NotEqualTo': 'NotEqualTo',
'Regex': 'Regex',
'Over': 'Over',
'Under': 'Under'
};
Expand Down
5 changes: 5 additions & 0 deletions dev/View/Popup/Filter.js
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,11 @@
{'id': Enums.FilterConditionType.NotEqualTo, 'name': Translator.i18n('POPUPS_FILTER/SELECT_TYPE_NOT_EQUAL_TO')}
]);

if (oModules && oModules.regex)
{
this.typeOptions.push({'id': Enums.FilterConditionType.Regex, 'name': 'Regex'});
}

this.typeOptionsSize([
{'id': Enums.FilterConditionType.Over, 'name': Translator.i18n('POPUPS_FILTER/SELECT_TYPE_OVER')},
{'id': Enums.FilterConditionType.Under, 'name': Translator.i18n('POPUPS_FILTER/SELECT_TYPE_UNDER')}
Expand Down
11 changes: 5 additions & 6 deletions dev/bootstrap.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,11 @@ export default (App) => {

Globals.__APP__ = App;

Globals.$win
.keydown(Utils.kill_CtrlA_CtrlS)
.unload(function () {
Globals.bUnload = true;
})
;
Globals.$win.on('keydown', Utils.kill_CtrlA_CtrlS);

Globals.$win.on('unload', function () {
Globals.bUnload = true;
});

Globals.$html
.addClass(Globals.bMobileDevice ? 'mobile' : 'no-mobile')
Expand Down
4 changes: 3 additions & 1 deletion gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,8 @@ cfg.paths.js = {
name: 'libs.js',
src: [
'vendors/underscore/1.6.0/underscore-min.js',
'vendors/jquery/jquery-1.12.3.min.js',
'vendors/jquery/jquery-2.2.4.min.js',
// 'vendors/jquery/jquery-3.0.0-rc1.min.js',
'vendors/jquery-ui/js/jquery-ui-1.10.3.custom.min.js',
'vendors/jquery-cookie/jquery.cookie-1.4.0.min.js',
'vendors/jquery-finger/jquery.finger.min.js',
Expand Down Expand Up @@ -299,6 +300,7 @@ gulp.task('js:libs', function() {
return gulp.src(cfg.paths.js.libs.src)
.pipe(concat(cfg.paths.js.libs.name, {separator: '\n\n'}))
.pipe(eol('\n', true))
.pipe(replace(/sourceMappingURL=[a-z0-9\.\-_]{1,20}\.map/ig, ''))
.pipe(gulp.dest(cfg.paths.staticMinJS));
});

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "RainLoop",
"title": "RainLoop Webmail",
"version": "1.10.1",
"release": "120",
"release": "121",
"private": true,
"ownCloudPackageVersion": "4.17",
"description": "Simple, modern & fast web-based email client",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ class ConditionType
const NOT_EQUAL_TO = 'NotEqualTo';
const CONTAINS = 'Contains';
const NOT_CONTAINS = 'NotContains';
const REGEX = 'Regex';
const OVER = 'Over';
const UNDER = 'Under';
}
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,9 @@ public function Load($oAccount, $bAllowRaw = false)
'Capa' => $bAllowRaw ? $aModules : array(),
'Modules' => array(
'redirect' => \in_array('fileinto', $aModules),
'regex' => \in_array('regex', $aModules),
'relational' => \in_array('relational', $aModules),
'date' => \in_array('date', $aModules),
'moveto' => \in_array('fileinto', $aModules),
'reject' => \in_array('reject', $aModules),
'vacation' => \in_array('vacation', $aModules),
Expand Down Expand Up @@ -161,7 +164,7 @@ public function Save($oAccount, $aFilters, $sRaw = '', $bRawIsActive = false)
*
* @return string
*/
private function conditionToSieveScript($oCondition)
private function conditionToSieveScript($oCondition, &$aCapa)
{
$sResult = '';
$sTypeWord = '';
Expand Down Expand Up @@ -192,6 +195,10 @@ private function conditionToSieveScript($oCondition)
case \RainLoop\Providers\Filters\Enumerations\ConditionType::CONTAINS:
$sTypeWord = ':contains';
break;
case \RainLoop\Providers\Filters\Enumerations\ConditionType::REGEX:
$sTypeWord = ':regex';
$aCapa['regex'] = true;
break;
default:
$bTrue = false;
$sResult = '/* @Error: unknown type value */ false';
Expand Down Expand Up @@ -284,7 +291,7 @@ private function filterToSieveScript($oFilter, &$aCapa)
foreach ($aConditions as $oCond)
{
$bTrim = true;
$sCons = $this->conditionToSieveScript($oCond);
$sCons = $this->conditionToSieveScript($oCond, $aCapa);
if (!empty($sCons))
{
$aResult[] = $sTab.$sCons.',';
Expand All @@ -302,7 +309,7 @@ private function filterToSieveScript($oFilter, &$aCapa)
$aResult[] = 'if allof(';
foreach ($aConditions as $oCond)
{
$aResult[] = $sTab.$this->conditionToSieveScript($oCond).',';
$aResult[] = $sTab.$this->conditionToSieveScript($oCond, $aCapa).',';
}

$aResult[\count($aResult) - 1] = \rtrim($aResult[\count($aResult) - 1], ',');
Expand All @@ -311,7 +318,7 @@ private function filterToSieveScript($oFilter, &$aCapa)
}
else if (1 === \count($aConditions))
{
$aResult[] = 'if '.$this->conditionToSieveScript($aConditions[0]).'';
$aResult[] = 'if '.$this->conditionToSieveScript($aConditions[0], $aCapa).'';
}
else
{
Expand Down
4 changes: 4 additions & 0 deletions vendors/jquery/jquery-2.2.4.min.js

Large diffs are not rendered by default.

0 comments on commit c0ab236

Please sign in to comment.