split citadel protocol related functions from msgbase.c into ctdl_message.c; fix...
[citadel.git] / citadel / user_ops.c
index f7cb7493870456c61d6eed7434531ce9849e5b35..eb91dcdac0980951ebaafb165872773be47d20bb 100644 (file)
@@ -61,6 +61,7 @@
 #include "context.h"
 #include "ctdl_module.h"
 #include "user_ops.h"
+#include "internet_addressing.h"
 
 /* These pipes are used to talk to the chkpwd daemon, which is forked during startup */
 int chkpwd_write_pipe[2];
@@ -369,7 +370,30 @@ void MailboxName(char *buf, size_t n, const struct ctdluser *who, const char *pr
 
 
 /*
- * Is the user currently logged in an Aide?
+ * Check to see if the specified user has Internet mail permission
+ * (returns nonzero if permission is granted)
+ */
+int CtdlCheckInternetMailPermission(struct ctdluser *who) {
+
+       /* Do not allow twits to send Internet mail */
+       if (who->axlevel <= AxProbU) return(0);
+
+       /* Globally enabled? */
+       if (config.c_restrict == 0) return(1);
+
+       /* User flagged ok? */
+       if (who->flags & US_INTERNET) return(2);
+
+       /* Admin level access? */
+       if (who->axlevel >= AxAideU) return(3);
+
+       /* No mail for you! */
+       return(0);
+}
+
+
+/*
+ * Is the user currently logged in an Admin?
  */
 int is_aide(void)
 {
@@ -381,7 +405,7 @@ int is_aide(void)
 
 
 /*
- * Is the user currently logged in an Aide *or* the room aide for this room?
+ * Is the user currently logged in an Admin *or* the room Admin for this room?
  */
 int is_room_aide(void)
 {
@@ -1589,7 +1613,7 @@ int CtdlInvtKick(char *iuser, int op) {
 void cmd_invt_kick(char *iuser, int op) {
 
        /*
-        * These commands are only allowed by aides, room aides,
+        * These commands are only allowed by admins, room admins,
         * and room namespace owners
         */
        if (is_room_aide()) {
@@ -1632,7 +1656,7 @@ void cmd_kick(char *iuser) {cmd_invt_kick(iuser, 0);}
 int CtdlForgetThisRoom(void) {
        visit vbuf;
 
-       /* On some systems, Aides are not allowed to forget rooms */
+       /* On some systems, Admins are not allowed to forget rooms */
        if (is_aide() && (config.c_aide_zap == 0)
           && ((CC->room.QRflags & QR_MAILBOX) == 0)  ) {
                return(1);