Gossamer Forum
Home : Products : Gossamer Links : Development, Plugins and Globals :

[BUG] PREFIX not available when installing plugins?

Quote Reply
[BUG] PREFIX not available when installing plugins?
Hi,

I was just trying to do the following in Install.pm for a plugin, to check if a table exists:

Code:
if (-e "$CFG->{admin_root_path}/defs/".$DB->{connect}->{PREFIX} ."ReviewLinkSession.def") {

..but it seems $DB is coming up as undef . Is there a reason for this?

BTW, I know we can use $DB->prefix to get the prefix - but I was just wondering why it didn't exist here Smile

Cheers

Andy (mod)
andy@ultranerds.co.uk


IMPORTANT: I've now moved to ultranerds.co.uk, and the .com will no longer work!
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package (plugins total "value" $3,325 & rising, for just $350)| GLinks ULTRA Package PRO (plugins total "value" $5,625 & rising, for just $500)
Support Forum | Links SQL Plugins | DMOZ Dumps | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Compare our different Plugin packages *new* Free CSS Templates
Quote Reply
Re: [Andy] [BUG] PREFIX not available when installing plugins? In reply to
It should be available. Did you import $DB?

Adrian
Quote Reply
Re: [brewt] [BUG] PREFIX not available when installing plugins? In reply to
Yeah, as $DB->creator is working fine - its just $DB->{connect} etc that doesn't seem to exist. Here is the Install.pm I tested with:

Code:
# ==================================================================
# Plugins::Test - Auto Generated Install Module
#
# Plugins::Test
# Author : Andrew Newby
# Version : 1
# Updated : Sat Nov 5 01:54:57 2011
#
# ==================================================================
#

package Plugins::Test;
# ==================================================================
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 = 'Test';
# Inhert from base class for debug and error methods
@Plugins::Test::ISA = qw(GT::Base);

$META = {
'author' => 'Andrew Newby',
'description' => 'Testing',
'license' => 'Freeware',
'prog_ver' => '3.2.0',
'url' => '',
'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 = '';

use Data::Dumper;
print "<pre>". Dumper($DB) . "</pre>";

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::Test::error
#
my ($mgr, $tar) = @_;

use Data::Dumper;
print "<pre>". Dumper($DB) . "</pre>";

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::Test::error
#
my $mgr = shift;

;
return "The plugin has been successfully removed!";
}

1;

As you can see from the screenshots, it just gives:

Code:
$VAR1 = bless( {}, 'GT::Delay' );

Its not a biggie - just wanted to let you know Smile

Cheers

Andy (mod)
andy@ultranerds.co.uk


IMPORTANT: I've now moved to ultranerds.co.uk, and the .com will no longer work!
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package (plugins total "value" $3,325 & rising, for just $350)| GLinks ULTRA Package PRO (plugins total "value" $5,625 & rising, for just $500)
Support Forum | Links SQL Plugins | DMOZ Dumps | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Compare our different Plugin packages *new* Free CSS Templates