#!/usr/bin/perl use strict; my($MT_DIR); BEGIN { if ($0 =~ m!(.*[/\\])!) { $MT_DIR = $1; } else { $MT_DIR = './'; } unshift @INC, $MT_DIR . 'lib'; unshift @INC, $MT_DIR . 'extlib'; } local $| = 1; print "Content-Type: text/html\n\n"; print "
\n\n";
eval {
local $SIG{__WARN__} = sub { print "**** WARNING: $_[0]\n" };
require MT;
if (MT->version_number < 3.1) {
print "You have not yet upgraded to the 3.0 version of MT. Please do that before you run this script. Exiting..."; exit;
}
my $mt = MT->new( Config => $MT_DIR . 'mt.cfg')
or die MT->errstr;
require MT::PluginData;
foreach my $subcat_data (MT::PluginData->load ({plugin=>'SubCategories'})) {
my $cat = MT::Category->load ($subcat_data->key) or next;
my $d = $subcat_data->data;
my $parent = (ref ($d) eq 'HASH') ? $d->{'parent'} : $$d;
print "Setting the parent of ".$cat->label." to category id $parent.\n";
$cat->parent ($parent);
$cat->save;
}
};
if ($@) {
print <\n";