nid; } /** * Utility function for retrieving an issue node from the corresponding issue ID. * This function is mainly used when processing incoming RPC calls from the backend, * where we don't have access to the node-id. * * @param $id The issue's ID * @return Drupal node of the issue */ function _node_from_issue_id($id) { $nid = _nid_from_issue_id($id); return node_load($nid); } /** * Utility function for retrieving an issue's ID (i.e. the issue numbers visible in the frontend). * Counterpart to function `_nid_from_issue_id'. * * @param $nid Drupal node ID * @return int The issue's ID */ function _issue_id_from_nid($nid) { $result = db_query("SELECT issue_id FROM {issues} WHERE nid=%d", $nid); $row = db_fetch_object($result); return (int)$row->issue_id; } /** * Utility function for retrieving an issue's ID (i.e. the issue numbers visible in the frontend). * Counterpart to function `_node_from_issue_id'. * * @param $node Drupal node of the issue * @return int The issue's ID */ function _issue_id_from_node($node) { return _issue_id_from_nid($node->nid); } function gmgetdate($ts = NULL) { $k = array('seconds', 'minutes', 'hours', 'mday', 'wday', 'mon', 'year', 'yday', 'weekday', 'month', 0); return (array_combine($k, split(":", gmdate('s:i:G:j:w:n:Y:z:l:F:U', is_null($ts) ? time() : $ts)))); } /** * Utility function for retrieving the vocabulary ID (vid) of "Issue Tags", * i.e. of the taxonomy items of issues. * * @return Integer The vid of Issue Tags. */ function _issue_tracker_get_issue_vocabulary_id() { global $issue_vid; if (!isset($issue_vid)) { $vocab = taxonomy_get_vocabularies('issue'); $issue_vid = key($vocab); return $issue_vid; } else { return $issue_vid; } } // utility variable for caching the issue-vid. global $issue_vid; /** * Utility function for retrieving the filter-format ID for issues. * Note that we search for Mediawiki-Filter, as Origo uses this filter with issue nodes. * * @return Integer The format-ID for Issues. */ function _issue_tracker_get_filter_format_id() { global $issue_filter_format_id; // lazy load issue filter format id if (!isset($issue_filter_format_id)) { $list = filter_formats(); $issue_filter_format_id = 0; foreach ($list as $filter) { if ($filter->name == "Mediawiki format") { $issue_filter_format_id = $filter->format; break; } } } return $issue_filter_format_id; } // utility variable for caching the filter-format ID of issues. global $issue_filter_format_id; /** * Access callback for an issue's 'Delete' tab. */ function _issue_tracker_delete_tab_access($node) { if ($node->nid && _issue_tracker_delete_tab_enabled($node->type)) { return user_access('delete issue'); } return FALSE; } /** * Utility function for building the issue-header, i.e. a single line * containing a link to the 'create issue' page, and a goto-issue input box. * * @return The formatted HTML string denoting the issue header. */ function _issue_tracker_build_issue_header() { $header_row_list[] = l('Create new issue report', 'node/add/issue'); $header_row_list[] = 'Go to issue #'. drupal_get_form('issue_tracker_goto_form'); $header_row_css = array('class' => 'horizontal_list'); return theme_item_list($header_row_list, NULL, 'ul', $header_row_css); } function attachments_contain_file($attachments, $filename) { if (!is_array($attachments)) { return FALSE; } else { foreach ($attachments as $attachment) { if (strcmp($attachment['file_name'], $filename) == 0) { return TRUE; } } } return FALSE; }