function blogger_install()
{
+ Addon::registerHook('hook_fork', 'addon/blogger/blogger.php', 'blogger_hook_fork');
Addon::registerHook('post_local', 'addon/blogger/blogger.php', 'blogger_post_local');
Addon::registerHook('notifier_normal', 'addon/blogger/blogger.php', 'blogger_send');
Addon::registerHook('jot_networks', 'addon/blogger/blogger.php', 'blogger_jot_nets');
function blogger_uninstall()
{
+ Addon::unregisterHook('hook_fork', 'addon/blogger/blogger.php', 'blogger_hook_fork');
Addon::unregisterHook('post_local', 'addon/blogger/blogger.php', 'blogger_post_local');
Addon::unregisterHook('notifier_normal', 'addon/blogger/blogger.php', 'blogger_send');
Addon::unregisterHook('jot_networks', 'addon/blogger/blogger.php', 'blogger_jot_nets');
}
}
+function blogger_hook_fork(App &$a, array &$b)
+{
+ if ($b['name'] != 'notifier_normal') {
+ return;
+ }
+
+ $post = $b['data'];
+
+ if ($post['deleted'] || $post['private'] || ($post['created'] !== $post['edited']) ||
+ !strstr($post['postopts'], 'blogger') || ($post['parent'] != $post['id'])) {
+ $b['execute'] = false;
+ return;
+ }
+}
+
function blogger_post_local(App $a, array &$b)
{
// This can probably be changed to allow editing by pointing to a different API endpoint
function buffer_install()
{
+ Addon::registerHook('hook_fork', 'addon/buffer/buffer.php', 'buffer_hook_fork');
Addon::registerHook('post_local', 'addon/buffer/buffer.php', 'buffer_post_local');
Addon::registerHook('notifier_normal', 'addon/buffer/buffer.php', 'buffer_send');
Addon::registerHook('jot_networks', 'addon/buffer/buffer.php', 'buffer_jot_nets');
function buffer_uninstall()
{
+ Addon::unregisterHook('hook_fork', 'addon/buffer/buffer.php', 'buffer_hook_fork');
Addon::unregisterHook('post_local', 'addon/buffer/buffer.php', 'buffer_post_local');
Addon::unregisterHook('notifier_normal', 'addon/buffer/buffer.php', 'buffer_send');
Addon::unregisterHook('jot_networks', 'addon/buffer/buffer.php', 'buffer_jot_nets');
$b['postopts'] .= 'buffer';
}
+function buffer_hook_fork(&$a, &$b)
+{
+ if ($b['name'] != 'notifier_normal') {
+ return;
+ }
+
+ $post = $b['data'];
+
+ if ($post['deleted'] || $post['private'] || ($post['created'] !== $post['edited']) ||
+ !strstr($post['postopts'], 'buffer') || ($post['parent'] != $post['id'])) {
+ $b['execute'] = false;
+ return;
+ }
+}
+
function buffer_send(App $a, array &$b)
{
if ($b['deleted'] || $b['private'] || ($b['created'] !== $b['edited'])) {
function diaspora_install()
{
+ Addon::registerHook('hook_fork', 'addon/diaspora/diaspora.php', 'diaspora_hook_fork');
Addon::registerHook('post_local', 'addon/diaspora/diaspora.php', 'diaspora_post_local');
Addon::registerHook('notifier_normal', 'addon/diaspora/diaspora.php', 'diaspora_send');
Addon::registerHook('jot_networks', 'addon/diaspora/diaspora.php', 'diaspora_jot_nets');
function diaspora_uninstall()
{
+ Addon::unregisterHook('hook_fork', 'addon/diaspora/diaspora.php', 'diaspora_hook_fork');
Addon::unregisterHook('post_local', 'addon/diaspora/diaspora.php', 'diaspora_post_local');
Addon::unregisterHook('notifier_normal', 'addon/diaspora/diaspora.php', 'diaspora_send');
Addon::unregisterHook('jot_networks', 'addon/diaspora/diaspora.php', 'diaspora_jot_nets');
}
}
+function diaspora_hook_fork(&$a, &$b)
+{
+ if ($b['name'] != 'notifier_normal') {
+ return;
+ }
+
+ $post = $b['data'];
+
+ if ($post['deleted'] || $post['private'] || ($post['created'] !== $post['edited']) ||
+ !strstr($post['postopts'], 'diaspora') || ($post['parent'] != $post['id'])) {
+ $b['execute'] = false;
+ return;
+ }
+}
+
function diaspora_post_local(App $a, array &$b)
{
if ($b['edit']) {
use Friendica\Database\DBA;
use Friendica\Util\Network;
-function libertree_install() {
- Addon::registerHook('post_local', 'addon/libertree/libertree.php', 'libertree_post_local');
- Addon::registerHook('notifier_normal', 'addon/libertree/libertree.php', 'libertree_send');
- Addon::registerHook('jot_networks', 'addon/libertree/libertree.php', 'libertree_jot_nets');
- Addon::registerHook('connector_settings', 'addon/libertree/libertree.php', 'libertree_settings');
- Addon::registerHook('connector_settings_post', 'addon/libertree/libertree.php', 'libertree_settings_post');
-
-}
-function libertree_uninstall() {
- Addon::unregisterHook('post_local', 'addon/libertree/libertree.php', 'libertree_post_local');
- Addon::unregisterHook('notifier_normal', 'addon/libertree/libertree.php', 'libertree_send');
- Addon::unregisterHook('jot_networks', 'addon/libertree/libertree.php', 'libertree_jot_nets');
- Addon::unregisterHook('connector_settings', 'addon/libertree/libertree.php', 'libertree_settings');
- Addon::unregisterHook('connector_settings_post', 'addon/libertree/libertree.php', 'libertree_settings_post');
+function libertree_install()
+{
+ Addon::registerHook('hook_fork', 'addon/libertree/libertree.php', 'libertree_hook_fork');
+ Addon::registerHook('post_local', 'addon/libertree/libertree.php', 'libertree_post_local');
+ Addon::registerHook('notifier_normal', 'addon/libertree/libertree.php', 'libertree_send');
+ Addon::registerHook('jot_networks', 'addon/libertree/libertree.php', 'libertree_jot_nets');
+ Addon::registerHook('connector_settings', 'addon/libertree/libertree.php', 'libertree_settings');
+ Addon::registerHook('connector_settings_post', 'addon/libertree/libertree.php', 'libertree_settings_post');
}
+function libertree_uninstall()
+{
+ Addon::unregisterHook('hook_fork', 'addon/libertree/libertree.php', 'libertree_hook_fork');
+ Addon::unregisterHook('post_local', 'addon/libertree/libertree.php', 'libertree_post_local');
+ Addon::unregisterHook('notifier_normal', 'addon/libertree/libertree.php', 'libertree_send');
+ Addon::unregisterHook('jot_networks', 'addon/libertree/libertree.php', 'libertree_jot_nets');
+ Addon::unregisterHook('connector_settings', 'addon/libertree/libertree.php', 'libertree_settings');
+ Addon::unregisterHook('connector_settings_post', 'addon/libertree/libertree.php', 'libertree_settings_post');
+}
function libertree_jot_nets(&$a,&$b) {
if(! local_user())
}
+function libertree_hook_fork(App &$a, array &$b)
+{
+ if ($b['name'] != 'notifier_normal') {
+ return;
+ }
+
+ $post = $b['data'];
+
+ if ($post['deleted'] || $post['private'] || ($post['created'] !== $post['edited']) ||
+ !strstr($post['postopts'], 'libertree') || ($post['parent'] != $post['id'])) {
+ $b['execute'] = false;
+ return;
+ }
+}
+
function libertree_post_local(&$a,&$b) {
// This can probably be changed to allow editing by pointing to a different API endpoint
function pumpio_install()
{
Addon::registerHook('load_config', 'addon/pumpio/pumpio.php', 'pumpio_load_config');
+ Addon::registerHook('hook_fork', 'addon/pumpio/pumpio.php', 'hook_fork');
Addon::registerHook('post_local', 'addon/pumpio/pumpio.php', 'pumpio_post_local');
Addon::registerHook('notifier_normal', 'addon/pumpio/pumpio.php', 'pumpio_send');
Addon::registerHook('jot_networks', 'addon/pumpio/pumpio.php', 'pumpio_jot_nets');
function pumpio_uninstall()
{
Addon::unregisterHook('load_config', 'addon/pumpio/pumpio.php', 'pumpio_load_config');
+ Addon::unregisterHook('hook_fork', 'addon/pumpio/pumpio.php', 'pumpio_hook_fork');
Addon::unregisterHook('post_local', 'addon/pumpio/pumpio.php', 'pumpio_post_local');
Addon::unregisterHook('notifier_normal', 'addon/pumpio/pumpio.php', 'pumpio_send');
Addon::unregisterHook('jot_networks', 'addon/pumpio/pumpio.php', 'pumpio_jot_nets');
$a->loadConfigFile(__DIR__. '/config/pumpio.ini.php');
}
+function pumpio_hook_fork(App $a, array &$b)
+{
+ if ($b['name'] != 'notifier_normal') {
+ return;
+ }
+
+ $post = $b['data'];
+
+ // Deleting and editing is not supported by the addon (deleting could, but isn't by now)
+ if ($post['deleted'] || ($post['created'] !== $post['edited'])) {
+ $b['execute'] = false;
+ return;
+ }
+
+ // if post comes from pump.io don't send it back
+ if ($post['app'] == "pump.io") {
+ $b['execute'] = false;
+ return;
+ }
+
+ if (PConfig::get($post['uid'], 'pumpio', 'import')) {
+ // Don't fork if it isn't a reply to a pump.io post
+ if (($post['parent'] != $post['id']) && !Item::exists(['id' => $post['parent'], 'network' => Protocol::PUMPIO])) {
+ Logger::log('No pump.io parent found for item ' . $post['id']);
+ $b['execute'] = false;
+ return;
+ }
+ } else {
+ // Comments are never exported when we don't import the pumpio timeline
+ if (!strstr($post['postopts'], 'pumpio') || ($post['parent'] != $post['id']) || $post['private']) {
+ $b['execute'] = false;
+ return;
+ }
+ }
+}
+
function pumpio_post_local(App $a, array &$b)
{
if (!local_user() || (local_user() != $b['uid'])) {
Addon::registerHook('connector_settings', 'addon/statusnet/statusnet.php', 'statusnet_settings');
Addon::registerHook('connector_settings_post', 'addon/statusnet/statusnet.php', 'statusnet_settings_post');
Addon::registerHook('notifier_normal', 'addon/statusnet/statusnet.php', 'statusnet_post_hook');
+ Addon::registerHook('hook_fork', 'addon/statusnet/statusnet.php', 'statusnet_hook_fork');
Addon::registerHook('post_local', 'addon/statusnet/statusnet.php', 'statusnet_post_local');
Addon::registerHook('jot_networks', 'addon/statusnet/statusnet.php', 'statusnet_jot_nets');
Addon::registerHook('cron', 'addon/statusnet/statusnet.php', 'statusnet_cron');
Addon::unregisterHook('connector_settings', 'addon/statusnet/statusnet.php', 'statusnet_settings');
Addon::unregisterHook('connector_settings_post', 'addon/statusnet/statusnet.php', 'statusnet_settings_post');
Addon::unregisterHook('notifier_normal', 'addon/statusnet/statusnet.php', 'statusnet_post_hook');
+ Addon::unregisterHook('hook_fork', 'addon/statusnet/statusnet.php', 'statusnet_hook_fork');
Addon::unregisterHook('post_local', 'addon/statusnet/statusnet.php', 'statusnet_post_local');
Addon::unregisterHook('jot_networks', 'addon/statusnet/statusnet.php', 'statusnet_jot_nets');
Addon::unregisterHook('cron', 'addon/statusnet/statusnet.php', 'statusnet_cron');
$s .= '</div><div class="clear"></div>';
}
+function statusnet_hook_fork(App $a, array &$b)
+{
+ if ($b['name'] != 'notifier_normal') {
+ return;
+ }
+
+ $post = $b['data'];
+
+ // Deleting and editing is not supported by the addon
+ if ($post['deleted'] || ($post['created'] !== $post['edited'])) {
+ $b['execute'] = false;
+ return;
+ }
+
+ // if post comes from GNU Social don't send it back
+ if ($post['extid'] == Protocol::STATUSNET) {
+ $b['execute'] = false;
+ return;
+ }
+
+ if ($post['app'] == 'StatusNet') {
+ $b['execute'] = false;
+ return;
+ }
+
+ if (PConfig::get($post['uid'], 'statusnet', 'import')) {
+ // Don't fork if it isn't a reply to a GNU Social post
+ if (($post['parent'] != $post['id']) && !Item::exists(['id' => $post['parent'], 'network' => Protocol::STATUSNET])) {
+ Logger::log('No GNU Social parent found for item ' . $post['id']);
+ $b['execute'] = false;
+ return;
+ }
+ } else {
+ // Comments are never exported when we don't import the GNU Social timeline
+ if (!strstr($post['postopts'], 'statusnet') || ($post['parent'] != $post['id']) || $post['private']) {
+ $b['execute'] = false;
+ return;
+ }
+ }
+}
+
function statusnet_post_local(App $a, &$b)
{
if ($b['edit']) {
function tumblr_install()
{
+ Addon::registerHook('hook_fork', 'addon/tumblr/tumblr.php', 'tumblr_hook_fork');
Addon::registerHook('post_local', 'addon/tumblr/tumblr.php', 'tumblr_post_local');
Addon::registerHook('notifier_normal', 'addon/tumblr/tumblr.php', 'tumblr_send');
Addon::registerHook('jot_networks', 'addon/tumblr/tumblr.php', 'tumblr_jot_nets');
function tumblr_uninstall()
{
+ Addon::unregisterHook('hook_fork', 'addon/tumblr/tumblr.php', 'tumblr_hook_fork');
Addon::unregisterHook('post_local', 'addon/tumblr/tumblr.php', 'tumblr_post_local');
Addon::unregisterHook('notifier_normal', 'addon/tumblr/tumblr.php', 'tumblr_send');
Addon::unregisterHook('jot_networks', 'addon/tumblr/tumblr.php', 'tumblr_jot_nets');
}
}
+function tumblr_hook_fork(&$a, &$b)
+{
+ if ($b['name'] != 'notifier_normal') {
+ return;
+ }
+
+ $post = $b['data'];
+
+ if ($post['deleted'] || $post['private'] || ($post['created'] !== $post['edited']) ||
+ !strstr($post['postopts'], 'tumblr') || ($post['parent'] != $post['id'])) {
+ $b['execute'] = false;
+ return;
+ }
+}
+
function tumblr_post_local(App $a, array &$b)
{
// This can probably be changed to allow editing by pointing to a different API endpoint
Addon::registerHook('load_config' , __FILE__, 'twitter_load_config');
Addon::registerHook('connector_settings' , __FILE__, 'twitter_settings');
Addon::registerHook('connector_settings_post', __FILE__, 'twitter_settings_post');
+ Addon::registerHook('hook_fork' , __FILE__, 'twitter_hook_fork');
Addon::registerHook('post_local' , __FILE__, 'twitter_post_local');
Addon::registerHook('notifier_normal' , __FILE__, 'twitter_post_hook');
Addon::registerHook('jot_networks' , __FILE__, 'twitter_jot_nets');
Addon::unregisterHook('load_config' , __FILE__, 'twitter_load_config');
Addon::unregisterHook('connector_settings' , __FILE__, 'twitter_settings');
Addon::unregisterHook('connector_settings_post', __FILE__, 'twitter_settings_post');
+ Addon::unregisterHook('hook_fork' , __FILE__, 'twitter_hook_fork');
Addon::unregisterHook('post_local' , __FILE__, 'twitter_post_local');
Addon::unregisterHook('notifier_normal' , __FILE__, 'twitter_post_hook');
Addon::unregisterHook('jot_networks' , __FILE__, 'twitter_jot_nets');
$s .= '</div><div class="clear"></div>';
}
+function twitter_hook_fork(App $a, array &$b)
+{
+ if ($b['name'] != 'notifier_normal') {
+ return;
+ }
+
+ $post = $b['data'];
+
+ // Deleting and editing is not supported by the addon (deleting could, but isn't by now)
+ if ($post['deleted'] || ($post['created'] !== $post['edited'])) {
+ $b['execute'] = false;
+ return;
+ }
+
+ // if post comes from twitter don't send it back
+ if ($post['extid'] == Protocol::TWITTER) {
+ $b['execute'] = false;
+ return;
+ }
+
+ if ($post['app'] == 'Twitter') {
+ $b['execute'] = false;
+ return;
+ }
+
+ if (PConfig::get($post['uid'], 'twitter', 'import')) {
+ // Don't fork if it isn't a reply to a twitter post
+ if (($post['parent'] != $post['id']) && !Item::exists(['id' => $post['parent'], 'network' => Protocol::TWITTER])) {
+ Logger::log('No twitter parent found for item ' . $post['id']);
+ $b['execute'] = false;
+ return;
+ }
+ } else {
+ // Comments are never exported when we don't import the twitter timeline
+ if (!strstr($post['postopts'], 'twitter') || ($post['parent'] != $post['id']) || $post['private']) {
+ $b['execute'] = false;
+ return;
+ }
+ }
+}
+
function twitter_post_local(App $a, array &$b)
{
if ($b['edit']) {
use Friendica\Util\Strings;
use Friendica\Util\XML;
-function wppost_install() {
- Addon::registerHook('post_local', 'addon/wppost/wppost.php', 'wppost_post_local');
- Addon::registerHook('notifier_normal', 'addon/wppost/wppost.php', 'wppost_send');
- Addon::registerHook('jot_networks', 'addon/wppost/wppost.php', 'wppost_jot_nets');
- Addon::registerHook('connector_settings', 'addon/wppost/wppost.php', 'wppost_settings');
- Addon::registerHook('connector_settings_post', 'addon/wppost/wppost.php', 'wppost_settings_post');
-
+function wppost_install()
+{
+ Addon::registerHook('hook_fork', 'addon/wppost/wppost.php', 'wppost_hook_fork');
+ Addon::registerHook('post_local', 'addon/wppost/wppost.php', 'wppost_post_local');
+ Addon::registerHook('notifier_normal', 'addon/wppost/wppost.php', 'wppost_send');
+ Addon::registerHook('jot_networks', 'addon/wppost/wppost.php', 'wppost_jot_nets');
+ Addon::registerHook('connector_settings', 'addon/wppost/wppost.php', 'wppost_settings');
+ Addon::registerHook('connector_settings_post', 'addon/wppost/wppost.php', 'wppost_settings_post');
}
-function wppost_uninstall() {
- Addon::unregisterHook('post_local', 'addon/wppost/wppost.php', 'wppost_post_local');
- Addon::unregisterHook('notifier_normal', 'addon/wppost/wppost.php', 'wppost_send');
- Addon::unregisterHook('jot_networks', 'addon/wppost/wppost.php', 'wppost_jot_nets');
- Addon::unregisterHook('connector_settings', 'addon/wppost/wppost.php', 'wppost_settings');
- Addon::unregisterHook('connector_settings_post', 'addon/wppost/wppost.php', 'wppost_settings_post');
- // obsolete - remove
- Addon::unregisterHook('post_local_end', 'addon/wppost/wppost.php', 'wppost_send');
- Addon::unregisterHook('addon_settings', 'addon/wppost/wppost.php', 'wppost_settings');
- Addon::unregisterHook('addon_settings_post', 'addon/wppost/wppost.php', 'wppost_settings_post');
+function wppost_uninstall()
+{
+ Addon::unregisterHook('hook_fork', 'addon/wppost/wppost.php', 'wppost_hook_fork');
+ Addon::unregisterHook('post_local', 'addon/wppost/wppost.php', 'wppost_post_local');
+ Addon::unregisterHook('notifier_normal', 'addon/wppost/wppost.php', 'wppost_send');
+ Addon::unregisterHook('jot_networks', 'addon/wppost/wppost.php', 'wppost_jot_nets');
+ Addon::unregisterHook('connector_settings', 'addon/wppost/wppost.php', 'wppost_settings');
+ Addon::unregisterHook('connector_settings_post', 'addon/wppost/wppost.php', 'wppost_settings_post');
+ // obsolete - remove
+ Addon::unregisterHook('post_local_end', 'addon/wppost/wppost.php', 'wppost_send');
+ Addon::unregisterHook('addon_settings', 'addon/wppost/wppost.php', 'wppost_settings');
+ Addon::unregisterHook('addon_settings_post', 'addon/wppost/wppost.php', 'wppost_settings_post');
}
-function wppost_jot_nets(&$a,&$b) {
- if(! local_user())
- return;
+function wppost_jot_nets(&$a, &$b)
+{
+ if (!local_user()) {
+ return;
+ }
- $wp_post = PConfig::get(local_user(),'wppost','post');
- if(intval($wp_post) == 1) {
- $wp_defpost = PConfig::get(local_user(),'wppost','post_by_default');
- $selected = ((intval($wp_defpost) == 1) ? ' checked="checked" ' : '');
- $b .= '<div class="profile-jot-net"><input type="checkbox" name="wppost_enable" ' . $selected . ' value="1" /> '
- . L10n::t('Post to Wordpress') . '</div>';
- }
+ $wp_post = PConfig::get(local_user(), 'wppost', 'post');
+ if (intval($wp_post) == 1) {
+ $wp_defpost = PConfig::get(local_user(),'wppost','post_by_default');
+ $selected = ((intval($wp_defpost) == 1) ? ' checked="checked" ' : '');
+ $b .= '<div class="profile-jot-net"><input type="checkbox" name="wppost_enable" ' . $selected . ' value="1" /> '
+ . L10n::t('Post to Wordpress') . '</div>';
+ }
}
}
+function wppost_hook_fork(&$a, &$b)
+{
+ if ($b['name'] != 'notifier_normal') {
+ return;
+ }
+
+ $post = $b['data'];
+
+ if ($post['deleted'] || $post['private'] || ($post['created'] !== $post['edited']) ||
+ !strstr($post['postopts'], 'wppost') || ($post['parent'] != $post['id'])) {
+ $b['execute'] = false;
+ return;
+ }
+}
+
function wppost_post_local(&$a, &$b) {
// This can probably be changed to allow editing by pointing to a different API endpoint