function for_buddypress_prepare_topic($_topic, $topic) { // Cast to an array $_topic = (array) $topic; // Set the URI $_topic['topic_uri'] = get_topic_link($_topic['topic_id']); // Set readable times $_topic['topic_start_time_since'] = bb_since($_topic['topic_start_time']); $_topic['topic_time_since'] = bb_since($_topic['topic_time']); // Set the display names $_topic['topic_poster_display_name'] = get_user_display_name($_topic['topic_poster']); $_topic['topic_last_poster_display_name'] = get_user_display_name($_topic['topic_last_poster']); return $_topic; }
function bb_user_row($user, $role = '', $email = false) { $actions = "<a href='" . esc_attr(get_user_profile_link($user->ID)) . "'>" . __('View') . "</a>"; $title = ''; if (bb_current_user_can('edit_user', $user_id)) { $actions .= " | <a href='" . esc_attr(bb_get_user_admin_link($user->ID)) . "'>" . __('Edit') . "</a>"; $title = " title='" . esc_attr(sprintf(__('User ID: %d'), $user->ID)) . "'"; } $r = "\t<tr id='user-{$user->ID}'" . get_alt_class("user-{$role}") . ">\n"; $r .= "\t\t<td class=\"user\">" . bb_get_avatar($user->ID, 32) . "<span class=\"row-title\"><a href='" . get_user_profile_link($user->ID) . "'" . $title . ">" . get_user_name($user->ID) . "</a></span><div><span class=\"row-actions\">{$actions}</span> </div></td>\n"; $r .= "\t\t<td><a href='" . get_user_profile_link($user->ID) . "'>" . get_user_display_name($user->ID) . "</a></td>\n"; if ($email) { $email = bb_get_user_email($user->ID); $r .= "\t\t<td><a href='mailto:{$email}'>{$email}</a></td>\n"; } $registered_time = bb_gmtstrtotime($user->user_registered); if ($registered_time < time() - 86400) { $time = date('Y/m/d\\<\\b\\r \\/\\>H:i:s', bb_offset_time($registered_time)); } else { $time = sprintf(__('%s ago'), bb_since($registered_time)); } $r .= "\t\t<td>" . $time . "</td>\n"; if (!isset($user->capabilities) || !is_array($user->capabilities) || empty($user->capabilities)) { $role = array(__('Inactive (no role)')); } else { global $nxt_roles; $_roles = $nxt_roles->get_names(); $role = array(); foreach ($user->capabilities as $cap => $cap_set) { if (!$cap_set) { continue; } $role[] = $_roles[$cap]; } if (!count($role)) { $role[] = __('None'); } } $r .= "\t\t<td>" . join(', ', $role) . "</td>\n\t</tr>"; return $r; }
/** * Prepares post data for return in an XML-RPC object * * @since 1.0 * @return array The prepared post data * @param array|object The unprepared post data **/ function prepare_post($post) { // Cast to an array $_post = (array) $post; // Set the URI $_post['post_uri'] = get_post_link($_post['post_id']); // Set readable times $_post['post_time_since'] = bb_since($_post['post_time']); // Set the display names $_post['poster_display_name'] = get_user_display_name($_post['poster_id']); // Remove some sensitive data unset($_post['poster_id'], $_post['poster_ip'], $_post['pingback_queued']); // Allow plugins to modify the data return apply_filters('bb_xmlrpc_prepare_post', $_post, (array) $post); }
function _bb_time_function_return($time, $args) { $time = bb_gmtstrtotime($time); switch ($format = $args['format']) { case 'since': return bb_since($time, $args['more']); break; case 'timestamp': $format = 'U'; break; case 'mysql': $format = 'Y-m-d H:i:s'; break; } if ($args['localize']) { return bb_gmdate_i18n($format, $time); } else { return gmdate($format, $time); } }
function bb_attachments_post_attachments($post_id = 0) { global $bbdb, $bb_attachments, $bb_attachments_cache, $bb_current_user; $output = ""; if ($post_id && ($bb_attachments['role']['see'] == "read" || bb_current_user_can($bb_attachments['role']['see']))) { $time = time() - 60; $can_delete = false; $self = false; $admin = false; $filter = true; // " AND status = 0 "; // speedup checks with flag if ($bb_current_user->ID == get_post_author_id($post_id)) { $self = true; } if ((!is_topic() || isset($_GET['bb_attachments'])) && bb_current_user_can('moderate')) { $filter = ""; $admin = bb_current_user_can('administrate'); } if (bb_current_user_can($bb_attachments['role']['delete']) && bb_current_user_can('edit_post', $post_id)) { $can_delete = true; } $location = bb_attachments_location(); $can_inline = true; if (!($bb_attachments['role']['inline'] == "read" || bb_current_user_can($bb_attachments['role']['inline']))) { $can_inline = false; } if (!isset($bb_attachments_cache[$post_id])) { $bb_attachments_cache[$post_id] = $bbdb->get_results("SELECT * FROM " . $bb_attachments['db'] . " WHERE post_id = {$post_id} ORDER BY time DESC LIMIT 999"); } if (count($bb_attachments_cache[$post_id])) { foreach ($bb_attachments_cache[$post_id] as $attachment) { $showerror = $self && $attachment->time > $time ? true : false; if ($attachment->status == 0 || empty($filter) || $showerror) { $attachment->filename = stripslashes($attachment->filename); $output .= "<li>"; $output .= "<span" . ($attachment->status > 0 ? " class='deleted' " : "") . "> "; if ($attachment->status > 0) { $icon = "missing.gif"; } else { if (isset($bb_attachments['icons'][$attachment->ext])) { $icon = $bb_attachments['icons'][$attachment->ext]; } else { $icon = $bb_attachments['icons']['default']; } } $output .= " <img align='absmiddle' title='" . $attachment->ext . "' src='" . $bb_attachments['icons']['url'] . $icon . "' /> "; if ($attachment->status > 0 && (empty($filter) || $showerror)) { $output .= " [" . __($bb_attachments['status'][$attachment->status]) . "] {$attachment->filename} "; } if ($attachment->status == 0) { $output .= " " . "<a href='" . attribute_escape(add_query_arg('bbat', $attachment->id, add_query_arg('bb_attachments', $attachment->post_id, remove_query_arg(array('bb_attachments', 'bbat', 'bbat_delete'))))) . "'>" . $attachment->filename . "</a> " . " "; } $output .= " <span class='num'>(" . round($attachment->size / 1024, 1) . " KB"; if ($attachment->status < 2) { $output .= ", " . bb_number_format_i18n($attachment->downloads) . " " . __('downloads'); } $output .= ")</span> "; if ($attachment->time < $time) { $output .= " <small>" . bb_since($attachment->time) . " " . __('old') . "</small> "; } if ($admin) { $output .= ' [<a href="' . attribute_escape(bb_get_option('uri') . 'bb-admin/view-ip.php?ip=' . long2ip($attachment->user_ip)) . '">' . long2ip($attachment->user_ip) . '</a>] '; } if ($attachment->status == 0 && $can_delete) { $output .= ' [<a onClick="return confirm(' . "'" . __('Delete') . " {$attachment->filename} ?" . "'" . ')" href="' . add_query_arg('bbat_delete', $attachment->id) . '">x</a>] '; } if ($attachment->status == 0 && $location == "edit.php" && $can_inline) { $fullpath = $bb_attachments['path'] . floor($attachment->id / 1000) . "/" . $attachment->id . "." . $attachment->filename; if (list($width, $height, $type) = getimagesize($fullpath)) { $output .= " [<strong><a href='#' onclick='bbat_inline_insert({$attachment->post_id},{$attachment->id}); return false;'>" . __("INSERT") . "</a></strong>] "; } } $output .= " </span></li>"; } } } if ($output) { $output = "<h3>" . __("Attachments") . "</h3><ol>" . $output . "</ol>"; } if ($location == "edit.php") { $output .= '<scr' . 'ipt type="text/javascript" defer="defer"> function bbat_inline_insert(post_id,id) { bbat_field = document.getElementsByTagName("textarea")[0]; bbat_value="[attachment="+post_id+","+id+"]"; if (document.selection) {bbat_field.focus(); sel = document.selection.createRange();sel.text = bbat_value;} else if (bbat_field.selectionStart || bbat_field.selectionStart == "0") {var startPos = bbat_field.selectionStart; var endPos = bbat_field.selectionEnd; bbat_field.value = bbat_field.value.substring(0, startPos)+ bbat_value+ bbat_field.value.substring(endPos, bbat_field.value.length); } else {bbat_field.value += bbat_value;} return false;} </script>'; } } if (is_bb_feed()) { $output = wp_specialchars($output); } return $output; }
function _bb_time_function_return($time, $args) { $time = bb_gmtstrtotime($time); switch ($format = $args['format']) { case 'since': return bb_since($time, $args['more']); break; case 'timestamp': $format = 'U'; break; case 'mysql': $format = 'Y-m-d H:i:s'; break; case 'datetime': $format = bb_get_option('datetime_format'); break; } return $args['localize'] ? bb_gmdate_i18n($format, $time) : gmdate($format, $time); }