diff options
Diffstat (limited to 'mod/connedit.php')
-rw-r--r-- | mod/connedit.php | 118 |
1 files changed, 60 insertions, 58 deletions
diff --git a/mod/connedit.php b/mod/connedit.php index 0944a3dca..877c12dc7 100644 --- a/mod/connedit.php +++ b/mod/connedit.php @@ -79,7 +79,7 @@ function connedit_post(&$a) { call_hooks('contact_edit_post', $_POST); - if($orig_record[0]['abook_flags'] & ABOOK_FLAG_SELF) { + if(intval($orig_record[0]['abook_self'])) { $autoperms = intval($_POST['autoperms']); $is_self = true; } @@ -130,7 +130,6 @@ function connedit_post(&$a) { } } - $abook_flags = $orig_record[0]['abook_flags']; $new_friend = false; if(! $is_self) { @@ -176,8 +175,7 @@ function connedit_post(&$a) { } } - if(($_REQUEST['pending']) && ($abook_flags & ABOOK_FLAG_PENDING)) { - $abook_flags = ( $abook_flags ^ ABOOK_FLAG_PENDING ); + if(($_REQUEST['pending']) && intval($orig_record[0]['abook_pending'])) { $new_friend = true; if(! $abook_my_perms) { @@ -192,13 +190,15 @@ function connedit_post(&$a) { } } - $r = q("UPDATE abook SET abook_profile = '%s', abook_my_perms = %d , abook_closeness = %d, abook_flags = %d, + $abook_pending = (($new_friend) ? 0 : $orig_record[0]['abook_pending']); + + $r = q("UPDATE abook SET abook_profile = '%s', abook_my_perms = %d , abook_closeness = %d, abook_pending = %d, abook_incl = '%s', abook_excl = '%s' where abook_id = %d AND abook_channel = %d", dbesc($profile_id), intval($abook_my_perms), intval($closeness), - intval($abook_flags), + intval($abook_pending), dbesc($abook_incl), dbesc($abook_excl), intval($contact_id), @@ -214,15 +214,14 @@ function connedit_post(&$a) { } - if($r) info( t('Connection updated.') . EOL); else notice( t('Failed to update connection record.') . EOL); if($a->poi && $a->poi['abook_my_perms'] != $abook_my_perms - && (! ($a->poi['abook_flags'] & ABOOK_FLAG_SELF))) { - proc_run('php', 'include/notifier.php', 'permission_update', $contact_id); + && (! intval($a->poi['abook_self']))) { + proc_run('php', 'include/notifier.php', (($new_friend) ? 'permission_create' : 'permission_update'), $contact_id); } if($new_friend) { @@ -241,11 +240,12 @@ function connedit_post(&$a) { $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')))) { + if(($pr) && (! intval($orig_record[0]['abook_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['item_wall'] = 1; + $xarr['item_origin'] = 1; + $xarr['item_thread_top'] = 1; $xarr['owner_xchan'] = $xarr['author_xchan'] = $channel['channel_hash']; $xarr['allow_cid'] = $channel['channel_allow_cid']; $xarr['allow_gid'] = $channel['channel_allow_gid']; @@ -314,16 +314,15 @@ 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]; - } - + $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; @@ -382,10 +381,9 @@ 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 )>0 LIMIT 1", + WHERE abook_id = %d AND abook_channel = %d AND abook_self = 0 LIMIT 1", intval($contact_id), - intval(local_channel()), - intval(ABOOK_FLAG_SELF) + intval(local_channel()) ); if(! count($orig_record)) { @@ -409,9 +407,6 @@ function connedit_content(&$a) { if($cmd === 'block') { if(abook_toggle_flag($orig_record[0],ABOOK_FLAG_BLOCKED)) { - // info((($orig_record[0]['abook_flags'] & ABOOK_FLAG_BLOCKED) - // ? t('Channel has been unblocked') - // : t('Channel has been blocked')) . EOL ); connedit_clone($a); } else @@ -421,9 +416,6 @@ function connedit_content(&$a) { if($cmd === 'ignore') { if(abook_toggle_flag($orig_record[0],ABOOK_FLAG_IGNORED)) { - // info((($orig_record[0]['abook_flags'] & ABOOK_FLAG_IGNORED) - // ? t('Channel has been unignored') - // : t('Channel has been ignored')) . EOL ); connedit_clone($a); } else @@ -433,9 +425,6 @@ function connedit_content(&$a) { if($cmd === 'archive') { if(abook_toggle_flag($orig_record[0],ABOOK_FLAG_ARCHIVED)) { - // info((($orig_record[0]['abook_flags'] & ABOOK_FLAG_ARCHIVED) - // ? t('Channel has been unarchived') - // : t('Channel has been archived')) . EOL ); connedit_clone($a); } else @@ -445,9 +434,6 @@ function connedit_content(&$a) { if($cmd === 'hide') { if(abook_toggle_flag($orig_record[0],ABOOK_FLAG_HIDDEN)) { - // info((($orig_record[0]['abook_flags'] & ABOOK_FLAG_HIDDEN) - // ? t('Channel has been unhidden') - // : t('Channel has been hidden')) . EOL ); connedit_clone($a); } else @@ -459,11 +445,8 @@ function connedit_content(&$a) { // Though maybe somebody will want this eventually (??) if($cmd === 'approve') { - if($orig_record[0]['abook_flags'] & ABOOK_FLAG_PENDING) { + if(intval($orig_record[0]['abook_pending'])) { if(abook_toggle_flag($orig_record[0],ABOOK_FLAG_PENDING)) { - // info((($orig_record[0]['abook_flags'] & ABOOK_FLAG_PENDING) - // ? t('Channel has been approved') - // : t('Channel has been unapproved')) . EOL ); connedit_clone($a); } else @@ -528,35 +511,35 @@ function connedit_content(&$a) { ), 'block' => array( - 'label' => (($contact['abook_flags'] & ABOOK_FLAG_BLOCKED) ? t('Unblock') : t('Block')), + 'label' => (intval($contact['abook_blocked']) ? t('Unblock') : t('Block')), 'url' => $a->get_baseurl(true) . '/connedit/' . $contact['abook_id'] . '/block', - 'sel' => (($contact['abook_flags'] & ABOOK_FLAG_BLOCKED) ? 'active' : ''), + 'sel' => (intval($contact['abook_blocked']) ? 'active' : ''), 'title' => t('Block (or Unblock) all communications with this connection'), - 'info' => (($contact['abook_flags'] & ABOOK_FLAG_BLOCKED) ? t('This connection is blocked!') : ''), + 'info' => (intval($contact['abook_blocked']) ? t('This connection is blocked!') : ''), ), 'ignore' => array( - 'label' => (($contact['abook_flags'] & ABOOK_FLAG_IGNORED) ? t('Unignore') : t('Ignore')), + 'label' => (intval($contact['abook_ignored']) ? t('Unignore') : t('Ignore')), 'url' => $a->get_baseurl(true) . '/connedit/' . $contact['abook_id'] . '/ignore', - 'sel' => (($contact['abook_flags'] & ABOOK_FLAG_IGNORED) ? 'active' : ''), + 'sel' => (intval($contact['abook_ignored']) ? 'active' : ''), 'title' => t('Ignore (or Unignore) all inbound communications from this connection'), - 'info' => (($contact['abook_flags'] & ABOOK_FLAG_IGNORED) ? t('This connection is ignored!') : ''), + 'info' => (intval($contact['abook_ignored']) ? t('This connection is ignored!') : ''), ), 'archive' => array( - 'label' => (($contact['abook_flags'] & ABOOK_FLAG_ARCHIVED) ? t('Unarchive') : t('Archive')), + 'label' => (intval($contact['abook_archived']) ? t('Unarchive') : t('Archive')), 'url' => $a->get_baseurl(true) . '/connedit/' . $contact['abook_id'] . '/archive', - 'sel' => (($contact['abook_flags'] & ABOOK_FLAG_ARCHIVED) ? 'active' : ''), + 'sel' => (intval($contact['abook_archived']) ? 'active' : ''), 'title' => t('Archive (or Unarchive) this connection - mark channel dead but keep content'), - 'info' => (($contact['abook_flags'] & ABOOK_FLAG_ARCHIVED) ? t('This connection is archived!') : ''), + 'info' => (intval($contact['abook_archived']) ? t('This connection is archived!') : ''), ), 'hide' => array( - 'label' => (($contact['abook_flags'] & ABOOK_FLAG_HIDDEN) ? t('Unhide') : t('Hide')), + 'label' => (intval($contact['abook_hidden']) ? t('Unhide') : t('Hide')), 'url' => $a->get_baseurl(true) . '/connedit/' . $contact['abook_id'] . '/hide', - 'sel' => (($contact['abook_flags'] & ABOOK_FLAG_HIDDEN) ? 'active' : ''), + 'sel' => (intval($contact['abook_hidden']) ? 'active' : ''), 'title' => t('Hide or Unhide this connection from your other connections'), - 'info' => (($contact['abook_flags'] & ABOOK_FLAG_HIDDEN) ? t('This connection is hidden!') : ''), + 'info' => (intval($contact['abook_hidden']) ? t('This connection is hidden!') : ''), ), 'delete' => array( @@ -570,7 +553,7 @@ function connedit_content(&$a) { $self = false; - if(($contact['abook_flags'] & ABOOK_FLAG_SELF)) + if(intval($contact['abook_self'])) $self = true; require_once('include/contact_selectors.php'); @@ -669,12 +652,31 @@ function connedit_content(&$a) { $perms[] = array('perms_' . $k, $v[3], (($contact['abook_their_perms'] & $v[1]) ? "1" : ""),$thisperm, $v[1], (($channel[$v[0]] == PERMS_SPECIFIC) ? '' : '1'), $v[4], $checkinherited); } + $locstr = ''; + + $locs = q("select hubloc_addr as location from hubloc left join site on hubloc_url = site_url where hubloc_hash = '%s' + and hubloc_deleted = 0 and site_dead = 0", + dbesc($contact['xchan_hash']) + ); + + if($locs) { + foreach($locs as $l) { + if(strlen($locstr)) + $locstr .= ', '; + $locstr .= $l['location']; + } + } + else + $locstr = t('none'); + $o .= replace_macros($tpl,array( '$header' => (($self) ? t('Connection Default Permissions') : sprintf( t('Connection: %s'),$contact['xchan_name'])), '$autoperms' => array('autoperms',t('Apply these permissions automatically'), ((get_pconfig(local_channel(),'system','autoperms')) ? 1 : 0), 'Connection requests will be approved without your interaction', array(t('No'),('Yes'))), '$addr' => $contact['xchan_addr'], - '$addr_text' => t('This connection\'s address is'), + '$addr_text' => t('This connection\'s primary address is'), + '$loc_text' => t('Available locations:'), + '$locstr' => $locstr, '$notself' => (($self) ? '' : '1'), '$self' => (($self) ? '1' : ''), '$autolbl' => t('The permissions indicated on this page will be applied to all new connections.'), @@ -685,8 +687,8 @@ function connedit_content(&$a) { '$lbl_rating_txt' => t('Optionally explain your rating'), '$connfilter' => feature_enabled(local_channel(),'connfilter'), '$connfilter_label' => t('Custom Filter'), - '$incl' => array('abook_incl',t('Only import posts with this text'), $contact['abook_incl'],t('words one per line or #tags or /patterns/, leave blank to import all posts')), - '$excl' => array('abook_excl',t('Do not import posts with this text'), $contact['abook_excl'],t('words one per line or #tags or /patterns/, leave blank to import all posts')), + '$incl' => array('abook_incl',t('Only import posts with this text'), $contact['abook_incl'],t('words one per line or #tags or /patterns/ or lang=xx, leave blank to import all posts')), + '$excl' => array('abook_excl',t('Do not import posts with this text'), $contact['abook_excl'],t('words one per line or #tags or /patterns/ or lang=xx, leave blank to import all posts')), '$rating_text' => array('rating_text', t('Optionally explain your rating'),$rating_text,''), '$rating_info' => t('This information is public!'), '$rating' => $rating, @@ -698,7 +700,7 @@ function connedit_content(&$a) { '$pending_modal_body' => sprintf(t('(%s) would like to connect with you. Please approve this connection to allow communication.'), $contact['xchan_addr']), '$pending_modal_approve' => t('Approve'), '$pending_modal_dismiss' => t('Approve Later'), - '$is_pending' => (($contact['abook_flags'] & ABOOK_FLAG_PENDING) ? 1 : ''), + '$is_pending' => (intval($contact['abook_pending']) ? 1 : ''), '$unapproved' => $unapproved, '$inherited' => t('inherited'), '$submit' => t('Submit'), |