aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorfriendica <info@friendica.com>2013-08-21 22:10:08 -0700
committerfriendica <info@friendica.com>2013-08-21 22:10:08 -0700
commit925b046794b77345c1321a3c74e4561d5c10ec95 (patch)
tree607a59b59d7f60f2e6b615b5454758f76254cdf2
parent6cea04eb440c2bb08bcb81ae13749c08d09b755c (diff)
downloadvolse-hubzilla-925b046794b77345c1321a3c74e4561d5c10ec95.tar.gz
volse-hubzilla-925b046794b77345c1321a3c74e4561d5c10ec95.tar.bz2
volse-hubzilla-925b046794b77345c1321a3c74e4561d5c10ec95.zip
premium/restricted channel connections implemented, configure at yoursite/channel/nickname - this basically redirects "follow" requests to a premium channel's sell page if it has one configured. You can still click through and create a connection request (introduction), but this provides a means for the channel owner to state their terms. If you don't abide by the terms, you will likely be blocked or the channel deleted. This facility is extensible in a number of ways.
-rwxr-xr-xboot.php17
-rw-r--r--include/Contact.php9
-rw-r--r--include/follow.php7
-rw-r--r--mod/connect.php28
-rw-r--r--mod/follow.php3
-rw-r--r--mod/zfinger.php2
-rw-r--r--view/css/mod_connect.css8
-rw-r--r--view/tpl/sellpage_edit.tpl23
8 files changed, 82 insertions, 15 deletions
diff --git a/boot.php b/boot.php
index 3327fdbb2..c8a8fbc7e 100755
--- a/boot.php
+++ b/boot.php
@@ -1623,13 +1623,20 @@ function profile_sidebar($profile, $block = 0, $show_connect = true) {
require_once('include/Contact.php');
+ if($show_connect) {
- $connect_url = (($show_connect) ? rconnect_url($profile['uid'],get_observer_hash()) : '');
-
- $connect = (($connect_url) ? t('Connect') : '');
+ // This will return an empty string if we're already connected.
+
+ $connect_url = rconnect_url($profile['uid'],get_observer_hash());
+ $connect = (($connect_url) ? t('Connect') : '');
+ if($connect_url)
+ $connect_url = sprintf($connect_url,urlencode($profile['channel_address'] . '@' . $a->get_hostname()));
- if($connect_url)
- $connect_url = $connect_url . '/follow?f=1&url=' . urlencode($profile['channel_address'] . '@' . $a->get_hostname());
+ // premium channel - over-ride
+
+ if($profile['channel_pageflags'] & PAGE_PREMIUM)
+ $connect_url = z_root() . '/connect/' . $profile['channel_address'];
+ }
// show edit profile to yourself
if($is_owner) {
diff --git a/include/Contact.php b/include/Contact.php
index bf536ccd5..46d356f3f 100644
--- a/include/Contact.php
+++ b/include/Contact.php
@@ -15,13 +15,20 @@ function rconnect_url($channel_id,$xchan) {
if($r)
return '';
+ $r = q("select * from xchan where xchan_hash = '%s' limit 1",
+ dbesc($xchan)
+ );
+
+ if(($r) && ($r[0]['xchan_follow']))
+ return $r[0]['xchan_follow'];
+
$r = q("select hubloc_url from hubloc where hubloc_hash = '%s' and ( hubloc_flags & %d ) limit 1",
dbesc($xchan),
intval(HUBLOC_FLAGS_PRIMARY)
);
if($r)
- return $r[0]['hubloc_url'];
+ return $r[0]['hubloc_url'] . '/follow?f=&url=%s';
return '';
}
diff --git a/include/follow.php b/include/follow.php
index ce550b07f..510c6cd7e 100644
--- a/include/follow.php
+++ b/include/follow.php
@@ -11,7 +11,7 @@
require_once('include/zot.php');
-function new_contact($uid,$url,$channel,$interactive = false) {
+function new_contact($uid,$url,$channel,$interactive = false, $confirm = false) {
$result = array('success' => false,'message' => '');
@@ -60,6 +60,11 @@ function new_contact($uid,$url,$channel,$interactive = false) {
return $result;
}
+ // Premium channel, set confirm before callback to avoid recursion
+
+ if(array_key_exists('connect_url',$j) && (! $confirm))
+ goaway($j['connect_url']);
+
// check service class limits
diff --git a/mod/connect.php b/mod/connect.php
index 0ab994ddd..c2b55d997 100644
--- a/mod/connect.php
+++ b/mod/connect.php
@@ -31,12 +31,13 @@ function connect_post(&$a) {
$channel = $a->get_channel();
if(($channel['channel_pageflags'] & PAGE_PREMIUM) != $premium)
- $r = q("update channel set channel_flags = channel_flags ^ %d where channel_id = %d limit 1",
+ $r = q("update channel set channel_pageflags = channel_pageflags ^ %d where channel_id = %d limit 1",
intval(PAGE_PREMIUM),
intval(local_user())
);
set_pconfig($a->profile['profile_uid'],'system','selltext',$text);
- return;
+ goaway(z_root() . '/' . $a->query_string);
+
}
$url = '';
@@ -53,7 +54,7 @@ function connect_post(&$a) {
}
}
if($url)
- goaway($url);
+ goaway($url . '&confirm=1');
else
notice('Unable to connect to your home hub location.');
@@ -68,20 +69,34 @@ function connect_content(&$a) {
$text = get_pconfig($a->profile['profile_uid'],'system','selltext');
if($edit) {
+ $channel = $a->get_channel();
+
$o = replace_macros(get_markup_template('sellpage_edit.tpl'),array(
+ '$header' => t('Premium Channel Setup'),
+ '$address' => $a->profile['channel_address'],
+ '$premium' => array('premium', t('Enable premium channel connection restrictions'),(($channel['channel_pageflags'] & PAGE_PREMIUM) ? '1' : ''),''),
+ '$lbl_about' => t('Please enter your restrictions or conditions, such as paypal receipt, usage guidelines, etc.'),
+ '$text' => $text,
+ '$desc' => t('This channel may require additional steps or acknowledgement of the following conditions prior to connecting:'),
+ '$lbl2' => t('Potential connections will then see the following text before proceeding:'),
+ '$desc2' => t('By continuing, I certify that I have complied with any instructions provided on this page.'),
+ '$submit' => t('Submit'),
));
return $o;
}
else {
+ if(! $text)
+ $text = t('(No specific instructions have been provided by the channel owner.)');
+
$submit = replace_macros(get_markup_template('sellpage_submit.tpl'), array(
'$continue' => t('Continue'),
'$address' => $a->profile['channel_address']
));
$o = replace_macros(get_markup_template('sellpage_view.tpl'),array(
- '$header' => t('Restricted Channel'),
+ '$header' => t('Restricted or Premium Channel'),
'$desc' => t('This channel may require additional steps or acknowledgement of the following conditions prior to connecting:'),
'$text' => prepare_text($text),
@@ -90,8 +105,9 @@ function connect_content(&$a) {
));
-
-
+ $arr = array('profile' => $a->profile,'observer' => $a->get_observer(), 'sellpage' => $o, 'submit' => $submit);
+ call_hooks('connect_premium', $arr);
+ $o = $arr['sellpage'];
}
diff --git a/mod/follow.php b/mod/follow.php
index d21c50df6..9f5a8183b 100644
--- a/mod/follow.php
+++ b/mod/follow.php
@@ -12,8 +12,9 @@ function follow_init(&$a) {
$uid = local_user();
$url = notags(trim($_REQUEST['url']));
$return_url = $_SESSION['return_url'];
+ $confirm = intval($_REQUEST['confirm']);
- $result = new_contact($uid,$url,$a->get_channel(),true);
+ $result = new_contact($uid,$url,$a->get_channel(),true,$confirm);
if($result['success'] == false) {
if($result['message'])
diff --git a/mod/zfinger.php b/mod/zfinger.php
index d5b750537..320f0ca71 100644
--- a/mod/zfinger.php
+++ b/mod/zfinger.php
@@ -140,7 +140,7 @@ function zfinger_init(&$a) {
// This is a template - %s will be replaced with the follow_url we discover for the return channel.
if($special_channel)
- $ret['connect_url'] = z_root() . '/connect/' . $e['channel_address'] . '?f=&follow=%s';
+ $ret['connect_url'] = z_root() . '/connect/' . $e['channel_address'];
// This is a template for our follow url, %s will be replaced with a webbie
diff --git a/view/css/mod_connect.css b/view/css/mod_connect.css
index 43de7d256..d1a46ec48 100644
--- a/view/css/mod_connect.css
+++ b/view/css/mod_connect.css
@@ -1,3 +1,11 @@
+.sellpage-body {
+ margin-top: 25px;
+}
+
.sellpage-final {
margin-top: 25px;
+}
+
+#sellpage-edit label{
+ width: 300px;
} \ No newline at end of file
diff --git a/view/tpl/sellpage_edit.tpl b/view/tpl/sellpage_edit.tpl
new file mode 100644
index 000000000..0a4726fb2
--- /dev/null
+++ b/view/tpl/sellpage_edit.tpl
@@ -0,0 +1,23 @@
+<h1>{{$header}}</h1>
+<form id="sellpage-edit" action="connect/{{$address}}" method="post">
+
+{{include file="field_checkbox.tpl" field=$premium}}
+
+<div class="descriptive-text">{{$desc}}</div>
+
+<div class="sellpage-editbody">
+<p id="sellpage-bodydesc" >
+{{$lbl_about}}
+</p>
+
+<textarea rows="10" cols="72" id="sellpage-textinp" name="text" >{{$text}}</textarea>
+
+</div>
+<div id="sellpage-editbody-end"></div>
+
+
+<div class="descriptive-text">{{$lbl2}}</div>
+<div class="sellpage-final">{{$desc2}}</div>
+
+<input type="submit" name="submit" value="{{$submit}}" />
+</form>