Wizard.pm 0000644 0002051 0000771 00000004550 11310650224 014037 0 ustar 00ultranerds ultranerds # ==================================================================
# Auto Generated Plugin Configuration - Needed for Web Based Creator.
#
# Plugins::ReviewAutoValidate
# Author : Andrew Newby
# Version : 1
# Updated : Sat Dec 12 00:16:27 2009
#
# ==================================================================
#
package Plugins::ReviewAutoValidate;
# ==================================================================
use strict;
use vars qw/$WIZARD/;
$WIZARD = {
'files' => [],
'hooks' => [
[
'review_add',
'POST',
'Plugins::ReviewAutoValidate::main',
undef
]
],
'install' => 'Lets you set a limit for the number of reviews a user must have validated by admin, before you treat them as a "trusted" contributer, and auto-validate their reviews',
'install_code' => '',
'menu' => [
[
'Readme',
'admin.cgi?do=plugin&plugin=ReviewAutoValidate&func=Readme'
]
],
'meta' => {
'author' => 'Andrew Newby',
'description' => 'Lets you set a limit for the number of reviews a user must have validated by admin, before you treat them as a "trusted" contributer, and auto-validate their reviews',
'license' => 'Freeware',
'prog_ver' => '3.2.0',
'url' => 'http://www.ultranerds.com',
'version' => '1'
},
'name' => 'ReviewAutoValidate',
'uninstall' => '',
'uninstall_code' => '',
'user' => [
[
'NumberOfReviewsRequired',
'5',
'Set this to the number of reviews you want to manually validate (for this user), before you trust them to be a valid contributor, and have their reviews auto-validated. For example, setting ot "5" will require the user to have contributed 5 ACTIVE reviews - and any more they add, will get auto-validated.',
'SELECT',
[
'10',
'9',
'8',
'7',
'6',
'5',
'4',
'3',
'2',
'1'
],
[
'10',
'9',
'8',
'7',
'6',
'5',
'4',
'3',
'2',
'1'
]
]
]
};
1;
Install.pm 0000644 0002051 0000771 00000010437 11310650533 014211 0 ustar 00ultranerds ultranerds # ==================================================================
# Plugins::ReviewAutoValidate - Auto Generated Install Module
#
# Plugins::ReviewAutoValidate
# Author : Andrew Newby
# Version : 1
# Updated : Sat Dec 12 00:16:27 2009
#
# ==================================================================
#
package Plugins::ReviewAutoValidate;
# ==================================================================
use strict;
use vars qw/$VERSION $DEBUG $NAME $META/;
use GT::Base;
use GT::Plugins qw/STOP CONTINUE/;
use Links qw/:objects/;
$VERSION = '1';
$DEBUG = 0;
$NAME = 'ReviewAutoValidate';
# Inhert from base class for debug and error methods
@Plugins::ReviewAutoValidate::ISA = qw(GT::Base);
$META = {
'author' => 'Andrew Newby',
'description' => 'Lets you set a limit for the number of reviews a user must have validated by admin, before you treat them as a "trusted" contributer, and auto-validate their reviews',
'license' => 'Freeware',
'prog_ver' => '3.2.0',
'url' => 'http://www.ultranerds.com',
'version' => '1'
};
sub pre_install {
# -----------------------------------------------------------------------------
# This function displays an HTML formatted message that will display any
# instructions/information to the user before they install the plugin.
#
my $inst_msg = 'Lets you set a limit for the number of reviews a user must have validated by admin, before you treat them as a "trusted" contributer, and auto-validate their reviews';
return $inst_msg;
}
sub pre_uninstall {
# -----------------------------------------------------------------------------
# This function displays an HTML formatted message that will display any
# instructions/information to the user before they remove the plugin.
#
my $uninst_msg = '';
return $uninst_msg;
}
sub install {
# -----------------------------------------------------------------------------
# This function does the actual installation. Its first argument is a plugin
# manager which you can use to register hooks, install files, add menu options,
# etc. The second argument is a GT::Tar object which you can use to access any
# files in your plugin module.
#
# You should return an HTML formatted string that will be displayed to the
# user.
#
# If there is an error, return undef, and set the error message in
# $Plugins::ReviewAutoValidate::error
#
my ($mgr, $tar) = @_;
$mgr->install_menu('ReviewAutoValidate', [['Readme', 'admin.cgi?do=plugin&plugin=ReviewAutoValidate&func=Readme']]);
$mgr->install_options('ReviewAutoValidate', [['NumberOfReviewsRequired', '5', 'Set this to the number of reviews you want to manually validate (for this user), before you trust them to be a valid contributor, and have their reviews auto-validated. For example, setting ot "5" will require the user to have contributed 5 ACTIVE reviews - and any more they add, will get auto-validated.', 'SELECT', ['10','9','8','7','6','5','4','3','2','1'], ['10','9','8','7','6','5','4','3','2','1'], '']]);
;
return "The plugin has been successfully installed!";
}
sub uninstall {
# -----------------------------------------------------------------------------
# This function removes the plugin. Its first argument is also a plugin
# manager which you can use to register hooks, install files, add menu options,
# etc. You should return an HTML formatted string that will be displayed to the
# user.
#
# If there is an error, return undef, and set the error message in
# $Plugins::ReviewAutoValidate::error
#
my $mgr = shift;
$mgr->uninstall_hooks('ReviewAutoValidate', [['review_add', 'POST', 'Plugins::ReviewAutoValidate::main', '']]); $mgr->uninstall_menu('ReviewAutoValidate', [['Readme', 'admin.cgi?do=plugin&plugin=ReviewAutoValidate&func=Readme']]);
$mgr->uninstall_options('ReviewAutoValidate', [['NumberOfReviewsRequired', '5', 'Set this to the number of reviews you want to manually validate (for this user), before you trust them to be a valid contributor, and have their reviews auto-validated. For example, setting ot "5" will require the user to have contributed 5 ACTIVE reviews - and any more they add, will get auto-validated.', 'SELECT', ['10','9','8','7','6','5','4','3','2','1'], ['10','9','8','7','6','5','4','3','2','1'], '']]);
;
return "The plugin has been successfully removed!";
}
1;
ReviewAutoValidate.pm 0000644 0002051 0000771 00000016663 11310650533 016356 0 ustar 00ultranerds ultranerds # ==================================================================
# Plugins::ReviewAutoValidate - Auto Generated Program Module
#
# Plugins::ReviewAutoValidate
# Author : Andrew Newby
# Version : 1
# Updated : Dec 12 2009
#
# ==================================================================
#
package Plugins::ReviewAutoValidate;
# ==================================================================
use strict;
use GT::Base;
use GT::Plugins qw/STOP CONTINUE/;
use Links qw/:objects/;
# Inherit from base class for debug and error methods
@Plugins::ReviewAutoValidate::ISA = qw(GT::Base);
# Your code begins here.
# PLUGIN HOOKS
# ===================================================================
# <%Plugins::ReviewAutoValidate::main%>
sub main {
# -----------------------------------------------------------------------------
# This subroutine will be called whenever the hook 'review_add' is run. You
# should call $PLG->action(STOP) if you don't want the regular
# 'review_add' code to run, otherwise the code will continue as normal.
#
# Do something useful here
if ($USER->{Username}) { # no point running this if they have the option for user required to off =)
use Links::Plugins;
my $PCFG = Links::Plugins::get_plugin_user_cfg ('ReviewAutoValidate');
# NumberOfReviewsRequired
my $review_id = $DB->table('Reviews')->select( ['MAX(ReviewID)'], { Review_Owner => $USER->{Username} } )->fetchrow;
my $users_total_validated_reviews = $DB->table('Reviews')->count( { Review_Validated => "Yes", Review_Owner => $USER->{Username} } ) || 0;
# print $IN->header;
# print qq|$users_total_validated_reviews >= $PCFG->{NumberOfReviewsRequired}
|;
# if greater, then lets validate this review..
if ($users_total_validated_reviews >= $PCFG->{NumberOfReviewsRequired}) {
$DB->table('Reviews')->update( { Review_Validated => "Yes" }, { ReviewID => $review_id } ) || die $GT::SQL::error;
my $review = $DB->table('Reviews')->select( { ReviewID => $review_id, Review_Owner => $USER->{Username} } )->fetchrow_hashref;
# Format the date
Links::init_date();
$review->{Review_Date} = GT::Date::date_transform($review->{Review_Date}, '%yyyy%-%mm%-%dd%', $CFG->{date_user_format});
if ($CFG->{email_add}) {
Links::send_email('review_added.eml', $review) or return Links::language('VAL_CANTEMAIL', $GT::Mail::error);
}
}
}
return;
}
# ADMIN MENU OPTIONS
# ===================================================================
sub Readme {
# -------------------------------------------------------------------
# This subroutine will be called whenever the user clicks on 'Readme' in the
# admin menu. Remember, you need to print your own HTTP header; to do so you
# can use:
#
print $IN->header();
print q|
ReviewAutoValidate Readme
Version: 1.0.0
Release Date: 12th December 2009
Author: Andy Newby (Ultranerds.com)
All you need to do, is edit the settings here, and update the template as explained a little further down this document.
The main requirements are as follows:
Lets you set a limit for the number of reviews a user must have validated by admin, before you treat them as a "trusted" contributor, and auto-validate their reviews
In review_add_success.html, you need to add the following (anywhere in the template, but probably better at the very top of it)
<%Plugins::ReviewAutoValidate::main%>
There is only one plugin option, and you can edit it via Plugins > Plugin Manager , then find ReviewAutoValidate and click [edit] next to it.
If you need help, please bear in mind this is a free plugin, you can use either of the following methods to get support;
© Ultranerds.com, All Rights Reserved. 2002-2009. A division of PUGDOG Enterprises ®
|; } # Always end with a 1. 1;