Description:
This box is the subscription link creation code for insertion of the 'subscribe' link to subscribe to users' diaries. In the story_summary block, the call to this box should look like this:
|BOX,diarysub_box,|aid||
This box must also be deployed as it's own op called 'diary', having a page template containing only the text ' |CONTENT| '. The purpose of this OP is to actually perform the subscribe and unsubscribe operations, storing the data used by the diary view of the hotlist_flex(diary) box.
Box Code:
my $op = $S->cgi->param('op');
my $user = $S->cgi->param('user');
my $content;
if($S->{GID} ne 'Anonymous'){
my $subscriptions;
map {$subscriptions->{$_}=1;} split(/,/,$S->pref('diary_sub'));
if($op eq 'diary'){
if(exists $subscriptions->{$user}){
delete $subscriptions->{$user};
}else{$subscriptions->{$user}=1;}
$S->pref('diary_sub',join(',',keys %$subscriptions));
$S->{APACHE}->header_out('location',$S->{REFERER} \|\| "$S->{UI}->{VARS}->{rootdir}/section/Diary");
$S->{APACHE}->header_out('Connection','close');
$S->{APACHE}->status(301); $S->{HEADER_ONLY}=1;
} else{
my $text=($subscriptions->{$ARGS[0]})?'Unsubscribe':'Subscribe';
$content=qq{<font size="2">[</font><a href="|rootdir|/diary/$ARGS[0]"><font size="2">$text</font></a><font size="2">]</font>};
return{content=>$content};
}
}
Announcement and Discussion
|