Added feature to expire pages.
This commit is contained in:
parent
923badbe1c
commit
5db70ffc07
4 changed files with 138 additions and 50 deletions
|
|
@ -656,8 +656,10 @@ delete from international where namespace='WebGUI' and internationalId=128;
|
|||
delete from settings where name='attachmentDirectoryLocal';
|
||||
delete from settings where name='attachmentDirectoryWeb';
|
||||
delete from settings where name='lib';
|
||||
|
||||
|
||||
update international set message='Attachment' where internationalId=33 and languageId=1 and namespace='UserSubmission';
|
||||
alter table page add column startDate int not null default 946710000;
|
||||
alter table page add column endDate int not null default 2082783600;
|
||||
update page set styleId=-6 where styleId=-3;
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ use WebGUI::URL;
|
|||
|
||||
our @ISA = qw(Exporter);
|
||||
our @EXPORT = qw(&helpIcon &becomeIcon &cutIcon ©Icon &deleteIcon &editIcon &moveUpIcon &moveDownIcon
|
||||
&pageIcon &moveTopIcon &moveBottomIcon &viewIcon);
|
||||
&wobjectIcon &pageIcon &moveTopIcon &moveBottomIcon &viewIcon);
|
||||
|
||||
=head1 NAME
|
||||
|
||||
|
|
@ -42,6 +42,7 @@ our @EXPORT = qw(&helpIcon &becomeIcon &cutIcon ©Icon &deleteIcon &editIcon
|
|||
$html = moveUpIcon('op=something');
|
||||
$html = pageIcon();
|
||||
$html = viewIcon('op=something');
|
||||
$html = wobjectIcon();
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
|
|
@ -58,7 +59,7 @@ our @EXPORT = qw(&helpIcon &becomeIcon &cutIcon ©Icon &deleteIcon &editIcon
|
|||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 becomeIcon ( urlParameters )
|
||||
=head2 becomeIcon ( urlParameters [, pageURL ] )
|
||||
|
||||
Generates a button with the word "Become" printed on it.
|
||||
|
||||
|
|
@ -67,18 +68,23 @@ our @EXPORT = qw(&helpIcon &becomeIcon &cutIcon ©Icon &deleteIcon &editIcon
|
|||
Any URL parameters that need to be tacked on to the current URL
|
||||
to accomplish whatever function this button represents.
|
||||
|
||||
=item pageURL
|
||||
|
||||
The URL to any page. Defaults to the current page.
|
||||
|
||||
=cut
|
||||
|
||||
sub becomeIcon {
|
||||
my ($output);
|
||||
$output = '<a href="'.WebGUI::URL::page($_[0]).'">';
|
||||
my ($output, $pageURL);
|
||||
$pageURL = $_[1] || $session{page}{urlizedTitle};
|
||||
$output = '<a href="'.WebGUI::URL::gateway($pageURL,$_[0]).'">';
|
||||
$output .= '<img src="'.$session{config}{extras}.'/become.gif" align="middle" border="0" alt="Become"></a>';
|
||||
return $output;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 copyIcon ( urlParameters )
|
||||
=head2 copyIcon ( urlParameters [, pageURL ] )
|
||||
|
||||
Generates a button with the word "Copy" printed on it.
|
||||
|
||||
|
|
@ -87,18 +93,23 @@ sub becomeIcon {
|
|||
Any URL parameters that need to be tacked on to the current URL
|
||||
to accomplish whatever function this button represents.
|
||||
|
||||
=item pageURL
|
||||
|
||||
The URL to any page. Defaults to the current page.
|
||||
|
||||
=cut
|
||||
|
||||
sub copyIcon {
|
||||
my ($output);
|
||||
$output = '<a href="'.WebGUI::URL::page($_[0]).'">';
|
||||
my ($output, $pageURL);
|
||||
$pageURL = $_[1] || $session{page}{urlizedTitle};
|
||||
$output = '<a href="'.WebGUI::URL::gateway($pageURL,$_[0]).'">';
|
||||
$output .= '<img src="'.$session{config}{extras}.'/copy.gif" align="middle" border="0" alt="Copy"></a>';
|
||||
return $output;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 cutIcon ( urlParameters )
|
||||
=head2 cutIcon ( urlParameters [, pageURL ] )
|
||||
|
||||
Generates a button with the word "Cut" printed on it.
|
||||
|
||||
|
|
@ -107,18 +118,23 @@ sub copyIcon {
|
|||
Any URL parameters that need to be tacked on to the current URL
|
||||
to accomplish whatever function this button represents.
|
||||
|
||||
=item pageURL
|
||||
|
||||
The URL to any page. Defaults to the current page.
|
||||
|
||||
=cut
|
||||
|
||||
sub cutIcon {
|
||||
my ($output);
|
||||
$output = '<a href="'.WebGUI::URL::page($_[0]).'">';
|
||||
my ($output, $pageURL);
|
||||
$pageURL = $_[1] || $session{page}{urlizedTitle};
|
||||
$output = '<a href="'.WebGUI::URL::gateway($pageURL,$_[0]).'">';
|
||||
$output .= '<img src="'.$session{config}{extras}.'/cut.gif" align="middle" border="0" alt="Cut"></a>';
|
||||
return $output;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 deleteIcon ( urlParameters )
|
||||
=head2 deleteIcon ( urlParameters [, pageURL ] )
|
||||
|
||||
Generates a button with an "X" printed on it.
|
||||
|
||||
|
|
@ -127,18 +143,23 @@ sub cutIcon {
|
|||
Any URL parameters that need to be tacked on to the current URL
|
||||
to accomplish whatever function this button represents.
|
||||
|
||||
=item pageURL
|
||||
|
||||
The URL to any page. Defaults to the current page.
|
||||
|
||||
=cut
|
||||
|
||||
sub deleteIcon {
|
||||
my ($output);
|
||||
$output = '<a href="'.WebGUI::URL::page($_[0]).'">';
|
||||
my ($output, $pageURL);
|
||||
$pageURL = $_[1] || $session{page}{urlizedTitle};
|
||||
$output = '<a href="'.WebGUI::URL::gateway($pageURL,$_[0]).'">';
|
||||
$output .= '<img src="'.$session{config}{extras}.'/delete.gif" align="middle" border="0" alt="Delete"></a>';
|
||||
return $output;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 editIcon ( urlParameters )
|
||||
=head2 editIcon ( urlParameters [, pageURL ] )
|
||||
|
||||
Generates a button with the word "Edit" printed on it.
|
||||
|
||||
|
|
@ -147,18 +168,23 @@ sub deleteIcon {
|
|||
Any URL parameters that need to be tacked on to the current URL
|
||||
to accomplish whatever function this button represents.
|
||||
|
||||
=item pageURL
|
||||
|
||||
The URL to any page. Defaults to the current page.
|
||||
|
||||
=cut
|
||||
|
||||
sub editIcon {
|
||||
my ($output);
|
||||
$output = '<a href="'.WebGUI::URL::page($_[0]).'">';
|
||||
my ($output, $pageURL);
|
||||
$pageURL = $_[1] || $session{page}{urlizedTitle};
|
||||
$output = '<a href="'.WebGUI::URL::gateway($pageURL,$_[0]).'">';
|
||||
$output .= '<img src="'.$session{config}{extras}.'/edit.gif" align="middle" border="0" alt="Edit"></a>';
|
||||
return $output;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 becomeIcon ( helpId [, namespace ] )
|
||||
=head2 helpIcon ( helpId [, namespace ] )
|
||||
|
||||
Generates a button with the word "Help" printed on it.
|
||||
|
||||
|
|
@ -184,7 +210,7 @@ sub helpIcon {
|
|||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 moveBottomIcon ( urlParameters )
|
||||
=head2 moveBottomIcon ( urlParameters [, pageURL ] )
|
||||
|
||||
Generates a button with a double down arrow printed on it.
|
||||
|
||||
|
|
@ -193,18 +219,23 @@ sub helpIcon {
|
|||
Any URL parameters that need to be tacked on to the current URL
|
||||
to accomplish whatever function this button represents.
|
||||
|
||||
=item pageURL
|
||||
|
||||
The URL to any page. Defaults to the current page.
|
||||
|
||||
=cut
|
||||
|
||||
sub moveBottomIcon {
|
||||
my ($output);
|
||||
$output = '<a href="'.WebGUI::URL::page($_[0]).'">';
|
||||
my ($output, $pageURL);
|
||||
$pageURL = $_[1] || $session{page}{urlizedTitle};
|
||||
$output = '<a href="'.WebGUI::URL::gateway($pageURL,$_[0]).'">';
|
||||
$output .= '<img src="'.$session{config}{extras}.'/jumpDown.gif" align="middle" border="0" alt="Move To Bottom"></a>';
|
||||
return $output;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 moveDownIcon ( urlParameters )
|
||||
=head2 moveDownIcon ( urlParameters [, pageURL ] )
|
||||
|
||||
Generates a button with a down arrow printed on it.
|
||||
|
||||
|
|
@ -213,18 +244,23 @@ sub moveBottomIcon {
|
|||
Any URL parameters that need to be tacked on to the current URL
|
||||
to accomplish whatever function this button represents.
|
||||
|
||||
=item pageURL
|
||||
|
||||
The URL to any page. Defaults to the current page.
|
||||
|
||||
=cut
|
||||
|
||||
sub moveDownIcon {
|
||||
my ($output);
|
||||
$output = '<a href="'.WebGUI::URL::page($_[0]).'">';
|
||||
my ($output, $pageURL);
|
||||
$pageURL = $_[1] || $session{page}{urlizedTitle};
|
||||
$output = '<a href="'.WebGUI::URL::gateway($pageURL,$_[0]).'">';
|
||||
$output .= '<img src="'.$session{config}{extras}.'/downArrow.gif" align="middle" border="0" alt="Move Down"></a>';
|
||||
return $output;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 moveTopIcon ( urlParameters )
|
||||
=head2 moveTopIcon ( urlParameters [, pageURL ] )
|
||||
|
||||
Generates a button with a double up arrow printed on it.
|
||||
|
||||
|
|
@ -233,18 +269,23 @@ sub moveDownIcon {
|
|||
Any URL parameters that need to be tacked on to the current URL
|
||||
to accomplish whatever function this button represents.
|
||||
|
||||
=item pageURL
|
||||
|
||||
The URL to any page. Defaults to the current page.
|
||||
|
||||
=cut
|
||||
|
||||
sub moveTopIcon {
|
||||
my ($output);
|
||||
$output = '<a href="'.WebGUI::URL::page($_[0]).'">';
|
||||
my ($output, $pageURL);
|
||||
$pageURL = $_[1] || $session{page}{urlizedTitle};
|
||||
$output = '<a href="'.WebGUI::URL::gateway($pageURL,$_[0]).'">';
|
||||
$output .= '<img src="'.$session{config}{extras}.'/jumpUp.gif" align="middle" border="0" alt="Move To Top"></a>';
|
||||
return $output;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 moveUpIcon ( urlParameters )
|
||||
=head2 moveUpIcon ( urlParameters [, pageURL ] )
|
||||
|
||||
Generates a button with an up arrow printed on it.
|
||||
|
||||
|
|
@ -253,11 +294,16 @@ sub moveTopIcon {
|
|||
Any URL parameters that need to be tacked on to the current URL
|
||||
to accomplish whatever function this button represents.
|
||||
|
||||
=item pageURL
|
||||
|
||||
The URL to any page. Defaults to the current page.
|
||||
|
||||
=cut
|
||||
|
||||
sub moveUpIcon {
|
||||
my ($output);
|
||||
$output = '<a href="'.WebGUI::URL::page($_[0]).'">';
|
||||
my ($output, $pageURL);
|
||||
$pageURL = $_[1] || $session{page}{urlizedTitle};
|
||||
$output = '<a href="'.WebGUI::URL::gateway($pageURL,$_[0]).'">';
|
||||
$output .= '<img src="'.$session{config}{extras}.'/upArrow.gif" align="middle" border="0" alt="Move Up"></a>';
|
||||
return $output;
|
||||
}
|
||||
|
|
@ -278,7 +324,7 @@ sub pageIcon {
|
|||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 viewIcon ( urlParameters )
|
||||
=head2 viewIcon ( urlParameters [, pageURL ] )
|
||||
|
||||
Generates a button with the word "View" printed on it.
|
||||
|
||||
|
|
@ -287,15 +333,34 @@ sub pageIcon {
|
|||
Any URL parameters that need to be tacked on to the current URL
|
||||
to accomplish whatever function this button represents.
|
||||
|
||||
=item pageURL
|
||||
|
||||
The URL to any page. Defaults to the current page.
|
||||
|
||||
=cut
|
||||
|
||||
sub viewIcon {
|
||||
my ($output);
|
||||
$output = '<a href="'.WebGUI::URL::page($_[0]).'">';
|
||||
my ($output, $pageURL);
|
||||
$pageURL = $_[1] || $session{page}{urlizedTitle};
|
||||
$output = '<a href="'.WebGUI::URL::gateway($pageURL,$_[0]).'">';
|
||||
$output .= '<img src="'.$session{config}{extras}.'/view.gif" align="middle" border="0" alt="View"></a>';
|
||||
return $output;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 wobjectIcon ( )
|
||||
|
||||
Generates an icon that looks like a wobject. It's purpose is to
|
||||
represent whether you're looking at page properties or Wobject
|
||||
properties.
|
||||
|
||||
=cut
|
||||
|
||||
sub wobjectIcon {
|
||||
return '<img src="'.$session{config}{extras}.'/wobject.gif" align="middle" border="0" alt="Wobject Settings">';
|
||||
}
|
||||
|
||||
|
||||
|
||||
1;
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@ package WebGUI::Operation::Page;
|
|||
|
||||
use Exporter;
|
||||
use strict;
|
||||
use WebGUI::DateTime;
|
||||
use WebGUI::HTMLForm;
|
||||
use WebGUI::Icon;
|
||||
use WebGUI::International;
|
||||
|
|
@ -31,7 +32,8 @@ sub _recursivelyChangePrivileges {
|
|||
my ($sth, $pageId);
|
||||
$sth = WebGUI::SQL->read("select pageId from page where parentId=$_[0]");
|
||||
while (($pageId) = $sth->array) {
|
||||
WebGUI::SQL->write("update page set ownerId=$session{form}{ownerId}, ownerView=$session{form}{ownerView},
|
||||
WebGUI::SQL->write("update page set startDate=$session{form}{startDate}, endDate=$session{form}{endDate},
|
||||
ownerId=$session{form}{ownerId}, ownerView=$session{form}{ownerView},
|
||||
ownerEdit=$session{form}{ownerEdit}, groupId='$session{form}{groupId}', groupView=$session{form}{groupView},
|
||||
groupEdit=$session{form}{groupEdit}, worldView=$session{form}{worldView}, worldEdit=$session{form}{worldEdit}
|
||||
where pageId=$pageId");
|
||||
|
|
@ -73,13 +75,18 @@ sub _traversePageTree {
|
|||
}
|
||||
$a = WebGUI::SQL->read("select * from page where (pageId<2 or pageId>25) and parentId='$_[0]' order by sequenceNumber");
|
||||
while (%page = $a->hash) {
|
||||
$output .= $depth.'<img src="'.$session{config}{extras}.'/page.gif" align="middle">'.
|
||||
' <a href="'.WebGUI::URL::gateway($page{urlizedTitle}).'">'.$page{title}.'</a><br>';
|
||||
$output .= $depth
|
||||
.pageIcon()
|
||||
.deleteIcon('op=deletePage',$page{urlizedTitle})
|
||||
.editIcon('op=editPage',$page{urlizedTitle})
|
||||
.' <a href="'.WebGUI::URL::gateway($page{urlizedTitle}).'">'.$page{title}.'</a><br>';
|
||||
$b = WebGUI::SQL->read("select * from wobject where pageId=$page{pageId}");
|
||||
while (%wobject = $b->hash) {
|
||||
$output .= $depth.$spacer.
|
||||
'<img src="'.$session{config}{extras}.'/wobject.gif"> '.
|
||||
$wobject{title}.'<br>';
|
||||
$output .= $depth.$spacer
|
||||
.wobjectIcon()
|
||||
.deleteIcon('func=delete&wid='.$wobject{wobjectId},$page{urlizedTitle})
|
||||
.editIcon('func=edit&wid='.$wobject{wobjectId},$page{urlizedTitle})
|
||||
.' '. $wobject{title}.'<br>';
|
||||
}
|
||||
$b->finish;
|
||||
$output .= _traversePageTree($page{pageId},$_[1]+1);
|
||||
|
|
@ -137,7 +144,7 @@ sub www_deletePageConfirm {
|
|||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_editPage {
|
||||
my ($f, $output, %hash, %page);
|
||||
my ($f, $endDate, $output, %hash, %page);
|
||||
tie %hash, "Tie::IxHash";
|
||||
if (WebGUI::Privilege::canEditPage($session{form}{npp})) {
|
||||
$f = WebGUI::HTMLForm->new;
|
||||
|
|
@ -152,11 +159,13 @@ sub www_editPage {
|
|||
} else {
|
||||
%page = %{$session{page}};
|
||||
}
|
||||
$page{endDate} = (time()+315360000) if ($page{endDate} < 0);
|
||||
$output = helpIcon(1);
|
||||
$output .= '<h1>'.WebGUI::International::get(102).'</h1>';
|
||||
$f->hidden("pageId",$page{pageId});
|
||||
$f->hidden("parentId",$page{parentId});
|
||||
$f->hidden("op","editPageSave");
|
||||
$f->submit if ($page{pageId} ne "new");
|
||||
$f->raw('<tr><td colspan=2><b>'.WebGUI::International::get(103).'</b></td></tr>');
|
||||
$f->readOnly($page{pageId},WebGUI::International::get(500));
|
||||
$f->text("title",WebGUI::International::get(99),$page{title});
|
||||
|
|
@ -172,6 +181,8 @@ sub www_editPage {
|
|||
' <a href="'.WebGUI::URL::page('op=listStyles').'">'.WebGUI::International::get(6).'</a>');
|
||||
$f->yesNo("recurseStyle",'','','',' '.WebGUI::International::get(106));
|
||||
$f->raw('<tr><td colspan=2><hr size=1><b>'.WebGUI::International::get(107).'</b></td></tr>');
|
||||
$f->date("startDate",WebGUI::International::get(497),$page{startDate});
|
||||
$f->date("endDate",WebGUI::International::get(498),$page{endDate});
|
||||
%hash = WebGUI::SQL->buildHash("select users.userId,users.username from users,groupings
|
||||
where groupings.groupId=4 and groupings.userId=users.userId order by users.username");
|
||||
$f->select("ownerId",\%hash,WebGUI::International::get(108),[$page{ownerId}],'','','',
|
||||
|
|
@ -213,6 +224,8 @@ sub www_editPageSave {
|
|||
$session{form}{menuTitle} = $session{form}{title} if ($session{form}{menuTitle} eq "");
|
||||
$session{form}{urlizedTitle} = $session{form}{menuTitle} if ($session{form}{urlizedTitle} eq "");
|
||||
$session{form}{urlizedTitle} = WebGUI::URL::makeUnique(WebGUI::URL::urlize($session{form}{urlizedTitle}),$session{form}{pageId});
|
||||
$session{form}{startDate} = setToEpoch($session{form}{startDate}) || setToEpoch(time());
|
||||
$session{form}{endDate} = setToEpoch($session{form}{endDate}) || setToEpoch(time()+315360000);
|
||||
WebGUI::SQL->write("update page set
|
||||
title=".quote($session{form}{title}).",
|
||||
styleId=$session{form}{styleId},
|
||||
|
|
@ -224,6 +237,8 @@ sub www_editPageSave {
|
|||
groupEdit=$session{form}{groupEdit},
|
||||
worldView=$session{form}{worldView},
|
||||
worldEdit=$session{form}{worldEdit},
|
||||
startDate=$session{form}{startDate},
|
||||
endDate=$session{form}{endDate},
|
||||
metaTags=".quote($session{form}{metaTags}).",
|
||||
urlizedTitle='$session{form}{urlizedTitle}',
|
||||
defaultMetaTags='$session{form}{defaultMetaTags}',
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@ sub canEditPage {
|
|||
my ($isContentManager,%page);
|
||||
tie %page, 'Tie::CPHash';
|
||||
if ($_[0] ne "") {
|
||||
%page = WebGUI::SQL->quickHash("select * from page where pageId=$_[0]");
|
||||
%page = WebGUI::SQL->quickHash("select ownerId,ownerEdit,worldEdit,groupId,groupEdit from page where pageId=$_[0]");
|
||||
} else {
|
||||
%page = %{$session{page}};
|
||||
}
|
||||
|
|
@ -56,10 +56,10 @@ sub canEditPage {
|
|||
return 1;
|
||||
} elsif ($session{user}{userId} eq $page{ownerId} && $page{ownerEdit} && $isContentManager) {
|
||||
return 1;
|
||||
} elsif (isInGroup(3)) {
|
||||
return 1;
|
||||
} elsif (isInGroup($page{groupId}) && $page{groupEdit} && $isContentManager) {
|
||||
return 1;
|
||||
} elsif (isInGroup(3)) { # admin check
|
||||
return 1;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -67,21 +67,27 @@ sub canEditPage {
|
|||
|
||||
#-------------------------------------------------------------------
|
||||
sub canViewPage {
|
||||
my (%page);
|
||||
my (%page, $inDateRange);
|
||||
tie %page, 'Tie::CPHash';
|
||||
if ($_[0] eq "") {
|
||||
%page = %{$session{page}};
|
||||
} else {
|
||||
%page = WebGUI::SQL->quickHash("select * from page where pageId=$_[0]");
|
||||
%page = WebGUI::SQL->quickHash("select ownerId,ownerView,groupId,groupView,worldView,startDate,endDate
|
||||
from page where pageId=$_[0]");
|
||||
}
|
||||
if ($page{worldView}) {
|
||||
if ($page{startDate} < time() && $page{endDate} > time()) {
|
||||
$inDateRange = 1;
|
||||
}
|
||||
if ($page{worldView} && $inDateRange) {
|
||||
return 1;
|
||||
} elsif ($session{user}{userId} eq $page{ownerId} && $page{ownerView}) {
|
||||
} elsif ($session{user}{userId} eq $page{ownerId} && $page{ownerView} && $inDateRange) {
|
||||
return 1;
|
||||
} elsif (isInGroup($page{groupId}) && $page{groupView} && $inDateRange) {
|
||||
return 1;
|
||||
} elsif (isInGroup(3)) { # admin check
|
||||
return 1;
|
||||
} elsif (isInGroup($page{groupId}) && $page{groupView}) {
|
||||
return 1;
|
||||
} elsif (canEditPage($_[0])) {
|
||||
return 1;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue