mirror of https://github.com/BOINC/boinc.git
Drupal: Bug fixes and layout changes.
Fixed bug where users could send message to users who did not exist. Changed autocomplete dropdown to use BOINC id in parenthesis. Removed dpm() debugging statements.
This commit is contained in:
parent
3d6c8c1071
commit
35a7f27c39
|
@ -2047,11 +2047,16 @@ function boincuser_apachesolr_index_documents_alter(array &$documents, $entity,
|
||||||
function boincuser_privatemsg_name_lookup($string) {
|
function boincuser_privatemsg_name_lookup($string) {
|
||||||
//Get the BOINC ID from the name string, and lookup the
|
//Get the BOINC ID from the name string, and lookup the
|
||||||
//corresponding drupal user.
|
//corresponding drupal user.
|
||||||
|
$boincname = substr($string, 0, strrpos($string, '_'));
|
||||||
$boincid = substr($string, strrpos($string, '_') + 1);
|
$boincid = substr($string, strrpos($string, '_') + 1);
|
||||||
$drupalid = get_drupal_id($boincid);
|
$drupalid = get_drupal_id($boincid);
|
||||||
dpm($drupalid, 'drupalid');
|
if ($drupalid>0) {
|
||||||
if ($recipient = user_load(array('uid' => $drupalid))) {
|
if ($recipient = user_load(array('uid' => $drupalid))) {
|
||||||
dpm($recipient, 'recipient in hook boincuser_privatemsg_name_lookup');
|
// Double-check that the loaded user matches both boincuser_id
|
||||||
|
// and boincuser_name.
|
||||||
|
if ( ($boincid == $recipient->boincuser_id) AND ($boincname == $recipient->boincuser_name) ) {
|
||||||
return $recipient;
|
return $recipient;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -877,8 +877,9 @@ function privatemsg_new(&$form_state, $recipients = array(), $subject = '', $thr
|
||||||
// Skip putting author in the recipients list for now.
|
// Skip putting author in the recipients list for now.
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
$to[] = $recipient->boincuser_name;
|
$myuser = user_load(array('uid' => $recipient->uid));
|
||||||
$to_themed[$recipient->uid] = $recipient->boincuser_name;
|
$to[] = $myuser->boincuser_name . "_" . $myuser->boincuser_id;
|
||||||
|
$to_themed[$recipient->uid] = $myuser->boincuser_name;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// Recipient list contains blocked users.
|
// Recipient list contains blocked users.
|
||||||
|
@ -888,10 +889,10 @@ function privatemsg_new(&$form_state, $recipients = array(), $subject = '', $thr
|
||||||
|
|
||||||
if (empty($to) && $usercount >= 1 && !$blocked) {
|
if (empty($to) && $usercount >= 1 && !$blocked) {
|
||||||
// Assume the user sent message to own account as if the usercount is one or less, then the user sent a message but not to self.
|
// Assume the user sent message to own account as if the usercount is one or less, then the user sent a message but not to self.
|
||||||
$to[] = $user->boincuser_name;
|
$myuser = user_load(array('uid' => $user->uid));
|
||||||
$to_themed[$user->uid] = $user->boincuser_name;
|
$to[] = $myuser->boincuser_name . "_" . $myuser->boincuser_id;
|
||||||
|
$to_themed[$user->uid] = $myuser->boincuser_name;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($to)) {
|
if (!empty($to)) {
|
||||||
$recipients_string = implode(', ', $to);
|
$recipients_string = implode(', ', $to);
|
||||||
}
|
}
|
||||||
|
@ -932,7 +933,7 @@ function privatemsg_new(&$form_state, $recipients = array(), $subject = '', $thr
|
||||||
$form['privatemsg']['recipient'] = array(
|
$form['privatemsg']['recipient'] = array(
|
||||||
'#type' => 'textfield',
|
'#type' => 'textfield',
|
||||||
'#title' => t('To'),
|
'#title' => t('To'),
|
||||||
'#description' => t('Separate multiple names with commas.'),
|
'#description' => t('Separate multiple names with commas. The number appearing in the suffix is the BOINC id. You can find a user\'s BOINC id on their user profile page.'),
|
||||||
'#default_value' => $recipients_string,
|
'#default_value' => $recipients_string,
|
||||||
'#required' => TRUE,
|
'#required' => TRUE,
|
||||||
'#weight' => -10,
|
'#weight' => -10,
|
||||||
|
@ -1434,7 +1435,7 @@ function privatemsg_user_name_autocomplete($string) {
|
||||||
$prefix = count($names) ? implode(", ", $names) .", " : '';
|
$prefix = count($names) ? implode(", ", $names) .", " : '';
|
||||||
// 3: Build proper suggestions and print.
|
// 3: Build proper suggestions and print.
|
||||||
while ($user = db_fetch_object($result)) {
|
while ($user = db_fetch_object($result)) {
|
||||||
$matches[$prefix . $user->name . "_" . $user->id . ", "] = $user->name . ' - BOINC id = ' . $user->id;
|
$matches[$prefix . $user->name . "_" . $user->id . ", "] = $user->name . '(' . $user->id . ')';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// convert to object to prevent drupal bug, see http://drupal.org/node/175361
|
// convert to object to prevent drupal bug, see http://drupal.org/node/175361
|
||||||
|
|
Loading…
Reference in New Issue