first round of changes for the new session system
This commit is contained in:
parent
da95226072
commit
d4b7f2ce59
128 changed files with 2442 additions and 1478 deletions
|
|
@ -11,8 +11,6 @@ package WebGUI::Macro::AOIHits;
|
|||
#-------------------------------------------------------------------
|
||||
|
||||
use strict;
|
||||
use WebGUI::Session;
|
||||
use WebGUI::SQL;
|
||||
|
||||
=head1 NAME
|
||||
|
||||
|
|
@ -37,16 +35,15 @@ The value for the key that will be looked up.
|
|||
|
||||
#-------------------------------------------------------------------
|
||||
sub process {
|
||||
my (@param, $temp);
|
||||
@param = @_;
|
||||
my $key = $param[0];
|
||||
my $value = $param[1];
|
||||
my $session = shift;
|
||||
my $key = shift;
|
||||
my $value = shift;
|
||||
my $sql = "select count from passiveProfileAOI a, metaData_properties f
|
||||
where a.fieldId=f.fieldId
|
||||
and userId=".quote($session{user}{userId})."
|
||||
and fieldName=".quote($key)."
|
||||
and value=".quote($value);
|
||||
my ($count) = WebGUI::SQL->buildArray($sql);
|
||||
and userId=".$session->db->$session->db->quote($session->user->userId)."
|
||||
and fieldName=".$session->db->$session->db->quote($key)."
|
||||
and value=".$session->db->$session->db->quote($value);
|
||||
my ($count) = $session->db->buildArray($sql);
|
||||
return $count;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -11,8 +11,6 @@ package WebGUI::Macro::AOIRank;
|
|||
#-------------------------------------------------------------------
|
||||
|
||||
use strict;
|
||||
use WebGUI::Session;
|
||||
use WebGUI::SQL;
|
||||
|
||||
=head1 NAME
|
||||
|
||||
|
|
@ -37,16 +35,15 @@ Define which value, by it's ranking, will be displayed. The highest ranking is
|
|||
|
||||
#-------------------------------------------------------------------
|
||||
sub process {
|
||||
my (@param, $temp);
|
||||
@param = @_;
|
||||
my $key = $param[0];
|
||||
my $rank = $param[1] || 1; # 1 is highest rank
|
||||
my $session = shift;
|
||||
my $key = shift;
|
||||
my $rank = shift || 1; # 1 is highest rank
|
||||
$rank--; # Rank is zero based
|
||||
my $sql = "select value from passiveProfileAOI a, metaData_properties f
|
||||
where a.fieldId=f.fieldId
|
||||
and userId=".quote($session{user}{userId})."
|
||||
and fieldName=".quote($key)." order by a.count desc";
|
||||
my @values = WebGUI::SQL->buildArray($sql);
|
||||
and userId=".$session->db->$session->db->quote($session->user->userId)."
|
||||
and fieldName=".$session->db->$session->db->quote($key)." order by a.count desc";
|
||||
my @values = $session->db->buildArray($sql);
|
||||
return $values[$rank];
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -18,9 +18,6 @@ use WebGUI::Asset;
|
|||
use WebGUI::Asset::Template;
|
||||
use WebGUI::Grouping;
|
||||
use WebGUI::International;
|
||||
use WebGUI::Session;
|
||||
use WebGUI::SQL;
|
||||
use WebGUI::URL;
|
||||
use WebGUI::Utility;
|
||||
|
||||
=head1 NAME
|
||||
|
|
@ -45,7 +42,8 @@ Admin bar to the left of the screen.
|
|||
|
||||
#-------------------------------------------------------------------
|
||||
sub process {
|
||||
return "" unless ($session{var}{adminOn});
|
||||
my $session = shift;
|
||||
return "" unless ($session->var->isAdminOn);
|
||||
my @param = @_;
|
||||
my $templateId = $param[0] || "PBtmpl0000000000000090";
|
||||
my %var;
|
||||
|
|
@ -53,29 +51,29 @@ sub process {
|
|||
tie %hash, "Tie::IxHash";
|
||||
tie %hash2, "Tie::IxHash";
|
||||
tie %cphash, "Tie::CPHash";
|
||||
$var{'packages.canAdd'} = ($session{user}{uiLevel} >= 7);
|
||||
$var{'packages.canAdd'} = ($session->user->profileField("uiLevel") >= 7);
|
||||
$var{'packages.label'} = WebGUI::International::get(376,'Macro_AdminBar');
|
||||
$var{'contentTypes.label'} = WebGUI::International::get(1083,'Macro_AdminBar');
|
||||
$var{'clipboard.label'} = WebGUI::International::get(1082,'Macro_AdminBar');
|
||||
if (exists $session{asset}) {
|
||||
foreach my $package (@{$session{asset}->getPackageList}) {
|
||||
if ($session->asset) {
|
||||
foreach my $package (@{$session->asset->getPackageList}) {
|
||||
my $title = $package->getTitle;
|
||||
$title =~ s/'//g; # stops it from breaking the javascript menus
|
||||
push(@{$var{'package_loop'}},{
|
||||
'url'=>$session{asset}->getUrl("func=deployPackage;assetId=".$package->getId),
|
||||
'url'=>$session->asset->getUrl("func=deployPackage;assetId=".$package->getId),
|
||||
'label'=>$title,
|
||||
'icon.small'=>$package->getIcon(1),
|
||||
'icon'=>$package->getIcon()
|
||||
});
|
||||
}
|
||||
$var{contentTypes_loop} = $session{asset}->getAssetAdderLinks;
|
||||
$var{container_loop} = $session{asset}->getAssetAdderLinks(undef,"assetContainers");
|
||||
foreach my $asset (@{$session{asset}->getAssetsInClipboard(1)}) {
|
||||
$var{contentTypes_loop} = $session->asset->getAssetAdderLinks;
|
||||
$var{container_loop} = $session->asset->getAssetAdderLinks(undef,"assetContainers");
|
||||
foreach my $asset (@{$session->asset->getAssetsInClipboard(1)}) {
|
||||
my $title = $asset->getTitle;
|
||||
$title =~ s/'//g; # stops it from breaking the javascript menus
|
||||
push(@{$var{clipboard_loop}}, {
|
||||
'label'=>$title,
|
||||
'url'=>$session{asset}->getUrl("func=paste;assetId=".$asset->getId),
|
||||
'url'=>$session->asset->getUrl("func=paste;assetId=".$asset->getId),
|
||||
'icon.small'=>$asset->getIcon(1),
|
||||
'icon'=>$asset->getIcon()
|
||||
});
|
||||
|
|
@ -83,7 +81,7 @@ sub process {
|
|||
}
|
||||
#--admin functions
|
||||
$var{adminConsole_loop} = WebGUI::AdminConsole->getAdminFunction;
|
||||
return WebGUI::Asset::Template->new($templateId)->process(\%var);
|
||||
return WebGUI::Asset::Template->new($session,$templateId)->process(\%var);
|
||||
# 'http://validator.w3.org/check?uri=referer'=>WebGUI::International::get(399,'Macro_AdminBar'),
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -11,7 +11,6 @@ package WebGUI::Macro::AdminText;
|
|||
#-------------------------------------------------------------------
|
||||
|
||||
use strict;
|
||||
use WebGUI::Session;
|
||||
|
||||
=head1 NAME
|
||||
|
||||
|
|
@ -31,9 +30,10 @@ string is returned.
|
|||
=cut
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub process {
|
||||
sub process {
|
||||
my $session = shift;
|
||||
my @param = @_;
|
||||
return "" unless ($session{var}{adminOn});
|
||||
return "" unless ($session->var->get("adminOn"));
|
||||
return $param[0];
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -13,9 +13,7 @@ package WebGUI::Macro::AdminToggle;
|
|||
use strict;
|
||||
use WebGUI::Grouping;
|
||||
use WebGUI::International;
|
||||
use WebGUI::Session;
|
||||
use WebGUI::Asset::Template;
|
||||
use WebGUI::URL;
|
||||
|
||||
=head1 NAME
|
||||
|
||||
|
|
@ -48,6 +46,7 @@ A template from the Macro/AdminToggle namespace to use for formatting the link.
|
|||
|
||||
#-------------------------------------------------------------------
|
||||
sub process {
|
||||
my $session = shift;
|
||||
if (WebGUI::Grouping::isInGroup(12)) {
|
||||
my %var;
|
||||
my ($turnOn,$turnOff,$templateName) = @_;
|
||||
|
|
@ -61,9 +60,9 @@ sub process {
|
|||
$var{'toggle.text'} = $turnOn;
|
||||
}
|
||||
if ($templateName) {
|
||||
return WebGUI::Asset::Template->newByUrl($templateName)->process(\%var);
|
||||
return WebGUI::Asset::Template->newByUrl($session,$templateName)->process(\%var);
|
||||
} else {
|
||||
return WebGUI::Asset::Template->new("PBtmpl0000000000000036")->process(\%var);
|
||||
return WebGUI::Asset::Template->new($session,"PBtmpl0000000000000036")->process(\%var);
|
||||
}
|
||||
}
|
||||
return "";
|
||||
|
|
|
|||
|
|
@ -13,8 +13,6 @@ package WebGUI::Macro::AssetProxy;
|
|||
use strict;
|
||||
use Time::HiRes;
|
||||
use WebGUI::Asset;
|
||||
use WebGUI::ErrorHandler;
|
||||
use WebGUI::Session;
|
||||
use WebGUI::International;
|
||||
|
||||
=head1 NAME
|
||||
|
|
@ -39,14 +37,15 @@ Admin is turned on.
|
|||
|
||||
#-------------------------------------------------------------------
|
||||
sub process {
|
||||
my $session = shift;
|
||||
my $url = shift;
|
||||
my $t = [Time::HiRes::gettimeofday()] if (WebGUI::ErrorHandler::canShowPerformanceIndicators());
|
||||
my $asset = WebGUI::Asset->newByUrl($url);
|
||||
my $t = [Time::HiRes::gettimeofday()] if ($session->errorHandler->canShowPerformanceIndicators());
|
||||
my $asset = WebGUI::Asset->newByUrl($session,$url);
|
||||
#Sorry, you cannot proxy the notfound page.
|
||||
if (defined $asset && $asset->getId ne $session{setting}{notFoundPage}) {
|
||||
if (defined $asset && $asset->getId ne $session->setting->get("notFoundPage")) {
|
||||
$asset->toggleToolbar;
|
||||
my $output = $asset->canView ? $asset->view : undef;
|
||||
$output .= "AssetProxy:".Time::HiRes::tv_interval($t) if (WebGUI::ErrorHandler::canShowPerformanceIndicators());
|
||||
$output .= "AssetProxy:".Time::HiRes::tv_interval($t) if ($session->errorHandler->canShowPerformanceIndicators());
|
||||
return $output;
|
||||
} else {
|
||||
return WebGUI::International::get('invalid url', 'Macro_AssetProxy');
|
||||
|
|
|
|||
|
|
@ -11,7 +11,6 @@ package WebGUI::Macro::At_username;
|
|||
#-------------------------------------------------------------------
|
||||
|
||||
use strict;
|
||||
use WebGUI::Session;
|
||||
|
||||
=head1 NAME
|
||||
|
||||
|
|
@ -27,7 +26,8 @@ Macro for displaying the current User's username.
|
|||
|
||||
#-------------------------------------------------------------------
|
||||
sub process {
|
||||
return $session{user}{username};
|
||||
my $session = shift;
|
||||
return $session->user->profileField("username");
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -11,7 +11,6 @@ package WebGUI::Macro::CanEditText;
|
|||
#-------------------------------------------------------------------
|
||||
|
||||
use strict;
|
||||
use WebGUI::Session;
|
||||
|
||||
=head1 NAME
|
||||
|
||||
|
|
@ -34,8 +33,9 @@ this asset, an empty string will be returned.
|
|||
|
||||
#-------------------------------------------------------------------
|
||||
sub process {
|
||||
my $session = shift;
|
||||
my @param = @_;
|
||||
if (exists $session{asset} && $session{asset}->canEdit) {
|
||||
if ($session->asset && $session->asset->canEdit) {
|
||||
return $param[0];
|
||||
} else {
|
||||
return "";
|
||||
|
|
|
|||
|
|
@ -38,6 +38,7 @@ time is used instead.
|
|||
|
||||
#-------------------------------------------------------------------
|
||||
sub process {
|
||||
my $session = shift;
|
||||
my (@param, $temp, $time);
|
||||
@param = @_;
|
||||
$time = $param[1] || time();
|
||||
|
|
|
|||
|
|
@ -13,9 +13,7 @@ package WebGUI::Macro::EditableToggle;
|
|||
use strict;
|
||||
use WebGUI::Grouping;
|
||||
use WebGUI::International;
|
||||
use WebGUI::Session;
|
||||
use WebGUI::Asset::Template;
|
||||
use WebGUI::URL;
|
||||
|
||||
=head1 NAME
|
||||
|
||||
|
|
@ -51,12 +49,13 @@ A template from the Macro/EditableToggle namespace to use for formatting the lin
|
|||
|
||||
#-------------------------------------------------------------------
|
||||
sub process {
|
||||
if (exists $session{asset} && $session{asset}->canEdit && WebGUI::Grouping::isInGroup(12)) {
|
||||
my $session = shift;
|
||||
if (exists $session->asset && $session->asset->canEdit && WebGUI::Grouping::isInGroup(12)) {
|
||||
my %var;
|
||||
my @param = @_;
|
||||
my $turnOn = $param[0] || WebGUI::International::get(516,'Macro_EditableToggle');
|
||||
my $turnOff = $param[1] || WebGUI::International::get(517,'Macro_EditableToggle');
|
||||
if ($session{var}{adminOn}) {
|
||||
if ($session->var->get("adminOn")) {
|
||||
$var{'toggle.url'} = WebGUI::URL::page('op=switchOffAdmin');
|
||||
$var{'toggle.text'} = $turnOff;
|
||||
} else {
|
||||
|
|
@ -64,9 +63,9 @@ sub process {
|
|||
$var{'toggle.text'} = $turnOn;
|
||||
}
|
||||
if ($param[2]) {
|
||||
return WebGUI::Asset::Template->newByUrl($param[2])->process(\%var);
|
||||
return WebGUI::Asset::Template->newByUrl($session,$param[2])->process(\%var);
|
||||
} else {
|
||||
return WebGUI::Asset::Template->new("PBtmpl0000000000000038")->process(\%var);
|
||||
return WebGUI::Asset::Template->new($session,"PBtmpl0000000000000038")->process(\%var);
|
||||
}
|
||||
}
|
||||
return "";
|
||||
|
|
|
|||
|
|
@ -11,7 +11,6 @@ package WebGUI::Macro::Env;
|
|||
#-------------------------------------------------------------------
|
||||
|
||||
use strict;
|
||||
use WebGUI::Session;
|
||||
|
||||
=head1 NAME
|
||||
|
||||
|
|
@ -32,7 +31,8 @@ then undef will be returned.
|
|||
|
||||
#-------------------------------------------------------------------
|
||||
sub process {
|
||||
return $session{env}{shift};
|
||||
my $session = shift;
|
||||
return $session->env->get(shift);
|
||||
}
|
||||
|
||||
1;
|
||||
|
|
|
|||
|
|
@ -33,6 +33,7 @@ be blocked and an error message returned instead.
|
|||
|
||||
#-------------------------------------------------------------------
|
||||
sub process {
|
||||
my $session = shift;
|
||||
my @param = @_;
|
||||
if ($param[0] =~ /passwd/ || $param[0] =~ /shadow/ || $param[0] =~ /\.conf/) {
|
||||
return WebGUI::International::get('execute error', 'Macro_Execute');
|
||||
|
|
|
|||
|
|
@ -11,7 +11,6 @@ package WebGUI::Macro::Extras;
|
|||
#-------------------------------------------------------------------
|
||||
|
||||
use strict;
|
||||
use WebGUI::Session;
|
||||
|
||||
=head1 NAME
|
||||
|
||||
|
|
@ -30,7 +29,8 @@ Returns the extrasURL. A trailing slash '/' is appended to the URL.
|
|||
|
||||
#-------------------------------------------------------------------
|
||||
sub process {
|
||||
return $session{config}{extrasURL}."/";
|
||||
my $session = shift;
|
||||
return $session->config->get("extrasURL")."/";
|
||||
}
|
||||
|
||||
1;
|
||||
|
|
|
|||
|
|
@ -11,7 +11,6 @@ package WebGUI::Macro::FetchMimeType; # edit this line to match your own macro n
|
|||
#-------------------------------------------------------------------
|
||||
|
||||
use strict;
|
||||
use WebGUI::Session;
|
||||
use LWP::MediaTypes qw(guess_media_type);
|
||||
|
||||
=head1 NAME
|
||||
|
|
@ -36,6 +35,7 @@ A path to a file
|
|||
|
||||
#-------------------------------------------------------------------
|
||||
sub process {
|
||||
my $session = shift;
|
||||
my $path = shift;
|
||||
return guess_media_type($path);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,7 +12,6 @@ package WebGUI::Macro::FileUrl;
|
|||
|
||||
use strict;
|
||||
use WebGUI::Asset;
|
||||
use WebGUI::Session;
|
||||
use WebGUI::Storage;
|
||||
use WebGUI::International;
|
||||
|
||||
|
|
@ -41,8 +40,9 @@ The URL to the Asset.
|
|||
|
||||
#-------------------------------------------------------------------
|
||||
sub process {
|
||||
my $session = shift;
|
||||
my $url = shift;
|
||||
my $asset = WebGUI::Asset->newByUrl($url);
|
||||
my $asset = WebGUI::Asset->newByUrl($session,$url);
|
||||
if (defined $asset) {
|
||||
my $storage = WebGUI::Storage->get($asset->get("storageId"));
|
||||
return $storage->getUrl($asset->get("filename"));
|
||||
|
|
|
|||
|
|
@ -11,7 +11,6 @@ package WebGUI::Macro::FormParam;
|
|||
#-------------------------------------------------------------------
|
||||
|
||||
use strict;
|
||||
use WebGUI::Session;
|
||||
|
||||
=head1 NAME
|
||||
|
||||
|
|
@ -33,7 +32,8 @@ The name of the field to pull from the session variable.
|
|||
|
||||
#-------------------------------------------------------------------
|
||||
sub process {
|
||||
return $session{req}->param(shift) if ($session{req});
|
||||
my $session = shift;
|
||||
return $session->form->process(shift);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -13,9 +13,7 @@ package WebGUI::Macro::GroupAdd;
|
|||
use strict;
|
||||
use WebGUI::Group;
|
||||
use WebGUI::Grouping;
|
||||
use WebGUI::Session;
|
||||
use WebGUI::Asset::Template;
|
||||
use WebGUI::URL;
|
||||
|
||||
=head1 NAME
|
||||
|
||||
|
|
@ -47,9 +45,10 @@ An optional template for formatting the text and link.
|
|||
#-------------------------------------------------------------------
|
||||
sub process {
|
||||
my @param = @_;
|
||||
my $session = shift;
|
||||
return "" if ($param[0] eq "");
|
||||
return "" if ($param[1] eq "");
|
||||
return "" if ($session{user}{userId} eq '1');
|
||||
return "" if ($session->user->userId eq '1');
|
||||
my $g = WebGUI::Group->find($param[0]);
|
||||
return "" if ($g->groupId eq "");
|
||||
return "" unless ($g->autoAdd);
|
||||
|
|
@ -58,9 +57,9 @@ sub process {
|
|||
$var{'group.url'} = WebGUI::URL::page("op=autoAddToGroup;groupId=".$g->groupId);
|
||||
$var{'group.text'} = $param[1];
|
||||
if ($param[2]) {
|
||||
return WebGUI::Asset::Template->newByUrl($param[2])->process(\%var);
|
||||
return WebGUI::Asset::Template->newByUrl($session,$param[2])->process(\%var);
|
||||
} else {
|
||||
return WebGUI::Asset::Template->new("PBtmpl0000000000000040")->process(\%var);
|
||||
return WebGUI::Asset::Template->new($session,"PBtmpl0000000000000040")->process(\%var);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -13,9 +13,7 @@ package WebGUI::Macro::GroupDelete;
|
|||
use strict;
|
||||
use WebGUI::Group;
|
||||
use WebGUI::Grouping;
|
||||
use WebGUI::Session;
|
||||
use WebGUI::Asset::Template;
|
||||
use WebGUI::URL;
|
||||
|
||||
=head1 NAME
|
||||
|
||||
|
|
@ -46,10 +44,11 @@ An optional template for formatting the text and link.
|
|||
|
||||
#-------------------------------------------------------------------
|
||||
sub process {
|
||||
my $session = shift;
|
||||
my @param = @_;
|
||||
return "" if ($param[0] eq "");
|
||||
return "" if ($param[1] eq "");
|
||||
return "" if ($session{user}{userId} eq '1');
|
||||
return "" if ($session->user->userId eq '1');
|
||||
my $g = WebGUI::Group->find($param[0]);
|
||||
return "" if ($g->groupId eq "");
|
||||
return "" unless ($g->autoDelete);
|
||||
|
|
@ -58,9 +57,9 @@ sub process {
|
|||
$var{'group.url'} = WebGUI::URL::page("op=autoDeleteFromGroup;groupId=".$g->groupId);
|
||||
$var{'group.text'} = $param[1];
|
||||
if ($param[2]) {
|
||||
return WebGUI::Asset::Template->newByUrl($param[2])->process(\%var);
|
||||
return WebGUI::Asset::Template->newByUrl($session,$param[2])->process(\%var);
|
||||
} else {
|
||||
return WebGUI::Asset::Template->new("PBtmpl0000000000000041")->process(\%var);
|
||||
return WebGUI::Asset::Template->new($session,"PBtmpl0000000000000041")->process(\%var);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -12,8 +12,6 @@ package WebGUI::Macro::GroupText;
|
|||
|
||||
use strict;
|
||||
use WebGUI::Grouping;
|
||||
use WebGUI::SQL;
|
||||
use WebGUI::Session;
|
||||
|
||||
=head1 NAME
|
||||
|
||||
|
|
@ -44,8 +42,9 @@ Text to be shown to someone not in the group.
|
|||
|
||||
#-------------------------------------------------------------------
|
||||
sub process {
|
||||
my $session = shift;
|
||||
my @param = @_;
|
||||
my ($groupId) = WebGUI::SQL->quickArray("select groupId from groups where groupName=".quote($param[0]),WebGUI::SQL->getSlave);
|
||||
my ($groupId) = $session->dbSlave->quickArray("select groupId from groups where groupName=".$session->db->quote($param[0]));
|
||||
$groupId = 3 if ($groupId eq "");
|
||||
if (WebGUI::Grouping::isInGroup($groupId)) {
|
||||
return $param[1];
|
||||
|
|
|
|||
|
|
@ -14,7 +14,6 @@ use strict;
|
|||
use WebGUI::Asset;
|
||||
use WebGUI::Asset::Template;
|
||||
use WebGUI::International;
|
||||
use WebGUI::Session;
|
||||
|
||||
=head1 NAME
|
||||
|
||||
|
|
@ -43,8 +42,9 @@ be used.
|
|||
|
||||
#-------------------------------------------------------------------
|
||||
sub process {
|
||||
my $session = shift;
|
||||
my ($label, $templateUrl) = @_;
|
||||
my $home = WebGUI::Asset->getDefault;
|
||||
my $home = WebGUI::Asset->getDefault($session);
|
||||
if ($label ne "linkonly") {
|
||||
my %var;
|
||||
$var{'homelink.url'} = $home->getUrl;
|
||||
|
|
@ -54,9 +54,9 @@ sub process {
|
|||
$var{'homeLink.text'} = WebGUI::International::get(47,'Macro_H_homeLink');
|
||||
}
|
||||
if ($templateUrl) {
|
||||
return WebGUI::Asset::Template->newByUrl($templateUrl)->process(\%var);
|
||||
return WebGUI::Asset::Template->newByUrl($session,$templateUrl)->process(\%var);
|
||||
} else {
|
||||
return WebGUI::Asset::Template->new("PBtmpl0000000000000042")->process(\%var);
|
||||
return WebGUI::Asset::Template->new($session,"PBtmpl0000000000000042")->process(\%var);
|
||||
}
|
||||
}
|
||||
return $home->getUrl;
|
||||
|
|
|
|||
|
|
@ -11,7 +11,6 @@ package WebGUI::Macro::Hash_userId;
|
|||
#-------------------------------------------------------------------
|
||||
|
||||
use strict;
|
||||
use WebGUI::Session;
|
||||
|
||||
=head1 NAME
|
||||
|
||||
|
|
@ -30,7 +29,8 @@ Returns the userId from the session variable for the current user.
|
|||
|
||||
#-------------------------------------------------------------------
|
||||
sub process {
|
||||
return $session{user}{userId};
|
||||
my $session = shift;
|
||||
return $session->user->userId;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1,63 +0,0 @@
|
|||
package WebGUI::Macro::If;
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
# WebGUI is Copyright 2001-2005 Plain Black Software.
|
||||
#-------------------------------------------------------------------
|
||||
# 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
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
|
||||
use strict;
|
||||
use WebGUI::International;
|
||||
use Safe;
|
||||
|
||||
=head1 NAME
|
||||
|
||||
Package WebGUI::Macro::If
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
A macro for implementing a simple conditional.
|
||||
|
||||
=head2 process ( expression, trueResult, falseResult )
|
||||
|
||||
Returns trueResult if expression is true, falseResult if the expression
|
||||
is false and an error message if there was a problem evaluating the
|
||||
expression.
|
||||
|
||||
=head3 expression
|
||||
|
||||
A perl expression that will be evaulated in a Safe compartment.
|
||||
|
||||
=head3 trueResult
|
||||
|
||||
Text that will be returned if the expression is true.
|
||||
|
||||
=head3 falseResult
|
||||
|
||||
Text that will be returned if the expression is false.
|
||||
|
||||
=cut
|
||||
|
||||
sub process {
|
||||
my ($expression, $true, $false) = @_;
|
||||
my $output = $false;
|
||||
|
||||
# Workaround to "Safely" eval $expression
|
||||
my $compartment = new Safe;
|
||||
my $return = $compartment->reval($expression);
|
||||
|
||||
return sprintf(WebGUI::International::get('eval error', 'Macro_If'),
|
||||
$@,$expression,$true,$false) if ($@);
|
||||
|
||||
$output = $true if ($return);
|
||||
|
||||
return $output;
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
|
|
@ -36,6 +36,7 @@ The complete path to a file in the local filesystem.
|
|||
|
||||
#-------------------------------------------------------------------
|
||||
sub process {
|
||||
my $self = shift;
|
||||
my (@param, $temp, $file);
|
||||
@param = @_;
|
||||
if ($param[0] =~ /passwd/ || $param[0] =~ /shadow/ || $param[0] =~ /WebGUI.conf/) {
|
||||
|
|
|
|||
|
|
@ -12,7 +12,6 @@ package WebGUI::Macro::International;
|
|||
|
||||
use strict;
|
||||
use WebGUI::International;
|
||||
use WebGUI::Session;
|
||||
|
||||
=head1 NAME
|
||||
|
||||
|
|
@ -41,6 +40,7 @@ The namespace to pull the label from.
|
|||
|
||||
#-------------------------------------------------------------------
|
||||
sub process {
|
||||
my $self = shift;
|
||||
return WebGUI::International::get(shift,shift);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -11,8 +11,6 @@ package WebGUI::Macro::JavaScript;
|
|||
#-------------------------------------------------------------------
|
||||
|
||||
use strict;
|
||||
use WebGUI::Session;
|
||||
use WebGUI::Style;
|
||||
|
||||
=head1 NAME
|
||||
|
||||
|
|
@ -20,7 +18,7 @@ Package WebGUI::Macro::JavaScript
|
|||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
This Macro is a wrapper for WebGUI::Style::setScript, which puts a script
|
||||
This Macro is a wrapper for $session->style->setScript, which puts a script
|
||||
tag into the head of the current page with the contents of the javascript
|
||||
found at the url that is passed in.
|
||||
|
||||
|
|
@ -35,7 +33,8 @@ URL to the javascript to include in the page's header tags.
|
|||
|
||||
#-------------------------------------------------------------------
|
||||
sub process {
|
||||
WebGUI::Style::setScript(shift,{type=>'text/javascript'});
|
||||
my $session = shift;
|
||||
$session->style->setScript(shift,{type=>'text/javascript'});
|
||||
return "";
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -13,9 +13,7 @@ package WebGUI::Macro::L_loginBox;
|
|||
use strict;
|
||||
use WebGUI::Form;
|
||||
use WebGUI::International;
|
||||
use WebGUI::Session;
|
||||
use WebGUI::Asset::Template;
|
||||
use WebGUI::URL;
|
||||
|
||||
=head1 NAME
|
||||
|
||||
|
|
@ -38,7 +36,9 @@ text to wrap in a link for logging out.
|
|||
|
||||
#-------------------------------------------------------------------
|
||||
sub _createURL {
|
||||
return '<a href="'.WebGUI::URL::page("op=auth;method=logout").'">'.$_[0].'</a>';
|
||||
my $session = shift;
|
||||
my $text = shift;
|
||||
return '<a href="'.WebGUI::URL::page("op=auth;method=logout").'">'.$text.'</a>';
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
|
@ -61,23 +61,24 @@ The ID of a template for custom layout of the login box and text.
|
|||
=cut
|
||||
|
||||
sub process {
|
||||
my $self = shift;
|
||||
my @param = @_;
|
||||
my $templateId = $param[2] || "PBtmpl0000000000000044";
|
||||
my %var;
|
||||
$var{'user.isVisitor'} = ($session{user}{userId} eq "1");
|
||||
$var{'user.isVisitor'} = ($session->user->profileField("userId") eq "1");
|
||||
$var{'customText'} = $param[1];
|
||||
$var{'customText'} =~ s/%(.*?)%/_createURL($1)/ge;
|
||||
$var{'customText'} =~ s/%(.*?)%/_createURL($session,$1)/ge;
|
||||
$var{'hello.label'} = WebGUI::International::get(48,'Macro_L_loginBox');
|
||||
$var{'logout.url'} = WebGUI::URL::page("op=auth;method=logout");
|
||||
$var{'account.display.url'} = WebGUI::URL::page('op=auth;method=displayAccount');
|
||||
$var{'logout.label'} = WebGUI::International::get(49,'Macro_L_loginBox');
|
||||
my $boxSize = $param[0];
|
||||
$boxSize = 12 unless ($boxSize);
|
||||
if (index(lc($ENV{HTTP_USER_AGENT}),"msie") < 0) {
|
||||
if (index(lc($session->env->get("HTTP_USER_AGENT")),"msie") < 0) {
|
||||
$boxSize = int($boxSize=$boxSize*2/3);
|
||||
}
|
||||
my $action;
|
||||
if ($session{setting}{encryptLogin}) {
|
||||
if ($session->setting->get("encryptLogin")) {
|
||||
$action = WebGUI::URL::page(undef,1);
|
||||
$action =~ s/http:/https:/;
|
||||
}
|
||||
|
|
@ -109,7 +110,7 @@ sub process {
|
|||
$var{'account.create.url'} = WebGUI::URL::page('op=auth;method=createAccount');
|
||||
$var{'account.create.label'} = WebGUI::International::get(407);
|
||||
$var{'form.footer'} = WebGUI::Form::formFooter();
|
||||
return WebGUI::Asset::Template->new($templateId)->process(\%var);
|
||||
return WebGUI::Asset::Template->new($session,$templateId)->process(\%var);
|
||||
}
|
||||
|
||||
1;
|
||||
|
|
|
|||
|
|
@ -13,9 +13,7 @@ package WebGUI::Macro::LastModified;
|
|||
use strict;
|
||||
use WebGUI::DateTime;
|
||||
use WebGUI::Asset;
|
||||
use WebGUI::Session;
|
||||
use WebGUI::International;
|
||||
use WebGUI::SQL;
|
||||
|
||||
=head1 NAME
|
||||
|
||||
|
|
@ -42,11 +40,12 @@ sprintf. See L<WebGUI::DateTime/"epochToHuman"> for a list of codes. Uses
|
|||
|
||||
#-------------------------------------------------------------------
|
||||
sub process {
|
||||
return '' unless $session{asset};
|
||||
my $session = shift;
|
||||
return '' unless $session->asset;
|
||||
my ($label, $format, $time);
|
||||
($label, $format) = @_;
|
||||
$format = '%z' if ($format eq "");
|
||||
($time) = WebGUI::SQL->quickArray("SELECT max(revisionDate) FROM assetData where assetId=".quote($session{asset}->getId),WebGUI::SQL->getSlave);
|
||||
($time) = $session->dbSlave->quickArray("SELECT max(revisionDate) FROM assetData where assetId=".$session->db->quote($session->asset->getId));
|
||||
return WebGUI::International::get('never','Macro_LastModified') if $time eq 0;
|
||||
return $label.epochToHuman($time,$format) if ($time);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -51,7 +51,7 @@ sub process {
|
|||
my $login = $param[0] || WebGUI::International::get(716,'Macro_LoginToggle');
|
||||
my $logout = $param[1] || WebGUI::International::get(717,'Macro_LoginToggle');
|
||||
my %var;
|
||||
if ($session{user}{userId} eq '1') {
|
||||
if ($session->user->profileField("userId") eq '1') {
|
||||
return WebGUI::URL::page("op=auth;method=init") if ($param[0] eq "linkonly");
|
||||
$var{'toggle.url'} = WebGUI::URL::page('op=auth;method=init');
|
||||
$var{'toggle.text'} = $login;
|
||||
|
|
|
|||
|
|
@ -11,7 +11,6 @@ package WebGUI::Macro::Page;
|
|||
#-------------------------------------------------------------------
|
||||
|
||||
use strict;
|
||||
use WebGUI::Session;
|
||||
|
||||
=head1 NAME
|
||||
|
||||
|
|
@ -28,14 +27,15 @@ session variable, returns a single space.
|
|||
|
||||
=head3 property
|
||||
|
||||
The name of the property to retrieve from the assset via $session{asset}->get()
|
||||
The name of the property to retrieve from the assset via $session->asset->get()
|
||||
|
||||
=cut
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub process {
|
||||
if (exists $session{asset}) {
|
||||
return $session{asset}->get(shift);
|
||||
my $session = shift;
|
||||
if ($session->asset) {
|
||||
return $session->asset->get(shift);
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,7 +11,6 @@ package WebGUI::Macro::PageTitle;
|
|||
#-------------------------------------------------------------------
|
||||
|
||||
use strict;
|
||||
use WebGUI::Session;
|
||||
|
||||
=head1 NAME
|
||||
|
||||
|
|
@ -31,11 +30,12 @@ no asset cached in the session variable, nothing is returned.
|
|||
|
||||
#-------------------------------------------------------------------
|
||||
sub process {
|
||||
if (exists $session{asset}) {
|
||||
if ($session{form}{op} || $session{form}{func}) {
|
||||
return '<a href="'.$session{asset}->getUrl.'">'.$session{asset}->get("title").'</a>';
|
||||
my $self = shift;
|
||||
if ($session->asset) {
|
||||
if ($session->form->process("op") || $session->form->process("func")) {
|
||||
return '<a href="'.$session->asset->getUrl.'">'.$session->asset->get("title").'</a>';
|
||||
} else {
|
||||
return $session{asset}->get("title");
|
||||
return $session->asset->get("title");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,8 +11,6 @@ package WebGUI::Macro::PageUrl;
|
|||
#-------------------------------------------------------------------
|
||||
|
||||
use strict;
|
||||
use WebGUI::Session;
|
||||
use WebGUI::URL;
|
||||
|
||||
=head1 NAME
|
||||
|
||||
|
|
@ -30,6 +28,7 @@ process is really a wrapper around WebGUI::URL::page();
|
|||
|
||||
#-------------------------------------------------------------------
|
||||
sub process {
|
||||
my $session = shift;
|
||||
return WebGUI::URL::page();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,10 +1,8 @@
|
|||
package WebGUI::Macro::Product;
|
||||
|
||||
use strict;
|
||||
use WebGUI::Session;
|
||||
use WebGUI::Product;
|
||||
use WebGUI::Asset::Template;
|
||||
use WebGUI::SQL;
|
||||
use WebGUI::International;
|
||||
|
||||
=head1 NAME
|
||||
|
|
@ -29,15 +27,16 @@ is left blank, a default template from the Macro/Product namespace will be used.
|
|||
=cut
|
||||
|
||||
sub process {
|
||||
my $session = shift;
|
||||
my (@param, $productId, $variantId, $product, $variant, $output, $templateId, @variantLoop, %var);
|
||||
|
||||
@param = @_;
|
||||
|
||||
return WebGUI::International::get('no sku or id','Macro_Product') unless ($_[0]);
|
||||
|
||||
($productId, $variantId) = WebGUI::SQL->quickArray("select productId, variantId from productVariants where sku=".quote($_[0]));
|
||||
($productId) = WebGUI::SQL->quickArray("select productId from products where sku=".quote($_[0])) unless ($productId);
|
||||
($productId) = WebGUI::SQL->quickArray("select productId from products where productId=".quote($_[0])) unless ($productId);
|
||||
($productId, $variantId) = $session->db->quickArray("select productId, variantId from productVariants where sku=".$session->db->quote($_[0]));
|
||||
($productId) = $session->db->quickArray("select productId from products where sku=".$session->db->quote($_[0])) unless ($productId);
|
||||
($productId) = $session->db->quickArray("select productId from products where productId=".$session->db->quote($_[0])) unless ($productId);
|
||||
|
||||
return WebGUI::International::get('cannot find product','Macro_Product') unless ($productId);
|
||||
|
||||
|
|
@ -75,7 +74,7 @@ sub process {
|
|||
$var{'variants.message'} = WebGUI::International::get('available product configurations', 'Macro_Product');
|
||||
$templateId = $_[1] || $product->get('templateId');
|
||||
|
||||
return WebGUI::Asset::Template->new($templateId)->process(\%var);
|
||||
return WebGUI::Asset::Template->new($ssession,$templateId)->process(\%var);
|
||||
}
|
||||
|
||||
1;
|
||||
|
|
|
|||
|
|
@ -11,7 +11,6 @@ package WebGUI::Macro::Quote;
|
|||
#-------------------------------------------------------------------
|
||||
|
||||
use strict;
|
||||
use WebGUI::SQL;
|
||||
|
||||
=head1 NAME
|
||||
|
||||
|
|
@ -23,7 +22,7 @@ Macro for quoting data to make it safe for use in SQL queries.
|
|||
|
||||
=head2 process ( text )
|
||||
|
||||
process is really a wrapper around WebGUI::SQL::quote();
|
||||
process is really a wrapper around WebGUI::SQL::$session->db->quote();
|
||||
|
||||
=head3 text
|
||||
|
||||
|
|
@ -33,7 +32,8 @@ The text to quote.
|
|||
|
||||
#-------------------------------------------------------------------
|
||||
sub process {
|
||||
return quote(shift);
|
||||
my $session = shift;
|
||||
return $session->db->quote(shift);
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -12,7 +12,6 @@ package WebGUI::Macro::RandomAssetProxy;
|
|||
|
||||
use strict;
|
||||
use WebGUI::Asset;
|
||||
use WebGUI::Session;
|
||||
use WebGUI::International;
|
||||
|
||||
=head1 NAME
|
||||
|
|
@ -35,14 +34,15 @@ if no asset exists at that url, or if the asset has no children.
|
|||
|
||||
#-------------------------------------------------------------------
|
||||
sub process {
|
||||
my $session = shift;
|
||||
my $url = shift;
|
||||
my $asset = WebGUI::Asset->newByUrl($url);
|
||||
my $asset = WebGUI::Asset->newByUrl($session, $url);
|
||||
if (defined $asset) {
|
||||
my $children = $asset->getLineage(["children"]);
|
||||
#randomize;
|
||||
srand;
|
||||
my $randomAssetId = $children->[rand(scalar(@{$children}))];
|
||||
my $randomAsset = WebGUI::Asset->newByDynamicClass($randomAssetId);
|
||||
my $randomAsset = WebGUI::Asset->newByDynamicClass($session,$randomAssetId);
|
||||
if (defined $randomAsset) {
|
||||
$randomAsset->toggleToolbar;
|
||||
return $randomAsset->canView ? $randomAsset->view() : undef;
|
||||
|
|
|
|||
|
|
@ -16,9 +16,6 @@ package WebGUI::Macro::RandomThread;
|
|||
use strict;
|
||||
use WebGUI::Asset;
|
||||
use WebGUI::Asset::Template;
|
||||
use WebGUI::ErrorHandler;
|
||||
use WebGUI::Macro;
|
||||
use WebGUI::Session;
|
||||
use WebGUI::Utility;
|
||||
|
||||
=head1 NAME
|
||||
|
|
@ -60,6 +57,7 @@ URL of the template to use to display the random thread. Must be a valid URL wit
|
|||
=cut
|
||||
|
||||
sub process {
|
||||
my $session = shift;
|
||||
my ($startURL, $relatives, $templateURL) = @_;
|
||||
# Seed the randomizer:
|
||||
srand;
|
||||
|
|
@ -70,33 +68,33 @@ sub process {
|
|||
my $numberOfTries = 2; # try this many times in case we select a thread the user cannot view
|
||||
|
||||
# Sanity check of parameters:
|
||||
my $startAsset = WebGUI::Asset->newByUrl($startURL);
|
||||
my $startAsset = WebGUI::Asset->newByUrl($session, $startURL);
|
||||
unless ($startAsset) {
|
||||
WebGUI::ErrorHandler::warn('Error: invalid startURL. Check parameters of macro on page '.$session{asset}->get('url'));
|
||||
$session->errorHandler->warn('Error: invalid startURL. Check parameters of macro on page '.$session->asset->get('url'));
|
||||
return '';
|
||||
}
|
||||
|
||||
$relatives = lc($relatives);
|
||||
unless ( isIn($relatives, ('siblings','children','ancestors','self','descendants','pedigree')) ) {
|
||||
WebGUI::ErrorHandler::warn('Error: invalid relatives specified. Must be one of siblings, children, ancestors, self, descendants, pedigree. Check parameters of macro on page '.$session{asset}->get('url'));
|
||||
$session->errorHandler->warn('Error: invalid relatives specified. Must be one of siblings, children, ancestors, self, descendants, pedigree. Check parameters of macro on page '.$session->asset->get('url'));
|
||||
return '';
|
||||
}
|
||||
|
||||
my $template = $templateURL ? WebGUI::Asset::Template->newByUrl($templateURL) : WebGUI::Asset::Template->new('WVtmpl0000000000000001');
|
||||
my $template = $templateURL ? WebGUI::Asset::Template->newByUrl($session,$templateURL) : WebGUI::Asset::Template->new($session,'WVtmpl0000000000000001');
|
||||
unless ($template) {
|
||||
WebGUI::ErrorHandler::warn('Error: invalid template URL. Check parameters of macro on page '.$session{asset}->get('url'));
|
||||
$session->errorHandler->warn('Error: invalid template URL. Check parameters of macro on page '.$session->asset->get('url'));
|
||||
return '';
|
||||
}
|
||||
|
||||
# Get all CS's that we'll use to pick a thread from:
|
||||
my $lineage = $startAsset->getLineage([$relatives],{includeOnlyClasses => ['WebGUI::Asset::Wobject::Collaboration']});
|
||||
unless ( scalar(@{$lineage}) ) {
|
||||
WebGUI::ErrorHandler::warn('Error: no Collaboration Systems found with current parameters. Check parameters of macro on page '.$session{asset}->get('url'));
|
||||
$session->errorHandler->warn('Error: no Collaboration Systems found with current parameters. Check parameters of macro on page '.$session->asset->get('url'));
|
||||
return '';
|
||||
}
|
||||
|
||||
# Try to get a random thread that the user can see:
|
||||
my $randomThread = _getRandomThread($lineage);
|
||||
my $randomThread = _getRandomThread($session, $lineage);
|
||||
my $i = 0;
|
||||
while ($i < $numberOfTries) {
|
||||
if($randomThread->canView()) {
|
||||
|
|
@ -105,21 +103,25 @@ sub process {
|
|||
return $template->process($var);
|
||||
} else {
|
||||
# Keep trying until we find a thread we can actually view:
|
||||
$randomThread = _getRandomThread($lineage);
|
||||
$randomThread = _getRandomThread($session, $lineage);
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
# If we reach this point, we had no success in finding an asset the user can view:
|
||||
WebGUI::ErrorHandler::warn("Could not find a random thread that was viewable by the user $session{user}{username} after $numberOfTries tries. Check parameters of macro on page ".$session{asset}->get('url'));
|
||||
$session->errorHandler->warn("Could not find a random thread that was viewable by the user $session->user->profileField("username") after $numberOfTries tries. Check parameters of macro on page ".$session->asset->get('url'));
|
||||
return '';
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 _getRandomThread ( lineage )
|
||||
=head2 _getRandomThread ( session, lineage )
|
||||
|
||||
Helper function that returns a random thread.
|
||||
|
||||
=head3 session
|
||||
|
||||
A reference to the current session.
|
||||
|
||||
=head3 lineage
|
||||
|
||||
Reference to an array with lineage of Collaboration Systems to select a random thread from.
|
||||
|
|
@ -127,18 +129,19 @@ Reference to an array with lineage of Collaboration Systems to select a random t
|
|||
=cut
|
||||
|
||||
sub _getRandomThread {
|
||||
my $session = shift;
|
||||
my $lineage = shift;
|
||||
|
||||
# Get random CS:
|
||||
my $randomIndex = int(rand(scalar(@{$lineage})));
|
||||
my $randomCSId = $lineage->[$randomIndex];
|
||||
my $randomCS = WebGUI::Asset->new($randomCSId,'WebGUI::Asset::Wobject::Collaboration');
|
||||
my $randomCS = WebGUI::Asset->new($session,$randomCSId,'WebGUI::Asset::Wobject::Collaboration');
|
||||
|
||||
# Get random thread in that CS:
|
||||
$lineage = $randomCS->getLineage(['children'],{includeOnlyClasses => ['WebGUI::Asset::Post::Thread']});
|
||||
$randomIndex = int(rand(scalar(@{$lineage})));
|
||||
my $randomThreadId = $lineage->[$randomIndex];
|
||||
return WebGUI::Asset->new($randomThreadId,'WebGUI::Asset::Post::Thread');
|
||||
return WebGUI::Asset->new($session,$randomThreadId,'WebGUI::Asset::Post::Thread');
|
||||
}
|
||||
|
||||
1;
|
||||
|
|
|
|||
|
|
@ -11,8 +11,6 @@ package WebGUI::Macro::RawHeadTags;
|
|||
#-------------------------------------------------------------------
|
||||
|
||||
use strict;
|
||||
use WebGUI::Session;
|
||||
use WebGUI::Style;
|
||||
|
||||
=head1 NAME
|
||||
|
||||
|
|
@ -24,7 +22,7 @@ Macro for adding
|
|||
|
||||
=head2 process ( tags )
|
||||
|
||||
process is a wrapper for WebGUI::Style::setRawHeadTags();
|
||||
process is a wrapper for $session->style->setRawHeadTags();
|
||||
|
||||
=head3 text
|
||||
|
||||
|
|
@ -34,7 +32,8 @@ Text that will be added to the HEAD tags for this page.
|
|||
|
||||
#-------------------------------------------------------------------
|
||||
sub process {
|
||||
WebGUI::Style::setRawHeadTags(shift);
|
||||
my $session = shift;
|
||||
$session->style->setRawHeadTags(shift);
|
||||
return "";
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -12,7 +12,6 @@ package WebGUI::Macro::RootTitle;
|
|||
|
||||
use strict;
|
||||
use WebGUI::Asset;
|
||||
use WebGUI::Session;
|
||||
|
||||
=head1 NAME
|
||||
|
||||
|
|
@ -32,10 +31,11 @@ is returned. Otherwise a space is returned.
|
|||
|
||||
#-------------------------------------------------------------------
|
||||
sub process {
|
||||
if (exists $session{asset}) {
|
||||
my $lineage = $session{asset}->get("lineage");
|
||||
my $session = shift;
|
||||
if ($session->asset) {
|
||||
my $lineage = $session->asset->get("lineage");
|
||||
$lineage = substr($lineage,0,6);
|
||||
my $root = WebGUI::Asset->newByLineage($lineage);
|
||||
my $root = WebGUI::Asset->newByLineage($session,$lineage);
|
||||
if (defined $root) {
|
||||
return $root->get("title");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,8 +11,6 @@ package WebGUI::Macro::SQL;
|
|||
#-------------------------------------------------------------------
|
||||
|
||||
use strict;
|
||||
use WebGUI::Session;
|
||||
use WebGUI::SQL;
|
||||
|
||||
=head1 NAME
|
||||
|
||||
|
|
@ -40,11 +38,12 @@ be used to position its output in the format.
|
|||
|
||||
#-------------------------------------------------------------------
|
||||
sub process {
|
||||
my $session = shift;
|
||||
my ($output, @data, $rownum, $temp);
|
||||
my ($statement, $format) = @_;
|
||||
$format = '^0;' if ($format eq "");
|
||||
if ($statement =~ /^\s*select/i || $statement =~ /^\s*show/i || $statement =~ /^\s*describe/i) {
|
||||
my $sth = WebGUI::SQL->unconditionalRead($statement,WebGUI::SQL->getSlave);
|
||||
my $sth = $session->dbSlave->unconditionalRead($statement);
|
||||
unless ($sth->errorCode < 1) {
|
||||
return sprintf WebGUI::International::get('sql error','Macro_SQL'), $sth->errorMessage;
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -11,8 +11,6 @@ package WebGUI::Macro::Slash_gatewayUrl;
|
|||
#-------------------------------------------------------------------
|
||||
|
||||
use strict;
|
||||
use WebGUI::Session;
|
||||
use WebGUI::URL;
|
||||
|
||||
=head1 NAME
|
||||
|
||||
|
|
@ -30,6 +28,7 @@ process is really a wrapper around WebGUI::URL::gateway();
|
|||
|
||||
#-------------------------------------------------------------------
|
||||
sub process {
|
||||
my $session = shift;
|
||||
return WebGUI::URL::gateway();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -11,7 +11,6 @@ package WebGUI::Macro::Spacer;
|
|||
#-------------------------------------------------------------------
|
||||
|
||||
use strict;
|
||||
use WebGUI::Session;
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
|
|
@ -39,11 +38,12 @@ Set the height of the spacer.
|
|||
=cut
|
||||
|
||||
sub process {
|
||||
my $session = shift;
|
||||
my ($output, @param, $width, $height);
|
||||
@param = @_;
|
||||
$width = $param[0] if defined $param[0];
|
||||
$height = $param[1] if defined $param[1];
|
||||
$output = '<img src="'.$session{config}{extrasURL}.'/spacer.gif"'.(defined $width?' width="'.$width.'"':'').(defined $height?' height="'.$height.'"':'').' border="0" alt="" />';
|
||||
$output = '<img src="'.$session->config->get("extrasURL").'/spacer.gif"'.(defined $width?' width="'.$width.'"':'').(defined $height?' height="'.$height.'"':'').' border="0" alt="" />';
|
||||
return $output;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -34,6 +34,7 @@ used as a default.
|
|||
|
||||
#-------------------------------------------------------------------
|
||||
sub process {
|
||||
my $session = shift;
|
||||
my ($temp, @param);
|
||||
@param = @_;
|
||||
if ($param[0] ne "") {
|
||||
|
|
|
|||
|
|
@ -11,8 +11,6 @@ package WebGUI::Macro::StyleSheet;
|
|||
#-------------------------------------------------------------------
|
||||
|
||||
use strict;
|
||||
use WebGUI::Session;
|
||||
use WebGUI::Style;
|
||||
|
||||
=head1 NAME
|
||||
|
||||
|
|
@ -24,7 +22,7 @@ Macro for dynamically adding references to CSS documents to use in this page.
|
|||
|
||||
=head2 process ( url )
|
||||
|
||||
process is a wrapper around WebGUI::Style::setLink().
|
||||
process is a wrapper around $session->style->setLink().
|
||||
|
||||
=head3 url
|
||||
|
||||
|
|
@ -34,7 +32,8 @@ The URL to the CSS document.
|
|||
|
||||
#-------------------------------------------------------------------
|
||||
sub process {
|
||||
WebGUI::Style::setLink(shift,{
|
||||
my $session = shift;
|
||||
$session->style->setLink(shift,{
|
||||
type=>'text/css',
|
||||
rel=>'stylesheet'
|
||||
});
|
||||
|
|
|
|||
|
|
@ -2,8 +2,6 @@ package WebGUI::Macro::SubscriptionItem;
|
|||
|
||||
use strict;
|
||||
use WebGUI::Asset::Template;
|
||||
use WebGUI::SQL;
|
||||
use WebGUI::URL;
|
||||
|
||||
=head1 NAME
|
||||
|
||||
|
|
@ -30,11 +28,12 @@ be used from the Macro/SubscriptionItem namespace.
|
|||
=cut
|
||||
|
||||
sub process {
|
||||
my $session = shift;
|
||||
my ($subscriptionId, $templateId, %var);
|
||||
($subscriptionId, $templateId) = @_;
|
||||
%var = WebGUI::SQL->quickHash('select * from subscription where subscriptionId='.quote($subscriptionId));
|
||||
%var = $session->db->quickHash('select * from subscription where subscriptionId='.$session->db->quote($subscriptionId));
|
||||
$var{url} = WebGUI::URL::page('op=purchaseSubscription;sid='.$subscriptionId);
|
||||
return WebGUI::Asset::Template->new($templateId || "PBtmpl0000000000000046")->process(\%var);
|
||||
return WebGUI::Asset::Template->new($session,$templateId || "PBtmpl0000000000000046")->process(\%var);
|
||||
}
|
||||
|
||||
1;
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
package WebGUI::Macro::SubscriptionItemPurchaseUrl;
|
||||
|
||||
use strict;
|
||||
use WebGUI::URL;
|
||||
|
||||
=head1 NAME
|
||||
|
||||
|
|
@ -23,6 +22,7 @@ The ID of the subscription item to purchase.
|
|||
=cut
|
||||
|
||||
sub process {
|
||||
my $session = shift;
|
||||
return WebGUI::URL::page('op=purchaseSubscription;sid='.shift);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -12,7 +12,6 @@ package WebGUI::Macro::Thumbnail;
|
|||
|
||||
use strict;
|
||||
use WebGUI::Asset::File::Image;
|
||||
use WebGUI::Session;
|
||||
|
||||
=head1 NAME
|
||||
|
||||
|
|
@ -33,8 +32,9 @@ Image Asset can be found with that URL, then undef will be returned.
|
|||
|
||||
#-------------------------------------------------------------------
|
||||
sub process {
|
||||
my $session = shift;
|
||||
my $url = shift;
|
||||
if (my $image = WebGUI::Asset::File::Image->newByUrl($url)) {
|
||||
if (my $image = WebGUI::Asset::File::Image->newByUrl($session,$url)) {
|
||||
return $image->getThumbnailUrl;
|
||||
} else {
|
||||
return undef;
|
||||
|
|
|
|||
|
|
@ -11,8 +11,6 @@ package WebGUI::Macro::URLEncode;
|
|||
#-------------------------------------------------------------------
|
||||
|
||||
use strict;
|
||||
use WebGUI::Session;
|
||||
use WebGUI::URL;
|
||||
|
||||
=head1 NAME
|
||||
|
||||
|
|
@ -35,6 +33,7 @@ The text to URL encode.
|
|||
|
||||
#-------------------------------------------------------------------
|
||||
sub process {
|
||||
my $session = shift;
|
||||
return WebGUI::URL::escape(shift);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -11,7 +11,6 @@ package WebGUI::Macro::User;
|
|||
#-------------------------------------------------------------------
|
||||
|
||||
use strict;
|
||||
use WebGUI::Session;
|
||||
|
||||
=head1 NAME
|
||||
|
||||
|
|
@ -30,7 +29,8 @@ the data stored in $session . If the field does not exist, undef is returned.
|
|||
|
||||
#-------------------------------------------------------------------
|
||||
sub process {
|
||||
return $session{user}{shift};
|
||||
my $session = shift;
|
||||
return $session->user->profileField(shift);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -11,10 +11,10 @@ package WebGUI::Macro::MacroSkeleton; # edit this line to match your own macro n
|
|||
#-------------------------------------------------------------------
|
||||
|
||||
use strict;
|
||||
use WebGUI::Session;
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub process {
|
||||
my $session = shift;
|
||||
my $somePassedInParameter = shift;
|
||||
my $someOtherPassedInParameter = shift;
|
||||
my $output = ""; # do some stuff
|
||||
|
|
|
|||
|
|
@ -12,9 +12,7 @@ package WebGUI::Macro::a_account;
|
|||
|
||||
use strict;
|
||||
use WebGUI::International;
|
||||
use WebGUI::Session;
|
||||
use WebGUI::Asset::Template;
|
||||
use WebGUI::URL;
|
||||
|
||||
=head1 NAME
|
||||
|
||||
|
|
@ -41,15 +39,16 @@ A template to use for formatting the link.
|
|||
|
||||
#-------------------------------------------------------------------
|
||||
sub process {
|
||||
my $session = shift;
|
||||
my %var;
|
||||
my @param = @_;
|
||||
return WebGUI::URL::page("op=auth;method=init") if ($param[0] eq "linkonly");
|
||||
$var{'account.url'} = WebGUI::URL::page('op=auth;method=init');
|
||||
$var{'account.text'} = $param[0] || WebGUI::International::get(46,'Macro_a_account');
|
||||
if ($param[1]) {
|
||||
return WebGUI::Asset::Template->newByUrl($param[1])->process(\%var);
|
||||
return WebGUI::Asset::Template->newByUrl($session,$param[1])->process(\%var);
|
||||
} else {
|
||||
return WebGUI::Asset::Template->new("PBtmpl0000000000000037")->process(\%var);
|
||||
return WebGUI::Asset::Template->new($session,"PBtmpl0000000000000037")->process(\%var);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -11,7 +11,6 @@ package WebGUI::Macro::c_companyName;
|
|||
#-------------------------------------------------------------------
|
||||
|
||||
use strict;
|
||||
use WebGUI::Session;
|
||||
|
||||
=head1 NAME
|
||||
|
||||
|
|
@ -29,7 +28,8 @@ returns the companyName from the session variable.
|
|||
|
||||
#-------------------------------------------------------------------
|
||||
sub process {
|
||||
return $session{setting}{companyName};
|
||||
my $session = shift;
|
||||
return $session->setting->get("companyName");
|
||||
}
|
||||
|
||||
1;
|
||||
|
|
|
|||
|
|
@ -11,7 +11,6 @@ package WebGUI::Macro::e_companyEmail;
|
|||
#-------------------------------------------------------------------
|
||||
|
||||
use strict;
|
||||
use WebGUI::Session;
|
||||
|
||||
=head1 NAME
|
||||
|
||||
|
|
@ -29,7 +28,8 @@ returns the companyEmail from the session variable.
|
|||
|
||||
#-------------------------------------------------------------------
|
||||
sub process {
|
||||
return $session{setting}{companyEmail};
|
||||
my $session = shift;
|
||||
return $session->setting->get("companyEmail");
|
||||
}
|
||||
|
||||
1;
|
||||
|
|
|
|||
|
|
@ -12,9 +12,7 @@ package WebGUI::Macro::r_printable;
|
|||
|
||||
use strict;
|
||||
use WebGUI::International;
|
||||
use WebGUI::Session;
|
||||
use WebGUI::Asset::Template;
|
||||
use WebGUI::URL;
|
||||
use WebGUI::Utility;
|
||||
|
||||
=head1 NAME
|
||||
|
|
@ -51,15 +49,16 @@ is used.
|
|||
|
||||
#-------------------------------------------------------------------
|
||||
sub process {
|
||||
my $session = shift;
|
||||
my ($temp, @param, $styleId);
|
||||
@param = @_;
|
||||
my $append = 'op=makePrintable';
|
||||
if ($session{env}{REQUEST_URI} =~ /op\=/) {
|
||||
if ($session->env->get("REQUEST_URI") =~ /op\=/) {
|
||||
$append = 'op2='.WebGUI::URL::escape($append);
|
||||
}
|
||||
$temp = WebGUI::URL::page($append);
|
||||
$temp =~ s/\/\//\//;
|
||||
$temp = WebGUI::URL::append($temp,$session{env}{QUERY_STRING});
|
||||
$temp = WebGUI::URL::append($temp,$session->env->get("QUERY_STRING"));
|
||||
if ($param[1] ne "") {
|
||||
$temp = WebGUI::URL::append($temp,'styleId='.$param[1]);
|
||||
}
|
||||
|
|
@ -72,9 +71,9 @@ sub process {
|
|||
$var{'printable.text'} = WebGUI::International::get(53,'Macro_r_printable');
|
||||
}
|
||||
if ($param[2]) {
|
||||
$temp = WebGUI::Asset::Template->newByUrl($param[2])->process(\%var);
|
||||
$temp = WebGUI::Asset::Template->newByUrl($session,$param[2])->process(\%var);
|
||||
} else {
|
||||
$temp = WebGUI::Asset::Template->new("PBtmpl0000000000000045")->process(\%var);
|
||||
$temp = WebGUI::Asset::Template->new($session,"PBtmpl0000000000000045")->process(\%var);
|
||||
}
|
||||
}
|
||||
return $temp;
|
||||
|
|
|
|||
|
|
@ -11,7 +11,6 @@ package WebGUI::Macro::u_companyUrl;
|
|||
#-------------------------------------------------------------------
|
||||
|
||||
use strict;
|
||||
use WebGUI::Session;
|
||||
|
||||
=head1 NAME
|
||||
|
||||
|
|
@ -30,7 +29,8 @@ returns the companyURL from the session variable.
|
|||
|
||||
#-------------------------------------------------------------------
|
||||
sub process {
|
||||
return $session{setting}{companyURL};
|
||||
my $session = shift;
|
||||
return $session->setting->get("companyURL");
|
||||
}
|
||||
|
||||
1;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue