inherit
2671
0
May 14, 2013 14:40:03 GMT -8
Peter
🐺
10,615
February 2002
peter3
|
Post by Peter on Sept 6, 2017 2:48:52 GMT -8
No bother at all You can't parse a whole array ( who_can_use is an array) like that. It's strange though, as inArrayLoose is not strict, so "2" is the same as 2. Could you post your plugin so I can debug it? Just to be clear to what you are logging out to the console. "Groups" is the groups the user is in. "Users" is the groups entered in the plugin UI?
|
|
inherit
217348
0
Jul 27, 2022 7:26:44 GMT -8
Lynx
5,846
January 2015
msg
|
Post by Lynx on Sept 6, 2017 12:01:03 GMT -8
Peter, Further testing is showing me that it seems to work properly for the root admin account, but not for my alt account. Yes, "Groups" is the array if the groups the member is in and "Users" is the "Who Can Use" setting. I'll PM you an editable copy, as I'd rather not have it out in the open.
|
|
inherit
2671
0
May 14, 2013 14:40:03 GMT -8
Peter
🐺
10,615
February 2002
peter3
|
Post by Peter on Sept 6, 2017 14:21:16 GMT -8
Lynx , Ok, so a couple of silly mistakes on my part it seems. - The order of parameters for inArrayLoose is wrong (in my defense I copied your code, but I should have seen it, so my bad). - The users parameter is an array, which is wrong, it should be an element from the array (I have my silly moments too ). The fixes / tweaks: 1. Order of conditions can be changed for performance. That way if the first condition is true, then we don't need to use the loop to check the users group (consider this on the line of micro performance, but it's handy to know). if (settings.msg_navlink[z].who_can_use.length == 0 || can_use_nav_link(groups, settings.msg_navlink[z].who_can_use)) { 2. The main problem was this line: if ($.inArrayLoose(groups, users) != -1){ The parameter order is wrong, and users should be an element, not the whole array. if ($.inArrayLoose(users[y], groups) != -1){ That should do it
|
|
inherit
217348
0
Jul 27, 2022 7:26:44 GMT -8
Lynx
5,846
January 2015
msg
|
Post by Lynx on Sept 6, 2017 15:58:09 GMT -8
Peter, Thank you very much! I made the changes and did some extensive testing - all seems well! Thank you for the tips as well as the tweaks.
|
|