Skip to content

Commit c21bf0f

Browse files
committed
allow hidding tags with '@' symbol in their name
1 parent 76895e5 commit c21bf0f

File tree

4 files changed

+51
-2
lines changed

4 files changed

+51
-2
lines changed

daos/Items.php

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,17 @@ public function get($options = array()) {
8080
$options
8181
);
8282

83-
return $this->backend->get($options);
83+
$items = $this->backend->get($options);
84+
85+
if(!\F3::get('auth')->showHiddenTags()) {
86+
foreach($items as $idx => $item) {
87+
if (strpos($item['tags'], "@") !== false) {
88+
unset($items[$idx]);
89+
}
90+
}
91+
$items = array_values($items);
92+
}
93+
94+
return $items;
8495
}
8596
}

daos/Sources.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,20 @@ public function __call($name, $args) {
4747
\F3::get('logger')->log('Unimplemented method for ' . \F3::get('db_type') . ': ' . $name, \ERROR);
4848
}
4949

50+
public function get() {
51+
$sources = $this->backend->get();
52+
53+
if(!\F3::get('auth')->showHiddenTags()) {
54+
foreach($sources as $idx => $source) {
55+
if (strpos($source['tags'], "@") !== false) {
56+
unset($sources[$idx]);
57+
}
58+
}
59+
$sources = array_values($sources);
60+
}
61+
62+
return $sources;
63+
}
5064

5165
/**
5266
* validate new data for a given source

daos/Tags.php

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,21 @@ public function __construct() {
3030
$this->backend = new $class();
3131
parent::__construct();
3232
}
33-
33+
34+
public function get() {
35+
$tags = $this->backend->get();
36+
37+
if(!\F3::get('auth')->showHiddenTags()) {
38+
foreach($tags as $idx => $tag) {
39+
if (strpos($tag['tag'], "@") !== false) {
40+
unset($tags[$idx]);
41+
}
42+
}
43+
$tags = array_values($tags);
44+
}
45+
46+
return $tags;
47+
}
3448

3549
/**
3650
* pass any method call to the backend.

helpers/Authentication.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,16 @@ public function isLoggedin() {
129129
return $this->loggedin;
130130
}
131131

132+
133+
/**
134+
* showHiddenTags
135+
*
136+
* @return bool
137+
*/
138+
public function showHiddenTags() {
139+
return $this->isLoggedin();
140+
}
141+
132142

133143
/**
134144
* logout

0 commit comments

Comments
 (0)