示例#1
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;
 }
 /**
  * @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);
     }
 }
示例#3
0
</th>
            <th class="cel_creation_date essential"><?php 
echo Ajax::text('?page=browse&action=set_sort&browse_id=' . $browse->id . '&type=pvmsg&sort=creation_date', T_('Date'), 'pvmsg_sort_creation_date');
?>
</th>
            <th class="cel_action essential"><?php 
echo T_('Action');
?>
</th>
        </tr>
    </thead>
    <tbody>
        <?php 
/* Foreach through every label that has been passed to us */
foreach ($object_ids as $pvmg_id) {
    $libitem = new PrivateMsg($pvmg_id);
    $libitem->format();
    ?>
        <tr id="label_<?php 
    echo $libitem->id;
    ?>
" class="<?php 
    echo UI::flip_class();
    ?>
 <?php 
    echo !$libitem->is_read ? "unread" : "";
    ?>
">
            <?php 
    require AmpConfig::get('prefix') . UI::find_template('show_pvmsg_row.inc.php');
    ?>
示例#4
0
    ?>
"><?php 
    echo $GLOBALS['user']->fullname;
    ?>
</a>
                            <?php 
    if (AmpConfig::get('sociable')) {
        ?>
                            <a href="<?php 
        echo $web_path;
        ?>
/browse.php?action=pvmsg" title="<?php 
        echo T_('New messages');
        ?>
">(<?php 
        echo count(PrivateMsg::get_private_msgs($GLOBALS['user']->id, true));
        ?>
)</a>
                            <?php 
    }
    ?>
                            <a rel="nohtml" href="<?php 
    echo $web_path;
    ?>
/logout.php">[<?php 
    echo T_('Log out');
    ?>
]</a>
                        </span>
                    <?php 
} else {
示例#5
0
文件: pvmsg.php 项目: cheese1/ampache
        foreach ($msgs as $msg_id) {
            $msg_id = intval($msg_id);
            $pvmsg = new PrivateMsg($msg_id);
            if ($pvmsg->id && $pvmsg->to_user === $GLOBALS['user']->id) {
                $pvmsg->delete();
            } else {
                debug_event('UI::access_denied', 'Unknown or unauthorized private message #' . $msg_id . '.', '3');
                UI::access_denied();
                exit;
            }
        }
        show_confirmation(T_('Messages Deletion'), T_('Messages have been deleted.'), AmpConfig::get('web_path') . "/browse.php?action=pvmsg");
        break;
    case 'show':
    default:
        $msg_id = intval($_REQUEST['pvmsg_id']);
        $pvmsg = new PrivateMsg($msg_id);
        if ($pvmsg->id && $pvmsg->to_user === $GLOBALS['user']->id) {
            $pvmsg->format();
            if (!$pvmsg->is_read) {
                $pvmsg->set_is_read(true);
            }
            require_once AmpConfig::get('prefix') . UI::find_template('show_pvmsg.inc.php');
        } else {
            debug_event('UI::access_denied', 'Unknown or unauthorized private message #' . $msg_id . '.', '3');
            UI::access_denied();
            exit;
        }
        break;
}
UI::show_footer();
示例#6
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;
 }
示例#7
0
 public static function __static()
 {
     self::$db_querier = PersistenceContext::get_querier();
 }
示例#8
0
					break;
				}
			}' . "\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', '', '&'));
    }
 private static function send_mp($user_id, $title, $content)
 {
     PrivateMsg::start_conversation($user_id, addslashes($title), nl2br($content), '-1', PrivateMsg::SYSTEM_PM);
 }
示例#10
0
文件: pm.php 项目: AroundPBT/PHPBoost
                break;
            case 'e_pm_del':
                $errstr = $LANG['e_pm_del'];
                $type = MessageHelper::WARNING;
                break;
            default:
                $errstr = '';
        }
        if (!empty($errstr)) {
            $tpl->put('message_helper', MessageHelper::display($errstr, $type));
        }
    }
    $tpl->display();
} else {
    $tpl = new FileTemplate('user/pm.tpl');
    $nbr_pm = PrivateMsg::count_conversations($current_user->get_id());
    //On crée une pagination si le nombre de MP est trop important.
    $page = AppContext::get_request()->get_getint('p', 1);
    $pagination = new ModulePagination($page, $nbr_pm, $_NBR_ELEMENTS_PER_PAGE);
    $pagination->set_url(new Url('/user/pm.php?p=%d'));
    if ($pagination->current_page_is_empty() && $page > 1) {
        $error_controller = PHPBoostErrors::unexisting_page();
        DispatchManager::redirect($error_controller);
    }
    $limit_group = $current_user->check_max_value(PM_GROUP_LIMIT, $user_accounts_config->get_max_private_messages_number());
    $unlimited_pm = $current_user->check_level(User::MODERATOR_LEVEL) || $limit_group === -1;
    $pm_max = $unlimited_pm ? $LANG['illimited'] : $limit_group;
    $tpl->assign_block_vars('convers', array('C_PAGINATION' => $pagination->has_several_pages(), 'PAGINATION' => $pagination->display(), 'NBR_PM' => $nbr_pm, 'PM_POURCENT' => '<strong>' . $nbr_pm . '</strong> / <strong>' . $pm_max . '</strong>', 'U_MARK_AS_READ' => 'pm.php?read=1', 'L_MARK_AS_READ' => $LANG['mark_pm_as_read'], 'U_USER_ACTION_PM' => url('.php?del_convers=1&amp;p=' . $page . '&amp;token=' . AppContext::get_session()->get_token()), 'U_PM_BOX' => '<a href="pm.php' . '">' . $LANG['pm_box'] . '</a>', 'U_POST_NEW_CONVERS' => 'pm' . url('.php?post=1', ''), 'L_POST_NEW_CONVERS' => $LANG['post_new_convers']));
    //Aucun message privé.
    if ($nbr_pm == 0) {
        $tpl->assign_block_vars('convers.no_pm', array('L_NO_PM' => LangLoader::get_message('no_item_now', 'common')));
示例#11
0
<?php

require_once '../kernel/begin.php';
define('TITLE', $LANG['title_pm']);
$Bread_crumb->add($LANG['member_area'], url('member.php?id=' . $User->get_attribute('user_id') . '&amp;view=1', 'member-' . $User->get_attribute('user_id') . '.php?view=1'));
$Bread_crumb->add($LANG['title_pm'], url('pm.php'));
require_once '../kernel/header.php';
if (!$User->check_level(MEMBER_LEVEL)) {
    $Errorh->handler('e_auth', E_USER_REDIRECT);
}
import('members/pm');
$Privatemsg = new PrivateMsg();
$pm_get = retrieve(GET, 'pm', 0);
$pm_id_get = retrieve(GET, 'id', 0);
$pm_del_convers = retrieve(GET, 'del_convers', false);
$quote_get = retrieve(GET, 'quote', 0);
$page = retrieve(GET, 'p', 0);
$post = retrieve(GET, 'post', false);
$pm_edit = retrieve(GET, 'edit', 0);
$pm_del = retrieve(GET, 'del', 0);
$read = retrieve(GET, 'read', false);
if ($read) {
    $nbr_pm = $Privatemsg->count_conversations($User->get_attribute('user_id'));
    $limit_group = $User->check_max_value(PM_GROUP_LIMIT, $CONFIG['pm_max']);
    $unlimited_pm = $User->check_level(MODO_LEVEL) || $limit_group === -1;
    $nbr_waiting_pm = 0;
    if (!$unlimited_pm && $nbr_pm > $limit_group) {
        $nbr_waiting_pm = $nbr_pm - $limit_group;
    }
    $j = 0;
    $result = $Sql->query_while("SELECT pm.last_msg_id, pm.user_view_pm\n\tFROM " . DB_TABLE_PM_TOPIC . "  pm\n\tLEFT JOIN " . DB_TABLE_PM_MSG . " msg ON msg.idconvers = pm.id AND msg.id = pm.last_msg_id\n\tWHERE " . $User->get_attribute('user_id') . " IN (pm.user_id, pm.user_id_dest) AND pm.last_user_id <> '" . $User->get_attribute('user_id') . "' AND msg.view_status = 0\n\tORDER BY pm.last_timestamp DESC ", __LINE__, __FILE__);