my ($inner,$nodeloc,$title,$htmltitle)=@_; return "[$inner]" unless $nodeloc; my $N; my ($node,$view,$type)=split /;/,$nodeloc; { if ($type and my $T=getType($type)) { last if $N=getNode($node,$T); } if ($node=~/^\d+$/) { $N=getNodeById($node); } else { ($N)=getNodeWhere({title=>$node}); } } return "[$inner]" unless $N; return linkNode($N,$title||$N->{title}, { class=> 'node_link', $view ? (displaytype => $view) : () } ); #### my ($user_spec, $text, $linktype, $idonly, $create) = @_; # $user_spec => a $USER object, a users id, or a users name # $text => text to use for link # $linktype => a hash of parameters to add to the links url # $idonly => we want an ID back ONLY # $create => create the scratchpad if necessary # Do some juggling to manage the different forms of $user_spec my $user; if (ref $user_spec) { # Its an object $user=$user_spec; } else { # Its either an id or a name. The || is to handle any pesky users # who have a number for a name. Not sure if thats legal, but we check anyway. $user = $user_spec=~/\D/ ? getNode($user_spec, 'user') : ( getNodeById($user_spec) || getNode($user_spec, 'user') ); # Bail if we still have no $user (we can't create without a user so # that flag is irrelevent here) unless ($user) { return $idonly ? "" : linkNode(108949, ($text || "$user_spec\'s scratchpad"), { user=> $user_spec } ) } } # at this point we have a valid $user object my $user_id = $user->{user_id}; my $user_title = $user->{title}; # [demerphq] commented the following out for now because # Anonymonk _has_ a scratchpad. Maybe one day the gods # will put something useful there... # # return $idonly ? "" : 'Anonymonk has no scratchpad!' # if and getId($user) == $HTMLVARS{guest_user}; # Fetch the pad my $ret={user=>$user}; my ($pad_id,$pad_title); if ( htmlcode('get_user_scratchpads','',$ret) ) { ($pad_id,$pad_title) = @{$ret->{pads}[0]}; } # Links to scratchpads go to the scratchpad viewer prior to # creating a proper node. If they actually follow the link # and go to the viewer then the creation will occur because # that node will call us again, but with the magic $create flag if (!$pad_id and !$create) { return "" if $idonly; $text ||= $user_title."'s scratchpad"; return ($linktype && $linktype->{displaytype} eq 'edit') ? linkNode(108949, $text, { user=>$user_title, svmode=>'edit'}) : linkNode(108949, $text, { user=>$user_title }) } else { $text||=$pad_title; } # They either have a pad, or we are supposed to force its creation. # So make a pad if there isn't one already... $pad_id = htmlcode('createscratchpad', '', $user,'',1) unless $pad_id; # Sanity clause -- Make sure we actually got one back return $idonly ? "" : "Woah! Bad Mojo in scratchpad_link ($user_id,$text,$user_title)" unless $pad_id; # Return the link/or ID of the scratchpad return $idonly ? $pad_id : linkNode($pad_id, $text, $linktype); #### my ($inner)=@_; my ($nodeloc,$title,$alt)=$inner=~m#^pmdev://([^|]+)(?:\|([^|]*)(?:\|([^|]*))?)?$#; return "[$inner]" unless $nodeloc; my $N; my ($textlink, $display, $comment)=('') x 3; if ($nodeloc=~/^\?/) { $textlink=qq(); if (!$title and $nodeloc=~/node(?:_id)?=([^&;]+)/) { $title=$1; } } elsif ($nodeloc=~/\D/) { my ($node,$view,$type)=split /;/,$nodeloc; if ($type) { $comment=""; my $T=getType($type); $N=getNode($node,$T) if $T; } elsif ($node=~/\D/) { $comment=""; ($N)=getNodeWhere({title=>$node}); } else { $comment=""; $N=getNodeById($node); } $display=$view; } else { $comment=""; $N=getNodeById($nodeloc); }; my $PMDEV=getNode( 'pmdev', 'usergroup' ); return join '',$comment, defined($alt) ? $alt : $title||$N->{title}||"" unless Everything::isApproved($USER,$PMDEV); return "[$inner]" unless $textlink || $N; return join '',$comment, $textlink ? $textlink.$q->escapeHTML($title||$nodeloc)."" : linkNode($N,$title||$N->{title}, $display ? { displaytype => $display } : () ) ;