xml-rpc: asure login name for comment author (optional)

This commit is contained in:
Grischa Brockhaus 2012-01-14 13:50:20 +01:00
parent f05b8a2294
commit 62ceb07887
5 changed files with 35 additions and 1 deletions

View file

@ -18,6 +18,11 @@
@define('PLUGIN_EVENT_XMLRPC_WPFAKEVERSION_DESC', 'Die XML-RPC Schnittlstelle kann auf WordPress Aufrufe reagieren. Wenn sie nach der installierten Software Version gefragt wird, antwortet sie normaler Weise mit Serendipity ' . $serendipity['version'] .'. Wenn Du hier eine Version einträgst, dann wird sie mit WordPress (angegebene Version) antworten. Einige Clients könnten auf eine minimale WordPress Version testen, eine Version wie 3.2 erscheint dann okay.');
@define('PLUGIN_EVENT_XMLRPC_HTMLCONVERT', 'Text Artikel nach HTML konvertieren');
@define('PLUGIN_EVENT_XMLRPC_HTMLCONVERT_DESC', 'Das Plugin versucht zu erkennen, ob Artikel als reine Texte oder als HTML übermittelt werden. Bei reinem Text wird es Zeilenumbrüche in HTML umwandeln. Wenn Du z.B: ein Textile oder das NL2BR Plugin für Artikel benutzt, solltest Du diese Option ausschalten.');
@define('PLUGIN_EVENT_XMLRPC_ASUREAUTHOR', 'Benutze Login als Kommentar Autor');
@define('PLUGIN_EVENT_XMLRPC_ASUREAUTHOR_DESC', 'Manche Clients speichern Kommentare mit einem generischen Autorennamen wie \'from WordPress\'. Wenn diese Option eingeschaltet ist, so wird immer der Name des eingeloggten Benutzers als Autor genommen.');
@define('PLUGIN_EVENT_XMLRPC_ASUREAUTHOR_DEFAULT', 'Autor nicht verändern');
@define('PLUGIN_EVENT_XMLRPC_ASUREAUTHOR_LOGIN', 'Loginname als Autor');
@define('PLUGIN_EVENT_XMLRPC_ASUREAUTHOR_REALNAME', 'Realname als Autor');
@define('PLUGIN_EVENT_XMLRPC_UPLOADDIR', 'Upload Verzeichnis');
@define('PLUGIN_EVENT_XMLRPC_UPLOADDIR_DESC', 'In welches Medienverzeichnis sollen Medien (wie Bilder und Videos) hoch geladen werden, die der Client schickt?');

View file

@ -18,6 +18,11 @@
@define('PLUGIN_EVENT_XMLRPC_WPFAKEVERSION_DESC', 'Die XML-RPC Schnittlstelle kann auf WordPress Aufrufe reagieren. Wenn sie nach der installierten Software Version gefragt wird, antwortet sie normaler Weise mit Serendipity ' . $serendipity['version'] .'. Wenn Du hier eine Version einträgst, dann wird sie mit WordPress (angegebene Version) antworten. Einige Clients könnten auf eine minimale WordPress Version testen, eine Version wie 3.2 erscheint dann okay.');
@define('PLUGIN_EVENT_XMLRPC_HTMLCONVERT', 'Text Artikel nach HTML konvertieren');
@define('PLUGIN_EVENT_XMLRPC_HTMLCONVERT_DESC', 'Das Plugin versucht zu erkennen, ob Artikel als reine Texte oder als HTML übermittelt werden. Bei reinem Text wird es Zeilenumbrüche in HTML umwandeln. Wenn Du z.B: ein Textile oder das NL2BR Plugin für Artikel benutzt, solltest Du diese Option ausschalten.');
@define('PLUGIN_EVENT_XMLRPC_ASUREAUTHOR', 'Benutze Login als Kommentar Autor');
@define('PLUGIN_EVENT_XMLRPC_ASUREAUTHOR_DESC', 'Manche Clients speichern Kommentare mit einem generischen Autorennamen wie \'from WordPress\'. Wenn diese Option eingeschaltet ist, so wird immer der Name des eingeloggten Benutzers als Autor genommen.');
@define('PLUGIN_EVENT_XMLRPC_ASUREAUTHOR_DEFAULT', 'Autor nicht verändern');
@define('PLUGIN_EVENT_XMLRPC_ASUREAUTHOR_LOGIN', 'Loginname als Autor');
@define('PLUGIN_EVENT_XMLRPC_ASUREAUTHOR_REALNAME', 'Realname als Autor');
@define('PLUGIN_EVENT_XMLRPC_UPLOADDIR', 'Upload Verzeichnis');
@define('PLUGIN_EVENT_XMLRPC_UPLOADDIR_DESC', 'In welches Medienverzeichnis sollen Medien (wie Bilder und Videos) hoch geladen werden, die der Client schickt?');

View file

@ -24,6 +24,11 @@
@define('PLUGIN_EVENT_XMLRPC_WPFAKEVERSION_DESC', 'This XML-RPC interface is able to respond to WordPress type calls. Normally, if asked for the software used, it answers with Serendipity ' . $serendipity['version'] .'. But if you enter a version here, it will response as WordPress (version entered). Some clients might check, if the WP version is high enough, so a version like 3.2 would be okay here.');
@define('PLUGIN_EVENT_XMLRPC_HTMLCONVERT', 'Convert plaintext articles to HTML');
@define('PLUGIN_EVENT_XMLRPC_HTMLCONVERT_DESC', 'The plugin tries to detect plain text delivered as article body and if detected converts its linefeeds to HTML. If you use plugins like the textile or nl2br textformats for articles you should disable this.');
@define('PLUGIN_EVENT_XMLRPC_ASUREAUTHOR', 'Comments author from login');
@define('PLUGIN_EVENT_XMLRPC_ASUREAUTHOR_DESC', 'Some clients post a comment with a generic author name like \'from WordPress\'. If this option is enabled, the author name will always be the name of the logged in user.');
@define('PLUGIN_EVENT_XMLRPC_ASUREAUTHOR_DEFAULT', 'Don\'t patch author');
@define('PLUGIN_EVENT_XMLRPC_ASUREAUTHOR_LOGIN', 'Use login name as author');
@define('PLUGIN_EVENT_XMLRPC_ASUREAUTHOR_REALNAME', 'Use real name as author');
@define('PLUGIN_EVENT_XMLRPC_UPLOADDIR', 'Upload directory');
@define('PLUGIN_EVENT_XMLRPC_UPLOADDIR_DESC', 'If the clients uploads medias (i.e. images and videos) in what medialibrary directory should they be stored?');

View file

@ -36,7 +36,7 @@ class serendipity_event_xmlrpc extends serendipity_event
'frontend_header' => true
));
$propbag->add('configuration',
array('doc_rpclink','category', 'gmt', 'uploaddir', 'htmlconvert', 'wpfakeversion', 'debuglog', 'spamevent_description', 'event_spam', 'event_approved','event_pending')
array('doc_rpclink','category', 'gmt', 'uploaddir', 'htmlconvert', 'asureauthor', 'wpfakeversion', 'debuglog', 'spamevent_description', 'event_spam', 'event_approved','event_pending')
);
$propbag->add('groups', array('FRONTEND_FULL_MODS', 'FRONTEND_EXTERNAL_SERVICES'));
}
@ -105,6 +105,18 @@ class serendipity_event_xmlrpc extends serendipity_event
$propbag->add('description', PLUGIN_EVENT_XMLRPC_HTMLCONVERT_DESC);
$propbag->add('default', true);
break;
case 'asureauthor':
$authoroptions = array(
'default' => PLUGIN_EVENT_XMLRPC_ASUREAUTHOR_DEFAULT,
'serendipityUser' => PLUGIN_EVENT_XMLRPC_ASUREAUTHOR_LOGIN,
'serendipityRealname' => PLUGIN_EVENT_XMLRPC_ASUREAUTHOR_REALNAME,
);
$propbag->add('type', 'select');
$propbag->add('select_values', $authoroptions);
$propbag->add('name', PLUGIN_EVENT_XMLRPC_ASUREAUTHOR);
$propbag->add('description', PLUGIN_EVENT_XMLRPC_ASUREAUTHOR_DESC);
$propbag->add('default', 'default');
break;
case 'wpfakeversion' :
$propbag->add('type', 'string');
$propbag->add('name', PLUGIN_EVENT_XMLRPC_WPFAKEVERSION);
@ -208,6 +220,7 @@ class serendipity_event_xmlrpc extends serendipity_event
$serendipity['xmlrpc_wpfakeversion'] = $this->get_config('wpfakeversion','');
$serendipity['xmlrpc_htmlconvert'] = $this->get_config('htmlconvert',true);
$serendipity['xmlrpc_uploadreldir'] = $this->get_config('uploaddir','');
$serendipity['xmlrpc_asureauthor'] = $this->get_config('asureauthor','default');
$serendipity['xmlrpc_event_spam'] = $this->get_config('event_spam','spam');
$serendipity['xmlrpc_event_approved'] = $this->get_config('event_approved','ham');

View file

@ -498,6 +498,9 @@ function wp_editComment($message) {
$entry_authorid = $commentInfo['entry_authorid'];
$comment_status = $commentInfo['comment_status'];
if (!empty($serendipity['xmlrpc_asureauthor']) && $serendipity['xmlrpc_asureauthor']!='default') {
$rpccomment['author'] = $serendipity[$serendipity['xmlrpc_asureauthor']];
}
// Setup new comment to save. Preserve old values, if nothing is given by the client.
$comment = array(
'author' => empty($rpccomment['author']) ? $commentInfo['author'] : $rpccomment['author'],
@ -554,6 +557,9 @@ function wp_newComment($message) {
$comment = $val->getval();
// Setup defaults, if not given by client. The serendipity vars were setup while authenticating.
if (!empty($serendipity['xmlrpc_asureauthor']) && $serendipity['xmlrpc_asureauthor']!='default') {
$comment['author'] = $serendipity[$serendipity['xmlrpc_asureauthor']];
}
if (empty($comment['author'])) $comment['author'] = $serendipity['serendipityRealname'];
if (empty($comment['author_email'])) $comment['author_email'] = $serendipity['serendipityEmail'];