aboutsummaryrefslogtreecommitdiff
path: root/mod/walledgarden/start.php
blob: df0982d3cc219789ccb04a712f4cef745a62ec49 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
<?php

	/**
	 * Walled garden support.
	 * 
	 * @package ElggWalledGarden
	 * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2
	 * @author Curverider Ltd
	 * @copyright Curverider Ltd 2008-2010
	 * @link http://elgg.com/
	 */

	function walledgarden_init()
	{
		global $CONFIG;
		
		$CONFIG->disable_registration = true;
		
		// elgg_set_viewtype('default');
		elgg_extend_view('pageshells/pageshell', 'walledgarden/walledgarden');
		
		elgg_extend_view('css','walledgarden/css');
		
		// Replace the default index page if the custom index plugin does not exist
		if(!is_plugin_enabled("custom_index"))
			register_plugin_hook('index','system','walledgarden_index');
		// um...what is this doing here?
		// Turn off simple cache if enabled
		//if (function_exists('elgg_view_disable_simplecache')) {
		//	elgg_view_disable_simplecache();
		//}
		
		register_plugin_hook('new_twitter_user', 'twitter_service', 'walledgarden_new_twitter_user');
	}
	
	function walledgarden_pagesetup() {
		
		global $CONFIG;
		if (current_page_url() != $CONFIG->url
			&& !defined('externalpage')
			&& !isloggedin()) {
				forward();
				exit;
			}
		
	}
	
	 function walledgarden_index() {
			
			if (!include_once(dirname(dirname(__FILE__))) . "/walledgarden/index.php") {
				return false;
			}
			return true;
			
		}

	function walledgarden_new_twitter_user($hook, $entity_type, $returnvalue, $params) {
		// do not allow new users to be created within the walled-garden
		register_error(elgg_echo('walledgarden:new_user:fail'));
		return FALSE;
	}
	
	register_elgg_event_handler('init','system','walledgarden_init');
	register_elgg_event_handler('pagesetup','system','walledgarden_pagesetup');
?>