aboutsummaryrefslogtreecommitdiffstats
path: root/mod/connedit.php
diff options
context:
space:
mode:
authorPaolo T <tuscanhobbit@users.noreply.github.com>2014-08-18 18:55:18 +0200
committerPaolo T <tuscanhobbit@users.noreply.github.com>2014-08-18 18:55:18 +0200
commitb5d1c7865b14fa60c35618b4179eb3c91949a441 (patch)
tree38ddb2fcab0f4c2c3baf6917e3544148cbe1eb9e /mod/connedit.php
parent3b979dd2a9f8bb8f569c234408d02dfd1e7039d7 (diff)
parentd9ff121930554aa9bcad4f4ceffeb9b5e3b83d17 (diff)
downloadvolse-hubzilla-b5d1c7865b14fa60c35618b4179eb3c91949a441.tar.gz
volse-hubzilla-b5d1c7865b14fa60c35618b4179eb3c91949a441.tar.bz2
volse-hubzilla-b5d1c7865b14fa60c35618b4179eb3c91949a441.zip
Merge pull request #1 from friendica/master
Red master has been merged
Diffstat (limited to 'mod/connedit.php')
-rw-r--r--mod/connedit.php72
1 files changed, 57 insertions, 15 deletions
diff --git a/mod/connedit.php b/mod/connedit.php
index b9f0299e2..b2de42343 100644
--- a/mod/connedit.php
+++ b/mod/connedit.php
@@ -118,13 +118,14 @@ function connedit_post(&$a) {
intval(local_user())
);
- if($orig_record[0]['abook_profile'] != $profile_id) { //Update profile photo permissions
+ if($orig_record[0]['abook_profile'] != $profile_id) {
+ //Update profile photo permissions
- logger('As a new profile was assigned updateing profile photos');
- require_once('mod/profile_photo.php');
- profile_photo_set_profile_perms($profile_id);
+ logger('As a new profile was assigned updating profile photos');
+ require_once('mod/profile_photo.php');
+ profile_photo_set_profile_perms($profile_id);
- }
+ }
if($r)
@@ -147,12 +148,44 @@ function connedit_post(&$a) {
group_add_member(local_user(),'',$a->poi['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
+
+ $pr = q("select * from profile where uid = %d and is_default = 1 and hide_friends = 0",
+ intval($channel['channel_id'])
+ );
+ if(($pr) && (! ($abook_flags & ABOOK_FLAG_HIDDEN))
+ && (intval(get_pconfig($channel['channel_id'],'system','post_newfriend')))) {
+ $xarr = array();
+ $xarr['verb'] = ACTIVITY_FRIEND;
+ $xarr['item_flags'] = ITEM_WALL|ITEM_ORIGIN|ITEM_THREAD_TOP;
+ $xarr['owner_xchan'] = $xarr['author_xchan'] = $channel['channel_hash'];
+ $xarr['allow_cid'] = $channel['channel_allow_cid'];
+ $xarr['allow_gid'] = $channel['channel_allow_gid'];
+ $xarr['deny_cid'] = $channel['channel_deny_cid'];
+ $xarr['deny_gid'] = $channel['channel_deny_gid'];
+ $xarr['item_private'] = (($xarr['allow_cid']||$xarr['allow_gid']||$xarr['deny_cid']||$xarr['deny_gid']) ? 1 : 0);
+ $obj = array(
+ 'type' => ACTIVITY_OBJ_PERSON,
+ 'title' => $a->poi['xchan_name'],
+ 'id' => $a->poi['xchan_hash'],
+ 'link' => array(
+ array('rel' => 'alternate', 'type' => 'text/html', 'href' => $a->poi['xchan_url']),
+ array('rel' => 'photo', 'type' => $a->poi['xchan_photo_mimetype'], 'href' => $a->poi['xchan_photo_l'])
+ ),
+ );
+ $xarr['object'] = json_encode($obj);
+ $xarr['obj_type'] = ACTIVITY_OBJ_PERSON;
+
+ $xarr['body'] = '[zrl=' . $channel['xchan_url'] . ']' . $channel['xchan_name'] . '[/zrl]' . ' ' . t('is now connected to') . ' ' . '[zrl=' . $a->poi['xchan_url'] . ']' . $a->poi['xchan_name'] . '[/zrl]';
+
+ $xarr['body'] .= "\n\n\n" . '[zrl=' . $a->poi['xchan_url'] . '][zmg=80x80]' . $a->poi['xchan_photo_m'] . '[/zmg][/zrl]';
+
+ post_activity_item($xarr);
+
+ }
+
// pull in a bit of content if there is any to pull in
proc_run('php','include/onepoll.php',$contact_id);
@@ -231,12 +264,10 @@ function connedit_content(&$a) {
$cmd = argv(2);
$orig_record = q("SELECT abook.*, xchan.* FROM abook left join xchan on abook_xchan = xchan_hash
- WHERE abook_id = %d AND abook_channel = %d AND NOT ( abook_flags & %d ) and not ( abook_flags & %d ) LIMIT 1",
+ WHERE abook_id = %d AND abook_channel = %d AND NOT ( abook_flags & %d ) LIMIT 1",
intval($contact_id),
intval(local_user()),
- intval(ABOOK_FLAG_SELF),
- // allow drop even if pending, just duplicate the self query
- intval(($cmd === 'drop') ? ABOOK_FLAG_SELF : ABOOK_FLAG_PENDING)
+ intval(ABOOK_FLAG_SELF)
);
if(! count($orig_record)) {
@@ -306,7 +337,8 @@ function connedit_content(&$a) {
goaway($a->get_baseurl(true) . '/connedit/' . $contact_id);
}
- // We'll prevent somebody from unapproving a contact.
+ // We'll prevent somebody from unapproving an already approved contact.
+ // Though maybe somebody will want this eventually (??)
if($cmd === 'approve') {
if($orig_record[0]['abook_flags'] & ABOOK_FLAG_PENDING) {
@@ -326,11 +358,21 @@ function connedit_content(&$a) {
if($cmd === 'drop') {
require_once('include/Contact.php');
+
// FIXME
-// terminate_friendship($a->get_channel(),$orig_record[0]);
+// We need to send either a purge or a refresh packet to the other side (the channel being unfriended).
+// The issue is that the abook DB record _may_ get destroyed when we call contact_remove. As the notifier runs
+// in the background there could be a race condition preventing this packet from being sent in all cases.
+// PLACEHOLDER
contact_remove(local_user(), $orig_record[0]['abook_id']);
-// FIXME - send to clones
+ build_sync_packet(0 /* use the current local_user */,
+ array('abook' => array(
+ 'abook_xchan' => $orig_record[0]['abook_xchan'],
+ 'entry_deleted' => true)
+ )
+ );
+
info( t('Connection has been removed.') . EOL );
if(x($_SESSION,'return_url'))
goaway($a->get_baseurl(true) . '/' . $_SESSION['return_url']);