Skip to content

Commit fafe974

Browse files
Merge pull request #4253 from Simpler1/no_tag_filter
feat(tags): Filter option for No Tag
2 parents 445c306 + aca3655 commit fafe974

File tree

6 files changed

+14
-5
lines changed

6 files changed

+14
-5
lines changed

db/zm_update-1.37.44.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ SET @s = (SELECT IF(
1818
`LastAssignedDate` dateTime,
1919
PRIMARY KEY (`Id`),
2020
UNIQUE(`Name`)
21-
) ENGINE=InnoDB AUTO_INCREMENT=0 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci"
21+
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci"
2222
));
2323

2424
PREPARE stmt FROM @s;

scripts/ZoneMinder/lib/ZoneMinder/Filter.pm

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,7 @@ sub Sql {
260260
} elsif ( $term->{attr} eq 'Name'
261261
|| $term->{attr} eq 'Cause'
262262
|| $term->{attr} eq 'Notes'
263+
|| $term->{attr} eq 'Tags'
263264
) {
264265
if ( $term->{op} eq 'LIKE'
265266
|| $term->{op} eq 'NOT LIKE'
@@ -339,6 +340,8 @@ sub Sql {
339340
$self->{Sql} .= ' LIKE '.$value;
340341
} elsif ( $term->{op} eq 'NOT LIKE' ) {
341342
$self->{Sql} .= ' NOT LIKE '.$value;
343+
} elsif ( $term->{attr} eq 'Tags' and ($term->{op} eq 'LIKE' or $term->{op} eq 'IS') and $term->{val} eq "'0'") {
344+
$self->{Sql} .= 'NOT EXISTS (SELECT NULL FROM `Events_Tags` AS ET WHERE ET.EventId = E.Id)';
342345
} else {
343346
$self->{Sql} .= ' '.$term->{op}.' '.$value;
344347
}

web/includes/Filter.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -957,7 +957,7 @@ public function widget() {
957957
}
958958
}
959959
}
960-
// $availableTags = array();
960+
$availableTags = array(translate('NoTag'));
961961
foreach ( dbFetchAll('SELECT Id, Name FROM Tags ORDER BY LastAssignedDate DESC') AS $tag ) {
962962
$availableTags[$tag['Id']] = validHtmlStr($tag['Name']);
963963
}
@@ -1093,7 +1093,7 @@ public function simple_widget() {
10931093
for ( $i = 0; $i < 7; $i++ ) {
10941094
$weekdays[$i] = date('D', mktime(12, 0, 0, 1, $i+1, 2001));
10951095
}
1096-
$availableTags = array();
1096+
$availableTags = array(translate('NoTag'));
10971097
foreach ( dbFetchAll('SELECT Id, Name FROM Tags ORDER BY LastAssignedDate DESC') AS $tag ) {
10981098
$availableTags[$tag['Id']] = validHtmlStr($tag['Name']);
10991099
}

web/includes/FilterTerm.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -312,6 +312,7 @@ public function sql() {
312312
}
313313

314314
$sql = '';
315+
$where_null = '';
315316
if ( isset($this->cnj) ) {
316317
$sql .= ' '.$this->cnj;
317318
}
@@ -332,6 +333,8 @@ public function sql() {
332333
$subterms[] = $subterm;
333334
}
334335
$sql .= '('.implode(' OR ', $subterms).')';
336+
} elseif (($this->attr === 'Tags') && ($values[0] === "'0'")) {
337+
$where_null = 'NOT EXISTS (SELECT NULL FROM Events_Tags AS ET WHERE ET.EventId = E.Id)';
335338
} else {
336339
$sql .= $this->sql_attr();
337340
if ($this->collate) $sql .= ' COLLATE '.$this->collate;
@@ -343,7 +346,7 @@ public function sql() {
343346
$sql .= $values[0];
344347
}
345348
}
346-
349+
$sql .= $where_null;
347350
if ( isset($this->cbr) ) {
348351
$sql .= ' '.str_repeat(')', $this->cbr);
349352
}

web/lang/en_gb.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@
7575
'AlarmPx' => 'Alarm Px',
7676
'AlarmRefImageBlendPct' => 'Alarm Reference Image Blend %ge',
7777
'AlarmRGBUnset' => 'You must set an alarm RGB colour',
78+
'All' => 'All',
7879
'AllTokensRevoked' => 'All Tokens Revoked',
7980
'AnalysisFPS' => 'Analysis FPS',
8081
'AnalysisUpdateDelay' => 'Analysis Update Delay',
@@ -442,10 +443,12 @@
442443
'NoneAvailable' => 'None available',
443444
'NoSavedFilters' => 'No Saved Filters',
444445
'NoStatisticsRecorded' => 'There are no statistics recorded for this event/frame',
446+
'NoTag' => 'No Tag',
445447
'NumPresets' => 'Num Presets',
446448
'OnvifProbe' => 'ONVIF',
447449
'OnvifProbeIntro' => 'The list below shows detected ONVIF cameras and whether they are already being used or available for selection.<br/><br/>Select the desired entry from the list below.<br/><br/>Please note that not all cameras may be detected and that choosing a camera here may overwrite any values you already have configured for the current monitor.<br/><br/>',
448450
'OnvifCredentialsIntro' => 'Please supply user name and password for the selected camera.<br/>If no user has been created for the camera then the user given here will be created with the given password.<br/><br/>',
451+
'OpBlank' => 'is blank',
449452
'OpEq' => 'equal to',
450453
'OpGtEq' => 'greater than or equal to',
451454
'OpGt' => 'greater than',

web/skins/classic/views/filter.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@
132132
}
133133
}
134134

135-
$availableTags = array();
135+
$availableTags = array(translate('NoTag'));
136136
foreach ( dbFetchAll('SELECT Id, Name FROM Tags ORDER BY LastAssignedDate DESC') AS $tag ) {
137137
$availableTags[$tag['Id']] = validHtmlStr($tag['Name']);
138138
}

0 commit comments

Comments
 (0)