sub UserClipBoardFilename { + my ($id) = @_; + + return "" if ($id < 1); + return $UserDir . "/" . ($id % 10) . "/$id.cb"; + } sub DoOtherRequest { ... + } elsif ($action eq "editclipboard") { + &DoEditClipboard(); +} elsif ($action eq "clipboard") { + &DoClipboard(); ... + if (&GetParam("edit_clipboard", 0)) { + &DoUpdateClipboard(); + return; + } + sub DoClipboard { + my ($username, $userfile); + my ($status, $data); + + $username = &GetParam('username', ''); + print &GetHeader('', &QuoteHtml(Ts('Clipboard for: %s', $username)), ''); + return if (!&UserIsAdminOrError()); + $userfile = &UserClipBoardFilename($UserID); + ($status, $data) = &ReadFile($userfile); + print &WikiToHTMLNoDivNoToc($data); + print &GetMinimumFooter(); + } + sub DoEditClipboard { + my $status; + my $clipboardFile; + + print &GetHeader('', T('Editing Clipboard'), ''); + return if (!&UserIsAdminOrError()); + ($status, $clipboardFile) = &ReadFile(&UserClipBoardFilename($UserID)); + $clipboardFile = "" if (!$status); + print &GetFormStart(); + print GetHiddenValue("edit_clipboard", 1), "\n"; + print &GetTextArea('clipboard', $clipboardFile, 20, 100); + print '<br>', $q->submit(-name=>'Save'), "\n"; + print $q->endform; + print &GetMinimumFooter(); + } + sub DoUpdateClipboard { + my ($newList, $fname); + my ($status, $data); + my ($userfile, $clipboardFile); + + print &GetHeader('', T('Updating Clipboard'), ''); + return if (!&UserIsAdminOrError()); + $fname = &UserClipBoardFilename($UserID); + $newList = &GetParam("clipboard", "#Empty file"); + if ($newList eq "") { + print "<p>Empty clipboard file or error."; + print "<p>Resubmit with at least one space character to remove."; + } elsif ($newList =~ /^\s*$/s) { + unlink($fname); + print "<p>Removed clipboard file"; + } else { + &WriteStringToFile($fname, $newList); + # print "<p>Updated clipboard file"; + $userfile = &UserClipBoardFilename($UserID); + ($status, $data) = &ReadFile($userfile); + print &WikiToHTML($data); + } + print &GetMinimumFooter(); + } sub GetAdminBar { ... + $result .= ' | ' . &ScriptLink('action=clipboard', T("ClipBoard")); + $result .= ' | ' . &ScriptLink("action=editclipboard", T('Edit ClipBoard'));--JuanmaMP