-/* +------------------------------------+
- * | Inspire Internet Relay Chat Daemon |
- * +------------------------------------+
+/* +------------------------------------+
+ * | Inspire Internet Relay Chat Daemon |
+ * +------------------------------------+
*
- * InspIRCd is copyright (C) 2002-2006 ChatSpike-Dev.
- * E-mail:
- *<brain@chatspike.net>
- *<Craig@chatspike.net>
+ * InspIRCd: (C) 2002-2007 InspIRCd Development Team
+ * See: http://www.inspircd.org/wiki/index.php/Credits
*
- * Written by Craig Edwards, Craig McLure, and others.
* This program is free but copyrighted software; see
- *the file COPYING for details.
+ * the file COPYING for details.
*
* ---------------------------------------------------
*/
/* get the last 'visible' chan of a user */
static char *getlastchanname(userrec *u)
{
- for (std::vector<ucrec*>::const_iterator v = u->chans.begin(); v != u->chans.end(); v++)
+ UCListIter i = u->chans.begin();
+ if (i != u->chans.end())
{
- ucrec* temp = (ucrec*)*v;
-
- if (temp->channel)
- {
- if (!temp->channel->IsModeSet('s'))
- return temp->channel->name;
- }
+ if (!i->first->IsModeSet('s'))
+ return i->first->name;
}
return "*";
return new cmd_who(Instance);
}
+bool cmd_who::CanView(chanrec* chan, userrec* user)
+{
+ if (!user || !chan)
+ return false;
+
+ /* Execute items in fastest-to-execute first order */
+ if (*user->oper)
+ return true;
+ else if (!chan->IsModeSet('s') && !chan->IsModeSet('p'))
+ return true;
+ else if (chan->HasUser(user))
+ return true;
+
+ return false;
+}
+
CmdResult cmd_who::Handle (const char** parameters, int pcnt, userrec *user)
{
/*
/* who on a channel? */
ch = ServerInstance->FindChan(matchtext);
- if (ch)
+ if ((ch) && (CanView(ch,user)))
{
/* who on a channel. */
CUList *cu = ch->GetUsers();