diff --git a/appnet/appnet.php b/appnet/appnet.php index d175ad589..de1dd970d 100644 --- a/appnet/appnet.php +++ b/appnet/appnet.php @@ -8,7 +8,10 @@ */ /* - 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 */ define('APPNET_DEFAULT_POLL_INTERVAL', 5); // given in minutes @@ -58,11 +61,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 +129,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 +155,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 .= '