/** * Fetches the note to be quoted and modifies it as appropriate. Determines * if this message should be private based on the quoted note. * * @param integer Note to quote * @param integer Issue being responded to/issue the note is in * @param array Permissions for this issue * @param bool (Output) Whether the quoted note is private * * @return string Quoted note (ready for passing into editor functions) */ function fetch_pt_quoted_note($quotenoteid, $issueid, $issueperms, &$quoted_private) { global $vbulletin, $db, $show, $stylevar, $vbphrase, $template_hook; $viewable_note_types = fetch_viewable_note_types($issueperms, $private_text); $quotenote = $db->query_first("\r\n\t\tSELECT *\r\n\t\tFROM " . TABLE_PREFIX . "pt_issuenote AS issuenote\r\n\t\tWHERE issuenoteid = {$quotenoteid}\r\n\t\t\tAND issueid = {$issueid}\r\n\t\t\tAND (visible IN (" . implode(',', $viewable_note_types) . "){$private_text})\r\n\t\t\tAND type IN ('user', 'petition')\r\n\t"); if ($quotenote) { // new post with a quote $quoted_private = $quotenote['visible'] == 'private'; require_once DIR . '/includes/functions_newpost.php'; $originalposter = fetch_quote_username($quotenote['username']); $quote_text = trim(strip_quotes($quotenote['pagetext'])); eval('$pagetext = "' . fetch_template('pt_postreply_quote', 0, false) . '\\n";'); return $pagetext; } else { $quoted_private = false; return ''; } }
/** * Build array of SQL for a where clause to limit matched results to the user's permissions. * * @param array User information * * @return array [projectid] => SQL for project only */ function build_issuenote_permissions_query(&$user) { global $vbulletin; if (!isset($user['projectpermissions'])) { prepare_project_permissions($user); } $clause = array(); foreach ($user['projectpermissions'] as $projectid => $types) { $type_options = array(); foreach ($types as $typeid => $perms) { $perms = fetch_viewable_note_types($perms, $private_text); $type_options["{$typeid}"] = "(issue.issuetypeid = '" . $typeid . "' AND (issuenote.visible IN (" . implode(", ", $perms) . "){$private_text}))"; } if ($type_options) { $clause["{$projectid}"] = "(issue.projectid = " . $projectid . " AND (" . implode(" OR ", $type_options) . "))"; } } return $clause; }
} while ($start >= $issue_count and $issue_count); $output .= print_archive_page_navigation($issue_count, $vbulletin->options['archive_threadsperpage'], "projectid-{$project['projectid']}", 'project.php?'); $issuebits = ''; while ($issue = $db->fetch_array($issue_results)) { ($hook = vBulletinHook::fetch_hook('projectarchive_project_issue')) ? eval($hook) : false; $issuebits .= "<li><a href=\"" . $vbulletin->options['bburl'] . '/archive/project.php' . (SLASH_METHOD ? '/' : '?') . "issueid-{$issue['issueid']}.html\">{$issue['title']}</a> (" . $vbphrase["issuetype_{$issue['issuetypeid']}_singular"] . ")</li>\n"; } if ($issuebits) { $output .= "<div id=\"content\">\n"; $output .= "<ol start=\"" . ($start + 1) . "\">{$issuebits}</ol>"; $output .= "</div>\n"; } } else { if ($do == 'issue') { $issueperms = fetch_project_permissions($vbulletin->userinfo, $project['projectid'], $issue['issuetypeid']); $viewable_note_types = fetch_viewable_note_types($issueperms, $private_text); // find total results for each type $notetype_counts = array('user' => 0, 'petition' => 0, 'system' => 0); $notetype_counts_query = $db->query_read("\r\n\t\tSELECT issuenote.type, COUNT(*) AS total\r\n\t\tFROM " . TABLE_PREFIX . "pt_issuenote AS issuenote\r\n\t\tWHERE issuenote.issueid = {$issue['issueid']}\r\n\t\t\tAND issuenote.issuenoteid <> {$issue['firstnoteid']}\r\n\t\t\tAND (issuenote.visible IN (" . implode(',', $viewable_note_types) . "){$private_text})\r\n\t\tGROUP BY issuenote.type\r\n\t"); while ($notetype_count = $db->fetch_array($notetype_counts_query)) { $notetype_counts["{$notetype_count['type']}"] = intval($notetype_count['total']); } $note_count = $notetype_counts['user'] + $notetype_counts['petition']; // pagination if (!$p) { $p = 1; } $start = ($p - 1) * $vbulletin->options['archive_postsperpage']; if ($start > $note_count) { $vbulletin->GPC['pagenumber'] = ceil($note_count / $vbulletin->options['archive_postsperpage']); $start = ($p - 1) * $vbulletin->options['archive_postsperpage'];