2016-04-19 03:38:38 +00:00
< ? php
namespace Zotlabs\Module ;
2019-05-07 03:22:08 +00:00
use App ;
use Zotlabs\Web\Controller ;
2018-06-01 02:42:13 +00:00
use Zotlabs\Lib\Libzot ;
2018-06-05 01:40:11 +00:00
use Zotlabs\Lib\Libsync ;
2018-08-23 23:50:00 +00:00
use Zotlabs\Lib\ActivityPub ;
2018-08-17 06:01:31 +00:00
use Zotlabs\Lib\Apps ;
2019-02-14 23:26:37 +00:00
use Zotlabs\Lib\AccessList ;
2020-05-17 06:49:40 +00:00
use Zotlabs\Lib\LibBlock ;
2019-05-07 03:22:08 +00:00
use Zotlabs\Access\Permissions ;
2019-05-07 05:22:58 +00:00
use Zotlabs\Access\PermissionLimits ;
use Zotlabs\Lib\Permcat ;
2020-06-15 07:29:56 +00:00
use Zotlabs\Daemon\Run ;
2019-05-07 05:22:58 +00:00
use Zotlabs\Web\HTTPHeaders ;
use Sabre\VObject\Reader ;
2018-06-01 02:42:13 +00:00
2020-04-16 23:24:01 +00:00
/**
* @ file connedit . php
2016-04-19 03:38:38 +00:00
* @ brief In this file the connection - editor form is generated and evaluated .
*/
2016-05-22 23:54:30 +00:00
2016-04-19 03:38:38 +00:00
require_once ( 'include/socgraph.php' );
require_once ( 'include/photos.php' );
2019-05-07 03:22:08 +00:00
class Connedit extends Controller {
2016-04-19 03:38:38 +00:00
2020-04-16 23:24:01 +00:00
/**
* @ brief Initialize the connection - editor
2016-06-15 00:04:29 +00:00
*/
2016-04-19 03:38:38 +00:00
function init () {
2020-04-16 23:24:01 +00:00
if ( ! local_channel ()) {
2016-04-19 03:38:38 +00:00
return ;
2020-04-16 23:24:01 +00:00
}
2016-04-19 03:38:38 +00:00
2020-04-16 23:24:01 +00:00
if (( argc () >= 2 ) && intval ( argv ( 1 ))) {
$r = q ( " SELECT abook.*, xchan.* FROM abook left join xchan on abook_xchan = xchan_hash
2016-04-19 03:38:38 +00:00
WHERE abook_channel = % d and abook_id = % d LIMIT 1 " ,
intval ( local_channel ()),
intval ( argv ( 1 ))
);
2020-04-16 23:24:01 +00:00
// Set the person-of-interest for use by widgets that operate on a single pre-defined channel
if ( $r ) {
2019-05-07 03:22:08 +00:00
App :: $poi = array_shift ( $r );
2016-04-19 03:38:38 +00:00
}
}
2019-05-07 03:22:08 +00:00
$channel = App :: get_channel ();
if ( $channel ) {
2016-04-19 03:38:38 +00:00
head_set_icon ( $channel [ 'xchan_photo_s' ]);
2019-05-07 03:22:08 +00:00
}
2016-04-19 03:38:38 +00:00
}
2016-11-24 23:08:31 +00:00
2016-04-19 03:38:38 +00:00
2020-04-16 23:24:01 +00:00
/**
* @ brief Evaluate posted values and set changes
2016-04-19 03:38:38 +00:00
*/
2016-06-15 00:04:29 +00:00
function post () {
2016-04-19 03:38:38 +00:00
2020-04-16 23:24:01 +00:00
if ( ! local_channel ()) {
2016-04-19 03:38:38 +00:00
return ;
2020-04-16 23:24:01 +00:00
}
2016-04-19 03:38:38 +00:00
$contact_id = intval ( argv ( 1 ));
2020-04-16 23:24:01 +00:00
if ( ! $contact_id ) {
2016-04-19 03:38:38 +00:00
return ;
2020-04-16 23:24:01 +00:00
}
2016-04-19 03:38:38 +00:00
2019-05-07 03:22:08 +00:00
$channel = App :: get_channel ();
2016-04-19 03:38:38 +00:00
$orig_record = q ( " SELECT * FROM abook WHERE abook_id = %d AND abook_channel = %d LIMIT 1 " ,
intval ( $contact_id ),
intval ( local_channel ())
);
2020-04-16 23:24:01 +00:00
if ( ! $orig_record ) {
2016-04-19 03:38:38 +00:00
notice ( t ( 'Could not access contact record.' ) . EOL );
goaway ( z_root () . '/connections' );
}
2020-04-16 23:24:01 +00:00
$orig_record = array_shift ( $orig_record );
2016-04-19 03:38:38 +00:00
call_hooks ( 'contact_edit_post' , $_POST );
2016-12-21 00:45:12 +00:00
$vc = get_abconfig ( local_channel (), $orig_record [ 'abook_xchan' ], 'system' , 'vcard' );
2019-05-07 05:22:58 +00:00
$vcard = (( $vc ) ? Reader :: read ( $vc ) : null );
2016-12-21 00:45:12 +00:00
$serialised_vcard = update_vcard ( $_REQUEST , $vcard );
2020-04-16 23:24:01 +00:00
if ( $serialised_vcard ) {
set_abconfig ( local_channel (), $orig_record [ 'abook_xchan' ], 'system' , 'vcard' , $serialised_vcard );
}
$autoperms = null ;
$is_self = false ;
2016-12-21 00:45:12 +00:00
2020-04-16 23:24:01 +00:00
if ( intval ( $orig_record [ 'abook_self' ])) {
2016-04-19 03:38:38 +00:00
$autoperms = intval ( $_POST [ 'autoperms' ]);
$is_self = true ;
}
2020-04-16 23:24:01 +00:00
$profile_id = (( array_key_exists ( 'profile_assign' , $_POST )) ? $_POST [ 'profile_assign' ] : $orig_record [ 'abook_profile' ]);
2018-12-17 09:59:17 +00:00
2020-04-16 23:24:01 +00:00
if ( $profile_id ) {
2016-10-09 23:31:04 +00:00
$r = q ( " SELECT profile_guid FROM profile WHERE profile_guid = '%s' AND uid = %d LIMIT 1 " ,
2016-04-19 03:38:38 +00:00
dbesc ( $profile_id ),
intval ( local_channel ())
);
2020-04-16 23:24:01 +00:00
if ( ! $r ) {
2016-04-19 03:38:38 +00:00
notice ( t ( 'Could not locate selected profile.' ) . EOL );
return ;
}
}
2020-04-16 23:24:01 +00:00
$abook_incl = (( array_key_exists ( 'abook_incl' , $_POST )) ? escape_tags ( $_POST [ 'abook_incl' ]) : $orig_record [ 'abook_incl' ]);
$abook_excl = (( array_key_exists ( 'abook_excl' , $_POST )) ? escape_tags ( $_POST [ 'abook_excl' ]) : $orig_record [ 'abook_excl' ]);
$abook_alias = (( array_key_exists ( 'abook_alias' , $_POST )) ? escape_tags ( trim ( $_POST [ 'abook_alias' ])) : $orig_record [ 'abook_alias' ]);
2018-12-17 09:59:17 +00:00
2021-04-08 06:22:10 +00:00
$block_announce = (( array_key_exists ( 'block_announce' , $_POST )) ? intval ( $_POST [ 'block_announce' ]) : 0 );
set_abconfig ( $channel [ 'channel_id' ], $orig_record [ 'abook_xchan' ], 'system' , 'block_announce' , $block_announce );
2016-04-19 03:38:38 +00:00
$hidden = intval ( $_POST [ 'hidden' ]);
$priority = intval ( $_POST [ 'poll' ]);
2020-04-16 23:24:01 +00:00
if ( $priority > 5 || $priority < 0 ) {
2016-04-19 03:38:38 +00:00
$priority = 0 ;
2020-04-16 23:24:01 +00:00
}
2016-04-19 03:38:38 +00:00
2020-04-16 23:24:01 +00:00
if ( ! array_key_exists ( 'closeness' , $_POST )) {
2018-12-17 09:59:17 +00:00
$_POST [ 'closeness' ] = 80 ;
}
2016-04-19 03:38:38 +00:00
$closeness = intval ( $_POST [ 'closeness' ]);
2020-04-16 23:24:01 +00:00
if ( $closeness < 0 || $closeness > 99 ) {
2018-12-17 09:59:17 +00:00
$closeness = 80 ;
}
2016-04-19 03:38:38 +00:00
2019-05-07 03:22:08 +00:00
$all_perms = Permissions :: Perms ();
2016-07-12 00:02:49 +00:00
2018-06-08 03:17:30 +00:00
$p = EMPTY_STR ;
2020-04-16 23:24:01 +00:00
if ( $all_perms ) {
foreach ( $all_perms as $perm => $desc ) {
if ( array_key_exists ( 'perms_' . $perm , $_POST )) {
if ( $p ) {
2018-06-08 03:17:30 +00:00
$p .= ',' ;
2020-04-16 23:24:01 +00:00
}
2018-06-08 03:17:30 +00:00
$p .= $perm ;
2016-07-12 00:02:49 +00:00
}
2016-04-19 03:38:38 +00:00
}
2020-04-16 23:24:01 +00:00
set_abconfig ( $channel [ 'channel_id' ], $orig_record [ 'abook_xchan' ], 'system' , 'my_perms' , $p );
if ( $autoperms ) {
2018-06-08 03:17:30 +00:00
set_pconfig ( $channel [ 'channel_id' ], 'system' , 'autoperms' , $p );
}
2016-04-19 03:38:38 +00:00
}
2016-07-19 04:37:34 +00:00
2016-04-19 03:38:38 +00:00
$new_friend = false ;
2018-08-06 04:57:53 +00:00
2020-04-16 23:24:01 +00:00
if (( $_REQUEST [ 'pending' ]) && intval ( $orig_record [ 'abook_pending' ])) {
2017-02-10 03:52:13 +00:00
2016-04-19 03:38:38 +00:00
$new_friend = true ;
// @fixme it won't be common, but when you accept a new connection request
// the permissions will now be that of your permissions role and ignore
// any you may have set manually on the form. We'll probably see a bug if somebody
// tries to set the permissions *and* approve the connection in the same
// request. The workaround is to approve the connection, then go back and
// adjust permissions as desired.
2019-05-07 03:22:08 +00:00
$p = Permissions :: connect_perms ( local_channel ());
$my_perms = Permissions :: serialise ( $p [ 'perms' ]);
if ( $my_perms ) {
2020-04-16 23:24:01 +00:00
set_abconfig ( $channel [ 'channel_id' ], $orig_record [ 'abook_xchan' ], 'system' , 'my_perms' , $my_perms );
2016-07-14 06:05:19 +00:00
}
2016-04-19 03:38:38 +00:00
}
2016-07-14 06:05:19 +00:00
2020-04-16 23:24:01 +00:00
$abook_pending = (( $new_friend ) ? 0 : $orig_record [ 'abook_pending' ]);
2018-12-17 09:59:17 +00:00
2016-07-14 06:05:19 +00:00
$r = q ( " UPDATE abook SET abook_profile = '%s', abook_closeness = %d, abook_pending = %d,
2019-09-12 03:41:16 +00:00
abook_incl = '%s' , abook_excl = '%s' , abook_alias = '%s'
2016-04-19 03:38:38 +00:00
where abook_id = % d AND abook_channel = % d " ,
dbesc ( $profile_id ),
intval ( $closeness ),
intval ( $abook_pending ),
dbesc ( $abook_incl ),
dbesc ( $abook_excl ),
2019-09-12 03:41:16 +00:00
dbesc ( $abook_alias ),
2016-04-19 03:38:38 +00:00
intval ( $contact_id ),
intval ( local_channel ())
);
2020-04-16 23:24:01 +00:00
if ( $r ) {
2016-04-19 03:38:38 +00:00
info ( t ( 'Connection updated.' ) . EOL );
2020-04-16 23:24:01 +00:00
}
else {
2016-04-19 03:38:38 +00:00
notice ( t ( 'Failed to update connection record.' ) . EOL );
2020-04-16 23:24:01 +00:00
}
if ( ! intval ( App :: $poi [ 'abook_self' ])) {
if ( $new_friend ) {
2020-06-15 07:29:56 +00:00
Run :: Summon ( [ 'Notifier' , 'permissions_accept' , $contact_id ] );
2017-09-19 20:25:34 +00:00
}
2020-06-15 07:29:56 +00:00
Run :: Summon ( [
2016-07-19 04:37:34 +00:00
'Notifier' ,
2018-06-28 01:43:39 +00:00
(( $new_friend ) ? 'permissions_create' : 'permissions_update' ),
2016-07-19 04:37:34 +00:00
$contact_id
]);
2016-04-19 03:38:38 +00:00
}
2020-04-16 23:24:01 +00:00
if ( $new_friend ) {
2016-04-19 03:38:38 +00:00
$default_group = $channel [ 'channel_default_group' ];
2020-04-16 23:24:01 +00:00
if ( $default_group ) {
2019-02-14 23:26:37 +00:00
$g = AccessList :: rec_byhash ( local_channel (), $default_group );
2020-04-16 23:24:01 +00:00
if ( $g ) {
2019-05-07 05:22:58 +00:00
AccessList :: member_add ( local_channel (), '' , App :: $poi [ 'abook_xchan' ], $g [ 'id' ]);
2020-04-16 23:24:01 +00:00
}
2016-04-19 03:38:38 +00:00
}
// 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
$pr = q ( " select * from profile where uid = %d and is_default = 1 and hide_friends = 0 " ,
intval ( $channel [ 'channel_id' ])
);
2020-04-16 23:24:01 +00:00
if (( $pr ) && ( ! intval ( $orig_record [ 'abook_hidden' ])) && ( intval ( get_pconfig ( $channel [ 'channel_id' ], 'system' , 'post_newfriend' )))) {
2019-04-02 00:00:00 +00:00
$xarr = [];
2016-04-19 03:38:38 +00:00
$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' ];
$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 );
2019-05-07 03:22:08 +00:00
$xarr [ 'body' ] = '[zrl=' . $channel [ 'xchan_url' ] . ']' . $channel [ 'xchan_name' ] . '[/zrl]' . ' ' . t ( 'is now connected to' ) . ' ' . '[zrl=' . App :: $poi [ 'xchan_url' ] . ']' . App :: $poi [ 'xchan_name' ] . '[/zrl]' ;
2016-04-19 03:38:38 +00:00
2019-05-07 03:22:08 +00:00
$xarr [ 'body' ] .= " \n \n \n " . '[zrl=' . App :: $poi [ 'xchan_url' ] . '][zmg=80x80]' . App :: $poi [ 'xchan_photo_m' ] . '[/zmg][/zrl]' ;
2016-04-19 03:38:38 +00:00
post_activity_item ( $xarr );
}
2019-09-12 03:41:16 +00:00
2016-04-19 03:38:38 +00:00
// pull in a bit of content if there is any to pull in
2020-06-15 07:29:56 +00:00
Run :: Summon ( [ 'Onepoll' , $contact_id ]);
2016-04-19 03:38:38 +00:00
}
// 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 )
);
2020-04-16 23:24:01 +00:00
if ( $r ) {
App :: $poi = array_shift ( $r );
2016-04-19 03:38:38 +00:00
}
2020-04-16 23:24:01 +00:00
if ( $new_friend ) {
$arr = [ 'channel_id' => local_channel (), 'abook' => App :: $poi ];
2016-04-19 03:38:38 +00:00
call_hooks ( 'accept_follow' , $arr );
}
$this -> connedit_clone ( $a );
2020-04-16 23:24:01 +00:00
if (( $_REQUEST [ 'pending' ]) && ( ! $_REQUEST [ 'done' ])) {
2016-04-19 03:38:38 +00:00
goaway ( z_root () . '/connections/ifpending' );
2020-04-16 23:24:01 +00:00
}
2016-04-19 03:38:38 +00:00
return ;
}
/* @ brief Clone connection
*
*
*/
function connedit_clone ( & $a ) {
2019-08-27 02:54:21 +00:00
if ( ! App :: $poi ) {
return ;
}
2016-04-19 03:38:38 +00:00
2019-08-27 02:54:21 +00:00
$channel = App :: get_channel ();
2016-04-19 03:38:38 +00:00
2019-08-27 02:54:21 +00:00
$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 ( App :: $poi [ 'abook_id' ])
);
2020-04-16 23:24:01 +00:00
if ( ! $r ) {
return ;
2019-08-27 02:54:21 +00:00
}
2020-04-16 23:24:01 +00:00
App :: $poi = array_shift ( $r );
2019-08-27 02:54:21 +00:00
$clone = App :: $poi ;
2016-04-19 03:38:38 +00:00
2019-08-27 02:54:21 +00:00
unset ( $clone [ 'abook_id' ]);
unset ( $clone [ 'abook_account' ]);
unset ( $clone [ 'abook_channel' ]);
2016-04-19 03:38:38 +00:00
2019-08-27 02:54:21 +00:00
$abconfig = load_abconfig ( $channel [ 'channel_id' ], $clone [ 'abook_xchan' ]);
if ( $abconfig ) {
$clone [ 'abconfig' ] = $abconfig ;
}
Libsync :: build_sync_packet ( $channel [ 'channel_id' ], [ 'abook' => [ $clone ] ] );
2016-04-19 03:38:38 +00:00
}
2020-04-16 23:24:01 +00:00
/**
* @ brief Generate content of connection edit page
2016-04-19 03:38:38 +00:00
*/
2016-06-15 00:04:29 +00:00
function get () {
2016-04-19 03:38:38 +00:00
$sort_type = 0 ;
2020-04-16 23:24:01 +00:00
$o = EMPTY_STR ;
2016-04-19 03:38:38 +00:00
2020-04-16 23:24:01 +00:00
if ( ! local_channel ()) {
2016-04-19 03:38:38 +00:00
notice ( t ( 'Permission denied.' ) . EOL );
return login ();
}
2016-11-30 02:41:34 +00:00
$section = (( array_key_exists ( 'section' , $_REQUEST )) ? $_REQUEST [ 'section' ] : '' );
2019-05-07 05:22:58 +00:00
$channel = App :: get_channel ();
2016-04-19 03:38:38 +00:00
2018-07-23 00:50:01 +00:00
$yes_no = [ t ( 'No' ), t ( 'Yes' ) ];
2016-04-19 03:38:38 +00:00
2019-05-07 03:22:08 +00:00
$connect_perms = Permissions :: connect_perms ( local_channel ());
2017-04-03 03:35:45 +00:00
$o .= " <script>function connectDefaultShare() {
\ $ ( '.abook-edit-me' ) . each ( function () {
if ( ! $ ( this ) . is ( ':disabled' ))
$ ( this ) . prop ( 'checked' , false );
}); \n\n " ;
foreach ( $connect_perms [ 'perms' ] as $p => $v ) {
if ( $v ) {
$o .= " \$ ('#me_id_perms_ " . $p . " ').prop('checked', true); \n " ;
2016-04-19 03:38:38 +00:00
}
}
2017-04-03 03:35:45 +00:00
$o .= " } \n </script> \n " ;
2016-04-19 03:38:38 +00:00
2020-04-16 23:24:01 +00:00
if ( argc () == 3 ) {
2016-04-19 03:38:38 +00:00
$contact_id = intval ( argv ( 1 ));
2020-04-16 23:24:01 +00:00
if ( ! $contact_id ) {
2016-04-19 03:38:38 +00:00
return ;
2020-04-16 23:24:01 +00:00
}
2016-04-19 03:38:38 +00:00
$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 abook_self = 0 LIMIT 1 " ,
intval ( $contact_id ),
intval ( local_channel ())
);
2021-03-12 22:26:56 +00:00
if ( ! $orig_record ) {
2016-04-19 03:38:38 +00:00
notice ( t ( 'Could not access address book record.' ) . EOL );
goaway ( z_root () . '/connections' );
}
2020-04-16 23:24:01 +00:00
$orig_record = array_shift ( $orig_record );
if ( $cmd === 'update' ) {
2016-04-19 03:38:38 +00:00
// pull feed and consume it, which should subscribe to the hub.
2020-06-15 07:29:56 +00:00
Run :: Summon ( [ 'Poller' , $contact_id ]);
2016-04-19 03:38:38 +00:00
goaway ( z_root () . '/connedit/' . $contact_id );
}
2017-02-28 05:14:09 +00:00
2021-03-12 22:26:56 +00:00
if ( $cmd === 'fetchvc' ) {
2020-04-16 23:24:01 +00:00
$url = str_replace ( '/channel/' , '/profile/' , $orig_record [ 'xchan_url' ]) . '/vcard' ;
2017-02-28 07:37:42 +00:00
$recurse = 0 ;
2017-02-28 07:48:54 +00:00
$x = z_fetch_url ( zid ( $url ), false , $recurse ,[ 'session' => true ]);
2020-04-16 23:24:01 +00:00
if ( $x [ 'success' ]) {
2019-05-07 05:22:58 +00:00
$h = new HTTPHeaders ( $x [ 'header' ]);
2021-03-12 22:26:56 +00:00
$fields = $h -> fetcharr ();
if ( $fields && array_key_exists ( 'content-type' , $fields )) {
$type = explode ( ';' , trim ( $fields [ 'content-type' ]));
if ( $type && $type [ 0 ] === 'text/vcard' && $x [ 'body' ]) {
$vc = Reader :: read ( $x [ 'body' ]);
$vcard = $vc -> serialize ();
if ( $vcard ) {
set_abconfig ( local_channel (), $orig_record [ 'abook_xchan' ], 'system' , 'vcard' , $vcard );
$this -> connedit_clone ( $a );
2017-02-28 05:14:09 +00:00
}
}
}
}
goaway ( z_root () . '/connedit/' . $contact_id );
}
2020-04-16 23:24:01 +00:00
if ( $cmd === 'resetphoto' ) {
2016-10-27 00:41:32 +00:00
q ( " update xchan set xchan_photo_date = '2001-01-01 00:00:00' where xchan_hash = '%s' " ,
2020-04-16 23:24:01 +00:00
dbesc ( $orig_record [ 'xchan_hash' ])
2016-06-15 00:04:29 +00:00
);
$cmd = 'refresh' ;
}
2020-04-16 23:24:01 +00:00
if ( $cmd === 'refresh' ) {
2021-10-28 08:55:09 +00:00
if ( in_array ( $orig_record [ 'xchan_network' ],[ 'nomad' , 'zot6' ])) {
2020-04-16 23:24:01 +00:00
if ( ! Libzot :: refresh ( $orig_record , App :: get_channel ())) {
2016-04-19 03:38:38 +00:00
notice ( t ( 'Refresh failed - channel is currently unavailable.' ) );
2020-04-16 23:24:01 +00:00
}
2016-04-19 03:38:38 +00:00
}
else {
2021-03-12 20:37:11 +00:00
if ( $orig_record [ 'xchan_network' ] === 'activitypub' ) {
ActivityPub :: discover ( $orig_record [ 'xchan_hash' ], true );
}
2020-04-16 23:24:01 +00:00
// if they are on a different network we'll force a refresh of the connection basic info
2020-06-15 07:29:56 +00:00
Run :: Summon ( [ 'Notifier' , 'permissions_update' , $contact_id ]);
2016-04-19 03:38:38 +00:00
}
goaway ( z_root () . '/connedit/' . $contact_id );
}
2019-07-31 00:56:35 +00:00
2020-04-16 23:24:01 +00:00
switch ( $cmd ) {
case 'block' :
2020-05-17 11:41:03 +00:00
if ( intval ( $orig_record [ 'abook_blocked' ])) {
2020-05-17 11:09:12 +00:00
LibBlock :: remove ( local_channel (), $orig_record [ 'abook_xchan' ]);
$sync = [
'block_channel_id' => local_channel (),
'block_entity' => $orig_record [ 'abook_xchan' ],
'block_type' => BLOCKTYPE_CHANNEL ,
'deleted' => true ,
];
}
else {
LibBlock :: store ( [
'block_channel_id' => local_channel (),
'block_entity' => $orig_record [ 'abook_xchan' ],
'block_type' => BLOCKTYPE_CHANNEL ,
'block_comment' => t ( 'Added by Connedit' )
]);
$z = q ( " insert into xign ( uid, xchan ) values ( %d , '%s' ) " ,
intval ( local_channel ()),
dbesc ( $orig_record [ 'abook_xchan' ])
);
$sync = LibBlock :: fetch_by_entity ( local_channel (), $orig_record [ 'abook_xchan' ]);
}
$ignored = [ 'uid' => local_channel (), 'xchan' => $orig_record [ 'abook_xchan' ] ];
Libsync :: build_sync_packet ( 0 , [ 'xign' => [ $ignored ], 'block' => [ $sync ]] );
2020-04-16 23:24:01 +00:00
$flag_result = abook_toggle_flag ( $orig_record , ABOOK_FLAG_BLOCKED );
break ;
case 'ignore' :
$flag_result = abook_toggle_flag ( $orig_record , ABOOK_FLAG_IGNORED );
break ;
case 'censor' :
$flag_result = abook_toggle_flag ( $orig_record , ABOOK_FLAG_CENSORED );
break ;
case 'archive' :
$flag_result = abook_toggle_flag ( $orig_record , ABOOK_FLAG_ARCHIVED );
break ;
case 'hide' :
$flag_result = abook_toggle_flag ( $orig_record , ABOOK_FLAG_HIDDEN );
break ;
case 'approve' :
if ( intval ( $orig_record [ 'abook_pending' ])) {
$flag_result = abook_toggle_flag ( $orig_record , ABOOK_FLAG_PENDING );
}
break ;
default :
break ;
2019-07-31 00:56:35 +00:00
}
2020-04-16 23:24:01 +00:00
if ( isset ( $flag_result )) {
if ( $flag_result ) {
2016-04-19 03:38:38 +00:00
$this -> connedit_clone ( $a );
}
2020-04-16 23:24:01 +00:00
else {
2016-04-19 03:38:38 +00:00
notice ( t ( 'Unable to set address book parameters.' ) . EOL );
}
goaway ( z_root () . '/connedit/' . $contact_id );
2020-04-16 23:24:01 +00:00
}
2016-04-19 03:38:38 +00:00
2020-04-16 23:24:01 +00:00
if ( $cmd === 'drop' ) {
if ( $orig_record [ 'xchan_network' ] === 'activitypub' ) {
ActivityPub :: contact_remove ( local_channel (), $orig_record );
2018-08-23 06:04:37 +00:00
}
2021-04-12 02:13:36 +00:00
contact_remove ( local_channel (), $orig_record [ 'abook_id' ], true );
2019-05-07 03:22:08 +00:00
// The purge notification is sent to the xchan_hash as the abook record will have just been removed
2020-06-15 07:29:56 +00:00
Run :: Summon ( [ 'Notifier' , 'purge' , $orig_record [ 'xchan_hash' ] ] );
2019-05-07 03:22:08 +00:00
2021-04-12 02:20:28 +00:00
Libsync :: build_sync_packet ( 0 , [ 'abook' => [ [ 'abook_xchan' => $orig_record [ 'abook_xchan' ], 'entry_deleted' => true ] ] ] );
2016-04-19 03:38:38 +00:00
2020-08-07 03:19:03 +00:00
info ( t ( 'Connection has been removed.' ) . EOL );
2021-03-12 22:26:56 +00:00
if ( isset ( $_SESSION [ 'return_url' ]) && $_SESSION [ 'return_url' ]) {
2016-04-19 03:38:38 +00:00
goaway ( z_root () . '/' . $_SESSION [ 'return_url' ]);
2020-04-16 23:24:01 +00:00
}
2016-04-19 03:38:38 +00:00
goaway ( z_root () . '/contacts' );
}
}
2020-04-16 23:24:01 +00:00
if ( App :: $poi ) {
2016-04-19 03:38:38 +00:00
2016-11-24 23:08:31 +00:00
$abook_prev = 0 ;
$abook_next = 0 ;
2019-05-07 03:22:08 +00:00
$contact_id = App :: $poi [ 'abook_id' ];
$contact = App :: $poi ;
2016-11-24 23:08:31 +00:00
2017-12-30 23:35:18 +00:00
$cn = q ( " SELECT abook_id, xchan_name from abook left join xchan on abook_xchan = xchan_hash where abook_channel = %d and abook_self = 0 and xchan_deleted = 0 order by xchan_name " ,
2016-11-24 23:08:31 +00:00
intval ( local_channel ())
);
2020-04-16 23:24:01 +00:00
if ( $cn ) {
// store previous/next ids for navigation
2016-11-24 23:08:31 +00:00
$pntotal = count ( $cn );
2020-04-16 23:24:01 +00:00
for ( $x = 0 ; $x < $pntotal ; $x ++ ) {
if ( $cn [ $x ][ 'abook_id' ] == $contact_id ) {
if ( $x === 0 ) {
2016-11-24 23:08:31 +00:00
$abook_prev = 0 ;
2020-04-16 23:24:01 +00:00
}
else {
2016-11-24 23:08:31 +00:00
$abook_prev = $cn [ $x - 1 ][ 'abook_id' ];
2020-04-16 23:24:01 +00:00
}
if ( $x === $pntotal ) {
2016-11-24 23:08:31 +00:00
$abook_next = 0 ;
2020-04-16 23:24:01 +00:00
}
else {
2016-11-24 23:08:31 +00:00
$abook_next = $cn [ $x + 1 ][ 'abook_id' ];
2020-04-16 23:24:01 +00:00
}
2016-11-24 23:08:31 +00:00
}
}
}
2016-04-25 08:00:50 +00:00
$tools = array (
2016-04-19 03:38:38 +00:00
'view' => array (
'label' => t ( 'View Profile' ),
'url' => chanlink_cid ( $contact [ 'abook_id' ]),
'sel' => '' ,
'title' => sprintf ( t ( 'View %s\'s profile' ), $contact [ 'xchan_name' ]),
),
'refresh' => array (
'label' => t ( 'Refresh Permissions' ),
'url' => z_root () . '/connedit/' . $contact [ 'abook_id' ] . '/refresh' ,
'sel' => '' ,
'title' => t ( 'Fetch updated permissions' ),
),
2017-02-28 05:14:09 +00:00
'rephoto' => array (
'label' => t ( 'Refresh Photo' ),
'url' => z_root () . '/connedit/' . $contact [ 'abook_id' ] . '/resetphoto' ,
'sel' => '' ,
'title' => t ( 'Fetch updated photo' ),
),
2016-04-19 03:38:38 +00:00
'recent' => array (
'label' => t ( 'Recent Activity' ),
2020-02-13 05:36:21 +00:00
'url' => z_root () . '/stream/?f=&cid=' . $contact [ 'abook_id' ],
2016-04-19 03:38:38 +00:00
'sel' => '' ,
'title' => t ( 'View recent posts and comments' ),
),
'block' => array (
'label' => ( intval ( $contact [ 'abook_blocked' ]) ? t ( 'Unblock' ) : t ( 'Block' )),
'url' => z_root () . '/connedit/' . $contact [ 'abook_id' ] . '/block' ,
'sel' => ( intval ( $contact [ 'abook_blocked' ]) ? 'active' : '' ),
'title' => t ( 'Block (or Unblock) all communications with this connection' ),
2020-08-07 03:19:03 +00:00
'info' => ( intval ( $contact [ 'abook_blocked' ]) ? t ( 'This connection is blocked' ) : '' ),
2016-04-19 03:38:38 +00:00
),
'ignore' => array (
'label' => ( intval ( $contact [ 'abook_ignored' ]) ? t ( 'Unignore' ) : t ( 'Ignore' )),
'url' => z_root () . '/connedit/' . $contact [ 'abook_id' ] . '/ignore' ,
'sel' => ( intval ( $contact [ 'abook_ignored' ]) ? 'active' : '' ),
'title' => t ( 'Ignore (or Unignore) all inbound communications from this connection' ),
2020-08-07 03:19:03 +00:00
'info' => ( intval ( $contact [ 'abook_ignored' ]) ? t ( 'This connection is ignored' ) : '' ),
2016-04-19 03:38:38 +00:00
),
2019-07-31 00:56:35 +00:00
2019-08-01 04:46:19 +00:00
'censor' => array (
'label' => ( intval ( $contact [ 'abook_censor' ]) ? t ( 'Uncensor' ) : t ( 'Censor' )),
'url' => z_root () . '/connedit/' . $contact [ 'abook_id' ] . '/censor' ,
'sel' => ( intval ( $contact [ 'abook_censor' ]) ? 'active' : '' ),
'title' => t ( 'Censor (or Uncensor) images from this connection' ),
2020-08-07 03:19:03 +00:00
'info' => ( intval ( $contact [ 'abook_censor' ]) ? t ( 'This connection is censored' ) : '' ),
2019-08-01 04:46:19 +00:00
),
2019-07-31 00:56:35 +00:00
2016-04-19 03:38:38 +00:00
'archive' => array (
'label' => ( intval ( $contact [ 'abook_archived' ]) ? t ( 'Unarchive' ) : t ( 'Archive' )),
'url' => z_root () . '/connedit/' . $contact [ 'abook_id' ] . '/archive' ,
'sel' => ( intval ( $contact [ 'abook_archived' ]) ? 'active' : '' ),
'title' => t ( 'Archive (or Unarchive) this connection - mark channel dead but keep content' ),
2020-08-07 03:19:03 +00:00
'info' => ( intval ( $contact [ 'abook_archived' ]) ? t ( 'This connection is archived' ) : '' ),
2016-04-19 03:38:38 +00:00
),
'hide' => array (
'label' => ( intval ( $contact [ 'abook_hidden' ]) ? t ( 'Unhide' ) : t ( 'Hide' )),
'url' => z_root () . '/connedit/' . $contact [ 'abook_id' ] . '/hide' ,
'sel' => ( intval ( $contact [ 'abook_hidden' ]) ? 'active' : '' ),
'title' => t ( 'Hide or Unhide this connection from your other connections' ),
2020-08-07 03:19:03 +00:00
'info' => ( intval ( $contact [ 'abook_hidden' ]) ? t ( 'This connection is hidden' ) : '' ),
2016-04-19 03:38:38 +00:00
),
'delete' => array (
'label' => t ( 'Delete' ),
'url' => z_root () . '/connedit/' . $contact [ 'abook_id' ] . '/drop' ,
'sel' => '' ,
'title' => t ( 'Delete this connection' ),
),
);
2017-01-09 11:03:32 +00:00
2017-02-28 05:14:09 +00:00
2021-10-28 08:55:09 +00:00
if ( in_array ( $contact [ 'xchan_network' ],[ 'nomad' , 'zot6' ])) {
2017-02-28 05:14:09 +00:00
$tools [ 'fetchvc' ] = [
'label' => t ( 'Fetch Vcard' ),
'url' => z_root () . '/connedit/' . $contact [ 'abook_id' ] . '/fetchvc' ,
'sel' => '' ,
'title' => t ( 'Fetch electronic calling card for this connection' )
];
}
2017-01-09 11:03:32 +00:00
$sections = [];
$sections [ 'perms' ] = [
'label' => t ( 'Permissions' ),
'url' => z_root () . '/connedit/' . $contact [ 'abook_id' ] . '/?f=§ion=perms' ,
'sel' => '' ,
'title' => t ( 'Open Individual Permissions section by default' ),
];
2016-04-19 03:38:38 +00:00
$self = false ;
2016-11-24 23:08:31 +00:00
if ( intval ( $contact [ 'abook_self' ])) {
2016-04-19 03:38:38 +00:00
$self = true ;
2016-11-24 23:08:31 +00:00
$abook_prev = $abook_next = 0 ;
}
2016-04-19 03:38:38 +00:00
2016-12-21 00:45:12 +00:00
$vc = get_abconfig ( local_channel (), $contact [ 'abook_xchan' ], 'system' , 'vcard' );
2019-05-07 05:22:58 +00:00
$vctmp = (( $vc ) ? Reader :: read ( $vc ) : null );
2016-12-21 02:43:20 +00:00
$vcard = (( $vctmp ) ? get_vcard_array ( $vctmp , $contact [ 'abook_id' ]) : [] );
2016-12-21 03:31:50 +00:00
if ( ! $vcard )
$vcard [ 'fn' ] = $contact [ 'xchan_name' ];
2016-12-21 00:45:12 +00:00
2016-04-19 03:38:38 +00:00
$tpl = get_markup_template ( " abook_edit.tpl " );
2019-07-30 02:33:36 +00:00
if ( Apps :: system_app_installed ( local_channel (), 'Friend Zoom' )) {
2017-01-09 11:03:32 +00:00
$sections [ 'affinity' ] = [
2019-07-30 02:33:36 +00:00
'label' => t ( 'Friend Zoom' ),
2017-01-09 11:03:32 +00:00
'url' => z_root () . '/connedit/' . $contact [ 'abook_id' ] . '/?f=§ion=affinity' ,
'sel' => '' ,
2019-07-30 02:33:36 +00:00
'title' => t ( 'Open Friend Zoom section by default' ),
2017-01-09 11:03:32 +00:00
];
2016-04-19 03:38:38 +00:00
2016-12-21 04:37:06 +00:00
$labels = [
2018-12-30 22:36:23 +00:00
0 => t ( 'Me' ),
20 => t ( 'Family' ),
40 => t ( 'Friends' ),
60 => t ( 'Peers' ),
80 => t ( 'Connections' ),
99 => t ( 'All' )
2016-12-21 04:37:06 +00:00
];
2016-04-19 03:38:38 +00:00
call_hooks ( 'affinity_labels' , $labels );
$slider_tpl = get_markup_template ( 'contact_slider.tpl' );
2018-12-17 09:59:17 +00:00
$slideval = intval ( $contact [ 'abook_closeness' ]);
2016-04-19 03:38:38 +00:00
$slide = replace_macros ( $slider_tpl , array (
'$min' => 1 ,
2018-12-17 09:59:17 +00:00
'$val' => $slideval ,
2018-12-30 22:36:23 +00:00
'$labels' => $labels ,
2016-04-19 03:38:38 +00:00
));
}
2017-01-09 11:03:32 +00:00
2019-01-23 03:11:53 +00:00
if ( Apps :: system_app_installed ( local_channel (), 'Content Filter' )) {
2017-01-09 11:03:32 +00:00
$sections [ 'filter' ] = [
'label' => t ( 'Filter' ),
'url' => z_root () . '/connedit/' . $contact [ 'abook_id' ] . '/?f=§ion=filter' ,
'sel' => '' ,
'title' => t ( 'Open Custom Filter section by default' ),
];
}
2016-04-19 03:38:38 +00:00
$rating_val = 0 ;
$rating_text = '' ;
$xl = q ( " select * from xlink where xlink_xchan = '%s' and xlink_link = '%s' and xlink_static = 1 " ,
dbesc ( $channel [ 'channel_hash' ]),
dbesc ( $contact [ 'xchan_hash' ])
);
if ( $xl ) {
$rating_val = intval ( $xl [ 0 ][ 'xlink_rating' ]);
$rating_text = $xl [ 0 ][ 'xlink_rating_text' ];
}
2016-08-26 00:43:07 +00:00
$rating_enabled = get_config ( 'system' , 'rating_enabled' );
2016-04-19 03:38:38 +00:00
2016-08-26 00:43:07 +00:00
if ( $rating_enabled ) {
2016-04-19 03:38:38 +00:00
$rating = replace_macros ( get_markup_template ( 'rating_slider.tpl' ), array (
'$min' => - 10 ,
'$val' => $rating_val
));
}
else {
$rating = false ;
}
2021-03-15 05:10:44 +00:00
$perms = [];
2019-05-07 03:22:08 +00:00
$channel = App :: get_channel ();
2016-04-19 03:38:38 +00:00
2019-05-07 03:22:08 +00:00
$global_perms = Permissions :: Perms ();
2016-07-05 00:55:13 +00:00
2018-07-31 00:41:37 +00:00
$existing = get_all_perms ( local_channel (), $contact [ 'abook_xchan' ], false );
2016-04-19 03:38:38 +00:00
2021-04-08 06:22:10 +00:00
$unapproved = array ( 'pending' , t ( 'Approve this connection' ), '' , t ( 'Accept connection to allow communication' ), array ( t ( 'No' ), t ( 'Yes' )));
2016-04-19 03:38:38 +00:00
$multiprofs = (( feature_enabled ( local_channel (), 'multi_profiles' )) ? true : false );
if ( $slide && ! $multiprofs )
2019-07-30 02:33:36 +00:00
$affinity = t ( 'Set Friend Zoom' );
2016-04-19 03:38:38 +00:00
if ( ! $slide && $multiprofs )
$affinity = t ( 'Set Profile' );
if ( $slide && $multiprofs )
2019-07-30 02:33:36 +00:00
$affinity = t ( 'Set Friend Zoom & Profile' );
2016-04-19 03:38:38 +00:00
2018-06-08 02:44:09 +00:00
$theirs = get_abconfig ( local_channel (), $contact [ 'abook_xchan' ], 'system' , 'their_perms' , EMPTY_STR );
2019-05-07 03:22:08 +00:00
$their_perms = Permissions :: FilledPerms ( explode ( ',' , $theirs ));
2018-06-08 02:44:09 +00:00
foreach ( $global_perms as $k => $v ) {
if ( ! array_key_exists ( $k , $their_perms ))
$their_perms [ $k ] = 1 ;
2016-07-10 04:08:02 +00:00
}
2018-06-08 02:44:09 +00:00
$my_perms = explode ( ',' , get_abconfig ( local_channel (), $contact [ 'abook_xchan' ], 'system' , 'my_perms' , EMPTY_STR ));
2016-04-19 03:38:38 +00:00
foreach ( $global_perms as $k => $v ) {
2018-06-08 02:44:09 +00:00
$thisperm = (( in_array ( $k , $my_perms )) ? 1 : 0 );
2016-07-05 00:55:13 +00:00
2019-05-07 05:22:58 +00:00
$checkinherited = PermissionLimits :: Get ( local_channel (), $k );
2016-04-19 03:38:38 +00:00
// For auto permissions (when $self is true) we don't want to look at existing
// permissions because they are enabled for the channel owner
if (( ! $self ) && ( $existing [ $k ]))
$thisperm = " 1 " ;
2016-07-10 04:08:02 +00:00
$perms [] = array ( 'perms_' . $k , $v , (( array_key_exists ( $k , $their_perms )) ? intval ( $their_perms [ $k ]) : '' ), $thisperm , 1 , (( $checkinherited & PERMS_SPECIFIC ) ? '' : '1' ), '' , $checkinherited );
2016-04-19 03:38:38 +00:00
}
2019-05-07 05:22:58 +00:00
$pcat = new Permcat ( local_channel ());
2017-02-08 01:17:38 +00:00
$pcatlist = $pcat -> listing ();
$permcats = [];
if ( $pcatlist ) {
foreach ( $pcatlist as $pc ) {
$permcats [ $pc [ 'name' ]] = $pc [ 'localname' ];
}
}
2018-02-01 23:09:51 +00:00
$locstr = locations_by_netid ( $contact [ 'xchan_hash' ]);
if ( ! $locstr )
2018-03-29 09:26:25 +00:00
$locstr = unpunify ( $contact [ 'xchan_url' ]);
2018-02-01 23:09:51 +00:00
2017-06-09 23:26:30 +00:00
$clone_warn = '' ;
2021-10-28 08:55:09 +00:00
$clonable = ( in_array ( $contact [ 'xchan_network' ],[ 'nomad' , 'zot6' , 'zot' , 'rss' ]) ? true : false );
2017-06-09 23:26:30 +00:00
if ( ! $clonable ) {
$clone_warn = '<strong>' ;
$clone_warn .= (( intval ( $contact [ 'abook_not_here' ]))
? t ( 'This connection is unreachable from this location.' )
: t ( 'This connection may be unreachable from other channel locations.' )
);
$clone_warn .= '</strong><br>' . t ( 'Location independence is not supported by their network.' );
}
if ( intval ( $contact [ 'abook_not_here' ]) && $unclonable )
$not_here = t ( 'This connection is unreachable from this location. Location independence is not supported by their network.' );
2016-04-19 03:38:38 +00:00
2016-12-21 04:37:06 +00:00
$o .= replace_macros ( $tpl , [
2019-09-12 03:41:16 +00:00
'$header' => (( $self ) ? t ( 'Connection Default Permissions' ) : sprintf ( t ( 'Connection: %s' ), $contact [ 'xchan_name' ]) . (( $contact [ 'abook_alias' ]) ? ' <' . $contact [ 'abook_alias' ] . '>' : '' )),
2016-04-19 03:38:38 +00:00
'$autoperms' => array ( 'autoperms' , t ( 'Apply these permissions automatically' ), (( get_pconfig ( local_channel (), 'system' , 'autoperms' )) ? 1 : 0 ), t ( 'Connection requests will be approved without your interaction' ), $yes_no ),
2018-01-15 10:34:42 +00:00
'$permcat' => [ 'permcat' , t ( 'Permission role' ), '' , '<span class="loading invisible">' . t ( 'Loading' ) . '<span class="jumping-dots"><span class="dot-1">.</span><span class="dot-2">.</span><span class="dot-3">.</span></span></span>' , $permcats ],
2017-02-09 01:21:32 +00:00
'$permcat_new' => t ( 'Add permission role' ),
'$permcat_enable' => feature_enabled ( local_channel (), 'permcats' ),
2018-03-29 09:26:25 +00:00
'$addr' => unpunify ( $contact [ 'xchan_addr' ]),
'$primeurl' => unpunify ( $contact [ 'xchan_url' ]),
2021-06-24 07:16:17 +00:00
'$block_announce' => [ 'block_announce' , t ( 'Ignore shares and repeats this connection posts' ), get_abconfig ( local_channel (), $contact [ 'xchan_hash' ], 'system' , 'block_announce' , false ), t ( 'Note: This is not recommended for Groups.' ), [ t ( 'No' ), t ( 'Yes' ) ] ],
2016-11-30 02:41:34 +00:00
'$section' => $section ,
2017-01-09 11:03:32 +00:00
'$sections' => $sections ,
2016-12-21 00:45:12 +00:00
'$vcard' => $vcard ,
2016-04-19 03:38:38 +00:00
'$addr_text' => t ( 'This connection\'s primary address is' ),
'$loc_text' => t ( 'Available locations:' ),
'$locstr' => $locstr ,
2017-06-09 23:26:30 +00:00
'$unclonable' => $clone_warn ,
2016-04-19 03:38:38 +00:00
'$notself' => (( $self ) ? '' : '1' ),
'$self' => (( $self ) ? '1' : '' ),
'$autolbl' => t ( 'The permissions indicated on this page will be applied to all new connections.' ),
2016-04-25 08:00:50 +00:00
'$tools_label' => t ( 'Connection Tools' ),
'$tools' => (( $self ) ? '' : $tools ),
2016-04-19 03:38:38 +00:00
'$lbl_slider' => t ( 'Slide to adjust your degree of friendship' ),
'$lbl_rating' => t ( 'Rating' ),
'$lbl_rating_label' => t ( 'Slide to adjust your rating' ),
'$lbl_rating_txt' => t ( 'Optionally explain your rating' ),
2019-01-23 03:11:53 +00:00
'$connfilter' => Apps :: system_app_installed ( local_channel (), 'Content Filter' ),
2016-04-19 03:38:38 +00:00
'$connfilter_label' => t ( 'Custom Filter' ),
2019-03-20 00:23:33 +00:00
'$incl' => array ( 'abook_incl' , t ( 'Only import posts with this text' ), $contact [ 'abook_incl' ], t ( 'words one per line or #tags, $categories, /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, $categories, /patterns/, or lang=xx, leave blank to import all posts' )),
2019-09-12 03:41:16 +00:00
'$alias' => array ( 'abook_alias' , t ( 'Nickname' ), $contact [ 'abook_alias' ], t ( 'optional - allows you to search by a name that you have chosen' )),
2016-04-19 03:38:38 +00:00
'$rating_text' => array ( 'rating_text' , t ( 'Optionally explain your rating' ), $rating_text , '' ),
'$rating_info' => t ( 'This information is public!' ),
'$rating' => $rating ,
'$rating_val' => $rating_val ,
'$slide' => $slide ,
'$affinity' => $affinity ,
'$pending_label' => t ( 'Connection Pending Approval' ),
'$is_pending' => ( intval ( $contact [ 'abook_pending' ]) ? 1 : '' ),
'$unapproved' => $unapproved ,
'$inherited' => t ( 'inherited' ),
'$submit' => t ( 'Submit' ),
'$lbl_vis2' => sprintf ( t ( 'Please choose the profile you would like to display to %s when viewing your profile securely.' ), $contact [ 'xchan_name' ]),
2018-12-17 09:59:17 +00:00
'$close' => (( $contact [ 'abook_closeness' ]) ? $contact [ 'abook_closeness' ] : 80 ),
2016-04-19 03:38:38 +00:00
'$them' => t ( 'Their Settings' ),
'$me' => t ( 'My Settings' ),
'$perms' => $perms ,
'$permlbl' => t ( 'Individual Permissions' ),
'$permnote' => t ( 'Some permissions may be inherited from your channel\'s <a href="settings"><strong>privacy settings</strong></a>, which have higher priority than individual settings. You can <strong>not</strong> change those settings here.' ),
'$permnote_self' => t ( 'Some permissions may be inherited from your channel\'s <a href="settings"><strong>privacy settings</strong></a>, which have higher priority than individual settings. You can change those settings here but they wont have any impact unless the inherited setting changes.' ),
'$lastupdtext' => t ( 'Last update:' ),
'$last_update' => relative_date ( $contact [ 'abook_connected' ]),
'$profile_select' => contact_profile_assign ( $contact [ 'abook_profile' ]),
'$multiprofs' => $multiprofs ,
'$contact_id' => $contact [ 'abook_id' ],
'$name' => $contact [ 'xchan_name' ],
2016-11-24 23:08:31 +00:00
'$abook_prev' => $abook_prev ,
2016-12-21 00:45:12 +00:00
'$abook_next' => $abook_next ,
'$vcard_label' => t ( 'Details' ),
2016-12-21 04:37:06 +00:00
'$displayname' => $displayname ,
'$name_label' => t ( 'Name' ),
'$org_label' => t ( 'Organisation' ),
'$title_label' => t ( 'Title' ),
'$tel_label' => t ( 'Phone' ),
'$email_label' => t ( 'Email' ),
'$impp_label' => t ( 'Instant messenger' ),
'$url_label' => t ( 'Website' ),
'$adr_label' => t ( 'Address' ),
'$note_label' => t ( 'Note' ),
'$mobile' => t ( 'Mobile' ),
'$home' => t ( 'Home' ),
'$work' => t ( 'Work' ),
'$other' => t ( 'Other' ),
'$add_card' => t ( 'Add Contact' ),
'$add_field' => t ( 'Add Field' ),
'$create' => t ( 'Create' ),
'$update' => t ( 'Update' ),
'$delete' => t ( 'Delete' ),
'$cancel' => t ( 'Cancel' ),
'$po_box' => t ( 'P.O. Box' ),
'$extra' => t ( 'Additional' ),
'$street' => t ( 'Street' ),
'$locality' => t ( 'Locality' ),
'$region' => t ( 'Region' ),
'$zip_code' => t ( 'ZIP Code' ),
'$country' => t ( 'Country' )
]);
2016-04-19 03:38:38 +00:00
$arr = array ( 'contact' => $contact , 'output' => $o );
call_hooks ( 'contact_edit' , $arr );
return $arr [ 'output' ];
2016-10-30 19:34:00 +00:00
}
2016-04-19 03:38:38 +00:00
}
}