aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/follow.php61
-rw-r--r--include/group.php34
-rwxr-xr-xinclude/items.php18
-rw-r--r--include/network.php31
-rw-r--r--include/text.php1
5 files changed, 69 insertions, 76 deletions
diff --git a/include/follow.php b/include/follow.php
index 88418926b..eba353c8b 100644
--- a/include/follow.php
+++ b/include/follow.php
@@ -111,7 +111,10 @@ function new_contact($uid,$url,$channel,$interactive = false) {
if((local_user()) && $uid == local_user()) {
$aid = get_account_id();
- $hash = $a->observer['xchan_hash'];
+ $hash = get_observer_hash();
+ $ch = $a->get_channel();
+ $default_group = $ch['channel_default_group'];
+
}
else {
$r = q("select * from channel where channel_id = %d limit 1",
@@ -123,6 +126,7 @@ function new_contact($uid,$url,$channel,$interactive = false) {
}
$aid = $r[0]['channel_account_id'];
$hash = $r[0]['channel_hash'];
+ $default_group = $r[0]['channel_default_group'];
}
if($hash == $xchan_hash) {
@@ -163,59 +167,16 @@ function new_contact($uid,$url,$channel,$interactive = false) {
if($r)
$result['abook'] = $r[0];
- // Then send a ping/message to the other side
-
-
-/*
-
- $r = q("INSERT INTO `contact` ( `uid`, `created`, `url`, `nurl`, `addr`, `alias`, `batch`, `notify`, `poll`, `poco`, `name`, `nick`, `photo`, `network`, `pubkey`, `rel`, `priority`,
- `writable`, `hidden`, `blocked`, `readonly`, `pending` )
- VALUES ( %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', %d, %d, %d, %d, 0, 0, 0) ",
- intval($uid),
- dbesc(datetime_convert()),
- dbesc($ret['url']),
- dbesc(normalise_link($ret['url'])),
- dbesc($ret['addr']),
- dbesc($ret['alias']),
- dbesc($ret['batch']),
- dbesc($ret['notify']),
- dbesc($ret['poll']),
- dbesc($ret['poco']),
- dbesc($ret['name']),
- dbesc($ret['nick']),
- dbesc($ret['photo']),
- dbesc($ret['network']),
- dbesc($ret['pubkey']),
- intval($new_relation),
- intval($ret['priority']),
- intval($writeable),
- intval($hidden)
- );
- }
-
- $r = q("SELECT * FROM `contact` WHERE `url` = '%s' AND `uid` = %d LIMIT 1",
- dbesc($ret['url']),
- intval($uid)
- );
-
- if(! count($r)) {
- $result['message'] .= t('Unable to retrieve contact information.') . EOL;
- return $result;
- }
+ /** If there is a default group for this channel, add this member to it */
- $contact = $r[0];
- $contact_id = $r[0]['id'];
-
-
- $g = q("select def_gid from user where uid = %d limit 1",
- intval($uid)
- );
- if($g && intval($g[0]['def_gid'])) {
+ if($default_group) {
require_once('include/group.php');
- group_add_member($uid,'',$contact_id,$g[0]['def_gid']);
+ $g = group_rec_byhash($uid,$default_group);
+ if($g)
+ group_add_member($uid,'',$xchan_hash,$g['id']);
}
-*/
+ // Then send a ping/message to the other side
$result['success'] = true;
diff --git a/include/group.php b/include/group.php
index d4a01593e..4a7acf7c9 100644
--- a/include/group.php
+++ b/include/group.php
@@ -52,40 +52,43 @@ function group_add($uid,$name) {
function group_rmv($uid,$name) {
$ret = false;
if(x($uid) && x($name)) {
- $r = q("SELECT id FROM `group` WHERE `uid` = %d AND `name` = '%s' LIMIT 1",
+ $r = q("SELECT id, hash FROM `group` WHERE `uid` = %d AND `name` = '%s' LIMIT 1",
intval($uid),
dbesc($name)
);
- if(count($r))
+ if($r) {
$group_id = $r[0]['id'];
+ $group_hash = $r[0]['hash'];
+ }
+
if(! $group_id)
return false;
// remove group from default posting lists
- $r = q("SELECT channel_default_gid, channel_allow_gid, channel_deny_gid FROM channel WHERE channel_id = %d LIMIT 1",
+ $r = q("SELECT channel_default_group, channel_allow_gid, channel_deny_gid FROM channel WHERE channel_id = %d LIMIT 1",
intval($uid)
);
if($r) {
$user_info = $r[0];
$change = false;
- if($user_info['channel_default_gid'] == $group_id) {
- $user_info['channel_default_gid'] = 0;
+ if($user_info['channel_default_group'] == $group_hash) {
+ $user_info['channel_default_group'] = '';
$change = true;
}
if(strpos($user_info['channel_allow_gid'], '<' . $group_id . '>') !== false) {
- $user_info['channel_allow_gid'] = str_replace('<' . $group_id . '>', '', $user_info['channel_allow_gid']);
+ $user_info['channel_allow_gid'] = str_replace('<' . $group_hash . '>', '', $user_info['channel_allow_gid']);
$change = true;
}
if(strpos($user_info['channel_deny_gid'], '<' . $group_id . '>') !== false) {
- $user_info['channel_deny_gid'] = str_replace('<' . $group_id . '>', '', $user_info['channel_deny_gid']);
+ $user_info['channel_deny_gid'] = str_replace('<' . $group_hash . '>', '', $user_info['channel_deny_gid']);
$change = true;
}
if($change) {
- q("UPDATE channel SET channel_default_gid = %d, channel_allow_gid = '%s', channel_deny_gid = '%s'
+ q("UPDATE channel SET channel_default_group = '%s', channel_allow_gid = '%s', channel_deny_gid = '%s'
WHERE channel_id = %d",
- intval($user_info['channel_default_gid']),
+ intval($user_info['channel_default_group']),
dbesc($user_info['channel_allow_gid']),
dbesc($user_info['channel_deny_gid']),
intval($uid)
@@ -124,6 +127,19 @@ function group_byname($uid,$name) {
return false;
}
+
+function group_rec_byhash($uid,$hash) {
+ if((! $uid) || (! strlen($hash)))
+ return false;
+ $r = q("SELECT * FROM `group` WHERE `uid` = %d AND `hash` = '%s' LIMIT 1",
+ intval($uid),
+ dbesc($hash)
+ );
+ if($r)
+ return $r[0];
+ return false;
+}
+
function group_rmv_member($uid,$name,$member) {
$gid = group_byname($uid,$name);
if(! $gid)
diff --git a/include/items.php b/include/items.php
index 6b9ecdd48..c303801e7 100755
--- a/include/items.php
+++ b/include/items.php
@@ -1427,22 +1427,8 @@ function item_store($arr,$force_parent = false) {
$arr['item_private'] = 0;
}
else {
-
- // Allow one to see reply tweets from status.net even when
- // we don't have or can't see the original post.
-
- if($force_parent) {
- logger('item_store: $force_parent=true, reply converted to top-level post.');
- $parent_id = 0;
- $arr['parent_mid'] = $arr['mid'];
- $arr['flags'] = $arr['flags'] | ITEM_THREAD_TOP;
- }
- else {
- logger('item_store: item parent was not found - ignoring item');
- return 0;
- }
-
- $parent_deleted = 0;
+ logger('item_store: item parent was not found - ignoring item');
+ return 0;
}
}
diff --git a/include/network.php b/include/network.php
index 9d7ae8497..427519c7a 100644
--- a/include/network.php
+++ b/include/network.php
@@ -10,6 +10,7 @@ function get_capath() {
// curl wrapper. If binary flag is true, return binary
// results.
+
/**
* fetch_url is deprecated and being replaced by the more capable z_fetch_url
* please use that function instead.
@@ -204,6 +205,26 @@ function post_url($url,$params, $headers = null, &$redirects = 0, $timeout = 0)
return($body);
}
+/**
+ * @function z_fetch_url
+ * @param string $url
+ * URL to fetch
+ * @param boolean $binary = false
+ * TRUE if asked to return binary results (file download)
+ * @param int $redirects = 0
+ * internal use, recursion counter
+ * @param array $opts (optional parameters)
+ * 'accept_content' => supply Accept: header with 'accept_content' as the value
+ * 'timeout' => int seconds, default system config value or 60 seconds
+ * 'http_auth' => username:password
+ * 'novalidate' => do not validate SSL certs, default is to validate using our CA list
+ *
+ * @returns array
+ * 'return_code' => HTTP return code or 0 if timeout or failure
+ * 'success' => boolean true (if HTTP 2xx result) or false
+ * 'header' => HTTP headers
+ * 'body' => fetched content
+ */
function z_fetch_url($url, $binary = false, $redirects = 0, $opts = array()) {
@@ -421,7 +442,15 @@ function xml_status($st, $message = '') {
killme();
}
-
+/**
+ * @function http_status_exit
+ *
+ * Send HTTP status header and exit
+ * @param int $val
+ * integer HTTP status result value
+ *
+ * @returns (does not return, process is terminated)
+ */
function http_status_exit($val) {
diff --git a/include/text.php b/include/text.php
index 6e0e63df3..833b495f4 100644
--- a/include/text.php
+++ b/include/text.php
@@ -222,6 +222,7 @@ function unxmlify($s) {
// convenience wrapper, reverse the operation "bin2hex"
+// This is a built-in function in php >= 5.4
if(! function_exists('hex2bin')) {
function hex2bin($s) {