[Rt-commit] [svn] r1353 - in RT-Journal/trunk/html/Journal: .
Elements
huberth at pallas.eruditorum.org
huberth at pallas.eruditorum.org
Wed Aug 18 20:50:03 EDT 2004
Author: huberth
Date: Wed Aug 18 20:50:02 2004
New Revision: 1353
Added:
RT-Journal/trunk/html/Journal/Friends.html
Modified:
RT-Journal/trunk/html/Journal/Article.html
RT-Journal/trunk/html/Journal/Edit.html
RT-Journal/trunk/html/Journal/Elements/Tabs
RT-Journal/trunk/html/Journal/Post.html
RT-Journal/trunk/html/Journal/Show.html
Log:
* A few minor changes/fixes:
- The post page has labels now.
- The edit link (from a given post) only appears if the current user
actually posted the given article. There still isn't any checking
done for rights, though.
- The edit page looks much better.
- Viewing a given post looks (much?) nicer now.
- Timestamps on comments are now correct.
* Friend lists implemented, so friends pages work now.
Modified: RT-Journal/trunk/html/Journal/Article.html
==============================================================================
--- RT-Journal/trunk/html/Journal/Article.html (original)
+++ RT-Journal/trunk/html/Journal/Article.html Wed Aug 18 20:50:02 2004
@@ -32,8 +32,8 @@
</%init>
%$m->comp( 'Elements/Tabs', Title => $post->CreatorObj->Name.": ".$post->Subject );
-<h1> <%$post->Subject%> </h1>
-( <%$post->CreatedObj->AsString%>)<br>
+<h1><%$post->Subject%></h1>
+(<%$post->CreatedObj->AsString%>)<br>
<%$post->FirstCustomFieldValue('RT-Journal::Category')%>
<br>
@@ -53,38 +53,39 @@
% }
</div>
-% #Todo, only let the right person edit
-% if ($session{'CurrentUser'} ) {
-[<a href=" <%$RT::WebPath%> /Journal/Edit.html?id= <%$post->Id%> ">Edit</a>]
-
+% # edit link only shows up if you created the post
+% # doesn't yet prevent people from manually hacking the URL
+% if ($session{'CurrentUser'}->Id == $post->Owner) {
+[<a href=" <%$RT::WebPath%> /Journal/Edit.html?id=<%$post->Id%>">Edit</a>]
% }
<hr>
% my $history = $post->Transactions();
% $history->Limit(FIELD => 'Type', VALUE => 'Correspond');
+<h3>Comments</h3>
% while (my $comment = $history->Next) {
-% my $attach = $comment->Attachments;
+% my $attach = $comment->Attachments;
-<%$comment->CreatorObj->Name%> - ( <%$post->CreatedObj->AsString%>)<br>
+<%$comment->CreatorObj->Name%> (<%$comment->CreatedObj->AsString%>)<br>
<%$comment->Content%>
-% $attach->Limit(FIELD => 'ContentType', OPERATOR => 'LIKE', VALUE => 'image/jpeg');
-% while (my $file = $attach->Next) {
+% $attach->Limit(FIELD => 'ContentType', OPERATOR => 'LIKE', VALUE => 'image/jpeg');
+% while (my $file = $attach->Next) {
Found : <%$attach->id%> / <%$attach->Filename%>
-% }
-<hr>
+% }
+<br><br>
-%}
+% }
<hr>
<form action="Article.html" method="post">
<input type=hidden name="id" value="<%$post->id%>">
<textarea name="comment" rows=10 cols=70></textarea>
-<input type="submit">
+<br>
+<input type="submit" value="Add Comment">
+<input type="reset" value="Clear">
</form>
---
-
Modified: RT-Journal/trunk/html/Journal/Edit.html
==============================================================================
--- RT-Journal/trunk/html/Journal/Edit.html (original)
+++ RT-Journal/trunk/html/Journal/Edit.html Wed Aug 18 20:50:02 2004
@@ -1,13 +1,22 @@
-<& Elements/Tabs &>
+% $m->comp( 'Elements/Tabs', Title => "Edit Post: " . $ticket->Subject);
+
<%$msg && '<h2>'.$msg.'</h2>'|n%>
<%$content_msg && '<h2>'.$content_msg.'</h2>'|n%>
<form action="Edit.html" method="post">
<input type="hidden" name="id" value="<%$ticket->Id%>">
-Category: <input name="Category" value="<%$ticket->FirstCustomFieldValue('Category')%>"><br>
+<b>Subject:</b>
+<input name="Title" value="<%$ticket->Subject%>">
+<br><br>
+
+<b>Category:</b>
+<input name="Category" value="<%$ticket->FirstCustomFieldValue('Category')%>">
+<br><br>
+<b>Post:</b><br>
<textarea rows=20 cols=80 name="Content"><%$attachment->Content%></textarea>
-<input type=submit>
+<br>
+<input type=submit value="Edit Post">
</form>
<%INIT>
@@ -23,7 +32,7 @@
if ($ARGS{'Content'} ) {
# this is an egregious hack and should never exist.
# We need an "Alter ticket content right"
- # it should be "permission denied, not 'immutable'
+ # it should be "permission denied, not 'immutable'"
($content_val,$content_msg) = $attachment->_Set( Field =>'Content', Value => $ARGS{'Content'});
}
Modified: RT-Journal/trunk/html/Journal/Elements/Tabs
==============================================================================
--- RT-Journal/trunk/html/Journal/Elements/Tabs (original)
+++ RT-Journal/trunk/html/Journal/Elements/Tabs Wed Aug 18 20:50:02 2004
@@ -40,16 +40,18 @@
my $second_tabs = { 'aab' => { title => loc('My Journal'),
path => 'Journal/Show.html?user='.$session{'CurrentUser'}->Name },
- post => { title => loc('Post'),
+ 'post' => { title => loc('Post'),
path => 'Journal/Post.html' },
-# 'articles' => { title => loc('Friends'),
-# path => 'Journal/Show.html?who=friends' },
+ 'articles' => { title => loc('My Friends'),
+ path => 'Journal/Show.html?who=friends' },
# 'articles2' => { title => loc('Workgroup'),
# path => 'Journal/Show.html?who=workgroup' },
# 'search' => { title => loc('Search'),
# path => 'Journal/Search.html' },
# 'd' => { title => loc('Configuration'),
-# path => 'Journal/Admin.html' }
+# path => 'Journal/Admin.html' },
+ 'q' => { title => loc('Edit Friends'),
+ path => 'Journal/Friends.html'}
};
my $topactions = {
Added: RT-Journal/trunk/html/Journal/Friends.html
==============================================================================
--- (empty file)
+++ RT-Journal/trunk/html/Journal/Friends.html Wed Aug 18 20:50:02 2004
@@ -0,0 +1,53 @@
+<& Elements/Tabs, Title => loc("Edit Friends") &>
+
+<form action="Friends.html" method=post>
+
+<h3>Current Friends:</h3> <i>(check box to remove)</i><br><br>
+% foreach my $friend (@friends) {
+<input type="checkbox" name="removefriend-<%$friend->Content%>">
+<% $namelookup{$friend->Content} %><br>
+% }
+
+Add Friend:
+<select name="addfriend">
+<option value="">Nobody</option>
+% foreach my $nf (@nonfriends) {
+<option value="<%$nf%>"><%$namelookup{$nf}%></option>
+% }
+</select>
+
+<input type="submit" value="Save Changes">
+</form>
+
+<%INIT>
+my $userobj = $session{'CurrentUser'};
+my @friends = $userobj->Attributes->Named("friend");
+my @nonfriends;
+my %namelookup;
+
+my $nfs = RT::Users->new($session{'CurrentUser'});
+$nfs->LimitToPrivileged;
+
+foreach my $friend (@friends) {
+# print $friend->Content . "<br>";
+ if ($ARGS{'removefriend-' . $friend->Content}) {
+ $userobj->Attributes->DeleteEntry(Name => "friend",
+ Content => $friend->Content);
+ }
+}
+
+if ($ARGS{'addfriend'}) {
+# print "adding " . $ARGS{'addfriend'} . "<br>";
+ $userobj->AddAttribute( Name => "friend", Content => $ARGS{'addfriend'} );
+}
+ at friends = $userobj->Attributes->Named("friend");
+
+while (my $nf = $nfs->Next) {
+ $namelookup{$nf->Id} = $nf->Name;
+ my $match = grep {$_ == $nf->Id} map {$_->Content} @friends;
+ push @nonfriends, ($nf->Id) if ($match == 0);
+}
+
+</%INIT>
+<%ARGS>
+</%ARGS>
Modified: RT-Journal/trunk/html/Journal/Post.html
==============================================================================
--- RT-Journal/trunk/html/Journal/Post.html (original)
+++ RT-Journal/trunk/html/Journal/Post.html Wed Aug 18 20:50:02 2004
@@ -1,4 +1,4 @@
-<& Elements/Tabs, Title => loc("Post Journal") &>
+<& Elements/Tabs, Title => loc("New Post") &>
<br><br>
<&|/l&>Add this to the bookmarks bar to blog urls you find interesting:</&>
<A href="javascript:void(window.open('<%$RT::WebURL%>Journal/Post.html?new-RefersTo='+escape(window.location)+'&Content='+escape(document.selection)+'&Subject='+escape(document.title),'webloglet','scrollbars=yes,status=yes,location=yes,toolbar=yes'));"><&|/l&>RT Journal Bookmarklet</&></a><BR>
@@ -8,9 +8,9 @@
<A NAME="top"></a>
<BR>
-<&|/l&>Subject</&>:
+<b><&|/l&>Subject</&></b>:
<INPUT Name="Subject" SIZE=60 MAXSIZE=100 value="<%$ARGS{Subject} || ''%>"><br>
-<&|/l&>Category</&>:<& Elements/SelectCategory &><br>
+<b><&|/l&>Category</&></b>:<& Elements/SelectCategory &><br>
%# <&|/l&>Attach</&>: <INPUT TYPE=FILE NAME="Attach"><br>
<&|/l&>Content</&>:<br>
Modified: RT-Journal/trunk/html/Journal/Show.html
==============================================================================
--- RT-Journal/trunk/html/Journal/Show.html (original)
+++ RT-Journal/trunk/html/Journal/Show.html Wed Aug 18 20:50:02 2004
@@ -1,29 +1,56 @@
-<& Elements/Tabs &>
-<h1><&|/l,$session{'CurrentUser'}->UserObj->Name&>Journal of [_1]</&></h1>
-%while( my $post = $tix->Next) {
-% my $my_category = $post->FirstCustomFieldValue('RT::Journal-Category');
+% my $title;
+% if ($who eq "friends") {
+% $title = "Friends of " . ($user ? $user : $session{'CurrentUser'}->Name);
+% } elsif ($user) {
+% $title = "Journal of " . $user;
+% } else {
+% $title = "All posts";
+% }
+<& Elements/Tabs, Title => loc($title) &>
+<h1><&|/l, $title &></&></h1>
+
+% my $any = 0;
+% while (my $post = $tix->Next) {
+% $any = 1;
+% my $my_category = $post->FirstCustomFieldValue('RT::Journal-Category');
<%$post->CreatedObj->AsString%><br>
-<h2><a href="Article.html?id=<%$post->id%>"><%$post->Transactions->First->Subject|| loc('Untitled')%></a></h2>
-% my $content = $post->Transactions->First->Content;
-% $content =~ s/^-- (.*)$//gism; # kill all signatures
-% $content =~ s/\n/<br>/gi;
+<h2><a href="Article.html?id=<%$post->id%>"><%$post->Transactions->First->Subject|| loc('Untitled')%></a>
+% unless ($user) {
+- [<%$post->OwnerObj->Name%>]
+% }
+</h2>
+% my $content = $post->Transactions->First->Content;
+% $content =~ s/^-- (.*)$//gism; # kill all signatures
+% $content =~ s/\n/<br>/gi;
<%$content|n%>
-% my $refto = $post->RefersTo;
+% my $refto = $post->RefersTo;
<div align="right">
-% while( my $link = $refto->Next ) {
+% while( my $link = $refto->Next ) {
<A href="<%$link->TargetURI->Resolver->HREF%>"><%$link->TargetURI->Resolver->HREF%></a><br>
-% }
+% }
</div>
-% my $comments = $post->Transactions;
-% $comments->Limit(FIELD => 'Type', VALUE => 'Correspond');
+% my $comments = $post->Transactions;
+% $comments->Limit(FIELD => 'Type', VALUE => 'Correspond');
[<a href="Article.html?id=<%$post->Id%>"><&|/l,$comments->Count&>[_1] Comments</&></a>]
<a href="Show.html?show=<%$ARGS{'show'}%>&user=<%$user%>&category=<%$my_category%>"><%$my_category%></a>
<hr>
% }
-<a href="Show.html?show=<%$ARGS{'show'}%>&user=<%$user%>&category=<%$category%>&first=<%$first+$count%>"><&|/l&>Next page</&></a> |
+
+% if ($total >= $first + $count) {
+<a href="Show.html?show=<%$ARGS{'show'}%>&user=<%$user%>&category=<%$category%>&first=<%$first+$count%>&count=<%$count%>"><&|/l&>Next page</&></a> |
+% }
% if ($first > 1) {
-<a href="Show.html?show=<%$ARGS{'show'}%>&user=<%$user%>&category=<%$category%>&first=<%$first-$count%>"><&|/l&>Previous page</&></a> |
+<a href="Show.html?show=<%$ARGS{'show'}%>&user=<%$user%>&category=<%$category%>&first=<%$first-$count%>&count=<%$count%>"><&|/l&>Previous page</&></a> |
% }
+
+% if ($any == 0) {
+% if ($who eq "friends") {
+Looks like <% $user ? $user . " has" : "you have" %> no friends defined, or they haven't posted anything at all.
+% } else {
+This journal is empty.
+% }
+% }
+
<%INIT>
my $q = RT::Queue->new($RT::SystemUser);
$q->Load($RT::JournalQueue);
@@ -34,7 +61,31 @@
my $tix = RT::Tickets->new( $session{'CurrentUser'} );
$tix->LimitQueue( VALUE => $RT::JournalQueue );
$tix->OrderBy( FIELD => 'Created', ORDER => 'DESC' );
-if ($user) {
+if ($who eq "friends") {
+ my $querystring = "";
+ my $querybase = "Owner = ";
+ my $userobj;
+ if ($user) {
+ $userobj = RT::User->new($session{'CurrentUser'});
+ $userobj->Load($user);
+ } else {
+ $userobj = $session{'CurrentUser'};
+ }
+ my @friends = $userobj->Attributes->Named("friend");
+ foreach my $friend (@friends) {
+ $querystring .= " OR " . $querybase . "'" . $friend->Content ."'";
+ }
+ $querystring =~ s/^ OR //;
+ if ($querystring eq "") {
+ # no friends. show nothing.
+
+ $querystring = "Owner = '1' AND Owner = '2'";
+ }
+ $querystring .= " AND Queue = '" . $q->Id . "'";
+# $tix = RT::Tickets->new( $session{'CurrentUser'} );
+ $tix->FromSQL($querystring);
+ $tix->OrderBy( FIELD => 'Created', ORDER => 'DESC' );
+} elsif ($user) {
$tix->LimitOwner( VALUE => $user );
}
if ($category) {
@@ -44,13 +95,15 @@
VALUE => $category . "%"
);
}
+my $total = $tix->Count;
$tix->RowsPerPage($count);
$tix->FirstRow($first);
</%INIT>
<%ARGS>
-$user => undef
-$first => 1
+$user => undef
+$first => 1
$category => undef
-$show => 'article'
-$count => 25
+$show => 'article'
+$count => 25
+$who => undef
</%ARGS>
More information about the Rt-commit
mailing list