#!/usr/bin/perl -w use strict; my($MT_DIR); BEGIN { if ($0 =~ m!(.*[/\\])!) { $MT_DIR = $1; } else { $MT_DIR = './'; } $MT_DIR =~ s/plugins\///g; unshift @INC, $MT_DIR . 'lib'; unshift @INC, $MT_DIR . 'extlib'; } eval { @MT::App::PSYCConf::ISA = qw( MT::App ); my $app = MT::App::PSYCConf->new( Config => $MT_DIR . 'mt.cfg', Directory => $MT_DIR ) or die MT->errstr; local $SIG{__WARN__} = sub { $app->trace($_[0]) }; my ($author, $first_time) = $app->login; if (ref $author eq 'MT::Author') { $app->run(); } else { print "Content-Type: text/html\n\n"; print "Log into MovableType first!\n"; } }; if ($@) { print "Content-Type: text/html\n\n"; print "Got an error: $@"; } package MT::App::PSYCConf; use MT::App; sub NAME { "PSYC Plugin, v.0.1" } sub init { my $app = shift; $app->SUPER::init(@_) or return; $app->add_methods('config' => \&view_config, 'add' => \&add, 'del' => \&del, 'reset'=> \&reset); $app->{default_mode} = 'config'; $app->{charset} = $app->{cfg}->PublishCharset; $app->{requires_login} = 1; MT::Object->set_driver($app->{cfg}->ObjectDriver); $app->{user_class} = 'MT::Author'; } sub view_config { my $app = shift; my $data = MT::PluginData->load({ plugin => NAME(), key => 'notify_list' }); my $T = $data->data; my $title = NAME(); my $html = < $title
Movable Type

EOF foreach my $blog (keys %$T) { my $b = MT::Blog->load($blog); my $blog_name = $b->name; my $blog_url = $b->site_url; my $rowspan = scalar(keys %{$T->{$blog}}); next unless ($rowspan); $html .= ""; foreach my $event (keys %{$T->{$blog}}) { next unless (@{$T->{$blog}->{$event}}); $html .= ""; } } $html .= <
Blog ID: Event: UNI:


Simply add the PSYC-address you want to be notified if an event occurs.
You have no idea how a PSYC-Adress looks like? Its rather simple: psyc://server:port/~nick for a users identification at his home-server or psyc://server:port/@room for a chatroom.

visit www.psyc.eu for more information about the idea behind PSYC and the protocol itself AND www.psyced.org to get yourself a psyced (an open-source PSYC-Server which also supports other protocols like IRC, Jabber and even a telnet interface).

EOF $html; } sub add { my $app = shift; my $query = $app->{query}; my $data = MT::PluginData->load({ plugin => NAME(), key => 'notify_list' }); my $T = $data->data; my $blog_id = $app->{query}->param('blog_id'); my $event = $app->{query}->param('event'); my $uni = $app->{query}->param('uni'); return view_config() unless ($uni && $event && $blog_id); return view_config() if (ref $T->{$blog_id}->{$event} && grep { $_ eq $uni } @{$T->{$blog_id}->{$event}}); return view_config() unless (MT::Blog->load($blog_id)); $T->{$blog_id}->{$event} = [] unless ($T->{$blog_id}->{$event}); push(@{$T->{$blog_id}->{$event}}, $uni); $data->data($T); $data->save or die $data->errstr; return view_config(); } sub del { my $app = shift; my $query = $app->{query}; my $data = MT::PluginData->load({ plugin => NAME(), key => 'notify_list' }); my $T = $data->data; my $blog_id = $app->{query}->param('blog_id'); my $event = $app->{query}->param('event'); my $uni = $app->{query}->param('uni'); return view_config() unless ($blog_id && $event && $uni); return view_config() unless (ref $T->{$blog_id}->{$event}); # remove the adress $T->{$blog_id}->{$event} = [ grep { $_ ne $uni } @{$T->{$blog_id}->{$event}} ]; delete $T->{$blog_id}->{$event} unless (@{$T->{$blog_id}->{$event}}); delete $T->{$blog_id} unless (keys %{$T->{$blog_id}}); $data->data($T); $data->save or die $data->errstr; return view_config(); } sub reset { my $app = shift; my $data = MT::PluginData->load({ plugin => NAME(), key => 'notify_list' }); my $T = $data->data; $data->data({}); $data->save or die $data->errstr; return view_config(); } 1;
BlogEventUNIs
$blog_name
Id: $blog
$event"; $html .= join("
", map("$_ delete", @{$T->{$blog}->{$event}})); $html .= "