From: <de...@de...> - 2011-03-14 12:11:53
|
Author: DipuDeshmukh Date: 2011-03-14 07:11:46 -0500 (Mon, 14 Mar 2011) New Revision: 20721 Trac url: http://develop.twiki.org/trac/changeset/20721 Modified: twiki/trunk/XmlQueryPlugin/data/TWiki/XmlQueryPlugin.txt twiki/trunk/XmlQueryPlugin/lib/TWiki/Plugins/XmlQueryPlugin.pm Log: Item6663: Use DatabasePlugin for DB credential declarations, remove Windows hardcoding of workarea location Modified: twiki/trunk/XmlQueryPlugin/data/TWiki/XmlQueryPlugin.txt =================================================================== --- twiki/trunk/XmlQueryPlugin/data/TWiki/XmlQueryPlugin.txt 2011-03-14 04:05:38 UTC (rev 20720) +++ twiki/trunk/XmlQueryPlugin/data/TWiki/XmlQueryPlugin.txt 2011-03-14 12:11:46 UTC (rev 20721) @@ -1,4 +1,4 @@ -%META:TOPICINFO{author="PatrickDiamond" date="1155807559" format="1.0" version="1.70"}% +%META:TOPICINFO{author="TWikiContributor" date="1300053313" format="1.0" version="$Rev$"}% ---+!! <nop>XmlQuery TWiki Plugin This Plugin allows TWiki to process [[http://www.w3.org/XML/][XML]] Data using the [[http://www.w3.org/TR/xslt][XSLT]] language. @@ -447,11 +447,8 @@ This Plugin requires some disk space to store it's cache and the XML versions of each topic. The XML version of each topic takes around 1k on average. -The location of this disk space has several different defaults +The location of this disk space has a default * On TWiki4.0+ systems the plugin work area will be used /twiki_install_dir/pub/_work_area/XmlQueryPlugin - * On a pre TWiki4,0 Unix system /var/tmp/twiki_xml - * On a pre TWiki4,0 Windows system c:/.twiki_xml -The default disk location can be modifed by altering the $xmldir variable within <nop>XmlQueryPlugin.pm. The default maximum size for this disk space is 100Mb. This value can be modified by altering the $cachelimit variable within <nop>XmlQueryPlugin.pm. @@ -461,6 +458,8 @@ __Note:__ You do not need to install anything on the browser to use this plugin. The following instructions are for the administrator who installs the plugin on the server where TWiki is running. + * For an __automated installation__, run the [[%SCRIPTURL{configure}%][configure]] script and follow "Find More Extensions" in the in the __Extensions__ section. + * Download the ZIP file from the Plugin web (see below) * Unzip ==%TOPIC%.zip== in your twiki installation directory. Content: | *File:* | *Description:* | @@ -483,8 +482,9 @@ ---++ Plugin Info | Plugin Author: | TWiki:Main/PatrickDiamond | -| Plugin Version: | 16th Aug 2006 (V1.204) | -| Change History: | | +| Plugin Version: | 14th Mar 2011 ($REV$) | +| Change History: | | +| 2011-03-14: | TWikibug:Item6663: Remove hardcoded folder reference for Windows, use TWiki:Plugins.DatabaseContrib to provide connection services to the database -- TWiki:Main.DipuDeshmukh | | 16th Aug 2006: | removed unsafe plugin preferences | | 28th Feb 2006: | Documentation fixes <br/> Added script to check for required perl modules | | 9th Feb 2006: | Dakar compatibility | @@ -493,7 +493,7 @@ | 9th Sept 2005: | Added DBI access functions<br/>Added output parameter support | | 7th Dec 2004: | Small fix, metadata date format problem.<br/> Date fields are now being padded to correct width | | 10 Nov 2004: | Initial version | -| TWiki Dependency: | TWiki version 01 Feb 2003 or later | +| TWiki Dependency: | TWiki:Plugins.DatabaseContrib, TWiki version 01 Feb 2003 or later | | CPAN Dependencies: | CPAN:DBI, CPAN:XML::LibXML, CPAN:XML::LibXSLT, CPAN:XML::Simple, CPAN:Text::ParseWords, CPAN:Cache::Cache, CPAN:String::CRC, CPAN:LWP::UserAgent | | Other Dependencies: | | | Perl Version: | 5.6 | @@ -501,5 +501,5 @@ | Plugin Home: | http://TWiki.org/cgi-bin/view/Plugins/%TOPIC% | | Feedback: | http://TWiki.org/cgi-bin/view/Plugins/%TOPIC%Dev | -__Related Topics:__ %TWIKIWEB%.TWikiPreferences, %TWIKIWEB%.TWikiPlugins +__Related Topics:__ DatabaseContrib, DBIQueryPlugin, %TWIKIWEB%.TWikiPreferences, %TWIKIWEB%.TWikiPlugins Modified: twiki/trunk/XmlQueryPlugin/lib/TWiki/Plugins/XmlQueryPlugin.pm =================================================================== --- twiki/trunk/XmlQueryPlugin/lib/TWiki/Plugins/XmlQueryPlugin.pm 2011-03-14 04:05:38 UTC (rev 20720) +++ twiki/trunk/XmlQueryPlugin/lib/TWiki/Plugins/XmlQueryPlugin.pm 2011-03-14 12:11:46 UTC (rev 20721) @@ -26,11 +26,13 @@ # # ========================= + package TWiki::Plugins::XmlQueryPlugin; # change the package name and $pluginName!!! use TWiki; use TWiki::Func (); - +use TWiki::Contrib::DatabaseContrib; +use DBI; # ========================= use strict; use vars qw( @@ -43,39 +45,18 @@ $datadir $pubdir $libxslt_debug $dbi_connections - $allow_user_to_specify_dbi_connection ); BEGIN { $pluginName = 'XmlQueryPlugin'; # Name of this Plugin - ########################################################################### - # modify the following hash to include your database connection definations - ########################################################################### - $dbi_connections = { - 'xxxxx' => { - 'DBD' => 'dbi:mysql:database=xxxxxxxxxxxxxx;host=yyyyyyyyyyyyyy.zzzzz', - 'user' => 'uuuuuuuuuuuuuuuu', - 'password' => 'pppppppppp' - }, - 'clonethis' => { 'DBD' => '', 'user' => '', 'password' => '' }, - }; - ########################################################################### - # Modify the following variable to allow TWiki page authors to specify - # their own DBI connections instead of being limited to the above set. This - # is a potential security risk depending on which DBD drivers are installed - # on the instance of perl running TWiki e.g. if a DBD driver allowing access - # to local files is available that is a major security hole when this variable - # is set to 1. - ########################################################################### - $allow_user_to_specify_dbi_connection=1; ########################################################################### # The following settings control the location of the auto generated XML and # cache files, plus size limits. Placed here as they are not suitable Plugin # Preferences #################### - $xmldir = undef ; # undef = use platform specific default for plugin file storage + #$xmldir = undef ; # undef = use platform specific default for plugin file storage $cachelimit = 1024 * 1024 * 100 ; # default 100 meg $cacheexpires = 'never'; @@ -83,8 +64,8 @@ # do not modify below. Settings suitable for modification can be altered via WebPreferences # see Plugin documentation for more info on this $initialized = 0; - $VERSION = '1.204'; - $RELEASE = 'Dakar'; + $VERSION = '$Rev$'; + $RELEASE = '2011-03-14'; $debug = 0; $cache = undef; } @@ -144,19 +125,22 @@ } # ensure that the XMLDIR is correctly defined + + $xmldir = TWiki::Func::getWorkArea($pluginName); + TWiki::Func::writeDebug( + "- TWiki::Plugins::${pluginName}::initPlugin( xmldir: $xmldir )") + if $debug; + if (not defined $xmldir) { if( $TWiki::Plugins::VERSION >= 1.1 ) { - # TWiki 4.0+ provides a plugin work area - $xmldir = TWiki::Func::getWorkArea($pluginName); - } else { - $xmldir = '/var/tmp/twiki_xml'; + # TWiki 4.0+ provides a plugin work area + $xmldir = TWiki::Func::getWorkArea($pluginName); + } + else { + $xmldir = '/var/tmp/twiki_xml'; } - # override xmldir if it has a Unix style path on a Windows machine - $xmldir = 'c:/.twiki_xml' if $^O eq 'MSWin32' and $xmldir !~ /^\[a-z]\:/i; } - - # Plugin correctly initialized TWiki::Func::writeDebug( "- TWiki::Plugins::${pluginName}::initPlugin( $web.$topic ) is OK") @@ -1287,30 +1271,10 @@ TWiki::Func::writeDebug("TWiki::Plugins::XmlQueryPlugin::_dbi_connect $dbi_def $user ") if $debug; - # check if the dbi name actually maps to a predefined DBI connection setting - if ( exists $dbi_connections->{$dbi_def} ) { - - # if the predefined DBI connection has a user id setting then override the - # supplied user and password - if ( exists $dbi_connections->{$dbi_def}->{'user'} ) { - - # update the userid and password - $user = $dbi_connections->{$dbi_def}->{'user'}; - $password = $dbi_connections->{$dbi_def}->{'password'}; - } - $dbi_def = $dbi_connections->{$dbi_def}->{'DBD'}; - } elsif ($allow_user_to_specify_dbi_connection == 0) { - # unauthorized connection do not allow to proceed - return ( - undef, - _import_dbi_data_warning("Error DBI connection not authorized. Only the following connections are available: ". join(',',keys %$dbi_connections)) - ); - } - - # connect to DB - my $dbh = DBI->connect( $dbi_def, $user, $password ) or + my $dbh = db_connect( $dbi_def ) or return (undef,_import_dbi_data_warning('Error connecting to database ' . $DBI::errstr )); + TWiki::Func::writeDebug("TWiki::Plugins::XmlQueryPlugin::_dbi_connect connected") if $debug; |