Added new collateral management system.
This commit is contained in:
parent
0903f05a8f
commit
82b6bd33f8
13 changed files with 654 additions and 437 deletions
|
|
@ -29,6 +29,78 @@ insert into international (internationalId,languageId,namespace,message,lastUpda
|
|||
insert into settings values ("trackPageStatistics",0);
|
||||
alter table pageStatistics add column wobjectId int;
|
||||
alter table pageStatistics add column function varchar(60);
|
||||
alter table images rename collateral;
|
||||
alter table imageGroup rename collateralFolder;
|
||||
alter table collateral change imageId collateralId int not null;
|
||||
alter table collateral change imageGroupId collateralFolderId int not null;
|
||||
alter table collateralFolder change imageGroupId collateralFolderId int not null;
|
||||
alter table collateral add column collateralType varchar(30) not null default 'image';
|
||||
update incrementer set incrementerId='collateralId' where incrementerId='imageId';
|
||||
update incrementer set incrementerId='collateralFolderId' where incrementerId='imageGroupId';
|
||||
insert into help (helpId,namespace,titleId,bodyId,seeAlso) values (49, 'WebGUI', 785, 786, NULL);
|
||||
delete from international where languageId=1 and namespace='WebGUI' and internationalId=394;
|
||||
insert into international (internationalId,languageId,namespace,message,lastUpdated) values (394,1,'WebGUI','Manage collateral.', 1036954925);
|
||||
delete from international where namespace='WebGUI' and internationalId=393;
|
||||
insert into international (internationalId,languageId,namespace,message,lastUpdated) values (785,1,'WebGUI','Collateral, Manage', 1036954767);
|
||||
insert into international (internationalId,languageId,namespace,message,lastUpdated) values (786,1,'WebGUI','', 1036954767);
|
||||
insert into international (internationalId,languageId,namespace,message,lastUpdated) values (784,1,'WebGUI','Thumbnail', 1036954393);
|
||||
insert into international (internationalId,languageId,namespace,message,lastUpdated) values (783,1,'WebGUI','Type', 1036954378);
|
||||
insert into international (internationalId,languageId,namespace,message,lastUpdated) values (782,1,'WebGUI','Any', 1036913053);
|
||||
insert into international (internationalId,languageId,namespace,message,lastUpdated) values (781,1,'WebGUI','Snippet', 1036912954);
|
||||
insert into international (internationalId,languageId,namespace,message,lastUpdated) values (780,1,'WebGUI','File', 1036912946);
|
||||
insert into international (internationalId,languageId,namespace,message,lastUpdated) values (779,1,'WebGUI','Image', 1036912938);
|
||||
insert into international (internationalId,languageId,namespace,message,lastUpdated) values (778,1,'WebGUI','Folder Description', 1036906132);
|
||||
insert into international (internationalId,languageId,namespace,message,lastUpdated) values (777,1,'WebGUI','Folder Id', 1036905972);
|
||||
insert into international (internationalId,languageId,namespace,message,lastUpdated) values (776,1,'WebGUI','Edit Folder', 1036905944);
|
||||
insert into international (internationalId,languageId,namespace,message,lastUpdated) values (775,1,'WebGUI','Are you certain you wish to delete this folder and move its contents to it\'s parent folder?', 1036903002);
|
||||
insert into international (internationalId,languageId,namespace,message,lastUpdated) values (774,1,'WebGUI','Are you certain you wish to delete this collateral? It cannot be recovered once deleted.', 1036902945);
|
||||
insert into international (internationalId,languageId,namespace,message,lastUpdated) values (773,1,'WebGUI','File', 1036893165);
|
||||
insert into international (internationalId,languageId,namespace,message,lastUpdated) values (772,1,'WebGUI','Edit File', 1036893140);
|
||||
insert into international (internationalId,languageId,namespace,message,lastUpdated) values (771,1,'WebGUI','Snippet', 1036893079);
|
||||
insert into international (internationalId,languageId,namespace,message,lastUpdated) values (770,1,'WebGUI','Edit Snippet', 1036893050);
|
||||
insert into international (internationalId,languageId,namespace,message,lastUpdated) values (769,1,'WebGUI','Organize in Folder', 1036893015);
|
||||
insert into international (internationalId,languageId,namespace,message,lastUpdated) values (768,1,'WebGUI','Name', 1036892946);
|
||||
insert into international (internationalId,languageId,namespace,message,lastUpdated) values (767,1,'WebGUI','Collateral Id', 1036892929);
|
||||
insert into international (internationalId,languageId,namespace,message,lastUpdated) values (766,1,'WebGUI','Back to collateral list.', 1036892898);
|
||||
insert into international (internationalId,languageId,namespace,message,lastUpdated) values (765,1,'WebGUI','Delete this collateral item.', 1036892866);
|
||||
insert into international (internationalId,languageId,namespace,message,lastUpdated) values (764,1,'WebGUI','Edit this collateral item.', 1036892856);
|
||||
insert into international (internationalId,languageId,namespace,message,lastUpdated) values (763,1,'WebGUI','Add a snippet.', 1036892785);
|
||||
insert into international (internationalId,languageId,namespace,message,lastUpdated) values (762,1,'WebGUI','Add a file.', 1036892774);
|
||||
insert into international (internationalId,languageId,namespace,message,lastUpdated) values (761,1,'WebGUI','Add an image.', 1036892765);
|
||||
insert into international (internationalId,languageId,namespace,message,lastUpdated) values (760,1,'WebGUI','Delete this folder.', 1036892740);
|
||||
insert into international (internationalId,languageId,namespace,message,lastUpdated) values (759,1,'WebGUI','Edit this folder.', 1036892731);
|
||||
insert into international (internationalId,languageId,namespace,message,lastUpdated) values (758,1,'WebGUI','Add a folder.', 1036892705);
|
||||
insert into international (internationalId,languageId,namespace,message,lastUpdated) values (757,1,'WebGUI','Manage Collateral', 1036892669);
|
||||
insert into international (internationalId,languageId,namespace,message,lastUpdated) values (756,1,'WebGUI','Back to group list.', 1036867726);
|
||||
insert into international (internationalId,languageId,namespace,message,lastUpdated) values (754,1,'WebGUI','Manage the users in this group.', 1036866994);
|
||||
insert into international (internationalId,languageId,namespace,message,lastUpdated) values (753,1,'WebGUI','Edit this group.', 1036866979);
|
||||
insert into international (internationalId,languageId,namespace,message,lastUpdated) values (752,1,'WebGUI','View this user\'s profile.', 1036864965);
|
||||
insert into international (internationalId,languageId,namespace,message,lastUpdated) values (751,1,'WebGUI','Become this user.', 1036864905);
|
||||
insert into international (internationalId,languageId,namespace,message,lastUpdated) values (750,1,'WebGUI','Delete this user.', 1036864742);
|
||||
delete from international where namespace='WebGUI' and internationalId=393;
|
||||
delete from international where namespace='WebGUI' and internationalId=396;
|
||||
delete from international where namespace='WebGUI' and internationalId=397;
|
||||
delete from international where namespace='WebGUI' and internationalId=389;
|
||||
delete from international where namespace='WebGUI' and internationalId=383;
|
||||
delete from international where namespace='WebGUI' and internationalId=544;
|
||||
delete from international where namespace='WebGUI' and internationalId=545;
|
||||
delete from international where namespace='WebGUI' and internationalId=546;
|
||||
delete from international where namespace='WebGUI' and internationalId=547;
|
||||
delete from international where namespace='WebGUI' and internationalId=548;
|
||||
delete from international where namespace='WebGUI' and internationalId=549;
|
||||
delete from international where namespace='WebGUI' and internationalId=550;
|
||||
delete from international where namespace='WebGUI' and internationalId=392;
|
||||
delete from international where namespace='WebGUI' and internationalId=382;
|
||||
delete from international where namespace='WebGUI' and internationalId=390;
|
||||
delete from international where namespace='WebGUI' and internationalId=673;
|
||||
delete from international where namespace='WebGUI' and internationalId=628;
|
||||
delete from international where namespace='WebGUI' and internationalId=686;
|
||||
delete from international where namespace='WebGUI' and internationalId=641;
|
||||
delete from international where namespace='WebGUI' and internationalId=676;
|
||||
delete from international where namespace='WebGUI' and internationalId=631;
|
||||
delete from help where namespace='WebGUI' and helpId=26;
|
||||
delete from help where namespace='WebGUI' and helpId=23;
|
||||
delete from help where namespace='WebGUI' and helpId=36;
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -75,6 +75,7 @@ sub _replacement {
|
|||
'http://validator.w3.org/check?uri=http%3A%2F%2F'.$session{env}{SERVER_NAME}.
|
||||
WebGUI::URL::page()=>WebGUI::International::get(399),
|
||||
WebGUI::URL::page('op=viewPageTree')=>WebGUI::International::get(447),
|
||||
WebGUI::URL::page('op=listCollateral')=>WebGUI::International::get(394),
|
||||
%hash
|
||||
);
|
||||
}
|
||||
|
|
@ -96,12 +97,6 @@ sub _replacement {
|
|||
%hash
|
||||
);
|
||||
}
|
||||
if (WebGUI::Privilege::isInGroup($session{setting}{imageManagersGroup},$session{user}{userId})) {
|
||||
%hash = (
|
||||
WebGUI::URL::page('op=listImages')=>WebGUI::International::get(394),
|
||||
%hash
|
||||
);
|
||||
}
|
||||
%hash = (
|
||||
WebGUI::URL::page('op=viewHelpIndex')=>WebGUI::International::get(13),
|
||||
%hash
|
||||
|
|
|
|||
41
lib/WebGUI/Macro/File.pm
Normal file
41
lib/WebGUI/Macro/File.pm
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
package WebGUI::Macro::File;
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
# WebGUI is Copyright 2001-2002 Plain Black LLC.
|
||||
#-------------------------------------------------------------------
|
||||
# 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 Tie::CPHash;
|
||||
use WebGUI::Attachment;
|
||||
use WebGUI::Macro;
|
||||
use WebGUI::Session;
|
||||
use WebGUI::SQL;
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub _replacement {
|
||||
my (@param, $temp, %data, $file);
|
||||
tie %data, 'Tie::CPHash';
|
||||
@param = WebGUI::Macro::getParams($_[0]);
|
||||
%data = WebGUI::SQL->quickHash("select collateralId,filename,name from collateral where name=".quote($param[0]));
|
||||
$file = WebGUI::Attachment->new($data{filename},"images",$data{collateralId});
|
||||
$temp = '<a href="'.$file->getURL.'"><img src="'.$file->getIcon.'" align="middle" border="0" /> '.$data{name}.'</a>';
|
||||
return $temp;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub process {
|
||||
my ($output, $temp);
|
||||
$output = $_[0];
|
||||
$output =~ s/\^File\((.*?)\)\;/_replacement($1)/ge;
|
||||
return $output;
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
|
||||
|
|
@ -22,9 +22,9 @@ sub _replacement {
|
|||
my (@param, $temp, %data, $image);
|
||||
tie %data, 'Tie::CPHash';
|
||||
@param = WebGUI::Macro::getParams($_[0]);
|
||||
%data = WebGUI::SQL->quickHash("select * from images where name=".quote($param[0]));
|
||||
$image = WebGUI::Attachment->new($data{filename},"images",$data{imageId});
|
||||
$temp = '<img src="'.$image->getURL.'" '.$data{parameters}.'>';
|
||||
%data = WebGUI::SQL->quickHash("select filename,parameters,collateralId from collateral where name=".quote($param[0]));
|
||||
$image = WebGUI::Attachment->new($data{filename},"images",$data{collateralId});
|
||||
$temp = '<img src="'.$image->getURL.'" '.$data{parameters}.' />';
|
||||
return $temp;
|
||||
}
|
||||
|
||||
|
|
|
|||
37
lib/WebGUI/Macro/Snippet.pm
Normal file
37
lib/WebGUI/Macro/Snippet.pm
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
package WebGUI::Macro::Snippet;
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
# WebGUI is Copyright 2001-2002 Plain Black LLC.
|
||||
#-------------------------------------------------------------------
|
||||
# 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 Tie::CPHash;
|
||||
use WebGUI::Macro;
|
||||
use WebGUI::Session;
|
||||
use WebGUI::SQL;
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub _replacement {
|
||||
my (@param, $temp);
|
||||
@param = WebGUI::Macro::getParams($_[0]);
|
||||
($temp) = WebGUI::SQL->quickArray("select parameters from collateral where name=".quote($param[0]));
|
||||
return $temp;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub process {
|
||||
my ($output, $temp);
|
||||
$output = $_[0];
|
||||
$output =~ s/\^Snippet\((.*?)\)\;/_replacement($1)/ge;
|
||||
return $output;
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
|
||||
|
|
@ -22,8 +22,8 @@ sub _replacement {
|
|||
my (@param, %data, $image);
|
||||
tie %data, 'Tie::CPHash';
|
||||
@param = WebGUI::Macro::getParams($_[0]);
|
||||
%data = WebGUI::SQL->quickHash("select * from images where name='$param[0]'");
|
||||
$image = WebGUI::Attachment->new($data{filename},"images",$data{imageId});
|
||||
%data = WebGUI::SQL->quickHash("select filename,collateralId from collateral where name='$param[0]'");
|
||||
$image = WebGUI::Attachment->new($data{filename},"images",$data{collateralId});
|
||||
return $image->getThumbnail;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -22,8 +22,8 @@ sub _replacement {
|
|||
my (@param, $image, %data);
|
||||
tie %data, 'Tie::CPHash';
|
||||
@param = WebGUI::Macro::getParams($_[0]);
|
||||
%data = WebGUI::SQL->quickHash("select * from images where name=".quote($param[0]));
|
||||
$image = WebGUI::Attachment->new($data{filename},"images",$data{imageId});
|
||||
%data = WebGUI::SQL->quickHash("select collateralId,filename from collateral where name=".quote($param[0]));
|
||||
$image = WebGUI::Attachment->new($data{filename},"images",$data{collateralId});
|
||||
return $image->getURL;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -13,9 +13,9 @@ package WebGUI::Operation;
|
|||
use strict;
|
||||
use WebGUI::Operation::Account;
|
||||
use WebGUI::Operation::Admin;
|
||||
use WebGUI::Operation::Collateral;
|
||||
use WebGUI::Operation::Group;
|
||||
use WebGUI::Operation::Help;
|
||||
use WebGUI::Operation::Image;
|
||||
use WebGUI::Operation::International;
|
||||
use WebGUI::Operation::Package;
|
||||
use WebGUI::Operation::Page;
|
||||
|
|
|
|||
440
lib/WebGUI/Operation/Collateral.pm
Normal file
440
lib/WebGUI/Operation/Collateral.pm
Normal file
|
|
@ -0,0 +1,440 @@
|
|||
package WebGUI::Operation::Collateral;
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
# WebGUI is Copyright 2001-2002 Plain Black LLC.
|
||||
#-------------------------------------------------------------------
|
||||
# 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 Exporter;
|
||||
use strict;
|
||||
use WebGUI::Attachment;
|
||||
use WebGUI::DateTime;
|
||||
use WebGUI::HTMLForm;
|
||||
use WebGUI::Icon;
|
||||
use WebGUI::International;
|
||||
use WebGUI::Node;
|
||||
use WebGUI::Operation::Shared;
|
||||
use WebGUI::Paginator;
|
||||
use WebGUI::Privilege;
|
||||
use WebGUI::Session;
|
||||
use WebGUI::SQL;
|
||||
use Tie::IxHash;
|
||||
use WebGUI::URL;
|
||||
|
||||
our @ISA = qw(Exporter);
|
||||
our @EXPORT = qw(&www_editCollateral &www_editCollateralSave &www_deleteCollateral
|
||||
&www_deleteCollateralConfirm &www_listCollateral
|
||||
&www_deleteFile &www_editCollateralFolder &www_editCollateralFolderSave &www_deleteCollateralFolder
|
||||
&www_deleteCollateralFolderConfirm);
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub _submenu {
|
||||
return WebGUI::Privilege::insufficient unless (WebGUI::Privilege::isInGroup(4));
|
||||
my (%menu);
|
||||
tie %menu, 'Tie::IxHash';
|
||||
$menu{WebGUI::URL::page('op=editCollateralFolder&fid=new')} = WebGUI::International::get(758);
|
||||
$menu{WebGUI::URL::page('op=editCollateral&cid=new&type=image')} = WebGUI::International::get(761);
|
||||
$menu{WebGUI::URL::page('op=editCollateral&cid=new&type=file')} = WebGUI::International::get(762);
|
||||
$menu{WebGUI::URL::page('op=editCollateral&cid=new&type=snippet')} = WebGUI::International::get(763);
|
||||
if ($session{form}{op} eq "editCollateral" || $session{form}{op} eq "deleteCollateral") {
|
||||
$menu{WebGUI::URL::page('op=editCollateral&cid='.$session{form}{cid})} = WebGUI::International::get(764);
|
||||
$menu{WebGUI::URL::page('op=deleteCollateral&cid='.$session{form}{cid})} = WebGUI::International::get(765);
|
||||
}
|
||||
$menu{WebGUI::URL::page('op=editCollateralFolder')} = WebGUI::International::get(759);
|
||||
$menu{WebGUI::URL::page('op=deleteCollateralFolder')} = WebGUI::International::get(760);
|
||||
$menu{WebGUI::URL::page('op=listCollateral')} = WebGUI::International::get(766);
|
||||
return menuWrapper($_[0],\%menu);
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_deleteCollateral {
|
||||
return WebGUI::Privilege::insufficient unless (WebGUI::Privilege::isInGroup(4));
|
||||
my $output = '<h1>'.WebGUI::International::get(42).'</h1>';
|
||||
$output .= WebGUI::International::get(774).'<p/><div align="center">';
|
||||
$output .= '<a href="'.WebGUI::URL::page('op=deleteCollateralConfirm&cid='.$session{form}{cid}).'">'
|
||||
.WebGUI::International::get(44).'</a>';
|
||||
$output .= ' ';
|
||||
$output .= '<a href="'.WebGUI::URL::page('op=listCollateral').'">'.WebGUI::International::get(45).'</a>';
|
||||
$output .= '</div>';
|
||||
return _submenu($output);
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_deleteCollateralConfirm {
|
||||
return WebGUI::Privilege::insufficient unless (WebGUI::Privilege::isInGroup(4));
|
||||
my $node = WebGUI::Node("images",$session{form}{cid});
|
||||
WebGUI::SQL->write("delete from collateral where collateralId=".$session{form}{cid});
|
||||
return www_listCollateral();
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_deleteCollateralFolder {
|
||||
return WebGUI::Privilege::insufficient unless (WebGUI::Privilege::isInGroup(4));
|
||||
return WebGUI::Privilege::vitalComponent() unless ($session{scratch}{collateralFolderId} > 999);
|
||||
my $output = '<h1>'.WebGUI::International::get(42).'</h1>';
|
||||
$output .= WebGUI::International::get(775).'<p/><div align="center">';
|
||||
$output .= '<a href="'.WebGUI::URL::page('op=deleteCollateralFolderConfirm').'">'
|
||||
.WebGUI::International::get(44).'</a>';
|
||||
$output .= ' ';
|
||||
$output .= '<a href="'.WebGUI::URL::page('op=listCollateral').'">'.WebGUI::International::get(45).'</a>';
|
||||
$output .= '</div>';
|
||||
return _submenu($output);
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_deleteCollateralFolderConfirm {
|
||||
return WebGUI::Privilege::insufficient unless (WebGUI::Privilege::isInGroup(4));
|
||||
return WebGUI::Privilege::vitalComponent() unless ($session{scratch}{collateralFolderId} > 999);
|
||||
my ($parent) = WebGUI::SQL->quickArray("select parentId from collateralFolder
|
||||
where collateralFolderId=".$session{scratch}{collateralFolderId});
|
||||
WebGUI::SQL->write("update collateral set collateralFolderId=$parent
|
||||
where collateralFolderId=$session{scratch}{collateralFolderId}");
|
||||
WebGUI::SQL->write("delete from collateralFolder where collateralFolderId=".$session{scratch}{collateralFolderId});
|
||||
WebGUI::Session::setScratch("collateralFolderId",$parent);
|
||||
return www_listCollateral();
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_deleteFile {
|
||||
return WebGUI::Privilege::insufficient unless (WebGUI::Privilege::isInGroup(4));
|
||||
WebGUI::SQL->write("update collateral set filename='' where collateralId=".$session{form}{cid});
|
||||
return www_editCollateral();
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_editCollateral {
|
||||
return WebGUI::Privilege::insufficient unless (WebGUI::Privilege::isInGroup(4));
|
||||
my ($canEdit, $file, $folderId, $output, $f, $collateral);
|
||||
if ($session{form}{cid} eq "new") {
|
||||
$collateral->{collateralType} = $session{form}{type};
|
||||
$collateral->{collateralId} = "new";
|
||||
$collateral->{username} = $session{user}{username};
|
||||
$collateral->{userId} = $session{user}{userId};
|
||||
$collateral->{parameters} = 'border="0"' if ($session{form}{type} eq "image");
|
||||
} else {
|
||||
$collateral = WebGUI::SQL->quickHashRef("select * from collateral where collateralId=".$session{form}{cid});
|
||||
}
|
||||
$canEdit = ($collateral->{userId} == $session{user}{userId} || WebGUI::Privilege::isInGroup($session{user}{userId}));
|
||||
$folderId = $session{scratch}{collateralFolderId} || 0;
|
||||
$f = WebGUI::HTMLForm->new;
|
||||
$f->hidden("op","editCollateralSave");
|
||||
$f->hidden("collateralType",$collateral->{collateralType});
|
||||
$f->hidden("cid",$collateral->{collateralId});
|
||||
$f->readOnly(
|
||||
-label=>WebGUI::International::get(767),
|
||||
-value=>$collateral->{collateralId}
|
||||
);
|
||||
$f->readOnly(
|
||||
-label=>WebGUI::International::get(388),
|
||||
-value=>epochToHuman($collateral->{dateUploaded},"%z")
|
||||
);
|
||||
$f->readOnly(
|
||||
-label=>WebGUI::International::get(387),
|
||||
-value=>$collateral->{username}
|
||||
);
|
||||
if ($canEdit) {
|
||||
$f->text(
|
||||
-name=>"name",
|
||||
-value=>$collateral->{name},
|
||||
-label=>WebGUI::International::get(768)
|
||||
);
|
||||
$f->select(
|
||||
-name=>"collateralFolderId",
|
||||
-value=>[$folderId],
|
||||
-label=>WebGUI::International::get(769),
|
||||
-options=>WebGUI::SQL->buildHashRef("select collateralFolderId,name from collateralFolder order by name")
|
||||
);
|
||||
} else {
|
||||
$f->readOnly(
|
||||
-label=>WebGUI::International::get(768),
|
||||
-value=>$collateral->{name}
|
||||
);
|
||||
}
|
||||
if ($collateral->{collateralType} eq "snippet") {
|
||||
$output .= '<h1>'.WebGUI::International::get(770).'</h1>';
|
||||
if ($canEdit) {
|
||||
$f->HTMLArea(
|
||||
-name=>"parameters",
|
||||
-value=>$collateral->{parameters},
|
||||
-label=>WebGUI::International::get(771)
|
||||
);
|
||||
} else {
|
||||
$f->readOnly(
|
||||
-value=>$collateral->{parameters},
|
||||
-label=>WebGUI::International::get(771)
|
||||
);
|
||||
}
|
||||
} elsif ($collateral->{collateralType} eq "file") {
|
||||
$output .= '<h1>'.WebGUI::International::get(772).'</h1>';
|
||||
if ($canEdit) {
|
||||
if ($collateral->{filename} ne "") {
|
||||
$f->readOnly(
|
||||
-value=>'<a href="'.WebGUI::URL::page('op=deleteFile&cid='
|
||||
.$collateral->{collateralId}).'">'.WebGUI::International::get(391).'</a>',
|
||||
-label=>WebGUI::International::get(773)
|
||||
);
|
||||
} else {
|
||||
$f->file(
|
||||
-name=>"filename",
|
||||
-label=>WebGUI::International::get(773)
|
||||
);
|
||||
}
|
||||
}
|
||||
$file = WebGUI::Attachment->new($collateral->{filename},"images",$collateral->{collateralId});
|
||||
if ($file->getFilename ne "") {
|
||||
$f->readOnly(
|
||||
-value=>'<a href="'.$file->getURL.'"><img src="'.$file->getIcon.'" border="0" align="middle" /> '
|
||||
.$file->getFilename.'</a>'
|
||||
);
|
||||
}
|
||||
} else {
|
||||
$output .= helpIcon(20);
|
||||
$output .= '<h1>'.WebGUI::International::get(382).'</h1>';
|
||||
if ($canEdit) {
|
||||
if ($collateral->{filename} ne "") {
|
||||
$f->readOnly(
|
||||
-value=>'<a href="'.WebGUI::URL::page('op=deleteFile&cid='
|
||||
.$collateral->{collateralId}).'">'.
|
||||
WebGUI::International::get(391).'</a>',
|
||||
-label=>WebGUI::International::get(384)
|
||||
);
|
||||
} else {
|
||||
$f->file(
|
||||
-name=>"filename",
|
||||
-label=>WebGUI::International::get(384)
|
||||
);
|
||||
}
|
||||
}
|
||||
$file = WebGUI::Attachment->new($collateral->{filename},"images",$collateral->{collateralId});
|
||||
if ($file->getFilename ne "") {
|
||||
$f->readOnly(
|
||||
-value=>'<a href="'.$file->getURL.'"><img src="'.$file->getThumbnail.'" border="0" /></a>'
|
||||
);
|
||||
}
|
||||
if ($canEdit) {
|
||||
$f->textarea(
|
||||
-name=>"parameters",
|
||||
-value=>$collateral->{parameters},
|
||||
-label=>WebGUI::International::get(385)
|
||||
);
|
||||
} else {
|
||||
$f->readOnly(
|
||||
-label=>WebGUI::International::get(385),
|
||||
-value=>$collateral->{parameters}
|
||||
);
|
||||
}
|
||||
}
|
||||
$f->submit if ($canEdit);
|
||||
$output .= $f->print;
|
||||
return _submenu($output);
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_editCollateralSave {
|
||||
return WebGUI::Privilege::insufficient unless (WebGUI::Privilege::isInGroup(4));
|
||||
WebGUI::Session::setScratch("collateralFolderId",$session{form}{collateralFolderId});
|
||||
my ($test, $file, $addFile);
|
||||
if ($session{form}{cid} eq "new") {
|
||||
$session{form}{cid} = getNextId("collateralId");
|
||||
WebGUI::SQL->write("insert into collateral (collateralId,userId,username,collateralType)
|
||||
values ($session{form}{cid},
|
||||
$session{user}{userId}, ".quote($session{user}{username}).",
|
||||
".quote($session{form}{collateralType}).")");
|
||||
}
|
||||
$file = WebGUI::Attachment->new("","images",$session{form}{cid});
|
||||
$file->save("filename");
|
||||
if ($file->getFilename ne "") {
|
||||
$addFile = ", filename=".quote($file->getFilename);
|
||||
$session{form}{name} = $file->getFilename if ($session{form}{name} eq "");
|
||||
}
|
||||
$session{form}{name} = "untitled" if ($session{form}{name} eq "");
|
||||
while (($test) = WebGUI::SQL->quickArray("select name from collateral
|
||||
where name=".quote($session{form}{name})." and collateralId<>$session{form}{cid}")) {
|
||||
if ($session{form}{name} =~ /(.*)(\d+$)/) {
|
||||
$session{form}{name} = $1.($2+1);
|
||||
} elsif ($test ne "") {
|
||||
$session{form}{name} .= "2";
|
||||
}
|
||||
}
|
||||
WebGUI::SQL->write("update collateral set name=".quote($session{form}{name}).", parameters="
|
||||
.quote($session{form}{parameters}).", collateralFolderId=$session{form}{collateralFolderId}, dateUploaded="
|
||||
.time()." $addFile where collateralId=$session{form}{cid}");
|
||||
$session{form}{collateralType} = "";
|
||||
return www_listCollateral();
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_editCollateralFolder {
|
||||
return WebGUI::Privilege::insufficient unless (WebGUI::Privilege::isInGroup(4));
|
||||
my ($output, $f, $folder, $folderId, $constraint);
|
||||
$output .= '<h1>'.WebGUI::International::get(776).'</h1>';
|
||||
if ($session{form}{fid} eq "new") {
|
||||
$folder->{collateralFolderId} = "new";
|
||||
$folder->{parentId} = $session{scratch}{collateralFolderId} || 0;
|
||||
} else {
|
||||
$folderId = $session{scratch}{collateralFolderId} || 0;
|
||||
$folder = WebGUI::SQL->quickHashRef("select * from collateralFolder where collateralFolderId=$folderId");
|
||||
$constraint = "where collateralFolderId<>".$folder->{collateralFolderId};
|
||||
}
|
||||
$f = WebGUI::HTMLForm->new;
|
||||
$f->hidden("op","editCollateralFolderSave");
|
||||
$f->hidden("fid",$session{form}{fid});
|
||||
$f->readOnly(
|
||||
-value=>$folder->{collateralFolderId},
|
||||
-label=>WebGUI::International::get(777)
|
||||
);
|
||||
if ($folder->{collateralFolderId} eq "0") {
|
||||
$f->hidden("parentId",0);
|
||||
} else {
|
||||
$f->select(
|
||||
-name=>"parentId",
|
||||
-value=>[$folder->{parentId}],
|
||||
-label=>WebGUI::International::get(769),
|
||||
-options=>WebGUI::SQL->buildHashRef("select collateralFolderId,name from collateralFolder
|
||||
$constraint order by name")
|
||||
);
|
||||
}
|
||||
$f->text(
|
||||
-value=>$folder->{name},
|
||||
-name=>"name",
|
||||
-label=>WebGUI::International::get(768)
|
||||
);
|
||||
$f->textarea(
|
||||
-value=>$folder->{description},
|
||||
-name=>"description",
|
||||
-label=>WebGUI::International::get(778)
|
||||
);
|
||||
$f->submit;
|
||||
$output .= $f->print;
|
||||
return _submenu($output);
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_editCollateralFolderSave {
|
||||
return WebGUI::Privilege::insufficient unless (WebGUI::Privilege::isInGroup(4));
|
||||
if ($session{form}{fid} eq "new") {
|
||||
$session{form}{fid} = getNextId("collateralFolderId");
|
||||
WebGUI::Session::setScratch("collateralFolderId",$session{form}{fid});
|
||||
WebGUI::SQL->write("insert into collateralFolder (collateralFolderId) values ($session{form}{fid})");
|
||||
}
|
||||
$session{form}{name} = "untitled" if ($session{form}{name} eq "");
|
||||
while (my ($test) = WebGUI::SQL->quickArray("select name from collateralFolder
|
||||
where name=".quote($session{form}{name})." and collateralFolderId<>$session{scratch}{collateralFolderId}")) {
|
||||
if ($session{form}{name} =~ /(.*)(\d+$)/) {
|
||||
$session{form}{name} = $1.($2+1);
|
||||
} elsif ($test ne "") {
|
||||
$session{form}{name} .= "2";
|
||||
}
|
||||
}
|
||||
WebGUI::SQL->write("update collateralFolder set parentId=$session{form}{parentId}, name=".quote($session{form}{name})
|
||||
.", description=".quote($session{form}{description})
|
||||
." where collateralFolderId=$session{scratch}{collateralFolderId}");
|
||||
return www_listCollateral();
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_listCollateral {
|
||||
return WebGUI::Privilege::insufficient unless (WebGUI::Privilege::isInGroup(4));
|
||||
my (%type, %user, $f, $row, $data, $sth, $url, $output, $parent, $p, $thumbnail, $file, $page, $constraints, $folderId);
|
||||
tie %type, 'Tie::IxHash';
|
||||
tie %user, 'Tie::IxHash';
|
||||
%type = (
|
||||
'-delete-'=>WebGUI::International::get(782),
|
||||
image=>WebGUI::International::get(779),
|
||||
file=>WebGUI::International::get(780),
|
||||
snippet=>WebGUI::International::get(781)
|
||||
);
|
||||
%user = (
|
||||
'-delete-'=>WebGUI::International::get(782),
|
||||
%{WebGUI::SQL->buildHashRef("select distinct(userId), username from collateral order by username")}
|
||||
);
|
||||
$session{form}{keyword} = '-delete-' if (exists $session{form}{keyword} && $session{form}{keyword} eq "");
|
||||
WebGUI::Session::setScratch("keyword",$session{form}{keyword});
|
||||
WebGUI::Session::setScratch("collateralUser",$session{form}{collateralUser});
|
||||
WebGUI::Session::setScratch("collateralType",$session{form}{collateralType});
|
||||
WebGUI::Session::setScratch("collateralPageNumber",$session{form}{pn});
|
||||
WebGUI::Session::setScratch("collateralFolderId",$session{form}{fid});
|
||||
$folderId = $session{scratch}{collateralFolderId} || 0;
|
||||
$constraints = "collateralFolderId=".$folderId;
|
||||
$constraints .= " and userId=$session{scratch}{collateralUser}" if ($session{scratch}{collateralUser});
|
||||
$constraints .= " and collateralType=".quote($session{scratch}{collateralType}) if ($session{scratch}{collateralType});
|
||||
$constraints .= " and name like ".quote('%'.$session{scratch}{keyword}.'%') if ($session{scratch}{keyword});
|
||||
$p = WebGUI::Paginator->new(WebGUI::URL::page('op=listCollateral'),[],"",$session{scratch}{collateralPageNumber});
|
||||
$p->setDataByQuery("select collateralId, name, filename, collateralType, dateUploaded, username
|
||||
from collateral where $constraints order by name");
|
||||
$page = $p->getPageData;
|
||||
$output = helpIcon(49);
|
||||
$output .= '<h1>'.WebGUI::International::get(757).'</h1>';
|
||||
$f = WebGUI::HTMLForm->new(1);
|
||||
$f->hidden("op","listCollateral");
|
||||
$f->hidden("pn",1);
|
||||
$f->text(
|
||||
-name=>"keyword",
|
||||
-value=>$session{scratch}{keyword},
|
||||
-size=>15
|
||||
);
|
||||
$f->select(
|
||||
-name=>"collateralUser",
|
||||
-value=>[$session{scratch}{collateralUser}],
|
||||
-options=>\%user
|
||||
);
|
||||
$f->select(
|
||||
-name=>"collateralType",
|
||||
-value=>[$session{scratch}{collateralType}],
|
||||
-options=>\%type
|
||||
);
|
||||
$f->submit(WebGUI::International::get(170));
|
||||
$output .= '<div align="center">'.$f->print.'</div>';
|
||||
$output .= '<table align="center" border="1" cellpadding="2" cellspacing="0">';
|
||||
$output .= '<tr><td class="tableHeader">'.WebGUI::International::get(768).'</td><td class="tableHeader">'
|
||||
.WebGUI::International::get(783).'</td><td class="tableHeader">'.WebGUI::International::get(387)
|
||||
.'</td><td class="tableHeader">'.WebGUI::International::get(388).'</td><td class="tableHeader">'
|
||||
.WebGUI::International::get(784).'</td></tr>';
|
||||
if ($folderId) {
|
||||
($parent) = WebGUI::SQL->quickArray("select parentId from collateralFolder
|
||||
where collateralFolderId=$folderId");
|
||||
$output .= '<tr><td colspan="5" class="tableData"><a href="'.WebGUI::URL::page('op=listCollateral&fid='
|
||||
.$parent.'&pn=1')
|
||||
.'"><img src="'.$session{config}{extras}.'/smallAttachment.gif" border="0">'
|
||||
.' '.WebGUI::International::get(542).'</a></td></tr>';
|
||||
}
|
||||
$sth = WebGUI::SQL->read("select collateralFolderId, name, description from collateralFolder
|
||||
where parentId=$folderId and collateralFolderId<>0 order by name");
|
||||
while ($data = $sth->hashRef) {
|
||||
$output .= '<tr><td class="tableData"><a href="'.WebGUI::URL::page('op=listCollateral&fid='
|
||||
.$data->{collateralFolderId}.'&pn=1')
|
||||
.'"><img src="'.$session{config}{extras}.'/smallAttachment.gif" border="0">'
|
||||
.' '.$data->{name}.'</a></td><td class="tableData" colspan="4">'.$data->{description}.'</td></tr>';
|
||||
}
|
||||
$sth->finish;
|
||||
foreach $row (@$page) {
|
||||
$url = WebGUI::URL::page('op=editCollateral&cid='.$row->{collateralId}.'&fid='.$folderId);
|
||||
$output .= '<tr>';
|
||||
$output .= '<td class="tableData"><a href="'.$url.'">'.$row->{name}.'</a></td>';
|
||||
$output .= '<td class="tableData">'.$type{$row->{collateralType}}.'</td>';
|
||||
$output .= '<td class="tableData">'.$row->{username}.'</td>';
|
||||
$output .= '<td class="tableData">'.epochToHuman($row->{dateUploaded},"%z").'</td>';
|
||||
if ($row->{filename} ne "" && $row->{collateralType} eq "image") {
|
||||
$file = WebGUI::Attachment->new($row->{filename},"images",$row->{collateralId});
|
||||
$thumbnail = '<a href="'.$url.'"><img src="'.$file->getThumbnail.'" border="0" /></a>';
|
||||
} elsif ($row->{filename} ne "" && $row->{collateralType} eq "file") {
|
||||
$file = WebGUI::Attachment->new($row->{filename},"images",$row->{collateralId});
|
||||
$thumbnail = '<a href="'.$url.'"><img src="'.$file->getIcon.'" border="0" /></a>';
|
||||
} else {
|
||||
$thumbnail = "";
|
||||
}
|
||||
$output .= '<td class="tableData">'.$thumbnail.'</td>';
|
||||
$output .= '</tr>';
|
||||
}
|
||||
$output .= '</table>';
|
||||
$output .= $p->getBarTraditional;
|
||||
return _submenu($output);
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
|
|
@ -50,21 +50,16 @@ sub _seeAlso {
|
|||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_deleteHelp {
|
||||
if ($session{user}{userId} != 3) {
|
||||
return "";
|
||||
} else {
|
||||
return "" unless (WebGUI::Privilege::isInGroup(3));
|
||||
my $output = '<h1>Confirm</h1>Are you sure? Deleting help is never a good idea. <a href="'
|
||||
.WebGUI::URL::page("op=deleteHelpConfirm&hid=".$session{form}{hid}."&namespace=".$session{form}{namespace})
|
||||
.'">Yes</a> / <a href="'.WebGUI::URL::page("op=manageHelp").'">No</a><p>';
|
||||
return $output;
|
||||
}
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_deleteHelpConfirm {
|
||||
if ($session{user}{userId} != 3) {
|
||||
return "";
|
||||
} else {
|
||||
return "" unless (WebGUI::Privilege::isInGroup(3));
|
||||
my ($titleId, $bodyId) = WebGUI::SQL->quickArray("select titleId,bodyId from help where helpId=".$session{form}{hid}."
|
||||
and namespace=".quote($session{form}{namespace}));
|
||||
WebGUI::SQL->write("delete from international where internationalId=$titleId
|
||||
|
|
@ -74,14 +69,11 @@ sub www_deleteHelpConfirm {
|
|||
WebGUI::SQL->write("delete from help where helpId=".$session{form}{hid}."
|
||||
and namespace=".quote($session{form}{namespace}));
|
||||
return www_manageHelp();
|
||||
}
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_editHelp {
|
||||
if ($session{user}{userId} != 3) {
|
||||
return "";
|
||||
} else {
|
||||
return "" unless (WebGUI::Privilege::isInGroup(3));
|
||||
my ($output, $f, %data, %help, @seeAlso);
|
||||
tie %data, 'Tie::IxHash';
|
||||
tie %help, 'Tie::CPHash';
|
||||
|
|
@ -125,14 +117,11 @@ sub www_editHelp {
|
|||
$f->submit;
|
||||
$output .= $f->print;
|
||||
return $output;
|
||||
}
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_editHelpSave {
|
||||
if ($session{user}{userId} != 3) {
|
||||
return "";
|
||||
} else {
|
||||
return "" unless (WebGUI::Privilege::isInGroup(3));
|
||||
my (@seeAlso);
|
||||
if ($session{form}{hid} eq "new") {
|
||||
if ($session{form}{namespace_new} ne "") {
|
||||
|
|
@ -165,12 +154,11 @@ sub www_editHelpSave {
|
|||
WebGUI::SQL->write("update help set seeAlso=".quote($session{form}{seeAlso})."
|
||||
where helpId=$session{form}{hid} and namespace=".quote($session{form}{namespace}));
|
||||
return www_manageHelp();
|
||||
}
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_exportHelp {
|
||||
return "" if ($session{user}{userId} != 3);
|
||||
return "" unless (WebGUI::Privilege::isInGroup(3));
|
||||
my ($export, $output, %help, $sth);
|
||||
$export = "#export of WebGUI ".$WebGUI::VERSION." help system.\n\n";
|
||||
$sth = WebGUI::SQL->read("select * from help");
|
||||
|
|
@ -187,7 +175,7 @@ sub www_exportHelp {
|
|||
#-------------------------------------------------------------------
|
||||
sub www_manageHelp {
|
||||
my ($sth, @help, $output);
|
||||
if ($session{user}{userId} != 3) {
|
||||
unless (WebGUI::Privilege::isInGroup(3)) {
|
||||
return "";
|
||||
} else {
|
||||
$output = '<h1>Manage Help</h1>';
|
||||
|
|
|
|||
|
|
@ -1,387 +0,0 @@
|
|||
package WebGUI::Operation::Image;
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
# WebGUI is Copyright 2001-2002 Plain Black LLC.
|
||||
#-------------------------------------------------------------------
|
||||
# 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 Exporter;
|
||||
use strict;
|
||||
use WebGUI::Attachment;
|
||||
use WebGUI::DateTime;
|
||||
use WebGUI::HTMLForm;
|
||||
use WebGUI::Icon;
|
||||
use WebGUI::International;
|
||||
use WebGUI::Paginator;
|
||||
use WebGUI::Privilege;
|
||||
use WebGUI::Session;
|
||||
use WebGUI::SQL;
|
||||
use WebGUI::Template;
|
||||
use WebGUI::URL;
|
||||
use WebGUI::Utility;
|
||||
|
||||
our @ISA = qw(Exporter);
|
||||
our @EXPORT = qw(&www_editImage &www_editImageSave &www_viewImage &www_deleteImage &www_deleteImageConfirm &www_listImages &www_deleteImageFile &www_editImageGroup &www_editImageGroupSave &www_viewImageGroup &www_deleteImageGroup &www_deleteImageGroupConfirm);
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_deleteImage {
|
||||
my ($output);
|
||||
if (WebGUI::Privilege::isInGroup($session{setting}{imageManagersGroup})) {
|
||||
$output .= helpIcon(23);
|
||||
$output .= '<h1>'.WebGUI::International::get(42).'</h1>';
|
||||
$output .= WebGUI::International::get(392).'<p>';
|
||||
$output .= '<div align="center"><a href="'.
|
||||
WebGUI::URL::page('op=deleteImageConfirm&iid='.$session{form}{iid}.'&gid='.$session{form}{gid})
|
||||
.'">'.WebGUI::International::get(44).'</a>';
|
||||
$output .= ' <a href="'.WebGUI::URL::page('op=listImages&gid='.$session{form}{gid}).'">'.
|
||||
WebGUI::International::get(45).'</a></div>';
|
||||
return $output;
|
||||
} else {
|
||||
return WebGUI::Privilege::insufficient();
|
||||
}
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_deleteImageConfirm {
|
||||
my ($image);
|
||||
if (WebGUI::Privilege::isInGroup($session{setting}{imageManagersGroup})) {
|
||||
$image = WebGUI::Attachment->new("","images",$session{form}{iid});
|
||||
$image->deleteNode;
|
||||
WebGUI::SQL->write("delete from images where imageId=$session{form}{iid}");
|
||||
return www_listImages();
|
||||
} else {
|
||||
return WebGUI::Privilege::insufficient();
|
||||
}
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_deleteImageFile {
|
||||
if (WebGUI::Privilege::isInGroup($session{setting}{imageManagersGroup})) {
|
||||
WebGUI::SQL->write("update images set filename='' where imageId=$session{form}{iid}");
|
||||
return www_editImage();
|
||||
} else {
|
||||
return WebGUI::Privilege::insufficient();
|
||||
}
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_editImage {
|
||||
my ($output, %data, $image, $f, $imageGroupId);
|
||||
tie %data, 'Tie::CPHash';
|
||||
if (WebGUI::Privilege::isInGroup($session{setting}{imageManagersGroup})) {
|
||||
if ($session{form}{iid} eq "new") {
|
||||
$imageGroupId = $session{form}{gid};
|
||||
} else {
|
||||
%data = WebGUI::SQL->quickHash("select * from images where imageId=$session{form}{iid}");
|
||||
$imageGroupId = $data{imageGroupId};
|
||||
}
|
||||
$output = helpIcon(20);
|
||||
$output .= '<h1>'.WebGUI::International::get(382).'</h1>';
|
||||
$f = WebGUI::HTMLForm->new;
|
||||
$f->hidden("op","editImageSave");
|
||||
$f->hidden("iid",$session{form}{iid});
|
||||
$f->hidden("gid",$imageGroupId);
|
||||
$f->readOnly($session{form}{iid},WebGUI::International::get(389));
|
||||
$f->text("name",WebGUI::International::get(383),$data{name});
|
||||
if ($data{filename} ne "") {
|
||||
$f->readOnly('<a href="'.WebGUI::URL::page('op=deleteImageFile&iid='.$data{imageId}).'">'.WebGUI::International::get(391).'</a>',
|
||||
WebGUI::International::get(384));
|
||||
} else {
|
||||
$f->file("filename",WebGUI::International::get(384));
|
||||
}
|
||||
$f->textarea("parameters",WebGUI::International::get(385),$data{parameters});
|
||||
$f->submit;
|
||||
$output .= $f->print;
|
||||
if ($data{filename} ne "") {
|
||||
$image = WebGUI::Attachment->new($data{filename},"images",$data{imageId});
|
||||
$output .= '<p>'.WebGUI::International::get(390).'<p><img src="'.$image->getURL.'">';
|
||||
}
|
||||
return $output;
|
||||
} else {
|
||||
return WebGUI::Privilege::insufficient();
|
||||
}
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_editImageSave {
|
||||
my ($file, $sqlAdd, $test);
|
||||
if (WebGUI::Privilege::isInGroup($session{setting}{imageManagersGroup})) {
|
||||
if ($session{form}{iid} eq "new") {
|
||||
$session{form}{iid} = getNextId("imageId");
|
||||
WebGUI::SQL->write("insert into images (imageId) values ($session{form}{iid})");
|
||||
}
|
||||
$file = WebGUI::Attachment->new("","images",$session{form}{iid});
|
||||
$file->save("filename");
|
||||
if ($file->getFilename) {
|
||||
$sqlAdd = ", filename=".quote($file->getFilename);
|
||||
}
|
||||
while (($test) = WebGUI::SQL->quickArray("select name from images
|
||||
where name=".quote($session{form}{name})." and imageId<>$session{form}{iid}")) {
|
||||
if ($session{form}{name} =~ /(.*)(\d+$)/) {
|
||||
$session{form}{name} = $1.($2+1);
|
||||
} elsif ($test ne "") {
|
||||
$session{form}{name} .= "2";
|
||||
}
|
||||
}
|
||||
WebGUI::SQL->write("update images set name=".quote($session{form}{name}).
|
||||
$sqlAdd.", parameters=".quote($session{form}{parameters}).", userId=$session{user}{userId}, ".
|
||||
" username=".quote($session{user}{username}).
|
||||
", imageGroupId=".$session{form}{gid}.
|
||||
", dateUploaded=".time()." where imageId=$session{form}{iid}");
|
||||
return www_listImages();
|
||||
} else {
|
||||
return WebGUI::Privilege::insufficient();
|
||||
}
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_listImages {
|
||||
my ($f, $output, $sth, %data, @row, $image, $p, $i, $search, $search_group,
|
||||
$isAdmin, $imageGroupId, $isImageManager, $imageGroupParentId);
|
||||
tie %data, 'Tie::CPHash';
|
||||
if (WebGUI::Privilege::isInGroup(4)) {
|
||||
$isImageManager = WebGUI::Privilege::isInGroup($session{setting}{imageManagersGroup});
|
||||
$isAdmin = WebGUI::Privilege::isInGroup(3);
|
||||
if($session{form}{gid} ne "") {
|
||||
$imageGroupId = $session{form}{gid};
|
||||
} else {
|
||||
$imageGroupId = 0;
|
||||
$session{form}{gid} = 0;
|
||||
}
|
||||
%data = WebGUI::SQL->quickHash("select parentId,name from imageGroup where imageGroupId=".$imageGroupId);
|
||||
if($session{form}{pid} ne "") {
|
||||
$imageGroupParentId = $session{form}{pid};
|
||||
} elsif($imageGroupId != 0) {
|
||||
$imageGroupParentId = $data{parentId};
|
||||
}
|
||||
$output = helpIcon(26);
|
||||
$output .= '<h1>'.WebGUI::International::get(393).' - '.$data{name}.'</h1>';
|
||||
$output .= '<table class="tableData" align="center" width="75%"><tr>';
|
||||
if($isImageManager) {
|
||||
$output .= '<td><a href="'.WebGUI::URL::page('op=editImage&iid=new&gid='.$imageGroupId).'">'.WebGUI::International::get(395).'</a>';
|
||||
$output .= '</td>';
|
||||
$output .= '<td><a href="'.WebGUI::URL::page('op=editImageGroup&gid=new&pid='.$imageGroupId).'">'.WebGUI::International::get(543).'</a></td>';
|
||||
}
|
||||
$f = WebGUI::HTMLForm->new(1);
|
||||
$f->raw('<td align="right">');
|
||||
$f->hidden("op","listImages");
|
||||
$f->text("keyword",'',$session{form}{keyword});
|
||||
$f->submit(WebGUI::International::get(170));
|
||||
$f->raw('</td>');
|
||||
$output .= $f->print;
|
||||
$output .= '</tr></table><p>';
|
||||
if ($session{form}{keyword} ne "") {
|
||||
$search = " where (name like '%".$session{form}{keyword}.
|
||||
"%' or username like '%".$session{form}{keyword}.
|
||||
"%' or filename like '%".$session{form}{keyword}."%') ";
|
||||
$search_group = " where (name like '%".$session{form}{keyword}.
|
||||
"%' or description like '%".$session{form}{keyword}."%') and imageGroupId>0";
|
||||
} else {
|
||||
$search = " where imageGroupId='".$imageGroupId."' ";
|
||||
$search_group = " where parentId='".$imageGroupId."' and imageGroupId>0 ";
|
||||
}
|
||||
# do image groups
|
||||
if($imageGroupId > 0) { # show previous link
|
||||
$row[$i] = '<tr class="tableData">';
|
||||
$row[$i] .= '<td colspan="5"><a href="'.WebGUI::URL::page('op=listImages&gid='.$imageGroupParentId)
|
||||
.'"><img src="'.$session{config}{extras}.'/smallAttachment.gif" border="0"></a>'
|
||||
.' <a href="'.WebGUI::URL::page('op=listImages&gid='.$imageGroupParentId)
|
||||
.'">'.WebGUI::International::get(542).'</a></td>'; # FIXME folder icon
|
||||
$row[$i] .= '</tr>';
|
||||
$i++;
|
||||
}
|
||||
$sth = WebGUI::SQL->read("select * from imageGroup $search_group order by name");
|
||||
while (%data = $sth->hash) {
|
||||
$row[$i] = '<tr class="tableData"><td>';
|
||||
if ($isImageManager) {
|
||||
$row[$i] .= deleteIcon('op=deleteImageGroup&gid='.$data{imageGroupId}.'&pid='.$imageGroupId);
|
||||
$row[$i] .= editIcon('op=editImageGroup&gid='.$data{imageGroupId}.'&pid='.$imageGroupId);
|
||||
}
|
||||
$row[$i] .= viewIcon('op=viewImageGroup&gid='.$data{imageGroupId}.'&pid='.$imageGroupId);
|
||||
$row[$i] .= '</td>';
|
||||
$row[$i] .= '<td><a href="'.WebGUI::URL::page('op=listImages&gid='.$data{imageGroupId}.'&pid='.$imageGroupId)
|
||||
.'"><img src="'.$session{config}{extras}.'/smallAttachment.gif" border="0"></a>'
|
||||
.' <a href="'.WebGUI::URL::page('op=listImages&gid='.$data{imageGroupId}.'&pid='.$imageGroupId)
|
||||
.'">'.$data{name}.'</a></td>'; # FIXME folder icon
|
||||
$row[$i] .= '<td>'.$data{description}.' </td>';
|
||||
$row[$i] .= '<td> </td>';
|
||||
$row[$i] .= '<td> </td>';
|
||||
$row[$i] .= '</tr>';
|
||||
$i++;
|
||||
}
|
||||
$sth->finish;
|
||||
# do images
|
||||
$sth = WebGUI::SQL->read("select * from images $search order by name");
|
||||
while (%data = $sth->hash) {
|
||||
$image = WebGUI::Attachment->new($data{filename},"images",$data{imageId});
|
||||
$row[$i] = '<tr class="tableData"><td>';
|
||||
if ($isAdmin || $session{user}{userId} == $data{userId}) {
|
||||
$row[$i] .= deleteIcon('op=deleteImage&iid='.$data{imageId}.'&gid='.$data{imageGroupId});
|
||||
$row[$i] .= editIcon('op=editImage&iid='.$data{imageId}.'&gid='.$data{imageGroupId});
|
||||
}
|
||||
$row[$i] .= viewIcon('op=viewImage&iid='.$data{imageId}.'&gid='.$data{imageGroupId});
|
||||
$row[$i] .= '</td>';
|
||||
$row[$i] .= '<td><a href="'.WebGUI::URL::page('op=viewImage&iid='.$data{imageId}.'&gid='.$data{imageGroupId})
|
||||
.'"><img src="'.$image->getThumbnail.'" border="0"></a>';
|
||||
$row[$i] .= '<td>'.$data{name}.'</td>';
|
||||
$row[$i] .= '<td>'.$data{username}.'</td>';
|
||||
$row[$i] .= '<td>'.WebGUI::DateTime::epochToHuman($data{dateUploaded},"%M/%D/%y").'</td>';
|
||||
$row[$i] .= '</tr>';
|
||||
$i++;
|
||||
}
|
||||
$sth->finish;
|
||||
$p = WebGUI::Paginator->new(WebGUI::URL::page('op=listImages&gid='.$session{form}{gid}),\@row);
|
||||
$output .= '<table border=1 cellpadding=5 cellspacing=0 align="center">';
|
||||
$output .= $p->getPage($session{form}{pn});
|
||||
$output .= '</table>';
|
||||
$output .= $p->getBarTraditional($session{form}{pn});
|
||||
return $output;
|
||||
} else {
|
||||
return WebGUI::Privilege::insufficient();
|
||||
}
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_viewImage {
|
||||
my ($output, %data, $image,$f);
|
||||
tie %data, 'Tie::CPHash';
|
||||
if (WebGUI::Privilege::isInGroup(4)) {
|
||||
%data = WebGUI::SQL->quickHash("select * from images where imageId=$session{form}{iid}");
|
||||
$image = WebGUI::Attachment->new($data{filename},"images",$data{imageId});
|
||||
$output .= '<h1>'.WebGUI::International::get(396).'</h1>';
|
||||
$output .= '<a href="'.WebGUI::URL::page('op=listImages&gid='.$session{form}{gid}).'">'.WebGUI::International::get(397).'</a>';
|
||||
$f = WebGUI::HTMLForm->new;
|
||||
$f->readOnly($data{imageId},WebGUI::International::get(389));
|
||||
$f->readOnly($data{name},WebGUI::International::get(383));
|
||||
$f->readOnly($data{filename},WebGUI::International::get(384));
|
||||
$f->readOnly($data{parameters},WebGUI::International::get(385));
|
||||
$f->readOnly($data{username},WebGUI::International::get(387));
|
||||
$f->readOnly(WebGUI::DateTime::epochToHuman($data{dateUploaded},"%z %z"),WebGUI::International::get(388));
|
||||
$output .= $f->print;
|
||||
$output .= '<p><img src="'.$image->getURL.'">';
|
||||
return $output;
|
||||
} else {
|
||||
return WebGUI::Privilege::insufficient();
|
||||
}
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_deleteImageGroup {
|
||||
my ($output);
|
||||
if (WebGUI::Privilege::isInGroup($session{setting}{imageManagersGroup})) {
|
||||
$output .= helpIcon(23);
|
||||
$output .= '<h1>'.WebGUI::International::get(42).'</h1>';
|
||||
$output .= WebGUI::International::get(544).'<p>';
|
||||
$output .= '<div align="center"><a href="'.
|
||||
WebGUI::URL::page('op=deleteImageGroupConfirm&gid='.$session{form}{gid}.'&pid='.$session{form}{pid})
|
||||
.'">'.WebGUI::International::get(44).'</a>';
|
||||
$output .= ' <a href="'.WebGUI::URL::page('op=listImages&gid='.$session{form}{pid}).'">'.
|
||||
WebGUI::International::get(45).'</a></div>';
|
||||
return $output;
|
||||
} else {
|
||||
return WebGUI::Privilege::insufficient();
|
||||
}
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_deleteImageGroupConfirm {
|
||||
my ($image, %data);
|
||||
tie %data, 'Tie::CPHash';
|
||||
if (WebGUI::Privilege::isInGroup($session{setting}{imageManagersGroup})) {
|
||||
%data = WebGUI::SQL->quickHash("select parentId from imageGroup where imageGroupId=$session{form}{gid}");
|
||||
WebGUI::SQL->write("update images set imageGroupId=$data{parentId} where imageGroupId=$session{form}{gid}");
|
||||
WebGUI::SQL->write("update imageGroup set parentId=$data{parentId} where parentId=$session{form}{gid}");
|
||||
WebGUI::SQL->write("delete from imageGroup where imageGroupId=$session{form}{gid}");
|
||||
$session{form}{gid}=$session{form}{pid};
|
||||
return www_listImages();
|
||||
} else {
|
||||
return WebGUI::Privilege::insufficient();
|
||||
}
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_editImageGroup {
|
||||
my ($output, %data, %parent_data, $image, $f);
|
||||
tie %data, 'Tie::CPHash';
|
||||
tie %parent_data, 'Tie::CPHash';
|
||||
if (WebGUI::Privilege::isInGroup($session{setting}{imageManagersGroup})) {
|
||||
if ($session{form}{gid} eq "new") {
|
||||
|
||||
} else {
|
||||
%data = WebGUI::SQL->quickHash("select * from imageGroup where imageGroupId=$session{form}{gid}");
|
||||
}
|
||||
%parent_data = WebGUI::SQL->quickHash("select name from imageGroup where imageGroupId=$session{form}{pid}");
|
||||
$output = helpIcon(36);
|
||||
$output .= '<h1>'.WebGUI::International::get(545).'</h1>';
|
||||
$f = WebGUI::HTMLForm->new;
|
||||
$f->hidden("op","editImageGroupSave");
|
||||
$f->hidden("gid",$session{form}{gid});
|
||||
$f->hidden("pid",$session{form}{pid}); #FIXME make this dropdown group tree
|
||||
$f->readOnly($session{form}{gid},WebGUI::International::get(546));
|
||||
$f->readOnly($parent_data{name},WebGUI::International::get(547));
|
||||
$f->text("name",WebGUI::International::get(548),$data{name});
|
||||
$f->text("description",WebGUI::International::get(549),$data{description});
|
||||
$f->submit;
|
||||
$output .= $f->print;
|
||||
return $output;
|
||||
} else {
|
||||
return WebGUI::Privilege::insufficient();
|
||||
}
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_editImageGroupSave {
|
||||
my ($test);
|
||||
if (WebGUI::Privilege::isInGroup($session{setting}{imageManagersGroup})) {
|
||||
if ($session{form}{gid} eq "new") {
|
||||
$session{form}{gid} = getNextId("imageGroupId");
|
||||
WebGUI::SQL->write("insert into imageGroup (imageGroupId) values ($session{form}{gid})");
|
||||
}
|
||||
while (($test) = WebGUI::SQL->quickArray("select name from imageGroup
|
||||
where name=".quote($session{form}{name})." and imageGroupId<>$session{form}{gid}")) {
|
||||
if ($session{form}{name} =~ /(.*)(\d+$)/) {
|
||||
$session{form}{name} = $1.($2+1);
|
||||
} elsif ($test ne "") {
|
||||
$session{form}{name} .= "2";
|
||||
}
|
||||
}
|
||||
WebGUI::SQL->write("update imageGroup set name=".quote($session{form}{name}).
|
||||
", parentId=".$session{form}{pid}.", description=".quote($session{form}{description}).
|
||||
" where imageGroupId=$session{form}{gid}");
|
||||
return www_listImages();
|
||||
} else {
|
||||
return WebGUI::Privilege::insufficient();
|
||||
}
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_viewImageGroup {
|
||||
my ($output, %data, %parent_data, $image,$f);
|
||||
tie %data, 'Tie::CPHash';
|
||||
tie %parent_data, 'Tie::CPHash';
|
||||
if (WebGUI::Privilege::isInGroup(4)) {
|
||||
%data = WebGUI::SQL->quickHash("select * from imageGroup where imageGroupId=$session{form}{gid}");
|
||||
%parent_data = WebGUI::SQL->quickHash("select name from imageGroup where imageGroupId=".$data{parentId});
|
||||
$output .= '<h1>'.WebGUI::International::get(550).'</h1>';
|
||||
$output .= '<a href="'.WebGUI::URL::page('op=listImages&gid='.$session{form}{pid}).'">'.WebGUI::International::get(397).'</a>';
|
||||
$f = WebGUI::HTMLForm->new;
|
||||
$f->readOnly($data{imageGroupId},WebGUI::International::get(546));
|
||||
$f->readOnly($parent_data{name},WebGUI::International::get(547));
|
||||
$f->readOnly($data{name},WebGUI::International::get(548));
|
||||
$f->readOnly($data{description},WebGUI::International::get(549));
|
||||
$output .= $f->print;
|
||||
return $output;
|
||||
} else {
|
||||
return WebGUI::Privilege::insufficient();
|
||||
}
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
|
||||
|
|
@ -27,6 +27,8 @@ use WebGUI::URL;
|
|||
|
||||
use WebGUI::Paginator;
|
||||
$p = WebGUI::Paginator->new("/index.pl/page_name?this=that",\@row);
|
||||
$p->setDataByQuery($sql);
|
||||
|
||||
$html = $p->getBar;
|
||||
$html = $p->getBarAdvanced;
|
||||
$html = $p->getBarSimple;
|
||||
|
|
@ -201,7 +203,7 @@ sub getFirstPageLink {
|
|||
$text = '|<'.WebGUI::International::get(404);
|
||||
if ($pn > 1) {
|
||||
return '<a href="'.
|
||||
WebGUI::URL::append($_[0]->{_url},($_[0]->{_pn}.'=1'))
|
||||
WebGUI::URL::append($_[0]->{_url},($_[0]->{_formVar}.'=1'))
|
||||
.'">'.$text.'</a>';
|
||||
} else {
|
||||
return $text;
|
||||
|
|
@ -228,7 +230,7 @@ sub getLastPageLink {
|
|||
$text = WebGUI::International::get(405).'>|';
|
||||
if ($pn != $_[0]->getNumberOfPages) {
|
||||
return '<a href="'.
|
||||
WebGUI::URL::append($_[0]->{_url},($_[0]->{_pn}.'='.$_[0]->getNumberOfPages))
|
||||
WebGUI::URL::append($_[0]->{_url},($_[0]->{_formVar}.'='.$_[0]->getNumberOfPages))
|
||||
.'">'.$text.'</a>';
|
||||
} else {
|
||||
return $text;
|
||||
|
|
@ -254,7 +256,7 @@ sub getNextPageLink {
|
|||
$pn = $_[1] || $_[0]->getPageNumber;
|
||||
$text = WebGUI::International::get(92).'»';
|
||||
if ($pn < $_[0]->getNumberOfPages) {
|
||||
return '<a href="'.WebGUI::URL::append($_[0]->{_url},($_[0]->{_pn}.'='.($pn+1))).'">'.$text.'</a>';
|
||||
return '<a href="'.WebGUI::URL::append($_[0]->{_url},($_[0]->{_formVar}.'='.($pn+1))).'">'.$text.'</a>';
|
||||
} else {
|
||||
return $text;
|
||||
}
|
||||
|
|
@ -335,7 +337,7 @@ sub getPageData {
|
|||
=cut
|
||||
|
||||
sub getPageNumber {
|
||||
return $session{form}{$_[0]->{_pn}} || 1;
|
||||
return $_[0]->{_pn} || 1;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
|
@ -359,7 +361,7 @@ sub getPageLinks {
|
|||
$output .= ' '.($i+1).' ';
|
||||
} else {
|
||||
$output .= ' <a href="'.
|
||||
WebGUI::URL::append($_[0]->{_url},($_[0]->{_pn}.'='.($i+1)))
|
||||
WebGUI::URL::append($_[0]->{_url},($_[0]->{_formVar}.'='.($i+1)))
|
||||
.'">'.($i+1).'</a> ';
|
||||
}
|
||||
}
|
||||
|
|
@ -385,7 +387,7 @@ sub getPreviousPageLink {
|
|||
$pn = $_[1] || $_[0]->getPageNumber;
|
||||
$text = '«'.WebGUI::International::get(91);
|
||||
if ($pn > 1) {
|
||||
return '<a href="'.WebGUI::URL::append($_[0]->{_url},($_[0]->{_pn}.'='.($pn-1))).'">'.$text.'</a>';
|
||||
return '<a href="'.WebGUI::URL::append($_[0]->{_url},($_[0]->{_formVar}.'='.($pn-1))).'">'.$text.'</a>';
|
||||
} else {
|
||||
return $text;
|
||||
}
|
||||
|
|
@ -394,7 +396,7 @@ sub getPreviousPageLink {
|
|||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 new ( currentURL, rowArrayRef [, paginateAfter, alternateFormVar ] )
|
||||
=head2 new ( currentURL, rowArrayRef [, paginateAfter, pageNumber, formVar ] )
|
||||
|
||||
Constructor.
|
||||
|
||||
|
|
@ -412,25 +414,49 @@ sub getPreviousPageLink {
|
|||
The number of rows to display per page. If left blank it defaults
|
||||
to 50.
|
||||
|
||||
=item alternateFormVar
|
||||
=item pageNumber
|
||||
|
||||
By default the paginator uses a form variable of "pn" to denote the
|
||||
By default the paginator uses a form variable of "pn" to determine the
|
||||
page number. If you wish it to use some other variable, then specify
|
||||
it here.
|
||||
the page number here.
|
||||
|
||||
=item formVar
|
||||
|
||||
Specify the form variable the paginator should use in it's links.
|
||||
Defaults to "pn".
|
||||
|
||||
=cut
|
||||
|
||||
sub new {
|
||||
my ($class, $currentURL, $rowsPerPage, $rowRef, $formVar, $pageRef);
|
||||
my ($class, $currentURL, $rowsPerPage, $rowRef, $formVar, $pageRef, $pn);
|
||||
$class = shift;
|
||||
$currentURL = shift;
|
||||
$rowRef = shift;
|
||||
$rowsPerPage = shift || 25;
|
||||
$pn = shift || $session{form}{$formVar};
|
||||
$formVar = shift || "pn";
|
||||
bless {_url => $currentURL, _rpp => $rowsPerPage, _rowRef => $rowRef, _pn => $formVar}, $class;
|
||||
bless {_url => $currentURL, _rpp => $rowsPerPage, _rowRef => $rowRef, _formVar => $formVar, _pn => $pn}, $class;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 setDataByQuery ( query [, dbh ] )
|
||||
|
||||
Retrieves a data set from a database and replaces whatever data
|
||||
set was passed in through the constructor.
|
||||
|
||||
NOTE: This retrieves only the current page's data for efficiency.
|
||||
|
||||
=item query
|
||||
|
||||
An SQL query that will retrieve a data set.
|
||||
|
||||
=item dbh
|
||||
|
||||
A DBI-style database handler. Defaults to the WebGUI site handler.
|
||||
|
||||
=cut
|
||||
|
||||
sub setDataByQuery {
|
||||
my ($sth, $pageCount, $rowCount, $dbh, $sql, $self, @row, $data);
|
||||
($self, $sql, $dbh) = @_;
|
||||
|
|
|
|||
|
|
@ -312,15 +312,20 @@ sub setCookie {
|
|||
=cut
|
||||
|
||||
sub setScratch {
|
||||
return "" unless ($session{var}{sessionId});
|
||||
if ($session{scratch}{$_[0]} ne "") {
|
||||
WebGUI::SQL->write("update userSessionScratch set value=".quote($_[1])."
|
||||
where sessionId=".quote($session{var}{sessionId})." and name=".quote($_[0]));
|
||||
my ($name, $value) = @_;
|
||||
return "" unless ($session{var}{sessionId} ne "" && $name ne "" && $value ne "");
|
||||
if ($value eq "-delete-") {
|
||||
WebGUI::SQL->write("delete from userSessionScratch where sessionId=".quote($session{var}{sessionId})
|
||||
." and name=".quote($name));
|
||||
$value = "";
|
||||
} elsif ($session{scratch}{$name} ne "") {
|
||||
WebGUI::SQL->write("update userSessionScratch set value=".quote($value)."
|
||||
where sessionId=".quote($session{var}{sessionId})." and name=".quote($name));
|
||||
} else {
|
||||
WebGUI::SQL->write("insert into userSessionScratch (sessionId,name,value) values
|
||||
(".quote($session{var}{sessionId}).", ".quote($_[0]).", ".quote($_[1]).")");
|
||||
(".quote($session{var}{sessionId}).", ".quote($name).", ".quote($value).")");
|
||||
}
|
||||
$session{scratch}{$_[0]} = $_[1];
|
||||
$session{scratch}{$name} = $value;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue