function dt_post_author($print = true, $name = true) { return get_post_detail('author', $print, $name); }
function get_thread_func() { global $context, $settings, $options, $txt, $smcFunc, $scripturl, $modSettings, $user_profile, $user_info, $topicinfo; $rpc_post_list = array(); $post_place = 0; $msg_ids = array(); $support_post_thanks = isset($modSettings['integrate_pre_include']) && strpos($modSettings['integrate_pre_include'], '$sourcedir/Subs-ThankYou.php'); while ($message = get_post_detail()) { $attachments = array(); if (!empty($message['attachment'])) { foreach ($message['attachment'] as $attachment) { $extension = pathinfo($attachment['name'], PATHINFO_EXTENSION); if (empty($extension)) { $extension = 'other'; } $xmlrpc_attachment = new xmlrpcval(array('filename' => new xmlrpcval(basic_clean($attachment['name']), 'base64'), 'filesize' => new xmlrpcval($attachment['byte_size'], 'int'), 'content_type' => new xmlrpcval($attachment['is_image'] ? 'image' : $extension), 'thumbnail_url' => new xmlrpcval($attachment['thumbnail']['has_thumb'] ? $attachment['thumbnail']['href'] : ''), 'url' => new xmlrpcval($attachment['href'])), 'struct'); $attachments[] = $xmlrpc_attachment; } } $avatar = ''; if (!empty($settings['show_user_images']) && empty($options['show_no_avatars']) && !empty($message['member']['avatar']['image'])) { $avatar = $message['member']['avatar']['href']; } $msg_ids[] = $message['id']; $mesageBody = post_html_clean($message['body']); if (in_array($message['member']['id'], $user_info['ignoreusers'])) { $mesageBody = '[spoiler]' . $mesageBody . '[/spoiler]'; } $xmlrpc_post = array('topic_id' => new xmlrpcval($context['current_topic'], 'string'), 'post_id' => new xmlrpcval($message['id']), 'post_title' => new xmlrpcval(basic_clean($message['subject']), 'base64'), 'post_content' => new xmlrpcval($mesageBody, 'base64'), 'post_author_id' => new xmlrpcval($message['member']['id']), 'post_author_name' => new xmlrpcval(basic_clean($message['member']['name']), 'base64'), 'icon_url' => new xmlrpcval($avatar), 'post_time' => new xmlrpcval($message['time'], 'dateTime.iso8601'), 'timestamp' => new xmlrpcval($message['timestamp'], 'string'), 'attachments' => new xmlrpcval($attachments, 'array'), 'is_online' => new xmlrpcval(isset($message['member']['online']['is_online']) && $message['member']['online']['is_online'] ? true : false, 'boolean'), 'can_edit' => new xmlrpcval($message['can_modify'], 'boolean'), 'can_delete' => new xmlrpcval($message['can_remove'], 'boolean'), 'allow_smilies' => new xmlrpcval($message['smileys_enabled'] ? true : false, 'boolean')); if ($settings['show_modify'] && $message['modified'] && $message['modified']['name']) { $loaded_ids = loadMemberData($message['modified']['name'], true); $xmlrpc_post['editor_id'] = new xmlrpcval($loaded_ids[0], 'string'); $xmlrpc_post['editor_name'] = new xmlrpcval(basic_clean($message['modified']['name']), 'base64'); $xmlrpc_post['edit_time'] = new xmlrpcval($message['modified']['timestamp'], 'string'); } $rpc_post_list[] = $xmlrpc_post; } global $board_info; $fixed_rpc_post_list = array(); if ($support_post_thanks) { if ($board_info['thank_you_post_enable'] && allowedTo('thank_you_post_show')) { if (function_exists('ThankYouPostList')) { ThankYouPostList($msg_ids); } else { global $sourcedir; include_once $sourcedir . '/ThankYouPost.php'; ThankYouPostList($msg_ids); } } if (!empty($context['topic_first_message']) && !empty($modSettings['thankYouPostFirstPostOnly'])) { foreach ($context['thank_you_post_info'] as $one_msg => $msg) { if ($msg['id_msg'] == $context['topic_first_message']) { $first_msg_thank_count = $msg['thank_you_post_counter']; } } } foreach ($rpc_post_list as $one_post => $xmlrpc_post) { $thx_info_list = array(); $rpc_me_name = "me"; $me_value = $xmlrpc_post['post_id']->{$rpc_me_name}; $msg_id = $me_value['string']; $me_author_id = $xmlrpc_post['post_author_id']->{$rpc_me_name}; $already_posted = $user_info['id'] == $me_author_id['string'] ? true : false; if (isset($context['thank_you_post'][$msg_id])) { $member_list = $context['thank_you_post'][$msg_id]['fulllist']; foreach ($member_list as $one_thank_member => $one) { $thx_info_list[] = new xmlrpcval(array('userid' => new xmlrpcval($one['id_member'], 'string'), 'username' => new xmlrpcval($one['member_name'], 'base64')), 'struct'); if ($user_info['id'] == $one['id_member']) { $already_posted = true; } } $is_the_post_locked = $context['thank_you_post_info'][$msg_id]['thank_you_post'] == 2; $can_thank_if_not_locked = $board_info['thank_you_post_enable'] && !$context['thank_you_post'][$msg_id]['user_postet'] && allowedTo('thank_you_post_post') && !$already_posted; } else { $is_the_post_locked = isset($context['thank_you_post_info'][$msg_id]) && $context['thank_you_post_info'][$msg_id]['thank_you_post'] == 2; $can_thank_if_not_locked = $board_info['thank_you_post_enable'] && allowedTo('thank_you_post_post') && !$already_posted; } $xmlrpc_post['can_thank'] = new xmlrpcval($can_thank_if_not_locked && !$is_the_post_locked && !$context['is_thank_you_post_locked'], 'boolean'); if (!empty($thx_info_list) && $board_info['thank_you_post_enable'] && allowedTo('thank_you_post_show')) { $xmlrpc_post['thanks_info'] = new xmlrpcval($thx_info_list, 'array'); } $fixed_rpc_post_list[] = new xmlrpcval($xmlrpc_post, 'struct'); } } else { foreach ($rpc_post_list as $one_post => $xmlrpc_post) { $fixed_rpc_post_list[] = new xmlrpcval($xmlrpc_post, 'struct'); } } $rpc_post_list = $fixed_rpc_post_list; $context['num_allowed_attachments'] = empty($modSettings['attachmentNumPerPostLimit']) ? 50 : $modSettings['attachmentNumPerPostLimit']; $context['can_post_attachment'] = !empty($modSettings['attachmentEnable']) && $modSettings['attachmentEnable'] == 1 && (allowedTo('post_attachment') || $modSettings['postmod_active'] && allowedTo('post_unapproved_attachments')) && $context['num_allowed_attachments'] > 0; //generate breadcrumbs $breadcrumbs = array(); $breadcrumbs[] = array('id' => 'c' . $board_info['cat']['id'], 'name' => $board_info['cat']['name'], 'sub_only' => 1); foreach ($board_info['parent_boards'] as $pbid => $cont) { $board_info['parent_boards'][$pbid]['id'] = $pbid; } $parent_boards = array_reverse($board_info['parent_boards']); if (!empty($parent_boards) && is_array($parent_boards)) { foreach ($parent_boards as $bd_content) { $breadcrumbs[] = array('id' => $bd_content['id'], 'name' => $bd_content['name'], 'sub_only' => 0); } } $breadcrumbs[] = array('id' => $board_info['id'], 'name' => $board_info['name'], 'sub_only' => 0); $can_modify = (!$context['is_locked'] || allowedTo('moderate_board')) && (allowedTo('modify_any') || allowedTo('modify_replies') && $context['user']['started'] || allowedTo('modify_own') && $context['user']['started']); if (isset($context['topic_starter_id']) && !empty($context['topic_starter_id'])) { if (isset($user_profile[$context['topic_starter_id']]) && !empty($user_profile[$context['topic_starter_id']])) { $topicAuthor = $user_profile[$context['topic_starter_id']]; } } $response = array('total_post_num' => new xmlrpcval($context['total_visible_posts'], 'int'), 'forum_id' => new xmlrpcval($context['current_board'], 'string'), 'forum_name' => new xmlrpcval(basic_clean($board_info['name']), 'base64'), 'topic_id' => new xmlrpcval($context['current_topic'], 'string'), 'topic_title' => new xmlrpcval(basic_clean($context['subject']), 'base64'), 'topic_author_id' => new xmlrpcval(isset($topicAuthor['id_member']) ? $topicAuthor['id_member'] : 0, 'string'), 'topic_author_name' => new xmlrpcval(isset($topicAuthor['real_name']) ? $topicAuthor['real_name'] : '', 'base64'), 'topic_author_avatar' => new xmlrpcval(isset($topicAuthor['avatar']) ? $topicAuthor['avatar'] : 0, 'string'), 'view_number' => new xmlrpcval($context['num_views'], 'int'), 'can_subscribe' => new xmlrpcval($context['can_mark_notify'], 'boolean'), 'is_subscribed' => new xmlrpcval($context['is_marked_notify'], 'boolean'), 'is_poll' => new xmlrpcval($topicinfo['id_poll'], 'boolean'), 'can_stick' => new xmlrpcval($context['can_sticky'], 'boolean'), 'is_sticky' => new xmlrpcval($context['is_sticky'], 'boolean'), 'can_reply' => new xmlrpcval($context['can_reply'], 'boolean'), 'can_delete' => new xmlrpcval($context['can_delete'], 'boolean'), 'can_upload' => new xmlrpcval($context['can_post_attachment'], 'boolean'), 'can_close' => new xmlrpcval($context['can_lock'], 'boolean'), 'is_closed' => new xmlrpcval($context['is_locked'], 'boolean'), 'position' => new xmlrpcval($context['new_position'], 'int'), 'can_move' => new xmlrpcval($context['can_move'], 'boolean'), 'can_report' => new xmlrpcval(true, 'boolean'), 'can_merge' => new xmlrpcval($context['can_merge'] ? true : false, 'boolean'), 'can_rename' => new xmlrpcval($can_modify, 'boolean')); if (!empty($breadcrumbs)) { $breadcrumblist = array(); foreach ($breadcrumbs as $node) { $breadcrumblist[] = new xmlrpcval(array('forum_id' => new xmlrpcval($node['id'], 'string'), 'forum_name' => new xmlrpcval(basic_clean($node['name']), 'base64'), 'sub_only' => new xmlrpcval($node['sub_only'], 'boolean')), 'struct'); } if (!empty($breadcrumblist)) { $response['breadcrumb'] = new xmlrpcval($breadcrumblist, 'array'); } } if (isset($first_msg_thank_count) && !empty($modSettings['thankYouPostFirstPostOnly'])) { $response['thank_count'] = new xmlrpcval($first_msg_thank_count, 'int'); } $response['posts'] = new xmlrpcval($rpc_post_list, 'array'); return new xmlrpcresp(new xmlrpcval($response, 'struct')); }
/** * Checks if the specified post representing a set matches the criteria * * @param WP_Post $post The child post * @return bool Whether the child post matches the criteria */ public static function postMatchesCriteria(WP_Post $post) { $detailDateStart = get_post_detail('date-start', $post->ID); $detailDateEnd = get_post_detail('date-end', $post->ID); $detailWeekScheme = get_post_detail('week-scheme', $post->ID); $detailDateStart = !empty($detailDateStart) ? new DateTime($detailDateStart, Dates::getTimezone()) : null; $detailDateEnd = !empty($detailDateEnd) ? new DateTime($detailDateEnd, Dates::getTimezone()) : null; if ($detailDateEnd !== null) { $detailDateEnd->setTime(23, 59, 59); } if ($detailDateStart == null and $detailDateEnd == null and ($detailWeekScheme == 'all' or empty($detailWeekScheme))) { return false; } $now = Dates::getNow(); if ($detailDateStart != null and $now < $detailDateStart) { return false; } if ($detailDateEnd != null and $now > $detailDateEnd) { return false; } $week_number_modulo = (int) $now->format('W') % 2; if ($detailWeekScheme == 'even' and $week_number_modulo === 1) { return false; } if ($detailWeekScheme == 'odd' and $week_number_modulo === 0) { return false; } return true; }