Tags:
plugin1Add my vote for this tag upgrade1Add my vote for this tag create new tag
, view all tags

Question

I would like to update the DBIQueryPlugin for use in version 4.2 (the original author has stated that he does not have time to do this).

It is making some method calls which appear to be redundant in the latest version (E.g. 'findUser' method on the 'Users' object).

I have spent a couple of hours searching through the Plugins, Codev and TWiki webs to see if I can find guidelines about what is required to update a Plugins for the new version, but I've come up blank. The best I could find was the Release Notes for version 4.2, but this still did not mention this specific problem (see DBIQueryPluginDev).

I'm obviously searching for the wrong thing, so I'm hoping someone can point me to a relevant topic which discusses what's required.

Cheers.

Environment

TWiki version: TWikiRelease04x02x00
TWiki plugins: DefaultPlugin, EmptyPlugin, InterwikiPlugin
Server OS: RedHat Linux
Web server: Apache
Perl version: 5.8
Client OS: Windows XP
Web Browser: Firefox
Categories: Plugins

-- DuncanKinnear - 18 Mar 2008

Answer

ALERT! If you answer a question - or someone answered one of your questions - please remember to edit the page and set the status to answered. The status selector is below the edit box.

OK, I've done a bit more analysis of the DBIQueryPlugin source code, and the only problem seems to be with a sub-routine for testing if a specified user is in a specified group. Here's the code snippet:

my $userObj = $TWiki::Plugins::SESSION->{users}->findUser($user);
return 0 unless defined $userObj;
return $userObj->isInList($group);

Where $user and $group are passed into the sub-routine.

Is there an easy way to do this with standard API methods? I could not see anything in TWikiFuncDotPm that could do this.

-- DuncanKinnear - 18 Mar 2008

You can use isGroupMember() of TWikiFuncDotPm, available since TWiki plugin API version 1.2.

It is good practice to use conditional code so that the plugin works on older and newer versions of TWiki. Untested example:

if( TWiki::Plugins::VERSION >= 1.2 ) {
    return TWiki::Func::isGroupMember( $group );
} else {
    my $userObj = $TWiki::Plugins::SESSION->{users}->findUser($user);
    return 0 unless defined $userObj;
    return $userObj->isInList($group);
}

-- PeterThoeny - 25 Apr 2008

Change status to:
Edit | Attach | Watch | Print version | History: r3 < r2 < r1 | Backlinks | Raw View | Raw edit | More topic actions
Topic revision: r3 - 2008-04-25 - PeterThoeny
 
  • Learn about TWiki  
  • Download TWiki
This site is powered by the TWiki collaboration platform Powered by Perl Hosted by OICcam.com Ideas, requests, problems regarding TWiki? Send feedback. Ask community in the support forum.
Copyright © 1999-2017 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.