[1968] in Moira Commits

home help back first fref pref prev next nref lref last post

/svn/moira r4107 - trunk/moira/regtape

daemon@ATHENA.MIT.EDU (Garry Zacheiss)
Thu May 9 11:39:11 2013

Date: Thu, 9 May 2013 11:39:02 -0400
From: Garry Zacheiss <zacheiss@MIT.EDU>
Message-Id: <201305091539.r49Fd2cI010410@drugstore.mit.edu>
To: moira-commits@MIT.EDU
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Author: zacheiss
Date: 2013-05-09 11:39:02 -0400 (Thu, 09 May 2013)
New Revision: 4107

Added:
   trunk/moira/regtape/affiliates.pl
Modified:
   trunk/moira/regtape/Makefile.in
   trunk/moira/regtape/common.h
   trunk/moira/regtape/common.pc
   trunk/moira/regtape/staff.pc
   trunk/moira/regtape/staff.sql
   trunk/moira/regtape/student.pc
Log:
Support for affiliation_basic and affiliation_detailed columns in users table, new script to reset users to affiliate status if they stop appearing in staff/student loads.

Modified: trunk/moira/regtape/Makefile.in
===================================================================
--- trunk/moira/regtape/Makefile.in	2013-05-09 15:36:35 UTC (rev 4106)
+++ trunk/moira/regtape/Makefile.in	2013-05-09 15:39:02 UTC (rev 4107)
@@ -35,7 +35,7 @@
 CFILES=student.c staff.c common.c vote.c
 
 TARGET=student staff vote
-SCRIPTS=grouper.pl staff.sql stellar.pl student.sql
+SCRIPTS=affiliates.pl grouper.pl staff.sql stellar.pl student.sql
 
 .SUFFIXES: .pc .lo
 

Modified: trunk/moira/regtape/common.h
===================================================================
--- trunk/moira/regtape/common.h	2013-05-09 15:36:35 UTC (rev 4106)
+++ trunk/moira/regtape/common.h	2013-05-09 15:39:02 UTC (rev 4107)
@@ -25,6 +25,9 @@
 
   /* Only used by student load */
   char *reg_type;
+
+  char *affiliation_basic;
+  char *affiliation_detailed;
 };
 
 void fixphone(char *phone);

Modified: trunk/moira/regtape/common.pc
===================================================================
--- trunk/moira/regtape/common.pc	2013-05-09 15:36:35 UTC (rev 4106)
+++ trunk/moira/regtape/common.pc	2013-05-09 15:39:02 UTC (rev 4107)
@@ -70,6 +70,8 @@
   char haddr[USERS_HOME_ADDR_SIZE], hphone[USERS_HOME_PHONE_SIZE];
   char dfirst[USERS_FIRST_SIZE], dlast[USERS_LAST_SIZE];
   char dmiddle[USERS_MIDDLE_SIZE];
+  char affiliation_basic[USERS_AFFILIATION_BASIC_SIZE];
+  char affiliation_detailed[USERS_AFFILIATION_DETAILED_SIZE];
   int id, status, fmodby, xnlen = USERS_XNAME_SIZE - 1;
   EXEC SQL END DECLARE SECTION;
 
@@ -87,9 +89,11 @@
 
   /* Get user info */
   EXEC SQL SELECT users_id, first, last, middle, type, office_addr,
-    office_phone, home_addr, home_phone, department, status, fmodby
+    office_phone, home_addr, home_phone, department, status, fmodby,
+    affiliation_basic, affiliation_detailed
     INTO :id, :dfirst, :dlast, :dmiddle, :type, :oaddr,
-    :ophone, :haddr, :hphone, :dept, :status, :fmodby
+    :ophone, :haddr, :hphone, :dept, :status, :fmodby,
+    :affiliation_basic, :affiliation_detailed
     FROM users
     WHERE clearid = :sid AND status != 3;
   if (sqlfail())
@@ -154,6 +158,31 @@
 	}
     }
 
+  /* Update affiliation information */
+  strtrim(affiliation_basic);
+  strtrim(affiliation_detailed);
+  if (strcmp(affiliation_basic, e->affiliation_basic) ||
+      strcmp(affiliation_detailed, e->affiliation_detailed))
+    {
+      com_err(whoami, 0, "affiliation for %s %s changed from \"%s (%s)\" to \"%s (%s)\"",
+	      first, last, affiliation_detailed, affiliation_basic, e->affiliation_detailed,
+	      e->affiliation_basic);
+
+      strlcpy(affiliation_basic, e->affiliation_basic, USERS_AFFILIATION_BASIC_SIZE);
+      strlcpy(affiliation_detailed, e->affiliation_detailed, USERS_AFFILIATION_DETAILED_SIZE);
+
+      EXEC SQL UPDATE users
+	SET affiliation_basic = NVL(:affiliation_basic, CHR(0)),
+	affiliation_detailed = NVL(:affiliation_detailed, CHR(0)),
+	modby = :who, modwith = :prog, modtime = SYSDATE
+	WHERE users_id = :id;
+      if (sqlca.sqlcode)
+	{
+	  dbmserr("updating affiliation", sqlca.sqlcode);
+	  exit(1);
+	}
+    }
+
   /* Update finger info fields if they have changed and the user
    * didn't set them blank.
    */
@@ -249,6 +278,7 @@
   char *id, *last, *first, *middle, *type;
   char *name, *dept, *haddr, *hphone, *oaddr, *ophone;
   char *xtitle, *xaddress, *xphone1, *xphone2;
+  char *affiliation_basic, *affiliation_detailed;
   EXEC SQL END DECLARE SECTION;
 
   users_id = set_next_users_id();
@@ -273,7 +303,9 @@
   xaddress = e->xaddress;
   xphone1 = e->xphone1;
   xphone2 = e->xphone2;
-
+  affiliation_basic = e->affiliation_basic;
+  affiliation_detailed = e->affiliation_detailed;
+  
   com_err(whoami, 0, "adding user %s %s", e->first, e->last);
 
   EXEC SQL INSERT INTO users
@@ -282,7 +314,8 @@
      department, home_addr, home_phone, office_addr, office_phone, fmodtime,
      fmodby, fmodwith, potype, pmodtime, pmodby, pmodwith,
      xname, xdept, xtitle, xaddress, xphone1, xphone2, xmodtime, secure,
-     created, creator, winhomedir, winprofiledir, sponsor_type, sponsor_id, expiration)
+     created, creator, winhomedir, winprofiledir, sponsor_type,
+     sponsor_id, expiration, affiliation_basic, affiliation_detailed)
     VALUES (:login, :users_id, :uid, '/bin/athena/bash', 'cmd',
 	    NVL(:last, CHR(0)), NVL(:first, CHR(0)), NVL(:middle, CHR(0)),
 	    :st, NVL(:id, CHR(0)), NVL(:type, CHR(0)), SYSDATE, :who, :prog,
@@ -293,7 +326,8 @@
 	    NVL(SUBSTR(:name, 0, :xnlen), CHR(0)), NVL(:dept, CHR(0)),
 	    NVL(:xtitle, CHR(0)), NVL(:xaddress, CHR(0)),
 	    NVL(:xphone1, CHR(0)), NVL(:xphone2, CHR(0)), SYSDATE, :issecure,
-	    SYSDATE, :who, '[DFS]', '[DFS]', 'NONE', 0, CHR(0));
+	    SYSDATE, :who, '[DFS]', '[DFS]', 'NONE', 0, CHR(0), :affiliation_basic,
+	    :affiliation_detailed);
   if (sqlca.sqlcode)
     {
       dbmserr("adding user", sqlca.sqlcode);

Modified: trunk/moira/regtape/staff.pc
===================================================================
--- trunk/moira/regtape/staff.pc	2013-05-09 15:36:35 UTC (rev 4106)
+++ trunk/moira/regtape/staff.pc	2013-05-09 15:39:02 UTC (rev 4107)
@@ -32,6 +32,7 @@
  * phone2 [12]
  * dept [50]
  * title [50]
+ * employee type [40]
  */
 
 #define LOC_ID 0
@@ -52,6 +53,8 @@
 #define LEN_DEPT 50
 #define LOC_TITLE (LOC_DEPT + LEN_DEPT)
 #define LEN_TITLE 50
+#define LOC_EMPLOYEE_TYPE (LOC_TITLE + LEN_TITLE)
+#define LEN_EMPLOYEE_TYPE 40
 
 struct entry *get_next_entry(FILE *in);
 void process_entry(struct entry *e, int secure);
@@ -147,6 +150,7 @@
   static char first_name[LEN_FIRST_NAME + 1], middle_name[LEN_MIDDLE_NAME + 1];
   static char office[LEN_OFFICE + 1], phone[LEN_PHONE + 1];
   static char phone2[LEN_PHONE2 + 1], dept[LEN_DEPT + 1], title[LEN_TITLE + 1];
+  static char employee_type[LEN_EMPLOYEE_TYPE + 1];
   int ends_sr, ends_jr, ends_iii, ends_iv, ends_ii, ends_v;
   char *p, *q;
 
@@ -162,6 +166,7 @@
   strlcpy(phone2, &buf[LOC_PHONE2], LEN_PHONE2 + 1);
   strlcpy(dept, &buf[LOC_DEPT], LEN_DEPT + 1);
   strlcpy(title, &buf[LOC_TITLE], LEN_TITLE + 1);
+  strlcpy(employee_type, &buf[LOC_EMPLOYEE_TYPE], LEN_EMPLOYEE_TYPE + 1);
 
   e.last = strtrim(last_name);
   e.first = strtrim(first_name);
@@ -242,6 +247,7 @@
   e.xtitle = strtrim(title);
 
   e.type = "MITS";
+
   if ((strstr(uppercase(e.xtitle), "PROF") &&
        !strstr(uppercase(e.xtitle), "PROFESSION")) ||
       strstr(uppercase(e.xtitle), "LECTURE"))
@@ -252,5 +258,11 @@
   FixCase(e.dept);
   FixCase(e.xtitle);
 
+  e.affiliation_detailed = strtrim(employee_type);
+  if (!strcmp(e.affiliation_detailed, "Faculty"))
+    e.affiliation_basic = "faculty";
+  else
+    e.affiliation_basic = "staff";
+
   return &e;
 }

Modified: trunk/moira/regtape/staff.sql
===================================================================
--- trunk/moira/regtape/staff.sql	2013-05-09 15:36:35 UTC (rev 4106)
+++ trunk/moira/regtape/staff.sql	2013-05-09 15:39:02 UTC (rev 4107)
@@ -3,6 +3,6 @@
 set pagesize 0
 set linesize 331
 spool /moira/load/staff.input.unsorted
-select mit_id || rpad(nvl(last_name, ' '), 30, ' ') || rpad(nvl(first_name, ' '), 30, ' ') || rpad(nvl(middle_name, ' '), 30, ' ') || rpad(substr(nvl(office_location, ' '), 0, 12), 12, ' ') || rpad(substr(nvl(secondary_office_location, ' '), 0, 12), 12, ' ') || lpad(substr(nvl(office_phone, ' '), 0, 12), 12, ' ') || lpad(substr(nvl(secondary_office_phone, ' '), 0, 12), 12, ' ') || rpad(substr(department_name, 0, 50), 50, ' ') || substr(directory_title, 0, 50) from wareuser.moira_employee;
+select mit_id || rpad(nvl(last_name, ' '), 30, ' ') || rpad(nvl(first_name, ' '), 30, ' ') || rpad(nvl(middle_name, ' '), 30, ' ') || rpad(substr(nvl(office_location, ' '), 0, 12), 12, ' ') || rpad(substr(nvl(secondary_office_location, ' '), 0, 12), 12, ' ') || lpad(substr(nvl(office_phone, ' '), 0, 12), 12, ' ') || lpad(substr(nvl(secondary_office_phone, ' '), 0, 12), 12, ' ') || rpad(substr(department_name, 0, 50), 50, ' ') || rpad(substr(nvl(directory_title, ' '), 0, 50), 50, ' ') || rpad(substr(nvl(employee_type, ' '), 0, 40), 40, ' ') from wareuser.moira_employee;
 spool off
 quit

Modified: trunk/moira/regtape/student.pc
===================================================================
--- trunk/moira/regtape/student.pc	2013-05-09 15:36:35 UTC (rev 4106)
+++ trunk/moira/regtape/student.pc	2013-05-09 15:39:02 UTC (rev 4107)
@@ -247,14 +247,18 @@
     {
       e.type = "G";
       sprintf(title, "Grad Student");
+      e.affiliation_detailed = "Graduate Student";      
     }
   else
     {
       e.type = classbuf;
       sprintf(classbuf, "%d", nyear + 4 - atoi(year) + 1900);
       sprintf(title, "Undergrad (class of %s)", classbuf);
+      e.affiliation_detailed = "Undergraduate Student";
     }
 
+  e.affiliation_basic = "student";
+
   e.dept = course;
 
   /* Used to detect cross-registered students. */


home help back first fref pref prev next nref lref last post