]> andersk Git - moira.git/commitdiff
update name if necessary
authormar <mar>
Wed, 10 Mar 1993 13:48:08 +0000 (13:48 +0000)
committermar <mar>
Wed, 10 Mar 1993 13:48:08 +0000 (13:48 +0000)
regtape/students.dc

index 098a01946d8c17e9bd6d61dde2f65744da2e318d..d0a69cadc73e12278cb028d64958bd083b440616 100644 (file)
@@ -247,7 +247,7 @@ struct entry *e;
     int changed, nochange, encrypted;
     char buf[BUFSIZ], *from, *to;
     EXEC SQL BEGIN DECLARE SECTION;
-    char *first, *last, *eid, *title, *sid, *name, *rname, *rdept, *rtitle;
+    char *first, *last, *middle, *eid, *title, *sid, *name, *rname, *rdept, *rtitle;
     char *rophone, *rhphone, *prog;
     char class[9], haddr[128], hphone[33], ophone[33], dept[33], raddr[128];
     char dfirst[17], dlast[17], dmiddle[17];
@@ -262,12 +262,13 @@ struct entry *e;
     last = e->last;
     if (strlen(last) > 16)
       last[16] = 0;
+    middle = e->middle;
     eid = e->eid;
     sid = e->id;
     id = 0;
     encrypted = 0;
 
-/* Get user info */
+    /* Get user info */
     EXEC SQL REPEATED SELECT users_id, first, last, middle, type, home_addr, home_phone, office_phone, status, department
       INTO :id, :dfirst, :dlast, :dmiddle, :class, :haddr, :hphone, :ophone, :status, :dept
       FROM users
@@ -292,10 +293,10 @@ struct entry *e;
        }
     }
 
-/* See if class changed: if it's different, and the value in the database
- * is not STAFF or SIPB, then update the database.  Since they were on the
- * students tape, make the account usable.
- */
+    /* See if class changed: if it's different, and the value in the database
    * is not STAFF or SIPB, then update the database.  Since they were on the
    * students tape, make the account usable.
    */
     if (strcmp(e->class, strtrim(class)) &&
        strcmp(class, "STAFF") && strcmp(class, "SIPB")) {
        com_err(whoami, 0, "updating class for user %s %s from %s to %s",
@@ -313,8 +314,22 @@ struct entry *e;
        }
     }
 
-    /* Deal with updating the finger info if necessary */
+    /* Update name if necessary */
+    if (strcmp(first, strtrim(dfirst)) ||
+       strcmp(last, strtrim(dlast)) ||
+       strcmp(middle, strtrim(dmiddle))) {
+       com_err(whoami, 0, "updating real name for %s %s", first, last);
+       EXEC SQL UPDATE users
+         SET first = :first, last = :last, middle = :middle,
+               modby = :who, modwith = :prog, modtime = 'now'
+         WHERE users_id = :id;
+       if (sqlca.sqlcode != 0) {
+           com_err(whoami, 0, "ingres error %d", sqlca.sqlcode);
+           exit(1);
+       }
+    }
 
+    /* Deal with updating the finger info if necessary */
     changed = nochange = 0;
     if (encrypted) changed++;
     strcpy(buf, e->address);
This page took 0.039623 seconds and 5 git commands to generate.