[Home]WikiPatches/Contributions

UseModWiki | WikiPatches | RecentChanges | Preferences

This is an attempt for implementing in Usemod a patch for contributions from a user.

Patch 1

Sub DoOtherRequest {
...
      &DoTrimUsers();
+    } elsif ($action eq "authorcontrib") {
+      &DoAuthorContrib($id);

sub GetHtmlRcLine {
...
  $html .= ". . . . . $author\n";
+ $html .=  ' | ' . &ScriptLink("action=authorcontrib&id=$userName", Ts("Contrib")) ;
  return $html;

sub DoAuthorContrib {
+  my ($id, $author) = @_;
+  my ($status, $data, $fileData, $oldFileData);
+  my (@full, $full, @fullrc, @fullnewrc);
+  my (@firstTs, $firstTs, @Author);
+  my ($i, $j);
+	
+  print  &GetHeader("", Ts('%s contributions', $id),"");
+  ($status, $fileData) = &ReadFile($RcFile);
+  @fullnewrc = split(/\n/, $fileData);
+  ($status, $oldFileData) = &ReadFile($RcOldFile);
+  @fullrc = split(/\n/, $oldFileData);
+  @full = (@fullrc, @fullnewrc);
+  ($i, $j) =0;
+  if (@full > 0) {
+    for ($i .. $#full) {
+      $j = $#full -$i;
+      ++$i;
+      @Author = split(/$FS2/, $full[$j]);
+      if ($id eq $Author[3]) {
+        @firstTs = split(/$FS3/, $full[$j]);
+	print &TimeToText($firstTs[0]). ' ' . &GetPageLink($firstTs[1]) , "<br>\n";
+      }
+    }
+  }
+  print &GetCommonFooter();
+}

To distinguish according to ID Number:

Patch 2

sub DoContributions {
  my ($id, $author) = @_;
  my (@userAuthor, $userAuthor, @userName, $userName, @userID, $userID);
  my ($status, $fileData, $oldFileData);
  my ($firstTs, @firstTs, @firstAuthor, @firstTime, $firstTime);
  my ($full, @full, @fullrc, @fullnewrc);
  my ($i, $j, @i, @j);
 
  (@userAuthor) = split('&', $ENV{QUERY_STRING});
  (@userName) = split ('=', $userAuthor[1]);
  (@userID) = split ('=', $userAuthor[2]);
  print  &GetHeader('', Ts('Contributions: %s', $userName[1]),'');
  ($status, $fileData) = &ReadFile($RcFile);
  @fullnewrc = split(/\n/, $fileData);
  ($status, $oldFileData) = &ReadFile($RcOldFile);
  @fullrc = split(/\n/, $oldFileData);
  @full = (@fullrc, @fullnewrc);
  ($i, $j) =0;
  print '<ol>';
  if (@full > 0) {  # Only false if no lines in file
	for ($i .. $#full) {
	  $j = $#full -$i;
      ++$i;
      @firstAuthor = split(/$FS2/, $full[$j]);
      if ($userName[1] eq $firstAuthor[$#j-2]  and $userID[1] eq $firstAuthor[$#j]) {
		@firstTs = split(/$FS3/, $full[$j]);
		    ## if ($firstAuthor[$#j-2] eq $firstAuthor[3]) { ## line pattern ok, not corrupt
            print '<li><nobr>' 
			## ' [' . $firstAuthor[$#j] . '] ' . $firstAuthor[$#j-2]
			.  ' (' . &TimeToText($firstTs[0]) 
			. ') ' . &GetPageOrEditAnchoredLink($firstTs[1]) 
			. '</nobr><br>';
            ## }
		}
	}
}
  print '</ol>';
  print '</div>' . &GetCommonFooter();
}

To Do

Add links to History and Diffs

--JuanmaMP


UseModWiki | WikiPatches | RecentChanges | Preferences
Edit text of this page | View other revisions | Search MetaWiki
Last edited July 24, 2009 11:28 pm by JuanmaMP (diff)
Search: