nuxsmin / sysPass

Systems Password Manager
https://syspass.org
GNU General Public License v3.0
975 stars 208 forks source link

TAG Filter #944

Closed endritius closed 6 years ago

endritius commented 6 years ago

Currently the TAG Filter works with OR operator, which means that if two tags are selected and two accounts have each of them, than they will show up.

I would like to know what part of the code can be modified so that it works with the AND operator, so that only the accounts that have both tags show in the filter.

Can you point me in the right direction or how can that be done?

Thanks in advance!

nuxsmin commented 6 years ago

You're right, the tags filtering is done by using an IN clause, so it will search for all the tags that match the given IDs. Please take a look to https://github.com/nuxsmin/sysPass/blob/master/inc/SP/Account/AccountSearch.class.php file on line 435.

Next version will include some special search strings that set the searching operator.

Regards

endritius commented 6 years ago

OK! Thanks!

cristianoisaac commented 6 years ago

@nuxsmin I'm trying to use the tags as Folders, so I'd like to use the "AND" operator to filter more precisely like an sub-folder. Nice to know that it will be implemented soon. You will do it to v3 beta too? Could you also make a way to use both (AND/OR) tags like: (TAG1 OR TAG2) AND (TAG3 OR TAG4)? Thanks.

nuxsmin commented 6 years ago

@Fizard yes, it has already been implemented in 3.0 beta version. You can try it on the demo website by using the special search strings.

The second point needs to be analyzed, since the tags box does not allow to use other strings than tags so it could be a bit tough to get running.

Regards

cristianoisaac commented 6 years ago

@nuxsmin, I tried on DEMO and also on my v3 beta and the TAG isn't working correctly. On DEMO I tried to filter the TAGs: "SSH" AND "MySQL". And it doesn't show any account. If it was using OR operator it should show all accounts with SSH and MySQL. If it was using AND it should appear only the accounts with "SSH" AND "MySQL" tags, but instead it isn't showing any of them. My Syspass is on version 3.0-beta (300.18053001) and it seems to be using the OR operator on TAGs cause it shows both the tags I filter.

nuxsmin commented 6 years ago

@Fizard hmm, did you try the 3.0 demo site? Http://demo-beta.syspass.org:10080

nuxsmin commented 6 years ago

It was implemented since 18053101 build

cristianoisaac commented 6 years ago

Yes I did! Just try it yourself. In the TAG insert the tag "SSH" image

Then when I insert the tag "MySQL" it goes blank like this: image

If it was using the "AND" or even the "OR" operator it should return some accounts.

nuxsmin commented 6 years ago

@Fizard right, you need to use the special search string "op:or" within the search box. There are more special actions by clicking the help icon.

cristianoisaac commented 6 years ago

@nuxsmin, but this op:and|or is only in the "Text to search" field, isn't it? I can't do this in the "Select tag" filter. Also, I couldn't filter tags on the "Text to search". image Also tried this way: image

nuxsmin commented 6 years ago

@Fizard the latter is the right one, it should apply the operand for every filter set (ie. Text, client, category or tag).

Didn't work?

cristianoisaac commented 6 years ago

Both returned No Records on Demo. And there are more then one account with both tags SSH and MySQL.

nuxsmin commented 6 years ago

You're right @Fizard , the SQL query was wrong and it wasn't performing the intended behaviour.

I'll fix it shortly.

Sorry for bothering you ;)

cristianoisaac commented 6 years ago

No problem @nuxsmin, it's no bother. I'll try to help as much as I can, cause I'm also being helped. With some more adjustments this app will be the best free with my requirements. Thank you for your quick responses and fixes.

nuxsmin commented 6 years ago

@Fizard this should be solved in latest commit.

Good night!