/**
  * @desc Send a PM to a member.
  * @param string $pm_type Type of PM ('assigned', 'comment', 'pending', 'in_progress', 'delete', 'edit', 'fixed', 'rejected', 'reopen')
  * @param int $recipient_id ID of the PM's recipient
  * @param int $bug_id ID of the bug which is concerned
  * @param string $message (optional) Message to include in the PM
  */
 public static function send_PM($pm_type, $recipient_id, $bug_id, $message = '')
 {
     //Load module lang
     $lang = LangLoader::get('common', 'bugtracker');
     //Send the PM if the recipient is not a guest
     if ($recipient_id > 0) {
         //Get current user
         $current_user = AppContext::get_current_user();
         $author = $current_user->get_id() != User::VISITOR_LEVEL ? $current_user->get_display_name() : LangLoader::get_message('visitor', 'user-common');
         $pm_content = StringVars::replace_vars($lang['pm.' . $pm_type . '.contents'], array('author' => $author, 'id' => $bug_id)) . (!empty($message) ? $pm_type != 'edit' ? StringVars::replace_vars($lang['pm.with_comment'], array('comment' => $message)) : StringVars::replace_vars($lang['pm.edit_fields'], array('fields' => $message)) : '') . ($pm_type != 'delete' ? StringVars::replace_vars($lang['pm.bug_link'], array('link' => BugtrackerUrlBuilder::detail($bug_id)->relative())) : '');
         //Send the PM
         PrivateMsg::start_conversation($recipient_id, StringVars::replace_vars($lang['pm.' . $pm_type . '.title'], array('id' => $bug_id)), $pm_content, -1, PrivateMsg::SYSTEM_PM);
     }
 }
Пример #2
0
 function Add_msg($idtopic, $idcat, $contents, $title, $last_page, $last_page_rewrite, $new_topic = false)
 {
     global $CONFIG, $Sql, $User, $CAT_FORUM, $LANG;
     ##### Insertion message #####
     $last_timestamp = time();
     $Sql->query_inject("INSERT INTO " . PREFIX . "forum_msg (idtopic, user_id, contents, timestamp, timestamp_edit, user_id_edit, user_ip) VALUES ('" . $idtopic . "', '" . $User->get_attribute('user_id') . "', '" . strparse($contents) . "', '" . $last_timestamp . "', '0', '0', '" . USER_IP . "')", __LINE__, __FILE__);
     $last_msg_id = $Sql->insert_id("SELECT MAX(id) FROM " . PREFIX . "forum_msg");
     $Sql->query_inject("UPDATE " . PREFIX . "forum_topics SET " . ($new_topic ? '' : 'nbr_msg = nbr_msg + 1, ') . "last_user_id = '" . $User->get_attribute('user_id') . "', last_msg_id = '" . $last_msg_id . "', last_timestamp = '" . $last_timestamp . "' WHERE id = '" . $idtopic . "'", __LINE__, __FILE__);
     $Sql->query_inject("UPDATE " . PREFIX . "forum_cats SET last_topic_id = '" . $idtopic . "', nbr_msg = nbr_msg + 1" . ($new_topic ? ', nbr_topic = nbr_topic + 1' : '') . " WHERE id_left <= '" . $CAT_FORUM[$idcat]['id_left'] . "' AND id_right >= '" . $CAT_FORUM[$idcat]['id_right'] . "' AND level <= '" . $CAT_FORUM[$idcat]['level'] . "'", __LINE__, __FILE__);
     $Sql->query_inject("UPDATE " . DB_TABLE_MEMBER . " SET user_msg = user_msg + 1 WHERE user_id = '" . $User->get_attribute('user_id') . "'", __LINE__, __FILE__);
     mark_topic_as_read($idtopic, $last_msg_id, $last_timestamp);
     ##### Gestion suivi du sujet mp/mail #####
     if (!$new_topic) {
         $previous_msg_id = $Sql->query("SELECT MAX(id) FROM " . PREFIX . "forum_msg WHERE idtopic = '" . $idtopic . "' AND id < '" . $last_msg_id . "'", __LINE__, __FILE__);
         $title_subject = html_entity_decode($title, ENT_COMPAT, 'ISO-8859-1');
         $title_subject_pm = '[url=' . HOST . DIR . '/forum/topic' . url('.php?id=' . $idtopic . $last_page, '-' . $idtopic . $last_page_rewrite . '.php') . '#m' . $previous_msg_id . ']' . $title_subject . '[/url]';
         if ($User->get_attribute('user_id') > 0) {
             $pseudo = $Sql->query("SELECT login FROM " . DB_TABLE_MEMBER . " WHERE user_id = '" . $User->get_attribute('user_id') . "'", __LINE__, __FILE__);
             $pseudo_pm = '[url=' . HOST . DIR . '/member/member.php?id=' . $User->get_attribute('user_id') . ']' . $pseudo . '[/url]';
         } else {
             $pseudo = $LANG['guest'];
             $pseudo_pm = $LANG['guest'];
         }
         $next_msg_link = HOST . DIR . '/forum/topic' . url('.php?id=' . $idtopic . $last_page, '-' . $idtopic . $last_page_rewrite . '.php') . '#m' . $previous_msg_id;
         $preview_contents = substr($contents, 0, 300);
         import('io/mail');
         $Mail = new Mail();
         import('members/pm');
         $Privatemsg = new PrivateMsg();
         $max_time = time() - $CONFIG['site_session_invit'];
         $result = $Sql->query_while("SELECT m.user_id, m.login, m.user_mail, tr.pm, tr.mail, v.last_view_id\n\t\t\tFROM " . PREFIX . "forum_track tr\n\t\t\tLEFT JOIN " . DB_TABLE_MEMBER . " m ON m.user_id = tr.user_id\n\t\t\tLEFT JOIN " . PREFIX . "forum_view v ON v.idtopic = '" . $idtopic . "' AND v.user_id = tr.user_id\n\t\t\tWHERE tr.idtopic = '" . $idtopic . "' AND v.last_view_id IS NOT NULL AND m.user_id != '" . $User->get_attribute('user_id') . "'", __LINE__, __FILE__);
         while ($row = $Sql->fetch_assoc($result)) {
             if ($row['last_view_id'] == $previous_msg_id && $row['mail'] == '1') {
                 $Mail->send_from_properties($row['user_mail'], $LANG['forum_mail_title_new_post'], sprintf($LANG['forum_mail_new_post'], $row['login'], $title_subject, $User->get_attribute('login'), $preview_contents, $next_msg_link, HOST . DIR . '/forum/action.php?ut=' . $idtopic . '&trt=1', 1), $CONFIG['mail_exp']);
             }
             if ($row['last_view_id'] == $previous_msg_id && $row['pm'] == '1') {
                 $Privatemsg->start_conversation($row['user_id'], addslashes($LANG['forum_mail_title_new_post']), sprintf($LANG['forum_mail_new_post'], $row['login'], $title_subject_pm, $User->get_attribute('login'), $preview_contents, '[url]' . $next_msg_link . '[/url]', '[url]' . HOST . DIR . '/forum/action.php?ut=' . $idtopic . '&trt=2[/url]'), '-1', SYSTEM_PM);
             }
         }
         forum_generate_feeds();
     }
     return $last_msg_id;
 }
Пример #3
0
 function Add_msg($idtopic, $idcat, $contents, $title, $last_page, $last_page_rewrite, $new_topic = false)
 {
     global $LANG;
     ##### Insertion message #####
     $last_timestamp = time();
     $result = PersistenceContext::get_querier()->insert(PREFIX . 'forum_msg', array('idtopic' => $idtopic, 'user_id' => AppContext::get_current_user()->get_id(), 'contents' => FormatingHelper::strparse($contents), 'timestamp' => $last_timestamp, 'timestamp_edit' => 0, 'user_id_edit' => 0, 'user_ip' => AppContext::get_request()->get_ip_address()));
     $last_msg_id = $result->get_last_inserted_id();
     //Topic
     PersistenceContext::get_querier()->inject("UPDATE " . PREFIX . "forum_topics SET " . ($new_topic ? '' : 'nbr_msg = nbr_msg + 1, ') . "last_user_id = '" . AppContext::get_current_user()->get_id() . "', last_msg_id = '" . $last_msg_id . "', last_timestamp = '" . $last_timestamp . "' WHERE id = '" . $idtopic . "'");
     //On met à jour le last_topic_id dans la catégorie dans le lequel le message a été posté
     PersistenceContext::get_querier()->update(ForumSetup::$forum_cats_table, array('last_topic_id' => $idtopic), 'WHERE id = :id', array('id' => $idcat));
     //Mise à jour du nombre de messages du membre.
     PersistenceContext::get_querier()->inject("UPDATE " . DB_TABLE_MEMBER . " SET posted_msg = posted_msg + 1 WHERE user_id = '" . AppContext::get_current_user()->get_id() . "'");
     //On marque le topic comme lu.
     mark_topic_as_read($idtopic, $last_msg_id, $last_timestamp);
     ##### Gestion suivi du sujet mp/mail #####
     if (!$new_topic) {
         //Message précédent ce nouveau message.
         $previous_msg_id = 0;
         try {
             $previous_msg_id = PersistenceContext::get_querier()->get_column_value(PREFIX . "forum_msg", 'MAX(id)', 'WHERE idtopic = :idtopic AND id < :id', array('idtopic' => $idtopic, 'id' => $last_msg_id));
         } catch (RowNotFoundException $e) {
         }
         $title_subject = TextHelper::html_entity_decode($title);
         $title_subject_pm = $title_subject;
         if (AppContext::get_current_user()->get_id() > 0) {
             $pseudo = '';
             try {
                 $pseudo = PersistenceContext::get_querier()->get_column_value(DB_TABLE_MEMBER, 'display_name', 'WHERE user_id = :id', array('id' => AppContext::get_current_user()->get_id()));
             } catch (RowNotFoundException $e) {
             }
             $pseudo_pm = '<a href="' . UserUrlBuilder::profile(AppContext::get_current_user()->get_id())->rel() . '">' . $pseudo . '</a>';
         } else {
             $pseudo = $LANG['guest'];
             $pseudo_pm = $LANG['guest'];
         }
         $next_msg_link = '/forum/topic' . url('.php?id=' . $idtopic . $last_page, '-' . $idtopic . $last_page_rewrite . '.php') . ($previous_msg_id ? '#m' . $previous_msg_id : '');
         $preview_contents = substr($contents, 0, 300);
         //Récupération des membres suivant le sujet.
         $max_time = time() - SessionsConfig::load()->get_active_session_duration();
         $result = PersistenceContext::get_querier()->select("SELECT m.user_id, m.display_name, m.email, tr.pm, tr.mail, v.last_view_id\n\t\t\tFROM " . PREFIX . "forum_track tr\n\t\t\tLEFT JOIN " . DB_TABLE_MEMBER . " m ON m.user_id = tr.user_id\n\t\t\tLEFT JOIN " . PREFIX . "forum_view v ON v.idtopic = :idtopic AND v.user_id = tr.user_id\n\t\t\tWHERE tr.idtopic = :idtopic AND v.last_view_id IS NOT NULL AND m.user_id != :user_id", array('idtopic' => $idtopic, 'user_id' => AppContext::get_current_user()->get_id()));
         while ($row = $result->fetch()) {
             //Envoi un Mail à ceux dont le last_view_id est le message précedent.
             if ($row['last_view_id'] == $previous_msg_id && $row['mail'] == '1') {
                 AppContext::get_mail_service()->send_from_properties($row['email'], $LANG['forum_mail_title_new_post'], sprintf($LANG['forum_mail_new_post'], $row['display_name'], $title_subject, AppContext::get_current_user()->get_display_name(), $preview_contents, HOST . DIR . $next_msg_link, HOST . DIR . '/forum/action.php?ut=' . $idtopic . '&trt=1', 1));
             }
             //Envoi un MP à ceux dont le last_view_id est le message précedent.
             if ($row['last_view_id'] == $previous_msg_id && $row['pm'] == '1') {
                 $content = sprintf($LANG['forum_mail_new_post'], $row['display_name'], $title_subject_pm, AppContext::get_current_user()->get_display_name(), $preview_contents, '<a href="' . $next_msg_link . '">' . $next_msg_link . '</a>', '<a href="/forum/action.php?ut=' . $idtopic . '&trt=2">/forum/action.php?ut=' . $idtopic . '&trt=2</a>');
                 PrivateMsg::start_conversation($row['user_id'], $LANG['forum_mail_title_new_post'], nl2br($content), '-1', PrivateMsg::SYSTEM_PM);
             }
         }
         $result->dispose();
         forum_generate_feeds();
         //Regénération du flux rss.
     }
     return $last_msg_id;
 }
Пример #4
0
				}
			}' . "\n" . 'if (replace_value != \'' . addslashes($LANG['no']) . '\')' . "\n" . '{' . "\n" . 'contents = contents.replace(regex, replace_value);' . "\n" . 'document.getElementById(\'action_contents\').disabled = \'\'' . "\n" . '} else' . "\n" . '	document.getElementById(\'action_contents\').disabled = \'disabled\';' . "\n" . 'document.getElementById(\'action_info\').innerHTML = replace_value;}', 'REGEX' => '/[0-9]+ [a-zA-Z]+/', 'L_ALTERNATIVE_PM' => $LANG['user_alternative_pm'], 'L_INFO_EXPLAIN' => $LANG['user_readonly_explain'], 'L_PM' => $LANG['user_contact_pm'], 'L_LOGIN' => $LANG['pseudo'], 'L_PM' => $LANG['user_contact_pm'], 'L_CHANGE_INFO' => $LANG['submit'], 'U_PM' => url('.php?pm=' . $id_get, '-' . $id_get . '.php'), 'U_ACTION_INFO' => url('.php?action=punish&amp;id=' . $id_get . '&amp;token=' . $Session->get_token())));
    }
} elseif ($action == 'warning') {
    $new_warning_level = retrieve(POST, 'new_info', 0);
    $warning_contents = retrieve(POST, 'action_contents', '', TSTRING_UNCHANGE);
    if ($new_warning_level >= 0 && $new_warning_level <= 100 && !empty($id_get) && retrieve(POST, 'valid_user', false)) {
        $info_mbr = $Sql->query_array(DB_TABLE_MEMBER, 'user_id', 'level', 'user_mail', "WHERE user_id = '" . $id_get . "'", __LINE__, __FILE__);
        if (!empty($info_mbr['user_id']) && ($info_mbr['level'] < 2 || $User->check_level(ADMIN_LEVEL))) {
            if ($new_warning_level < 100) {
                $Sql->query_inject("UPDATE " . DB_TABLE_MEMBER . " SET user_warning = '" . $new_warning_level . "' WHERE user_id = '" . $info_mbr['user_id'] . "'", __LINE__, __FILE__);
                if ($info_mbr['user_id'] != $User->get_attribute('user_id')) {
                    if (!empty($warning_contents)) {
                        import('members/pm');
                        $Privatemsg = new PrivateMsg();
                        $Privatemsg->start_conversation($info_mbr['user_id'], addslashes($LANG['warning_title']), $warning_contents, '-1', SYSTEM_PM);
                    }
                }
                forum_history_collector(H_SET_WARNING_USER, $info_mbr['user_id'], 'moderation_forum.php?action=warning&id=' . $info_mbr['user_id']);
            } elseif ($new_warning_level == 100) {
                $Sql->query_inject("UPDATE " . DB_TABLE_MEMBER . " SET user_warning = 100 WHERE user_id = '" . $info_mbr['user_id'] . "'", __LINE__, __FILE__);
                $Sql->query_inject("DELETE FROM " . DB_TABLE_SESSIONS . " WHERE user_id = '" . $info_mbr['user_id'] . "'", __LINE__, __FILE__);
                forum_history_collector(H_BAN_USER, $info_mbr['user_id'], 'moderation_forum.php?action=warning&id=' . $info_mbr['user_id']);
                import('io/mail');
                $Mail = new Mail();
                $Mail->send_from_properties($info_mbr['user_mail'], addslashes($LANG['ban_title_mail']), sprintf(addslashes($LANG['ban_mail']), HOST, addslashes($CONFIG['sign'])), $CONFIG['mail_exp']);
            }
        }
        redirect(HOST . DIR . '/forum/moderation_forum' . url('.php?action=warning', '', '&'));
    }
    $Template->assign_vars(array('MODULE_DATA_PATH' => $Template->get_module_data_path('forum'), 'L_FORUM' => $LANG['forum'], 'L_LOGIN' => $LANG['pseudo'], 'L_MODERATION_PANEL' => $LANG['moderation_panel'], 'L_MODERATION_FORUM' => $LANG['moderation_forum'], 'L_INFO_MANAGEMENT' => $LANG['warning_management'], 'U_XMLHTTPREQUEST' => 'warning_moderation_panel', 'U_MODERATION_FORUM_ACTION' => '&raquo; <a href="moderation_forum.php' . url('?action=warning&amp;token=' . $Session->get_token()) . '">' . $LANG['warning_management'] . '</a>', 'U_ACTION' => url('.php?action=warning&amp;token=' . $Session->get_token())));
 private static function send_mp($user_id, $title, $content)
 {
     PrivateMsg::start_conversation($user_id, addslashes($title), nl2br($content), '-1', PrivateMsg::SYSTEM_PM);
 }
Пример #6
0
 $title = retrieve(POST, 'title', '');
 $contents = retrieve(POST, 'contents', '', TSTRING_UNCHANGE);
 $login = retrieve(POST, 'login', '');
 $limit_group = $current_user->check_max_value(PM_GROUP_LIMIT, $user_accounts_config->get_max_private_messages_number());
 //Vérification de la boite de l'expéditeur.
 if (PrivateMsg::count_conversations($current_user->get_id()) >= $limit_group && (!$current_user->check_level(User::MODERATOR_LEVEL) && !($limit_group === -1))) {
     //Boîte de l'expéditeur pleine.
     AppContext::get_response()->redirect('/user/pm' . url('.php?post=1&error=e_pm_full_post', '', '&') . '#message_helper');
 }
 if (!empty($title) && !empty($contents) && !empty($login)) {
     //On essaye de récupérer le user_id, si le membre n'a pas cliqué une fois la recherche AJAX terminée.
     $user_id_dest = PersistenceContext::get_querier()->get_column_value(DB_TABLE_MEMBER, 'user_id', 'WHERE display_name = :name', array('name' => $login));
     if (!empty($user_id_dest) && $user_id_dest != $current_user->get_id()) {
         $contents = FormatingHelper::strparse($contents, array(), false);
         //Envoi de la conversation, vérification de la boite si pleine => erreur
         list($pm_convers_id, $pm_msg_id) = PrivateMsg::start_conversation($user_id_dest, $title, $contents, $current_user->get_id());
         //Envoi d'un mail si l'utilisateur a activé l'option
         $pmtomail_field = ExtendedFieldsCache::load()->get_extended_field_by_field_name('user_pmtomail');
         if (!empty($pmtomail_field) && $pmtomail_field['display']) {
             if (PersistenceContext::get_querier()->get_column_value(DB_TABLE_MEMBER_EXTENDED_FIELDS, 'user_pmtomail', 'WHERE user_id = :id', array('id' => $user_id_dest))) {
                 $email_dest = PersistenceContext::get_querier()->get_column_value(DB_TABLE_MEMBER, 'email', 'WHERE user_id = :id', array('id' => $user_id_dest));
                 AppContext::get_mail_service()->send_from_properties($email_dest, $LANG['new_pm'] . ' : ' . $title, $contents);
             }
         }
         //Succès redirection vers la conversation.
         AppContext::get_response()->redirect('/user/pm' . url('.php?id=' . $pm_convers_id, '-0-' . $pm_convers_id . '.php', '&') . '#m' . $pm_msg_id);
     } else {
         //Destinataire non trouvé.
         AppContext::get_response()->redirect('/user/pm' . url('.php?post=1&error=e_unexist_user', '', '&') . '#message_helper');
     }
 } else {
Пример #7
0
    $Sql->query_inject("UPDATE " . DB_TABLE_MEMBER . " SET user_pm = '" . $nbr_waiting_pm . "' WHERE user_id = '" . $User->get_attribute('user_id') . "'", __LINE__, __FILE__);
    redirect(HOST . DIR . url('/member/pm.php', '', '&'));
}
$convers = retrieve(POST, 'convers', false);
if ($convers && empty($pm_edit) && empty($pm_del)) {
    $title = retrieve(POST, 'title', '');
    $contents = retrieve(POST, 'contents', '', TSTRING_UNCHANGE);
    $login = retrieve(POST, 'login', '');
    $limit_group = $User->check_max_value(PM_GROUP_LIMIT, $CONFIG['pm_max']);
    if ($Privatemsg->count_conversations($User->get_attribute('user_id')) >= $limit_group && (!$User->check_level(MODO_LEVEL) && !($limit_group === -1))) {
        redirect(HOST . DIR . '/member/pm' . url('.php?post=1&error=e_pm_full_post', '', '&') . '#errorh');
    }
    if (!empty($title) && !empty($contents) && !empty($login)) {
        $user_id_dest = $Sql->query("SELECT user_id FROM " . DB_TABLE_MEMBER . " WHERE login = '******'", __LINE__, __FILE__);
        if (!empty($user_id_dest) && $user_id_dest != $User->get_attribute('user_id')) {
            $Privatemsg->start_conversation($user_id_dest, $title, $contents, $User->get_attribute('user_id'));
            redirect(HOST . DIR . '/member/pm' . url('.php?id=' . $Privatemsg->pm_convers_id, '-0-' . $Privatemsg->pm_convers_id . '.php', '&') . '#m' . $Privatemsg->pm_msg_id);
        } else {
            redirect(HOST . DIR . '/member/pm' . url('.php?post=1&error=e_unexist_user', '', '&') . '#errorh');
        }
    } else {
        redirect(HOST . DIR . '/member/pm' . url('.php?post=1&error=e_incomplete', '', '&') . '#errorh');
    }
} elseif (!empty($post) || !empty($pm_get) && $pm_get != $User->get_attribute('user_id') && $pm_get > '0') {
    $Template->set_filenames(array('pm' => 'member/pm.tpl'));
    $Template->assign_vars(array('LANG' => get_ulang(), 'THEME' => get_utheme(), 'KERNEL_EDITOR' => display_editor(), 'L_REQUIRE_RECIPIENT' => $LANG['require_recipient'], 'L_REQUIRE_MESSAGE' => $LANG['require_text'], 'L_REQUIRE_TITLE' => $LANG['require_title'], 'L_REQUIRE' => $LANG['require'], 'L_PRIVATE_MESSAGE' => $LANG['private_message'], 'L_POST_NEW_CONVERS' => $LANG['post_new_convers'], 'L_RECIPIENT' => $LANG['recipient'], 'L_SEARCH' => $LANG['search'], 'L_TITLE' => $LANG['title'], 'L_MESSAGE' => $LANG['message'], 'L_SUBMIT' => $LANG['submit'], 'L_PREVIEW' => $LANG['preview'], 'L_RESET' => $LANG['reset']));
    $login = !empty($pm_get) ? $Sql->query("SELECT login FROM " . DB_TABLE_MEMBER . " WHERE user_id = '" . $pm_get . "'", __LINE__, __FILE__) : '';
    $Template->assign_block_vars('post_convers', array('U_ACTION_CONVERS' => url('.php?token=' . $Session->get_token()), 'U_PM_BOX' => '<a href="pm.php' . SID . '">' . $LANG['pm_box'] . '</a>', 'U_USER_VIEW' => '<a href="' . url('member.php?id=' . $User->get_attribute('user_id') . '&amp;view=1', 'member-' . $User->get_attribute('user_id') . '.php?view=1') . '">' . $LANG['member_area'] . '</a>', 'LOGIN' => $login));
    $limit_group = $User->check_max_value(PM_GROUP_LIMIT, $CONFIG['pm_max']);
    $nbr_pm = $Privatemsg->count_conversations($User->get_attribute('user_id'));
    if (!$User->check_level(MODO_LEVEL) && !($limit_group === -1) && $nbr_pm >= $limit_group) {