X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=appnet%2Fappnet.php;h=7e80c6abd2d9471aa3f31c6ece0d688f4e5526af;hb=3d8d0e2860c3cb379e486e5a9565df5cbcc041a0;hp=d175ad589c0c27d610a39498aacedb5e5ed9162c;hpb=ec8384df667ea1395879c40014c4ae536668254e;p=friendica-addons.git diff --git a/appnet/appnet.php b/appnet/appnet.php index d175ad58..7e80c6ab 100644 --- a/appnet/appnet.php +++ b/appnet/appnet.php @@ -8,7 +8,11 @@ */ /* - Some marker in the post so that reimported posts can be treated better. (BBCode over app.net?) + To-Do: + - Use embedded pictures for the attachment information (large attachment) + - Sound links must be handled + - https://alpha.app.net/sr_rolando/post/32365203 - double pictures + - https://alpha.app.net/opendev/post/34396399 - location data */ define('APPNET_DEFAULT_POLL_INTERVAL', 5); // given in minutes @@ -20,6 +24,7 @@ function appnet_install() { register_hook('cron', 'addon/appnet/appnet.php', 'appnet_cron'); register_hook('connector_settings', 'addon/appnet/appnet.php', 'appnet_settings'); register_hook('connector_settings_post','addon/appnet/appnet.php', 'appnet_settings_post'); + register_hook('prepare_body', 'addon/appnet/appnet.php', 'appnet_prepare_body'); } @@ -28,8 +33,9 @@ function appnet_uninstall() { unregister_hook('notifier_normal', 'addon/appnet/appnet.php', 'appnet_send'); unregister_hook('jot_networks', 'addon/appnet/appnet.php', 'appnet_jot_nets'); unregister_hook('cron', 'addon/appnet/appnet.php', 'appnet_cron'); - unregister_hook('connector_settings', 'addon/appnet/appnet.php', 'appnet_settings'); + unregister_hook('connector_settings', 'addon/appnet/appnet.php', 'appnet_settings'); unregister_hook('connector_settings_post', 'addon/appnet/appnet.php', 'appnet_settings_post'); + unregister_hook('prepare_body', 'addon/appnet/appnet.php', 'appnet_prepare_body'); } function appnet_module() {} @@ -58,11 +64,35 @@ function appnet_content(&$a) { return $o; } +function appnet_plugin_admin(&$a, &$o){ + $t = get_markup_template( "admin.tpl", "addon/appnet/" ); + + $o = replace_macros($t, array( + '$submit' => t('Save Settings'), + // name, label, value, help, [extra values] + '$clientid' => array('clientid', t('Client ID'), get_config('appnet', 'clientid' ), ''), + '$clientsecret' => array('clientsecret', t('Client Secret'), get_config('appnet', 'clientsecret' ), ''), + )); +} + +function appnet_plugin_admin_post(&$a){ + $clientid = ((x($_POST,'clientid')) ? notags(trim($_POST['clientid'])) : ''); + $clientsecret = ((x($_POST,'clientsecret')) ? notags(trim($_POST['clientsecret'])): ''); + set_config('appnet','clientid',$clientid); + set_config('appnet','clientsecret',$clientsecret); + info( t('Settings updated.'). EOL ); +} + function appnet_connect(&$a) { require_once 'addon/appnet/AppDotNet.php'; - $clientId = get_pconfig(local_user(),'appnet','clientid'); - $clientSecret = get_pconfig(local_user(),'appnet','clientsecret'); + $clientId = get_config('appnet','clientid'); + $clientSecret = get_config('appnet','clientsecret'); + + if (($clientId == "") OR ($clientSecret == "")) { + $clientId = get_pconfig(local_user(),'appnet','clientid'); + $clientSecret = get_pconfig(local_user(),'appnet','clientsecret'); + } $app = new AppDotNet($clientId, $clientSecret); @@ -102,8 +132,14 @@ function appnet_settings(&$a,&$s) { return; $token = get_pconfig(local_user(),'appnet','token'); - $app_clientId = get_pconfig(local_user(),'appnet','clientid'); - $app_clientSecret = get_pconfig(local_user(),'appnet','clientsecret'); + + $app_clientId = get_config('appnet','clientid'); + $app_clientSecret = get_config('appnet','clientsecret'); + + if (($app_clientId == "") OR ($app_clientSecret == "")) { + $app_clientId = get_pconfig(local_user(),'appnet','clientid'); + $app_clientSecret = get_pconfig(local_user(),'appnet','clientsecret'); + } /* Add our stylesheet to the page so we can make our settings look nice */ $a->page['htmlhead'] .= '' . "\r\n"; @@ -122,11 +158,11 @@ function appnet_settings(&$a,&$s) { $ownid = get_pconfig(local_user(),'appnet','ownid'); $s .= ''; - $s .= '

'. t('App.net Export').'

'; + $s .= '

'. t('App.net Import/Export').'

'; $s .= '
'; $s .= '