/** * Shows the new subscribed PT issues in the user CP * * @return string Printable issue bits */ function process_new_subscribed_issues() { global $vbulletin, $show, $stylevar, $vbphrase, $template_hook, $vbcollapse; if (!($vbulletin->userinfo['permissions']['ptpermissions'] & $vbulletin->bf_ugp_ptpermissions['canviewprojecttools'])) { return ''; } $perms_query = build_issue_permissions_query($vbulletin->userinfo); if (!$perms_query) { return ''; } $marking = ($vbulletin->options['threadmarking'] and $vbulletin->userinfo['userid']); if ($marking) { $issueview_sql = "IF(issueread IS NOT NULL, issueread, " . intval(TIMENOW - $vbulletin->options['markinglimit'] * 86400) . ")"; $issueview_sql2 = "IF(projectread IS NOT NULL, projectread, " . intval(TIMENOW - $vbulletin->options['markinglimit'] * 86400) . ")"; } else { $issueview = max(intval(fetch_bbarray_cookie('issue_lastview', $issue['issueid'])), intval(fetch_bbarray_cookie('issue_lastview', $issue['projectid'] . $issue['issuetypeid']))); if (!$issueview) { $issueview = $vbulletin->userinfo['lastvisit']; } $issueview_sql = intval($issueview); $issueview_sql2 = ''; } build_issue_private_lastpost_sql_all($vbulletin->userinfo, $private_lastpost_join, $private_lastpost_fields); $replycount_clause = fetch_private_replycount_clause($vbulletin->userinfo); $subscriptions = $vbulletin->db->query_read("\r\n\t\tSELECT issue.*, issuesubscribe.subscribetype,\r\n\t\t\tproject.title_clean\r\n\t\t\t" . ($marking ? ", issueread.readtime AS issueread, projectread.readtime AS projectread" : '') . "\r\n\t\t\t" . ($private_lastpost_fields ? ", {$private_lastpost_fields}" : '') . "\r\n\t\t\t" . ($replycount_clause ? ", {$replycount_clause} AS replycount" : '') . "\r\n\t\tFROM " . TABLE_PREFIX . "pt_issuesubscribe AS issuesubscribe\r\n\t\tINNER JOIN " . TABLE_PREFIX . "pt_issue AS issue ON (issue.issueid = issuesubscribe.issueid)\r\n\t\tINNER JOIN " . TABLE_PREFIX . "pt_project AS project ON (project.projectid = issue.projectid)\r\n\t\t" . ($marking ? "\r\n\t\t\tLEFT JOIN " . TABLE_PREFIX . "pt_issueread AS issueread ON (issueread.issueid = issue.issueid AND issueread.userid = " . $vbulletin->userinfo['userid'] . ")\r\n\t\t\tLEFT JOIN " . TABLE_PREFIX . "pt_projectread as projectread ON (projectread.projectid = issue.projectid AND projectread.userid = " . $vbulletin->userinfo['userid'] . " AND projectread.issuetypeid = issue.issuetypeid)\r\n\t\t" : '') . "\r\n\t\t{$private_lastpost_join}\r\n\t\tWHERE issuesubscribe.userid = " . $vbulletin->userinfo['userid'] . "\r\n\t\t\tAND (" . implode(' OR ', $perms_query) . ")\r\n\t\tHAVING lastpost > " . intval(TIMENOW - $vbulletin->options['markinglimit'] * 86400) . "\r\n\t\t\tAND lastpost > " . $issueview_sql . "\r\n\t\t\t" . (!empty($issueview_sql2) ? " AND lastpost > " . $issueview_sql2 : '') . "\r\n\t\tORDER BY lastpost DESC\r\n\t"); $show['issuebit_project_title'] = true; $subscriptionbits = ''; while ($issue = $vbulletin->db->fetch_array($subscriptions)) { $issue = prepare_issue($issue); eval('$subscriptionbits .= "' . fetch_template('pt_issuebit') . '";'); } if (!$subscriptionbits) { return ''; } eval('$return = "' . fetch_template('pt_usercp_subscriptions') . '";'); return $return; }
/** * Adds reply count <= criteria * * @param string * @param integer * * @return boolean True on success */ function add_replycount_lteq($name, $value) { $value = intval($value); if ($value < 0) { return PT_SEARCHGEN_CRITERIA_UNNECESSARY; } $replycount_clause = fetch_private_replycount_clause($this->registry->userinfo); $this->where['replycount'] = trim("\r\n\t\t\t{$replycount_clause} <= {$value}\r\n\t\t"); return PT_SEARCHGEN_CRITERIA_ADDED; }
/** * Executes the issue list query with the specified criteria. * * @param string Criteria to limit results to * @param integer Page number to fetch * @param integer Results to fetch per page */ function exec_query($criteria, $pagenumber, $perpage) { build_issue_private_lastpost_sql_project($this->registry->userinfo, $this->project['projectid'], $private_lastpost_join, $private_lastpost_fields); $replycount_clause = fetch_private_replycount_clause($this->registry->userinfo, $this->project['projectid']); $marking = ($this->registry->options['threadmarking'] and $this->registry->userinfo['userid']); if (!$criteria) { $criteria = '1=1'; } do { if (!$pagenumber) { $pagenumber = 1; } $start = ($pagenumber - 1) * $perpage; // issue list $this->result = $this->registry->db->query_read("\r\n\t\t\t\tSELECT\r\n\t\t\t\t\t" . ($this->calc_total_rows ? "SQL_CALC_FOUND_ROWS" : '') . "\r\n\t\t\t\t\tissue.*, issuedeletionlog.reason AS deletionreason\r\n\t\t\t\t\t" . ($this->registry->userinfo['userid'] ? ", issuesubscribe.subscribetype, IF(issueassign.issueid IS NULL, 0, 1) AS isassigned" : '') . "\r\n\t\t\t\t\t" . ($marking ? ", issueread.readtime AS issueread, projectread.readtime AS projectread" : '') . "\r\n\t\t\t\t\t" . ($private_lastpost_fields ? ", {$private_lastpost_fields}" : '') . "\r\n\t\t\t\t\t" . ($replycount_clause ? ", {$replycount_clause} AS replycount" : '') . "\r\n\t\t\t\t\t{$this->extra_fields}\r\n\t\t\t\tFROM " . TABLE_PREFIX . "pt_issue AS issue\r\n\t\t\t\tLEFT JOIN " . TABLE_PREFIX . "pt_issuedeletionlog AS issuedeletionlog ON\r\n\t\t\t\t\t(issuedeletionlog.primaryid = issue.issueid AND issuedeletionlog.type = 'issue')\r\n\t\t\t\tLEFT JOIN " . TABLE_PREFIX . "pt_projectversion AS projectversion ON\r\n\t\t\t\t\t(projectversion.projectversionid = issue.appliesversionid)\r\n\t\t\t\t" . ($this->registry->userinfo['userid'] ? "\r\n\t\t\t\t\tLEFT JOIN " . TABLE_PREFIX . "pt_issuesubscribe AS issuesubscribe ON\r\n\t\t\t\t\t\t(issuesubscribe.issueid = issue.issueid AND issuesubscribe.userid = " . $this->registry->userinfo['userid'] . ")\r\n\t\t\t\t\tLEFT JOIN " . TABLE_PREFIX . "pt_issueassign AS issueassign ON\r\n\t\t\t\t\t\t(issueassign.issueid = issue.issueid AND issueassign.userid = " . $this->registry->userinfo['userid'] . ")\r\n\t\t\t\t" : '') . "\r\n\t\t\t\t" . ($marking ? "\r\n\t\t\t\t\tLEFT JOIN " . TABLE_PREFIX . "pt_issueread AS issueread ON (issueread.issueid = issue.issueid AND issueread.userid = " . $this->registry->userinfo['userid'] . ")\r\n\t\t\t\t\tLEFT JOIN " . TABLE_PREFIX . "pt_projectread as projectread ON (projectread.projectid = issue.projectid AND projectread.userid = " . $this->registry->userinfo['userid'] . " AND projectread.issuetypeid = issue.issuetypeid)\r\n\t\t\t\t" : '') . "\r\n\t\t\t\t\t{$private_lastpost_join}\r\n\t\t\t\t\t{$this->extra_joins}\r\n\t\t\t\tWHERE {$criteria}\r\n\t\t\t\tORDER BY {$this->sort_field_sql} {$this->sort_order}, issue.lastpost DESC\r\n\t\t\t\tLIMIT {$start}, {$perpage}\r\n\t\t\t"); if (!$this->calc_total_rows) { break; } list($this->total_rows) = $this->registry->db->query_first("SELECT FOUND_ROWS()", DBARRAY_NUM); if ($start >= $this->total_rows) { $pagenumber = ceil($this->total_rows / $perpage); } } while ($start >= $this->total_rows and $this->total_rows); $this->real_pagenumber = $pagenumber; }
if (!$vbulletin->GPC['pagenumber']) { $vbulletin->GPC['pagenumber'] = 1; } if (!$vbulletin->GPC['start']) { $vbulletin->GPC['start'] = ($vbulletin->GPC['pagenumber'] - 1) * $perpage; } // setup the sort arrow $opposite_sort = $search['sortorder'] == 'asc' ? 'desc' : 'asc'; $sort_arrow = array('title' => '', 'priority' => '', 'replies' => '', 'lastpost' => ''); eval('$sort_arrow["$search[sortby]"] = "' . fetch_template('pt_searchresultgroupbit_arrow') . '";'); if (!$perpage) { $perpage = 999999; } $marking = ($vbulletin->options['threadmarking'] and $vbulletin->userinfo['userid']); build_issue_private_lastpost_sql_all($vbulletin->userinfo, $private_lastpost_join, $private_lastpost_fields); $replycount_clause = fetch_private_replycount_clause($vbulletin->userinfo); $show['first_group'] = true; $resultgroupbits = ''; foreach ($groups as $groupid => $group) { $group_only = ($vbulletin->GPC['groupid'] and $vbulletin->GPC['groupid'] == $groupid); $hook_query_fields = $hook_query_joins = $hook_query_where = ''; ($hook = vBulletinHook::fetch_hook('projectsearch_results_query')) ? eval($hook) : false; $results = $db->query_read("\r\n\t\t\tSELECT issue.*, issuesearchresult.offset\r\n\t\t\t\t" . ($vbulletin->userinfo['userid'] ? ", issuesubscribe.subscribetype, IF(issueassign.issueid IS NULL, 0, 1) AS isassigned" : '') . "\r\n\t\t\t\t" . ($marking ? ", issueread.readtime AS issueread, projectread.readtime AS projectread" : '') . "\r\n\t\t\t\t" . ($private_lastpost_fields ? ", {$private_lastpost_fields}" : '') . "\r\n\t\t\t\t" . ($replycount_clause ? ", {$replycount_clause} AS replycount" : '') . "\r\n\t\t\t\t{$hook_query_fields}\r\n\t\t\tFROM " . TABLE_PREFIX . "pt_issuesearchresult AS issuesearchresult\r\n\t\t\tINNER JOIN " . TABLE_PREFIX . "pt_issue AS issue ON (issuesearchresult.issueid = issue.issueid)\r\n\t\t\t" . ($vbulletin->userinfo['userid'] ? "\r\n\t\t\t\tLEFT JOIN " . TABLE_PREFIX . "pt_issuesubscribe AS issuesubscribe ON\r\n\t\t\t\t\t(issuesubscribe.issueid = issue.issueid AND issuesubscribe.userid = " . $vbulletin->userinfo['userid'] . ")\r\n\t\t\t\tLEFT JOIN " . TABLE_PREFIX . "pt_issueassign AS issueassign ON\r\n\t\t\t\t\t(issueassign.issueid = issue.issueid AND issueassign.userid = " . $vbulletin->userinfo['userid'] . ")\r\n\t\t\t" : '') . "\r\n\t\t\t" . ($marking ? "\r\n\t\t\t\tLEFT JOIN " . TABLE_PREFIX . "pt_issueread AS issueread ON (issueread.issueid = issue.issueid AND issueread.userid = " . $vbulletin->userinfo['userid'] . ")\r\n\t\t\t\tLEFT JOIN " . TABLE_PREFIX . "pt_projectread AS projectread ON (projectread.projectid = issue.projectid AND projectread.userid = " . $vbulletin->userinfo['userid'] . " AND projectread.issuetypeid = issue.issuetypeid)\r\n\t\t\t" : '') . "\r\n\t\t\t{$private_lastpost_join}\r\n\t\t\t{$hook_query_joins}\r\n\t\t\tWHERE issuesearchresult.issuesearchid = {$search['issuesearchid']}\r\n\t\t\t\t" . (!$group_only ? " AND issuesearchresult.offset >= " . $vbulletin->GPC['start'] : '') . "\r\n\t\t\t\t" . ($groupid != -1 ? " AND issuesearchresult.groupid = '" . $db->escape_string($groupid) . "'" : '') . "\r\n\t\t\t\tAND ((" . implode(') OR (', $search_perms) . "))\r\n\t\t\t\t{$hook_query_where}\r\n\t\t\tORDER BY issuesearchresult.offset\r\n\t\t\t" . ($group_only ? "LIMIT " . $vbulletin->GPC['start'] . ", {$perpage}" : "LIMIT {$perpage}") . "\r\n\t\t"); $resultbits = ''; while ($issue = $db->fetch_array($results)) { $resultbits .= build_pt_search_resultbit($issue); } if (!$resultbits) { continue; } if ($search['groupby']) {