Monday, January 27, 2014

Department database design (8) - edit and delete users





C:\Users\jiansen\Desktop\CAS\jiansen_dir\www_cesei0_mobile\ubc_surgery_pub\scripts\manage\index.ph, line 512 add 
     <li>Choose a person's entries to edit:
     <select onchange="if(this.value!='') location.href='./?action=people&userid='+this.value">
          <option value=""> --- Choose a person --- </option>
          <?php
              foreach(getallpeople() as $k=>$v)       
            echo "\n<option value=\"$k\">$v[LASTNAME],$v[FIRSTNAME]</option>";
          ?>
     </select>         
     </li>

line 324 add
case 'deleteuser':
    include_once($config['homedir'] . 'manage/common.php');
    if(!isset($userid)) $userid = $_REQUEST['userid'];
    deleteuser($userid);
   break;

 C:\Users\jiansen\Desktop\CAS\jiansen_dir\www_cesei0_mobile\ubc_surgery_pub\scripts\personal\index.php (1 hits)
    Line 287: (<?php echo $userinfo['email']?>) [<a href="javascript:revealupdatenamedetailsform();">Edit these details</a>]</p>

line 301 remove
 <th scope="col">Title</th> 
line 288 add
[<a href="javascript:if(confirm('Are you sure you want to do this?')){ location.href='./?userid=<?php echo $userinfo['userid']?> &amp;action=deleteuser'};">Delete  this entry </a>]
  changeupdatename(stripslashes($userid), stripslashes($title), stripslashes($firstname), stripslashes($lastname), stripslashes($honorifics), stripslashes($email));

line 86 change
updatename(stripslashes($userid), stripslashes($title), stripslashes($firstname), stripslashes($lastname), stripslashes($honorifics), stripslashes($email));
to
updatename1(stripslashes($userid), stripslashes($title), stripslashes($firstname), stripslashes($lastname), stripslashes($honorifics), stripslashes($room), stripslashes($email));
line 310 remove
  <td valign="top"><input name="title" type="text" value="<?php echo $userinfo['title']?>" size="<?php echo max(strlen($userinfo['title']),5)+1 ?>" maxlength="64"></td> 
line 315 remove
 <?php if($deptchoose) { ?><td valign="top"><?php echo $deptchoose ?>
    <label style="display: block; float: left;">Additional department(s) (if jointly-appointed): <br />
    <select name="otherdepts[]" id="otherdepts[]" size="2" multiple="multiple"><option value="">No additional departments</option>
      <?php
         $alldepts = getalldepts();
        $otherdepts = splitDeptListString($userinfo['otherdepts']);
//        print_r($otherdepts);
        foreach($alldepts as $k=>$v)
          echo '<option value="' . htmlspecialchars($k) . '"'.(array_search($k,$otherdepts)===false?'':' selected="selected"').'>' . htmlspecialchars($v['NAME']) . '</option>';
      ?>
    </select>    </label></td><?php } ?>

  <td valign="top"><input type="submit" value="Store amended details">
    <input type="hidden" name="userid" value="<?php echo $userid ?>" />
    <input type="hidden" name="action" value="updatename" /></td>
  </tr>

</table>
to
  <?php if($deptchoose) { ?><td valign="top"><?php echo $deptchoose ?>
    </td><?php } ?>
  </tr>
</table>
  <input type="submit" value="Store amended details">
    <input type="hidden" name="userid" value="<?php echo $userid ?>" />
    <input type="hidden" name="action" value="updatename" />


C:\Users\jiansen\Desktop\CAS\jiansen_dir\www_cesei0_mobile\ubc_surgery_pub\scripts\manage\common.php, line 1176 add
function deleteuser($userid)
{
  $userid = intval($userid);

  $res = mysql_query("DELETE FROM USERS WHERE userid='$userid' LIMIT 1",connectpubsdb());
   if(!$res)
    return false;
    else
      {echo 'User id '.$userid.' is deleted.<p>'; return true;}
 }  

line 1393 add
function updatename1($userid, $title, $firstname, $lastname, $honorifics, $room, $email)
{
  $q = "UPDATE USERS SET title='" . mysql_real_escape_string($title)
                         . "', firstname='" . mysql_real_escape_string($firstname)
                         . "', lastname='" . mysql_real_escape_string($lastname)
                         . "', email='" . mysql_real_escape_string($email)
                          . "', room='" . mysql_real_escape_string($room)
                         . "', honorifics='" . mysql_real_escape_string($honorifics) . "' WHERE userid='$userid' LIMIT 1";
  $res = mysql_query($q, connectpubsdb());
  recordtransaction('updatename',0);
  recordLsUsersTransaction('LS:updatename', $q);
  return $res;

No comments:

Post a Comment