From 9f40c69ca062be39abecc06870824332da558c25 Mon Sep 17 00:00:00 2001 From: brain Date: Fri, 30 Apr 2004 14:40:20 +0000 Subject: Added oper classes and types (done through the planned privilage system on a per-command basis) git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@756 e03df62e-2008-0410-955e-edbf42e46eb7 --- src/users.cpp | 62 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 61 insertions(+), 1 deletion(-) (limited to 'src/users.cpp') diff --git a/src/users.cpp b/src/users.cpp index 6fb0e6a5c..b523033ba 100644 --- a/src/users.cpp +++ b/src/users.cpp @@ -1,5 +1,5 @@ /* - +Manages userrec objects */ #include "inspircd_config.h" @@ -8,6 +8,8 @@ #include "inspircd.h" #include +extern std::stringstream config_f; + userrec::userrec() { // the PROPER way to do it, AVOID bzero at *ALL* costs @@ -91,3 +93,61 @@ void userrec::RemoveInvite(char* channel) } } } + +bool userrec::HasPermission(char* command) +{ + char TypeName[MAXBUF],Classes[MAXBUF],ClassName[MAXBUF],CommandList[MAXBUF]; + char* myclass; + char* mycmd; + char* savept; + char* savept2; + + // are they even an oper at all? + if (strchr(this->modes,'o')) + { + log(DEBUG,"*** HasPermission: %s is an oper",this->nick); + for (int j =0; j < ConfValueEnum("type",&config_f); j++) + { + ConfValue("type","name",j,TypeName,&config_f); + if (!strcmp(TypeName,this->oper)) + { + log(DEBUG,"*** HasPermission: %s is an oper of type '%s'",this->nick,this->oper); + ConfValue("type","classes",j,Classes,&config_f); + char* myclass = strtok_r(Classes," ",&savept); + //myclass = savept; + while (myclass) + { + log(DEBUG,"*** HasPermission: checking classtype '%s'",myclass); + for (int k =0; k < ConfValueEnum("class",&config_f); k++) + { + ConfValue("class","name",k,ClassName,&config_f); + if (!strcmp(ClassName,myclass)) + { + ConfValue("class","commands",k,CommandList,&config_f); + log(DEBUG,"*** HasPermission: found class named %s with commands: '%s'",ClassName,CommandList); + + + mycmd = strtok_r(CommandList," ",&savept2); + //mycmd = savept2; + while (mycmd) + { + if (!strcasecmp(mycmd,command)) + { + log(DEBUG,"*** Command %s found, returning true",command); + return true; + } + mycmd = strtok_r(NULL," ",&savept2); + //mycmd = savept2; + } + } + } + myclass = strtok_r(NULL," ",&savept); + //myclass = savept; + } + } + } + } + return false; +} + + -- cgit v1.3.1-10-gc9f91