public function NewPM(vB_DataManager_PM &$pmdm) { if ($this->vbulletin->options['dle_onoff'] && $this->vbulletin->options['dle_pm']) { $user_from = $pmdm->pmtext['fromusername']; $to_user = $pmdm->pmtext['touserarray']; $subj = $pmdm->pmtext['title']; $text = $pmdm->pmtext['message']; $send = "<b>Это сообщение было отправленно c форума следующим пользователям: </b>"; $text = $this->_parseBB($text); // $text = preg_replace('#<!--.*?-->#si', "", $text); if (DLE_CHARSET && DLE_CHARSET != $this->vbulletin->userinfo['lang_charset']) { $user_from = iconv($this->vbulletin->userinfo['lang_charset'], DLE_CHARSET, $user_from); $to_user = iconv($this->vbulletin->userinfo['lang_charset'], DLE_CHARSET, $to_user); $subj = iconv($this->vbulletin->userinfo['lang_charset'], DLE_CHARSET, $subj); $text = iconv($this->vbulletin->userinfo['lang_charset'], DLE_CHARSET, $text); // $send = iconv($this->vbulletin->userinfo['lang_charset'], DLE_CHARSET, $send); } if (strtolower($this->vbulletin->userinfo['lang_charset']) != 'utf-8') { $send = iconv('utf-8', $this->vbulletin->userinfo['lang_charset'], $send); } $to_user = unserialize($to_user); $this->_db_connect(); $subj = $this->db->escape_string($subj); $text = $this->db->escape_string($text); $user_from = $this->db->escape_string($user_from); if (empty($to_user['cc'])) { if (!empty($to_user['bcc'])) { $to_user_a = $to_user['bcc']; } else { $this->_db_disconnect(); return; } } else { $to_user_a = $to_user['cc']; } $to_user_name = array(); foreach ($to_user_a as $user) { if (DLE_CHARSET && DLE_CHARSET != $this->vbulletin->userinfo['lang_charset']) { $user = iconv($this->vbulletin->userinfo['lang_charset'], DLE_CHARSET, $user); } $to_user_name[] = $this->db->escape_string($user); } $result_users = $this->db->query_read("SELECT user_id, name FROM " . USERPREFIX . "_users WHERE name IN('" . implode("','", $to_user_name) . "')"); if ($this->db->num_rows($result_users)) { $i = 0; $send_user_array = $users_id = array(); $values = ''; while ($value = $this->db->fetch_array($result_users)) { $users_id[] = $value['user_id']; if (in_array($value['user_id'], $send_user_array)) { continue; } if ($i != 0) { $send .= ", "; $values .= ", "; } $send .= "<a href=\"{$config['http_home_url']}index.php?subaction=userinfo&user={$value['name']}\" >{$value['name']}</a>"; $values .= "('{$subj}', '{$text}', '{$value['user_id']}', '{$user_from}', '{$pmdm->pmtext['dateline']}', 'no', 'inbox')"; $send_user_array[] = $value['user_id']; $i++; } $this->db->query_write("INSERT INTO " . USERPREFIX . "_pm (subj, text, user, user_from, date, pm_read, folder) VALUES {$values}"); $this->db->query_write("UPDATE " . USERPREFIX . "_users SET pm_all=pm_all+1, pm_unread=pm_unread+1 WHERE user_id IN('" . implode("','", $users_id) . "')"); if ($pmdm->info['savecopy']) { $user = $users_id[0]; if ($user) { if ($i > 1) { $text = $this->db->escape_string($send) . "<hr></br></br>" . $text; } $this->db->query_write("INSERT INTO " . USERPREFIX . "_pm (subj, text, user, user_from, date, pm_read, folder) values ('{$subj}', '{$text}', '{$user}', '{$user_from}', '{$pmdm->pmtext['dateline']}', 'yes', 'outbox')"); $this->db->query_write("UPDATE " . USERPREFIX . "_users SET pm_all=pm_all+1 where name='{$user_from}'"); } } } $this->_db_disconnect(); } }