Update of /cvsroot/php-blog/serendipity/plugins/serendipity_event_karma
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13665/plugins/serendipity_event_karma
Modified Files:
serendipity_event_karma.php
Log Message:
updated karma plugin
Index: serendipity_event_karma.php
===================================================================
RCS file: /cvsroot/php-blog/serendipity/plugins/serendipity_event_karma/serendipity_event_karma.php,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- serendipity_event_karma.php 26 May 2004 12:07:00 -0000 1.1
+++ serendipity_event_karma.php 27 May 2004 12:01:03 -0000 1.2
@@ -33,6 +33,9 @@
@define('PLUGIN_KARMA_MAXKARMA', 'Maximaler Abstimmungszeitraum');
@define('PLUGIN_KARMA_MAXKARMA_BLAHBLAH', 'Abstimmungen nur erlauben bis der Artikel X Tage alt ist (Standard: 7)');
+ @define('PLUGIN_KARMA_LOGGING', 'Protokollieren');
+ @define('PLUGIN_KARMA_LOGGING_BLAHBLAH', 'Sollen Logfiles der Votes angelegt werden?');
+
break;
case 'en':
@@ -66,6 +69,9 @@
@define('PLUGIN_KARMA_MAXKARMA', 'Karmavoting period');
@define('PLUGIN_KARMA_MAXKARMA_BLAHBLAH', 'Only allow karmavoting until the article is X days old (Default: 7)');
+ @define('PLUGIN_KARMA_LOGGING', 'Log votes?');
+ @define('PLUGIN_KARMA_LOGGING_BLAHBLAH', 'Should karma votes be logged?');
+
break;
}
@@ -84,7 +90,7 @@
$propbag->add('description', PLUGIN_KARMA_BLAHBLAH);
$propbag->add('event_hooks', array('frontend_configure' => true, 'entry_display' => true, 'css' => true));
- $propbag->add('configuration', array('max_entrytime', 'max_votetime', 'extended_only', 'max_karmatime'));
+ $propbag->add('configuration', array('max_entrytime', 'max_votetime', 'extended_only', 'max_karmatime', 'logging'));
}
function introspect_config_item($name, &$propbag)
@@ -114,17 +120,33 @@
$propbag->add('description', PLUGIN_KARMA_EXTENDEDONLY_BLAHBLAH);
break;
+ case 'logging':
+ $propbag->add('type', 'boolean');
+ $propbag->add('name', PLUGIN_KARMA_LOGGING);
+ $propbag->add('description', PLUGIN_KARMA_LOGGING_BLAHBLAH);
+ break;
+
default:
return false;
}
return true;
}
- function register_dependencies($remove = false, $authorid = '0')
- {
+ function checkScheme() {
global $serendipity;
- if ($this->get_config('version') != '1.0') {
+ $version = $this->get_config('version', '0.9');
+ if ($version == '1.0') {
+ $q = "CREATE TABLE {$serendipity['dbPrefix']}karmalog (
+ entryid int(11) default null,
+ points int(4) default null,
+ ip varchar(15),
+ user_agent varchar(255),
+ votetime int(11) default null
+ )";
+ $sql = serendipity_db_schema_import($q);
+ $this->set_config('version', '1.1');
+ } elseif ($version != '1.1') {
$q = "CREATE TABLE {$serendipity['dbPrefix']}karma (
entryid int(11) default null,
points int(4) default null,
@@ -133,13 +155,30 @@
)";
$sql = serendipity_db_schema_import($q);
+ $q = "CREATE TABLE {$serendipity['dbPrefix']}karmalog (
+ entryid int(11) default null,
+ points int(4) default null,
+ ip varchar(15),
+ user_agent varchar(255)
+ )";
+ $sql = serendipity_db_schema_import($q);
+
$q = "CREATE INDEX kfetch ON {$serendipity['dbPrefix']}karma (entryid, lastvote);";
$sql = serendipity_db_schema_import($q);
$q = "CREATE INDEX kentryid ON {$serendipity['dbPrefix']}karma (entryid);";
$sql = serendipity_db_schema_import($q);
+ $this->set_config('version', '1.1');
+ }
- $this->set_config('version', '1.0');
+ return true;
+ }
+
+ function register_dependencies($remove = false, $authorid = '0')
+ {
+ global $serendipity;
+
+ if ($this->get_config('version') != '1.1') {
}
}
@@ -244,6 +283,24 @@
$sql = serendipity_db_query($q);
}
+ if ($this->get_config('logging', false)) {
+ $this->checkScheme();
+
+ $q = sprintf(
+ "INSERT INTO {$serendipity['dbPrefix']}karmalog
+ (entryid, points, ip, user_agent, votetime)
+ VALUES (%s, %s, '%s', '%s', %s)",
+ $this->karmaId,
+ $this->karmaVoting,
+ serendipity_db_escape_string($_SERVER['REMOTE_ADDR']),
+ serendipity_db_escape_string($_SERVER['HTTP_USER_AGENT']),
+ $now
+ );
+ print_r(serendipity_db_query($q));
+ } else {
+ echo 'NO LOGGING';
+ }
+
$karma[$this->karmaId] = $this->karmaVoting;
$this->karmaVote = 'voted';
serendipity_setCookie('karmaVote', serialize($karma));
|