Author: Kev <klmitch@mit.edu>
[ircu2.10.12-pk.git] / ircd / m_clearmode.c
index ef2e10bb1891d494b14e54d0e3dc1f38e7cce77f..cbd961f88ce6629e0b81b649d0e71776c12e6055 100644 (file)
  *            note:   it is guaranteed that parv[0]..parv[parc-1] are all
  *                    non-NULL pointers.
  */
-#if 0
-/*
- * No need to include handlers.h here the signatures must match
- * and we don't need to force a rebuild of all the handlers everytime
- * we add a new one to the list. --Bleep
- */
-#include "handlers.h"
-#endif /* 0 */
+#include "config.h"
+
 #include "client.h"
 #include "channel.h"
 #include "hash.h"
 #include "ircd.h"
 #include "ircd_alloc.h"
+#include "ircd_features.h"
+#include "ircd_log.h"
 #include "ircd_reply.h"
 #include "ircd_string.h"
 #include "list.h"
@@ -224,12 +220,6 @@ do_clearmode(struct Client *cptr, struct Client *sptr, struct Channel *chptr,
   if (del_mode & MODE_KEY)
     chptr->mode.key[0] = '\0';
 
-#ifndef OPATH
-  /* Don't propagate CLEARMODE if it's a local channel */
-  if (IsLocalChannel(chptr->chname))
-    return 0;
-#endif
-
   /* Ok, build control string again */
   for (flag_p = flags; flag_p[0]; flag_p += 2)
     if (del_mode & flag_p[0])
@@ -237,10 +227,9 @@ do_clearmode(struct Client *cptr, struct Client *sptr, struct Channel *chptr,
 
   control_buf[control_buf_i] = '\0';
 
-#ifdef OPATH
-  write_log(OPATH, "%Tu %#C CLEARMODE %H %s\n", TStime(), sptr, chptr,
-           control_buf);
-#endif
+  /* Log it... */
+  log_write(LS_OPERMODE, L_INFO, LOG_NOSNOTICE, "%#C CLEARMODE %H %s", sptr,
+           chptr, control_buf);
 
   /* Then send it */
   if (!IsLocalChannel(chptr->chname))
@@ -287,12 +276,12 @@ ms_clearmode(struct Client* cptr, struct Client* sptr, int parc, char* parv[])
 int
 mo_clearmode(struct Client* cptr, struct Client* sptr, int parc, char* parv[])
 {
-#ifndef CONFIG_OPERCMDS
-  return send_reply(sptr, ERR_DISABLED, "CLEARMODE");
-#else
   struct Channel *chptr;
   char *control = "ovpsmikbl"; /* default control string */
 
+  if (!feature_bool(FEAT_CONFIG_OPERCMDS))
+    return send_reply(sptr, ERR_DISABLED, "CLEARMODE");
+
   if (parc < 2)
     return need_more_params(sptr, "CLEARMODE");
 
@@ -301,12 +290,12 @@ mo_clearmode(struct Client* cptr, struct Client* sptr, int parc, char* parv[])
 
   clean_channelname(parv[1]);
 
-  if (!IsOper(sptr) && !IsLocalChannel(parv[1]))
+  if (!HasPriv(sptr,
+              IsLocalChannel(parv[1]) ? PRIV_LOCAL_OPMODE : PRIV_OPMODE))
     return send_reply(sptr, ERR_NOPRIVILEGES);
 
-  if (!IsChannelName(parv[1]) || !(chptr = FindChannel(parv[1])))
+  if (('#' != *parv[1] && '&' != *parv[1]) || !(chptr = FindChannel(parv[1])))
     return send_reply(sptr, ERR_NOSUCHCHANNEL, parv[1]);
 
   return do_clearmode(cptr, sptr, chptr, control);
-#endif /* CONFIG_OPERCMDS */
 }