[pLog-svn] r5102 - in plugins/branches/lifetype-1.2/unported/karma: . class/action class/karma
oscar at devel.lifetype.net
oscar at devel.lifetype.net
Thu Mar 15 16:05:17 EDT 2007
Author: oscar
Date: 2007-03-15 16:05:17 -0400 (Thu, 15 Mar 2007)
New Revision: 5102
Modified:
plugins/branches/lifetype-1.2/unported/karma/class/action/adminkarmapluginsettingsaction.class.php
plugins/branches/lifetype-1.2/unported/karma/class/action/adminkarmapluginupdatesettingsaction.class.php
plugins/branches/lifetype-1.2/unported/karma/class/action/karmarateaction.class.php
plugins/branches/lifetype-1.2/unported/karma/class/action/viewmoderateddownaction.class.php
plugins/branches/lifetype-1.2/unported/karma/class/karma/karmalib.class.php
plugins/branches/lifetype-1.2/unported/karma/pluginkarma.class.php
plugins/branches/lifetype-1.2/unported/karma/readme.txt
Log:
Ported the 'karma' plugin to LT 1.2.
Modified: plugins/branches/lifetype-1.2/unported/karma/class/action/adminkarmapluginsettingsaction.class.php
===================================================================
--- plugins/branches/lifetype-1.2/unported/karma/class/action/adminkarmapluginsettingsaction.class.php 2007-03-15 20:00:31 UTC (rev 5101)
+++ plugins/branches/lifetype-1.2/unported/karma/class/action/adminkarmapluginsettingsaction.class.php 2007-03-15 20:05:17 UTC (rev 5102)
@@ -1,9 +1,9 @@
<?php
- lt_include( PLOG_CLASS_PATH."class/action/admin/blogowneradminaction.class.php" );
+ lt_include( PLOG_CLASS_PATH."class/action/admin/adminaction.class.php" );
lt_include( PLOG_CLASS_PATH."plugins/karma/class/view/adminkarmapluginsettingsview.class.php" );
- class AdminKarmaPluginSettingsAction extends BlogOwnerAdminAction
+ class AdminKarmaPluginSettingsAction extends AdminAction
{
/**
@@ -12,7 +12,9 @@
*/
function AdminKarmaPluginSettingsAction( $actionInfo, $request )
{
- $this->BlogOwnerAdminAction( $actionInfo, $request );
+ $this->AdminAction( $actionInfo, $request );
+
+ $this->requirePermission( "manage_plugins" );
}
/**
Modified: plugins/branches/lifetype-1.2/unported/karma/class/action/adminkarmapluginupdatesettingsaction.class.php
===================================================================
--- plugins/branches/lifetype-1.2/unported/karma/class/action/adminkarmapluginupdatesettingsaction.class.php 2007-03-15 20:00:31 UTC (rev 5101)
+++ plugins/branches/lifetype-1.2/unported/karma/class/action/adminkarmapluginupdatesettingsaction.class.php 2007-03-15 20:05:17 UTC (rev 5102)
@@ -1,6 +1,6 @@
<?php
- lt_include( PLOG_CLASS_PATH."class/action/admin/blogowneradminaction.class.php" );
+ lt_include( PLOG_CLASS_PATH."class/action/admin/adminaction.class.php" );
lt_include( PLOG_CLASS_PATH."plugins/karma/class/view/adminkarmapluginsettingsview.class.php" );
lt_include( PLOG_CLASS_PATH."plugins/karma/class/karma/karmalib.class.php" );
lt_include( PLOG_CLASS_PATH."class/dao/blogs.class.php" );
@@ -8,7 +8,7 @@
lt_include( PLOG_CLASS_PATH."class/dao/customfields/customfield.class.php" );
lt_include( PLOG_CLASS_PATH."class/data/validator/integervalidator.class.php" );
- class AdminKarmaPluginUpdateSettingsAction extends BlogOwnerAdminAction
+ class AdminKarmaPluginUpdateSettingsAction extends AdminAction
{
var $_pluginEnabled;
@@ -23,7 +23,9 @@
*/
function AdminKarmaPluginUpdateSettingsAction( $actionInfo, $request )
{
- $this->BlogOwnerAdminAction( $actionInfo, $request );
+ $this->AdminAction( $actionInfo, $request );
+
+ $this->requirePermission( "manage_plugins" );
}
function validate()
Modified: plugins/branches/lifetype-1.2/unported/karma/class/action/karmarateaction.class.php
===================================================================
--- plugins/branches/lifetype-1.2/unported/karma/class/action/karmarateaction.class.php 2007-03-15 20:00:31 UTC (rev 5101)
+++ plugins/branches/lifetype-1.2/unported/karma/class/action/karmarateaction.class.php 2007-03-15 20:05:17 UTC (rev 5102)
@@ -17,7 +17,7 @@
function KarmaRateAction( $actionInfo, $request )
{
$this->BlogAction( $actionInfo, $request );
- }
+ }
function validate()
{
@@ -91,7 +91,6 @@
$karmaVoters = new KarmaVoters();
if( $karmaVoters->clientHasVoted( $clientIp, $this->_articleId )) {
$voteAllowed = false;
- _debug("user $clientIp has already voted!<br/>");
$this->_view = new ErrorView( $this->_blogInfo );
$message = $this->_locale->tr("error_karma_vote_per_article");
$this->_view->setValue( "message", $message );
@@ -102,13 +101,11 @@
else {
$voteAllowed = true;
// and store a vote
- _debug("user is voting...<br/>");
$karmaVoters->storeClientVote( $clientIp, $this->_articleId );
}
}
else {
$voteAllowed = true;
- _debug("not tracking voters...<br/>");
}
// if we're allowing the user to vote...
@@ -138,14 +135,12 @@
$negativeScore = $article->getField( "negativeKarma" );
if( KarmaScoreLogic::karmaScore( $positiveScore, $negativeScore, $negativeThreshold, $pluginCoefficient ) == KARMA_SCORE_MODERATE_DOWN ) {
// check if the post has to be moderated down
- _debug("moderating down!");
if( $article->getStatus() != POST_STATUS_KARMA_MODERATED_DOWN ) {
$article->setStatus( POST_STATUS_KARMA_MODERATED_DOWN );
$articles->updateArticle( $article );
}
}
else {
- _debug("moderating up!");
// maybe it has to be moderated up!!
if( $article->getStatus() != POST_STATUS_PUBLISHED ) {
$article->setStatus( POST_STATUS_PUBLISHED );
Modified: plugins/branches/lifetype-1.2/unported/karma/class/action/viewmoderateddownaction.class.php
===================================================================
--- plugins/branches/lifetype-1.2/unported/karma/class/action/viewmoderateddownaction.class.php 2007-03-15 20:00:31 UTC (rev 5101)
+++ plugins/branches/lifetype-1.2/unported/karma/class/action/viewmoderateddownaction.class.php 2007-03-15 20:05:17 UTC (rev 5102)
@@ -31,7 +31,7 @@
$this->_postAmount = -1;
// also, inform the template that we're showing them all!
- $this->_view = new PluginTemplatedView( $this->_blogInfo, "karma", "moderateddownlist", SMARTY_VIEW_CACHE_DISABLE );
+ $this->_view = new PluginTemplatedView( $this->_blogInfo, "karma", "moderateddownlist", SMARTY_VIEW_CACHE_DISABLED );
$this->_view->setValue( "showAll", true );
// another flag indicating that we are showing the list of moderated down posts
Modified: plugins/branches/lifetype-1.2/unported/karma/class/karma/karmalib.class.php
===================================================================
--- plugins/branches/lifetype-1.2/unported/karma/class/karma/karmalib.class.php 2007-03-15 20:00:31 UTC (rev 5101)
+++ plugins/branches/lifetype-1.2/unported/karma/class/karma/karmalib.class.php 2007-03-15 20:05:17 UTC (rev 5102)
@@ -3,15 +3,11 @@
lt_include( PLOG_CLASS_PATH."class/dao/articles.class.php" );
lt_include( PLOG_CLASS_PATH."class/dao/model.class.php" );
- lt_include( PLOG_CLASS_PATH."debug.php" );
-
define( "PLUGIN_KARMA_DEFAULT_NEGATIVE_THRESHOLD", 3 );
define( "PLUGIN_KARMA_DEFAULT_COEFFICIENT", 1.5 );
define( "KARMA_SCORE_MODERATE_DOWN", 1 );
define( "KARMA_SCORE_MODERATE_UP", 2 );
- define( "DEBUG_ENABLED", false );
-
/**
* encapsulates the scoring logic
*
@@ -197,7 +193,7 @@
$query = "SELECT * FROM ".$this->getPrefix()."karma_voters
WHERE client_ip = '$clientIp' AND
article_id = $articleId";
- $this->_db->debug=false;
+
$result = $this->Execute( $query );
if( !$result )
@@ -220,8 +216,6 @@
$result = $this->Execute( $query );
- _debug("storing user vote ($clientIp) for blog=$blogId and article=$articleId<br/>");
-
return $result;
}
}
Modified: plugins/branches/lifetype-1.2/unported/karma/pluginkarma.class.php
===================================================================
--- plugins/branches/lifetype-1.2/unported/karma/pluginkarma.class.php 2007-03-15 20:00:31 UTC (rev 5101)
+++ plugins/branches/lifetype-1.2/unported/karma/pluginkarma.class.php 2007-03-15 20:05:17 UTC (rev 5102)
@@ -15,14 +15,15 @@
{
var $pluginEnabled;
- function PluginKarma()
+ function PluginKarma( $source )
{
- $this->PluginBase();
+ $this->PluginBase( $source );
$this->id = "karma";
$this->desc = "Implements karma rating for posts";
$this->author = "The LifeType Team";
$this->locales = Array();
+ $this->version = "20070315";
$this->init();
}
@@ -32,15 +33,18 @@
*/
function init()
{
- $this->registerBlogAction( "karmaRate", "KarmaRateAction" );
- $this->registerBlogAction( "viewModeratedDown", "ViewModeratedDownAction" );
- $this->registerBlogAction( "viewModeratedDownArticle", "ViewModeratedDownArticleAction" );
- $this->registerAdminAction( "karmaPluginSettings", "AdminKarmaPluginSettingsAction" );
- $this->registerAdminAction( "pluginKarmaUpdateSettings", "AdminKarmaPluginUpdateSettingsAction" );
-
- // add a menu entry
- $this->addMenuEntry( "/menu/Manage/managePosts", "karmaPluginSettings", "admin.php?op=karmaPluginSettings", "", true, false );
-
+ if( $this->getSource() == "index" ) {
+ $this->registerBlogAction( "karmaRate", "KarmaRateAction" );
+ $this->registerBlogAction( "viewModeratedDown", "ViewModeratedDownAction" );
+ }
+ else {
+ $this->registerBlogAction( "viewModeratedDownArticle", "ViewModeratedDownArticleAction" );
+ $this->registerAdminAction( "karmaPluginSettings", "AdminKarmaPluginSettingsAction" );
+ $this->registerAdminAction( "pluginKarmaUpdateSettings", "AdminKarmaPluginUpdateSettingsAction" );
+
+ // add a menu entry
+ $this->addMenuEntry( "/menu/Manage/managePosts", "karmaPluginSettings", "admin.php?op=karmaPluginSettings", "", true, false );
+ }
}
function register()
@@ -56,13 +60,9 @@
function pluginTemplatePage()
{
- $rg = new RawRequestGenerator($this->blogInfo);
-
- $rg->addParameter( "op", "viewModeratedDown" );
- $rg->addParameter( "blogId", $this->blogInfo->getId());
+ $rg = $this->blogInfo->getBlogRequestGenerator();
+ $templatePage = $rg->getIndexUrl()."?op=viewModeratedDown&blogId=".$this->blogInfo->getId();
- $templatePage = $rg->getIndexUrl().$rg->getRequest();
-
return $templatePage;
}
@@ -75,7 +75,7 @@
function getPositiveUrl( $post )
{
$url =& $this->blogInfo->getBlogRequestGenerator();
- $karmaUrl = $url->getBaseUrl()."/karma.php?op=karmaRate&mode=1&articleId=".$post->getId()."&blogId=".$post->getBlog();
+ $karmaUrl = $url->getBaseUrl()."/index.php?op=karmaRate&mode=1&articleId=".$post->getId()."&blogId=".$post->getBlog();
return $karmaUrl;
}
@@ -89,7 +89,7 @@
function getNegativeUrl( $post )
{
$url =& $this->blogInfo->getBlogRequestGenerator();
- $karmaUrl = $url->getBaseUrl()."/karma.php?op=karmaRate&mode=2&articleId=".$post->getId()."&blogId=".$post->getBlog();
+ $karmaUrl = $url->getBaseUrl()."/index.php?op=karmaRate&mode=2&articleId=".$post->getId()."&blogId=".$post->getBlog();
return $karmaUrl;
}
Modified: plugins/branches/lifetype-1.2/unported/karma/readme.txt
===================================================================
--- plugins/branches/lifetype-1.2/unported/karma/readme.txt 2007-03-15 20:00:31 UTC (rev 5101)
+++ plugins/branches/lifetype-1.2/unported/karma/readme.txt 2007-03-15 20:05:17 UTC (rev 5102)
@@ -12,7 +12,7 @@
4. $karma->getNegativeUrl($post) to get negative karma url
Install:
-1. Configurate your Host Block plugin in your LifeType control center
+1. Configure your the plugin in the Control Centre.
2. Modify you post.template with the follow code to get karma link:
{if !empty($karma)}
{if $karma->isEnabled()}
More information about the pLog-svn
mailing list