added zip archive and in/out board assets

This commit is contained in:
JT Smith 2005-11-19 20:54:15 +00:00
parent 57eaa1f73f
commit cb4729f7e7
15 changed files with 1674 additions and 34 deletions

View file

@ -0,0 +1,312 @@
package WebGUI::Asset::File::ZipArchive;
=head1 LEGAL
-------------------------------------------------------------------
WebGUI is Copyright 2001-2005 Plain Black Corporation.
-------------------------------------------------------------------
Please read the legal notices (docs/legal.txt) and the license
(docs/license.txt) that came with this distribution before using
this software.
-------------------------------------------------------------------
http://www.plainblack.com info@plainblack.com
-------------------------------------------------------------------
=cut
use strict;
use WebGUI::Asset::File;
use WebGUI::HTMLForm;
use WebGUI::HTTP;
use WebGUI::Session;
use WebGUI::SQL;
use WebGUI::Utility;
use Archive::Tar;
use Archive::Zip;
our @ISA = qw(WebGUI::Asset::File);
=head1 NAME
Package WebGUI::Asset::ZipArchive
=head1 DESCRIPTION
Provides a mechanism to upload and automatically extract a zip archive
containing related items. An asset setting will set the launch point of the archive.
=head1 SYNOPSIS
use WebGUI::Asset::ZipArchive;
=head1 METHODS
These methods are available from this class:
=cut
#-------------------------------------------------------------------
sub unzip {
my $self = shift;
my $storage = $_[0];
my $filename = $_[1];
my $filepath = $storage->getPath();
chdir $filepath;
if($filename =~ m/\.zip/i){
my $zip = Archive::Zip->new();
unless ($zip->read($filename) == $zip->AZ_OK){
WebGUI::ErrorHandler::warn(WebGUI::International::get("zip_error","Asset_ZipArchive"));
return 0;
}
$zip->extractTree();
} elsif($filename =~ m/\.tar/i){
Archive::Tar->extract_archive($filepath.$session{os}{slash}.$filename,1);
if (Archive::Tar->error){
WebGUI::ErrorHandler::warn(Archive::Tar->error);
return 0;
}
} else{
WebGUI::ErrorHandler::warn(WebGUI::International::get("bad_archive","Asset_ZipArchive"));
}
return 1;
}
#-------------------------------------------------------------------
=head2 addRevision
This method exists for demonstration purposes only. The superclass
handles revisions to ZipArchive Assets.
=cut
sub addRevision {
my $self = shift;
my $newSelf = $self->SUPER::addRevision(@_);
return $newSelf;
}
#-------------------------------------------------------------------
=head2 definition ( definition )
Defines the properties of this asset.
=head3 definition
A hash reference passed in from a subclass definition.
=cut
sub definition {
my $class = shift;
my $definition = shift;
push(@{$definition}, {
assetName=>WebGUI::International::get('asset label',"Asset_ZipArchive"),
tableName=>'ZipArchiveAsset',
className=>'WebGUI::Asset::File',
properties=>{
showPage=>{
fieldType=>'text',
defaultValue=>'index.html'
},
templateId=>{
fieldType=>'template',
defaultValue=>''
},
}
});
return $class->SUPER::definition($definition);
}
#-------------------------------------------------------------------
=head2 duplicate
This method exists for demonstration purposes only. The superclass
handles duplicating ZipArchive Assets. This method will be called
whenever a copy action is executed
=cut
sub duplicate {
my $self = shift;
my $newAsset = $self->SUPER::duplicate(shift);
return $newAsset;
}
#-------------------------------------------------------------------
=head2 getEditForm ()
Returns the TabForm object that will be used in generating the edit page for this asset.
=cut
sub getEditForm {
my $self = shift;
my $tabform = $self->SUPER::getEditForm();
$tabform->getTab("display")->template(
-value=>$self->getValue("templateId"),
-label=>WebGUI::International::get('template label', 'Asset_ZipArchive'),
-namespace=>"ZipArchiveAsset"
);
$tabform->getTab("properties")->text (
-name=>"showPage",
-label=>WebGUI::International::get('show page', 'Asset_ZipArchive'),
-value=>$self->getValue("showPage"),
-hoverHelp=>WebGUI::International::get('show page description', 'Asset_ZipArchive'),
);
return $tabform;
}
#-------------------------------------------------------------------
=head2 getIcon ( [small] )
Returns the icons to be associated with this asset
=head3 small
If this evaluates to True, then the smaller icon is returned.
=cut
sub getIcon {
my $self = shift;
my $small = shift;
return $session{config}{extrasURL}.'/assets/ziparchive.gif' unless ($small);
return $session{config}{extrasURL}.'/assets/small/ziparchive.gif';
}
#-------------------------------------------------------------------
=head2 processPropertiesFromFormPost ( )
Used to process properties from the form posted. In this asset, we use
this method to deflate the zip file into the proper folder
=cut
sub processPropertiesFromFormPost {
my $self = shift;
#File should be saved here by the superclass
$self->SUPER::processPropertiesFromFormPost;
my $storage = $self->getStorageLocation();
my $file = $self->get("filename");
#return unless $file;
unless($session{form}{showPage}) {
$storage->delete;
WebGUI::SQL->write("update FileAsset set filename=NULL where assetId=".quote($self->getId));
WebGUI::Session::setScratch("za_error",WebGUI::International::get("za_show_error","Asset_ZipArchive"));
return;
}
unless($file =~ m/\.tar/i || $file =~ m/\.zip/i) {
$storage->delete;
WebGUI::SQL->write("update FileAsset set filename=NULL where assetId=".quote($self->getId));
WebGUI::Session::setScratch("za_error",WebGUI::International::get("za_error","Asset_ZipArchive"));
return;
}
unless ($self->unzip($storage,$self->get("filename"))) {
WebGUI::ErrorHandler::warn(WebGUI::International::get("unzip_error","Asset_ZipArchive"));
}
}
#-------------------------------------------------------------------
=head2 purge ( )
This method is called when data is purged by the system.
=cut
sub purge {
my $self = shift;
return $self->SUPER::purge;
}
#-------------------------------------------------------------------
=head2 purgeRevision ( )
This method is called when data is purged by the system.
=cut
sub purgeRevision {
my $self = shift;
return $self->SUPER::purgeRevision;
}
#-------------------------------------------------------------------
=head2 view ( )
method called by the container www_view method. In this asset, this is
used to show the file to administrators.
=cut
sub view {
my $self = shift;
my %var = %{$self->get};
#WebGUI::ErrorHandler::warn($self->getId);
$var{controls} = $self->getToolbar;
if($session{scratch}{za_error}) {
$var{error} = $session{scratch}{za_error};
}
WebGUI::Session::deleteScratch("za_error");
my $storage = $self->getStorageLocation;
if($self->get("filename") ne "") {
$var{fileUrl} = $storage->getUrl($self->get("showPage"));
$var{fileIcon} = $storage->getFileIconUrl($self->get("showPage"));
}
unless($self->get("showPage")) {
$var{pageError} = "true";
}
return $self->processTemplate(\%var,$self->get("templateId"));
}
#-------------------------------------------------------------------
=head2 www_edit ( )
Web facing method which is the default edit page
=cut
sub www_edit {
my $self = shift;
return WebGUI::Privilege::insufficient() unless $self->canEdit;
$self->getAdminConsole->setHelp("zip archive add/edit", "Asset_ZipArchive");
return $self->getAdminConsole->render($self->getEditForm->print,
WebGUI::International::get('edit asset',"Asset_ZipArchive"));
}
#-------------------------------------------------------------------
=head2 www_view ( )
Web facing method which is the default view page. This method does a
302 redirect to the "showPage" file in the storage location.
=cut
sub www_view {
my $self = shift;
return WebGUI::Privilege::noAccess() unless $self->canView;
if (WebGUI::Session::isAdminOn()) {
return $self->getContainer->www_view;
}
WebGUI::HTTP::setRedirect($self->getFileUrl($self->getValue("showPage")));
return "";
}
1;

View file

@ -0,0 +1,504 @@
package WebGUI::Asset::Wobject::InOutBoard;
$VERSION = "0.5.3";
use strict;
use WebGUI::DateTime;
use WebGUI::FormProcessor;
use WebGUI::Grouping;
use WebGUI::HTMLForm;
use WebGUI::International;
use WebGUI::Paginator;
use WebGUI::Privilege;
use WebGUI::Session;
use WebGUI::SQL;
use WebGUI::URL;
use WebGUI::Asset::Wobject;
use WebGUI::ErrorHandler;
use Data::Dumper;
our @ISA = qw(WebGUI::Asset::Wobject);
#See line 285 if you wish to change the users visible in the delegate select list
#-------------------------------------------------------------------
sub _defineUsername {
my $data = shift;
if ($data->{firstName} ne "" && $data->{lastName} ne "") {
return join ' ', $data->{firstName}, $data->{lastName};
}
else {
return $data->{username};
}
}
#-------------------------------------------------------------------
sub _fetchNames {
my @userIds = @_;
my %nameHash;
my $sql = "select users.username,
users.userId,
a.fieldData as firstName,
b.fieldData as lastName
from users
left join userProfileData a on users.userId=a.userId and a.fieldName='firstName'
left join userProfileData b on users.userId=b.userId and b.fieldName='lastName'
where users.userId=?";
my $sth = WebGUI::SQL->prepare($sql);
foreach my $userId (@userIds) {
$sth->execute([ $userId ]);
$nameHash{ $userId } = _defineUsername($sth->hashRef);
}
$sth->finish;
return %nameHash;
}
#-------------------------------------------------------------------
sub _fetchDepartments {
return WebGUI::SQL->buildArray("select fieldData from userProfileData where fieldName='department' GROUP by fieldData");
}
#-------------------------------------------------------------------
sub definition {
my $class = shift;
my $definition = shift;
push(@{$definition}, {
tableName=>'InOutBoard',
className=>'WebGUI::Asset::Wobject::InOutBoard',
properties=>{
statusList => {
defaultValue => WebGUI::International::get(10, "Asset_InOutBoard")."\n"
.WebGUI::International::get(11, "Asset_InOutBoard")."\n",
fieldType=>"textarea"
},
reportViewerGroup => {
defaultValue => 3,
fieldType => "group"
},
inOutGroup => {
defaultValue => 2,
fieldType => "group"
},
inOutTemplateId => {
fieldType=>"template",
defaultValue => 'IOB0000000000000000001'
},
reportTemplateId => {
fieldType=>"template",
defaultValue => 'IOB0000000000000000002'
},
paginateAfter => {
fieldType=>"integer",
defaultValue => 50
},
}
});
return $class->SUPER::definition($definition);
}
#-------------------------------------------------------------------
sub getEditForm {
my $self = shift;
my $tabform = $self->SUPER::getEditForm();
$tabform->getTab("properties")->textarea(
-name=>"statusList",
-label=>WebGUI::International::get(1, "Asset_InOutBoard"),
-value=>$self->getValue("statusList"),
-subtext=>WebGUI::International::get(2, "Asset_InOutBoard"),
);
$tabform->getTab("display")->integer(
-name=>"paginateAfter",
-label=>WebGUI::International::get(12, "Asset_InOutBoard"),
-value=>$self->getValue("paginateAfter")
);
$tabform->getTab("display")->template (
-name => "inOutTemplateId",
-value => $self->getValue("inOutTemplateId"),
-label => WebGUI::International::get("In Out Template", "Asset_InOutBoard"),
-namespace => "InOutBoard"
);
$tabform->getTab("display")->template (
-name => "reportTemplateId",
-value => $self->getValue("reportTemplateId"),
-label => WebGUI::International::get(13, "Asset_InOutBoard"),
-namespace => "InOutBoard/Report"
);
$tabform->getTab("security")->group(
-name=>"reportViewerGroup",
-value=>[$self->getValue("reportViewerGroup")],
-label=>WebGUI::International::get(3, "Asset_InOutBoard")
);
$tabform->getTab("security")->group(
-name=>"inOutGroup",
-value=>[$self->getValue("inOutGroup")],
-label=>WebGUI::International::get('inOutGroup', "Asset_InOutBoard")
);
return $tabform;
}
#-------------------------------------------------------------------
sub getName {
return WebGUI::International::get(9,"Asset_InOutBoard");
}
#-------------------------------------------------------------------
sub view {
my $self = shift;
my %var;
my $url = $self->getUrl('func=view');
if (WebGUI::Grouping::isInGroup($self->getValue("reportViewerGroup"))) {
$var{'viewReportURL'} = $self->getUrl("func=viewReport");
$var{canViewReport} = 1;
}
else { $var{canViewReport} = 0; }
my $statusUserId = $session{scratch}{userId} || $session{user}{userId};
my $statusListString = $self->getValue("statusList");
chop($statusListString);
my @statusListArray = split("\n",$statusListString);
my $statusListHashRef;
foreach my $status (@statusListArray) {
chop($status);
$statusListHashRef->{$status} = $status;
}
#WebGUI::ErrorHandler::warn("VIEW: userId: ".$statusUserId."\n" );
my ($status) = WebGUI::SQL->quickArray("select status from InOutBoard_status where userId=".quote($statusUserId)." and assetId=".quote($self->getId));
##Find all the users for which I am a delegate
my @users = WebGUI::SQL->buildArray("select userId from InOutBoard_delegates where assetId=".quote($self->getId)." and delegateUserId=".quote($session{user}{userId}));
my $f = WebGUI::HTMLForm->new(-action=>$self->getUrl);
if (@users) {
my %nameHash;
tie %nameHash, "Tie::IxHash";
%nameHash = _fetchNames(@users);
$nameHash{""} = WebGUI::International::get('myself',"Asset_InOutBoard");
%nameHash = WebGUI::Utility::sortHash(%nameHash);
$f->selectList(
-name=>"delegate",
-options=>\%nameHash,
-value=>[ $session{scratch}{userId} ],
-label=>WebGUI::International::get('delegate', "Asset_InOutBoard"),
-extras=>q|onchange="this.form.submit();"|,
);
}
$f->radioList(
-name=>"status",
-value=>$status,
-options=>$statusListHashRef,
-label=>WebGUI::International::get(5, "Asset_InOutBoard")
);
$f->text(
-name=>"message",
-label=>WebGUI::International::get(6, "Asset_InOutBoard")
);
$f->hidden(
-name=>"func",
-value=>"setStatus"
);
$f->submit;
my ($isInGroup) = WebGUI::SQL->quickArray("select count(*) from groupings where userId=".quote($session{user}{userId})." and groupId=".quote($self->get("inOutGroup")));
if ($isInGroup) {
$var{displayForm} = 1;
$var{'form'} = $f->print;
$var{'selectDelegatesURL'} = $self->getUrl("func=selectDelegates");
}
else { $var{displayForm} = 0; }
my $lastDepartment = "_nothing_";
my $p = WebGUI::Paginator->new($url, $self->getValue("paginateAfter"));
my $sql = "select users.username,
users.userId,
a.fieldData as firstName,
InOutBoard_status.message,
b.fieldData as lastName,
InOutBoard_status.status,
InOutBoard_status.dateStamp,
c.fieldData as department,
groupings.groupId
from users, InOutBoard, groupings
left join userProfileData a on users.userId=a.userId and a.fieldName='firstName'
left join userProfileData b on users.userId=b.userId and b.fieldName='lastName'
left join userProfileData c on users.userId=c.userId and c.fieldName='department'
left join InOutBoard_status on users.userId=InOutBoard_status.userId and InOutBoard_status.assetId=".quote($self->getId())."
where users.userId<>'1' and groupings.groupId=InOutBoard.inOutGroup and groupings.userId=users.userId and InOutBoard.inOutGroup=".quote($self->get("inOutGroup"))."
group by userId
order by department, lastName, firstName";
$p->setDataByQuery($sql);
my $rowdata = $p->getPageData();
my @rows;
foreach my $data (@$rowdata) {
my %row;
if ($lastDepartment ne $data->{department}) {
$row{deptHasChanged} = 1;
$row{'department'} = ($data->{department}||WebGUI::International::get(7, "Asset_InOutBoard"));
$lastDepartment = $data->{department};
}
else { $row{deptHasChanged} = 0; }
if ($data->{firstName} ne "" && $data->{lastName} ne "") {
$row{'username'} = $data->{firstName}." ".$data->{lastName};
}
else {
$row{'username'} = $data->{username};
}
$row{'status'} = ($data->{status}||WebGUI::International::get(15, "Asset_InOutBoard"));
$row{'dateStamp'} = WebGUI::DateTime::epochToHuman($data->{dateStamp});
$row{'message'} = ($data->{message}||"&nbsp;");
push (@rows, \%row);
}
$var{rows_loop} = \@rows;
$var{'paginateBar'} = $p->getBarTraditional();
$p->appendTemplateVars(\%var);
return $self->processTemplate(\%var,$self->getValue("inOutTemplateId"));
}
#-------------------------------------------------------------------
sub www_edit {
my $self = shift;
return WebGUI::Privilege::insufficient() unless $self->canEdit;
return $self->getAdminConsole->render($self->getEditForm->print,WebGUI::International::get("Edit In/Out Board","Asset_InOutBoard"));
}
#-------------------------------------------------------------------
sub www_selectDelegates {
my $self = shift;
#Uncomment the sql query below (lines 286 - 294) to show all users of the system in the delegate select list
#my $sql = sprintf "select users.username,
#users.userId,
#a.fieldData as firstName,
#b.fieldData as lastName
#from users
#left join userProfileData a on users.userId=a.userId and a.fieldName='firstName'
#left join userProfileData b on users.userId=b.userId and b.fieldName='lastName'
#where users.userId<>'1' and users.status='Active' and users.userId<>%s
#group by userId", quote($session{user}{userId});
#Comment the sql query below (lines 297 - 307) to show all users of the system in the delegate select list
my $sql = sprintf "select users.username,
users.userId,
a.fieldData as firstName,
b.fieldData as lastName
from users, InOutBoard, groupings
left join userProfileData a on users.userId=a.userId and a.fieldName='firstName'
left join userProfileData b on users.userId=b.userId and b.fieldName='lastName'
left join userProfileData c on users.userId=c.userId and c.fieldName='department'
left join InOutBoard_status on users.userId=InOutBoard_status.userId and InOutBoard_status.assetId=%s
where users.userId<>'1' and groupings.groupId=InOutBoard.inOutGroup and users.status='Active' and users.userId <> %s and groupings.userId=users.userId and InOutBoard.inOutGroup=%s
group by userId", quote($self->getId), quote($session{user}{userId}), quote($self->getValue("inOutGroup")) ;
my %userNames = ();
my $sth = WebGUI::SQL->read($sql);
while (my $data = $sth->hashRef) {
$userNames{ $data->{userId} } = _defineUsername($data);
}
$sth->finish;
$sql = sprintf "select delegateUserId from InOutBoard_delegates where userId=%s and assetId=%s",
quote($session{user}{userId}), quote($self->getId);
my $delegates = WebGUI::SQL->buildArrayRef($sql);
my $f = WebGUI::HTMLForm->new(-action=>$self->getUrl);
$f->hidden(
-name => "func",
-value => "selectDelegatesEditSave"
);
$f->selectList(
-name => "delegates",
-label => WebGUI::International::get('in/out status delegates','Asset_InOutBoard'),
-options => \%userNames,
-multiple => 1, ##Multiple select
-size => 10, ##Multiple select
-sortByValue => 1,
-value => $delegates, ##My current delegates, if any
-subtext => WebGUI::International::get('in/out status delegates subtext','Asset_InOutBoard'),
);
$f->submit;
my $ac = $self->getAdminConsole;
return $ac->render($f->print,
WebGUI::International::get('select delegate','Asset_InOutBoard'));
}
#-------------------------------------------------------------------
sub www_selectDelegatesEditSave {
my $self = shift;
my @delegates = WebGUI::FormProcessor::selectList("delegates");
WebGUI::SQL->write("delete from InOutBoard_delegates where assetId=".quote($self->getId)." and userId=".quote($session{user}{userId}));
foreach my $delegate (@delegates) {
WebGUI::SQL->write("insert into InOutBoard_delegates
(userId,delegateUserId,assetId) values
(".quote($session{user}{userId}).",".quote($delegate).",".quote($self->getId).")");
}
return "";
}
#-------------------------------------------------------------------
sub www_setStatus {
my $self = shift;
#WebGUI::ErrorHandler::warn("delegateId: ". $session{form}{delegate}."\n" );
#WebGUI::ErrorHandler::warn("userId: ".$session{scratch}{userId} ."\n" );
if ($session{form}{delegate} eq $session{scratch}{userId}) {
#WebGUI::ErrorHandler::warn("Wrote data and removed scratch\n");
my $sessionUserId = $session{scratch}{userId} || $session{user}{userId};
#WebGUI::ErrorHandler::warn("user Id: ".$sessionUserId."\n");
WebGUI::Session::deleteScratch("userId");
WebGUI::SQL->write("delete from InOutBoard_status where userId=".quote($sessionUserId)." and assetId=".quote($self->getId));
WebGUI::SQL->write("insert into InOutBoard_status (assetId,userId,status,dateStamp,message) values (".quote($self->getId).",".quote($sessionUserId).","
.quote($session{form}{status}).",".WebGUI::DateTime::time().",".quote($session{form}{message}).")");
WebGUI::SQL->write("insert into InOutBoard_statusLog (assetId,userId,createdBy,status,dateStamp,message) values (".quote($self->getId).",".quote($sessionUserId).",".quote($session{user}{userId}).","
.quote($session{form}{status}).",".WebGUI::DateTime::time().",".quote($session{form}{message}).")");
}
else {
#WebGUI::ErrorHandler::warn("Set scratch, redisplay\n");
#WebGUI::ErrorHandler::warn(sprintf "Delegate is %s\n", $session{form}{delegate});
WebGUI::Session::setScratch("userId",$session{form}{delegate});
}
return $self->www_view;
}
sub www_view {
my $self = shift;
$self->SUPER::www_view(1);
}
#-------------------------------------------------------------------
sub www_viewReport {
my $self = shift;
return "" unless (WebGUI::Grouping::isInGroup($self->getValue("reportViewerGroup")));
my %var;
my $f = WebGUI::HTMLForm->new(-action=>$self->getUrl, -method=>"GET");
my %changedBy = ();
$f->hidden(
-name=>"func",
-value=>"viewReport"
);
$f->hidden(
-name=>"doit",
-value=>"1"
);
my $startDate = WebGUI::DateTime::addToDate(WebGUI::DateTime::time(),0,0,-15);
$startDate = WebGUI::FormProcessor::date("startDate") if ($session{form}{doit});
$f->date(
-name=>"startDate",
-label=>WebGUI::International::get(16, "Asset_InOutBoard"),
-value=>$startDate
);
my $endDate = WebGUI::FormProcessor::date("endDate");
$f->date(
-name=>"endDate",
-label=>WebGUI::International::get(17, "Asset_InOutBoard"),
-value=>$endDate
);
my %depHash;
%depHash = map { $_ => $_ } (_fetchDepartments(),
WebGUI::International::get('all departments', 'Asset_InOutBoard'));
my $defaultDepartment = $session{form}{selectDepartment}
|| WebGUI::International::get('all departments', 'Asset_InOutBoard');
my $departmentSQLclause = ($defaultDepartment eq WebGUI::International::get('all departments', 'Asset_InOutBoard'))
? ''
: 'and c.fieldData='.quote($defaultDepartment);
$f->selectList(
-name=>"selectDepartment",
-options=>\%depHash,
-value=>[ $defaultDepartment ],
-label=>WebGUI::International::get('filter departments', "Asset_InOutBoard"),
);
my %paginHash;
tie %paginHash, "Tie::IxHash"; ##Because default sort order is alpha
%paginHash = (50 => 50, 100 => 100, 300 => 300, 500 => 500, 1000 => 1000, 10_000 => 10_000,);
my $pageReportAfter = $session{form}{reportPagination} || 50;
$f->selectList(
-name=>"reportPagination",
-options=>\%paginHash,
-value=>[ $pageReportAfter ],
-label=>WebGUI::International::get(14, "Asset_InOutBoard"),
);
$f->submit(-value=>"Search");
$var{'form'} = $f->print;
my $url = $self->getUrl("func=viewReport&selectDepartment=$session{form}{selectDepartment}&reportPagination=$session{form}{reportPagination}&startDate=$session{form}{startDate}&endDate=$session{form}{endDate}&doit=1");
if ($session{form}{doit}) {
$var{showReport} = 1;
$endDate = WebGUI::DateTime::addToTime($endDate,24,0,0);
my $lastDepartment = "_none_";
my $p = WebGUI::Paginator->new($url, $pageReportAfter);
my $sql = "select users.username,
users.userId,
a.fieldData as firstName,
InOutBoard_statusLog.message,
b.fieldData as lastName,
InOutBoard_statusLog.status,
InOutBoard_statusLog.dateStamp,
InOutBoard_statusLog.createdBy,
c.fieldData as department,
groupings.groupId
from users, InOutBoard, groupings
left join userProfileData a on users.userId=a.userId and a.fieldName='firstName'
left join userProfileData b on users.userId=b.userId and b.fieldName='lastName'
left join userProfileData c on users.userId=c.userId and c.fieldName='department'
left join InOutBoard_statusLog on users.userId=InOutBoard_statusLog.userId and InOutBoard_statusLog.assetId=".quote($self->getId())."
where users.userId<>'1' and
groupings.groupId=".quote($self->getValue("inOutGroup"))." and
groupings.userId=users.userId and
InOutBoard_statusLog.dateStamp>=$startDate and
InOutBoard_statusLog.dateStamp<=$endDate
$departmentSQLclause
group by InOutBoard_statusLog.dateStamp
order by department, lastName, firstName, InOutBoard_statusLog.dateStamp";
#WebGUI::ErrorHandler::warn("QUERY: $sql\n");
$p->setDataByQuery($sql);
my $rowdata = $p->getPageData();
my @rows;
foreach my $data (@$rowdata) {
my %row;
if ($lastDepartment ne $data->{department}) {
$row{deptHasChanged} = 1;
$row{'department'} = ($data->{department}||WebGUI::International::get(7, "Asset_InOutBoard"));
$lastDepartment = $data->{department};
}
else { $row{deptHasChanged} = 0; }
$row{'username'} = _defineUsername($data);
$row{'status'} = ($data->{status}||WebGUI::International::get(15, "Asset_InOutBoard"));
$row{'dateStamp'} = WebGUI::DateTime::epochToHuman($data->{dateStamp});
$row{'message'} = ($data->{message}||"&nbsp;");
if (! exists $changedBy{ $data->{createdBy} }) {
my %whoChanged = _fetchNames($data->{createdBy});
$changedBy{ $data->{createdBy} } = $whoChanged{ $data->{createdBy} };
}
$row{'createdBy'} = $changedBy{ $data->{createdBy} };
push (@rows, \%row);
}
$var{rows_loop} = \@rows;
$var{'paginateBar'} = $p->getBarTraditional();
$var{'username.label'} = WebGUI::International::get('username.label','Asset_InOutBoard');
$var{'status.label'} = WebGUI::International::get(5,'Asset_InOutBoard');
$var{'date.label'} = WebGUI::International::get('date.label','Asset_InOutBoard');
$var{'message.label'} = WebGUI::International::get('message.label','Asset_InOutBoard');
$var{'updatedBy.label'} = WebGUI::International::get('updatedBy.label','Asset_InOutBoard');
$p->appendTemplateVars(\%var);
}
else { $var{showReport} = 0; }
return $self->processStyle($self->processTemplate(\%var, $self->getValue("reportTemplateId")));
}
1;

View file

@ -0,0 +1,61 @@
package WebGUI::Help::Asset_InOutBoard;
our $HELP = {
'1' => {
title => '18',
body => '19',
related => [
{
tag => '2',
namespace => 'Asset_InOutBoard'
},
{
tag => 'wobject add/edit',
namespace => 'WebGUI'
},
{
tag => 'wobjects using',
namespace => 'WebGUI'
}
]
},
'2' => {
title => '20',
body => '21',
related => [
{
tag => '1',
namespace => 'Asset_InOutBoard'
},
{
tag => 'template language',
namespace => 'WebGUI'
},
{
tag => 'wobject template',
namespace => 'WebGUI'
}
]
},
'3' => {
title => '22',
body => '23',
related => [
{
tag => '1',
namespace => 'Asset_InOutBoard'
},
{
tag => '2',
namespace => 'Asset_InOutBoard'
},
{
tag => 'template language',
namespace => 'WebGUI'
}
]
},
};
1;

View file

@ -0,0 +1,57 @@
package WebGUI::Help::Asset_ZipArchive;
our $HELP = {
'zip archive add/edit' => {
title => 'zip archive add/edit title',
body => 'zip archive add/edit body',
fields => [
{
title => 'new file',
description => 'new file description',
namespace => 'Asset_File',
},
{
title => 'current file',
description => 'current file description',
namespace => 'Asset_File',
},
{
title => 'show page',
description => 'show page description',
namespace => 'Asset_ZipArchive',
},
],
related => [
{
tag => 'asset fields',
namespace => 'Asset',
},
{
tag => 'zip archive template',
namespace => 'Asset_ZipArchive',
},
]
},
'zip archive template' => {
title => 'zip archive template title',
body => 'zip archive template body',
fields => [
],
related => [
{
tag => 'file add/edit',
namespace => 'Asset_File',
},
{
tag => 'template language',
namespace => 'Asset_Template',
},
]
},
};
1;

View file

@ -0,0 +1,230 @@
package WebGUI::i18n::English::Asset_InOutBoard;
our $I18N = {
'In Out Template' => {
message => q|In/Out Template|,
lastUpdated =>1091624565
},
'22' => {
message => q|In/Out Board, Report Template|,
lastUpdated =>1091624565
},
'18' => {
message => q|In/Out Board, Add/Edit|,
lastUpdated =>1091624565
},
'select delegate' => {
message => q|In/Out Board, Select Delegates|,
lastUpdated =>1122010599
},
'in/out status delegates' => {
message => q|In/Out Status Delegates|,
lastUpdated =>1122010599
},
'23' => {
message => q| The following variables are made available from In/Out Board Report:
<P><B>showReport</B><BR>A boolean indicating whether or not the&nbsp;<I>rows_loop</I> variable will be set. <BR><BR><B>form</B><BR>A variable that contains the HTML for displaying the&nbsp;Date Range Selector Form for the report.&nbsp;<BR><BR><B>rows_loop</B><BR>A loop containing the rows of data for the In/Out Board Report&nbsp;<BR><BR>
<BLOCKQUOTE><B>deptHasChanged</B><BR>A boolean value indicating whether or not this row of data is for a department that is differnet than the previous rows<BR><BR><B>username</B><BR>A variable that returns the users name. If the first and last name fields are defined in the user profile, that is what is returned. Otherwise, the users WebGUI username is returned. i.e., "John Doe" vs "Jdoe" <BR><BR><B>status</B><BR>A variable that returns the users status. The status of a user is defined by the Status List in the Wobject Properties. If no status is set for the current user 'Never Checked In' is returned. <BR><BR><B>dateStamp</B><BR>A variable that returns the date the status of the user was last updated. <BR><BR><B>message</B><BR>A variable that returns what the user entered in the "What's going on?" field when updating their status. <BR><BR></BLOCKQUOTE><B>paginateBar</B><BR>A variable that returns the HTML necessary to create a Traditional Pagination Bar. i.e., &lt;&lt; First, 1, 2, Last &gt;&gt; <BR><BR>|,
lastUpdated =>1091624565
},
'19' => {
message => q|An In/Out board is used to keep track of whether people are currently in/out of the office. It shows the current In/Out status of all WebGUI users and also logs the event the person has left for, the time they left and the time they return. <P><B>Status List</B><BR>The status list allows you to customize what the 'states' of a user are. i.e., 'In' or 'Out'. <P><B>Paginate After</B><BR>How many rows should be displayed before splitting the results into separate pages? In other words, how many rows should be displayed per page? <P><B>Report Paginate After</B><BR>Same as paginate after except that it controls the number of rows displayed in the In/Out Report. <P><B>Who Can View Reports?</B><BR>What group is allowed to view reports generated by the In/Out Board Wobject. <P></P>|,
lastUpdated =>1091624565
},
'20' => {
message => q|In/Out Board, Template|,
lastUpdated =>1091624565
},
'21' => {
message => q|The following variables are made available from In/Out Board:
<p><b>canViewReport</b><br />
A boolean indicating whether or not the <i>viewReportURL</i> variable will be set.</p>
<p><b>viewReportURL</b><br />
URL that links to the view report page.</p>
<p><b>selectDelegatesURL</b><br />
URL that links to a form where users can select other users (delegates) who
can alter their status.</p>
<p><b>displayForm</b><br />
A boolean indicating whether or not the <i>form</i> variable will be set.</p>
<p><b>form</b><br />
A variable that contains the HTML for displaying the In/Out Entry Form.</p>
<p><b>rows_loop</b><br />
A loop containing the rows of data for the In/Out Board</p>
<blockquote>
<p><b>deptHasChanged</b><br />
A boolean value indicating whether or not this row of data is for a department that is differnet than the previous rows</p>
<p><b>username</b><br />
A variable that returns the users name. If the first and last name fields are defined in the user profile, that is what is returned. Otherwise, the users WebGUI username is returned. i.e., "John Doe" vs "Jdoe"</p>
<p><b>status</b><br />
A variable that returns the users status. The status of a user is defined by the Status List in the Wobject Properties. If no status is set for the current user 'Never Checked In' is returned.</p>
<p><b>dateStamp</b><br />
A variable that returns the date the status of the user was last updated.</p>
<p><b>message</b><br />
A variable that returns what the user entered in the "What's going on?" field when updating their status.</p>
</blockquote>
<p><b>paginateBar</b><br />
A variable that returns the HTML necessary to create a Traditional Pagination Bar. i.e., &gt;&gt; First, 1, 2, Last &lt;&lt;</p>
|,
lastUpdated =>1122523725
},
'2' => {
message => q|Enter one per line.|,
lastUpdated =>1091624565
},
'in/out status delegates subtext' => {
message => q|Multiple users can be selected as delegates. Delegates will be able to update your status.|,
lastUpdated =>1122523790,
},
'17' => {
message => q|End Date|,
lastUpdated =>1091624565
},
'16' => {
message => q|Start Date|,
lastUpdated =>1091624565
},
'15' => {
message => q|Never Checked In|,
lastUpdated =>1091624565
},
'14' => {
message => q|Paginate Report After|,
lastUpdated =>1091624565
},
'13' => {
message => q|Report Template|,
lastUpdated =>1091624565
},
'12' => {
message => q|Paginate After|,
lastUpdated =>1091624565
},
'11' => {
message => q|Out|,
lastUpdated =>1091624565
},
'10' => {
message => q|In|,
lastUpdated =>1091624565
},
'9' => {
message => q|In/Out Board|,
lastUpdated =>1091624565
},
'8' => {
message => q|Status Log Report|,
lastUpdated =>1091624565
},
'7' => {
message => q|No Department|,
lastUpdated =>1091624565
},
'6' => {
message => q|What's happening?|,
lastUpdated =>1091624565
},
'delegate' => {
message => q|Update status for: |,
lastUpdated =>1122319088
},
'myself' => {
message => q|Myself|,
lastUpdated =>1122319088
},
'5' => {
message => q|Status|,
lastUpdated =>1091624565
},
'4' => {
message => q|View Report|,
lastUpdated =>1091624565
},
'3' => {
message => q|Who can view reports?|,
lastUpdated =>1091624565
},
'1' => {
message => q|Status List|,
lastUpdated =>1091624565
},
'inOutGroup' => {
message => q|Who can log in/out?|,
lastUpdated =>1091624565
},
'username.label' => {
message => q|Username|,
lastUpdated =>1123199740
},
'date.label' => {
message => q|Date|,
lastUpdated =>1123199740
},
'message.label' => {
message => q|Message|,
lastUpdated =>1123199740
},
'updatedBy.label' => {
message => q|Updated By|,
lastUpdated =>1123199740
},
'all departments' => {
message => q|All Departments|,
lastUpdated =>1123266324
},
'filter departments' => {
message => q|Filter departments:|,
lastUpdated =>1123266322
},
};
1;

View file

@ -0,0 +1,91 @@
package WebGUI::i18n::English::Asset_ZipArchive;
our $I18N = {
'zip_error' => {
message => q|An error occurred while trying to unzip the archive. Please check to make sure the file is not password protected and can be accessed by the operating system.|,
lastUpdated => 1119068809
},
'bad_archive' => {
message => q|Not a valid archive. Please use zip or tar archives to import files |,
lastUpdated => 1119068809
},
'unzip_error' => {
message => q|File could not be unzipped. Please upload a valid archive|,
lastUpdated => 1119068809
},
'template label' => {
message => q|Zip Archive Template|,
context => q|label for Zip Archive asset form|,
lastUpdated => 1121703035,
},
'show page' => {
message => q|Initial Page|,
context => q|label for Zip Archive asset form|,
lastUpdated => 1106762088
},
'asset label' => {
message => q|Zip Archive|,
context => q|label for Asset Manager, getName|,
lastUpdated => 1121703035,
},
'show page description' => {
message => q|Enter the name of the file which serves as the "base" file for this archive. This is the page which will initially be served up|,
lastUpdated => 1119068745
},
'za_error' => {
message => q|This asset only accepts valid tar and zip files|,
lastUpdated => 1119068745
},
'za_show_error' => {
message => q|You must provide an initial page to direct users|,
lastUpdated => 1119068745
},
'zip archive add/edit title' => {
message => q|Zip Archive, Add/Edit|,
lastUpdated => 1119068745
},
'zip archive add/edit body' => {
message => q|<p>Zip Archive Assets are assets on your site that are allow you to upload a zip archive (as either zip or tar) containing files that require collateral (static html pages with images or movies, etc) that you wish to display to your users outside of the WebGUI context, but retain WebGUI's file security. The asset uzips the folder in a WebGUI storage location, and redirects the user to the initial page when the link provided is clicked</p>|,
lastUpdated => 1119068839,
},
'zip archive template title' => {
message => q|Zip Archive, Template|,
lastUpdated => 1109287565,
},
'zip archive template body' => {
message => q|<p>The following variables are available in Zip Archive Templates:</p>
<P><b>controls</b><br/>
Asset controls for administrators.
<P><b>error</b><br/>
Any errors reported during upload or unzip
<P><b>fileUrl</b><br/>
URL to the initial file
<P><b>fileIcon</b><br/>
Initial file file type icon
|,
context => 'Describing the zip archive template variables',
lastUpdated => 1109287834,
},
};
1;