/***************************************************************************************/
/* Anope Module : os_global.c : v1.1                                                   */  
/* Trystan Scott Lee                                                                   */
/* trystan@nomadirc.net                                                                */ 
/*                                                                                     */
/* Anope (c) 2000-2002 Anope.org                                                       */
/*                                                                                     */ 
/* This program is free software; you can redistribute it and/or modify it under the   */
/* terms of the GNU General Public License as published by the Free Software           */
/* Foundation; either version 1, or (at your option) any later version.                */
/*                                                                                     */
/*  This program is distributed in the hope that it will be useful, but WITHOUT ANY    */
/*  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A    */
/*  PARTICULAR PURPOSE.  See the GNU General Public License for more details.          */
/*                                                                                     */
/***************************************************************************************/

#include "module.h"
#define AUTHOR "Trystan"
#define VERSION "1.1"

int GLOBAL_ACCESS = 2;   /* 1 = Service Opers, 2 = Service Admins, 3 = Service Roots  */

int m_do_global(User * u);                        /* OperServ Command function           */

int AnopeInit(int argc, char **argv) 
{
 	Command *c;
	c = createCommand("global",m_do_global,NULL,-1,-1,-1,-1,-1);
        moduleAddCommand(OPERSERV,c,MOD_HEAD);

        moduleAddAuthor(AUTHOR);
        moduleAddVersion(VERSION);
	return MOD_CONT;
}

void AnopeFini(void) {
  alog("Unloading os_global.so");
}

int m_do_global(User * u)
{
 int is_sop = is_services_oper(u);
 int is_sa  = is_services_admin(u);
 int is_sr  = is_services_root(u);

 if (GLOBAL_ACCESS == 1 && is_sop) {
  return MOD_CONT;
 }
 if (GLOBAL_ACCESS == 2 && is_sa) {
  return MOD_CONT;
 }
 if (GLOBAL_ACCESS == 3 && is_sr) {
  return MOD_CONT;
 }
 notice_lang(s_OperServ, u, PERMISSION_DENIED);
 return MOD_STOP;
}

