diff options
-rw-r--r-- | include/Contact.php | 3 | ||||
-rw-r--r-- | mod/connections.php | 140 | ||||
-rw-r--r-- | mod/connedit.php | 12 | ||||
-rw-r--r-- | version.inc | 2 |
4 files changed, 13 insertions, 144 deletions
diff --git a/include/Contact.php b/include/Contact.php index 035e83a82..a27a8eca9 100644 --- a/include/Contact.php +++ b/include/Contact.php @@ -149,9 +149,6 @@ function abook_toggle_flag($abook,$flag) { ); } - $a = get_app(); - if($a->data['abook']) - $a->data['abook']['abook_flags'] = $a->data['abook']['abook_flags'] ^ $flag; return $r; } diff --git a/mod/connections.php b/mod/connections.php index 469d3a62f..8b95cbf2a 100644 --- a/mod/connections.php +++ b/mod/connections.php @@ -19,146 +19,6 @@ function connections_init(&$a) { } -function connections_post(&$a) { - - if(! local_channel()) - return; - - $contact_id = intval(argv(1)); - if(! $contact_id) - return; - - $orig_record = q("SELECT * FROM abook WHERE abook_id = %d AND abook_channel = %d LIMIT 1", - intval($contact_id), - intval(local_channel()) - ); - - if(! $orig_record) { - notice( t('Could not access contact record.') . EOL); - goaway(z_root() . '/connections'); - return; // NOTREACHED - } - - call_hooks('contact_edit_post', $_POST); - - $profile_id = $_POST['profile_assign']; - if($profile_id) { - $r = q("SELECT profile_guid FROM profile WHERE profile_guid = '%s' AND `uid` = %d LIMIT 1", - dbesc($profile_id), - intval(local_channel()) - ); - if(! count($r)) { - notice( t('Could not locate selected profile.') . EOL); - return; - } - } - - $hidden = intval($_POST['hidden']); - - $priority = intval($_POST['poll']); - if($priority > 5 || $priority < 0) - $priority = 0; - - $closeness = intval($_POST['closeness']); - if($closeness < 0) - $closeness = 99; - - $abook_my_perms = 0; - - foreach($_POST as $k => $v) { - if(strpos($k,'perms_') === 0) { - $abook_my_perms += $v; - } - } - - $abook_flags = $orig_record[0]['abook_flags']; - $new_friend = false; - - - if(($_REQUEST['pending']) && ($abook_flags & ABOOK_FLAG_PENDING)) { - $abook_flags = ( $abook_flags ^ ABOOK_FLAG_PENDING ); - $new_friend = true; - } - - $r = q("UPDATE abook SET abook_profile = '%s', abook_my_perms = %d , abook_closeness = %d, abook_flags = %d - where abook_id = %d AND abook_channel = %d", - dbesc($profile_id), - intval($abook_my_perms), - intval($closeness), - intval($abook_flags), - intval($contact_id), - intval(local_channel()) - ); - - if($r) - info( t('Connection updated.') . EOL); - else - notice( t('Failed to update connection record.') . EOL); - - if((x($a->data,'abook')) && $a->data['abook']['abook_my_perms'] != $abook_my_perms - && (! ($a->data['abook']['abook_flags'] & ABOOK_FLAG_SELF))) { - proc_run('php', 'include/notifier.php', 'permission_update', $contact_id); - } - - if($new_friend) { - $channel = $a->get_channel(); - $default_group = $channel['channel_default_group']; - if($default_group) { - require_once('include/group.php'); - $g = group_rec_byhash(local_channel(),$default_group); - if($g) - group_add_member(local_channel(),'',$a->data['abook_xchan'],$g['id']); - } - - - - // Check if settings permit ("post new friend activity" is allowed, and - // friends in general or this friend in particular aren't hidden) - // and send out a new friend activity - // TODO - - // pull in a bit of content if there is any to pull in - proc_run('php','include/onepoll.php',$contact_id); - - } - - // Refresh the structure in memory with the new data - - $r = q("SELECT abook.*, xchan.* - FROM abook left join xchan on abook_xchan = xchan_hash - WHERE abook_channel = %d and abook_id = %d LIMIT 1", - intval(local_channel()), - intval($contact_id) - ); - if($r) { - $a->data['abook'] = $r[0]; - } - - if($new_friend) { - $arr = array('channel_id' => local_channel(), 'abook' => $a->data['abook']); - call_hooks('accept_follow', $arr); - } - - connections_clone($a); - - return; - -} - -function connections_clone(&$a) { - - if(! array_key_exists('abook',$a->data)) - return; - $clone = $a->data['abook']; - - unset($clone['abook_id']); - unset($clone['abook_account']); - unset($clone['abook_channel']); - - build_sync_packet(0 /* use the current local_channel */, array('abook' => array($clone))); -} - - function connections_content(&$a) { $sort_type = 0; diff --git a/mod/connedit.php b/mod/connedit.php index bc8ae5e2e..0944a3dca 100644 --- a/mod/connedit.php +++ b/mod/connedit.php @@ -313,6 +313,18 @@ function connedit_clone(&$a) { if(! $a->poi) return; + + $r = q("SELECT abook.*, xchan.* + FROM abook left join xchan on abook_xchan = xchan_hash + WHERE abook_channel = %d and abook_id = %d LIMIT 1", + intval(local_channel()), + intval($a->poi['abook_id']) + ); + if($r) { + $a->poi = $r[0]; + } + + $clone = $a->poi; unset($clone['abook_id']); diff --git a/version.inc b/version.inc index 6e33a9758..853449713 100644 --- a/version.inc +++ b/version.inc @@ -1 +1 @@ -2015-08-23.1133 +2015-08-24.1134 |