Index: trunk/tools/wmib/Core.cs |
— | — | @@ -290,12 +290,12 @@ |
291 | 291 | { |
292 | 292 | if (u.name == user) |
293 | 293 | { |
294 | | - if (getLevel("admin") > getLevel(trusted.level)) |
| 294 | + if (getLevel(u.level) > getLevel(trusted.level)) |
295 | 295 | { |
296 | 296 | Message("This user has higher level than you, sorry", _Channel); |
297 | 297 | return true; |
298 | 298 | } |
299 | | - if (u == trusted) |
| 299 | + if (u.name == trusted.name) |
300 | 300 | { |
301 | 301 | Message("You can't delete yourself from db", _Channel); |
302 | 302 | return true; |
— | — | @@ -317,14 +317,16 @@ |
318 | 318 | /// <returns>0</returns> |
319 | 319 | private int getLevel(string level) |
320 | 320 | { |
321 | | - if (level == "admin") |
| 321 | + switch (level) |
322 | 322 | { |
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; |
324 | 330 | } |
325 | | - if (level == "trusted") |
326 | | - { |
327 | | - return 2; |
328 | | - } |
329 | 331 | return 0; |
330 | 332 | } |
331 | 333 | |
— | — | @@ -385,6 +387,10 @@ |
386 | 388 | /// <returns></returns> |
387 | 389 | public bool matchLevel(int level, string rights) |
388 | 390 | { |
| 391 | + if (rights == "root") |
| 392 | + { |
| 393 | + return true; |
| 394 | + } |
389 | 395 | if (level == 2) |
390 | 396 | { |
391 | 397 | return (rights == "admin"); |
— | — | @@ -401,7 +407,7 @@ |
402 | 408 | /// </summary> |
403 | 409 | /// <param name="User">Username</param> |
404 | 410 | /// <param name="Host">Hostname</param> |
405 | | - /// <param name="command"></param> |
| 411 | + /// <param name="command">Approved for specified object / request</param> |
406 | 412 | /// <returns></returns> |
407 | 413 | public bool isApproved(string User, string Host, string command) |
408 | 414 | { |
— | — | @@ -418,8 +424,11 @@ |
419 | 425 | case "info": |
420 | 426 | case "trustadd": |
421 | 427 | case "trustdel": |
| 428 | + case "recentchanges": |
422 | 429 | return matchLevel(1, current.level); |
423 | 430 | case "admin": |
| 431 | + case "infobot-manage": |
| 432 | + case "recentchanges-manage": |
424 | 433 | case "shutdown": |
425 | 434 | return matchLevel(2, current.level); |
426 | 435 | } |
— | — | @@ -757,12 +766,16 @@ |
758 | 767 | } |
759 | 768 | catch (Exception) |
760 | 769 | { } |
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 |
764 | 771 | { |
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 | + } |
766 | 778 | } |
| 779 | + catch (Exception) { } |
767 | 780 | config.channels.Remove(chan); |
768 | 781 | config.Save(); |
769 | 782 | return; |
— | — | @@ -795,10 +808,10 @@ |
796 | 809 | /// <summary> |
797 | 810 | /// Display admin command |
798 | 811 | /// </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> |
803 | 816 | public static void admin(config.channel chan, string user, string host, string message) |
804 | 817 | { |
805 | 818 | if (message == "@reload") |
— | — | @@ -831,7 +844,7 @@ |
832 | 845 | |
833 | 846 | if (message == "@recentchanges-on") |
834 | 847 | { |
835 | | - if (chan.Users.isApproved(user, host, "admin")) |
| 848 | + if (chan.Users.isApproved(user, host, "recentchanges-manage")) |
836 | 849 | { |
837 | 850 | if (chan.feed) |
838 | 851 | { |
— | — | @@ -853,7 +866,7 @@ |
854 | 867 | |
855 | 868 | if (message.StartsWith("@recentchanges+")) |
856 | 869 | { |
857 | | - if (chan.Users.isApproved(user, host, "admin")) |
| 870 | + if (chan.Users.isApproved(user, host, "recentchanges-manage")) |
858 | 871 | { |
859 | 872 | if (chan.feed) |
860 | 873 | { |
— | — | @@ -1211,10 +1224,10 @@ |
1212 | 1225 | case "recentchanges+": |
1213 | 1226 | showInfo("recentchanges+", "Insert a wiki to feed, example @recentchanges+ en_wikipedia", channel); |
1214 | 1227 | return false; |
1215 | | - case "RC-": |
| 1228 | + case "rc-": |
1216 | 1229 | showInfo("RC-", "Remove a page from rc list", channel); |
1217 | 1230 | return false; |
1218 | | - case "RC+": |
| 1231 | + case "rc+": |
1219 | 1232 | showInfo("RC+", "Create entry for feed of specified page, example @RC+ wiki page", channel); |
1220 | 1233 | return false; |
1221 | 1234 | } |
— | — | @@ -1397,16 +1410,3 @@ |
1398 | 1411 | } |
1399 | 1412 | } |
1400 | 1413 | } |
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 | | -} |