switch ($serendipity['lang']) {
case 'de':
- @define('PLUGIN_KARMA_VERSION', '1.2');
+ @define('PLUGIN_KARMA_VERSION', '1.3');
@define('PLUGIN_KARMA_NAME', 'Karma');
@define('PLUGIN_KARMA_BLAHBLAH', 'Abstimmung über die Einträge');
@define('PLUGIN_KARMA_VOTETEXT', 'Karma dieses Eintrags: ');
case 'en':
default:
- @define('PLUGIN_KARMA_VERSION', '1.2');
+ @define('PLUGIN_KARMA_VERSION', '1.3');
@define('PLUGIN_KARMA_NAME', 'Karma');
@define('PLUGIN_KARMA_BLAHBLAH', 'Let visitors rate the quality of your entries');
@define('PLUGIN_KARMA_VOTETEXT', 'Karma for this article: ');
$propbag->add('description', PLUGIN_KARMA_BLAHBLAH);
$propbag->add('stackable', false);
$propbag->add('author', 'Garvin Hicking');
- $propbag->add('version', '1.01');
+ $propbag->add('version', PLUGIN_KARMA_VERSION);
$propbag->add('requirements', array(
'serendipity' => '0.8',
'smarty' => '2.6.7',
serendipity_setCookie('karmaVote', serialize(array()));
}
+ if (isset($serendipity['GET']['id'])) {
+ $entryid = (int)serendipity_db_escape_string($serendipity['GET']['id']);
+ } elseif (preg_match(PAT_COMMENTSUB, $_SERVER['REQUEST_URI'], $matches)) {
+ $entryid = (int)$matches[1];
+ } else {
+ $entryid = false;
+ }
+
+ if ($entryid) {
+ $track_clicks = serendipity_db_bool($this->get_config('visits_active', true));
+ if ($track_clicks) {
+ $sql = serendipity_db_query('UPDATE ' . $serendipity['dbPrefix'] . 'karma SET visits = visits + 1 WHERE entryid = ' . $entryid, true);
+ if (serendipity_db_affected_rows() < 1) {
+ serendipity_db_query("INSERT INTO {$serendipity['dbPrefix']}karma (entryid, points, votes, lastvote, visits) VALUES ('$entryid', 0, 0, 0, 1)");
+ }
+ }
+ }
+
if (!isset($serendipity['GET']['karmaId']) || !isset($serendipity['GET']['karmaVote'])) {
return;
}
}
$now = time();
-
- if ($row['votes'] > 0) {
+ if ($row['votes'] === '0' || $row['votes'] > 0) {
// Votes for this entry already exist. Do some checking.
$max_entrytime = $this->get_config('max_entrytime', 1440) * 60;
$max_votetime = $this->get_config('max_votetime', 5) * 60;
if ($addData['extended'] || $addData['preview']) {
$entryid = (int)serendipity_db_escape_string($eventData[0]['id']);
- if ($track_clicks && !$addData['preview']) {
- $sql = serendipity_db_query('UPDATE ' . $serendipity['dbPrefix'] . 'karma SET visits = visits + 1 WHERE entryid = ' . $entryid, true);
- if (serendipity_db_affected_rows() < 1) {
- serendipity_db_query("INSERT INTO {$serendipity['dbPrefix']}karma (entryid, points, votes, lastvote, visits) VALUES ('$entryid', 0, 0, 0, 1)");
- }
- }
-
$q = 'SELECT SUM(votes) AS votes, SUM(points) AS points, SUM(visits) AS visits
FROM ' . $serendipity['dbPrefix'] . 'karma AS k
WHERE k.entryid = ' . $entryid . ' GROUP BY k.entryid LIMIT 1';