//begin custom code by michaelest
function get_user_is_qualified($add_blank=true, $status="Active", $assigned_user="", $use_real_name=false, $user_name_begins = null, $is_group=' AND is_group=0 ') { //'function get_user_is_qualified' instead of 'function get_user_array'
global $locale;
global $sugar_config;
if(empty($locale)) {
require_once('include/Localization/Localization.php');
$locale = new Localization();
}
$db = & PearDatabase::getInstance();
$temp_result = Array();
// Including deleted users for now.
if (empty($status)) {
$query = "SELECT id, first_name, last_name, user_name from users, users_cstm WHERE users.id=users_cstm.id_c AND 1=1".$is_group; //I look up in two tables 'users' and 'users_cstm'
}
else {
$query = "SELECT id, first_name, last_name, user_name from users , users_cstm WHERE users.id=users_cstm.id_c AND status='$status'".$is_group; //I look up in two tables 'users' and 'users_cstm'
}
if (!empty($user_name_begins)) {
$query .= " AND user_name LIKE '$user_name_begins%' ";
}
if (!empty($assigned_user)) {
$query .= " OR id='$assigned_user'";
}
$query = $query.' AND users_cstm.is_qualified_c=1'; //look in 'users_cstm' to match users who 'is_qualified=1'
$query = $query.' ORDER BY user_name ASC';
$GLOBALS['log']->debug("get_user_array query: $query");
$result = $db->query($query, true, "Error filling in user array: ");
if ($add_blank==true) {
// Add in a blank row
$temp_result[''] = '';
}
// Get the id and the name.
while($row = $db->fetchByAssoc($result)) {
if($use_real_name == true || showFullName()) {
if(isset($row['last_name'])) { // cn: we will ALWAYS have both first_name and last_name (empty value if blank in db)
$temp_result[$row['id']] = $locale->getLocaleFormattedName($row['first_name'],$row['last_name']);
} else {
$temp_result[$row['id']] = $row['user_name'];
}
} else {
$temp_result[$row['id']] = $row['user_name'];
}
}
$user_array = $temp_result;
//set_register_value('user_array', $add_blank. $status . $assigned_user, $temp_result);
return $user_array;
}
//end custom by michaelest {
Bookmarks