From 71ee624718793432b1da731612c0ce17b3867c41 Mon Sep 17 00:00:00 2001 From: Colin Kuskie Date: Wed, 5 Nov 2008 05:05:16 +0000 Subject: [PATCH] Add the profile field needed by the UsersOnline macro. Internationalized the profile field label. --- docs/changelog/7.x.x.txt | 3 + docs/upgrades/upgrade_7.6.2-7.6.3.pl | 150 +++++++++++++++++++++++++++ lib/WebGUI/i18n/English/WebGUI.pm | 6 ++ 3 files changed, 159 insertions(+) create mode 100644 docs/upgrades/upgrade_7.6.2-7.6.3.pl diff --git a/docs/changelog/7.x.x.txt b/docs/changelog/7.x.x.txt index 3e0814b0b..2aace0c38 100644 --- a/docs/changelog/7.x.x.txt +++ b/docs/changelog/7.x.x.txt @@ -1,3 +1,6 @@ +7.6.3 + - fixed #8989: Missing profile field "showOnline" for the UsersOnline macro. + 7.6.2 - fixed: not allowed to add calendar events if in can edit group but not can add event group - sped up lineage changes significantly diff --git a/docs/upgrades/upgrade_7.6.2-7.6.3.pl b/docs/upgrades/upgrade_7.6.2-7.6.3.pl new file mode 100644 index 000000000..dafaa2680 --- /dev/null +++ b/docs/upgrades/upgrade_7.6.2-7.6.3.pl @@ -0,0 +1,150 @@ +#------------------------------------------------------------------- +# WebGUI is Copyright 2001-2008 Plain Black Corporation. +#------------------------------------------------------------------- +# Please read the legal notices (docs/legal.txt) and the license +# (docs/license.txt) that came with this distribution before using +# this software. +#------------------------------------------------------------------- +# http://www.plainblack.com info@plainblack.com +#------------------------------------------------------------------- + +our ($webguiRoot); + +BEGIN { + $webguiRoot = "../.."; + unshift (@INC, $webguiRoot."/lib"); +} + +use strict; +use Getopt::Long; +use WebGUI::Session; +use WebGUI::Storage; +use WebGUI::Asset; + + +my $toVersion = "7.6.3"; # make this match what version you're going to +my $quiet; # this line required + + +my $session = start(); # this line required +# upgrade functions go here +createFieldShowOnline($session); + +finish($session); # this line required + + +#---------------------------------------------------------------------------- +# Describe what our function does +#sub exampleFunction { +# my $session = shift; +# print "\tWe're doing some stuff here that you should know about... " unless $quiet; +# # and here's our code +# print "DONE!\n" unless $quiet; +#} + +sub createFieldShowOnline { + my $session = shift; + print "\tCreating an additional profile field 'showOnline' for the UsersOnline macro... " unless $quiet; + + # Define field properties + my $properties = { + label => q!WebGUI::International::get('Show when online?','WebGUI')!, + visible => 1, + required => 0, + protected => 1, # The UsersOnline macro requires this field for working properly. + editable => 1, + fieldType => 'YesNo', + dataDefault => 0 # Users are not shown by default. + }; + # Create field in category "preferences" + my $field = WebGUI::ProfileField->create($session, 'showOnline', $properties, 4); + + # Check for failure + if ($field == undef) { + print "Creation of the field 'showOnline' failed, possibly because it does already exist. Note that this may cause the UsersOnline macro not to work properly.\n"; + } + else { + print "DONE!\n" unless $quiet; + } + + return; +} + +# -------------- DO NOT EDIT BELOW THIS LINE -------------------------------- + +#---------------------------------------------------------------------------- +# Add a package to the import node +sub addPackage { + my $session = shift; + my $file = shift; + + # Make a storage location for the package + my $storage = WebGUI::Storage->createTemp( $session ); + $storage->addFileFromFilesystem( $file ); + + # Import the package into the import node + my $package = WebGUI::Asset->getImportNode($session)->importPackage( $storage ); + + # Make the package not a package anymore + $package->update({ isPackage => 0 }); + + # Set the default flag for templates added + my $assetIds + = $package->getLineage( ['self','descendants'], { + includeOnlyClasses => [ 'WebGUI::Asset::Template' ], + } ); + for my $assetId ( @{ $assetIds } ) { + my $asset = WebGUI::Asset->newByDynamicClass( $session, $assetId ); + if ( !$asset ) { + print "Couldn't instantiate asset with ID '$assetId'. Please check package '$file' for corruption.\n"; + next; + } + $asset->update( { isDefault => 1 } ); + } + + return; +} + +#------------------------------------------------- +sub start { + my $configFile; + $|=1; #disable output buffering + GetOptions( + 'configFile=s'=>\$configFile, + 'quiet'=>\$quiet + ); + my $session = WebGUI::Session->open($webguiRoot,$configFile); + $session->user({userId=>3}); + my $versionTag = WebGUI::VersionTag->getWorking($session); + $versionTag->set({name=>"Upgrade to ".$toVersion}); + return $session; +} + +#------------------------------------------------- +sub finish { + my $session = shift; + updateTemplates($session); + my $versionTag = WebGUI::VersionTag->getWorking($session); + $versionTag->commit; + $session->db->write("insert into webguiVersion values (".$session->db->quote($toVersion).",'upgrade',".$session->datetime->time().")"); + $session->close(); +} + +#------------------------------------------------- +sub updateTemplates { + my $session = shift; + return undef unless (-d "packages-".$toVersion); + print "\tUpdating packages.\n" unless ($quiet); + opendir(DIR,"packages-".$toVersion); + my @files = readdir(DIR); + closedir(DIR); + my $newFolder = undef; + foreach my $file (@files) { + next unless ($file =~ /\.wgpkg$/); + # Fix the filename to include a path + $file = "packages-" . $toVersion . "/" . $file; + addPackage( $session, $file ); + } +} + +#vim:ft=perl diff --git a/lib/WebGUI/i18n/English/WebGUI.pm b/lib/WebGUI/i18n/English/WebGUI.pm index 81cc4c7e5..f1c49fb6d 100644 --- a/lib/WebGUI/i18n/English/WebGUI.pm +++ b/lib/WebGUI/i18n/English/WebGUI.pm @@ -4141,6 +4141,12 @@ LongTruncOk=1

context => q{Column heading for the total logged in time for the user}, }, + 'Show when online?' => { + message => q{Show when online?}, + lastUpdated => 0, + context => q{Label for the user profile field used by the UsersOnline macro}, + }, + }; 1;