aboutsummaryrefslogtreecommitdiff
path: root/mod/walledgarden/start.php
blob: 260a8c1e4c9fdd73aafdf9eac9e4a0f1611b0071 (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
66
67
68
69
70
71
<?php

/**
 * Walled garden support.
 */

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');
	
	register_plugin_hook('new_twitter_user', 'twitter_service', 'walledgarden_new_twitter_user');
	
	if(!isloggedin())
		register_plugin_hook('index','system','walledgarden_index');
}
	
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;
}
	
/**
 * This is so the homepage can have its own pageshell
 **/
 
function page_draw_walledgarden($title, $body, $sidebar = "") {

	// Draw the page
	$output = elgg_view('page_shells/walled_garden_index', array(
		'title' => $title,
		'body' => $body,
		'sidebar' => $sidebar,
		'sysmessages' => system_messages(null,"")
		)
	);
	$split_output = str_split($output, 1024);

	foreach($split_output as $chunk) {
		echo $chunk;
	}
}
	
register_elgg_event_handler('init','system','walledgarden_init');
register_elgg_event_handler('pagesetup','system','walledgarden_pagesetup');