From 205f29ca268d332536d6dc397b425733095fefa4 Mon Sep 17 00:00:00 2001 From: Michael Fairchild <mfairchild365@gmail.com> Date: Thu, 4 Feb 2016 14:04:56 -0600 Subject: [PATCH] Add legacy icon support --- plugins/unl_avatars/manifest.xml | 11 +++++++++++ plugins/unl_avatars/start.php | 28 ++++++++++++++++++++++++++++ 2 files changed, 39 insertions(+) create mode 100644 plugins/unl_avatars/manifest.xml create mode 100644 plugins/unl_avatars/start.php diff --git a/plugins/unl_avatars/manifest.xml b/plugins/unl_avatars/manifest.xml new file mode 100644 index 00000000..647859f1 --- /dev/null +++ b/plugins/unl_avatars/manifest.xml @@ -0,0 +1,11 @@ +<?xml version="1.0" encoding="UTF-8" ?> +<plugin_manifest xmlns="http://www.elgg.org/plugin_manifest/1.8"> + <name>UNL Avatars</name> + <author>UNL</author> + <version>1.0</version> + <description>Adds legacy and public Avatar (icon) support</description> + <requires> + <type>elgg_release</type> + <version>2.0</version> + </requires> +</plugin_manifest> diff --git a/plugins/unl_avatars/start.php b/plugins/unl_avatars/start.php new file mode 100644 index 00000000..81395d7f --- /dev/null +++ b/plugins/unl_avatars/start.php @@ -0,0 +1,28 @@ +<?php + +function unl_avatars_init() { + elgg_register_page_handler('pg', 'unl_avatars_pg_handler'); +} + +// Fire up the plugin initialization using the elgg handler +elgg_register_event_handler('init','system','unl_avatars_init'); + +function unl_avatars_pg_handler($segments) { + if ('icon' != $segments[0]) { + return false; + } + + if (!isset($segments[1], $segments[2])) { + return false; + } + + $username = $segments[1]; + $size = $segments[2]; + + if (!$user = get_user_by_username($username)) { + return false; + } + + //Forward to the new guy + forward('mod/profile/icondirect.php?guid='.$user->guid.'&size='.$size); +} -- GitLab