X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=statusnet%2Fstatusnet.php;h=8433580f2a49e8c6be600a93e51edac28e6118db;hb=e1c67f3bf49ec02f68f9306c52b7ec1805e1b8fc;hp=f7158a40187c73b7e9f68b7db3c210bb530eb9b2;hpb=c3e93f1ed9a487f823bcc75ddd43024334c25bfc;p=friendica-addons.git diff --git a/statusnet/statusnet.php b/statusnet/statusnet.php index f7158a40..8433580f 100644 --- a/statusnet/statusnet.php +++ b/statusnet/statusnet.php @@ -43,12 +43,13 @@ define('STATUSNET_DEFAULT_POLL_INTERVAL', 5); // given in minutes -require_once('library/twitteroauth.php'); -require_once('include/enotify.php'); -require_once("include/socgraph.php"); +require_once 'library/twitteroauth.php'; +require_once 'include/enotify.php'; use Friendica\Core\Config; use Friendica\Core\PConfig; +use Friendica\Model\GlobalContact; +use Friendica\Object\Photo; class StatusNetOAuth extends TwitterOAuth { function get_maxlength() { @@ -174,18 +175,18 @@ function statusnet_settings_post ($a,$post) { /*** * if the GNU Social-disconnect checkbox is set, clear the GNU Social configuration */ - del_pconfig(local_user(), 'statusnet', 'consumerkey'); - del_pconfig(local_user(), 'statusnet', 'consumersecret'); - del_pconfig(local_user(), 'statusnet', 'post'); - del_pconfig(local_user(), 'statusnet', 'post_by_default'); - del_pconfig(local_user(), 'statusnet', 'oauthtoken'); - del_pconfig(local_user(), 'statusnet', 'oauthsecret'); - del_pconfig(local_user(), 'statusnet', 'baseapi'); - del_pconfig(local_user(), 'statusnet', 'lastid'); - del_pconfig(local_user(), 'statusnet', 'mirror_posts'); - del_pconfig(local_user(), 'statusnet', 'import'); - del_pconfig(local_user(), 'statusnet', 'create_user'); - del_pconfig(local_user(), 'statusnet', 'own_id'); + PConfig::delete(local_user(), 'statusnet', 'consumerkey'); + PConfig::delete(local_user(), 'statusnet', 'consumersecret'); + PConfig::delete(local_user(), 'statusnet', 'post'); + PConfig::delete(local_user(), 'statusnet', 'post_by_default'); + PConfig::delete(local_user(), 'statusnet', 'oauthtoken'); + PConfig::delete(local_user(), 'statusnet', 'oauthsecret'); + PConfig::delete(local_user(), 'statusnet', 'baseapi'); + PConfig::delete(local_user(), 'statusnet', 'lastid'); + PConfig::delete(local_user(), 'statusnet', 'mirror_posts'); + PConfig::delete(local_user(), 'statusnet', 'import'); + PConfig::delete(local_user(), 'statusnet', 'create_user'); + PConfig::delete(local_user(), 'statusnet', 'own_id'); } else { if (isset($_POST['statusnet-preconf-apiurl'])) { /*** @@ -265,7 +266,7 @@ function statusnet_settings_post ($a,$post) { PConfig::set(local_user(), 'statusnet', 'create_user', intval($_POST['statusnet-create_user'])); if (!intval($_POST['statusnet-mirror'])) - del_pconfig(local_user(),'statusnet','lastid'); + PConfig::delete(local_user(),'statusnet','lastid'); info( t('GNU Social settings updated.') . EOL); }}}} @@ -541,6 +542,13 @@ function statusnet_post_hook(&$a,&$b) { if($b['private'] || !strstr($b['postopts'],'statusnet')) return; + + // Dont't post if the post doesn't belong to us. + // This is a check for forum postings + $self = dba::select('contact', array('id'), array('uid' => $b['uid'], 'self' => true), array('limit' => 1)); + if ($b['contact-id'] != $self['id']) { + return; + } } if (($b['verb'] == ACTIVITY_POST) && $b['deleted']) @@ -929,7 +937,7 @@ function statusnet_fetch_contact($uid, $contact, $create_user) { if ($contact->statusnet_profile_url == "") return(-1); - update_gcontact(array("url" => $contact->statusnet_profile_url, + GlobalContact::update(array("url" => $contact->statusnet_profile_url, "network" => NETWORK_STATUSNET, "photo" => $contact->profile_image_url, "name" => $contact->name, "nick" => $contact->screen_name, "location" => $contact->location, "about" => $contact->description, @@ -990,9 +998,7 @@ function statusnet_fetch_contact($uid, $contact, $create_user) { group_add_member($uid,'',$contact_id,$g[0]['def_gid']); } - require_once("Photo.php"); - - $photos = import_profile_photo($contact->profile_image_url,$uid,$contact_id); + $photos = Photo::importProfilePhoto($contact->profile_image_url,$uid,$contact_id); q("UPDATE `contact` SET `photo` = '%s', `thumb` = '%s', @@ -1017,9 +1023,7 @@ function statusnet_fetch_contact($uid, $contact, $create_user) { logger("statusnet_fetch_contact: Updating contact ".$contact->screen_name, LOGGER_DEBUG); - require_once("Photo.php"); - - $photos = import_profile_photo($contact->profile_image_url, $uid, $r[0]['id']); + $photos = Photo::importProfilePhoto($contact->profile_image_url, $uid, $r[0]['id']); q("UPDATE `contact` SET `photo` = '%s', `thumb` = '%s', @@ -1687,7 +1691,7 @@ function statusnet_fetch_own_contact($a, $uid) { if(count($r)) $contact_id = $r[0]["id"]; else - del_pconfig($uid, 'statusnet', 'own_url'); + PConfig::delete($uid, 'statusnet', 'own_url'); } return($contact_id);