aboutsummaryrefslogtreecommitdiffstats
path: root/Zotlabs/Module/Connedit.php
diff options
context:
space:
mode:
Diffstat (limited to 'Zotlabs/Module/Connedit.php')
-rw-r--r--Zotlabs/Module/Connedit.php98
1 files changed, 50 insertions, 48 deletions
diff --git a/Zotlabs/Module/Connedit.php b/Zotlabs/Module/Connedit.php
index c0df57390..0fc807d42 100644
--- a/Zotlabs/Module/Connedit.php
+++ b/Zotlabs/Module/Connedit.php
@@ -7,9 +7,16 @@ namespace Zotlabs\Module;
*
*/
+use App;
use Zotlabs\Lib\Apps;
use Zotlabs\Lib\Libzot;
use Zotlabs\Lib\Libsync;
+use Zotlabs\Daemon\Master;
+use Zotlabs\Web\Controller;
+use Zotlabs\Access\Permissions;
+use Zotlabs\Access\PermissionLimits;
+use Zotlabs\Web\HTTPHeaders;
+use Zotlabs\Lib\Permcat;
require_once('include/socgraph.php');
require_once('include/selectors.php');
@@ -17,7 +24,7 @@ require_once('include/group.php');
require_once('include/photos.php');
-class Connedit extends \Zotlabs\Web\Controller {
+class Connedit extends Controller {
/* @brief Initialize the connection-editor
*
@@ -37,12 +44,12 @@ class Connedit extends \Zotlabs\Web\Controller {
intval(argv(1))
);
if($r) {
- \App::$poi = array_shift($r);
+ App::$poi = array_shift($r);
}
}
- $channel = \App::get_channel();
+ $channel = App::get_channel();
if($channel)
head_set_icon($channel['xchan_photo_s']);
@@ -62,7 +69,7 @@ class Connedit extends \Zotlabs\Web\Controller {
if(! $contact_id)
return;
- $channel = \App::get_channel();
+ $channel = App::get_channel();
// TODO if configured for hassle-free permissions, we'll post the form with ajax as soon as the
// connection enable is toggled to a special autopost url and set permissions immediately, leaving
@@ -141,7 +148,7 @@ class Connedit extends \Zotlabs\Web\Controller {
$rating_text = trim(escape_tags($_REQUEST['rating_text']));
- $all_perms = \Zotlabs\Access\Permissions::Perms();
+ $all_perms = Permissions::Perms();
if($all_perms) {
foreach($all_perms as $perm => $desc) {
@@ -213,7 +220,7 @@ class Connedit extends \Zotlabs\Web\Controller {
$record = $z[0]['xlink_id'];
}
if($record) {
- \Zotlabs\Daemon\Master::Summon(array('Ratenotif','rating',$record));
+ Master::Summon(array('Ratenotif','rating',$record));
}
}
@@ -228,7 +235,7 @@ class Connedit extends \Zotlabs\Web\Controller {
// request. The workaround is to approve the connection, then go back and
// adjust permissions as desired.
- $p = \Zotlabs\Access\Permissions::connect_perms(local_channel());
+ $p = Permissions::connect_perms(local_channel());
$my_perms = $p['perms'];
if($my_perms) {
foreach($my_perms as $k => $v) {
@@ -258,12 +265,12 @@ class Connedit extends \Zotlabs\Web\Controller {
else
notice( t('Failed to update connection record.') . EOL);
- if(! intval(\App::$poi['abook_self'])) {
+ if(! intval(App::$poi['abook_self'])) {
if($new_friend) {
- \Zotlabs\Daemon\Master::Summon( [ 'Notifier', 'permission_accept', $contact_id ] );
+ Master::Summon( [ 'Notifier', 'permission_accept', $contact_id ] );
}
- \Zotlabs\Daemon\Master::Summon( [
+ Master::Summon( [
'Notifier',
(($new_friend) ? 'permission_create' : 'permission_update'),
$contact_id
@@ -276,7 +283,7 @@ class Connedit extends \Zotlabs\Web\Controller {
require_once('include/group.php');
$g = group_rec_byhash(local_channel(),$default_group);
if($g)
- group_add_member(local_channel(),'',\App::$poi['abook_xchan'],$g['id']);
+ group_add_member(local_channel(),'',App::$poi['abook_xchan'],$g['id']);
}
// Check if settings permit ("post new friend activity" is allowed, and
@@ -300,19 +307,19 @@ class Connedit extends \Zotlabs\Web\Controller {
$xarr['item_private'] = (($xarr['allow_cid']||$xarr['allow_gid']||$xarr['deny_cid']||$xarr['deny_gid']) ? 1 : 0);
$obj = array(
'type' => ACTIVITY_OBJ_PERSON,
- 'title' => \App::$poi['xchan_name'],
- 'id' => \App::$poi['xchan_hash'],
+ 'title' => App::$poi['xchan_name'],
+ 'id' => App::$poi['xchan_hash'],
'link' => array(
- array('rel' => 'alternate', 'type' => 'text/html', 'href' => \App::$poi['xchan_url']),
- array('rel' => 'photo', 'type' => \App::$poi['xchan_photo_mimetype'], 'href' => \App::$poi['xchan_photo_l'])
+ array('rel' => 'alternate', 'type' => 'text/html', 'href' => App::$poi['xchan_url']),
+ array('rel' => 'photo', 'type' => App::$poi['xchan_photo_mimetype'], 'href' => App::$poi['xchan_photo_l'])
),
);
$xarr['obj'] = 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=' . \App::$poi['xchan_url'] . ']' . \App::$poi['xchan_name'] . '[/zrl]';
+ $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]';
- $xarr['body'] .= "\n\n\n" . '[zrl=' . \App::$poi['xchan_url'] . '][zmg=80x80]' . \App::$poi['xchan_photo_m'] . '[/zmg][/zrl]';
+ $xarr['body'] .= "\n\n\n" . '[zrl=' . App::$poi['xchan_url'] . '][zmg=80x80]' . App::$poi['xchan_photo_m'] . '[/zmg][/zrl]';
post_activity_item($xarr);
@@ -320,7 +327,7 @@ class Connedit extends \Zotlabs\Web\Controller {
// pull in a bit of content if there is any to pull in
- \Zotlabs\Daemon\Master::Summon(array('Onepoll',$contact_id));
+ Master::Summon(array('Onepoll',$contact_id));
}
@@ -333,11 +340,11 @@ class Connedit extends \Zotlabs\Web\Controller {
intval($contact_id)
);
if($r) {
- \App::$poi = $r[0];
+ App::$poi = $r[0];
}
if($new_friend) {
- $arr = array('channel_id' => local_channel(), 'abook' => \App::$poi);
+ $arr = array('channel_id' => local_channel(), 'abook' => App::$poi);
call_hooks('accept_follow', $arr);
}
@@ -357,23 +364,23 @@ class Connedit extends \Zotlabs\Web\Controller {
function connedit_clone(&$a) {
- if(! \App::$poi)
+ if(! App::$poi)
return;
- $channel = \App::get_channel();
+ $channel = App::get_channel();
$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'])
+ intval(App::$poi['abook_id'])
);
if($r) {
- \App::$poi = array_shift($r);
+ App::$poi = array_shift($r);
}
- $clone = \App::$poi;
+ $clone = App::$poi;
unset($clone['abook_id']);
unset($clone['abook_account']);
@@ -402,11 +409,11 @@ class Connedit extends \Zotlabs\Web\Controller {
}
$section = ((array_key_exists('section',$_REQUEST)) ? $_REQUEST['section'] : '');
- $channel = \App::get_channel();
+ $channel = App::get_channel();
$yes_no = array(t('No'),t('Yes'));
- $connect_perms = \Zotlabs\Access\Permissions::connect_perms(local_channel());
+ $connect_perms = Permissions::connect_perms(local_channel());
$o .= "<script>function connectDefaultShare() {
\$('.abook-edit-me').each(function() {
@@ -427,7 +434,7 @@ class Connedit extends \Zotlabs\Web\Controller {
return;
$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),
@@ -441,7 +448,7 @@ class Connedit extends \Zotlabs\Web\Controller {
if($cmd === 'update') {
// pull feed and consume it, which should subscribe to the hub.
- \Zotlabs\Daemon\Master::Summon(array('Poller',$contact_id));
+ Master::Summon(array('Poller',$contact_id));
goaway(z_root() . '/connedit/' . $contact_id);
}
@@ -451,7 +458,7 @@ class Connedit extends \Zotlabs\Web\Controller {
$recurse = 0;
$x = z_fetch_url(zid($url),false,$recurse,['session' => true]);
if($x['success']) {
- $h = new \Zotlabs\Web\HTTPHeaders($x['header']);
+ $h = new HTTPHeaders($x['header']);
$fields = $h->fetch();
if($fields) {
foreach($fields as $y) {
@@ -482,17 +489,17 @@ class Connedit extends \Zotlabs\Web\Controller {
if($cmd === 'refresh') {
if($orig_record[0]['xchan_network'] === 'zot') {
- if(! zot_refresh($orig_record[0],\App::get_channel()))
+ if(! zot_refresh($orig_record[0],App::get_channel()))
notice( t('Refresh failed - channel is currently unavailable.') );
}
elseif($orig_record[0]['xchan_network'] === 'zot6') {
- if(! Libzot::refresh($orig_record[0],\App::get_channel()))
+ if(! Libzot::refresh($orig_record[0],App::get_channel()))
notice( t('Refresh failed - channel is currently unavailable.') );
}
else {
// if you are on a different network we'll force a refresh of the connection basic info
- \Zotlabs\Daemon\Master::Summon(array('Notifier','permission_update',$contact_id));
+ Master::Summon(array('Notifier','permission_update',$contact_id));
}
goaway(z_root() . '/connedit/' . $contact_id);
}
@@ -550,15 +557,10 @@ class Connedit extends \Zotlabs\Web\Controller {
if($cmd === 'drop') {
-
- // @FIXME
- // 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_channel(), $orig_record[0]['abook_id']);
+
+ Master::Summon( [ 'Notifier', 'purge', local_channel(), $orig_record[0]['xchan_hash'] ] );
+
Libsync::build_sync_packet(0 /* use the current local_channel */,
array('abook' => array(array(
'abook_xchan' => $orig_record[0]['abook_xchan'],
@@ -574,13 +576,13 @@ class Connedit extends \Zotlabs\Web\Controller {
}
}
- if(\App::$poi) {
+ if(App::$poi) {
$abook_prev = 0;
$abook_next = 0;
- $contact_id = \App::$poi['abook_id'];
- $contact = \App::$poi;
+ $contact_id = App::$poi['abook_id'];
+ $contact = App::$poi;
$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",
intval(local_channel())
@@ -788,9 +790,9 @@ class Connedit extends \Zotlabs\Web\Controller {
$perms = array();
- $channel = \App::get_channel();
+ $channel = App::get_channel();
- $global_perms = \Zotlabs\Access\Permissions::Perms();
+ $global_perms = Permissions::Perms();
$existing = get_all_perms(local_channel(),$contact['abook_xchan'],false);
@@ -822,7 +824,7 @@ class Connedit extends \Zotlabs\Web\Controller {
$thisperm = get_abconfig(local_channel(),$contact['abook_xchan'],'my_perms',$k);
//fixme
- $checkinherited = \Zotlabs\Access\PermissionLimits::Get(local_channel(),$k);
+ $checkinherited = PermissionLimits::Get(local_channel(),$k);
// For auto permissions (when $self is true) we don't want to look at existing
// permissions because they are enabled for the channel owner
@@ -835,7 +837,7 @@ class Connedit extends \Zotlabs\Web\Controller {
$perms[] = array('perms_' . $k, $v, ((array_key_exists($k,$their_perms)) ? intval($their_perms[$k]) : ''),$thisperm, 1, (($checkinherited & PERMS_SPECIFIC) ? '' : '1'), '', $checkinherited);
}
- $pcat = new \Zotlabs\Lib\Permcat(local_channel());
+ $pcat = new Permcat(local_channel());
$pcatlist = $pcat->listing();
$permcats = [];
if($pcatlist) {