use strict; use Cmates::Config qw( %CONFIG ); use Cmates::DB; use Cmates::Group qw(:org_types);; use Cmates::User::Circle; use Cmates::Circle; use Cmates::Invitation; use Apache; my($cgi, $scribe) = @_; my %CTYPEMAP = ( 'REUNION' => 'rc', 'INTEREST GROUP' => 'ig', 'PRIVATE GROUP - AUTO' => 'prc', 'PRIVATE GROUP' => 'mpc', ); my %org_tab_type_map = ( hs => 'school', col => 'college', mil => 'military', wk => 'work', rc => 'reunion', ig => 'interestgroup', prc => 'privategroup', mpc => 'privategroup', gen => 'general', ); my %org_type_map = ( hs => SCHOOLS, col => SCHOOLS, mil => MILITARY, wk => WORK, rc => CIRCLES, ig => CIRCLES, prc => CIRCLES, mpc => CIRCLES, gen => GENERAL, ); $scribe->{registration_id} or return $forge->redirect('/cmo/'); my %args = map { $_ => $cgi->param($_) } $cgi->param; if ($args{app} eq 'mb') { my $tab_type = $org_tab_type_map{$args{type}}; return $forge->redirect("$CONFIG{URL_HOME}/cmo/mboard/mboardredirect.jsp?communityID=$args{id}&tabType=$tab_type"); } # old moderator board # point moderator board to new circle if($args{type} eq 'gen' and $args{id} = 2){ delete $args{type}; delete $args{id}; $args{circle_id} = Cmates::Circle::moderator_circle_id(); } for ( qw(ti mi to) ) { $args{$_} =~ tr/0-9//cd if $args{$_}; } my $circle_member_id; my $circle_type; my ($orgtype, $orgid); if ( $args{circle_id} ) { # if ( $args{type} ) { # Apache::warn "This script does not require 'type' if you pass in 'circle_id': $!"; # } $circle_member_id = Cmates::User::Circle->is_member($args{circle_id}); my $circle_type_id; my $ctype_query = q[ SELECT ct.name FROM circle_types ct ,circles c WHERE c.circle_id = ? AND c.circle_type_id = ct.circle_type_id ]; my $dbh = Cmates::DB->connect; my $sth = $dbh->prepare_cached( $ctype_query ); $sth->execute( $args{circle_id} ); unless ( $circle_type = $sth->fetchrow_array() ) { Apache::warn "Error fetching circle type for circle id [$args{circle_id}]: $!"; return $forge->redirect('/cmo/'); } $sth->finish; $orgid = $args{circle_id}; $orgtype = $CTYPEMAP{ $circle_type } or Apache::warn( "Circle typemap needs to be updated: $!"); } else { $orgid = $args{id}; $orgtype = $args{type}; } return $forge->redirect("/reunion/invite/?circle_id=$orgid") if ($args{app} eq 'cl'); # If it's a PRIVATE GROUP, we can't let them browse unless # they're a member or an invitee { last unless $orgtype eq 'mpc'; last if $circle_member_id; # They're a member. Ignore them. if (!Cmates::Invitation->is_invited('C', $args{circle_id})) { Apache::warn "$scribe->{registration_id} cannot access priv group $args{circle_id}"; return $forge->redirect("/cmo/user/index.jsp"); } } local $_; my %apps = ( mb => 1, # message boards pa => 1, # photo albums tc => 1, # text chat cl => 1, # calendar/event ); my $group_id; my $group_org_type; if($group_org_type = $org_type_map{$orgtype}){ $group_id = Cmates::Group::fetch_group_id($orgid, $group_org_type); } my %urls = ( pa => "$CONFIG{URL_PHOTO_HOST}/user/photoalbum/?group_id=$group_id&circle_id=$args{circle_id}&type=$args{type}", mb => "$CONFIG{URL_GROUP_HOST}/user/mboard/?group_id=$group_id&type=$args{type}", # tc => "$CONFIG{URL_GROUP_HOST}/user/textchat/?group_id=$group_id", ); my $url = $urls{ $args{app} }; return $forge->redirect( "$url" ); =head1 NAME www/user/ec.tf -- duct-tape gateway to eCircles functionality =head1 SYNOPSIS Link to a... * high school message board $CONFIG{URL_HOME}/user/ec.tf?app=mb;type=hs;id=5967 * military text chat $CONFIG{URL_HOME}/user/ec.tf?app=tc;type=mil;id=3330987 * interest group or member-created private group photo album $CONFIG{URL_HOME}/user/ec.tf?app=pa;circle_id=4244 * specific message in a school message board $CONFIG{URL_HOME}/user/ec.tf?app=mb;type=hs;id=5967;ti=321;mi=591;to=7566 =head1 QUERY STRING SPECIFICS Of course, the only important part of this Perl servlet is the query string. =over 4 =item * C ... always pass this in. Possbile values are currently: mb -- message boards pa -- photo albums tc -- text chat cl -- calendar/event =item * C ... pass this in with 'id' unless you're linking to a true circle (eg. interest groups or private groups) in which case you would pass in neither 'type' nor 'id' but simply 'circle_id'. Possible types are: rc -- reunion ig -- interest group prc -- private club (not currently used) pbc -- public club (not currently used) mpc -- member-created private group but see %Cmates::ECircles::CIRCLE_TYPES to see what circle types are really available. =item * C ... for real circles, all you have to pass in is 'app' and 'circle_id', the circle_type is fetched for you automatically. =item * C ... threadId. Used for linking to a specific message (only applies to message boards) =item * C ... messageId. Used for linking to a specific message (only applies to message boards) =item * C ... topicId. Used for linking to a specific message (only applies to message boards) =back =head1 AUTHORS Adam Monsen Eamonsen@classmates.comE. =head1 COPYRIGHT Copyright 2001-2002, Classmates Online, Inc. All rights reserved. =cut