streams/mod/follow.php

60 lines
1.3 KiB
PHP
Raw Normal View History

<?php
2012-06-03 06:12:20 +00:00
require_once('include/follow.php');
2011-12-18 20:41:46 +00:00
function follow_init(&$a) {
2015-01-29 04:56:04 +00:00
if(! local_channel()) {
return;
}
2015-01-29 04:56:04 +00:00
$uid = local_channel();
2012-06-03 06:17:49 +00:00
$url = notags(trim($_REQUEST['url']));
$return_url = $_SESSION['return_url'];
$confirm = intval($_REQUEST['confirm']);
2016-03-01 03:31:52 +00:00
$channel = $a->get_channel();
$result = new_contact($uid,$url,$channel,true,$confirm);
2012-06-03 06:12:20 +00:00
if($result['success'] == false) {
if($result['message'])
notice($result['message']);
goaway($return_url);
}
2013-05-20 03:38:53 +00:00
info( t('Channel added.') . EOL);
2012-06-03 06:17:49 +00:00
$clone = array();
foreach($result['abook'] as $k => $v) {
if(strpos($k,'abook_') === 0) {
$clone[$k] = $v;
}
}
unset($clone['abook_id']);
unset($clone['abook_account']);
unset($clone['abook_channel']);
2016-03-01 03:31:52 +00:00
$abconfig = load_abconfig($channel['channel_hash'],$clone['abook_xchan']);
if($abconfig)
$clone['abconfig'] = $abconfig;
build_sync_packet(0 /* use the current local_channel */, array('abook' => array($clone)));
// If we can view their stream, pull in some posts
if(($result['abook']['abook_their_perms'] & PERMS_R_STREAM) || ($result['abook']['xchan_network'] === 'rss'))
proc_run('php','include/onepoll.php',$result['abook']['abook_id']);
2014-03-08 07:00:27 +00:00
goaway(z_root() . '/connedit/' . $result['abook']['abook_id'] . '?f=&follow=1');
2011-12-18 20:41:46 +00:00
}
function follow_content(&$a) {
2015-01-29 04:56:04 +00:00
if(! local_channel()) {
return login();
}
}