r107592 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r107591‎ | r107592 | r107593 >
Date:19:41, 29 December 2011
Author:petrb
Status:deferred
Tags:
Comment:
Fixed crash when dropping access db
Modified paths:
  • /trunk/tools/wmib/Core.cs (modified) (history)

Diff [purge]

Index: trunk/tools/wmib/Core.cs
@@ -290,12 +290,12 @@
291291 {
292292 if (u.name == user)
293293 {
294 - if (getLevel("admin") > getLevel(trusted.level))
 294+ if (getLevel(u.level) > getLevel(trusted.level))
295295 {
296296 Message("This user has higher level than you, sorry", _Channel);
297297 return true;
298298 }
299 - if (u == trusted)
 299+ if (u.name == trusted.name)
300300 {
301301 Message("You can't delete yourself from db", _Channel);
302302 return true;
@@ -317,14 +317,16 @@
318318 /// <returns>0</returns>
319319 private int getLevel(string level)
320320 {
321 - if (level == "admin")
 321+ switch (level)
322322 {
323 - return 10;
 323+ // root is special only for global admins etc
 324+ case "root":
 325+ return 65534;
 326+ case "admin":
 327+ return 10;
 328+ case "trusted":
 329+ return 2;
324330 }
325 - if (level == "trusted")
326 - {
327 - return 2;
328 - }
329331 return 0;
330332 }
331333
@@ -385,6 +387,10 @@
386388 /// <returns></returns>
387389 public bool matchLevel(int level, string rights)
388390 {
 391+ if (rights == "root")
 392+ {
 393+ return true;
 394+ }
389395 if (level == 2)
390396 {
391397 return (rights == "admin");
@@ -401,7 +407,7 @@
402408 /// </summary>
403409 /// <param name="User">Username</param>
404410 /// <param name="Host">Hostname</param>
405 - /// <param name="command"></param>
 411+ /// <param name="command">Approved for specified object / request</param>
406412 /// <returns></returns>
407413 public bool isApproved(string User, string Host, string command)
408414 {
@@ -418,8 +424,11 @@
419425 case "info":
420426 case "trustadd":
421427 case "trustdel":
 428+ case "recentchanges":
422429 return matchLevel(1, current.level);
423430 case "admin":
 431+ case "infobot-manage":
 432+ case "recentchanges-manage":
424433 case "shutdown":
425434 return matchLevel(2, current.level);
426435 }
@@ -757,12 +766,16 @@
758767 }
759768 catch (Exception)
760769 { }
761 - File.Delete(variables.config + "/" + chan.name + ".setting");
762 - File.Delete(variables.config + "/" + chan.Users.File);
763 - if (File.Exists(variables.config + "/" + chan.name + ".list"))
 770+ try
764771 {
765 - File.Delete(variables.config + "/" + chan.name + ".list");
 772+ File.Delete(variables.config + "/" + chan.name + ".setting");
 773+ File.Delete(chan.Users.File);
 774+ if (File.Exists(variables.config + "/" + chan.name + ".list"))
 775+ {
 776+ File.Delete(variables.config + "/" + chan.name + ".list");
 777+ }
766778 }
 779+ catch (Exception) { }
767780 config.channels.Remove(chan);
768781 config.Save();
769782 return;
@@ -795,10 +808,10 @@
796809 /// <summary>
797810 /// Display admin command
798811 /// </summary>
799 - /// <param name="chan"></param>
800 - /// <param name="user"></param>
801 - /// <param name="host"></param>
802 - /// <param name="message"></param>
 812+ /// <param name="chan">Channel</param>
 813+ /// <param name="user">User name</param>
 814+ /// <param name="host">Host</param>
 815+ /// <param name="message">Message</param>
803816 public static void admin(config.channel chan, string user, string host, string message)
804817 {
805818 if (message == "@reload")
@@ -831,7 +844,7 @@
832845
833846 if (message == "@recentchanges-on")
834847 {
835 - if (chan.Users.isApproved(user, host, "admin"))
 848+ if (chan.Users.isApproved(user, host, "recentchanges-manage"))
836849 {
837850 if (chan.feed)
838851 {
@@ -853,7 +866,7 @@
854867
855868 if (message.StartsWith("@recentchanges+"))
856869 {
857 - if (chan.Users.isApproved(user, host, "admin"))
 870+ if (chan.Users.isApproved(user, host, "recentchanges-manage"))
858871 {
859872 if (chan.feed)
860873 {
@@ -1211,10 +1224,10 @@
12121225 case "recentchanges+":
12131226 showInfo("recentchanges+", "Insert a wiki to feed, example @recentchanges+ en_wikipedia", channel);
12141227 return false;
1215 - case "RC-":
 1228+ case "rc-":
12161229 showInfo("RC-", "Remove a page from rc list", channel);
12171230 return false;
1218 - case "RC+":
 1231+ case "rc+":
12191232 showInfo("RC+", "Create entry for feed of specified page, example @RC+ wiki page", channel);
12201233 return false;
12211234 }
@@ -1397,16 +1410,3 @@
13981411 }
13991412 }
14001413 }
1401 -on xx)
1402 - {
1403 - handleException(xx, channel);
1404 - }
1405 - }
1406 - }
1407 - public static int Disconnect()
1408 - {
1409 - wd.Flush();
1410 - return 0;
1411 - }
1412 - }
1413 -}

Status & tagging log