#!/usr/bin/perl # use strict; unless (-d $ENV{'LJHOME'}) { die "\$LJHOME not set.\n"; } use vars qw(%hooks); my $LJHOME = $ENV{'LJHOME'}; require "$LJHOME/doc/raw/build/docbooklib.pl"; $hooks{'canonicalize_url'} = { desc => "Cleans up a URL into its canonical form.", args => [ { 'desc' => "URL to be cleaned", 'name' => "\$url", } ], source => ["bin/maint/stats.pl"], }; $hooks{'emailconfirmed'} = { desc => "After a user has confirmed their email address, this hook is called ". "with a dbs/dbh and a user object. This is useful to update a ". "database alias table which you also have your mail system using for ". "address lookups.", args => [ { 'desc' => "Either a dbs or dbh resource object.", 'name' => "\$dbarg", }, { 'desc' => "User object.", 'name' => "\$u", }, ], source => ["htdocs/register.bml"], }; $hooks{'login_formopts'} = { desc => "Returns extra HTML for login options on login.bml", args => [ { 'desc' => "Hash of arguments", 'name' => "\%args", 'keys' => [ { 'desc' => "Scalar return reference", 'name' => "ret", }, ], }, ], source => ["htdocs/login.bml"], }; $hooks{'modify_login_menu'} = { desc => "Modifies or resets entirely the web menu data structure that is sent to the client.", args => [ { 'desc' => "Hash of arguments", 'name' => "\%args", 'keys' => [ { 'desc' => "Menu item", 'name' => "menu", }, { 'desc' => "User object", 'name' => "u", }, { 'desc' => "Resource object", 'name' => "dbs", }, { 'desc' => "Username string", 'name' => "user", }, ], }, ], source => ["cgi-bin/ljprotocol.pl"], }; $hooks{'post_login'} = { desc => "Action to take after logging in, before HTML is sent to ". "to client (possible to print HTTP headers directly)", args => [ { 'desc' => "Hash of arguments", 'name' => "\%args", 'keys' => [ { 'desc' => "User object", 'name' => "u", }, { 'desc' => "Hash of form elements", 'name' => "form", }, { 'desc' => "Used for cookies. Can either be a unix timestamp, or '0' for session cookies.", 'name' => "expiretime", }, ], }, ], source => ["htdocs/login.bml", "htdocs/talkread_do.bml"], }; $hooks{'post_changepassword'} = { desc => "Action to take after changing password, before HTML is sent to ". "to client (possible to print HTTP headers directly)", args => [ { 'desc' => "Hash of arguments", 'name' => "\%args", 'keys' => [ { 'desc' => "User object", 'name' => "u", }, { 'desc' => "Resource object", 'name' => "dbs", }, { 'desc' => "New password.", 'name' => "newpassword", }, { 'desc' => "Old password.", 'name' => "oldpassword", }, ], }, ], source => ["htdocs/changepassword.bml"], }; $hooks{'post_create'} = { desc => "Action to take after creating an account.", args => [ { 'desc' => "Hash of arguments", 'name' => "\%args", 'keys' => [ { 'desc' => "Resource object", 'name' => "dbs", }, { 'desc' => "Username string", 'name' => "user", }, { 'desc' => "Integer", 'name' => "userid", }, { 'desc' => "Auth code, if in use", 'name' => "code", }, ], }, ], source => ["cgi-bin/ljlib.pl"], }; $hooks{'userinfo_html_by_user'} = { desc => "Extra HTML to show next to username & id on userinfo.bml", args => [ { 'desc' => "Hash of arguments", 'name' => "\%args", 'keys' => [ { 'desc' => "Scalar return reference", 'name' => "ret", }, { 'desc' => "User object", 'name' => "u", }, ], }, ], source => ["htdocs/userinfo.bml"], }; $hooks{'userinfo_rows'} = { desc => "Returns a two-element arrayref for a row on a userinfo page, ". "containing first the left side label, then the body.", args => [ { 'desc' => "Hash of arguments", 'name' => "\%args", 'keys' => [ { 'desc' => "Resource Object (read-only)", 'name' => "dbr", }, { 'desc' => "User object", 'name' => "u", }, { 'desc' => "Remote user object", 'name' => "remote", }, ], }, ], source => ["htdocs/userinfo.bml"], }; $hooks{'validate_get_remote'} = { desc => "This hook lets you ignore the remote user's cookies or flag them ". "as intentionally forged to LJ::get_remote(). If you return a ". "true value, no action is taken. If you return false, LJ::get_remote() ". "returns undef. You can optionally set \$\$criterr to something true as well.", args => [ { 'desc' => "Hash of arguments", 'name' => "\%args", 'keys' => [ { 'desc' => "May be an empty string or undef", 'name' => "user", }, { 'desc' => "May be 0", 'name' => "userid", }, { 'desc' => "Resource object", 'name' => "dbs", }, { 'desc' => "Capabilities", 'name' => "caps", }, { 'desc' => "Scalar error reference", 'name' => "criterr", }, { 'desc' => "Sub reference which takes a cookie name and returns its value", 'name' => "cookiesource", }, ], }, ], source => ["cgi-bin/ljlib.pl"], }; $hooks{'bad_password'} = { desc => "Check the given password, and either return a string explaining why ". "the password is bad, or undef if the password is ok.", args => [ { 'desc' => "Password to check", 'name' => "\$password", }, ], source => ["cgi-bin/ljprotocol.pl","htdocs/changepassword.bml","htdocs/create.bml","htdocs/update.bml"], }; $hooks{'name_caps'} = { desc => "Returns the long name of the given capability bit.", args => [ { 'desc' => "Capability bit to check", 'name' => "\$cap", }, ], source => ["cgi-bin/ljlib.pl"], }; $hooks{'name_caps_short'} = { desc => "Returns the short name of the given capability bit.", args => [ { 'desc' => "Capability bit to check", 'name' => "\$cap", }, ], source => ["cgi-bin/ljlib.pl"], }; $hooks{'login_add_opts'} = { desc => "Appends options to the cookie value. Each option should be short, and preceeded by a period.", args => [ { 'desc' => "", 'name' => '%args', 'keys' => [ { 'desc' => "User object", 'name' => "u", }, { 'desc' => "Login form elements", 'name' => "form", }, { 'desc' => "Hash reference of options to append to login cookie", 'name' => "opts", }, ], }, ], source => ["htdocs/login.bml"], }; $hooks{'set_s2bml_lang'} = { desc => "Given an S2 Context, return the correct BML language id", args => [ { 'desc' => "S2 Context", 'name' => '$ctx', }, { 'desc' => "Language id reference", 'name' => '\$langref', }, ], source => ["cgi-bin/LJ/S2.pm"], }; sub hooks { my $hooks = shift; my $arg; print "\n"; foreach my $hook (sort keys %$hooks) { print " \n"; print " $hook\n"; print " Synopsis:\n"; print " \n"; print " $hook\n"; if (@{$hooks->{$hook}->{'args'}}) { print " \n"; foreach $arg (@{$hooks->{$hook}->{'args'}}) { print " $arg->{'name'}\n"; } print " \n"; } else { print " "; } print " \n"; print " \n"; print " $hooks->{$hook}->{'desc'}\n"; print " \n"; if (@{$hooks->{$hook}->{'args'}}) { print " Arguments:\n"; print " \n"; foreach $arg (@{$hooks->{$hook}->{'args'}}) { print " \n"; print " $arg->{'name'}\n"; print " \n"; print " $arg->{'desc'}\n"; if ($arg->{'keys'}) { print " Keys\n"; foreach my $key (@{$arg->{'keys'}}) { print " $key->{'name'}"; print " — $key->{'desc'}\n"; } print " "; } print " \n"; print " \n"; } print " \n"; print " \n"; } print " Source:\n"; print " "; foreach my $i ( 0 .. $#{ $hooks->{$hook}->{'source'} } ) { print ""; print $hooks->{$hook}->{'source'}[$i]; print ""; } print " \n"; print " \n"; print " \n"; } print "\n"; } hooks(\%hooks);