aboutsummaryrefslogtreecommitdiffstats
path: root/Zotlabs/Module/Ochannel.php
blob: 508be1408679e79ace0f1434fee083151289d9dc (plain) (blame)
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
<?php

namespace Zotlabs\Module;

require_once('include/contact_widgets.php');
require_once('include/items.php');
require_once("include/bbcode.php");
require_once('include/security.php');
require_once('include/conversation.php');
require_once('include/acl_selectors.php');
require_once('include/permissions.php');

/**
 * @brief Channel Controller for broken OStatus implementations
 *
 */
class Ochannel extends \Zotlabs\Web\Controller {

	function init() {

		$which = null;
		if(argc() > 1)
			$which = argv(1);
		if(! $which) {
			if(local_channel()) {
				$channel = \App::get_channel();
				if($channel && $channel['channel_address'])
				$which = $channel['channel_address'];
			}
		}
		if(! $which) {
			notice( t('You must be logged in to see this page.') . EOL );
			return;
		}

		$profile = 0;
		$channel = \App::get_channel();

		if((local_channel()) && (argc() > 2) && (argv(2) === 'view')) {
			$which = $channel['channel_address'];
			$profile = argv(1);
		}

		head_add_link( [ 
			'rel'   => 'alternate', 
			'type'  => 'application/atom+xml',
			'href'  => z_root() . '/ofeed/' . $which
		]);


		// Run profile_load() here to make sure the theme is set before
		// we start loading content

		profile_load($which,$profile);
	}

	function get($update = 0, $load = false) {

		if(argc() < 2)
			return;

		if($load)
			$_SESSION['loadtime'] = datetime_convert();

		return '<script>window.location.href = "' . z_root() . '/' . str_replace('ochannel/','channel/',\App::$query_string) . '";</script>';

	}

}