t('Table used to store data for module "issue_tracker".'), 'fields' => array( 'nid' => array( 'description' => t('The primary identifier for a node.'), 'type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE), 'issue_id' => array( 'description' => t('Unique ID for issues.'), 'type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0), ), // end fields 'primary key' => array('nid') ); $schema['issue_filter'] = array( 'description' => t('Table used to store filter related data for module "issue_tracker".'), 'fields' => array( 'fid' => array( 'description' => t('The primary identifier for a node.'), 'type' => 'serial', 'unsigned' => TRUE, 'not null' => TRUE), 'uid' => array( 'description' => t('Unique ID for issues.'), 'type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0), 'name' => array( 'description' => t('Name of the filter.'), 'type' => 'varchar', 'length' => 128, 'not null' => TRUE, 'default' => ''), 'url' => array( 'description' => t('URL for issues.'), 'type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => ''), ), // end fields 'primary key' => array('fid') ); return $schema; } /** * Creates required database tables */ function issue_tracker_install() { drupal_install_schema('issue_tracker'); } /** * Remove tables, sequence on uninstall. */ function issue_tracker_uninstall() { drupal_uninstall_schema('issue_tracker'); } /** * Update #1, 2009-11-04 * Add auto-increment to `issue_filer`.`fid` */ function issue_tracker_update_6100() { $ret = array(); // Note: We have to recreate all indices that use the field that we change, // see http://api.drupal.org/api/function/db_change_field/6 db_drop_primary_key($ret, 'issue_filter'); db_change_field($ret, 'issue_filter', 'fid', 'fid', array('type' => 'serial', 'unsigned' => TRUE, 'not null' => TRUE), array('primary key' => array('fid')) ); return $ret; } /** * Update #2, 2009-11-04 * Add new access permission 'delete issue' */ function issue_tracker_update_6102() { $ret = array(); $sql_str = "UPDATE {permission} SET perm = CONCAT(perm, ', delete issue') WHERE rid = 3 OR rid = 5"; db_query($sql_str); return $ret; } /** * Update #3, 2010-06-21 * New issue-filter format * * Updates all user filters to the new format: * - use IDs of the input fields as keys * was: status=... * new: filter-status=... * * - always full tag-prefixes * was: status=open * new: filter-status=status::open * * - delimit multiple selected values by comma instead of semi-colon * was: tags=foo;bar * new: filter-tags=foo,bar */ function issue_tracker_update_6103() { $ret = array(); $tag_prefix_values = array( 'status' => 'status::', 'resolution' => 'resolution::', 'assignments' => 'assigned::', ); $filter_prefix_values = array( 'status' => 'filter-status', 'resolution' => 'filter-resolution', 'visibility' => 'filter-visibility', 'reporters' => 'filter-reporter', 'assignments' => 'filter-assignedto', 'tags' => 'filter-tags', 'text' => 'filter-text', 'sortcolumn' => 'sortcolumn', // still the same 'sortdirection' => 'sortdirection', // still the same ); $temp_prefix = $filter_prefix_values; unset($temp_prefix['sortcolumn']); unset($temp_prefix['sortdirection']); $new_filter_prefixes = array_values($temp_prefix); $sql_str = "SELECT * FROM {issue_filter}"; $result = db_query($sql_str); $new_filters = array(); while ($row = db_fetch_array($result)) { $url = $row['url']; $new_parameters = array(); // split params $parameters = preg_split("/\&/", $url, -1, PREG_SPLIT_NO_EMPTY); foreach ($parameters as $p) { // split keys from values $key_value = preg_split("/=/", $p, -1, PREG_SPLIT_NO_EMPTY); if (count($key_value) > 1) { $filter_key = $key_value[0]; // check if the key is included in the new prefixes // if so, this filter is already updated, so skip it. if (!in_array($filter_key, $new_filter_prefixes)) { // split multiple selected values, e.g. "status=open;closed" $values = preg_split("/;/", $key_value[1], -1, PREG_SPLIT_NO_EMPTY); $tag_prefix = $tag_prefix_values[$filter_key]; $key_prefix = $filter_prefix_values[$filter_key]; foreach ($values as &$v) { $v = $tag_prefix . $v; } $new_parameters[] = $key_prefix . '=' . implode(',', $values); } else { // we read a new parameter key => skip this filter break; } } } if (count($new_parameters) > 0) { $new_filters[$row['fid']] = implode('&', $new_parameters); } } foreach ($new_filters as $fid => $url) { db_query("UPDATE {issue_filter} SET `url`='%s' WHERE fid=%s", $url, $fid); } return $ret; }