From: Michael Andreen Date: Fri, 1 Aug 2008 10:59:01 +0000 (+0200) Subject: Sending private messages or threads. X-Git-Url: https://ruin.nu/git/?p=ndwebbie.git;a=commitdiff_plain;h=af67320b296a7ebc59fcbe227efc2b0362c0a13d Sending private messages or threads. --- diff --git a/lib/NDWeb.pm b/lib/NDWeb.pm index af45ad0..bce6c38 100644 --- a/lib/NDWeb.pm +++ b/lib/NDWeb.pm @@ -97,6 +97,7 @@ __PACKAGE__->deny_access_unless('/intel/naps',[qw/intel_naps/]); __PACKAGE__->deny_access_unless('/jsrpc',[qw//]); __PACKAGE__->allow_access_if('/jsrpc/end',1); __PACKAGE__->deny_access_unless('/forum/allUnread',[qw//]); +__PACKAGE__->deny_access_unless('/forum/privmsg',[qw//]); __PACKAGE__->deny_access_unless('/settings',[qw//]); =head1 NAME diff --git a/lib/NDWeb/Controller/Forum.pm b/lib/NDWeb/Controller/Forum.pm index f33319a..d08bb61 100644 --- a/lib/NDWeb/Controller/Forum.pm +++ b/lib/NDWeb/Controller/Forum.pm @@ -425,6 +425,31 @@ sub removeownthreadaccess : Local { $c->res->redirect($c->uri_for('allUnread')); } +sub privmsg : Local { + my ( $self, $c, $uid ) = @_; + + $uid ||= 0; + $c->stash(uid => $uid); + + $c->forward('findUsers'); +} + +sub postprivmsg : Local { + my ( $self, $c ) = @_; + my $dbh = $c->model; + + $dbh->begin_work; + $c->forward('insertThread',[-1999]); + + $c->req->parameters->{uid} = [$c->req->parameters->{uid}] + unless ref $c->req->parameters->{uid} eq 'ARRAY'; + push @{$c->req->parameters->{uid}}, $c->user->id; + $c->forward('addaccess',[$c->stash->{thread}]); + + $c->forward('addPost',[$c->stash->{thread}]); + $dbh->commit; +} + sub addaccess : Private { my ( $self, $c, $thread) = @_; my $dbh = $c->model; diff --git a/root/lib/site/leftbar.tt2 b/root/lib/site/leftbar.tt2 index 08e1ac3..c5c71b2 100644 --- a/root/lib/site/leftbar.tt2 +++ b/root/lib/site/leftbar.tt2 @@ -5,6 +5,7 @@
  • Forum search
  • [% IF user %]
  • New posts [% IF user.unreadposts %]([% user.unreadposts %])[% END %]
  • +
  • Priv msg
  • Settings
  • Log out ([% c.user.username %])
  • [% ELSE %] diff --git a/root/src/forum/privmsg.tt2 b/root/src/forum/privmsg.tt2 new file mode 100644 index 0000000..8870813 --- /dev/null +++ b/root/src/forum/privmsg.tt2 @@ -0,0 +1,45 @@ +[% META title = 'Private Message' %] + +
    +New Private Message +

    Receiver(s):

    +
    +

    Subject:

    + +
    + + +
    +
    + +