/**
  * returns the persons name replacing a pidm
  */
 public static function get_name($pidm, $format = 'l, f')
 {
     $person = new PSUPerson($pidm);
     $name = $person->formatName($format);
     $person->destroy();
     return $name;
 }
 $pdf->setTextColor(120, 7, 41);
 $prev_response = $record['response'];
 $pdf->Cell(25, 5, '     Marked as', 0, 0, 'L');
 if ($record['response'] == 'incomplete') {
     $pdf->Cell(20, 5, 'incomplete', 0, 0, 'L');
     $no_answer = 'f';
 } elseif ($record['response'] == 'complete') {
     $pdf->Cell(20, 5, 'complete', 0, 0, 'L');
     $no_answer = 'f';
 } elseif ($record['response'] == 'n/a') {
     $pdf->Cell(20, 5, 'n/a', 0, 0, 'L');
     $no_answer = 'f';
 }
 $pdf->Cell(5, 5, 'by', 0, 0, 'L');
 $responder = new PSUPerson($record['updated_by']);
 $record['updated_by'] = $responder->formatName('f m l');
 $responder->destroy();
 $pdf->Cell(80, 5, $record['updated_by'] . ' at ' . $record['activity_date'], 0, 1, 'L');
 $pdf->setTextColor(0, 0, 0);
 if ($no_answer == 't') {
     $pdf->setTextColor(120, 7, 41);
     $pdf->Cell(190, 5, '     No action taken', 0, 1, 'L');
     $pdf->setTextColor(0, 0, 0);
     $no_answer = 'f';
 }
 if ($record['notes']) {
     $pdf->setTextColor(0, 0, 0);
     $pdf->Cell(95, 5, 'Do you have more details or anything else to add?', 0, 1, 'L');
     $pdf->setTextColor(120, 7, 41);
     $pdf->Cell(190, 5, "     " . $record['notes'], 0, 1, 'L');
 }
$redirect_id = $identifier;
$reason = isset($_GET['reason']) ? $_GET['reason'] : null;
try {
    if ($action == 'impersonate') {
        if (!$GLOBALS['ape']->canResetPassword()) {
            throw new Exception('You are not allowed to modify account locks.');
        }
        $person = new PSUPerson($identifier);
        $redirect_id = PSU::nvl($person->wp_id, $person->id);
        $GLOBALS['LOG']->write('Impersonating account: ' . $reason, $person->login_name);
        $_SESSION['impersonate'] = TRUE;
        $_SESSION['impersonate_store'] = array('wp_id' => $_SESSION['wp_id'], 'username' => $_SESSION['username'], 'pidm' => $_SESSION['pidm'], 'fullname' => $_SESSION['fullname']);
        $_SESSION['wp_id'] = $person->wp_id;
        $_SESSION['username'] = PSU::nvl($person->login_name, $person->wp_id);
        $_SESSION['pidm'] = $person->pidm;
        $_SESSION['fullname'] = $person->formatName('f m l');
        $_SESSION['phpCAS']['user'] = PSU::nvl($person->login_name, $person->wp_id);
        unset($_SESSION['AUTHZ']);
        if ($_SESSION['pidm']) {
            PSU::get('idmobject')->loadAuthZ($_SESSION['pidm']);
        }
        //end if
        unset($_SESSION['AUTHZ']['admin']);
        foreach ((array) $_SESSION['AUTHZ']['permission'] as $key => $value) {
            if (strpos($key, 'ape_') === 0) {
                unset($_SESSION['AUTHZ']['permission'][$key]);
            }
            //end if
        }
        //end foreach
        $message = 'Now impersonating: ' . $_SESSION['username'] . ' (' . $_SESSION['wp_id'] . ')';
 function addNewCall($new_call_form_vars, $call_location = '')
 {
     $query_status = '';
     // Gets new call form variables from add_new_call.html
     $call_log = array();
     $call_history = array();
     // Vars going to addToCallLog--I laid them out in a way that matched the database.
     $call_log['call_id'] = '';
     $person = new PSUPerson($new_call_form_vars['caller_user_name']);
     $call_log['wp_id'] = $person->wp_id;
     $call_log['pidm'] = $person->pidm ? $person->pidm : 0;
     $call_log['caller_username'] = PSU::nvl($person->username, $person->wp_id, $new_call_form_vars['caller_user_name']);
     //required
     $call_log['caller_first_name'] = stripslashes($person->formatName('f'));
     //required
     $call_log['caller_last_name'] = stripslashes($person->formatName('l'));
     //required
     $call_log['caller_phone_number'] = $new_call_form_vars['caller_phone_number'];
     //required
     $call_log['calllog_username'] = $_SESSION['username'];
     //required
     $call_log['call_type'] = $new_call_form_vars['resnet_check'];
     $call_log['call_time'] = 'NOW()';
     $call_log['call_date'] = 'NOW()';
     $call_log['keywords'] = stripslashes($new_call_form_vars['keywords_list']);
     $call_log['location_building_id'] = $new_call_form_vars['location_building_id'];
     $call_log['location_building_room_number'] = $new_call_form_vars['location_building_room_number'];
     $call_log['location_call_logged_from'] = $call_location;
     $call_log['title'] = stripslashes($new_call_form_vars['title']);
     $call_log['feelings'] = stripslashes($new_call_form_vars['feelings']);
     $call_log['feelings_face'] = $new_call_form_vars['feelings_face'];
     // If the new auto-incremented call_id was returned
     if ($new_call_id = $this->addToCallLog($call_log)) {
         // Vars going to addToCallHistory
         $call_history['id'] = '';
         $call_history['call_id'] = $new_call_id;
         $call_history['updated_by'] = $_SESSION['username'];
         $call_history['tlc_assigned_to'] = $new_call_form_vars['tlc_assigned_to'];
         if ($call_history['tlc_assigned_to'] != "" && $call_history['tlc_assigned_to'] == "helpdesk") {
             $call_history['tlc_assigned_to'] = "";
         }
         $call_history['its_assigned_group'] = $new_call_form_vars['its_assigned_group'];
         if ($call_history['its_assigned_group'] != "") {
         }
         $call_history['comments'] = stripslashes($new_call_form_vars['problem_details']);
         //required
         $call_history['date_assigned'] = 'NOW()';
         $call_history['time_assigned'] = 'NOW()';
         $call_history['call_status'] = $new_call_form_vars['call_status'];
         //required
         $call_history['call_priority'] = $new_call_form_vars['call_priority'];
         //required
         $call_history['call_state'] = $new_call_form_vars['call_state'];
         //required
         $call_history['current'] = 1;
         $status = $this->addToCallHistory($call_history);
         if (!$status) {
             $_SESSION['user_message'] = 'Error inserting new call into call_history table.';
         }
     } else {
         $_SESSION['user_message'] = 'Error retrieving new auto-incremented call_id.';
     }
     return $new_call_id;
 }
 public static function simple_search($search, $type = 'all')
 {
     global $db;
     $phonebook_search = array('all', 'name_first', 'name_last', 'email', 'phone');
     $search_data = array();
     $search_data['search_string'] = $_SESSION['search_string'] = stripslashes($search);
     $search_data['search_type'] = $_SESSION['search_type'] = $type;
     if (in_array($type, $phonebook_search)) {
         $search_results = phonebookSearch($search, $type);
     }
     switch ($search_data['search_type']) {
         case 'closed':
             $sql = "\n\t\t\t\t\tSELECT * \n\t\t\t\t\t\tFROM call_view \n\t\t\t\t\t WHERE caller_username = ?\n\t\t\t\t\t\t AND current='1' \n\t\t\t\t\t\t AND call_status = 'closed' \n\t\t\t\t\t ORDER BY call_date DESC, \n\t\t\t\t\t\t\t\t call_time DESC\n\t\t\t\t";
             $results = $db->GetAll($sql, array($search_data['search_string']));
             foreach ($results as $key) {
                 $key['comments'] = substr($key['comments'], 0, 23) . '...';
                 $search_data['results'][] = array('key' => $key, 'search_string' => $search_data['search_string'], 'search_type' => $search_data['search_type']);
             }
             $search_data['fields'][1] = 'Call ID';
             $search_data['fields'][2] = 'Name';
             $search_data['fields'][3] = 'Call Date';
             $search_data['fields'][4] = 'Call Time';
             $search_data['fields'][5] = 'Comments';
             $search_data['search_results_text'] = 'Calls By';
             break;
         case 'computer':
             $hardware = searchHardwareInformation($search_data['search_string']);
             $username = explode("@", $hardware[0]['email']);
             $username = $username[0];
             foreach ($hardware as $hardware_info) {
                 $search_data['results'][] = array('HW_Key' => $hardware_info['id'], 'HW_IPName' => $hardware_info['computer_name'], 'HW_Username' => $username, 'MACAddress' => $hardware_info['mac_address'], 'IPAddress' => $hardware_info['ip_address'], 'search_string' => $search_data['search_string'], 'location' => $hardware_info['NodeName'], 'search_type' => $search_data['search_type']);
             }
             $search_data['fields'][1] = 'Computer Name';
             $search_data['fields'][2] = 'MAC Address';
             $search_data['fields'][3] = 'IP Address';
             $search_data['fields'][4] = 'Location';
             $search_data['search_results_text'] = 'Computer Name';
             break;
         case 'ip':
             $HardwareInfo = $db->GetAll("SELECT * FROM hardware_inventory WHERE ip_address = ?", array($search_data['search_string']));
             $username = explode("@", $HardwareInfo[0]['email']);
             $username = $username[0];
             $search_results = phonebookSearch($username);
             $search_results = current($search_results);
             $search_data['results'][] = array('HW_Key' => $HardwareInfo[0]['id'], 'HW_IPName' => $HardwareInfo[0]['computer_name'], 'HW_Username' => $search_results['email'], 'HW_Name' => $search_results['name_full'], 'MACAddress' => $HardwareInfo[0]['mac_address'], 'IPAddress' => $HardwareInfo[0]['ip_address'], 'search_string' => $search_data['search_string'], 'search_type' => $search_data['search_type']);
             $search_data['fields'][1] = 'IP Address';
             $search_data['fields'][2] = 'Name';
             $search_data['fields'][3] = 'Username';
             $search_data['fields'][4] = 'MAC Address';
             $search_data['fields'][5] = 'Computer Name';
             $search_data['search_results_text'] = 'IP Address';
             break;
         case 'mac':
             $HardwareInfo = $db->GetAll("SELECT * FROM hardware_inventory WHERE upper(mac_address) = ?", array(strtoupper($search_data['search_string'])));
             $username = explode("@", $HardwareInfo[0]['email']);
             $username = $username[0];
             $search_results = phonebookSearch($username);
             $search_results = current($search_results);
             $search_data['results'][] = array('HW_Key' => $HardwareInfo[0]['id'], 'HW_IPName' => $HardwareInfo[0]['computer_name'], 'HW_Username' => $search_results['email'], 'HW_Name' => $search_results['name_full'], 'MACAddress' => $HardwareInfo[0]['mac_address'], 'IPAddress' => $HardwareInfo[0]['ip_address'], 'search_string' => $search_data['search_string'], 'search_type' => $search_data['search_type']);
             $search_data['fields'][1] = 'MAC Address';
             $search_data['fields'][2] = 'Name';
             $search_data['fields'][3] = 'Username';
             $search_data['fields'][4] = 'Computer Name';
             $search_data['search_results_text'] = 'MAC Address';
             break;
         case 'ticket':
             $ticket_number_results = searchTicketNumber($search_data['search_string']);
             if ($ticket_number_results['call_id'] != '') {
                 $search_data['results'][] = array('call_id' => $ticket_number_results['call_id'], 'caller_username' => $ticket_number_results['caller_username'], 'caller_first_name' => $ticket_number_results['caller_first_name'], 'caller_last_name' => $ticket_number_results['caller_last_name'], 'caller_phone_number' => $ticket_number_results['caller_phone_number'], 'call_date' => $ticket_number_results['call_date'], 'call_time' => $ticket_number_results['call_time'], 'calllog_username' => $ticket_number_results['calllog_username'], 'search_string' => $search_data['search_string'], 'search_type' => $search_data['search_type'], $search_data['search_type'] . '_selected' => 'SELECTED');
             } else {
                 $tpl->assign('no_ticket', 'NO TICKET FOUND');
                 $tpl->parse('main.searchResults.no_ticket');
             }
             $search_data['fields'][1] = 'Call ID';
             $search_data['fields'][2] = 'Name';
             $search_data['fields'][3] = 'Username';
             $search_data['fields'][4] = 'Call Date/Time';
             $search_data['fields'][5] = 'Call Log User';
             $search_data['search_results_text'] = 'Ticket #';
             break;
         case 'user':
             $results = $db->GetAll("SELECT * FROM call_log, call_history WHERE call_log.call_id = call_history.call_id AND call_log.calllog_username = '******'search_string']}' AND current='1' ORDER BY call_date DESC, call_time DESC");
             foreach ($results as $key) {
                 if ($key['comments'] != "") {
                     $key['comments'] = substr($key['comments'], 0, 23) . '...';
                 } else {
                     $key['comments'] = "Closed on Submit";
                 }
                 $search_data['results'][] = array('key' => $key, 'search_string' => $search_data['search_string'], 'search_type' => $search_data['search_type']);
             }
             $search_data['fields'][1] = 'Call ID';
             $search_data['fields'][2] = 'Name';
             $search_data['fields'][3] = 'Call Date';
             $search_data['fields'][4] = 'Call Time';
             $search_data['fields'][5] = 'Comments';
             $search_data['search_results_text'] = 'Calls By';
             break;
         case 'wp_id':
         case 'all':
         case 'name_last':
         case 'name_first':
         case 'email':
         case 'phone':
             if ($search_data['search_type'] == 'wp_id') {
                 $sql = "\n\t\t\t\t\t\tSELECT * \n\t\t\t\t\t\t\tFROM wp_users \n\t\t\t\t\t\t WHERE user_login LIKE ?\n\t\t\t\t\t";
                 $search_results = PSU::db('connect')->GetAll($sql, array($search_data['search_string'] . '%'));
                 foreach ($search_results as &$record) {
                     $person = new PSUPerson($record['user_login']);
                     $record['identifier'] = $record['wp_id'] = $person->wp_id;
                     $record['name_full'] = $person->formatName('f l');
                     $record['email'] = $person->username;
                     $record['dept'] = 'Family Portal';
                     $person->destroy();
                     unset($person);
                 }
                 //end foreach
             }
             //end if
             foreach ($search_results as $k => $key) {
                 $class_prepend = '';
                 if ($key['email']) {
                     $display = "user_info";
                     if (!$key['identifier']) {
                         $key['identifier'] = $key['email'];
                     }
                     //end if
                 } else {
                     $display = "no_username";
                     if (!$key['identifier']) {
                         $key['identifier'] = $key['pidm'];
                     }
                     //end if
                 }
                 //end else
                 $portal_roles = PSU::get('idmobject')->GetAllBannerRoles($key['pidm']);
                 if (is_array($portal_roles) && in_array('alumni', $portal_roles)) {
                     $class_prepend = 'Alumni' . ($class_prepend ? '/ ' . $class_prepend : '');
                 }
                 //end if
                 if (is_array($portal_roles) && in_array('student_account_active', $portal_roles)) {
                     $class_prepend = 'Student' . ($class_prepend ? '/ ' . $class_prepend : '');
                 }
                 //end if
                 $key['dept'] = $class_prepend . ($key['dept'] ? '/ ' . $key['dept'] : '');
                 if ($key['pidm'] || $key['username'] || $key['wp_id']) {
                     $where = array();
                     $args = array();
                     if ($key['pidm']) {
                         $where[] = "call_log.pidm = ?";
                         $args[] = $key['pidm'];
                     }
                     //end if
                     if ($key['username']) {
                         $where[] = "call_log.caller_username = ?";
                         $args[] = $key['username'];
                     }
                     //end if
                     if ($key['wp_id']) {
                         $where[] = "call_log.wp_id = ?";
                         $args[] = $key['wp_id'];
                     }
                     //end if
                     $where = implode(" OR ", $where);
                     $getOpenCallInfo = $db->GetOne("SELECT * FROM call_log, call_history WHERE call_log.call_id = call_history.call_id AND call_history.call_status = 'open' AND ({$where}) AND call_history.current='1'", $args);
                     $num_open_calls = $db->GetOne("SELECT count(*) FROM call_log, call_history WHERE call_log.call_id = call_history.call_id AND call_history.call_status = 'open' AND ({$where}) AND call_history.current='1'", $args);
                     if ($num_open_calls >= 1) {
                         $key['call_id'] = $getOpenCallInfo;
                         $key['open_call'] = "(" . $num_open_calls . " Open)";
                     }
                     //end if
                     if ($key['major'] && $key['title']) {
                         $key['major_title'] = substr($key['major'] . ' / ' . $key['title'], 0, 20);
                         $key['major_title_full'] = $key['major'] . ' / ' . $key['title'];
                     } else {
                         $key['major_title'] = substr($key['major'] . ' ' . $key['title'], 0, 20);
                         $key['major_title_full'] = $key['major'] . ' ' . $key['title'];
                     }
                     //end else
                 }
                 //end if
                 $search_data['results'][] = array('key' => $key, 'search_string' => $search_data['search_string'], 'search_type' => $search_data['search_type']);
             }
             // end foreach
             $search_data['fields'][1] = 'Name';
             $search_data['fields'][2] = 'Username';
             $search_data['fields'][3] = 'Phone';
             $search_data['fields'][4] = 'Major/Title';
             $search_data['fields'][5] = 'Class/Dept';
             switch ($search_data['search_type']) {
                 case 'email':
                     $search_data['search_results_text'] = 'User Name';
                     $search_data['five_selected'] = 'SELECTED';
                     break;
                 case 'name_last':
                     $search_data['search_results_text'] = 'Last Name';
                     $search_data['2_selected'] = 'SELECTED';
                     break;
                 case 'name_first':
                     $search_data['search_results_text'] = 'First Name';
                     $search_data['1_selected'] = 'SELECTED';
                     break;
             }
             //end switch
             break;
     }
     //end switch
     return $search_data;
 }
<?php

require_once 'PrintUser.class.php';
if (in_array($_SESSION['tlc_position'], $_SESSION['priv_users']) || $_SESSION['tlc_position'] == 'shift_leader' || $_SESSION['tlc_position'] == 'supervisor') {
    $print_user = new PrintUser($_GET['pidm']);
    if ($print_user->username && $_GET['action'] == 'update') {
        $print_increased = false;
        $increase = $_GET['fund_increase'];
        if (in_array($increase, array(-20, -10, -5, -1, -0.1, 0.1, 1, 5, 10, 20))) {
            $print_increased = $print_user->adjustBalance($increase);
            $person = new PSUPerson($_GET['pidm']);
            if ($print_increased === true) {
                $call_data = array('call_log_username' => $_SESSION['username'], 'caller_first_name' => $person->formatName('f'), 'caller_last_name' => $person->formatName('l'), 'caller_user_name' => $person->username, 'call_status' => 'closed', 'call_priority' => 'normal', 'problem_details' => 'Added ' . number_format($increase, 2) . ' in print funds', 'keywords_list' => 'pquota');
                $call_location = $GLOBALS['new_call']->returnCallLoggedFromLocation($_SERVER['REMOTE_ADDR']);
                $GLOBALS['new_call']->addNewCall($call_data, $call_location);
                $call_added = 'call_added';
                echo number_format($print_user->balance + $increase, 2);
            }
            //end if
        } else {
            echo isset($print_user->balance) ? number_format($print_user->balance, 2) : number_format(20, 2);
        }
        //end else
    }
    //end if
} else {
    echo 'invalid_privs';
}
//end else
 /**
  * displays a ticket's public updates
  */
 public function ticket($ticket)
 {
     IDMObject::authN();
     $sql = "SELECT *,\n\t\t\t\t\t\t\t\t\t CONCAT(date_assigned, ' ', time_assigned) update_date\n\t\t\t        FROM call_history\n\t\t\t\t\t\t WHERE call_id = ?\n               AND (updated_by = ?\n\t\t\t\t\t\t        OR\n\t\t\t\t\t\t        tlc_assigned_to = ?\n\t\t\t\t\t\t\t\t\t\tOR\n\t\t\t\t\t\t\t\t\t\tupdated_by = ?\n\t\t\t\t\t\t\t\t\t\tOR\n\t\t\t\t\t\t\t\t\t\ttlc_assigned_to = ?\n\t\t\t\t\t\t\t\t\t )\n\t\t\t\t\t\t ORDER BY date_assigned, time_assigned";
     $args = array($ticket, $this->myuser->login_name, $this->myuser->login_name, $this->myuser->wp_id, $this->myuser->wp_id);
     $details = PSU::db('calllog')->GetAll($sql, $args);
     foreach ($details as &$detail) {
         $p = new PSUPerson($detail['updated_by']);
         $detail['updated_by_name'] = $p->wp_id == $_SESSION['wp_id'] ? 'You' : $p->formatName('f');
         $p->destroy();
         unset($p);
     }
     //end foreach
     $sql = "SELECT call_status\n\t\t\t        FROM call_history\n\t\t\t\t\t\t WHERE call_id = ? AND current = 1";
     $args = array($ticket);
     $this->tpl->assign('call_status', PSU::db('calllog')->GetOne($sql, $args));
     $this->tpl->assign('details', $details);
     $this->tpl->assign('ticket', $ticket);
     $tpl = new PSUSmarty();
     $tpl->assign('hide_checklist', true);
     $tpl->assign('details_title', 'Update Ticket');
     $form = $tpl->fetch(PSU_BASE_DIR . '/webapp/calllog/templates/ticket_form.tpl');
     $this->tpl->assign('form', $form);
     $this->tpl->display('ticket.tpl');
 }
 $_POST['problem_details'] = filter_var($_POST['problem_details'], FILTER_SANITIZE_STRING);
 $prevent_file_upload = true;
 $GLOBALS['end_user_email'] = true;
 $person = new PSUPerson($_SESSION['username']);
 $_POST['call_id'] = $_GET['call_id'] = (int) $_GET['ticket'];
 $call = $db->GetRow("SELECT * FROM call_log WHERE call_id = ?", array($_GET['call_id']));
 $_POST['title'] = $call['title'];
 $_POST['feelings'] = $call['feelings'];
 $_POST['feelings_face'] = $call['feelings_face'];
 $max_history = $db->GetRow("SELECT * FROM call_history WHERE call_id = ? AND current = 1", array($_GET['call_id']));
 if ($max_history['call_status'] == 'closed') {
     PSU::redirect($_GET['redirect']);
 }
 //end if
 $_POST['call_log_username'] = $_POST['caller_user_name'] = $person->username ? $person->username : $person->wp_id;
 $_POST['caller_first_name'] = $person->formatName('f');
 $_POST['caller_last_name'] = $person->formatName('l');
 if ($person->phones['OF'][0]) {
     $_POST['caller_phone_number'] = '(' . $person->phones['OF'][0]->phone_area . ')' . $person->phones['OF'][0]->phone_number;
 } else {
     $_POST['caller_phone_number'] = '';
 }
 //end else
 $_POST['its_assigned_group'] = $max_history['its_assigned_group'];
 if ($max_history['tlc_assigned_to'] != $person->username) {
     $_POST['tlc_assigned_to'] = $max_history['tlc_assigned_to'];
 } else {
     $_POST['tlc_assigned_to'] = 'unassigned';
 }
 //end else
 $_POST['call_status'] = $_POST['call_status'] == 'closed' ? 'closed' : $max_history['call_status'];
 /**
  * getCallerData
  *
  * returns caller data.  wewt.
  *
  * @param string $caller Caller username or pidm or wp_id
  * @param array $person Person record
  * @return array
  */
 function getCallerData($caller, $person = false)
 {
     $found_via = null;
     if ($person) {
         $found_via = 'function-args';
     }
     if (!$caller) {
         return array();
     }
     $config = \PSU\Config\Factory::get_config();
     $overrides = $config->get_json('psuperson', 'overrides');
     if (isset($overrides->{$caller})) {
         $caller = $overrides->{$caller};
     }
     //has the caller data already been queried?
     if (is_scalar($caller) && $this->people[$caller]) {
         //aye!  return it
         return $this->people[$caller];
     }
     //end if
     // are we trying to query getCallerData based on an already-populated $caller?
     if (is_array($caller) && isset($caller['wp_id']) && isset($this->people[$caller['wp_id']])) {
         return $this->people[$caller['wp_id']];
     } elseif (is_array($caller) && isset($caller['pidm']) && isset($this->people[$caller['pidm']])) {
         return $this->people[$caller['pidm']];
     }
     //end elseif
     //
     // populate generic data
     //
     $caller_data = array('pidm' => 0, 'wp_id' => null, 'identifier' => 'generic', 'email' => $GLOBALS['HELPDESK_EMAIL'], 'name_first' => 'Generic Caller', 'name_last' => 'Help Desk');
     switch ($caller) {
         case 'generic':
             $found_via = 'fake-user';
             break;
         case 'kiosk':
             $caller_data['identifier'] = 'kiosk';
             $caller_data['name_first'] = 'Kiosk';
             $found_via = 'fake-user';
             break;
         case 'clusteradm':
             $caller_data['identifier'] = 'clusteradm';
             $caller_data['name_first'] = 'Cluster Call';
             $found_via = 'fake-user';
             break;
     }
     //end switch
     $caller_data['name_full'] = $caller_data['name_first'] . ' - ' . $caller_data['name_last'];
     //
     // done with generic user setup; try to populate real user
     //
     if (!$person && !$this->isFakeUser($caller)) {
         // looks like a real user. try and find him.
         $caller_person = new PSUPerson($caller);
         if ($caller_person->is_valid()) {
             $person = array();
             $person['name_full'] = $caller_person->formatName('f l');
             $person['wp_id'] = $caller_person->wp_id;
             $person['email'] = $caller_person->wp_email;
             $person['pidm'] = $caller_person->pidm ? $caller_person->pidm : null;
             $person['identifier'] = $caller_person->wp_email ? $caller_person->wp_id : $caller_person->pidm;
             $person['username'] = $caller_person->username ?: $caller_person->wp_id;
             $found_via = 'psuperson';
         }
     }
     //end if
     //was a person record found?
     if (!empty($person)) {
         //Do some data cleansing
         $person['phone_number'] = $person['phone_of'] ? $person['phone_of'] : $person['phone_vm'];
         if ($person['pidm']) {
             $person['role'] = @implode(', ', PSU::get('idmobject')->getAllBannerRoles($person['identifier']));
         } else {
             $person['role'] = 'No Roles: Family Portal Only';
         }
         //end else
         if ($person['class'] == 'Alumni') {
             $person['class'] = strtolower($person['class']) . '.';
         }
         //end if
         if ($person['pidm']) {
             //get address for location
             if ($addresses = current($GLOBALS['BannerGeneral']->getAddress($person['pidm'], 'RH'))) {
                 $person['location'] = $addresses['r_street_line1'] . ' / ' . $person['msc'];
             } elseif ($addresses = current($GLOBALS['BannerGeneral']->getAddress($person['pidm'], 'OF'))) {
                 $person['location'] = $addresses['r_street_line2'] . ' / ' . $person['msc'];
             }
             //end elseif
             $psu_person = new PSUPerson($person['pidm']);
             $person['phone_number'] = $this->getCallerPhone($psu_person);
         }
         //end if
         //set the caller data to the person record
         $caller_data = $person;
     } elseif (!$this->isFakeUser($caller)) {
         $person = new PSUPerson($caller);
         $caller_data = array('pidm' => $person->pidm, 'wp_id' => $person->wp_id, 'psu_id' => $person->id, 'username' => $person->username, 'identifier' => $person->username ? $person->username : $person->wp_id, 'email' => $person->wp_email ? $person->wp_email : ($person->email ? $person->email['CA'][0] : ''), 'name_last' => $person->last_name, 'name_first' => $person->first_name, 'name_full' => "{$person->first_name} {$person->last_name}", 'phone_number' => $this->getCallerPhone($person));
         if (isset($caller_data['email']['CA']) && strpos($caller_data['email']['CA'], '@') !== false) {
             $caller_data['email'] = $caller_data['email']['CA'][0];
         } elseif (count($caller_data['email'])) {
             if (is_array($caller_data['email'])) {
                 $caller_data['email'] = array_shift(array_shift($caller_data['email']));
             } else {
                 $caller_data['email'] = $caller_data['email'];
             }
         } else {
             $caller_data['email'] = null;
         }
     }
     $caller_data['username'] = $caller_data['username'] ?: $caller_data['identifier'];
     if ($found_via == null) {
         return false;
     }
     //store the caller data so it isn't requeried a crap ton of times
     $this->people[$caller] = $caller_data;
     return $caller_data;
 }
     throw new Exception('You are not allowed to modify account locks.');
 }
 $person = new PSUPerson($pidm);
 $redirect_id = PSU::nvl($person->id, $person->wp_id);
 if ($lock) {
     $GLOBALS['LOG']->write('Locking account', $person->login_name);
     $message = "Account for {$person->login_name} has been locked.";
     $reason .= ' (auto-opened via APE)';
     if ($call_id = APE::create_ticket($person->login_name, 'Account Locked', $reason, array('call_source' => 'APE Locked Account'))) {
         $message .= ' Ticket #<a href="http://go.plymouth.edu/log/' . $call_id . '">' . $call_id . '</a> opened.';
     }
     //end if
     $_SESSION['messages'][] = $message;
     $keys = array('added', 'sourced_id', 'password', 'pidm', 'login_name', 'fullname', 'reason', 'locker_pidm');
     $values = array('NOW()', '?', '?', '?', '?', '?', '?', '?');
     $args = array($person->sourced_id, ' ', $pidm, $person->login_name, $person->formatName('f l'), $reason, $_SESSION['pidm']);
     $sql = "\n\t\t  INSERT INTO ape_support_locks (" . implode(', ', $keys) . ")\n\t\t  VALUES (" . implode(', ', $values) . ")\n\t\t";
     if (!PSU::db('myplymouth')->Execute($sql, $args)) {
         throw new Exception(PSU::db('myplymouth')->errorMsg());
     }
     $person->lock_wp_account();
 } else {
     $GLOBALS['LOG']->write('Unlocking account', $person->login_name);
     $message = "Account for {$person->login_name} has been unlocked.";
     if ($call = APE::find_ticket_by_source($person->wp_id ? $person->wp_id : $person->login_name, 'Account Locked')) {
         $call_id = $call['call_id'];
         $reason = $_GET['reason'] . "\n\n" . 'Account is now unlocked. (auto-updated via APE)';
         if (APE::update_ticket($call_id, $reason)) {
             $message .= ' Ticket #<a href="http://go.plymouth.edu/log/' . $call_id . '">' . $call_id . '</a> has been updated. It has <strong>not</strong> been closed.';
         }
         //end if