/* -------------- GLOBAL INCLUDE -------------- */
/* This file will be called from a context that
requires the global file already: thus, will
require no global file call. */
/* -------------------------------------------- */
/**
* Check for a user_id to edit, and if not found, kick you out.
*/
/*Functions to pass data to the address tab */
include($_SERVER['APPLICATION_ROOT'] . 'user_management/member_address_functions.php');
$user_array = array();
$user_array =$_GET['user_id'];
if($_GET['array'] != "false"){
$_SESSION['search_page']['key'] = "user_id";
$_SESSION['search_page']['ids'] = $user_array;
}
if($_GET['user']!='' && $_GET['user_id']==''){
$_GET['user_id'] = $_GET['user'];
}
if($_REQUEST['user_id']!='' && $_GET['user_id']==''){
$_GET['user_id'] = $_REQUEST['user_id'];
}
if($clsLogin->IsUserTypeLoggedIn('COMS Administrator'))
$user_id = $clsLogin->GetUserInfo('user_id',(int)$_GET['user_id']);
else
$user_id = $clsLogin->GetUserInfo('user_id',(int)$_GET['user_id']);
if(!$user_id)
{
$ALERT_MSG = "User / Member not found.";
print
'
Error: No Such User Found.
Find User
';
return;
}
/**
* Make the mapper.
*/
$mapper = new CInfoMapper( 'data_dictionary', 'info_display_label', 'info_name', 'is_required', 'Y' );
$compInfo = $db->GetRow(false, "SELECT comp_id FROM company_contact_map WHERE user_id = '".$user_id."'");
if($compInfo ==""){
echo "";
}
/**
* Make the nuts.
*/
$ui_nut =& new CDBNut(DB_LOGIN_NAME.'.user_info', $user_id, 'user_id');
$ext_nut =& new CDBNut(DB_LOGIN_NAME.'.user_info_ext', $user_id, 'user_id');
$company_nut =& new CDBNut(DB_NAME.'.company', $compInfo['comp_id'], 'comp_id');
$attributes_nut =& new CDBNut(DB_LOGIN_NAME.'.user_attributes', $user_id, 'user_id');
$addr_nuts = new CDBMultiNut(DB_LOGIN_NAME.'.user_info_address',$user_id,'user_id','tabs');
$addr_nuts->SetTitle("Address","",true);
$addr_nuts->SetRecordName("Address");
/**
* Set any reformatting functions needed.
*/
$ui_nut -> ApplyPreSaveFunctionToField('phone', 'reformatPhoneNum');
/**
* Save any results we've got.
*/
if($_POST['submit_user']){
$ui_keys = array_keys($_SESSION['ui']);
foreach( $ui_keys as $key) {
if(array_key_exists($key, $_POST)){
if(stripslashes($_POST[$key]) != stripslashes($_SESSION['ui'][$key]) && $key != 'user_id'){
$current_user = $_POST['user_id'];
$newvalue = addslashes($_POST[$key]);
$oldvalue = addslashes($_SESSION['ui'][$key]);
$id = $clsLogin->GetUserId();
$sql = "INSERT INTO ".LOGIN_CHANGE_LOG." (user_id, changed_by, field, previous_value, new_value, date) VALUES
($current_user, $id, '$key', '$oldvalue', '$newvalue', NOW())";
$db->Query($sql);
$sql = "INSERT INTO ".UPDATE_TABLE." (section, updated) VALUES ('Changed Member Info', NOW())";
$db->Query($sql);
}
}
}
$ext_keys = array_keys($_SESSION['ext']);
foreach( $ext_keys as $key) {
if(array_key_exists($key, $_POST)){
if(stripslashes($_POST[$key]) != stripslashes($_SESSION['ext'][$key]) && $key != 'user_id'){
$current_user = $_POST['user_id'];
$newvalue = addslashes($_POST[$key]);
$oldvalue = addslashes($_SESSION['ext'][$key]);
$id = $clsLogin->GetUserId();
$sql = "INSERT INTO ".LOGIN_CHANGE_LOG." (user_id, changed_by, field, previous_value, new_value, date) VALUES
($current_user, $id, '$key', '$oldvalue', '$newvalue', NOW())";
$db->Query($sql);
$sql = "INSERT INTO ".UPDATE_TABLE." (section, updated) VALUES ('Changed Member Info', NOW())";
$db->Query($sql);
}
}
}
$comp_keys = array_keys($_SESSION['comp']);
foreach( $ext_keys as $key) {
if(array_key_exists($key, $_POST)){
if(stripslashes($_POST[$key]) != stripslashes($_SESSION['ext'][$key]) && $key != 'comp_id'){
$current_user = $_POST['user_id'];
$newvalue = addslashes($_POST[$key]);
$oldvalue = addslashes($_SESSION['ext'][$key]);
$id = $clsLogin->GetUserId();
$sql = "INSERT INTO ".LOGIN_CHANGE_LOG." (user_id, changed_by, field, previous_value, new_value, date) VALUES
($current_user, $id, '$key', '$oldvalue', '$newvalue', NOW())";
$db->Query($sql);
$sql = "INSERT INTO ".UPDATE_TABLE." (section, updated) VALUES ('Changed Member Info', NOW())";
$db->Query($sql);
}
}
}
$att_keys = array_keys($_SESSION['att']);
foreach( $att_keys as $key) {
if(array_key_exists($key, $_POST)){
if($_POST[$key] == 'No')
$keyv = 0;
else
$keyv = 1;
if($keyv != $_SESSION['att'][$key] && $key != 'user_id'){
$current_user = $_POST['user_id'];
$newvalue = addslashes($_POST[$key]);
$oldvalue = addslashes($_SESSION['att'][$key]);
$id = $clsLogin->GetUserId();
if($newvalue == 1 || $newvalue == 'Yes' )
$newvalue = 'Yes';
else
$newvalue = 'No';
if($oldvalue == 0 || $oldvalue == 'No' )
$oldvalue = 'No';
else
$oldvalue = 'Yes';
$sql = "INSERT INTO ".LOGIN_CHANGE_LOG." (user_id, changed_by, field, previous_value, new_value, date) VALUES
($current_user, $id, '$key', '$oldvalue', '$newvalue', NOW())";
$db->Query($sql);
$sql = "INSERT INTO ".UPDATE_TABLE." (section, updated) VALUES ('Changed Member Info', NOW())";
$db->Query($sql);
}
}
}
$ui_nut -> SetAllData($_POST);
$ext_nut -> SetAllData($_POST);
$addr_nuts->SetAllData($_POST);
$attributes_nut->SetAllData($_POST);
$company_nut->SetAllData($_POST);
$ui_nut -> Save();
$ext_nut -> Save();
$attributes_nut -> Save();
$company_nut -> Save();
$addr_nuts->Commit();
}
/**
* Blacklist the id.
*/
$ui_nut -> Hide('user_id');
$ext_nut -> Hide('user_id');
$attributes_nut -> Hide('user_id');
$company_nut -> Hide('user_id');
$company_nut -> Hide('comp_id');
/* **** 4/25/07 Ryan Marranca - per UBD's request hiding the website and job title **** */
$ui_nut -> Hide('website');
$ui_nut -> Hide('job_title');
/* **** 7/5/07 Rich Kudela - Hiding info based on User Logged in per UBDs request*/
$_SESSION['ui'] = $ui_nut -> GetAllData();
$_SESSION['ext'] = $ext_nut -> GetAllData();
$_SESSION['att'] = $attributes_nut -> GetAllData();
$_SESSION['comp'] = $company_nut -> GetAllData();
//First, if this is the user logged in and its not an admin, hide some stuff
if($clsLogin->GetUserId() == $_GET['user_id'] && !$clsLogin->IsUserTypeLoggedIn('COMS Administrator')){
$addr_nuts -> Blacklist('priority');
$addr_nuts -> Blacklist('allow_mail');
$addr_nuts -> Blacklist('allow_email');
$addr_nuts -> Blacklist('allow_display');
$addr_nuts -> Blacklist('preferred');
$attributes_nut -> Hide('user_id');
$attributes_nut -> Hide('International_DDS_Program');
$attributes_nut -> Hide('UB_Staff');
$attributes_nut -> Hide('UB_Faculty');
$attributes_nut -> Hide('UB_PT_Faculty');
$attributes_nut -> Hide('Post_Grad_Resident');
$attributes_nut -> Hide('Retired');
$attributes_nut -> Hide('Speaker');
$attributes_nut -> Hide('Clinics_Groups');
$attributes_nut -> Hide('ACDE');
$attributes_nut -> Hide('Reviewed');
$attributes_nut -> Hide('Exhibitor');
$attributes_nut -> Hide('Company_Rep');
$attributes_nut -> Hide('Vendor');
$attributes_nut -> Hide('Advertiser');
$ext_nut -> Hide('demo_agd_number');
$ext_nut -> Hide('demo_spouse');
$ext_nut -> Hide('demo_former_name');
$ext_nut -> Hide('demo_ada_num');
$ext_nut -> Hide('demo_dental_school');
$ext_nut -> Hide('demo_year_graduated');
$ext_nut -> Hide('demo_specialty');
$ext_nut -> Hide('demo_ss_num');
$ext_nut -> Hide('demo_student_num');
$ext_nut -> Hide('demo_person_num');
$ext_nut -> Hide('demo_pager_num');
$ext_nut -> Hide('demo_website');
$ext_nut -> Hide('demo_date_death');
$ext_nut -> Hide('date_death');
$ext_nut -> Hide('demo_date_birth');
$ext_nut -> Hide('date_birth');
$ext_nut -> Hide('demo_gender');
$ext_nut -> Hide('demo_county');
$ext_nut -> Hide('list_alumni_codes');
$ext_nut -> Hide('list_cde_codes');
$ext_nut -> Hide('list_ub_grad_progs');
$ext_nut -> Hide('notes_general');
$ext_nut -> Hide('notes_resume');
$ext_nut -> Hide('notes_additional');
$ext_nut -> Hide('photo');
$ext_nut -> Hide('ub_dds_degree');
$ext_nut -> Hide('ub_post_grad_degree');
$ext_nut -> Hide('specialty');
$ext_nut -> Hide('logo');
$ext_nut -> Hide('deceased');
$ext_nut -> Hide('mem_id');
$ext_nut -> Hide('mem_points');
$ext_nut -> Hide('blank_1');
$ext_nut -> Hide('blank_2');
$ext_nut -> Hide('blank_3');
$ext_nut -> Hide('blank_4');
}
//This person is not an admin and is looking at info of other people
else if($clsLogin->GetUserId() != $_GET['user_id'] && !$clsLogin->IsUserTypeLoggedIn('COMS Administrator')){
$addr_nuts -> Blacklist('priority');
$addr_nuts -> Blacklist('allow_mail');
$addr_nuts -> Blacklist('allow_email');
$addr_nuts -> Blacklist('allow_display');
$addr_nuts -> Blacklist('preferred');
$attributes_nut -> Hide('user_id');
$attributes_nut -> Hide('International_DDS_Program');
$attributes_nut -> Hide('UB_Staff');
$attributes_nut -> Hide('UB_Faculty');
$attributes_nut -> Hide('UB_PT_Faculty');
$attributes_nut -> Hide('Post_Grad_Resident');
$attributes_nut -> Hide('Retired');
$attributes_nut -> Hide('Speaker');
$attributes_nut -> Hide('Clinics_Groups');
$attributes_nut -> Hide('ACDE');
$attributes_nut -> Hide('Reviewed');
$attributes_nut -> Hide('Exhibitor');
$attributes_nut -> Hide('Company_Rep');
$attributes_nut -> Hide('Vendor');
$attributes_nut -> Hide('Advertiser');
$ext_nut -> Hide('demo_agd_number');
$ext_nut -> Hide('demo_spouse');
$ext_nut -> Hide('demo_former_name');
$ext_nut -> Hide('demo_ada_num');
$ext_nut -> Hide('demo_dental_school');
$ext_nut -> Hide('demo_year_graduated');
$ext_nut -> Hide('demo_specialty');
$ext_nut -> Hide('demo_ss_num');
$ext_nut -> Hide('demo_student_num');
$ext_nut -> Hide('demo_person_num');
$ext_nut -> Hide('demo_pager_num');
$ext_nut -> Hide('demo_website');
$ext_nut -> Hide('demo_date_death');
$ext_nut -> Hide('date_death');
$ext_nut -> Hide('demo_date_birth');
$ext_nut -> Hide('date_birth');
$ext_nut -> Hide('demo_gender');
$ext_nut -> Hide('demo_county');
$ext_nut -> Hide('list_alumni_codes');
$ext_nut -> Hide('list_cde_codes');
$ext_nut -> Hide('list_ub_grad_progs');
$ext_nut -> Hide('notes_general');
$ext_nut -> Hide('notes_resume');
$ext_nut -> Hide('notes_additional');
$ext_nut -> Hide('photo');
$ext_nut -> Hide('ub_dds_degree');
$ext_nut -> Hide('ub_post_grad_degree');
$ext_nut -> Hide('specialty');
$ext_nut -> Hide('logo');
$ext_nut -> Hide('deceased');
$ext_nut -> Hide('mem_id');
$ext_nut -> Hide('mem_points');
$ext_nut -> Hide('blank_1');
$ext_nut -> Hide('blank_2');
$ext_nut -> Hide('blank_3');
$ext_nut -> Hide('blank_4');
}
///////////////////////////////////////////////////////////////////////////////////////////
if($clsLogin->IsUserTypeLoggedIn('COMS Administrator')){
$uidele = new CFormElement("hidden", "user_id", "", $user_id);
$allow_mail = new CFormElement("select","allow_mail");
$allow_mail->SetOptions(array("No","Yes"), "allow_mail");
$allow_email = new CFormElement("select","allow_email");
$allow_email->SetOptions(array("No","Yes"), "allow_email");
$allow_display = new CFormElement("select","allow_display");
$allow_display->SetOptions(array("No","Yes"), "allow_display");
$addr_nuts->ReplaceFormElement("user_id",$uidele);
$addr_nuts->ReplaceFormElement("allow_mail", $allow_mail);
$addr_nuts->ReplaceFormElement("allow_email", $allow_email);
$addr_nuts->ReplaceFormElement("allow_display", $allow_display);
}
/**
* Show the required info only
*/
if($END_USER!==true){
}
/**
* Set the mappings.
*/
$ui_nut->SetTitleMapper($mapper);
$ext_nut->SetTitleMapper($mapper);
$addr_nuts->SetTitleMapper($mapper);
$attributes_nut->SetTitleMapper($mapper);
$company_nut->SetTitleMapper($mapper);
$states = new CDBSelectBox('states','state_province','state_name','state_abbreviation');
$ui_nut -> ReplaceFormElement('state_province', $states);
/**
* Set these in Tabs.
*/
//this function is defined in member_address_functions.php
$member_data = static_members($user_id);
?>
$tabs =& new CTabs();
$tabs->AddTab("User Info", $ui_nut->ToInputHtml());
$tabs->AddTab("Addresses", $member_data);
$tabs->AddTab("More Info", $ext_nut->ToInputHtml());
$tabs->AddTab("Attributes", $attributes_nut->ToInputHtml());
$tabs->AddTab("Company", $company_nut->ToInputHtml());
$REQUIRES_DYNAMIC_STYLES .= $tabs -> GetTabsCss();
//$js = $tabs -> GetTabsJs(); /* to make $tabs print no javascript. */ // commented by : Jet
/**
*
These are all of the functions required for these DBNuts.
Reformats a phone number to (3-digit area code or default area code) XXX-YYYY
*/
function reformatPhoneNum($phone_str){
$p = preg_replace('/\D/', '', $phone_str);
switch(strlen($p)){
case 7:
$p = substr($p,0,3).'-'.substr($p,3);
$p = "(".COMS_DEFAULT_AREA_CODE.") {$p}";
break;
case 10:
$p = '1'.$p;
case 11:
if(substr($p, 0, 1)==='1'){
$p = substr($p, 1);
$p = '('.substr($p,0,3).') '.substr($p,3,3).'-'.substr($p,6);
break;
} else { break; }
default:
return $phone_str;
}
return $p;
}
if($_GET['array'] != "false"){
include($_SERVER['APPLICATION_ROOT']."common/search_page.php");
}
?>
if($clsLogin->IsUserTypeLoggedIn('COMS Administrator') && $user_id) {?>
}?>