rewrote the plugin for Elgg 1.8.14