Jump to content

Моментально Оповещения о новом сообщении


Recommended Posts

Заходим в /system/modules/messages.php и ищем следующие строки:

mozg_clear_cache_file('user_'.$for_user_id.'/im');
mozg_create_cache('user_'.$for_user_id.'/im_update', '1');

и ниже вставляем:
//Вставляем событие в моментальные оповещания
$row_owner = $db->super_query("SELECT user_last_visit FROM `".PREFIX."_users` WHERE user_id = '{$for_user_id}'");
$update_time = $server_time - 70;

if($row_owner['user_last_visit'] >= $update_time){

$db->query("INSERT INTO `".PREFIX."_updates` SET for_user_id = '{$for_user_id}', from_user_id = '{$user_info['user_id']}', type = '8', date = '{$server_time}', text = '{$msg}', user_photo = '{$user_info['user_photo']}', user_search_pref = '{$user_info['user_search_pref']}', lnk = '/messages'");

mozg_create_cache("user_{$for_user_id}/updates", 1);

}

Далее заходим в /system/modules/im.php и ищем следующий код:

$check_im_2 = $db->super_query("SELECT iuser_id FROM ".PREFIX."_im WHERE iuser_id = '".$for_user_id."' AND im_user_id = '".$user_id."'");
if(!$check_im_2)
$db->query("INSERT INTO ".PREFIX."_im SET iuser_id = '".$for_user_id."', im_user_id = '".$user_id."', msg_num = 1, idate = '".$server_time."', all_msg_num = 1");
else
$db->query("UPDATE ".PREFIX."_im SET idate = '".$server_time."', msg_num = msg_num 1, all_msg_num = all_msg_num 1 WHERE iuser_id = '".$for_user_id."' AND im_user_id = '".$user_id."'");

и ниже вставляем:
//Вставляем событие в моментальные оповещания
$row_owner = $db->super_query("SELECT user_last_visit FROM `".PREFIX."_users` WHERE user_id = '{$for_user_id}'");
$update_time = $server_time - 70;

if($row_owner['user_last_visit'] >= $update_time){

$db->query("INSERT INTO `".PREFIX."_updates` SET for_user_id = '{$for_user_id}', from_user_id = '{$user_info['user_id']}', type = '8', date = '{$server_time}', text = '{$msg}', user_photo = '{$user_info['user_photo']}', user_search_pref = '{$user_info['user_search_pref']}', lnk = '/messages'");

mozg_create_cache("user_{$for_user_id}/updates", 1);

}

Теперь идём в админку и редактируем main.tpl
Ищем:

else if(row[0] == 4) uTitle = 'Новый комментарий к заметке';

и ниже вставляем: 

else if(row[0] == 8) uTitle = 'Новое сообщение';

Далее находим:

else uTitle = 'Событие';

и ниже вставляем:
if(row[0] == 8){
sli = row[6].split('/');
tURL = (location.href).replace('http://' location.host, '').replace('/', '').split('#');
if(!sli[2] && tURL[0] == 'messages') return false;
if($('#new_msg').text()) msg_num = parseInt($('#new_msg').text().replace(')', '').replace('(', '')) 1;
else msg_num = 1;
$('#new_msg').html("<div class="headm_newac" style="margin-left:37px"> " msg_num "</div>");
}


Вот и все!

 

  • Upvote 1
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

×
×
  • Create New...