Commit 62db978c authored by Audrey Tang's avatar Audrey Tang
Browse files

r3835: autrijus | 2004-02-15T17:34:34.852189Z

bring autrijus branch up to date
r3836:  autrijus | 2004-02-15T17:49:10.192619Z
the new schema.
r3837:  root | 2004-02-15T18:53:08.183749Z
correct javascript in hideshow()
r3838:  root | 2004-02-15T18:54:01.658701Z
make transaction backward compat
r3839:  autrijus | 2004-02-15T20:30:05.474784Z
new factory and changed objects
r3840:  autrijus | 2004-02-15T20:30:21.308543Z
the v4 schema.

git-svn-id: svn+ssh://svn.bestpractical.com/svn/bps-public/rt/branches/autrijus-3.1@421 e417ac7c-1bcc-0310-8ffa-8f5827389a85
parent c51cf7ab
......@@ -335,6 +335,23 @@ Set($MyTicketsLength, 10);
@MasonParameters = () unless (@MasonParameters);
# $DefaultSearchResultFormat is the default format for RT search results
Set ($DefaultSearchResultFormat, qq{
'<B><A HREF="$RT::WebPath/Ticket/Display.html?id=__id__">__id__</a></B>/TITLE:#',
'<B><A HREF="$RT::WebPath/Ticket/Display.html?id=__id__">__Subject__</a></B>/TITLE:Subject',
Status,
QueueName,
OwnerName,
Priority,
'__NEWLINE__',
'',
'<small>__Requestors__</small>',
'<small>__CreatedRelative__</small>',
'<small>__ToldRelative__</small>',
'<small>__LastUpdatedRelative__</small>',
'<small>__TimeLeft__</small>'});
# }}}
# {{{ RT UTF-8 Settings
......
......@@ -119,21 +119,23 @@ CREATE TABLE ScripConditions (
# {{{ Transactions
CREATE TABLE Transactions (
id INTEGER NOT NULL AUTO_INCREMENT,
EffectiveTicket integer NOT NULL DEFAULT 0 ,
Ticket integer NOT NULL DEFAULT 0 ,
ObjectType varchar(64),
ObjectId integer NOT NULL DEFAULT 0 ,
TimeTaken integer NOT NULL DEFAULT 0 ,
Type varchar(20) NULL ,
Field varchar(40) NULL ,
OldValue varchar(255) NULL ,
NewValue varchar(255) NULL ,
ReferenceType varchar(255) NULL,
OldReference integer NULL ,
NewReference integer NULL ,
Data varchar(255) NULL ,
Creator integer NOT NULL DEFAULT 0 ,
Created DATETIME NULL ,
PRIMARY KEY (id)
) TYPE=InnoDB;
CREATE INDEX Transactions1 ON Transactions (Ticket);
CREATE INDEX Transactions2 ON Transactions (EffectiveTicket);
CREATE INDEX Transactions1 ON Transactions (ObjectId);
# }}}
......@@ -344,13 +346,19 @@ CREATE TABLE Templates (
# }}}
# {{{ TicketCustomFieldValues
# {{{ ObjectCustomFieldValues
CREATE TABLE TicketCustomFieldValues (
CREATE TABLE ObjectCustomFieldValues (
id INTEGER NOT NULL AUTO_INCREMENT,
Ticket int NOT NULL ,
CustomField int NOT NULL ,
ObjectType varchar(255) NULL, # Final target of the Object
ObjectId int NOT NULL , # New -- Replaces Ticket
Current BOOL DEFAULT 1, # New -- whether the value was current
Content varchar(255) NULL ,
LargeContent LONGTEXT NULL, # New -- to hold 255+ strings
ContentType varchar(80) NULL, # New -- only text/* gets searched
ContentEncoding varchar(80) NULL , # New -- for binary Content
Creator integer NOT NULL DEFAULT 0 ,
Created DATETIME NULL ,
......@@ -359,8 +367,8 @@ CREATE TABLE TicketCustomFieldValues (
PRIMARY KEY (id)
) TYPE=InnoDB;
CREATE INDEX TicketCustomFieldValues1 ON TicketCustomFieldValues (CustomField,Ticket,Content);
CREATE INDEX TicketCustomFieldValues2 ON TicketCustomFieldValues (CustomField,Ticket);
CREATE INDEX ObjectCustomFieldValues1 ON ObjectCustomFieldValues (CustomField,ObjectType,ObjectId,Content);
CREATE INDEX ObjectCustomFieldValues2 ON ObjectCustomFieldValues (CustomField,ObjectType,ObjectId);
# }}}
......@@ -369,8 +377,9 @@ CREATE INDEX TicketCustomFieldValues2 ON TicketCustomFieldValues (CustomField,Ti
CREATE TABLE CustomFields (
id INTEGER NOT NULL AUTO_INCREMENT,
Name varchar(200) NULL ,
Type varchar(200) NULL ,
Queue integer NOT NULL DEFAULT 0 ,
Type varchar(200) NULL , # Changed -- 'Single' and 'Multiple' is moved out
MaxValues integer, # New -- was 'Single'(1) and 'Multiple'(0)
Pattern varchar(255) NULL , # New -- Must validate against this
Description varchar(255) NULL ,
SortOrder integer NOT NULL DEFAULT 0 ,
......@@ -382,8 +391,24 @@ CREATE TABLE CustomFields (
PRIMARY KEY (id)
) TYPE=InnoDB;
CREATE INDEX CustomFields1 on CustomFields (Disabled, Queue);
# }}}
# {{{ ObjectCustomFields
CREATE TABLE ObjectCustomFields (
id INTEGER NOT NULL AUTO_INCREMENT,
CustomField int NOT NULL ,
ObjectType varchar(255) NULL,
IntermediateType varchar(255) NULL,
ParentType varchar(255) NULL,
ParentId integer NOT NULL,
Creator integer NOT NULL DEFAULT 0 ,
Created DATETIME NULL ,
LastUpdatedBy integer NOT NULL DEFAULT 0 ,
LastUpdated DATETIME NULL ,
PRIMARY KEY (id)
) TYPE=InnoDB;
# }}}
......
......@@ -36,8 +36,9 @@ function hideshow(num) {
idstring = "element-" + num;
chunk = document.getElementById(idstring);
if ( chunk.style.display == "none") {
chunk.style.display = "show";
chunk.style.display = chunk.style.tag;
} else {
chunk.style.tag = chunk.style.display;
chunk.style.display = "none";
}
}
......
......@@ -33,6 +33,11 @@
<%PERL>
my $i;
while (my $queue = $Queues->Next) {
my $new_q = "Queue = '".$queue->Name."' AND Status = 'new'";
my $open_q = "Queue = '".$queue->Name."' AND Status = 'open'";
my $all_q = "Queue = '".$queue->Name."' AND (Status = 'open' OR Status = 'new')";
$Tickets->ClearRestrictions;
$Tickets->LimitStatus(VALUE => "open");
$Tickets->LimitQueue(VALUE => $queue->Name, OPERATOR => '=');
......@@ -43,12 +48,15 @@ while (my $queue = $Queues->Next) {
$Tickets->LimitQueue(VALUE => $queue->Name, OPERATOR => '=');
my $new = $Tickets->Count();
</%PERL>
% $i++;
<TR class="<% $i%2 ? 'oddline' : 'evenline'%>" >
<td><A HREF="<% $RT::WebPath%>/Search/Listing.html?ValueOfStatus=open&ValueOfStatus=new&StatusOp=%3D&QueueOp=%3D&ValueOfQueue=<%$queue->Id%>&RowsPerPage=50&NewSearch=1" TITLE="<% $queue->Description %>"><%$queue->Name%></a></TD>
<td align="right"><A HREF="<% $RT::WebPath%>/Search/Listing.html?ValueOfStatus=new&StatusOp=%3D&QueueOp=%3D&ValueOfQueue=<%$queue->Id%>&RowsPerPage=50&NewSearch=1"><%$new%></a></TD>
<td align="right"><A HREF="<% $RT::WebPath%>/Search/Listing.html?ValueOfStatus=open&StatusOp=%3D&QueueOp=%3D&ValueOfQueue=<%$queue->Id%>&RowsPerPage=50&NewSearch=1"><%$open%></a></TD>
<td><A HREF="Search/Results.html?Query=<%$all_q%>&Rows=50" TITLE="<% $queue->Description %>"><%$queue->Name%></a></TD>
<td align="right"><A HREF="Search/Results.html?Query=<%$new_q%>&Rows=50"><%$new%></a></TD>
<td align="right"><A HREF="Search/Results.html?Query=<%$open_q%>&Rows=50"><%$open%></a></TD>
</TR>
% }
</TABLE>
......
......@@ -22,7 +22,6 @@
%#
%# END LICENSE BLOCK
<TABLE BORDER=0 cellspacing=0 cellpadding=1 WIDTH=100%>
<& .Header,
Format => \@Format,
......@@ -37,8 +36,21 @@
<& .Row, Format => \@Format, i => $i, record => $record, map => $map &>
% }
</TABLE>
<&|/l, $Page, int($TotalFound/$Rows)&>Page [_1] of [_2]</&>
% if ($Page != 1) {
<A href="<%$BaseURL%>?Page=<%$Page-1%>&Rows=<%$Rows%>&Format=<%$Format%>&Query=<%$Query%>"><&|/l&>Previous Page</&></a>
% }
% if (($Page * $Rows) < $TotalFound) {
<A href="<%$BaseURL%>Page=<%$Page+1%>&Rows=<%$Rows%>&Format=<%$Format%>&Query=<%$Query%>"><&|/l&>Next Page</&></a>
% }
<%INIT>
$Rows = '25' unless ($Rows); # we need a positive value
# {{{ item map
my $map = {
QueueName => {
attribute => 'Queue',
......@@ -176,15 +188,23 @@ my $map = {
};
# }}}
unless ($Collection) {
$Collection = RT::Tickets->new($session{'CurrentUser'});
$Collection->FromSQL($Query);
}
my (@Format) = $m->comp('.ParseColumnDefinitions', Format => $Format);
my (@Format) = $m->comp('.ParseColumnDefinitions', Format => $Format);
$Collection->OrderBy(FIELD => $OrderBy, ORDER => $Order);
$Collection->RowsPerPage($Rows);
$Collection->GotoPage($Page-1); # SB uses page 0 as the first page
my $TotalFound = $Collection->CountAll();
</%INIT>
......@@ -198,12 +218,12 @@ $AllowSorting => undef
$Order =>undef
$OrderBy => undef
$BaseURL => undef
$Format => undef
$Format => $RT::DefaultSearchResultFormat
</%ARGS>
%#### SUB COMPONENTS
%#
%#
%#
%# {{{ Header
<%DEF .Header>
<%ARGS>
@Format => undef
......@@ -247,7 +267,8 @@ foreach my $col (@Format) {
</%perl>
</TR>
</%DEF>
%# }}}
%# {{{ Row
<%DEF .Row>
<%ARGS>
$i => undef
......@@ -282,6 +303,9 @@ $m->out('</TR>');
</%DEF>
%# }}}
%# {{{ ParseColumnDefinitions
<%DEF .ParseColumnDefinitions >
<%ARGS>
$Format => "id, Subject"
......@@ -342,3 +366,4 @@ while ($Format =~ /($justquoted|$word)/igx) {
return(@Columns);
</%init>
</%DEF>
%# }}}
This diff is collapsed.
......@@ -42,10 +42,8 @@
my $i;
$session{'tickets'}->RedoSearch();
while (my $Ticket = $session{'tickets'}->Next) {
$Tickets->RedoSearch();
while (my $Ticket = $Tickets->Next) {
$i++;
if ($i % 2) {
$bgcolor = "#dddddd";
......@@ -157,7 +155,11 @@ map ($ARGS{$_} =~ /^$/ && (delete $ARGS{$_}), keys %ARGS);
my ($bgcolor, @results);
my @cols = qw(id Status Priority Subject QueueObj->Name OwnerObj->Name RequestorAddresses DueAsString );
Abort(loc("No search to operate on.")) unless ($session{'tickets'});
my $Tickets = RT::Tickets->new($session{'CurrentUser'});
$Tickets->FromSQL($ARGS{'Query'});
Abort(loc("No search to operate on.")) unless ($Tickets);
my $do_comment_reply=0;
......@@ -175,8 +177,8 @@ if ($ARGS{'UpdateContent'} &&
#Iterate through each ticket we've been handed
my @linkresults;
$session{'tickets'}->RedoSearch();
while (my $Ticket = $session{'tickets'}->Next) {
$Tickets->RedoSearch();
while (my $Ticket = $Tickets->Next) {
$RT::Logger->debug( "Checking Ticket ".$Ticket->Id ."\n");
next unless ($ARGS{"UpdateTicket".$Ticket->Id});
$RT::Logger->debug ("Matched\n");
......
......@@ -23,8 +23,11 @@
%# END LICENSE BLOCK
<& /Elements/Header, Title => $title&>
<& /Ticket/Elements/Tabs,
current_tab => 'Search/Edit.html',
Title => $title &>
current_tab => "Search/Edit.html".$QueryString,
Title => $title,
Format => $Format,
Query => $Query,
Rows => $ARGS{'Rows'} &>
<& Elements/NewListActions, actions => \@actions &>
......@@ -38,6 +41,12 @@
<%INIT>
my $title = "Edit Query";
$Format =~ s/#/%23/g;
$Format =~ s/&/%26/g;
my $QueryString = "?Query=$Query&Format=$Format&Rows=$ARGS{'Rows'}";
</%INIT>
......
......@@ -4,20 +4,7 @@ $Format => undef
<%init>
unless ($Format) {
$Format = qq{
'<B><A HREF="$RT::WebPath/Ticket/Display.html?id=__id__">__id__</a></B>/TITLE:#',
'<B><A HREF="$RT::WebPath/Ticket/Display.html?id=__id__">__Subject__</a></B>/TITLE:Subject',
Status,
QueueName,
OwnerName,
Priority,
'__NEWLINE__',
'',
'<small>__Requestors__</small>',
'<small>__CreatedRelative__</small>',
'<small>__ToldRelative__</small>',
'<small>__LastUpdatedRelative__</small>',
'<small>__TimeLeft__</small>'};
$Format = $RT::DefaultSearchResultFormat;
}
# escape the '#' symbols so they won't be parsed as part of a URL
......
......@@ -12,7 +12,7 @@ Format:
</td>
<tr>
<td valign=top>
<select size=6 name="SelectDisplayColumns">
<select size="6" name="SelectDisplayColumns">
% my $i = 0;
% while ($i < scalar @$AvailableColumns) {
% my $field = $AvailableColumns->[$i];
......@@ -65,9 +65,9 @@ SELECTED
</select>
<br>
<center>
<input type=submit name="ColUp" value="^">
<input type=submit name="ColDown" value="v">
<input type=submit name="RemoveCol" value="<%loc('Delete')%>">
<input type="submit" name="ColUp" value="^">
<input type="submit" name="ColDown" value="v">
<input type="submit" name="RemoveCol" value="<%loc('Delete')%>">
</center>
</td>
<td colspan=3 align=center>
......
<& /Elements/TitleBoxStart, title => loc('Saved searches') &>
<input type="hidden" name="SearchId" value="<%$SearchId%>">
<&|/l&>Privacy:</&>
% if ($CurrentSearch->{'Object'}) {
% if ($CurrentSearch->{'Object'} && $CurrentSearch->{'Object'}->id) {
<& SearchPrivacy, Object => $CurrentSearch->{'Object'}->Object &><br>
% } else {
<& SelectSearchObject, Name => 'Owner', Objects => \@Objects &><br>
% }
<&|/l&>Description</&>:<br>
<font size="-1"><input size="25" name="Description" value="<%$CurrentSearch->{'Description'}%>"></font>
<font size="-1"><input size="25" name="Description" value="<%$CurrentSearch->{'Description'}%>" onChange="BuildQuery.Save.click()"></font>
<br>
% if ($SearchId ne 'new') {
<input type="submit" name="Revert" value="<%loc('Revert')%>">
......@@ -21,7 +21,6 @@
<&|/l&>Load saved search:</&><br>
<& SelectSearchesForObjects, Name => 'LoadSavedSearch', Objects => \@Objects&>
<input value="<%loc('Load')%>" type="submit">
</form>
<& /Elements/TitleBoxEnd &>
<%init>
......
......@@ -23,31 +23,28 @@
%# END LICENSE BLOCK
<& /Elements/Header, Title => $title, Refresh => $session{'tickets_refresh_interval'} &>
<& /Ticket/Elements/Tabs,
current_tab => 'Search/Results.html',
Title => $title, %ARGS &>
current_tab => "Search/Results.html".$QueryString,
Title => $title,
Format => $Format,
Query => $Query,
Rows => $ARGS{'Rows'} &>
<hr>
about to be
%unless ( $HideResults) {
Looking at results
<& /Elements/TicketList,
Query => $ARGS{'Query'},
Query => $Query,
AllowSorting => 1,
OrderBy => $ARGS{'OrderBy'},
Order => $ARGS{'Order'},
Rows => $ARGS{'Rows'},
FirstRow => $ARGS{'FirstRow'},
OrderBy => $OrderBy,
Order => $Order,
Rows => $Rows,
Page => $Page,
Format => $Format,
BaseURL => $RT::WebPath."/Search/Listing.html?"
BaseURL => $RT::WebPath."/Search/Results.html?"
&>
<div align=right>
<a href="Bulk.html"><&|/l&>Update all these tickets at once</&></a>
<a href="Results.tsv"><&|/l&>spreadsheet</&></a>
<a href="Results.tsv"><&|/l&>RSS</&></a>
<a href="Bulk.html<%$QueryString%>"><&|/l&>Update all these tickets at once</&></a><br>
<a href="Results.tsv<%$QueryString%>"><&|/l&>spreadsheet</&></a><br>
<a href="Results.tsv<%$QueryString%>"><&|/l&>RSS</&></a><br>
</div>
% }
<%INIT>
my ($title, $ticketcount);
$session{'i'}++;
......@@ -62,7 +59,11 @@ if ( $session{'tickets'}->Query()) {
$title = loc("Find tickets");
}
$ARGS{Format} = $Format;
my $tabformat = $Format;
$tabformat =~ s/#/%23/g;
$tabformat =~ s/&/%26/g;
my $QueryString =
"?Query=$Query&Format=$tabformat&Rows=$ARGS{'Rows'}&Page=<%$ARGS{'Page'}%>";
</%INIT>
<%CLEANUP>
......@@ -73,4 +74,7 @@ $Query => undef
$Format => undef
$HideResults => 0
$Rows => 50
$Page => 1
$OrderBy => 'id'
$Order => 'ASC'
</%ARGS>
<%INIT>
my $Tickets = $session{'tickets'};
my $Tickets = RT::Tickets->new($session{'CurrentUser'});
$Tickets->FromSQL($ARGS{'Query'});
my $per_page = $Tickets->RowsPerPage();
my $first_row = ($Tickets->FirstRow()+1);
$Tickets->RowsPerPage(0);
$Tickets->FirstRow(1);
my @rows;
my %known_cfs;
......@@ -69,6 +65,4 @@ foreach my $row (@rows) {
$m->abort();
$Tickets->RowsPerPage($per_page);
$Tickets->FirstRow($first_row);
</%INIT>
......@@ -162,7 +162,7 @@ my $format = $ARGS{'Format'};
$format =~ s/#/%23/g;
$format =~ s/&/%26/g;
my $args = "?Query=$ARGS{'Query'}&Format=\"$format\"&Rows=$ARGS{'Rows'}";
my $args = "?Query=$ARGS{'Query'}&Format=$format&Rows=$ARGS{'Rows'}";
$tabs->{"f"} = { path => "Search/Build.html",
title => loc('New Query'),
......
......@@ -56,7 +56,7 @@ our $PERSONAL_ACL_MAP = {
};
=head2 LookupObjectRight { create, update, delete, display }
=head2 LookupObjectRight { ObjectType => undef, ObjectId => undef, Name => undef, Right => { create, update, delete, display } }
Returns the right that the user needs to have on this attribute's object to perform the related attribute operation. Returns "allow" if the right is otherwise unspecified.
......@@ -64,20 +64,24 @@ Returns the right that the user needs to have on this attribute's object to perf
sub LookupObjectRight {
my $self = shift;
my $right = shift;
my %args = ( ObjectType => undef,
ObjectId => undef,
Right => undef,
Name => undef,
@_);
# if it's an attribute on oneself, check the personal acl map
if (($self->__Value('ObjectType') eq 'RT::User') && ($self->__Value('ObjectId') eq $self->CurrentUser->Id)) {
return('allow') unless ($PERSONAL_ACL_MAP->{$self->__Value('Name')});
return('allow') unless ($PERSONAL_ACL_MAP->{$self->__Value('Name')}->{$right});
return($PERSONAL_ACL_MAP->{$self->__Value('Name')}->{$right});
if (($args{'ObjectType'} eq 'RT::User') && ($args{'ObjectId'} eq $self->CurrentUser->Id)) {
return('allow') unless ($PERSONAL_ACL_MAP->{$args{'Name'}});
return('allow') unless ($PERSONAL_ACL_MAP->{$args{'Name'}}->{$args{'Right'}});
return($PERSONAL_ACL_MAP->{$args{'Name'}}->{$args{'Right'}});
}
# otherwise check the main ACL map
else {
return('allow') unless ($ACL_MAP->{$self->__Value('Name')});
return('allow') unless ($ACL_MAP->{$self->__Value('Name')}->{$right});
return($ACL_MAP->{$self->__Value('Name')}->{$right});
return('allow') unless ($ACL_MAP->{$args{'Name'}});
return('allow') unless ($ACL_MAP->{$args{'Name'}}->{$args{'Right'}});
return($ACL_MAP->{$args{'Name'}}->{$args{'Right'}});
}
}
......@@ -108,8 +112,7 @@ sub Create {
Description => '',
Content => '',
ContentType => '',
ObjectType => '',
ObjectId => '0',
Object => undef,
@_);
if ($args{Object} and UNIVERSAL::can($args{Object}, 'Id')) {
......@@ -120,8 +123,22 @@ sub Create {
}
# object_right is the right that the user has to have on the object for them to have $right on this attribute
my $object_right = $self->LookupObjectRight(
Right => 'create',
ObjectId => $args{'ObjectId'},
ObjectType => $args{'ObjectType'},
Name => $args{'Name'}
);
if ($object_right eq 'deny') {
return (0, $self->loc('Permission Denied'));
}
elsif ($object_right eq 'allow') {
# do nothing, we're ok
}
elsif (!$self->CurrentUser->HasRight( Object => $args{Object}, Right => $object_right)) {
return (0, $self->loc('Permission Denied'));
}
if (ref ($args{'Content'}) ) {
......@@ -396,17 +413,17 @@ sub CurrentUserHasRight {
my $right = shift;
# object_right is the right that the user has to have on the object for them to have $right on this attribute
my $object_right = $self->LookupObjectRight($right);
my $object_right = $self->LookupObjectRight(
Right => $right,
ObjectId => $self->__Value('ObjectId'),
ObjectType => $self->__Value('ObjectType'),
Name => $self->__Value('Name')
);
return (1) if ($object_right eq 'allow');
return (0) if ($object_right eq 'deny');
return(1) if ($self->CurrentUser->HasRight( Object => $self->Object,
Right => $object_right));
return(undef);
return(1) if ($self->CurrentUser->HasRight( Object => $self->Object, Right => $object_right));
return(0);
}
......
......@@ -46,7 +46,6 @@ RT::CustomField
package RT::CustomField;
use RT::Record;
use RT::Queue;
use vars qw( @ISA );
......@@ -69,7 +68,8 @@ Create takes a hash of values and creates a row in the database:
varchar(200) 'Name'.
varchar(200) 'Type'.
int(11) 'Queue'.
int(11) 'MaxValues'.
varchar(255) 'Pattern'.
varchar(255) 'Description'.
int(11) 'SortOrder'.
smallint(6) 'Disabled'.
......@@ -84,7 +84,8 @@ sub Create {
my %args = (
Name => '',
Type => '',
Queue => '0',
MaxValues => '',
Pattern => '',
Description => '',
SortOrder => '0',
Disabled => '0',
......@@ -93,7 +94,8 @@ sub Create {
$self->SUPER::Create(
Name => $args{'Name'},
Type => $args{'Type'},
Queue => $args{'Queue'},
MaxValues => $args{'MaxValues'},
Pattern => $args{'Pattern'},
Description => $args{'Description'},
SortOrder => $args{'SortOrder'},
Disabled => $args{'Disabled'},
......@@ -148,37 +150,41 @@ Returns (1, 'Status message') on success and (0, 'Error Message') on failure.
=cut
=head2 Queue
=head2 MaxValues
Returns the current value of Queue.
(In the database, Queue is stored as int(11).)