# -*-perl-*-
# keitairc/lib/plugins/00all
# チャネルの全メッセージ閲覧
# $Id: 00all,v 1.1 2008/01/09 19:30:34 morimoto Exp $
# $Source: /cvsroot/keitairc/lib/plugins/00all,v $

$plugin = {
	name => 'all',
	action_imprementation => sub {
		my ($request, $name, $session_id, $param_string) = @_;
		my $channel = ::uri_unescape($param_string);

		::send_message($request, $channel);

		my $buf;
		my $no_message_here_yet;
		if(defined($::ib->name($channel))){
			if(length($::ib->buffer($channel))){
				if($::cf->show_newmsgonly() && $::ib->message_added()){
					$buf = ::render_line($::ib->unread($channel), $session_id) ||
						'(未読発言はありません)';
					$buf .= sprintf('<br /><a accesskey="5" href="../all/%s">[5] 全発言へ</a>',
							::uri_escape($channel));
				}else{
					$buf = ::render_line($::ib->buffer($channel), $session_id);
				}
			}else{
				$no_message_here_yet = 1;
			}
		}else{
			$buf = '指定のﾁｬﾈﾙは存在しません';
		}

		$::ib->message_added(0); # clear check flags
		$::ib->clear_unread($channel);

		my $ci = new Keitairc::ClientInfo($request);
		my $view = new Keitairc::View($::cf, $ci);
		return $view->render('all.html', {
			buf => $buf,
			channel_compact => $::ib->compact_channel_name($::ib->name($channel)),
			channel => ::uri_escape($channel),
			no_message_here_yet => $no_message_here_yet,
			ipod => $ci->is_ipod(),
			     });
	}
};

1;
