#define SM_ERR_NOPRIVS 0x00000400
#define SM_ERR_RPL_Q 0x00000800
#define SM_ERR_RPL_F 0x00001000
+#define SM_ERR_MLOCK 0x00002000
#define MAXMODES_SIMPLE 46 /* a-zA-Z except bqeIov */
int chmode_flags[256];
+extern int h_get_channel_access;
+
/* OPTIMIZE ME! -- dwr */
void
construct_cflags_strings(void)
construct_cflags_strings();
}
-static int
+int
get_channel_access(struct Client *source_p, struct membership *msptr)
{
- if(!MyClient(source_p) || is_chanop(msptr))
+ hook_data_channel_approval moduledata;
+
+ if(!MyClient(source_p))
return CHFL_CHANOP;
- return CHFL_PEON;
+ if (msptr == NULL)
+ return CHFL_PEON;
+
+ moduledata.client = source_p;
+ moduledata.chptr = msptr->chptr;
+ moduledata.msptr = msptr;
+ moduledata.target = NULL;
+ moduledata.approved = is_chanop(msptr) ? CHFL_CHANOP : CHFL_PEON;
+
+ call_hook(h_get_channel_access, &moduledata);
+
+ return moduledata.approved;
}
/* add_id()
if(dir == MODE_ADD)
{
- if(targ_p == source_p)
+ if(targ_p == source_p && mstptr->flags & CHFL_CHANOP)
return;
mode_changes[mode_count].letter = c;
}
}
-void
-chm_regonly(struct Client *source_p, struct Channel *chptr,
- int alevel, int parc, int *parn,
- const char **parv, int *errors, int dir, char c, long mode_type)
-{
- if(alevel != CHFL_CHANOP)
- {
- if(!(*errors & SM_ERR_NOOPS))
- sendto_one(source_p, form_str(ERR_CHANOPRIVSNEEDED),
- me.name, source_p->name, chptr->chname);
- *errors |= SM_ERR_NOOPS;
- return;
- }
-
- if(dir == MODE_QUERY)
- return;
-
- if(((dir == MODE_ADD) && (chptr->mode.mode & mode_type)) ||
- ((dir == MODE_DEL) && !(chptr->mode.mode & mode_type)))
- return;
-
- if(MyClient(source_p) && (++mode_limit_simple > MAXMODES_SIMPLE))
- return;
-
- if(dir == MODE_ADD)
- chptr->mode.mode |= mode_type;
- else
- chptr->mode.mode &= ~mode_type;
-
- mode_changes[mode_count].letter = c;
- mode_changes[mode_count].dir = dir;
- mode_changes[mode_count].caps = CAP_SERVICE;
- mode_changes[mode_count].nocaps = 0;
- mode_changes[mode_count].mems = ALL_MEMBERS;
- mode_changes[mode_count].id = NULL;
- mode_changes[mode_count++].arg = NULL;
-}
-
/* *INDENT-OFF* */
struct ChannelMode chmode_table[256] =
{
{chm_op, 0 }, /* o */
{chm_simple, MODE_PRIVATE }, /* p */
{chm_ban, CHFL_QUIET }, /* q */
- {chm_regonly, MODE_REGONLY }, /* r */
+ {chm_simple, MODE_REGONLY }, /* r */
{chm_simple, MODE_SECRET }, /* s */
{chm_simple, MODE_TOPICLIMIT }, /* t */
{chm_nosuch, 0 }, /* u */
/* If this mode char is locked, don't allow local users to change it. */
if (MyClient(source_p) && chptr->mode_lock && strchr(chptr->mode_lock, c))
{
- sendto_one_numeric(source_p, ERR_MLOCKRESTRICTED, form_str(ERR_MLOCKRESTRICTED), chptr->name, c, chptr->mode_lock);
+ if (!(errors & SM_ERR_MLOCK))
+ sendto_one_numeric(source_p,
+ ERR_MLOCKRESTRICTED,
+ form_str(ERR_MLOCKRESTRICTED),
+ chptr->chname,
+ c,
+ chptr->mode_lock);
+ errors |= SM_ERR_MLOCK;
continue;
}
chmode_table[(unsigned char) c].set_func(fakesource_p, chptr, alevel,
*/
void
set_channel_mlock(struct Client *client_p, struct Client *source_p,
- struct Channel *chptr, const char *newmlock)
+ struct Channel *chptr, const char *newmlock, int propagate)
{
rb_free(chptr->mode_lock);
chptr->mode_lock = newmlock ? rb_strdup(newmlock) : NULL;
- sendto_server(client_p, NULL, CAP_TS6 | CAP_MLOCK, NOCAPS, ":%s MLOCK %ld %s :%s",
- source_p->id, (long) chptr->channelts, chptr->chname,
- chptr->mode_lock ? chptr->mode_lock : "");
+ if (propagate)
+ {
+ sendto_server(client_p, NULL, CAP_TS6 | CAP_MLOCK, NOCAPS, ":%s MLOCK %ld %s :%s",
+ source_p->id, (long) chptr->channelts, chptr->chname,
+ chptr->mode_lock ? chptr->mode_lock : "");
+ }
}