[Home]WikiPatches/BulkLock

UseModWiki | WikiPatches | RecentChanges | Preferences

An intend to implement a new action for admins that returns a list of all pages in order to check or uncheck the lock parameter, having bulk action style.

With a little hack from: [UseModWiki소스수정/UploadedFiles매크로] (for delete images).

Current action permits manage both status (lock, unlock) through one input.

Analogously, this may apply to Delete Pages.

Comments are welcome.

sub DoOtherRequest {
...
    } elsif ($action eq "node") {
      &DoIndex();
    + } elsif ($action eq 'lockbulk') {
    +  &PrintPageLockList();
    + } elsif ($action eq 'lockcheckedfiles') {
    +  &DoLockCheckedFiles();
...
}

sub GetAdminBar {
...
  $result .= " | " . &ScriptLink("action=editlinks", T("Edit/Rename pages"));
  + $result .= " | " . &ScriptLink("action=lockbulk", T('Lock/Unlock Bulk'));
...
}

+ sub PrintPageLockList { 
+  my ($pagename, @pagename); 
+  my (@results) = @_; 
+  my %hash; 
+
+  print &GetHeader('', T('Bulk Lock'), ''); 
+  print $q->start_form("post","$ScriptName",""); 
+  print "<input type='hidden' name='action' value='lockcheckedfiles'>"; 
+  print '<ol>'; 
+  foreach $pagename (&AllPagesList()) { 
+    @pagename = split (/\//,$pagename); 
+    print '<li>'; 
+    if (-f &GetLockedPageFile($pagename)) { 
+      print "<input type='checkbox' name='next' value='$pagename' checked='1'/>";
+      print "<input type='hidden' name='prev' value='$pagename'/>" ; 
+    } else { 
+      print "<input type='checkbox' name='next' value='$pagename'/>";
+    } 
+    for (1 .. $#pagename) {print ' .. ',} 
+    print &GetPageLink($pagename); 
+    }  
+  } 
+  print '<br>'; 
+  print $q->submit(T('DoIt')) if (&UserIsAdmin()); 
+  print $q->endform; 
+  print '</ol>'; 
+  print &GetCommonFooter(); 
+ } 
+
+ sub DoLockCheckedFiles { 
  my (%vars, %count, @next, @prev, @diffs); 
+ my $fname; 
+  my $diffs; 
+
+ print &GetHeader("", T('Lock Checked Files'), ""); 
+  return  if (!&UserIsAdminOrError()); 
+  %vars = $q->Vars;
+  # this array provides the list with check state (for submit)
+  @next = split(/\0/,$vars{'next'}, -1);
+  # this array provides items in lock status (before submit)
+  @prev = split(/\0/,$srav{'prev'}, -1);
+  # not-commons elements (changes to submit: check mark to uncheck or viceversa)
+  map $count{$_}++ , @next, @prev; 
+  $, = ""; 
+  push (@diffs, grep $count{$_} == 1, @next, @prev); 
+  if (@diffs) { 
+    foreach (@diffs) { 
+      $fname = &GetLockedPageFile($_); 
+      if (-f $fname) { 
+        unlink $fname; 
+        print Ts('%s is unlocked successfully', $_) . '<br>'; 
+        next; 
+      } 
+      if (!-f $fname)  { 
+        &WriteStringToFile($fname, "editing locked."); 
+        print Ts('%s is locked successfully', $_) . '<br>'; 
+      } 
+    } 
+  } else { 
+    print T('Invalid URL or bulk does not exist --nothing done'); 
+  } 
+  print &GetCommonFooter(); 
+ }
--JuanmaMP

UseModWiki | WikiPatches | RecentChanges | Preferences
Edit text of this page | View other revisions | Search MetaWiki
Last edited May 14, 2012 9:05 pm by JuanmaMP (diff)
Search: