/**
* Summary of setLockedByMessage
* Shows 'Locked by ' message and proposes to request unlock from locker
**/
private function setLockedByMessage()
{
global $CFG_GLPI;
// should get locking user info
$user = new User();
$user->getFromDBByQuery(" WHERE id = " . $this->fields['users_id']);
$useremail = new UserEmail();
$showAskUnlock = $useremail->getFromDBByQuery(" WHERE users_id = " . $this->fields['users_id'] . "\n AND is_default = 1 ") && $CFG_GLPI['use_mailing'] == 1;
$completeUserName = formatUserName(0, $user->fields['name'], $user->fields['realname'], $user->fields['firstname']);
if ($showAskUnlock) {
$ret = Html::scriptBlock("\n function askUnlock() {\n \$('#message_after_lock').fadeToggle() ;\n " . Html::jsConfirmCallback(__('Ask for unlock item?'), $this->itemtypename . " #" . $this->itemid, "function() {\n \$.ajax({\n url: '" . $CFG_GLPI['root_doc'] . "/ajax/unlockobject.php',\n cache: false,\n data: 'requestunlock=1&id=" . $this->fields['id'] . "',\n success: function( jqXHR, textStatus ) {\n " . Html::jsAlertCallback($completeUserName, __('Request sent to'), "function() { \$('#message_after_lock').fadeToggle() ; }") . "\n }\n });\n }", "function() {\n \$('#message_after_lock').fadeToggle() ;\n }") . "\n }\n\n ");
echo $ret;
}
$msg = "<table><tr><td class=red nowrap>";
$msg .= __('Locked by ') . "<a href='" . $user->getLinkURL() . "'>{$completeUserName}</a> -> " . Html::convDateTime($this->fields['date_mod']);
$msg .= "</td><td nowrap>";
if ($showAskUnlock) {
$msg .= "<a class='vsubmit' onclick='javascript:askUnlock();'>" . __('Ask for unlock') . "</a>";
}
$msg .= "</td></tr></table>";
$this->displayLockMessage($msg);
}