本文整理汇总了PHP中BP_Messages_Thread类的典型用法代码示例。如果您正苦于以下问题:PHP BP_Messages_Thread类的具体用法?PHP BP_Messages_Thread怎么用?PHP BP_Messages_Thread使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了BP_Messages_Thread类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: messages_action_view_message
function messages_action_view_message()
{
global $thread_id, $bp;
if (!bp_is_messages_component() || !bp_is_current_action('view')) {
return false;
}
$thread_id = (int) bp_action_variable(0);
if (!$thread_id || !messages_is_valid_thread($thread_id) || !messages_check_thread_access($thread_id) && !is_super_admin()) {
bp_core_redirect(bp_displayed_user_domain() . bp_get_messages_slug());
}
// Check if a new reply has been submitted
if (isset($_POST['send'])) {
// Check the nonce
check_admin_referer('messages_send_message', 'send_message_nonce');
// Send the reply
if (messages_new_message(array('thread_id' => $thread_id, 'subject' => $_POST['subject'], 'content' => $_POST['content']))) {
bp_core_add_message(__('Your reply was sent successfully', 'buddypress'));
} else {
bp_core_add_message(__('There was a problem sending your reply, please try again', 'buddypress'), 'error');
}
bp_core_redirect(bp_displayed_user_domain() . bp_get_messages_slug() . '/view/' . $thread_id . '/');
}
// Mark message read
messages_mark_thread_read($thread_id);
// Decrease the unread count in the nav before it's rendered
$name = sprintf(__('Messages <span>%s</span>', 'buddypress'), bp_get_total_unread_messages_count());
$bp->bp_nav[$bp->messages->slug]['name'] = $name;
do_action('messages_action_view_message');
bp_core_new_subnav_item(array('name' => sprintf(__('From: %s', 'buddypress'), BP_Messages_Thread::get_last_sender($thread_id)), 'slug' => 'view', 'parent_url' => trailingslashit(bp_displayed_user_domain() . bp_get_messages_slug()), 'parent_slug' => bp_get_messages_slug(), 'screen_function' => true, 'position' => 40, 'user_has_access' => bp_is_my_profile(), 'link' => bp_displayed_user_domain() . bp_get_messages_slug() . '/view/' . (int) $thread_id));
bp_core_load_template(apply_filters('messages_template_view_message', 'members/single/home'));
}
开发者ID:hornetalcala,项目名称:trunk,代码行数:31,代码来源:bp-messages-actions.php
示例2: bp_messages_box_template
function bp_messages_box_template( $user_id, $box, $per_page, $max, $type ) {
$this->pag_page = isset( $_GET['mpage'] ) ? intval( $_GET['mpage'] ) : 1;
$this->pag_num = isset( $_GET['num'] ) ? intval( $_GET['num'] ) : $per_page;
$this->user_id = $user_id;
$this->box = $box;
$this->type = $type;
if ( 'notices' == $this->box ) {
$this->threads = BP_Messages_Notice::get_notices();
} else {
$threads = BP_Messages_Thread::get_current_threads_for_user( $this->user_id, $this->box, $this->type, $this->pag_num, $this->pag_page );
$this->threads = $threads['threads'];
$this->total_thread_count = $threads['total'];
}
if ( !$this->threads ) {
$this->thread_count = 0;
$this->total_thread_count = 0;
} else {
$total_notice_count = BP_Messages_Notice::get_total_notice_count();
if ( !$max || $max >= (int)$total_notice_count ) {
if ( 'notices' == $this->box ) {
$this->total_thread_count = (int)$total_notice_count;
}
} else {
$this->total_thread_count = (int)$max;
}
if ( $max ) {
if ( $max >= count($this->threads) ) {
$this->thread_count = count($this->threads);
} else {
$this->thread_count = (int)$max;
}
} else {
$this->thread_count = count($this->threads);
}
}
if ( (int)$this->total_thread_count && (int)$this->pag_num ) {
$this->pag_links = paginate_links( array(
'base' => add_query_arg( 'mpage', '%#%' ),
'format' => '',
'total' => ceil( (int)$this->total_thread_count / (int)$this->pag_num ),
'current' => $this->pag_page,
'prev_text' => '←',
'next_text' => '→',
'mid_size' => 1
) );
}
}
开发者ID:n-sane,项目名称:zaroka,代码行数:54,代码来源:bp-messages-templatetags.php
示例3: messages_ajax_delete
function messages_ajax_delete()
{
global $bp;
if (!isset($_POST['thread_ids'])) {
echo "-1[[split]]" . __('There was a problem deleting messages.', 'buddypress');
} else {
$thread_ids = explode(',', $_POST['thread_ids']);
for ($i = 0; $i < count($thread_ids); $i++) {
BP_Messages_Thread::delete($thread_ids[$i]);
}
_e('Messages deleted.', 'buddypress');
}
}
开发者ID:alvaropereyra,项目名称:shrekcms,代码行数:13,代码来源:bp-messages-ajax.php
示例4: __construct
function __construct($user_id, $box, $per_page, $max, $type, $search_terms, $page_arg = 'mpage')
{
$this->pag_page = isset($_GET[$page_arg]) ? intval($_GET[$page_arg]) : 1;
$this->pag_num = isset($_GET['num']) ? intval($_GET['num']) : $per_page;
$this->user_id = $user_id;
$this->box = $box;
$this->type = $type;
$this->search_terms = $search_terms;
if ('notices' == $this->box) {
$this->threads = BP_Messages_Notice::get_notices(array('pag_num' => $this->pag_num, 'pag_page' => $this->pag_page));
} else {
$threads = BP_Messages_Thread::get_current_threads_for_user($this->user_id, $this->box, $this->type, $this->pag_num, $this->pag_page, $this->search_terms);
$this->threads = $threads['threads'];
$this->total_thread_count = $threads['total'];
}
if (!$this->threads) {
$this->thread_count = 0;
$this->total_thread_count = 0;
} else {
$total_notice_count = BP_Messages_Notice::get_total_notice_count();
if (!$max || $max >= (int) $total_notice_count) {
if ('notices' == $this->box) {
$this->total_thread_count = (int) $total_notice_count;
}
} else {
$this->total_thread_count = (int) $max;
}
if ($max) {
if ($max >= count($this->threads)) {
$this->thread_count = count($this->threads);
} else {
$this->thread_count = (int) $max;
}
} else {
$this->thread_count = count($this->threads);
}
}
if ((int) $this->total_thread_count && (int) $this->pag_num) {
$this->pag_links = paginate_links(array('base' => add_query_arg($page_arg, '%#%'), 'format' => '', 'total' => ceil((int) $this->total_thread_count / (int) $this->pag_num), 'current' => $this->pag_page, 'prev_text' => _x('←', 'Message pagination previous text', 'buddypress'), 'next_text' => _x('→', 'Message pagination next text', 'buddypress'), 'mid_size' => 1));
}
}
开发者ID:adisonc,项目名称:MaineLearning,代码行数:41,代码来源:bp-messages-template.php
示例5: bp_dtheme_ajax_messages_delete
function bp_dtheme_ajax_messages_delete()
{
global $bp;
if (!isset($_POST['thread_ids'])) {
echo "-1<div id='message' class='error'><p>" . __('There was a problem deleting messages.', 'buddypress') . '</p></div>';
} else {
$thread_ids = explode(',', $_POST['thread_ids']);
for ($i = 0, $count = count($thread_ids); $i < $count; ++$i) {
BP_Messages_Thread::delete($thread_ids[$i]);
}
_e('Messages deleted.', 'buddypress');
}
}
开发者ID:hscale,项目名称:webento,代码行数:13,代码来源:ajax.php
示例6: messages_is_valid_thread
function messages_is_valid_thread( $thread_id ) {
return BP_Messages_Thread::is_valid( $thread_id );
}
开发者ID:n-sane,项目名称:zaroka,代码行数:3,代码来源:bp-messages.php
示例7: bp_messages_message_delete_notifications
/**
* When a message is deleted, delete corresponding notifications.
*
* @since BuddyPress (2.0.0)
*
* @param int $thread_id ID of the thread.
* @param array $message_ids IDs of the messages.
*/
function bp_messages_message_delete_notifications($thread_id, $message_ids)
{
if (!bp_is_active('notifications')) {
return;
}
// For each recipient, delete notifications corresponding to each message.
$thread = new BP_Messages_Thread($thread_id);
foreach ($thread->get_recipients() as $recipient) {
foreach ($message_ids as $message_id) {
bp_notifications_delete_notifications_by_item_id($recipient->user_id, (int) $message_id, buddypress()->messages->id, 'new_message');
}
}
}
开发者ID:kosir,项目名称:thatcamp-org,代码行数:21,代码来源:bp-messages-notifications.php
示例8: bp_update_db_stuff
function bp_update_db_stuff()
{
$bp_prefix = bp_core_get_table_prefix();
// Rename the old user activity cached table if needed.
if ($nxtdb->get_var("SHOW TABLES LIKE '%{$bp_prefix}bp_activity_user_activity_cached%'")) {
$nxtdb->query("RENAME TABLE {$bp_prefix}bp_activity_user_activity_cached TO {$bp->activity->table_name}");
}
// Rename fields from pre BP 1.2
if ($nxtdb->get_var("SHOW TABLES LIKE '%{$bp->activity->table_name}%'")) {
if ($nxtdb->get_var("SHOW COLUMNS FROM {$bp->activity->table_name} LIKE 'component_action'")) {
$nxtdb->query("ALTER TABLE {$bp->activity->table_name} CHANGE component_action type varchar(75) NOT NULL");
}
if ($nxtdb->get_var("SHOW COLUMNS FROM {$bp->activity->table_name} LIKE 'component_name'")) {
$nxtdb->query("ALTER TABLE {$bp->activity->table_name} CHANGE component_name component varchar(75) NOT NULL");
}
}
// On first installation - record all existing blogs in the system.
if (!(int) $bp->site_options['bp-blogs-first-install']) {
bp_blogs_record_existing_blogs();
bp_update_option('bp-blogs-first-install', 1);
}
if (is_multisite()) {
bp_core_add_illegal_names();
}
// Update and remove the message threads table if it exists
if ($nxtdb->get_var("SHOW TABLES LIKE '%{$bp_prefix}bp_messages_threads%'")) {
$update = BP_Messages_Thread::update_tables();
if ($update) {
$nxtdb->query("DROP TABLE {$bp_prefix}bp_messages_threads");
}
}
}
开发者ID:nxtclass,项目名称:NXTClass-Plugin,代码行数:32,代码来源:bp-core-update.php
示例9: mark_unread
/**
* Mark a thread initialized in this class as unread.
*
* @since 1.0.0
*
* @see BP_Messages_Thread::mark_as_unread()
*/
public function mark_unread()
{
BP_Messages_Thread::mark_as_unread($this->thread_id);
}
开发者ID:jasonmcalpin,项目名称:BuddyPress,代码行数:11,代码来源:class-bp-messages-thread.php
示例10: bp_dtheme_ajax_messages_delete
function bp_dtheme_ajax_messages_delete()
{
// Bail if not a POST action
if ('POST' !== strtoupper($_SERVER['REQUEST_METHOD'])) {
return;
}
if (!isset($_POST['thread_ids'])) {
echo "-1<div id='message' class='error'><p>" . __('There was a problem deleting messages.', 'buddypress') . '</p></div>';
} else {
$thread_ids = explode(',', $_POST['thread_ids']);
for ($i = 0, $count = count($thread_ids); $i < $count; ++$i) {
BP_Messages_Thread::delete($thread_ids[$i]);
}
_e('Messages deleted.', 'buddypress');
}
}
开发者ID:nxtclass,项目名称:NXTClass-Plugin,代码行数:16,代码来源:ajax.php
示例11: bp_legacy_theme_ajax_message_markread
/**
* Mark a private message as read in your inbox via a POST request.
*
* @return mixed String on error, void on success
* @since BuddyPress (1.2)
*/
function bp_legacy_theme_ajax_message_markread()
{
// Bail if not a POST action
if ('POST' !== strtoupper($_SERVER['REQUEST_METHOD'])) {
return;
}
if (!isset($_POST['thread_ids'])) {
echo "-1<div id='message' class='error'><p>" . __('There was a problem marking messages as read.', 'buddypress') . '</p></div>';
} else {
$thread_ids = explode(',', $_POST['thread_ids']);
for ($i = 0, $count = count($thread_ids); $i < $count; ++$i) {
BP_Messages_Thread::mark_as_read((int) $thread_ids[$i]);
}
}
exit;
}
开发者ID:kosir,项目名称:thatcamp-org,代码行数:22,代码来源:buddypress-functions.php
示例12: bp_get_total_unread_messages_count
/**
* Get the unread messages count for the current inbox.
*
* @return int
*/
function bp_get_total_unread_messages_count()
{
/**
* Filters the unread messages count for the current inbox.
*
* @since 1.0.0
*
* @param int $value Unread messages count for the current inbox.
*/
return apply_filters('bp_get_total_unread_messages_count', BP_Messages_Thread::get_inbox_count());
}
开发者ID:igniterealtime,项目名称:community-plugins,代码行数:16,代码来源:bp-messages-template.php
示例13: test_is_valid_invalid_thread
/**
* @group is_valid
*/
public function test_is_valid_invalid_thread()
{
$this->assertEquals(null, BP_Messages_Thread::is_valid(999));
}
开发者ID:AceMedia,项目名称:BuddyPress,代码行数:7,代码来源:class.bp-messages-thread.php
示例14: messages_get_unread_count
function messages_get_unread_count($user_id = false)
{
global $bp;
if (!$user_id) {
$user_id = $bp->loggedin_user->id;
}
return BP_Messages_Thread::get_inbox_count($user_id);
}
开发者ID:alvaropereyra,项目名称:shrekcms,代码行数:8,代码来源:bp-messages.php
示例15: __construct
/**
* Constructor method.
*
* @param array $args {
* Array of arguments. See bp_has_message_threads() for full description.
* }
*/
public function __construct($args = array())
{
// Backward compatibility with old method of passing arguments
if (!is_array($args) || func_num_args() > 1) {
_deprecated_argument(__METHOD__, '2.2.0', sprintf(__('Arguments passed to %1$s should be in an associative array. See the inline documentation at %2$s for more details.', 'buddypress'), __METHOD__, __FILE__));
$old_args_keys = array(0 => 'user_id', 1 => 'box', 2 => 'per_page', 3 => 'max', 4 => 'type', 5 => 'search_terms', 6 => 'page_arg');
$func_args = func_get_args();
$args = bp_core_parse_args_array($old_args_keys, $func_args);
}
$r = wp_parse_args($args, array('page' => 1, 'per_page' => 10, 'page_arg' => 'mpage', 'box' => 'inbox', 'type' => 'all', 'user_id' => bp_loggedin_user_id(), 'max' => false, 'search_terms' => '', 'meta_query' => array()));
$this->pag_arg = sanitize_key($r['page_arg']);
$this->pag_page = bp_sanitize_pagination_arg($this->pag_arg, $r['page']);
$this->pag_num = bp_sanitize_pagination_arg('num', $r['per_page']);
$this->user_id = $r['user_id'];
$this->box = $r['box'];
$this->type = $r['type'];
$this->search_terms = $r['search_terms'];
if ('notices' === $this->box) {
$this->threads = BP_Messages_Notice::get_notices(array('pag_num' => $this->pag_num, 'pag_page' => $this->pag_page));
} else {
$threads = BP_Messages_Thread::get_current_threads_for_user(array('user_id' => $this->user_id, 'box' => $this->box, 'type' => $this->type, 'limit' => $this->pag_num, 'page' => $this->pag_page, 'search_terms' => $this->search_terms, 'meta_query' => $r['meta_query']));
$this->threads = $threads['threads'];
$this->total_thread_count = $threads['total'];
}
if (!$this->threads) {
$this->thread_count = 0;
$this->total_thread_count = 0;
} else {
$total_notice_count = BP_Messages_Notice::get_total_notice_count();
if (empty($r['max']) || (int) $r['max'] >= (int) $total_notice_count) {
if ('notices' === $this->box) {
$this->total_thread_count = (int) $total_notice_count;
}
} else {
$this->total_thread_count = (int) $r['max'];
}
if (!empty($r['max'])) {
if ((int) $r['max'] >= count($this->threads)) {
$this->thread_count = count($this->threads);
} else {
$this->thread_count = (int) $r['max'];
}
} else {
$this->thread_count = count($this->threads);
}
}
if ((int) $this->total_thread_count && (int) $this->pag_num) {
$pag_args = array($r['page_arg'] => '%#%');
if (defined('DOING_AJAX') && true === (bool) DOING_AJAX) {
$base = remove_query_arg('s', wp_get_referer());
} else {
$base = '';
}
$add_args = array();
if (!empty($this->search_terms)) {
$add_args['s'] = $this->search_terms;
}
$this->pag_links = paginate_links(array('base' => add_query_arg($pag_args, $base), 'format' => '', 'total' => ceil((int) $this->total_thread_count / (int) $this->pag_num), 'current' => $this->pag_page, 'prev_text' => _x('←', 'Message pagination previous text', 'buddypress'), 'next_text' => _x('→', 'Message pagination next text', 'buddypress'), 'mid_size' => 1, 'add_args' => $add_args));
}
}
开发者ID:kosir,项目名称:thatcamp-org,代码行数:67,代码来源:bp-messages-template.php
注:本文中的BP_Messages_Thread类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论