aboutsummaryrefslogtreecommitdiff
path: root/mod/landing/start.php
diff options
context:
space:
mode:
Diffstat (limited to 'mod/landing/start.php')
-rw-r--r--mod/landing/start.php78
1 files changed, 78 insertions, 0 deletions
diff --git a/mod/landing/start.php b/mod/landing/start.php
new file mode 100644
index 000000000..05ccac9fb
--- /dev/null
+++ b/mod/landing/start.php
@@ -0,0 +1,78 @@
+<?php
+/**
+ * Landing Page Plugin for Elgg 1.8
+ *
+ * @author: hellekin <hellekin@lorea.org>
+ * @copyright: 2012 Lorea Faeries <federation@lorea.org>
+ * @license: GNU Affero General Public License version 3 or later
+ * @package: ElggLanding
+ */
+
+elgg_register_event_handler('init', 'system', 'landing_init');
+
+function landing_init() {
+ // Register Tests
+ elgg_register_plugin_hook_handler('unit_test', 'system', 'landing_test');
+
+ // Register CSS
+ elgg_extend_view('css', 'landing/css');
+
+ // Register Login Event Handler
+ elgg_register_event_handler('login', 'user', 'landing_login_handler');
+
+}
+
+/**
+ * Test the plugin
+ */
+function landing_test($hook, $type, $value, $params) {
+ $value[] = 'landing/test/landing_test.php';
+ return $value;
+}
+
+/**
+ * Redirect user to chosen landing page upon login
+ */
+function landing_login_handler($event, $type, $user) {
+ global $forward_url;
+
+ if (empty($forward_url)) {
+ $forward_url = landing_page_url();
+ }
+
+ return NULL;
+}
+
+function landing_page_url() {
+
+ $user = elgg_get_logged_in_user_entity();
+ if (!($user instanceof ElggUser)) {
+ return '';
+ }
+
+ $mode = get_plugin_usersetting('landing_mode', $user->guid, 'landing');
+
+ switch($mode) {
+ case 'profile':
+ if (elgg_is_active_plugin('profile')) {
+ $forward_url = "/profile/{$user->username}";
+ } else {
+ $forward_url = "/view/{$user->guid}";
+ }
+ break;
+ case 'custom':
+ $forward_url = get_plugin_usersetting('landing_url', $user->guid, 'landing');
+ break;
+ case 'dashboard':
+ if (elgg_is_active_plugin('dashboard')) {
+ $forward_url = '/dashboard';
+ break;
+ }
+ case 'default':
+ default:
+ $forward_url = '';
+ break;
+ }
+
+ return $forward_url;
+}