[1972] in Moira Commits

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

/svn/moira r4111 - trunk/moira/regtape

daemon@ATHENA.MIT.EDU (Garry Zacheiss)
Wed May 22 16:26:58 2013

Date: Wed, 22 May 2013 16:26:51 -0400
From: Garry Zacheiss <zacheiss@MIT.EDU>
Message-Id: <201305222026.r4MKQpXP017496@drugstore.mit.edu>
To: moira-commits@MIT.EDU
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Author: zacheiss
Date: 2013-05-22 16:26:51 -0400 (Wed, 22 May 2013)
New Revision: 4111

Modified:
   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
   trunk/moira/regtape/student.sql
Log:
Update alternate_email address from HR data for users with non-default email address.

Modified: trunk/moira/regtape/common.h
===================================================================
--- trunk/moira/regtape/common.h	2013-05-09 15:43:17 UTC (rev 4110)
+++ trunk/moira/regtape/common.h	2013-05-22 20:26:51 UTC (rev 4111)
@@ -28,6 +28,7 @@
 
   char *affiliation_basic;
   char *affiliation_detailed;
+  char *email_address;
 };
 
 void fixphone(char *phone);

Modified: trunk/moira/regtape/common.pc
===================================================================
--- trunk/moira/regtape/common.pc	2013-05-09 15:43:17 UTC (rev 4110)
+++ trunk/moira/regtape/common.pc	2013-05-22 20:26:51 UTC (rev 4111)
@@ -72,6 +72,8 @@
   char dmiddle[USERS_MIDDLE_SIZE];
   char affiliation_basic[USERS_AFFILIATION_BASIC_SIZE];
   char affiliation_detailed[USERS_AFFILIATION_DETAILED_SIZE];
+  char mit_email[USERS_LOGIN_SIZE + 9]; /* strlen("@mit.edu") + 1; */
+  char alternate_email[USERS_ALTERNATE_EMAIL_SIZE];
   int id, status, fmodby, xnlen = USERS_XNAME_SIZE - 1;
   EXEC SQL END DECLARE SECTION;
 
@@ -88,12 +90,12 @@
   id = 0;
 
   /* Get user info */
-  EXEC SQL SELECT users_id, first, last, middle, type, office_addr,
+  EXEC SQL SELECT users_id, login||'@mit.edu', first, last, middle, type, office_addr,
     office_phone, home_addr, home_phone, department, status, fmodby,
-    affiliation_basic, affiliation_detailed
-    INTO :id, :dfirst, :dlast, :dmiddle, :type, :oaddr,
+    affiliation_basic, affiliation_detailed, alternate_email
+    INTO :id, :mit_email, :dfirst, :dlast, :dmiddle, :type, :oaddr,
     :ophone, :haddr, :hphone, :dept, :status, :fmodby,
-    :affiliation_basic, :affiliation_detailed
+    :affiliation_basic, :affiliation_detailed, :alternate_email
     FROM users
     WHERE clearid = :sid AND status != 3;
   if (sqlfail())
@@ -183,6 +185,33 @@
 	}
     }
 
+  /* Update alternate email information, if any */
+  strtrim(alternate_email);
+  strtrim(mit_email);
+  if (strlen(e->email_address) > 0)
+    {
+      /* If directory information email address is the default, treat is as empty. */
+      if (!strcmp(mit_email, e->email_address))
+	e->email_address = "";
+
+      if (strcmp(alternate_email, e->email_address))
+	{
+	  com_err(whoami, 0, "alternate email for %s %s changed from \"%s\" to \"%s\"",
+		  first, last, alternate_email, e->email_address);
+	  
+	  strlcpy(alternate_email, e->email_address, USERS_ALTERNATE_EMAIL_SIZE);
+	  
+	  EXEC SQL UPDATE users SET alternate_email = NVL(:alternate_email, CHR(0)),
+	    modby = :who, modwith = :prog, modtime = SYSDATE
+	    WHERE users_id = :id;
+	  if (sqlca.sqlcode)
+	    {
+	      dbmserr("updating alternate email", sqlca.sqlcode);
+	      exit(1);
+	    }
+	}
+    }
+
   /* Update finger info fields if they have changed and the user
    * didn't set them blank.
    */

Modified: trunk/moira/regtape/staff.pc
===================================================================
--- trunk/moira/regtape/staff.pc	2013-05-09 15:43:17 UTC (rev 4110)
+++ trunk/moira/regtape/staff.pc	2013-05-22 20:26:51 UTC (rev 4111)
@@ -33,6 +33,7 @@
  * dept [50]
  * title [50]
  * employee type [40]
+ * email address [100]
  */
 
 #define LOC_ID 0
@@ -55,6 +56,8 @@
 #define LEN_TITLE 50
 #define LOC_EMPLOYEE_TYPE (LOC_TITLE + LEN_TITLE)
 #define LEN_EMPLOYEE_TYPE 40
+#define LOC_EMAIL_ADDRESS (LOC_EMPLOYEE_TYPE + LEN_EMPLOYEE_TYPE)
+#define LEN_EMAIL_ADDRESS 100
 
 struct entry *get_next_entry(FILE *in);
 void process_entry(struct entry *e, int secure);
@@ -150,7 +153,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];
+  static char employee_type[LEN_EMPLOYEE_TYPE + 1], email_address[LEN_EMAIL_ADDRESS + 1];
   int ends_sr, ends_jr, ends_iii, ends_iv, ends_ii, ends_v;
   char *p, *q;
 
@@ -167,6 +170,7 @@
   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);
+  strlcpy(email_address, &buf[LOC_EMAIL_ADDRESS], LEN_EMAIL_ADDRESS + 1);
 
   e.last = strtrim(last_name);
   e.first = strtrim(first_name);
@@ -264,5 +268,7 @@
   else
     e.affiliation_basic = "staff";
 
+  e.email_address = strtrim(email_address);
+
   return &e;
 }

Modified: trunk/moira/regtape/staff.sql
===================================================================
--- trunk/moira/regtape/staff.sql	2013-05-09 15:43:17 UTC (rev 4110)
+++ trunk/moira/regtape/staff.sql	2013-05-22 20:26:51 UTC (rev 4111)
@@ -1,8 +1,8 @@
 set head off
 set feedback off
 set pagesize 0
-set linesize 331
+set linesize 512
 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, ' ') || rpad(substr(nvl(directory_title, ' '), 0, 50), 50, ' ') || rpad(substr(nvl(employee_type, ' '), 0, 40), 40, ' ') 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, ' ') || rpad(substr(nvl(lower(email_address), ' '), 0, 100), 100, ' ') from wareuser.moira_employee;
 spool off
 quit

Modified: trunk/moira/regtape/student.pc
===================================================================
--- trunk/moira/regtape/student.pc	2013-05-09 15:43:17 UTC (rev 4110)
+++ trunk/moira/regtape/student.pc	2013-05-22 20:26:51 UTC (rev 4111)
@@ -38,6 +38,8 @@
 185-204	phone
 205-234	office address
 235-254	office phone
+255-304 registration type
+305-364 email address
 
 */
 
@@ -69,6 +71,8 @@
 #define LEN_OPHONE 20
 #define LOC_REG_TYPE (LOC_OPHONE + LEN_OPHONE)
 #define LEN_REG_TYPE 50
+#define LOC_EMAIL_ADDRESS (LOC_REG_TYPE + LEN_REG_TYPE)
+#define LEN_EMAIL_ADDRESS 60
 
 EXEC SQL BEGIN DECLARE SECTION;
 int who;
@@ -178,6 +182,7 @@
   static char ophone[LEN_OPHONE + 1], title[128];
   static char zip[LEN_ZIP + 1], oaddr[LEN_OADDR + 1];
   static char reg_type[LEN_REG_TYPE + 1];
+  static char email_address[LEN_EMAIL_ADDRESS + 1];
   static int nyear = 0;
   int ends_jr, ends_iii, ends_iv, ends_sr, ends_ii, ends_v;
   char *p;
@@ -225,6 +230,8 @@
   strtrim(ophone);
   strlcpy(reg_type, &buf[LOC_REG_TYPE], LEN_REG_TYPE + 1);
   strtrim(reg_type);
+  strlcpy(email_address, &buf[LOC_EMAIL_ADDRESS], LEN_EMAIL_ADDRESS + 1);
+  strtrim(email_address);
 
   e.first = first;
   e.last = last;
@@ -264,6 +271,8 @@
   /* Used to detect cross-registered students. */
   e.reg_type = reg_type;
 
+  e.email_address = email_address;
+
   e.oaddr = oaddr;
   fixaddress(e.oaddr);
   e.ophone = e.xphone2 = ophone;

Modified: trunk/moira/regtape/student.sql
===================================================================
--- trunk/moira/regtape/student.sql	2013-05-09 15:43:17 UTC (rev 4110)
+++ trunk/moira/regtape/student.sql	2013-05-22 20:26:51 UTC (rev 4111)
@@ -3,6 +3,6 @@
 set pagesize 0
 set linesize 512
 spool /moira/load/student.input.unsorted
-select rpad(nvl(mit_id, ' '), 9, ' ') || rpad(nvl(last_name, ' '), 30, ' ') || rpad(nvl(first_name, ' '), 30, ' ') || rpad(nvl(middle_name, ' '), 30, ' ') || rpad(nvl(student_year, ' '), 1, ' ') || rpad(nvl(department, ' '), 4, ' ') || rpad(nvl(term_street1, ' '), 30, ' ') || rpad(nvl(term_city, ' '), 40, ' ') || rpad(nvl(term_state, ' '), 2, ' ') || rpad(nvl(term_zip, ' '), 9, ' ') || rpad(nvl(term_phone1, ' '), 20, ' ') || rpad(nvl(office_location, ' '), 30, ' ') || rpad(nvl(office_phone, ' '), 20, ' ') || rpad(nvl(reg_type, ' '), 50, ' ') from wareuser.moira_student;
+select rpad(nvl(mit_id, ' '), 9, ' ') || rpad(nvl(last_name, ' '), 30, ' ') || rpad(nvl(first_name, ' '), 30, ' ') || rpad(nvl(middle_name, ' '), 30, ' ') || rpad(nvl(student_year, ' '), 1, ' ') || rpad(nvl(department, ' '), 4, ' ') || rpad(nvl(term_street1, ' '), 30, ' ') || rpad(nvl(term_city, ' '), 40, ' ') || rpad(nvl(term_state, ' '), 2, ' ') || rpad(nvl(term_zip, ' '), 9, ' ') || rpad(nvl(term_phone1, ' '), 20, ' ') || rpad(nvl(office_location, ' '), 30, ' ') || rpad(nvl(office_phone, ' '), 20, ' ') || rpad(nvl(reg_type, ' '), 50, ' ') || rpad(nvl(lower(email_address), ' '), 60, ' ') from wareuser.moira_student;
 spool off
 quit


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