using System;
using System.Collections.Generic;
namespace Swarmops.Common.Enums
{
///
/// RoleTypes.
/// Important that the number corresponds
/// to RoleTypeId in database since roles are stored referencing
/// id rather than name.
/// Add new roles at the end, and create corresponding record in db.
///
public enum RoleType
{
///
/// Undefined
///
Unknown = 0,
///
/// The primary contact for a geographical node in an organization
///
LocalLead = 1,
///
/// The secondary contact for a geographical node in an organization
///
LocalDeputy = 2,
///
/// OBSOLETE - DO NOT USE
///
LocalActive = 3,
///
/// Non-public role - full access to organization's node
///
LocalAdmin = 4,
///
/// Public role - PoC for org and can perform any task on the org in the system
///
OrganizationChairman = 5,
///
/// Treasurers in an org can approve and manage expenses
///
OrganizationTreasurer = 6,
///
/// Public role - for display / PoC purposes only
///
OrganizationBoardMember = 7,
///
/// Public role - for display / PoC purposes only
///
OrganizationSecretary = 8,
///
/// Non-public role for people who do administrative work
///
OrganizationAdmin = 9,
///
/// Non-public role - full access to entire PirateWeb
///
SystemAdmin = 10,
///
/// Non-public role - editor of the geography tree (at a certain geo and below)
///
SystemGeographyEditor = 11,
///
/// Non-public role - a member/nonmember who has full access to the organization
///
OrganizationAuditor = 12,
///
/// A deputy board member of an org
///
OrganizationBoardDeputy = 13,
///
/// First vice chairman
///
OrganizationVice1 = 14,
///
/// Second vice chairman
///
OrganizationVice2 = 15,
///
/// This Role is assigned to Memberservice administrators
///
OrganizationMemberService = 17,
///
/// This Role is assigned to Memberservice administrators, extra permissions
///
OrganizationMemberServiceLead = 18,
///
/// Role assigned to elected representatives, mostly for admin purposes. No intrinsic rights.
///
OrganizationElectedRepresentative = 19,
///
/// A role that everybody has, although it is not set in the database on every person.
/// Letters may be sent to people in this role, in which case they are private. No intrinsic rights.
///
PrivateIndividual = 20,
///
/// A person who can upload paper documents, like letters/invoices, but not access members.
///
OrganizationClerk = 21,
///
/// A person who can see and manage all of the economy, but not member registry.
///
OrganizationEconomyAssistant = 22,
///
/// An elected meeting official, to be assigned temporarily during a meeting
///
OrganizationMeetingOfficial = 23,
///
/// The board's secretary. Not the same as the org's secretary.
///
OrganizationBoardSecretary = 24,
///
/// Role for non officers helping with ballot distribution etc
///
LocalElectionSupport = 25,
///
/// Temporary - Jörgen added this; the whole enum is deprecated anyway; added for compatibility with v4
///
OrganizationMailSender
}
public enum RoleClass
{
///
/// Undefined
///
Undefined = 0,
///
/// System-wide privileges and responsibilities
///
System,
///
/// Roles for an entire organization
///
Organization,
///
/// Roles and responsibilities to a node in an organization
///
Local,
///
/// Roles that are org-agnostic but are tied to a geo node
///
Geographic
}
public class RoleTypes
{
public static readonly RoleType[] AllLocalRoleTypes =
{
RoleType.LocalLead,
RoleType.LocalDeputy,
RoleType.LocalActive,
RoleType.LocalAdmin,
RoleType.LocalElectionSupport
};
public static readonly RoleType[] AllOrganizationalRoleTypes =
{
RoleType.OrganizationChairman,
RoleType.OrganizationVice1,
RoleType.OrganizationVice2,
RoleType.OrganizationTreasurer,
RoleType.OrganizationSecretary,
RoleType.OrganizationBoardMember,
RoleType.OrganizationBoardDeputy,
RoleType.OrganizationAdmin,
RoleType.OrganizationClerk,
RoleType.OrganizationAuditor,
RoleType.OrganizationMemberService,
RoleType.OrganizationMemberServiceLead,
RoleType.OrganizationElectedRepresentative,
RoleType.OrganizationEconomyAssistant,
RoleType.OrganizationMeetingOfficial,
RoleType.OrganizationBoardSecretary
};
public static readonly RoleType[] AllSystemRoleTypes =
{
RoleType.SystemAdmin,
RoleType.SystemGeographyEditor
};
public static readonly RoleType[] AllRoleTypes = CreateAllRoleTypes();
private static RoleType[] CreateAllRoleTypes()
{
List retList = new List();
retList.AddRange (AllOrganizationalRoleTypes);
retList.AddRange (AllSystemRoleTypes);
retList.AddRange (AllLocalRoleTypes);
foreach (RoleType rt in Enum.GetValues (typeof (RoleType)))
{
if (!retList.Contains (rt))
retList.Add (rt);
}
return retList.ToArray();
}
public static RoleClass ClassOfRole (RoleType r)
{
if (Array.IndexOf (AllLocalRoleTypes, r) > -1)
return RoleClass.Local;
if (Array.IndexOf (AllOrganizationalRoleTypes, r) > -1)
return RoleClass.Organization;
if (Array.IndexOf (AllSystemRoleTypes, r) > -1)
return RoleClass.System;
return RoleClass.Undefined;
}
}
}