/** * Generates the javascript code handle the "watchdog" associated with the concurrent access locking mechanism * @param Webpage $oPage * @param string $sOwnershipToken */ protected function GetOwnershipJSHandler($oPage, $sOwnershipToken) { $iInterval = max(MIN_WATCHDOG_INTERVAL, MetaModel::GetConfig()->Get('concurrent_lock_expiration_delay')) * 1000 / 2; // Minimum interval for the watchdog is MIN_WATCHDOG_INTERVAL $sJSClass = json_encode(get_class($this)); $iKey = (int) $this->GetKey(); $sJSToken = json_encode($sOwnershipToken); $sJSTitle = json_encode(Dict::S('UI:DisconnectedDlgTitle')); $sJSOk = json_encode(Dict::S('UI:Button:Ok')); $oPage->add_ready_script(<<<EOF \t\twindow.setInterval(function() { \t\t\tif (window.bInSubmit || window.bInCancel) return; \t\t\t \t\t\t\$.post(GetAbsoluteUrlAppRoot()+'pages/ajax.render.php', {operation: 'extend_lock', obj_class: {$sJSClass}, obj_key: {$iKey}, token: {$sJSToken} }, function(data) { \t\t\t\tif (!data.status) \t\t\t\t{ \t\t\t\t\tif (\$('.lock_owned').length == 0) \t\t\t\t\t{ \t\t\t\t\t\t\$('.ui-layout-content').prepend('<div class="header_message message_error lock_owned">'+data.message+'</div>'); \t\t\t\t\t\t\$('<div>'+data.popup_message+'</div>').dialog({title: {$sJSTitle}, modal: true, autoOpen: true, buttons:[ {text: {$sJSOk}, click: function() { \$(this).dialog('close'); } }], close: function() { \$(this).remove(); }}); \t\t\t\t\t} \t\t\t\t\t\$('.wizContainer form button.action:not(.cancel)').attr('disabled', 'disabled'); \t\t\t\t} \t\t\t\telse if ((data.operation == 'lost') || (data.operation == 'expired')) \t\t\t\t{ \t\t\t\t\tif (\$('.lock_owned').length == 0) \t\t\t\t\t{ \t\t\t\t\t\t\$('.ui-layout-content').prepend('<div class="header_message message_error lock_owned">'+data.message+'</div>'); \t\t\t\t\t\t\$('<div>'+data.popup_message+'</div>').dialog({title: {$sJSTitle}, modal: true, autoOpen: true, buttons:[ {text: {$sJSOk}, click: function() { \$(this).dialog('close'); } }], close: function() { \$(this).remove(); }}); \t\t\t\t\t} \t\t\t\t\t\$('.wizContainer form button.action:not(.cancel)').attr('disabled', 'disabled'); \t\t\t\t} \t\t\t}, 'json'); \t\t}, {$iInterval}); EOF ); }