Show or hide a tab based on IP address
The one thing we have specific to each office is the network address of the client machine. Specifically, the subnet portion of the IP address.
I knew that I had to use the "condition" field on the portal action, so after many hours of searching and reading (which I hope saves at least one person the same amount of trouble), I came up with the following.
Simply put the following string as a condition on your portal action -
python:request.getClientAddr()[:12] == '192.168.100.'
This makes the tab appear for any client machine that has an IP address starting with 192.168.100
The [:12] is a count of the number characters in the quoted string. You could also use -
python:request.getClientAddr()[:10] == '192.168.1.'
You get the idea. I am sure you could use other operators, it just takes some experimenting.
This has been tested on 2.0.x and 2.1, but nothing earlier. I believe the getClientAddr() API was new at some stage, so this may not work on earlier versions.
