Monday, January 13, 2014

Department database design (2)





http://localhost/ubc_surgery_pub/scripts/manage/
C:\Users\jiansen\Desktop\CAS\jiansen_dir\www_cesei0_mobile\ubc_surgery_pub\scripts\manage\superadmin\convertauthor.php, new file:
<?php
error_reporting(E_ALL ^ E_NOTICE);
// Simply list all users. If "deptid" is supplied then restrict to that dept.
require_once($config['homedir']. '/manage/common.php');
$q = "SELECT * FROM USERS";
if(!($res = mysql_query($q, connectpubsdb()))){
  echo "<p>Database error. Please try refreshing the page, and contact the system administrator if this error persists.</p>";
}else{
  $subcategorised = array();
  while($row = mysql_fetch_assoc($res)){
    $username=$row['firstname'].','.$row['lastname'][0];
    $rvv = '[[:<:]]'.$username.'[[:>:]]';
   
    $wh = "CONCAT_WS(' ', authorlist, secondaryauthorlist, seriesauthorlist) LIKE
    '%$vv%' AND CONCAT_WS(' ', authorlist, secondaryauthorlist, seriesauthorlist) REGEXP '$rvv'";
    $sql = "SELECT * FROM PUBLICATIONS WHERE ($wh)";

    $res1 = mysql_query($sql, connectpubsdb());
    while($row1 = mysql_fetch_assoc($res1)){
      $userlist = $row1['userlist'].','.$row['userid'];
      $pieces = explode(",", $row1['userlist']);
      if (in_array($row['userid'], $pieces)) break;
      $sql_1 = "UPDATE PUBLICATIONS SET userlist='$userlist' WHERE pubid=".$row1['pubid'];
      $res2 = mysql_query($sql_1, connectpubsdb());
    }
  }

?>

Download csv of department faculty and staff from
http://surgery.med.ubc.ca/faculty-staff/directory/

Change department to divisions in the code
C:\Users\jiansen\Desktop\CAS\jiansen_dir\www_cesei0_mobile\ubc_surgery_pub\scripts\manage\superadmin\index.php
change department to division, change faculty to department
C:\Users\jiansen\Desktop\CAS\jiansen_dir\www_cesei0_mobile\ubc_surgery_pub\scripts\manage\superadmin\user.php
change department to division
http://localhost/ubc_surgery_pub/scripts/manage/
add import user by csv

C:\Users\jiansen\Desktop\CAS\jiansen_dir\www_cesei0_mobile\ubc_surgery_pub\scripts\manage\index.php, line 582 add
 <li><a href="./?action=importcsvuser">Import user via csv file (new)</a></li>
line 70 add:
case 'importcsvuser':
  require_once('superadmin/importcsvuser.php');
  break;    

create new file  superadmin/importcsvuser.php

No comments:

Post a Comment