Wizard.pm 0000644 0000143 0000143 00000002201 07625324052 012210 0 ustar nobody nobody # ================================================================== # Auto Generated Plugin Configuration - Needed for Web Based Creator. # # Plugins::GForum::Subscribe # Author : Joe Tan # Version : 1 # Updated : Thu Feb 20 23:18:35 2003 # # ================================================================== # package Plugins::GForum::Subscribe; # ================================================================== use strict; use vars qw/$WIZARD/; $WIZARD = { 'install' => '', 'files' => [], 'name' => 'Subscribe', 'menu' => [], 'uninstall' => '', 'hooks' => [ [ 'user_profile_email_change', 'PRE', 'Plugins::GForum::Subscribe::add_subscription', 'FIRST' ] ], 'meta' => { 'version' => '1', 'prog_ver' => '1.1.8', 'url' => 'http://forums.christianity.com', 'author' => 'Joe Tan', 'description' => 'Adds a PRE hook to forums subscription to allow for just one forum to be subscribed.', 'license' => 'Freeware' }, 'user' => [], 'install_code' => '', 'uninstall_code' => '' }; 1; Install.pm 0000644 0000143 0000143 00000007641 07625324233 012374 0 ustar nobody nobody # ================================================================== # Plugins::GForum::Subscribe - Auto Generated Install Module # # Plugins::GForum::Subscribe # Author : Joe Tan # Version : 1 # Updated : Thu Feb 20 23:18:35 2003 # # ================================================================== # package Plugins::GForum::Subscribe; # ================================================================== use strict; use vars qw/$VERSION $DEBUG $NAME $META/; use GT::Base; use GT::Plugins qw/STOP CONTINUE/; use GForum qw/$IN $DB $CFG/; $VERSION = '1'; $DEBUG = 0; $NAME = 'Subscribe'; # Inhert from base class for debug and error methods @Plugins::GForum::Subscribe::ISA = qw(GT::Base); $META = { 'version' => '1', 'prog_ver' => '1.1.8', 'url' => 'http://forums.christianity.com', 'author' => 'Joe Tan', 'description' => 'Adds a PRE hook to forums subscription to allow for just one forum to be subscribed.', 'license' => 'Freeware' }; sub pre_install { # ------------------------------------------------------------------- # This function displays an HTML formatted message that will display # to the user any instructions/information before they install # the plugin. # my $inst_msg = ''; return $inst_msg; } sub pre_uninstall { # ------------------------------------------------------------------- # This function displays an HTML formatted message that will display # to the user any instructions/information before they remove the # plugin. # my $uninst_msg = ''; return $uninst_msg; } sub install { # ------------------------------------------------------------------- # This function does the actual installation. It's 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::GForum::Subscribe::error # my ($mgr, $tar) = @_; $CFG->{functions}->{user_profile_email_add} = { action => 'function', customizable => { description => '1', page => '1', min_user_status => '1', user_groups => '1' }, description => 'Voting', function => 'Plugins::GForum::Subscribe::add_subscription_thankyou', hidden => '1', page => { thankyou => 'user_profile_email_add.html' } }; $CFG->save(); $mgr->install_hooks ( 'Subscribe', [ ['do_user_profile_email_change', 'PRE', 'Plugins::GForum::Subscribe::add_subscription', 'FIRST'] ]); my $file; # Install template files my @files = ('user_profile_email_add.html' ); for my $html (@files) { $file = $tar->get_file ("$html"); $file->name("$CFG->{admin_root_path}/templates/$CFG->{default_template_set}/$html"); unless ($file->write) { last; return Plugins::GForum::Poll->error("Unable to extract file: '$CFG->{admin_root_path}/templates/$CFG->{default_template_set}/$html' ($GT::Tar::error)", 'WARN'); } } return "The plugin has been successfully installed!"; } sub uninstall { # ------------------------------------------------------------------- # This function removes the plugin. It's 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::GForum::Subscribe::error # my $mgr = shift; $mgr->uninstall_hooks ( 'Subscribe', [ ['do_user_profile_email_change', 'PRE', 'Plugins::GForum::Subscribe::add_subscription', 'FIRST'] ]); delete $CFG->{functions}->{user_profile_email_add}; $CFG->save(); ; return "The plugin has been successfully removed!"; } 1; Subscribe.pm 0000644 0000143 0000143 00000004665 07625324233 012712 0 ustar nobody nobody # ================================================================== # Plugins::GForum::Subscribe - Auto Generated Program Module # # Plugins::GForum::Subscribe # Author : Joe Tan # Version : 1 # Updated : Thu Feb 20 23:18:35 2003 # # ================================================================== # package Plugins::GForum::Subscribe; # ================================================================== use strict; use GT::Base; use GT::Plugins qw/STOP CONTINUE/; use GForum qw/:forum $IN $DB $CFG $USER/; # Inherit from base class for debug and error methods @Plugins::GForum::Subscribe::ISA = qw(GT::Base); # Your code begins here! Good Luck! # PLUGIN HOOKS # =================================================================== sub add_subscription { my $update = $IN->param('update'); if ($update) { my $forum_id = $IN->param('forum'); my %subscribed = map { ($_->[0] => 1) } @{$DB->table('ForumSubscriber')->select(forum_id_fk => { user_id_fk => $USER->{user_id} })->fetchall_arrayref}; require GForum::Authenticate; if (GForum::Authenticate::auth('forum_permission', $forum_id) >= FORUM_PERM_READ ) { unless ($subscribed{$forum_id}) { $DB->table('ForumSubscriber')->insert({ forum_id_fk => $forum_id, user_id_fk => $USER->{user_id}, subsc_time => time, subsc_last => undef }); } } $GForum::Template::VARS{changes_saved} = 1; GForum::do_func($IN->param('next_do')); GT::Plugins->action ( STOP ); } else { GT::Plugins->action( CONTINUE ); } } # same as above, except jump to thankyou page sub add_subscription_thankyou { my $self = shift; my ($do, $func) = @_; my $page = $func->{page}; my $forum_id = $IN->param('forum'); my %subscribed = map { ($_->[0] => 1) } @{$DB->table('ForumSubscriber')->select(forum_id_fk => { user_id_fk => $USER->{user_id} })->fetchall_arrayref}; require GForum::Authenticate; my $status = ''; if (GForum::Authenticate::auth('forum_permission', $forum_id) >= FORUM_PERM_READ ) { unless ($subscribed{$forum_id}) { $DB->table('ForumSubscriber')->insert({ forum_id_fk => $forum_id, user_id_fk => $USER->{user_id}, subsc_time => time, subsc_last => undef }); $status = 'subscribe'; } else { $status = 'exist'; } } my $sth = $DB->table('Forum')->select( {forum_id => $forum_id} )->fetchrow_hashref; return ( $page->{thankyou} => { status => $status, forum_id => $forum_id, forum_name => $sth->{forum_name} } ); } # Always end with a 1. 1; user_profile_email_add.html 0000644 0000143 0000143 00000001723 07625460502 015766 0 ustar nobody nobody <%-- File ==== user_profile_email_add.html Description =========== Thankyou page after subscribing to one forum --%>