Add MYACCESS command; fix reference count bug in MOVE
authorEntrope <entrope@clan-dk.org>
Tue, 2 Mar 2004 18:21:59 +0000 (18:21 +0000)
committerEntrope <entrope@clan-dk.org>
Tue, 2 Mar 2004 18:21:59 +0000 (18:21 +0000)
* Always LockChannel(target) when moving a registered channel.

* Move the self-access list function from ACCESS to MYACCESS, so that
ACCESS can be marked with MODCMD_REQUIRE_CHANUSER.

* Update documentation for MYACCESS vs ACCESS.
git-archimport-id: srvx@srvx.net--2004-srvx/srvx--devo--1.3--patch-21

src/chanserv.c
src/chanserv.help

index 365d000e91d845b21fca08a6b86d9f74ab4318ce..f7ee36a1234f0e257bb3c67715090ced3d5ae097 100644 (file)
@@ -337,8 +337,8 @@ static const struct message_entry msgtab[] = {
 
 /* Access information */
     { "CSMSG_IS_CHANSERV", "$b$C$b is the $bchannel service bot$b." },
-    { "CSMSG_ACCESS_SELF_ONLY", "You may only see the list of infolines for yourself (by using $b%s$b with no arguments)." },
-    { "CSMSG_SQUAT_ACCESS", "You do not have access to any channels." },
+    { "CSMSG_MYACCESS_SELF_ONLY", "You may only see the list of infolines for yourself (by using $b%s$b with no arguments)." },
+    { "CSMSG_SQUAT_ACCESS", "$b%s$b does not have access to any channels." },
     { "CSMSG_INFOLINE_LIST", "Showing all channel entries for account $b%s$b:" },
     { "CSMSG_USER_NO_ACCESS", "%s lacks access to %s." },
     { "CSMSG_USER_HAS_ACCESS", "%s has access $b%d$b in %s." },
@@ -1863,7 +1863,6 @@ static CHANSERV_FUNC(cmd_move)
     if(!(target = GetChannel(argv[1])))
     {
         target = AddChannel(argv[1], now, NULL, NULL);
-        LockChannel(target);
         if(!IsSuspended(channel->channel_info))
             AddChannelUser(chanserv, target);
     }
@@ -1905,6 +1904,7 @@ static CHANSERV_FUNC(cmd_move)
        DelChannelUser(chanserv, channel, reason2, 0);
     }
     UnlockChannel(channel);
+    LockChannel(target);
     global_message(MESSAGE_RECIPIENT_OPERS | MESSAGE_RECIPIENT_HELPERS, reason);
     return 1;
 }
@@ -3133,61 +3133,57 @@ static CHANSERV_FUNC(cmd_open)
     return 1;
 }
 
-static CHANSERV_FUNC(cmd_access)
+static CHANSERV_FUNC(cmd_myaccess)
 {
-    struct userNode *target;
     struct handle_info *target_handle;
     struct userData *uData;
-    int helping;
-    char prefix[MAXLEN];
+    const char *chanName;
 
-    if(!channel)
+    if(argc < 2)
+        target_handle = user->handle_info;
+    else if(!IsHelping(user))
     {
-        struct userData *uData;
-        const char *chanName;
-        int hide = 0;
+        reply("CSMSG_MYACCESS_SELF_ONLY", argv[0]);
+        return 0;
+    }
+    else if(!(target_handle = modcmd_get_handle_info(user, argv[1])))
+        return 0;
 
-        target_handle = user->handle_info;
-        if(!target_handle)
-        {
-            reply("MSG_AUTHENTICATE");
-            return 0;
-        }
-        if(argc > 1)
-        {
-            if(!IsHelping(user))
-            {
-                reply("CSMSG_ACCESS_SELF_ONLY", argv[0]);
-                return 0;
-            }
+    if(!target_handle->channels)
+    {
+        reply("CSMSG_SQUAT_ACCESS", target_handle->handle);
+        return 1;
+    }
 
-            if(!(target_handle = modcmd_get_handle_info(user, argv[1])))
-                return 0;
-            hide = 1;
-        }
-        if(!target_handle->channels)
-        {
-            reply("CSMSG_SQUAT_ACCESS");
-            return 1;
-        }
-        reply("CSMSG_INFOLINE_LIST", target_handle->handle);
-        for(uData = target_handle->channels; uData; uData = uData->u_next)
-        {
-            struct chanData *cData = uData->channel;
+    reply("CSMSG_INFOLINE_LIST", target_handle->handle);
+    for(uData = target_handle->channels; uData; uData = uData->u_next)
+    {
+        struct chanData *cData = uData->channel;
 
-            if(uData->access > UL_OWNER)
-                continue;
-            if(IsProtected(cData) && hide && !GetTrueChannelAccess(cData, user->handle_info))
-                continue;
-            chanName = cData->channel->name;
-            if(uData->info)
-                send_message_type(4, user, cmd->parent->bot, "[%s (%d)] %s", chanName, uData->access, uData->info);
-            else
-                send_message_type(4, user, cmd->parent->bot, "[%s (%d)]", chanName, uData->access);
-        }
-        return 1;
+        if(uData->access > UL_OWNER)
+            continue;
+        if(IsProtected(cData)
+           && (target_handle != user->handle_info)
+           && !GetTrueChannelAccess(cData, user->handle_info))
+            continue;
+        chanName = cData->channel->name;
+        if(uData->info)
+            send_message_type(4, user, cmd->parent->bot, "[%s (%d)] %s", chanName, uData->access, uData->info);
+        else
+            send_message_type(4, user, cmd->parent->bot, "[%s (%d)]", chanName, uData->access);
     }
 
+    return 1;
+}
+
+static CHANSERV_FUNC(cmd_access)
+{
+    struct userNode *target;
+    struct handle_info *target_handle;
+    struct userData *uData;
+    int helping;
+    char prefix[MAXLEN];
+
     if(argc < 2)
     {
        target = user;
@@ -7075,7 +7071,8 @@ init_chanserv(const char *nick)
     DEFINE_COMMAND(bans, 1, MODCMD_REQUIRE_REGCHAN, "access", "1", "flags", "+nolog", NULL);
     DEFINE_COMMAND(peek, 1, MODCMD_REQUIRE_REGCHAN, "access", "op", "flags", "+nolog", NULL);
 
-    DEFINE_COMMAND(access, 1, 0, "flags", "+nolog,+acceptchan", NULL);
+    DEFINE_COMMAND(myaccess, 1, MODCMD_REQUIRE_AUTHED, NULL);
+    DEFINE_COMMAND(access, 1, MODCMD_REQUIRE_REGCHAN, "flags", "+nolog,+joinable", NULL);
     DEFINE_COMMAND(users, 1, MODCMD_REQUIRE_REGCHAN, "flags", "+nolog,+joinable", NULL);
     DEFINE_COMMAND(wlist, 1, MODCMD_REQUIRE_REGCHAN, "flags", "+nolog,+joinable", NULL);
     DEFINE_COMMAND(clist, 1, MODCMD_REQUIRE_REGCHAN, "flags", "+nolog,+joinable", NULL);
index 803930a6e946517225a925017ef7a8962ca28d29..574f39da408db0316f1510ae5806f51af1fbccb2 100644 (file)
@@ -8,7 +8,8 @@
         "  OPER            Helper/Operator commands."
 );
 "USER" ("$bUser commands:$b",
-        "  ACCESS      Check your own or another person's access to a channel.",
+        "  ACCESS      Check someone's access in a channel.",
+        "  MYACCESS    Show all channels where you have access.",
         "  ADDCOOWNER  Give another person coowner status in a channel.",
         "  ADDMASTER                       master status in a channel.",
         "  ADDOP                           op status in a channel.",
         "  CREATENOTE  Create a new note type.",
         "  REMOVENOTE  Remove an existing note type."
 );
-"ACCESS" ("/msg $C ACCESS <#channel> <nick|*account>",
-        "Reports various pieces of information about a channel user, including channel and network access level, and the user's info line. If no nick or account is provided, $C returns your own information.",
-        "If no channel is provided, $C lists your infolines in all registered channels.",
-        "$uSee Also:$u users");
+"MYACCESS" ("/msg $S MYACCESS [<nick|*account>]",
+        "Lists channels where you have access and infolines in each.",
+        "Network staff may specify a nickname or *account to view the list for another user.",
+        "$uSee Also:$u access, users");
+"ACCESS" ("/msg $S ACCESS <#channel> [<nick|*account>]",
+        "Reports various pieces of information about a channel user, including channel and network access level, and the user's info line. If no nick or account is provided, $S returns your own information.",
+        "$uSee Also:$u myaccess, users");
 "ADDBAN" ("/msg $C ADDBAN <#channel> <mask|nick> [Reason]",
         "Adds a ban to the channels permanent ban list, remaining in effect until removed with the DELBAN command. If it exactly matches an existing ban already in the list, the reason will be updated. If the existing ban was a timed ban, it will be extended into a permanent ban.",
         "$uSee Also:$u bans, delban, mdelban");